From 15a627f4618651a8f9aec266791227b0cf709211 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Wed, 24 Mar 2010 18:59:28 +0100 Subject: [PATCH] feature #198: Removed some unused directories --- .../client/virtualMachine/VirtualMachine.java | 395 ------------------ .../virtualMachine/VirtualMachinePool.java | 129 ------ .../client/virtualNetwork/VirtualNetwork.java | 126 ------ .../virtualNetwork/VirtualNetworkPool.java | 128 ------ 4 files changed, 778 deletions(-) delete mode 100644 src/oca/java/src/org/opennebula/client/virtualMachine/VirtualMachine.java delete mode 100644 src/oca/java/src/org/opennebula/client/virtualMachine/VirtualMachinePool.java delete mode 100644 src/oca/java/src/org/opennebula/client/virtualNetwork/VirtualNetwork.java delete mode 100644 src/oca/java/src/org/opennebula/client/virtualNetwork/VirtualNetworkPool.java diff --git a/src/oca/java/src/org/opennebula/client/virtualMachine/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/virtualMachine/VirtualMachine.java deleted file mode 100644 index 2a416f54e8..0000000000 --- a/src/oca/java/src/org/opennebula/client/virtualMachine/VirtualMachine.java +++ /dev/null @@ -1,395 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.opennebula.client.virtualMachine; - - -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.PoolElement; -import org.w3c.dom.Node; - -/** - * This class represents an OpenNebula VM. - * It also offers static XML-RPC call wrappers. - */ -public class VirtualMachine extends PoolElement{ - - private static final String METHOD_PREFIX = "vm."; - private static final String ALLOCATE = METHOD_PREFIX + "allocate"; - private static final String INFO = METHOD_PREFIX + "info"; - private static final String DEPLOY = METHOD_PREFIX + "deploy"; - private static final String ACTION = METHOD_PREFIX + "action"; - private static final String MIGRATE = METHOD_PREFIX + "migrate"; - - private static final String[] VM_STATES = - { - "INIT", - "PENDING", - "HOLD", - "ACTIVE", - "STOPPED", - "SUSPENDED", - "DONE", - "FAILED" }; - - private static final String[] SHORT_VM_STATES = - { - "init", - "pend", - "hold", - "actv", - "stop", - "susp", - "done", - "fail" }; - - private static final String[] LCM_STATE = - { - "LCM_INIT", - "PROLOG", - "BOOT", - "RUNNING", - "MIGRATE", - "SAVE_STOP", - "SAVE_SUSPEND", - "SAVE_MIGRATE", - "PROLOG_MIGRATE", - "PROLOG_RESUME", - "EPILOG_STOP", - "EPILOG", - "SHUTDOWN", - "CANCEL", - "FAILURE", - "DELETE", - "UNKNOWN" }; - - private static final String[] SHORT_LCM_STATES = - { - null, - "prol", - "boot", - "runn", - "migr", - "save", - "save", - "save", - "migr", - "prol", - "epil", - "epil", - "shut", - "shut", - "fail", - "dele", - "unkn" }; - - /** - * Creates a new VM representation. - * - * @param id The virtual machine Id (vid). - * @param client XML-RPC Client. - */ - public VirtualMachine(int id, Client client) - { - super(id, client); - } - - /** - * @see PoolElement - */ - protected VirtualMachine(Node xmlElement, Client client) - { - super(xmlElement, client); - } - - - // ================================= - // Static XML-RPC methods - // ================================= - - /** - * Allocates a new VM in OpenNebula. - * - * @param client XML-RPC Client. - * @param description A string containing the template of the vm. - * @return If successful the message contains the associated - * id generated for this VM. - */ - public static OneResponse allocate(Client client, String description) - { - return client.call(ALLOCATE, description); - } - - /** - * Retrieves the information of the given VM. - * - * @param client XML-RPC Client. - * @param id The virtual machine id (vid) of the target instance. - * @return If successful the message contains the string - * with the information returned by OpenNebula. - */ - public static OneResponse info(Client client, int id) - { - return client.call(INFO, id); - } - - - // ================================= - // Instanced object XML-RPC methods - // ================================= - - /** - * Loads the xml representation of the virtual machine. - * The info is also stored internally. - * - * @see VirtualMachine#info(Client, int) - */ - public OneResponse info() - { - OneResponse response = info(client, id); - super.processInfo(response); - return response; - } - - /** - * Initiates the instance of the VM on the target host. - * - * @param hostId The host id (hid) of the target host where - * the VM will be instantiated. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse deploy(int hostId) - { - return client.call(DEPLOY, id, hostId); - } - - /** - * Submits an action to be performed on the virtual machine. - *
- * It is recommended to use the helper methods instead: - * - * - * @param action The action name to be performed, can be:
- * "shutdown", "hold", "release", "stop", "cancel", "suspend", - * "resume", "restart", "finalize". - * @return If an error occurs the error message contains the reason. - */ - protected OneResponse action(String action) - { - return client.call(ACTION, action, id); - } - - /** - * Migrates the virtual machine to the target host (hid). - * - * @param hostId The target host id (hid) where we want to migrate - * the vm. - * @param live If true we are indicating that we want livemigration, - * otherwise false. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse migrate(int hostId, boolean live) - { - return client.call(MIGRATE, id, hostId, live); - } - - - // ================================= - // Helpers - // ================================= - - /** - * Shuts down the already deployed VM. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse shutdown() - { - return action("shutdown"); - } - - /** - * Cancels the running VM. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse cancel() - { - return action("cancel"); - } - - /** - * Sets the VM to hold state. The VM will not be scheduled until it is - * released. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse hold() - { - return action("hold"); - } - - /** - * Releases a virtual machine from hold state. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse release() - { - return action("release"); - } - - /** - * Stops the virtual machine. The virtual machine state is transferred back - * to OpenNebula for a possible reschedule. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse stop() - { - return action("stop"); - } - - /** - * Suspends the virtual machine. The virtual machine state is left in the - * cluster node for resuming. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse suspend() - { - return action("suspend"); - } - - /** - * Resumes the execution of a saved VM. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse resume() - { - return action("resume"); - } - - /** - * Deletes the VM from the pool and database. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse finalizeVM() - { - return action("finalize"); - } - - /** - * Resubmits the virtual machine after failure. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse restart() - { - return action("shutdown"); - } - - - /** - * Migrates the virtual machine to the target host (hid). - *
- * It does the same as {@link VirtualMachine#migrate(int, boolean)} - * with live set to false. - * - * @param hostId The target host id (hid) where we want to migrate - * the vm. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse migrate(int hostId) - { - return migrate(hostId, false); - } - - /** - * Performs a live migration of the virtual machine to the - * target host (hid). - *
- * It does the same as {@link VirtualMachine#migrate(int, boolean)} - * with live set to true. - * - * @param hostId The target host id (hid) where we want to migrate - * the vm. - * @return If an error occurs the error message contains the reason. - */ - public OneResponse liveMigrate(int hostId) - { - return migrate(hostId, true); - } - - public int state() - { - return super.state(); - } - - /** - * Returns the VM state of the VirtualMachine (string value). - * @return The VM state of the VirtualMachine (string value). - */ - public String stateStr() - { - int state = state(); - return state != -1 ? VM_STATES[state()] : null; - } - - /** - * Returns the LCM state of the VirtualMachine (numeric value). - * @return The LCM state of the VirtualMachine (numeric value). - */ - public int lcmState() - { - String state = xpath("LCM_STATE"); - return state != null ? Integer.parseInt(state) : -1; - } - - /** - * Returns the LCM state of the VirtualMachine (string value). - * @return The LCM state of the VirtualMachine (string value). - */ - public String lcmStateStr() - { - int state = lcmState(); - return state != -1 ? LCM_STATE[state] : null; - } - - /** - * Returns the short status string for the VirtualMachine. - * @return The short status string for the VirtualMachine. - */ - public String status() - { - int state = state(); - String shortStateStr = null; - if(state != -1) - { - shortStateStr = SHORT_VM_STATES[state]; - if(shortStateStr.equals("actv")) - { - int lcmState = lcmState(); - if(lcmState != -1) - shortStateStr = SHORT_LCM_STATES[lcmState]; - } - } - return shortStateStr; - } -} diff --git a/src/oca/java/src/org/opennebula/client/virtualMachine/VirtualMachinePool.java b/src/oca/java/src/org/opennebula/client/virtualMachine/VirtualMachinePool.java deleted file mode 100644 index 5b0f3d5f9e..0000000000 --- a/src/oca/java/src/org/opennebula/client/virtualMachine/VirtualMachinePool.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.opennebula.client.virtualMachine; - -import java.util.AbstractList; -import java.util.Iterator; - - -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.Pool; -import org.opennebula.client.PoolElement; -import org.w3c.dom.Node; - -/** - * This class represents an OpenNebula VM pool. - * It also offers static XML-RPC call wrappers. - */ -public class VirtualMachinePool extends Pool implements Iterable{ - - private static final String ELEMENT_NAME = "VM"; - private static final String INFO_METHOD = "vmpool.info"; - - private int filter; - - /** - * Creates a new VM pool with the default filter flag value - * set to 0 (VMs belonging to user with UID 0) - * - * @param client XML-RPC Client. - * - * @see VirtualMachinePool#VirtualMachinePool(Client, int) - */ - public VirtualMachinePool(Client client) - { - super(ELEMENT_NAME, client); - this.filter = 0; - } - - /** - * Creates a new VM pool. - * - * @param client XML-RPC Client. - * @param filter Filter flag used by default in the method - * {@link VirtualMachinePool#info()}. Possible values: - * - */ - public VirtualMachinePool(Client client, int filter) - { - super(ELEMENT_NAME, client); - this.filter = filter; - } - - @Override - public PoolElement factory(Node node) - { - return new VirtualMachine(node, client); - } - - /** - * Retrieves all or part of the VMs in the pool. - * - * @param client XML-RPC Client. - * @param filter Filter flag. Possible values: - * - * @return If successful the message contains the string - * with the information returned by OpenNebula. - */ - public static OneResponse info(Client client, int filter) - { - return client.call(INFO_METHOD, filter); - } - - /** - * Loads the xml representation of all or part of the - * VMs in the pool. The filter used is the one set in - * the constructor. - * - * @see VirtualMachinePool#info(Client, int) - * - * @return If successful the message contains the string - * with the information returned by OpenNebula. - */ - public OneResponse info() - { - OneResponse response = info(client, filter); - super.processInfo(response); - return response; - } - - public Iterator iterator() - { - AbstractList ab = new AbstractList() - { - public int size() - { - return getLength(); - } - - public VirtualMachine get(int index) - { - return (VirtualMachine) item(index); - } - }; - - return ab.iterator(); - } -} diff --git a/src/oca/java/src/org/opennebula/client/virtualNetwork/VirtualNetwork.java b/src/oca/java/src/org/opennebula/client/virtualNetwork/VirtualNetwork.java deleted file mode 100644 index 6982498eb4..0000000000 --- a/src/oca/java/src/org/opennebula/client/virtualNetwork/VirtualNetwork.java +++ /dev/null @@ -1,126 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.opennebula.client.virtualNetwork; - - -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.PoolElement; -import org.w3c.dom.Node; - -/** - * This class represents an OpenNebula virtual network. - * It also offers static XML-RPC call wrappers. - */ -public class VirtualNetwork extends PoolElement{ - - private static final String METHOD_PREFIX = "vn."; - private static final String ALLOCATE = METHOD_PREFIX + "allocate"; - private static final String INFO = METHOD_PREFIX + "info"; - private static final String DELETE = METHOD_PREFIX + "delete"; - - - /** - * Creates a new virtual network representation. - * - * @param id The virtual network id (nid) . - * @param client XML-RPC Client. - */ - public VirtualNetwork(int id, Client client) - { - super(id, client); - } - - /** - * @see PoolElement - */ - protected VirtualNetwork(Node xmlElement, Client client) - { - super(xmlElement, client); - } - - // ================================= - // Static XML-RPC methods - // ================================= - - /** - * Allocates a new virtual network in OpenNebula. - * - * @param client XML-RPC Client. - * @param description A string containing the template - * of the virtual network. - * @return If successful the message contains the associated - * id generated for this virtual network. - */ - public static OneResponse allocate(Client client, String description) - { - return client.call(ALLOCATE, description); - } - - /** - * Retrieves the information of the given virtual network - * - * @param client XML-RPC Client. - * @param id the virtual network id (nid) for the network to - * retrieve the information from. - * @return If successful the message contains the string - * with the information returned by OpenNebula. - */ - public static OneResponse info(Client client, int id) - { - return client.call(INFO, id); - } - - /** - * Deletes a network from OpenNebula. - * - * @param client XML-RPC Client. - * @param id The virtual network id (nid) of the target network. - * @return A encapsulated response. - */ - public static OneResponse delete(Client client, int id) - { - return client.call(DELETE, id); - } - - - // ================================= - // Instanced object XML-RPC methods - // ================================= - - /** - * Loads the xml representation of the virtual network. - * The info is also stored internally. - * - * @see VirtualNetwork#info(Client, int) - */ - public OneResponse info() - { - OneResponse response = info(client, id); - super.processInfo(response); - return response; - } - - /** - * Deletes the network from OpenNebula. - * - * @return A encapsulated response. - */ - public OneResponse delete() - { - return delete(client, id); - } -} diff --git a/src/oca/java/src/org/opennebula/client/virtualNetwork/VirtualNetworkPool.java b/src/oca/java/src/org/opennebula/client/virtualNetwork/VirtualNetworkPool.java deleted file mode 100644 index cfc0dfd2d9..0000000000 --- a/src/oca/java/src/org/opennebula/client/virtualNetwork/VirtualNetworkPool.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ******************************************************************************/ -package org.opennebula.client.virtualNetwork; - -import java.util.AbstractList; -import java.util.Iterator; - - -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.Pool; -import org.opennebula.client.PoolElement; -import org.w3c.dom.Node; - -/** - * This class represents an OpenNebula Virtual Network pool. - * It also offers static XML-RPC call wrappers. - */ -public class VirtualNetworkPool extends Pool implements Iterable{ - - private static final String ELEMENT_NAME = "VNET"; - private static final String INFO_METHOD = "vnpool.info"; - - private int filter; - - /** - * Creates a new VN pool with the default filter flag value - * set to 0 (VNs belonging to user with UID 0) - * - * @param client XML-RPC Client. - * - * @see VirtualNetworkPool#VirtualNetworkPool(Client, int) - */ - public VirtualNetworkPool(Client client) - { - super(ELEMENT_NAME, client); - this.filter = 0; - } - - /** - * Creates a new VN pool. - * - * @param client XML-RPC Client. - * @param filter Filter flag used by default in the method - * {@link VirtualNetworkPool#info()}. Possible values: - *
    - *
  • <= -2: All VNs
  • - *
  • -1: Connected user's VNs
  • - *
  • >= 0: UID User's VNs
  • - *
- */ - public VirtualNetworkPool(Client client, int filter) - { - super(ELEMENT_NAME, client); - this.filter = filter; - } - - @Override - public PoolElement factory(Node node) - { - return new VirtualNetwork(node, client); - } - - /** - * Retrieves all or part of the VNs in the pool. - * - * @param client XML-RPC Client. - * @param filter Filter flag. Possible values: - *
    - *
  • <= -2: All VNs
  • - *
  • -1: Connected user's VNs
  • - *
  • >= 0: UID User's VNs
  • - *
- * @return If successful the message contains the string - * with the information returned by OpenNebula. - */ - public static OneResponse info(Client client, int filter) - { - return client.call(INFO_METHOD, filter); - } - - /** - * Loads the xml representation of all or part of the - * VNs in the pool. The filter used is the one set in - * the constructor. - * - * @see VirtualNetworkPool#info(Client, int) - * @return If successful the message contains the string - * with the information returned by OpenNebula. - */ - public OneResponse info() - { - OneResponse response = info(client, filter); - super.processInfo(response); - return response; - } - - public Iterator iterator() - { - AbstractList ab = new AbstractList() - { - public int size() - { - return getLength(); - } - - public VirtualNetwork get(int index) - { - return (VirtualNetwork) item(index); - } - }; - - return ab.iterator(); - } -}