From 51a5919be13daa3c2d46f782a8ff71052ca87d80 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 28 Nov 2012 23:32:31 -0800 Subject: [PATCH 001/145] devcloud: fix configuations for default devcloud.sql Patch moves config. info from cfg file to .sql file. Adds more options so DevCloud can run on host-only IPs and cidr. Signed-off-by: Rohit Yadav --- tools/devcloud/devcloud.cfg | 30 ------------------------------ tools/devcloud/devcloud.sql | 8 ++++++++ 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/tools/devcloud/devcloud.cfg b/tools/devcloud/devcloud.cfg index d0ea32c36aa..8d296eb7b98 100644 --- a/tools/devcloud/devcloud.cfg +++ b/tools/devcloud/devcloud.cfg @@ -80,36 +80,6 @@ "file": "/tmp/testcase.log" } ], - "globalConfig": [ - { - "name": "expunge.workers", - "value": "3" - }, - { - "name": "expunge.delay", - "value": "60" - }, - { - "name": "expunge.interval", - "value": "60" - }, - { - "name":"enable.ec2.api", - "value":"true" - }, - { - "name":"system.vm.use.local.storage", - "value":"true" - }, - { - "name":"enable.s3.api", - "value":"true" - }, - { - "name":"host", - "value":"192.168.56.1" - } - ], "mgtSvr": [ { "mgtSvrIp": "127.0.0.1", diff --git a/tools/devcloud/devcloud.sql b/tools/devcloud/devcloud.sql index 6bcbcf7e6c5..cebf5a3702e 100644 --- a/tools/devcloud/devcloud.sql +++ b/tools/devcloud/devcloud.sql @@ -26,6 +26,14 @@ INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','cons INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','ssvm.ram.size','100'); INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','ssvm.cpu.mhz','100'); INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'system.vm.use.local.storage', 'true'); +INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.workers', '3'); +INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.delay', '60'); +INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'expunge.interval', '60'); +INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'enable.ec2.api', 'true'); +INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'enable.s3.api', 'true'); +INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'host', '192.168.56.1'); +INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'management.network.cidr', '192.168.56.0/24'); +INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'secstorage.allowed.internal.sites', '192.168.56.0/8'); UPDATE `cloud`.`configuration` SET value='10' where name = 'storage.overprovisioning.factor'; UPDATE `cloud`.`configuration` SET value='10' where name = 'cpu.overprovisioning.factor'; UPDATE `cloud`.`configuration` SET value='10' where name = 'mem.overprovisioning.factor'; From 46b16e59173f5c262e60a2aabef94d6d3fa9a4fd Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Thu, 29 Nov 2012 18:26:35 +0530 Subject: [PATCH 002/145] CLOUDSTACK-557:For createFirewallRule API startport and endport are optional arguments but in UI ports are not optional --- ui/scripts/network.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 547802a1c69..a8d4f52147b 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -2302,8 +2302,8 @@ }); } }, - 'startport': { edit: true, label: 'label.start.port' }, - 'endport': { edit: true, label: 'label.end.port' }, + 'startport': { edit: true, label: 'label.start.port',isOptional: true }, + 'endport': { edit: true, label: 'label.end.port',isOptional: true }, 'icmptype': { edit: true, label: 'ICMP.type', isDisabled: true }, 'icmpcode': { edit: true, label: 'ICMP.code', isDisabled: true }, 'add-rule': { From e4a51731990c7599f92e00cd286d6ae760a98ed4 Mon Sep 17 00:00:00 2001 From: Chip Childers Date: Thu, 29 Nov 2012 12:24:42 -0500 Subject: [PATCH 003/145] CLOUDSTACK-505: Do not log the command response object for the createSSHKeyPair command. Signed-off-by: Chip Childers --- server/src/com/cloud/api/ApiServer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index a5c9ea5b1ee..7365b36622f 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -586,7 +586,11 @@ public class ApiServer implements HttpRequestHandler { return; } auditTrailSb.append(" " + HttpServletResponse.SC_OK + " "); - auditTrailSb.append(result); + if (command.equals("createSSHKeyPair")){ + auditTrailSb.append("This result was not logged because it contains sensitive data."); + } else { + auditTrailSb.append(result); + } /* * if (command.equals("queryAsyncJobResult")){ //For this command we need to also log job status and job * resultcode for From 6d8cd9f5c07f22cce33f823fd4a932a8bb098edf Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 29 Nov 2012 10:55:51 -0800 Subject: [PATCH 004/145] CLOUDSTACK-564: cloudstack UI - EIP/ELB Basic Zone - Network menu - Guest Network section - network detailView - Add Load Balancer tab - use jobid from assignToLoadBalancerRule instead of createLoadBalancerRule. --- ui/scripts/network.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index a8d4f52147b..133610546e4 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1321,7 +1321,7 @@ async: true, success: function(data) { var itemData = args.itemData; - var jobID = data.createloadbalancerruleresponse.jobid; + //var jobID = data.createloadbalancerruleresponse.jobid; //CS-16964: use jobid from assignToLoadBalancerRule instead of createLoadBalancerRule $.ajax({ url: createURL('assignToLoadBalancerRule'), @@ -1334,7 +1334,8 @@ dataType: 'json', async: true, success: function(data) { - var lbCreationComplete = false; + var jobID = data.assigntoloadbalancerruleresponse.jobid; //CS-16964: use jobid from assignToLoadBalancerRule instead of createLoadBalancerRule + var lbCreationComplete = false; args.response.success({ _custom: { From fefec372a2da48f15151bf927f78894654775d51 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 29 Nov 2012 11:02:34 -0800 Subject: [PATCH 005/145] CLOUDSTACK-565: cloudstack UI - EIP/ELB Basic Zone - Network menu > Guest Network Section > Network detailView > Add Load Balancer tab > Add VMs button: pass current login's domainId and account to listVirtualMachines API. --- ui/scripts/network.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 133610546e4..c53150d5ac2 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1190,7 +1190,7 @@ } }, - addloadBalancer: { + addloadBalancer: { // EIP/ELB Basic zone: Add Load Balancer tab in network detailView title: 'label.add.load.balancer', custom: function(args) { var context = args.context; @@ -1201,21 +1201,18 @@ listView: $.extend(true, {}, cloudStack.sections.instances, { listView: { filters: false, - dataProvider: function(args) { - var networkid; - if('vpc' in args.context) - networkid = args.context.multiData.tier; - else - networkid = args.context.ipAddresses[0].associatednetworkid; + + dataProvider: function(args) { + var data = { + page: args.page, + pageSize: pageSize, + domainid: g_domainid, + account: g_account, + networkid: args.context.networks[0].id, + listAll: true + }; - var data = { - page: args.page, - pageSize: pageSize, - networkid: networkid, - listAll: true - }; - - $.ajax({ + $.ajax({ url: createURL('listVirtualMachines'), data: data, dataType: 'json', From a28f4cac3c6e98439d92d72ed6a29f89ecc2c7b5 Mon Sep 17 00:00:00 2001 From: Hiroaki Kawai Date: Thu, 29 Nov 2012 20:23:30 +0100 Subject: [PATCH 006/145] HttpClient needs releaseConnection method call reviewboard: https://reviews.apache.org/r/8186/ Signed-off-by: Hugo Trippaers --- agent/src/com/cloud/agent/AgentShell.java | 2 + .../bridge/io/S3CAStorBucketAdapter.java | 56 +++++++++++-------- .../cloud/network/nicira/NiciraNvpApi.java | 15 ++++- .../cluster/ClusterServiceServletImpl.java | 20 +++---- .../com/cloud/maint/UpgradeManagerImpl.java | 2 + 5 files changed, 57 insertions(+), 38 deletions(-) diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java index 774f222dfb9..e3d1063e6b8 100644 --- a/agent/src/com/cloud/agent/AgentShell.java +++ b/agent/src/com/cloud/agent/AgentShell.java @@ -231,6 +231,7 @@ public class AgentShell implements IAgentShell { int response; response = client.executeMethod(method); if (response != HttpURLConnection.HTTP_OK) { + method.releaseConnection(); s_logger.warn("Retrieving from " + url + " gives response code: " + response); throw new CloudRuntimeException("Unable to download from " + url @@ -253,6 +254,7 @@ public class AgentShell implements IAgentShell { s_logger.warn("Exception while closing download stream from " + url + ", ", e); } + method.releaseConnection(); } private void loadProperties() throws ConfigurationException { diff --git a/awsapi/src/com/cloud/bridge/io/S3CAStorBucketAdapter.java b/awsapi/src/com/cloud/bridge/io/S3CAStorBucketAdapter.java index 2101afe1418..d7adc286816 100644 --- a/awsapi/src/com/cloud/bridge/io/S3CAStorBucketAdapter.java +++ b/awsapi/src/com/cloud/bridge/io/S3CAStorBucketAdapter.java @@ -58,6 +58,7 @@ import com.caringo.client.ScspResponse; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpException; import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; /** @@ -413,23 +414,26 @@ public class S3CAStorBucketAdapter implements S3BucketAdapter { } public class ScspDataSource implements DataSource { - GetMethod method; - public ScspDataSource(GetMethod m) { - method = m; + String content_type = null; + byte content[] = null; + public ScspDataSource(GetMethod method) { + Header h = method.getResponseHeader("Content-type"); + if (h != null) { + content_type = h.getValue(); + } + try{ + content = method.getResponseBody(); + }catch(IOException e){ + s_logger.error("CAStor loadObjectRange getInputStream error", e); + } } @Override public String getContentType() { - Header h = method.getResponseHeader("Content-type"); - return h==null ? null : h.getValue(); + return content_type; } @Override - public InputStream getInputStream() throws IOException { - try { - return method.getResponseBodyAsStream(); - } catch (Exception e) { - s_logger.error("CAStor loadObjectRange getInputStream error", e); - return null; - } + public InputStream getInputStream() { + return new ByteArrayInputStream(content); } @Override public String getName() { @@ -445,21 +449,27 @@ public class S3CAStorBucketAdapter implements S3BucketAdapter { @Override public DataHandler loadObjectRange(String mountedRoot, String bucket, String fileName, long startPos, long endPos) { + HttpClient httpClient = new HttpClient(s_httpClientManager); + // Create a method instance. + GetMethod method = new GetMethod(castorURL(mountedRoot, bucket, fileName)); + method.addRequestHeader("Range", "bytes=" + startPos + "-" + endPos); + int statusCode; try { - HttpClient httpClient = new HttpClient(s_httpClientManager); - // Create a method instance. - GetMethod method = new GetMethod(castorURL(mountedRoot, bucket, fileName)); - method.addRequestHeader("Range", "bytes=" + startPos + "-" + endPos); - int statusCode = httpClient.executeMethod(method); - if (statusCode < HTTP_OK || statusCode >= HTTP_UNSUCCESSFUL) { - s_logger.error("CAStor loadObjectRange response: "+ statusCode); - throw new FileNotExistException("CAStor loadObjectRange response: " + statusCode); - } - return new DataHandler(new ScspDataSource(method)); - } catch (Exception e) { + statusCode = httpClient.executeMethod(method); + } catch (HttpException e) { + s_logger.error("CAStor loadObjectRange failure", e); + throw new FileNotExistException("CAStor loadObjectRange failure: " + e); + } catch (IOException e) { s_logger.error("CAStor loadObjectRange failure", e); throw new FileNotExistException("CAStor loadObjectRange failure: " + e); } + if (statusCode < HTTP_OK || statusCode >= HTTP_UNSUCCESSFUL) { + s_logger.error("CAStor loadObjectRange response: "+ statusCode); + throw new FileNotExistException("CAStor loadObjectRange response: " + statusCode); + } + DataHandler ret = new DataHandler(new ScspDataSource(method)); + method.releaseConnection(); + return ret; } @Override diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java index 26e7e0d663c..43a6c0b5be8 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java @@ -119,6 +119,8 @@ public class NiciraNvpApi { throw new NiciraNvpApiException("Nicira NVP API login failed ", e); } catch (IOException e) { throw new NiciraNvpApiException("Nicira NVP API login failed ", e); + } finally { + pm.releaseConnection(); } if (pm.getStatusCode() != HttpStatus.SC_OK) { @@ -322,10 +324,11 @@ public class NiciraNvpApi { if (pm.getStatusCode() != HttpStatus.SC_OK) { String errorMessage = responseToErrorMessage(pm); + pm.releaseConnection(); s_logger.error("Failed to update object : " + errorMessage); throw new NiciraNvpApiException("Failed to update object : " + errorMessage); } - + pm.releaseConnection(); } private T executeCreateObject(T newObject, Type returnObjectType, String uri, Map parameters) throws NiciraNvpApiException { @@ -352,6 +355,7 @@ public class NiciraNvpApi { if (pm.getStatusCode() != HttpStatus.SC_CREATED) { String errorMessage = responseToErrorMessage(pm); + pm.releaseConnection(); s_logger.error("Failed to create object : " + errorMessage); throw new NiciraNvpApiException("Failed to create object : " + errorMessage); } @@ -361,6 +365,8 @@ public class NiciraNvpApi { result = (T)gson.fromJson(pm.getResponseBodyAsString(), TypeToken.get(newObject.getClass()).getType()); } catch (IOException e) { throw new NiciraNvpApiException("Failed to decode json response body", e); + } finally { + pm.releaseConnection(); } return result; @@ -382,9 +388,11 @@ public class NiciraNvpApi { if (dm.getStatusCode() != HttpStatus.SC_NO_CONTENT) { String errorMessage = responseToErrorMessage(dm); + dm.releaseConnection(); s_logger.error("Failed to delete object : " + errorMessage); throw new NiciraNvpApiException("Failed to delete object : " + errorMessage); } + dm.releaseConnection(); } private T executeRetrieveObject(Type returnObjectType, String uri, Map parameters) throws NiciraNvpApiException { @@ -410,6 +418,7 @@ public class NiciraNvpApi { if (gm.getStatusCode() != HttpStatus.SC_OK) { String errorMessage = responseToErrorMessage(gm); + gm.releaseConnection(); s_logger.error("Failed to retrieve object : " + errorMessage); throw new NiciraNvpApiException("Failed to retrieve object : " + errorMessage); } @@ -421,8 +430,9 @@ public class NiciraNvpApi { } catch (IOException e) { s_logger.error("IOException while retrieving response body",e); throw new NiciraNvpApiException(e); + } finally { + gm.releaseConnection(); } - return returnValue; } @@ -430,6 +440,7 @@ public class NiciraNvpApi { try { _client.executeMethod(method); if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { + method.releaseConnection(); // login and try again login(); _client.executeMethod(method); diff --git a/server/src/com/cloud/cluster/ClusterServiceServletImpl.java b/server/src/com/cloud/cluster/ClusterServiceServletImpl.java index 0c3a175c5c5..3270315785b 100644 --- a/server/src/com/cloud/cluster/ClusterServiceServletImpl.java +++ b/server/src/com/cloud/cluster/ClusterServiceServletImpl.java @@ -62,11 +62,7 @@ public class ClusterServiceServletImpl implements ClusterService { method.addParameter("stopOnError", pdu.isStopOnError() ? "1" : "0"); method.addParameter("pduType", Integer.toString(pdu.getPduType())); - try { - return executePostMethod(client, method); - } finally { - method.releaseConnection(); - } + return executePostMethod(client, method); } @Override @@ -81,15 +77,11 @@ public class ClusterServiceServletImpl implements ClusterService { method.addParameter("method", Integer.toString(RemoteMethodConstants.METHOD_PING)); method.addParameter("callingPeer", callingPeer); - try { - String returnVal = executePostMethod(client, method); - if("true".equalsIgnoreCase(returnVal)) { - return true; - } - return false; - } finally { - method.releaseConnection(); + String returnVal = executePostMethod(client, method); + if("true".equalsIgnoreCase(returnVal)) { + return true; } + return false; } private String executePostMethod(HttpClient client, PostMethod method) { @@ -115,6 +107,8 @@ public class ClusterServiceServletImpl implements ClusterService { s_logger.error("IOException from : " + _serviceUrl + ", method : " + method.getParameter("method")); } catch(Throwable e) { s_logger.error("Exception from : " + _serviceUrl + ", method : " + method.getParameter("method") + ", exception :", e); + } finally { + method.releaseConnection(); } return result; diff --git a/server/src/com/cloud/maint/UpgradeManagerImpl.java b/server/src/com/cloud/maint/UpgradeManagerImpl.java index c1ce3f0517f..7875c97ec50 100644 --- a/server/src/com/cloud/maint/UpgradeManagerImpl.java +++ b/server/src/com/cloud/maint/UpgradeManagerImpl.java @@ -131,6 +131,8 @@ public class UpgradeManagerImpl implements UpgradeManager { return "Unable to retrieve the file from " + url; } catch (final IOException e) { return "Unable to retrieve the file from " + url; + } finally { + method.releaseConnection(); } file.delete(); From 5aad7cc307404e738ac12cf83d3a72c6c4e61649 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Thu, 29 Nov 2012 13:49:20 -0700 Subject: [PATCH 007/145] Summary: Pull patch from 4.0 that skips deleting patchVbd when systemvms are stopped Detail: This patch fixed an issue with hosts trying to stop system vms that were already not running and deleting a patch disk for the system vm running on another host. It got applied to 4.0 but not master. Signed-off-by: Marcus Sorensen 1354222160 -0700 --- .../hypervisor/kvm/resource/LibvirtComputingResource.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 41ee1dd4139..b5af7841ca7 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -2651,13 +2651,14 @@ public class LibvirtComputingResource extends ServerResourceBase implements if (disk.getDeviceType() == DiskDef.deviceType.CDROM && disk.getDiskPath() != null) { cleanupDisk(conn, disk); - } else if (disk.getDiskPath() != null + } /* The clean up of patch disks should probably be done in expunge + else if (disk.getDiskPath() != null && disk.getDiskPath().contains(vmName + "-patchdisk") && vmName.matches("^[rsv]-\\d+-VM$")) { if (!_storagePoolMgr.deleteVbdByPath(disk.getDiskPath())) { s_logger.warn("failed to delete patch disk " + disk.getDiskPath()); } - } + }*/ } for (InterfaceDef iface: ifaces) { _vifDriver.unplug(iface); From 05d3f86b16e78de2f16ebcd368f662c8c8cfeb8a Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Thu, 29 Nov 2012 13:52:15 -0700 Subject: [PATCH 008/145] Summary: Fix orphaned patch disks for system VMs on KVM Detail: This patch deletes any patchdisk found when deleting root volume for system VM. BUG-ID: CLOUDSTACK-566 Bugfix-for: 4.0.1 Signed-off-by: Marcus Sorensen 1354222335 -0700 --- .../resource/LibvirtComputingResource.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index b5af7841ca7..e0187e67689 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -1271,6 +1271,25 @@ public class LibvirtComputingResource extends ServerResourceBase implements KVMStoragePool pool = _storagePoolMgr.getStoragePool(vol .getPoolUuid()); pool.deletePhysicalDisk(vol.getPath()); + String vmName = cmd.getVmName(); + String poolPath = pool.getLocalPath(); + + /* if vol is a root disk for a system vm, try to remove accompanying patch disk as well + this is a bit tricky since the patchdisk is only a LibvirtComputingResource construct + and not tracked anywhere in cloudstack */ + if (vol.getType() == Volume.Type.ROOT && vmName.matches("^[rsv]-\\d+-.+$")) { + File patchVbd = new File(poolPath + File.separator + vmName + "-patchdisk"); + if(patchVbd.exists()){ + try { + _storagePoolMgr.deleteVbdByPath(patchVbd.getAbsolutePath()); + } catch(CloudRuntimeException e) { + s_logger.warn("unable to destroy patch disk '" + patchVbd.getAbsolutePath() + + "' while removing root disk for " + vmName + " : " + e); + } + } else { + s_logger.debug("file '" +patchVbd.getAbsolutePath()+ "' not found"); + } + } return new Answer(cmd, true, "Success"); } catch (CloudRuntimeException e) { @@ -2651,14 +2670,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements if (disk.getDeviceType() == DiskDef.deviceType.CDROM && disk.getDiskPath() != null) { cleanupDisk(conn, disk); - } /* The clean up of patch disks should probably be done in expunge - else if (disk.getDiskPath() != null - && disk.getDiskPath().contains(vmName + "-patchdisk") - && vmName.matches("^[rsv]-\\d+-VM$")) { - if (!_storagePoolMgr.deleteVbdByPath(disk.getDiskPath())) { - s_logger.warn("failed to delete patch disk " + disk.getDiskPath()); - } - }*/ + } } for (InterfaceDef iface: ifaces) { _vifDriver.unplug(iface); From ec40aff931f3bbe3678751964ac75ea00328a765 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 29 Nov 2012 13:11:37 -0800 Subject: [PATCH 009/145] CLOUDSTACK-459: cloudstack UI - create network offering - When capability ElasticIp=true is passed to API, if capability associatePublicIP=true/false is not passed to API, cloudStack API will assume associatePublicIP=true. So, UI has to explicitly pass associatePublicIP=false to API if its checkbox is unchecked. --- ui/scripts/configuration.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index ef8376ddf45..bb16138726e 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -1720,7 +1720,28 @@ inputData[key] = value; } }); - + + for(var key1 in inputData) { + /* When capability ElasticIp=true is passed to API, if capability associatePublicIP is not passed to API, cloudStack API will assume associatePublicIP=true. + So, UI has to explicitly pass associatePublicIP=false to API if its checkbox is unchecked. */ + if(inputData[key1] == 'ElasticIp') { //ElasticIp checkbox is checked + var associatePublicIPExists = false; + for(var key2 in inputData) { + if(inputData[key2] == 'associatePublicIP') { + associatePublicIPExists = true; + break; //break key2 for loop + } + } + if(associatePublicIPExists == false) { //but associatePublicIP checkbox is unchecked + //UI explicitly passes associatePublicIP=false to API + inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].service'] = 'StaticNat'; + inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilitytype'] = 'associatePublicIP'; + inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilityvalue'] = false; //associatePublicIP checkbox is unchecked + } + break; //break key1 for loop + } + } + // Make supported services list inputData['supportedServices'] = $.map(serviceProviderMap, function(value, key) { return key; From 6036f73725889b3557263e1a4a80106f11217974 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Thu, 29 Nov 2012 13:34:55 -0800 Subject: [PATCH 010/145] Removed that darn exceptions when cloudstack is running in windows. It's a simple or check that was written as an and check --- .../cloud/server/ConfigurationServerImpl.java | 83 +++++++++---------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index 3c155ed0e5f..d2f0bb01a3e 100755 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -23,16 +23,13 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.math.BigInteger; import java.net.InetAddress; import java.net.UnknownHostException; -import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -86,7 +83,6 @@ import com.cloud.offerings.NetworkOfferingServiceMapVO; import com.cloud.offerings.NetworkOfferingVO; import com.cloud.offerings.dao.NetworkOfferingDao; import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.server.auth.UserAuthenticator; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.DiskOfferingVO; @@ -98,7 +94,6 @@ import com.cloud.user.User; import com.cloud.user.dao.AccountDao; import com.cloud.utils.PasswordGenerator; import com.cloud.utils.PropertiesUtil; -import com.cloud.utils.component.Adapters; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.crypt.DBEncryptionUtil; import com.cloud.utils.db.DB; @@ -266,7 +261,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { // store the public and private keys in the database updateKeyPairs(); - + // generate a random password for system vm updateSystemvmPassword(); @@ -338,7 +333,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { } // insert system user insertSql = "INSERT INTO `cloud`.`user` (id, username, password, account_id, firstname, lastname, created)" + - " VALUES (1, 'system', RAND(), 1, 'system', 'cloud', now())"; + " VALUES (1, 'system', RAND(), 1, 'system', 'cloud', now())"; txn = Transaction.currentTxn(); try { PreparedStatement stmt = txn.prepareAutoCloseStatement(insertSql); @@ -352,7 +347,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { String username = "admin"; String firstname = "admin"; String lastname = "cloud"; - + // create an account for the admin user first insertSql = "INSERT INTO `cloud`.`account` (id, account_name, type, domain_id) VALUES (" + id + ", '" + username + "', '1', '1')"; txn = Transaction.currentTxn(); @@ -540,29 +535,29 @@ public class ConfigurationServerImpl implements ConfigurationServer { if (!userid.startsWith("cloud")) { return; } - + if (!Boolean.valueOf(_configDao.getValue("system.vm.random.password"))) { - return; + return; } - String already = _configDao.getValue("system.vm.password"); - if (already == null) { - Transaction txn = Transaction.currentTxn(); - try { - String rpassword = PasswordGenerator.generatePresharedKey(8); - String wSql = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " - + "VALUES ('Hidden','DEFAULT', 'management-server','system.vm.password', '" + rpassword - + "','randmon password generated each management server starts for system vm')"; - PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql); - stmt.executeUpdate(wSql); - s_logger.info("Updated systemvm password in database"); - } catch (SQLException e) { - s_logger.error("Cannot retrieve systemvm password", e); - } - } + String already = _configDao.getValue("system.vm.password"); + if (already == null) { + Transaction txn = Transaction.currentTxn(); + try { + String rpassword = PasswordGenerator.generatePresharedKey(8); + String wSql = "INSERT INTO `cloud`.`configuration` (category, instance, component, name, value, description) " + + "VALUES ('Hidden','DEFAULT', 'management-server','system.vm.password', '" + rpassword + + "','randmon password generated each management server starts for system vm')"; + PreparedStatement stmt = txn.prepareAutoCloseStatement(wSql); + stmt.executeUpdate(wSql); + s_logger.info("Updated systemvm password in database"); + } catch (SQLException e) { + s_logger.error("Cannot retrieve systemvm password", e); + } + } + + } - } - @Override @DB public void updateKeyPairs() { @@ -570,17 +565,17 @@ public class ConfigurationServerImpl implements ConfigurationServer { String username = System.getProperty("user.name"); Boolean devel = Boolean.valueOf(_configDao.getValue("developer")); - if (!username.equalsIgnoreCase("cloud") && !devel) { + if (!username.equalsIgnoreCase("cloud") || !devel) { s_logger.warn("Systemvm keypairs could not be set. Management server should be run as cloud user, or in development mode."); return; } String already = _configDao.getValue("ssh.privatekey"); String homeDir = null; homeDir = Script.runSimpleBashScript("echo ~" + username); - if (homeDir == null) { + if (homeDir == null) { throw new CloudRuntimeException("Cannot get home directory for account: " + username); } - + if (s_logger.isInfoEnabled()) { s_logger.info("Processing updateKeyPairs"); } @@ -658,11 +653,11 @@ public class ConfigurationServerImpl implements ConfigurationServer { } s_logger.info("Going to update systemvm iso with generated keypairs if needed"); try { - injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath()); + injectSshKeysIntoSystemVmIsoPatch(pubkeyfile.getAbsolutePath(), privkeyfile.getAbsolutePath()); } catch (CloudRuntimeException e) { - if (!devel) { - throw new CloudRuntimeException(e.getMessage()); - } + if (!devel) { + throw new CloudRuntimeException(e.getMessage()); + } } } @@ -928,7 +923,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { defaultSharedSGNetworkOffering.setState(NetworkOffering.State.Enabled); defaultSharedSGNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultSharedSGNetworkOffering); - + for (Service service : defaultSharedSGNetworkOfferingProviders.keySet()) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(defaultSharedSGNetworkOffering.getId(), service, defaultSharedSGNetworkOfferingProviders.get(service)); _ntwkOfferingServiceMapDao.persist(offService); @@ -1003,7 +998,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { _ntwkOfferingServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } - + // Offering #6 NetworkOfferingVO defaultNetworkOfferingForVpcNetworks = new NetworkOfferingVO( NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks, @@ -1014,7 +1009,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { defaultNetworkOfferingForVpcNetworks.setState(NetworkOffering.State.Enabled); defaultNetworkOfferingForVpcNetworks = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworks); - + Map defaultVpcNetworkOfferingProviders = new HashMap(); defaultVpcNetworkOfferingProviders.put(Service.Dhcp, Provider.VPCVirtualRouter); defaultVpcNetworkOfferingProviders.put(Service.Dns, Provider.VPCVirtualRouter); @@ -1026,14 +1021,14 @@ public class ConfigurationServerImpl implements ConfigurationServer { defaultVpcNetworkOfferingProviders.put(Service.StaticNat, Provider.VPCVirtualRouter); defaultVpcNetworkOfferingProviders.put(Service.PortForwarding, Provider.VPCVirtualRouter); defaultVpcNetworkOfferingProviders.put(Service.Vpn, Provider.VPCVirtualRouter); - + for (Service service : defaultVpcNetworkOfferingProviders.keySet()) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO (defaultNetworkOfferingForVpcNetworks.getId(), service, defaultVpcNetworkOfferingProviders.get(service)); _ntwkOfferingServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } - + // Offering #7 NetworkOfferingVO defaultNetworkOfferingForVpcNetworksNoLB = new NetworkOfferingVO( NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB, @@ -1044,7 +1039,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { defaultNetworkOfferingForVpcNetworksNoLB.setState(NetworkOffering.State.Enabled); defaultNetworkOfferingForVpcNetworksNoLB = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetworkOfferingForVpcNetworksNoLB); - + Map defaultVpcNetworkOfferingProvidersNoLB = new HashMap(); defaultVpcNetworkOfferingProvidersNoLB.put(Service.Dhcp, Provider.VPCVirtualRouter); defaultVpcNetworkOfferingProvidersNoLB.put(Service.Dns, Provider.VPCVirtualRouter); @@ -1055,16 +1050,16 @@ public class ConfigurationServerImpl implements ConfigurationServer { defaultVpcNetworkOfferingProvidersNoLB.put(Service.StaticNat, Provider.VPCVirtualRouter); defaultVpcNetworkOfferingProvidersNoLB.put(Service.PortForwarding, Provider.VPCVirtualRouter); defaultVpcNetworkOfferingProvidersNoLB.put(Service.Vpn, Provider.VPCVirtualRouter); - + for (Service service : defaultVpcNetworkOfferingProvidersNoLB.keySet()) { NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO (defaultNetworkOfferingForVpcNetworksNoLB.getId(), service, defaultVpcNetworkOfferingProvidersNoLB.get(service)); _ntwkOfferingServiceMapDao.persist(offService); s_logger.trace("Added service for the network offering: " + offService); } - - - + + + txn.commit(); } From 2c561dd3a8d125254fc3d707360a9a7f7789e64e Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 29 Nov 2012 14:31:49 -0800 Subject: [PATCH 011/145] Summary: Removing ostypeid dependencies from tests Detail: The listOsTypes API will filter when given the ostype name as centOS 5.3. There is now no need to hardcode the uuids into the test Signed-off-by: Prasanna Santhanam 1354228309 -0800 --- test/integration/component/test_snapshots.py | 24 +++--- test/integration/smoke/test_iso.py | 31 +++++++- test/integration/smoke/test_network.py | 14 ++-- test/integration/smoke/test_routers.py | 4 +- test/integration/smoke/test_templates.py | 18 +++-- test/integration/smoke/test_vm_life_cycle.py | 12 +-- test/integration/smoke/test_volumes.py | 8 +- tools/marvin/marvin/integration/lib/base.py | 73 ++++++++++++++++++- tools/marvin/marvin/integration/lib/common.py | 44 ++++++++++- 9 files changed, 182 insertions(+), 46 deletions(-) diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py index 27c960f1b16..8659f14309a 100644 --- a/test/integration/component/test_snapshots.py +++ b/test/integration/component/test_snapshots.py @@ -105,7 +105,7 @@ class Services: "templates": { "displaytext": 'Template', "name": 'Template', - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", "templatefilter": 'self', }, "diskdevice": "/dev/xvda", @@ -117,8 +117,7 @@ class Services: "sub_lvl_dir1": "test1", "sub_lvl_dir2": "test2", "random_data": "random.data", - - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", # Cent OS 5.3 (64 bit) "sleep": 60, "timeout": 10, @@ -139,11 +138,11 @@ class TestSnapshotRootDisk(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["domainid"] = cls.domain.id cls.services["server_without_disk"]["zoneid"] = cls.zone.id - cls.services["template"] = template.id + cls.services["templates"]["ostypeid"] = template.ostypeid cls.services["zoneid"] = cls.zone.id # Create VMs, NAT Rules etc @@ -364,7 +363,7 @@ class TestSnapshots(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["domainid"] = cls.domain.id @@ -373,7 +372,7 @@ class TestSnapshots(cloudstackTestCase): cls.services["server_without_disk"]["zoneid"] = cls.zone.id - cls.services["template"] = template.id + cls.services["templates"]["ostypeid"] = template.ostypeid cls.services["zoneid"] = cls.zone.id cls.services["diskoffering"] = cls.disk_offering.id @@ -1195,12 +1194,11 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase): cls.template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["domainid"] = cls.domain.id cls.services["server"]["zoneid"] = cls.zone.id - cls.services["template"] = cls.template.id # Create VMs, NAT Rules etc cls.account = Account.create( @@ -1491,7 +1489,7 @@ class TestAccountSnapshotClean(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["server"]["zoneid"] = cls.zone.id @@ -1843,7 +1841,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["server"]["zoneid"] = cls.zone.id cls.services["server"]["diskoffering"] = cls.disk_offering.id @@ -2126,7 +2124,7 @@ class TestSnapshotLimit(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["server"]["zoneid"] = cls.zone.id @@ -2384,7 +2382,7 @@ class TestSnapshotEvents(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["server"]["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index 0215d892e5c..2c14ed9704a 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -55,7 +55,7 @@ class Services: "isextractable": True, "isfeatured": True, "ispublic": True, - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", }, "iso_2": { @@ -66,7 +66,7 @@ class Services: "isextractable": True, "isfeatured": True, "ispublic": True, - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", "mode": 'HTTP_DOWNLOAD', # Used in Extract template, value must be HTTP_DOWNLOAD }, @@ -79,7 +79,7 @@ class Services: "passwordenabled": True, "sleep": 60, "timeout": 10, - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", # CentOS 5.3 (64 bit) "mode": 'advanced' # Networking mode: Basic or Advanced @@ -103,7 +103,18 @@ class TestCreateIso(cloudstackTestCase): self.services["account"], domainid=self.domain.id ) - + # Finding the OsTypeId from Ostype + ostypes = list_os_types( + self.apiclient, + description=self.services["ostype"] + ) + if not isinstance(ostypes, list): + raise unittest.SkipTest("OSTypeId for given description not found") + + self.services["iso_1"]["ostypeid"] = ostypes[0].id + self.services["iso_2"]["ostypeid"] = ostypes[0].id + self.services["ostypeid"] = ostypes[0].id + self.cleanup = [self.account] return @@ -200,6 +211,18 @@ class TestISO(cloudstackTestCase): domainid=cls.domain.id ) cls.services["account"] = cls.account.account.name + # Finding the OsTypeId from Ostype + ostypes = list_os_types( + self.apiclient, + description=self.services["ostype"] + ) + if not isinstance(ostypes, list): + raise unittest.SkipTest("OSTypeId for given description not found") + + self.services["iso_1"]["ostypeid"] = ostypes[0].id + self.services["iso_2"]["ostypeid"] = ostypes[0].id + self.services["ostypeid"] = ostypes[0].id + cls.iso_1 = Iso.create( cls.api_client, cls.services["iso_1"], diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py index 0a3a3c3bd74..e78cc43fe33 100644 --- a/test/integration/smoke/test_network.py +++ b/test/integration/smoke/test_network.py @@ -36,7 +36,7 @@ class Services: def __init__(self): self.services = { - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", # Cent OS 5.3 (64 bit) "mode": 'advanced', # Networking mode: Basic or advanced @@ -305,7 +305,7 @@ class TestPortForwarding(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) #Create an account, network, VM and IP addresses cls.account = Account.create( @@ -604,7 +604,7 @@ class TestLoadBalancingRule(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["server"]["zoneid"] = cls.zone.id @@ -1076,7 +1076,7 @@ class TestRebootRouter(cloudstackTestCase): template = get_template( self.apiclient, self.zone.id, - self.services["ostypeid"] + self.services["ostype"] ) self.services["server"]["zoneid"] = self.zone.id @@ -1236,7 +1236,7 @@ class TestAssignRemoveLB(cloudstackTestCase): template = get_template( self.apiclient, self.zone.id, - self.services["ostypeid"] + self.services["ostype"] ) self.services["server"]["zoneid"] = self.zone.id @@ -1495,7 +1495,7 @@ class TestReleaseIP(cloudstackTestCase): template = get_template( self.apiclient, self.zone.id, - self.services["ostypeid"] + self.services["ostype"] ) self.services["server"]["zoneid"] = self.zone.id @@ -1635,7 +1635,7 @@ class TestDeleteAccount(cloudstackTestCase): template = get_template( self.apiclient, self.zone.id, - self.services["ostypeid"] + self.services["ostype"] ) self.services["server"]["zoneid"] = self.zone.id diff --git a/test/integration/smoke/test_routers.py b/test/integration/smoke/test_routers.py index 967533965ae..93dc7606ace 100644 --- a/test/integration/smoke/test_routers.py +++ b/test/integration/smoke/test_routers.py @@ -61,7 +61,7 @@ class Services: "username": "testuser", "password": "password", }, - "ostypeid":'01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", "sleep": 60, "timeout": 10, "mode": 'advanced', #Networking mode: Basic, Advanced @@ -84,7 +84,7 @@ class TestRouterServices(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py index 9a7f6b1459c..26d59f70057 100644 --- a/test/integration/smoke/test_templates.py +++ b/test/integration/smoke/test_templates.py @@ -75,12 +75,12 @@ class Services: "template_1": { "displaytext": "Cent OS Template", "name": "Cent OS Template", - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", }, "template_2": { "displaytext": "Public Template", "name": "Public template", - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", "isfeatured": True, "ispublic": True, "isextractable": True, @@ -94,7 +94,7 @@ class Services: "isextractable": False, "bootable": True, "passwordenabled": True, - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": "CentOS 5.3 (64-bit)", "mode": 'advanced', # Networking mode: Advanced, basic "sleep": 30, @@ -135,8 +135,12 @@ class TestCreateTemplate(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) + cls.services["template_1"]["ostypeid"] = template.ostypeid + cls.services["template_2"]["ostypeid"] = template.ostypeid + cls.services["ostypeid"] = template.ostypeid + cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["volume"]["diskoffering"] = cls.disk_offering.id cls.services["volume"]["zoneid"] = cls.zone.id @@ -298,7 +302,7 @@ class TestTemplates(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["virtual_machine"]["zoneid"] = cls.zone.id cls.services["volume"]["diskoffering"] = cls.disk_offering.id @@ -306,6 +310,10 @@ class TestTemplates(cloudstackTestCase): cls.services["template_2"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id + cls.services["template_1"]["ostypeid"] = template.ostypeid + cls.services["template_2"]["ostypeid"] = template.ostypeid + cls.services["ostypeid"] = template.ostypeid + cls.account = Account.create( cls.api_client, cls.services["account"], diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index a6d0c106526..50c75d109e9 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -109,7 +109,7 @@ class Services: "name": "testISO", "url": "http://iso.linuxquestions.org/download/504/1819/http/gd4.tuwien.ac.at/dsl-4.4.10.iso", # Source URL where ISO is located - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": 'CentOS 5.3 (64-bit)', "mode": 'HTTP_DOWNLOAD', # Downloading existing ISO }, "template": { @@ -123,7 +123,7 @@ class Services: "sleep": 60, "timeout": 10, #Migrate VM to hostid - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', + "ostype": 'CentOS 5.3 (64-bit)', # CentOS 5.3 (64-bit) "mode":'advanced', } @@ -143,7 +143,7 @@ class TestDeployVM(cloudstackTestCase): template = get_template( self.apiclient, zone.id, - self.services["ostypeid"] + self.services["ostype"] ) # Set Zones and disk offerings self.services["small"]["zoneid"] = zone.id @@ -245,7 +245,7 @@ class TestVMLifeCycle(cloudstackTestCase): template = get_template( cls.api_client, zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) # Set Zones and disk offerings cls.services["small"]["zoneid"] = zone.id @@ -999,7 +999,7 @@ class TestVMPasswordEnabled(cloudstackTestCase): template = get_template( cls.api_client, zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) # Set Zones and disk offerings cls.services["small"]["zoneid"] = zone.id @@ -1065,7 +1065,7 @@ class TestVMPasswordEnabled(cloudstackTestCase): "Exception: Unable to find root volume foe VM: %s" % cls.virtual_machine.id) - cls.services["template"]["ostypeid"] = cls.services["ostypeid"] + cls.services["template"]["ostype"] = cls.services["ostype"] #Create templates for Edit, Delete & update permissions testcases cls.pw_enabled_template = Template.create( cls.api_client, diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py index f8128081d39..2d0cd491672 100644 --- a/test/integration/smoke/test_volumes.py +++ b/test/integration/smoke/test_volumes.py @@ -75,8 +75,8 @@ class Services: "publicport": 22, "protocol": 'TCP', "diskdevice": "/dev/xvdb", - "ostypeid": '01853327-513e-4508-9628-f1f55db1946f', - "mode": 'advanced', + "ostype": 'CentOS 5.3 (64-bit)', + "mode": 'basic', "sleep": 60, "timeout": 10, } @@ -104,7 +104,7 @@ class TestCreateVolume(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id @@ -286,7 +286,7 @@ class TestVolumes(cloudstackTestCase): template = get_template( cls.api_client, cls.zone.id, - cls.services["ostypeid"] + cls.services["ostype"] ) cls.services["domainid"] = cls.domain.id cls.services["zoneid"] = cls.zone.id diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py index 5001dafb5ec..66754bd292f 100644 --- a/tools/marvin/marvin/integration/lib/base.py +++ b/tools/marvin/marvin/integration/lib/base.py @@ -547,7 +547,22 @@ class Template: cmd = createTemplate.createTemplateCmd() cmd.displaytext = services["displaytext"] cmd.name = "-".join([services["name"], random_gen()]) - cmd.ostypeid = services["ostypeid"] + if "ostypeid" in services: + cmd.ostypeid = services["ostypeid"] + elif "ostype" in services: + # Find OSTypeId from Os type + sub_cmd = listOsTypes.listOsTypesCmd() + sub_cmd.description = services["ostype"] + ostypes = apiclient.listOsTypes(sub_cmd) + + if not isinstance(ostypes, list): + raise Exception( + "Unable to find Ostype id with desc: %s" % + services["ostype"]) + cmd.ostypeid = ostypes[0].id + else: + raise Exception( + "Unable to find Ostype is required for creating template") cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False cmd.ispublic = services["ispublic"] if "ispublic" in services else False @@ -579,7 +594,24 @@ class Template: cmd.name = "-".join([services["name"], random_gen()]) cmd.format = services["format"] cmd.hypervisor = services["hypervisor"] - cmd.ostypeid = services["ostypeid"] + + if "ostypeid" in services: + cmd.ostypeid = services["ostypeid"] + elif "ostype" in services: + # Find OSTypeId from Os type + sub_cmd = listOsTypes.listOsTypesCmd() + sub_cmd.description = services["ostype"] + ostypes = apiclient.listOsTypes(sub_cmd) + + if not isinstance(ostypes, list): + raise Exception( + "Unable to find Ostype id with desc: %s" % + services["ostype"]) + cmd.ostypeid = ostypes[0].id + else: + raise Exception( + "Unable to find Ostype is required for registering template") + cmd.url = services["url"] if zoneid: @@ -615,7 +647,24 @@ class Template: services["name"], random_gen() ]) if random_name else services["name"] - cmd.ostypeid = services["ostypeid"] + + if "ostypeid" in services: + cmd.ostypeid = services["ostypeid"] + elif "ostype" in services: + # Find OSTypeId from Os type + sub_cmd = listOsTypes.listOsTypesCmd() + sub_cmd.description = services["ostype"] + ostypes = apiclient.listOsTypes(sub_cmd) + + if not isinstance(ostypes, list): + raise Exception( + "Unable to find Ostype id with desc: %s" % + services["ostype"]) + cmd.ostypeid = ostypes[0].id + else: + raise Exception( + "Unable to find Ostype is required for creating template") + cmd.snapshotid = snapshot.id return Template(apiclient.createTemplate(cmd).__dict__) @@ -695,7 +744,23 @@ class Iso: cmd = registerIso.registerIsoCmd() cmd.displaytext = services["displaytext"] cmd.name = services["name"] - cmd.ostypeid = services["ostypeid"] + if "ostypeid" in services: + cmd.ostypeid = services["ostypeid"] + elif "ostype" in services: + # Find OSTypeId from Os type + sub_cmd = listOsTypes.listOsTypesCmd() + sub_cmd.description = services["ostype"] + ostypes = apiclient.listOsTypes(sub_cmd) + + if not isinstance(ostypes, list): + raise Exception( + "Unable to find Ostype id with desc: %s" % + services["ostype"]) + cmd.ostypeid = ostypes[0].id + else: + raise Exception( + "Unable to find Ostype is required for creating ISO") + cmd.url = services["url"] cmd.zoneid = services["zoneid"] diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py index b1c87bcf91d..de68178d0be 100644 --- a/tools/marvin/marvin/integration/lib/common.py +++ b/tools/marvin/marvin/integration/lib/common.py @@ -29,6 +29,30 @@ from base import * import time +def wait_for_cleanup(apiclient, configs=None): + """Sleeps till the cleanup configs passed""" + + # Configs list consists of the list of global configs + if not isinstance(configs, list): + return + for config in configs: + cmd = listConfigurations.listConfigurationsCmd() + cmd.name = config + cmd.listall = True + try: + config_descs = apiclient.listConfigurations(cmd) + except Exception as e: + raise Exception("Failed to fetch configurations: %s" % e) + + if not isinstance(config_descs, list): + raise Exception("List configs didn't returned a valid data") + + config_desc = config_descs[0] + # Sleep for the config_desc.value time + time.sleep(int(config_desc.value)) + return + + def get_domain(apiclient, services=None): "Returns a default domain" @@ -79,9 +103,19 @@ def get_pod(apiclient, zoneid, services=None): raise Exception("Exception: Failed to find specified pod.") -def get_template(apiclient, zoneid, ostypeid=12, services=None): +def get_template(apiclient, zoneid, ostype, services=None): "Returns a template" + cmd = listOsTypes.listOsTypesCmd() + cmd.description = ostype + ostypes = apiclient.listOsTypes(cmd) + + if isinstance(ostypes, list): + ostypeid = ostypes[0].id + else: + raise Exception( + "Failed to find OS type with description: %s" % ostype) + cmd = listTemplates.listTemplatesCmd() cmd.templatefilter = 'featured' cmd.zoneid = zoneid @@ -265,6 +299,14 @@ def update_resource_limit(apiclient, resourcetype, account=None, return +def list_os_types(apiclient, **kwargs): + """List all os types matching criteria""" + + cmd = listOsTypes.listOsTypesCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return(apiclient.listOsTypes(cmd)) + + def list_routers(apiclient, **kwargs): """List all Routers matching criteria""" From 4b539ddcb3e37810757e74b2a6060ec6f4776e07 Mon Sep 17 00:00:00 2001 From: Talluri Date: Thu, 29 Nov 2012 14:27:42 +0530 Subject: [PATCH 012/145] Summary: Fixes marvin integration test for copy template/iso between zones Detail: This is a fix 1. to populate 'destzoneid' as part of the test data by issuing listZones API. Earlier, this is provided manually in the test data. 2. to wait till the ISO/template is downloaded & installed successfully before being deleted as part of the cleanup. BUG-ID: CLOUDSTACK-567 Reviewed-by: Prasanna Santhanam Reported-by: Prasanna Santhanam Signed-off-by: Prasanna Santhanam 1354234426 -0800 --- test/integration/component/test_templates.py | 37 ++++++++++++++++++ test/integration/smoke/test_iso.py | 38 ++++++++++++++++++- test/integration/smoke/test_templates.py | 40 +++++++++++++++++++- 3 files changed, 111 insertions(+), 4 deletions(-) diff --git a/test/integration/component/test_templates.py b/test/integration/component/test_templates.py index e6b2dd6c476..e9be63d66b8 100644 --- a/test/integration/component/test_templates.py +++ b/test/integration/component/test_templates.py @@ -283,6 +283,13 @@ class TestTemplates(cloudstackTestCase): # Get Zone, templates etc cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) + #populate second zone id for iso copy + cmd = listZones.listZonesCmd() + zones = cls.api_client.listZones(cmd) + if not isinstance(zones, list): + raise Exception("Failed to find zones.") + if len(zones) >= 2: + cls.services["destzoneid"] = zones[1].id template = get_template( cls.api_client, @@ -467,6 +474,36 @@ class TestTemplates(cloudstackTestCase): ) # Cleanup- Delete the copied template + timeout = self.services["timeout"] + while True: + time.sleep(self.services["sleep"]) + list_template_response = list_templates( + self.apiclient, + templatefilter=\ + self.services["templatefilter"], + id=self.template_2.id, + zoneid=self.services["destzoneid"] + ) + self.assertEqual( + isinstance(list_template_response, list), + True, + "Check list response returns a valid list" + ) + self.assertNotEqual( + len(list_template_response), + 0, + "Check template extracted in List Templates" + ) + + template_response = list_template_response[0] + if template_response.isready == True: + break + + if timeout == 0: + raise Exception( + "Failed to download copied template(ID: %s)" % template_response.id) + + timeout = timeout - 1 cmd = deleteTemplate.deleteTemplateCmd() cmd.id = self.template.id cmd.zoneid = self.services["destzoneid"] diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index 2c14ed9704a..fc726721c9b 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -70,8 +70,6 @@ class Services: "mode": 'HTTP_DOWNLOAD', # Used in Extract template, value must be HTTP_DOWNLOAD }, - "destzoneid": 5, - # Copy ISO from one zone to another (Destination Zone) "isfeatured": True, "ispublic": True, "isextractable": True, @@ -203,6 +201,13 @@ class TestISO(cloudstackTestCase): cls.services["iso_1"]["zoneid"] = cls.zone.id cls.services["iso_2"]["zoneid"] = cls.zone.id cls.services["sourcezoneid"] = cls.zone.id + #populate second zone id for iso copy + cmd = listZones.listZonesCmd() + zones = cls.api_client.listZones(cmd) + if not isinstance(zones, list): + raise Exception("Failed to find zones.") + if len(zones) >= 2: + cls.services["destzoneid"] = zones[1].id #Create an account, ISOs etc. cls.account = Account.create( @@ -524,6 +529,35 @@ class TestISO(cloudstackTestCase): self.debug("Cleanup copied ISO: %s" % iso_response.id) # Cleanup- Delete the copied ISO + timeout = self.services["timeout"] + while True: + time.sleep(self.services["sleep"]) + list_iso_response = list_isos( + self.apiclient, + id=self.iso_2.id, + zoneid=self.services["destzoneid"] + ) + self.assertEqual( + isinstance(list_iso_response, list), + True, + "Check list response returns a valid list" + ) + + self.assertNotEqual( + len(list_iso_response), + 0, + "Check template extracted in List ISO" + ) + + iso_response = list_iso_response[0] + if iso_response.isready == True: + break + + if timeout == 0: + raise Exception( + "Failed to download copied iso(ID: %s)" % iso_response.id) + + timeout = timeout - 1 cmd = deleteIso.deleteIsoCmd() cmd.id = iso_response.id cmd.zoneid = self.services["destzoneid"] diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py index 26d59f70057..d450a5d8122 100644 --- a/test/integration/smoke/test_templates.py +++ b/test/integration/smoke/test_templates.py @@ -87,8 +87,6 @@ class Services: "mode": "HTTP_DOWNLOAD", }, "templatefilter": 'self', - "destzoneid": 5, - # For Copy template (Destination zone) "isfeatured": True, "ispublic": True, "isextractable": False, @@ -295,6 +293,14 @@ class TestTemplates(cloudstackTestCase): # Get Zone, Domain and templates cls.domain = get_domain(cls.api_client, cls.services) cls.zone = get_zone(cls.api_client, cls.services) + #populate second zone id for iso copy + cmd = listZones.listZonesCmd() + zones = cls.api_client.listZones(cmd) + if not isinstance(zones, list): + raise Exception("Failed to find zones.") + if len(zones) >= 2: + cls.services["destzoneid"] = zones[1].id + cls.disk_offering = DiskOffering.create( cls.api_client, cls.services["disk_offering"] @@ -700,6 +706,36 @@ class TestTemplates(cloudstackTestCase): ) # Cleanup- Delete the copied template + timeout = self.services["timeout"] + while True: + time.sleep(self.services["sleep"]) + list_template_response = list_templates( + self.apiclient, + templatefilter=\ + self.services["templatefilter"], + id=self.template_2.id, + zoneid=self.services["destzoneid"] + ) + self.assertEqual( + isinstance(list_template_response, list), + True, + "Check list response returns a valid list" + ) + self.assertNotEqual( + len(list_template_response), + 0, + "Check template extracted in List Templates" + ) + + template_response = list_template_response[0] + if template_response.isready == True: + break + + if timeout == 0: + raise Exception( + "Failed to download copied template(ID: %s)" % template_response.id) + + timeout = timeout - 1 cmd = deleteTemplate.deleteTemplateCmd() cmd.id = template_response.id cmd.zoneid = self.services["destzoneid"] From 8819ec6ea7c7214ceb252db3657cfa288bbafaa8 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 30 Nov 2012 09:35:38 -0800 Subject: [PATCH 013/145] CLOUDSTACK-571: cloudstack UI - network menu - guest network section - network detailView - edit action - network offering upgrade is not allowed in Shared network. --- ui/scripts/network.js | 5 +++++ ui/scripts/sharedFunctions.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index c53150d5ac2..7d2345a1897 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -933,6 +933,11 @@ label: 'label.network.offering', isEditable: true, select: function(args){ + if (args.context.networks[0].type == 'Shared') { //Shared network is not allowed to upgrade to a different network offering + args.response.success({ data: [] }); + return; + } + if (args.context.networks[0].state == 'Destroyed') { args.response.success({ data: [] }); return; diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index b6b3ef817f6..f1b7efaa621 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -266,7 +266,7 @@ cloudStack.actionFilter = { var allowedActions = []; if(jsonObj.type == 'Isolated') { - allowedActions.push('edit'); //only Isolated network can be upgraded + allowedActions.push('edit'); //only Isolated network is allowed to upgrade to a different network offering (Shared network is not allowed to) allowedActions.push('restart'); allowedActions.push('remove'); } From 4472eca5b429071e6d275c8e546561fb0c2ac853 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Fri, 30 Nov 2012 11:36:41 -0800 Subject: [PATCH 014/145] Zone wizard UI: Fix typo in word 'Management' --- client/WEB-INF/classes/resources/messages.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index b606cce3c95..48514e8f29d 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -19,7 +19,7 @@ #new labels (begin) ********************************************************************************************** label.egress.rules=Egress rules message.acquire.new.ip.vpc=Please confirm that you would like to acquire a new IP for this VPC. -label.zoneWizard.trafficType.management=Mangement: Traffic between CloudStack\'s internal resources, including any components that communicate with the Management Server, such as hosts and CloudStack system VMs +label.zoneWizard.trafficType.management=Management: Traffic between CloudStack\'s internal resources, including any components that communicate with the Management Server, such as hosts and CloudStack system VMs label.zoneWizard.trafficType.public=Public: Traffic between the internet and virtual machines in the cloud. label.zoneWizard.trafficType.guest=Guest: Traffic between end-user virtual machines label.zoneWizard.trafficType.storage=Storage: Traffic between primary and secondary storage servers, such as VM templates and snapshots From 28cc7477b05478dbad2e5836602b8045b68b6014 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Fri, 30 Nov 2012 11:33:45 -0800 Subject: [PATCH 015/145] Zone wizard UI: Add labels on traffic type edit area For zone wizard physical network step: Adds a text label to the top of the 'edit' button indicating what type of traffic type (Management, Storage, Guest, etc.) --- ui/css/cloudstack3.css | 58 ++++++++++++++++++++++++++++++++---------- ui/index.jsp | 4 +++ 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css index 7d0a6b76894..1f862b06656 100644 --- a/ui/css/cloudstack3.css +++ b/ui/css/cloudstack3.css @@ -1449,7 +1449,7 @@ div.list-view td.state.off span { -webkit-text-shadow: 0px 1px #EAEAEA; -o-text-shadow: 0px 1px #EAEAEA; text-shadow: 0px 1px #EAEAEA; - overflow:hidden; + overflow: hidden; } .quick-view-tooltip .detail-view .detail-group table td.value input[type=text] { @@ -6498,7 +6498,7 @@ label.error { .multi-wizard.zone-wizard .select-container.multi .drop-container { background: #DAE2EC; width: 484px; - height: 100px; + height: 114px; clear: both; position: relative; /*+border-radius:4px;*/ @@ -6538,10 +6538,10 @@ label.error { text-align: center; color: #959BA0; font-size: 13px; - /*+placement:shift 0px 24px;*/ + /*+placement:shift 0px 45px;*/ position: relative; left: 0px; - top: 24px; + top: 45px; } /*** Add physical network -- traffic type drag area*/ @@ -6769,20 +6769,20 @@ label.error { border-radius: 4px; border-radius: 4px 4px 4px 4px; border-top: 1px solid #FFFFFF; - /*+placement:shift -15px 61px;*/ + /*+placement:shift -16px 70px;*/ position: relative; - left: -15px; - top: 61px; + left: -16px; + top: 70px; } .multi-wizard.zone-wizard .drop-container .traffic-type-draggable > .edit-traffic-type:hover { background-position: 0px -105px; color: #FFFFFF; - /*+box-shadow:inset 0px 2px 1px #727272;*/ - -moz-box-shadow: inset 0px 2px 1px #727272; - -webkit-box-shadow: inset 0px 2px 1px #727272; - -o-box-shadow: inset 0px 2px 1px #727272; - box-shadow: inset 0px 2px 1px #727272; + /*+box-shadow:inset 0px -1px 1px #727272;*/ + -moz-box-shadow: inset 0px -1px 1px #727272; + -webkit-box-shadow: inset 0px -1px 1px #727272; + -o-box-shadow: inset 0px -1px 1px #727272; + box-shadow: inset 0px -1px 1px #727272; } .multi-wizard.zone-wizard .drop-container .traffic-type-draggable > .edit-traffic-type:hover span { @@ -6795,10 +6795,10 @@ label.error { } .multi-wizard.zone-wizard .drop-container .traffic-type-draggable:hover > .edit-traffic-type { - /*+placement:shift -7px 67px;*/ + /*+placement:shift -7px 76px;*/ position: relative; left: -7px; - top: 67px; + top: 76px; } .multi-wizard.zone-wizard .drop-container .traffic-type-draggable .edit-traffic-type span { @@ -6819,6 +6819,36 @@ label.error { padding: 7px 11px 0 7px; } +.multi-wizard.zone-wizard .traffic-type-draggable .edit-traffic-type span.name { + float: left; + width: 76px; + font-size: 10px; + padding: 2px; + color: #4E5F6F; + background: #DBE1E9; + /*+border-radius:4px 4px 0 0;*/ + -moz-border-radius: 4px 4px 0 0; + -webkit-border-radius: 4px 4px 0 0; + -khtml-border-radius: 4px 4px 0 0; + border-radius: 4px 4px 0 0; + /*+placement:shift -13px -16px;*/ + position: relative; + left: -13px; + top: -16px; + margin-bottom: -13px; + border: 1px solid #C3BCBC; + border-bottom: 1px solid #D1CDCD; + /*+box-shadow:inset 0px 1px 1px #F5F4F4;*/ + -moz-box-shadow: inset 0px 1px 1px #F5F4F4; + -webkit-box-shadow: inset 0px 1px 1px #F5F4F4; + -o-box-shadow: inset 0px 1px 1px #F5F4F4; + box-shadow: inset 0px 1px 1px #F5F4F4; +} + +.multi-wizard.zone-wizard .traffic-type-draggable .edit-traffic-type:hover span.name { + background: #C4C3C3; +} + /*** Configure guest network -- tabs*/ .multi-wizard.zone-wizard .setup-guest-traffic .ui-widget-content { width: 682px; diff --git a/ui/index.jsp b/ui/index.jsp index 96352d76203..a9b83e6fdd5 100644 --- a/ui/index.jsp +++ b/ui/index.jsp @@ -552,6 +552,7 @@ under the License. class="traffic-type-draggable management">
+   Edit
@@ -569,6 +570,7 @@ under the License. class="traffic-type-draggable public">
+   Edit
@@ -586,6 +588,7 @@ under the License. class="traffic-type-draggable guest">
+   Edit
@@ -603,6 +606,7 @@ under the License. class="traffic-type-draggable storage">
+   Edit
From 77f80ab72de45618910ffe5a6813d35ecc7d44c7 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Fri, 30 Nov 2012 10:55:14 -0800 Subject: [PATCH 016/145] Egress UI: Make start/end port optional --- ui/scripts/network.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 7d2345a1897..7dc69925d47 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1077,8 +1077,8 @@ }); } }, - 'startport': { edit: true, label: 'label.start.port' }, - 'endport': { edit: true, label: 'label.end.port' }, + 'startport': { edit: true, label: 'label.start.port', isOptional: true }, + 'endport': { edit: true, label: 'label.end.port', isOptional: true }, 'icmptype': { edit: true, label: 'ICMP.type', isHidden: true }, 'icmpcode': { edit: true, label: 'ICMP.code', isHidden: true }, 'add-rule': { From 1aa4ad6a3c5c051ff6fcb68e0bf2bd58c9ddedcc Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Thu, 29 Nov 2012 16:15:30 -0800 Subject: [PATCH 017/145] CLOUDSTACK-572: Advance SG enabled zone - allow deploying vm in SG disabled Account specific networks Conflicts: server/src/com/cloud/vm/UserVmManagerImpl.java --- .../src/com/cloud/vm/UserVmManagerImpl.java | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 687f521e08c..1af344ff6e4 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -35,6 +35,7 @@ import org.apache.commons.codec.binary.Base64; import org.apache.log4j.Logger; import com.cloud.acl.ControlledEntity.ACLType; +import com.cloud.acl.SecurityChecker.AccessType; import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; import com.cloud.agent.api.AttachIsoCommand; @@ -2174,8 +2175,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager isSecurityGroupEnabledNetworkUsed = true; } else { - // Verify that all the networks are Direct/Guest/AccountSpecific; can't create combination of SG enabled network and - // regular networks + // Verify that all the networks are Shared/Guest; can't create combination of SG enabled and disabled networks for (Long networkId : networkIdList) { NetworkVO network = _networkDao.findById(networkId); @@ -2191,21 +2191,17 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } isSecurityGroupEnabledNetworkUsed = true; - } + } - if (network.getTrafficType() != TrafficType.Guest || network.getGuestType() != Network.GuestType.Shared || (network.getGuestType() == Network.GuestType.Shared && !isSecurityGroupEnabled)) { - throw new InvalidParameterValueException("Can specify only Direct Guest Account specific networks when deploy vm in Security Group enabled zone"); + if (!(network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Shared)) { + throw new InvalidParameterValueException("Can specify only Shared Guest networks when" + + " deploy vm in Advance Security Group enabled zone", null); } // Perform account permission check - if (network.getGuestType() != Network.GuestType.Shared) { - // Check account permissions - List networkMap = _networkDao.listBy(owner.getId(), network.getId()); - if (networkMap == null || networkMap.isEmpty()) { - throw new PermissionDeniedException("Unable to create a vm using network with id " + network.getId() + ", permission denied"); - } + if (network.getAclType() == ACLType.Account) { + _accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network); } - networkList.add(network); } } From 7857b1f62ab905790e4dd96f6b19d7d67255b56c Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Fri, 30 Nov 2012 13:03:05 -0800 Subject: [PATCH 018/145] CLOUDSTACK-573: check if external provider enabled, only when finalize the service/provider list for the network --- .../com/cloud/network/NetworkManagerImpl.java | 31 +++++++++++-------- .../element/VpcVirtualRouterElement.java | 2 +- .../src/com/cloud/vm/UserVmManagerImpl.java | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index ec0ca79e89a..9841f106523 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -23,6 +23,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Comparator; import java.util.Date; import java.util.HashMap; @@ -1672,7 +1673,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), related, name, displayText, predefined.getNetworkDomain(), offering.getGuestType(), plan.getDataCenterId(), plan.getPhysicalNetworkId(), aclType, offering.getSpecifyIpRanges(), vpcId); - networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated, + networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated, finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId()))); if (domainId != null && aclType == ACLType.Domain) { @@ -2664,10 +2665,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } - if (cidr != null && networkOfferingIsConfiguredForExternalNetworking(networkOfferingId)) { + Collection ntwkProviders = finalizeServicesAndProvidersForNetwork(ntwkOff, physicalNetworkId).values(); + if (cidr != null && providersConfiguredForExternalNetworking(ntwkProviders)) { throw new InvalidParameterValueException("Cannot specify CIDR when using network offering with external devices!"); } + // Vlan is created in 2 cases - works in Advance zone only: // 1) GuestType is Shared // 2) GuestType is Isolated, but SourceNat service is disabled @@ -4366,17 +4369,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag return false; } } - - public boolean networkOfferingIsConfiguredForExternalNetworking(long networkOfferingId) { - boolean netscalerInNetworkOffering = isProviderForNetworkOffering(Network.Provider.Netscaler, networkOfferingId); - boolean juniperInNetworkOffering = isProviderForNetworkOffering(Network.Provider.JuniperSRX, networkOfferingId); - boolean f5InNetworkOffering = isProviderForNetworkOffering(Network.Provider.F5BigIp, networkOfferingId); - - if (netscalerInNetworkOffering || juniperInNetworkOffering || f5InNetworkOffering) { - return true; - } else { - return false; + + public boolean providersConfiguredForExternalNetworking(Collection providers) { + for(String providerStr : providers){ + Provider provider = Network.Provider.getProvider(providerStr); + if(provider.isExternal()){ + return true; + } } + return false; } @Override @@ -4651,7 +4652,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } if (networkOfferingId != oldNetworkOfferingId) { - if (networkOfferingIsConfiguredForExternalNetworking(networkOfferingId) != networkOfferingIsConfiguredForExternalNetworking(oldNetworkOfferingId) + NetworkOffering oldNtwkOff = _networkOfferingDao.findByIdIncludingRemoved(oldNetworkOfferingId); + Collection newProviders = finalizeServicesAndProvidersForNetwork(networkOffering, network.getPhysicalNetworkId()).values(); + Collection oldProviders = finalizeServicesAndProvidersForNetwork(oldNtwkOff, network.getPhysicalNetworkId()).values(); + + if (providersConfiguredForExternalNetworking(newProviders) != providersConfiguredForExternalNetworking(oldProviders) && !changeCidr) { throw new InvalidParameterValueException("Updating network failed since guest CIDR needs to be changed!"); } diff --git a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java index 2a2d05a76ec..0acc47d7d88 100644 --- a/server/src/com/cloud/network/element/VpcVirtualRouterElement.java +++ b/server/src/com/cloud/network/element/VpcVirtualRouterElement.java @@ -304,7 +304,7 @@ public class VpcVirtualRouterElement extends VirtualRouterElement implements Vpc Map networkACLCapabilities = new HashMap(); networkACLCapabilities.put(Capability.SupportedProtocols, "tcp,udp,icmp"); capabilities.put(Service.NetworkACL, networkACLCapabilities); - + return capabilities; } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 1af344ff6e4..837e3f7d146 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2195,7 +2195,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (!(network.getTrafficType() == TrafficType.Guest && network.getGuestType() == Network.GuestType.Shared)) { throw new InvalidParameterValueException("Can specify only Shared Guest networks when" + - " deploy vm in Advance Security Group enabled zone", null); + " deploy vm in Advance Security Group enabled zone"); } // Perform account permission check From 751e74708e295cdfbaaea8463c0476e5f879285b Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Sun, 2 Dec 2012 10:50:14 -0800 Subject: [PATCH 019/145] Setup unittests for the nicira nvp plugin Changed the creation of the NiciraNvpApi to a factory method that can be overridden by a mock object. Setup two tests to test the configure function of the NiciraNvpResource to test this factory method. --- plugins/network-elements/nicira-nvp/pom.xml | 8 +++ .../cloud/network/nicira/NiciraNvpApi.java | 19 +++---- .../network/resource/NiciraNvpResource.java | 45 +++++++++-------- .../resource/NiciraNvpResourceTest.java | 49 +++++++++++++++++++ 4 files changed, 89 insertions(+), 32 deletions(-) create mode 100644 plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml index 70f85607e4a..294e88be9db 100644 --- a/plugins/network-elements/nicira-nvp/pom.xml +++ b/plugins/network-elements/nicira-nvp/pom.xml @@ -26,4 +26,12 @@ 4.1.0-SNAPSHOT ../../pom.xml + + + org.mockito + mockito-all + 1.9.5 + test + + diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java index 43a6c0b5be8..bfab2485b24 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java @@ -72,15 +72,7 @@ public class NiciraNvpApi { private HttpClient _client; - public NiciraNvpApi(String host, String adminuser, String adminpass) throws NiciraNvpApiException { - this._host = host; - this._adminpass = adminpass; - this._adminuser = adminuser; - - if (_host == null || _adminpass == null || _adminuser == null) { - throw new NiciraNvpApiException("host, adminuser and adminpass may not be null"); - } - + public NiciraNvpApi() { _client = new HttpClient(s_httpClientManager); _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); @@ -93,6 +85,15 @@ public class NiciraNvpApi { } + public void setControllerAddress(String address) { + this._host = address; + } + + public void setAdminCredentials(String username, String password) { + this._adminuser = username; + this._adminpass = password; + } + /** * Logs into the Nicira API. The cookie is stored in the _authcookie variable. *

diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java index c6359d37553..b297e7f979d 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java @@ -88,39 +88,25 @@ public class NiciraNvpResource implements ServerResource { private static final Logger s_logger = Logger.getLogger(NiciraNvpResource.class); private String _name; - private String _ip; - private String _adminuser; - private String _adminpass; private String _guid; private String _zoneId; private int _numRetries; private NiciraNvpApi _niciraNvpApi; + protected NiciraNvpApi createNiciraNvpApi() { + return new NiciraNvpApi(); + } + @Override public boolean configure(String name, Map params) throws ConfigurationException { - + _name = (String) params.get("name"); if (_name == null) { throw new ConfigurationException("Unable to find name"); } - _ip = (String) params.get("ip"); - if (_ip == null) { - throw new ConfigurationException("Unable to find IP"); - } - - _adminuser = (String) params.get("adminuser"); - if (_adminuser == null) { - throw new ConfigurationException("Unable to find admin username"); - } - - _adminpass = (String) params.get("adminpass"); - if (_adminpass == null) { - throw new ConfigurationException("Unable to find admin password"); - } - _guid = (String)params.get("guid"); if (_guid == null) { throw new ConfigurationException("Unable to find the guid"); @@ -133,11 +119,24 @@ public class NiciraNvpResource implements ServerResource { _numRetries = 2; - try { - _niciraNvpApi = new NiciraNvpApi(_ip, _adminuser, _adminpass); - } catch (NiciraNvpApiException e) { - throw new ConfigurationException(e.getMessage()); + String ip = (String) params.get("ip"); + if (ip == null) { + throw new ConfigurationException("Unable to find IP"); } + + String adminuser = (String) params.get("adminuser"); + if (adminuser == null) { + throw new ConfigurationException("Unable to find admin username"); + } + + String adminpass = (String) params.get("adminpass"); + if (adminpass == null) { + throw new ConfigurationException("Unable to find admin password"); + } + + _niciraNvpApi = createNiciraNvpApi(); + _niciraNvpApi.setControllerAddress(ip); + _niciraNvpApi.setAdminCredentials(adminuser,adminpass); return true; } diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java new file mode 100644 index 00000000000..9fd2cef5b9c --- /dev/null +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java @@ -0,0 +1,49 @@ +package com.cloud.network.resource; + +import static org.mockito.Mockito.*; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import javax.naming.ConfigurationException; + +import org.junit.Before; +import org.junit.Test; + +import com.cloud.network.nicira.NiciraNvpApi; + +public class NiciraNvpResourceTest { + NiciraNvpApi _nvpApi = mock(NiciraNvpApi.class); + NiciraNvpResource _resource; + + @Before + public void setUp() { + _resource = new NiciraNvpResource() { + protected NiciraNvpApi createNiciraNvpApi() { + return _nvpApi; + } + }; + } + + @Test (expected=ConfigurationException.class) + public void resourceConfigureFailure() throws ConfigurationException { + _resource.configure("NiciraNvpResource", Collections.emptyMap()); + } + + @Test + public void resourceConfigure() throws ConfigurationException { + Map parameters = new HashMap(); + parameters.put("name","nvptestdevice"); + parameters.put("ip","127.0.0.1"); + parameters.put("adminuser","adminuser"); + parameters.put("guid", "aaaaa-bbbbb-ccccc"); + parameters.put("zoneId", "blublub"); + parameters.put("adminpass","adminpass"); + _resource.configure("NiciraNvpResource", parameters); + + verify(_nvpApi).setAdminCredentials("adminuser", "adminpass"); + verify(_nvpApi).setControllerAddress("127.0.0.1"); + } + +} From 0902f60c61b311a933d01205cd481e9e367d6630 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Sun, 2 Dec 2012 11:19:32 -0800 Subject: [PATCH 020/145] Quickly add the license header before Chip finds out. --- .../resource/NiciraNvpResourceTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java index 9fd2cef5b9c..7632703aecd 100644 --- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java @@ -1,5 +1,22 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 com.cloud.network.resource; +import static org.junit.Assert.*; import static org.mockito.Mockito.*; import java.util.Collections; @@ -11,6 +28,7 @@ import javax.naming.ConfigurationException; import org.junit.Before; import org.junit.Test; +import com.cloud.host.Host; import com.cloud.network.nicira.NiciraNvpApi; public class NiciraNvpResourceTest { @@ -44,6 +62,13 @@ public class NiciraNvpResourceTest { verify(_nvpApi).setAdminCredentials("adminuser", "adminpass"); verify(_nvpApi).setControllerAddress("127.0.0.1"); + + assertTrue("nvptestdevice".equals(_resource.getName())); + + /* Pretty lame test, but here to assure this plugin fails + * if the type name ever changes from L2Networking + */ + assertTrue(_resource.getType() == Host.Type.L2Networking); } } From 1aecd7b42a2b58175b5f81332b133f8125923656 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 4 Dec 2012 10:39:27 -0800 Subject: [PATCH 021/145] Egress UI: Make ICMP type/code optional --- ui/scripts/network.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 7dc69925d47..726790c4aa2 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1079,8 +1079,8 @@ }, 'startport': { edit: true, label: 'label.start.port', isOptional: true }, 'endport': { edit: true, label: 'label.end.port', isOptional: true }, - 'icmptype': { edit: true, label: 'ICMP.type', isHidden: true }, - 'icmpcode': { edit: true, label: 'ICMP.code', isHidden: true }, + 'icmptype': { edit: true, label: 'ICMP.type', isHidden: true, isOptional: true }, + 'icmpcode': { edit: true, label: 'ICMP.code', isHidden: true, isOptional: true }, 'add-rule': { label: 'label.add', addButton: true From 2514b92e4bd86b0dabfa2d5927699d0a5fdb0692 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 4 Dec 2012 10:46:25 -0800 Subject: [PATCH 022/145] Add VPC: Don't list SG-enabled zones Conflicts: ui/scripts/network.js --- ui/scripts/network.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 726790c4aa2..6bd38a318f3 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -4155,10 +4155,10 @@ url: createURL('listZones'), data: data, success: function(json) { - var zones = json.listzonesresponse.zone; - var advZones = $.grep(zones, function(zone) { - return zone.networktype == 'Advanced'; - }); + var zones = json.listzonesresponse.zone; + var advZones = $.grep(zones, function(zone) { + return zone.networktype == 'Advanced' && ! zone.securitygroupsenabled; + }); args.response.success({ data: $.map(advZones, function(zone) { return { From 4bab97be3e23bceea70dff5977172593e2fe8dac Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 4 Dec 2012 11:06:35 -0800 Subject: [PATCH 023/145] Hide acquire new IP button if in advanced SG zone --- ui/scripts/network.js | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 6bd38a318f3..136315444eb 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1440,28 +1440,34 @@ addRow: 'true', preFilter: function(args) { var zoneObj; - var dataObj = {}; - if('vpc' in args.context) { //from VPC section - $.extend(dataObj, { - id: args.context.vpc[0].zoneid - }); - } - else if('networks' in args.context) { //from Guest Network section - $.extend(dataObj, { - id: args.context.networks[0].zoneid - }); - } + var dataObj = {}; + + if ('vpc' in args.context) { //from VPC section + $.extend(dataObj, { + id: args.context.vpc[0].zoneid + }); + } else if ('networks' in args.context) { //from Guest Network section + $.extend(dataObj, { + id: args.context.networks[0].zoneid + }); + } $.ajax({ url: createURL('listZones'), data: dataObj, + // id: args.context.networks[0].zoneid + // }, async: false, success: function(json) { zoneObj = json.listzonesresponse.zone[0]; } }); + + if (zoneObj.networktype == 'Advanced' && zoneObj.securitygroupsenabled) { + return false; + } - if(zoneObj.networktype == 'Basic') { + if (zoneObj.networktype == 'Basic') { var havingEIP = false, havingELB = false; $.ajax({ url: createURL('listNetworkOfferings'), @@ -1469,20 +1475,19 @@ id: args.context.networks[0].networkofferingid }, async: false, - success: function(json) { + success: function(json) { $(json.listnetworkofferingsresponse.networkoffering[0].service).each(function(){ var thisService = this; - if(thisService.name == "StaticNat") { + if (thisService.name == "StaticNat") { $(thisService.capability).each(function(){ - if(this.name == "ElasticIp" && this.value == "true") { + if (this.name == "ElasticIp" && this.value == "true") { havingEIP = true; return false; //break $.each() loop } }); - } - else if(thisService.name == "Lb") { + } else if (thisService.name == "Lb") { $(thisService.capability).each(function(){ - if(this.name == "ElasticLb" && this.value == "true") { + if (this.name == "ElasticLb" && this.value == "true") { havingELB = true; return false; //break $.each() loop } From 5f1f1e7534ae76c3209c18b74b08f227efcb1696 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 4 Dec 2012 11:22:52 -0800 Subject: [PATCH 024/145] Don't show egress tab for advanced SG zones --- ui/scripts/network.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 136315444eb..7cdf9771c28 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -805,7 +805,10 @@ var networkOfferingHavingELB = false; var hasNetworkACL = false; var isVPC = false; - + var isAdvancedSGZone = false; + var hiddenTabs = []; + + // Get network offering data $.ajax({ url: createURL("listNetworkOfferings&id=" + args.context.networks[0].networkofferingid), dataType: "json", @@ -833,13 +836,25 @@ } }); - var hiddenTabs = []; - + // Get zone data + $.ajax({ + url: createURL('listZones'), + data: { + id: args.context.networks[0].zoneid + }, + async: false, + success: function(json) { + var zone = json.listzonesresponse.zone[0]; + + isAdvancedSGZone = zone.securitygroupsenabled; + } + }); + if (!networkOfferingHavingELB) { hiddenTabs.push("addloadBalancer"); } - if (isVPC) { + if (isVPC || isAdvancedSGZone) { hiddenTabs.push('egressRules'); } From 13211417976fa1b6c5dd8b7e3ddd95ab21486082 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Tue, 4 Dec 2012 11:33:43 -0800 Subject: [PATCH 025/145] Fix updateZone fail if guest CIDR field is blank --- ui/scripts/system.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 516111b392a..589739be49b 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -4348,8 +4348,11 @@ array1.push("&name=" +todb(args.data.name)); array1.push("&dns1=" + todb(args.data.dns1)); array1.push("&dns2=" + todb(args.data.dns2)); //dns2 can be empty ("") when passed to API - if(selectedZoneObj.networktype == "Advanced"){ - array1.push("&guestcidraddress=" +todb(args.data.guestcidraddress)); } + + if (selectedZoneObj.networktype == "Advanced" && args.data.guestcidraddress) { + array1.push("&guestcidraddress=" + todb(args.data.guestcidraddress)); + } + array1.push("&internaldns1=" + todb(args.data.internaldns1)); array1.push("&internaldns2=" + todb(args.data.internaldns2)); //internaldns2 can be empty ("") when passed to API array1.push("&domain=" + todb(args.data.domain)); From 40682fc43dc202b1dbffb4fd32388ad1a46f6e6a Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 5 Dec 2012 05:24:46 -0800 Subject: [PATCH 026/145] CLOUDSTACK-587: use setMemoryLimits instead --- .../cloud/hypervisor/xen/resource/CitrixResourceBase.java | 6 +----- .../cloud/hypervisor/xen/resource/XenServer56Resource.java | 5 ----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index d2db85c8597..967a2993f2e 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -3113,11 +3113,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } protected void setMemory(Connection conn, VM vm, long memsize) throws XmlRpcException, XenAPIException { - vm.setMemoryStaticMin(conn, memsize); - vm.setMemoryDynamicMin(conn, memsize); - - vm.setMemoryDynamicMax(conn, memsize); - vm.setMemoryStaticMax(conn, memsize); + vm.setMemoryLimits(conn, memsize, memsize, memsize, memsize); } private void waitForTask(Connection c, Task task, long pollInterval, long timeout) throws XenAPIException, XmlRpcException { diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java index 270240b69c8..716bb7cc9cc 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer56Resource.java @@ -74,11 +74,6 @@ public class XenServer56Resource extends CitrixResourceBase { } } - @Override - protected void setMemory(Connection conn, VM vm, long memsize) throws XmlRpcException, XenAPIException { - vm.setMemoryLimits(conn, memsize, memsize, memsize, memsize); - } - @Override protected String getGuestOsType(String stdType, boolean bootFromCD) { From 30dd34d258051838f6ee2aca42be1070f910954d Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Thu, 6 Dec 2012 02:35:49 +0530 Subject: [PATCH 027/145] CLOUDSTACK-588:restoreVirtualMachine api functionality on the UI while the VMs are in running or stopped state --- ui/css/cloudstack3.css | 9 +++++++++ ui/scripts/instances.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css index 1f862b06656..f233095a6bc 100644 --- a/ui/css/cloudstack3.css +++ b/ui/css/cloudstack3.css @@ -11210,11 +11210,20 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it background-position: -168px -31px; } +.reset .icon{ +background-position: -168px -31px; +} + .restoreVM:hover .icon, .restore:hover .icon { background-position: -168px -613px; } + +.reset:hover .icon { + background-position: -168px -613px; +} + .enableVPN .icon { background-position: -198px -3px; } diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index dc4768b2601..5b5ed1853e7 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -475,6 +475,39 @@ } }, + reset: { + label: 'Reset VM', + messages:{ + confirm:function(args) { + return 'Do you want to restore the VM ?'; + }, + notification:function(args) { + return 'Reset VM'; + } + }, + + action:function(args){ + $.ajax({ + url: createURL("restoreVirtualMachine&virtualmachineid=" + args.context.instances[0].id), + dataType: "json", + async: true, + success: function(json) { + var item = json.restorevmresponse; + args.response.success({data:item}); + } + }); + + }, + + notification: { + poll: function(args) { + args.complete({ data: { state: 'Stopped' }}); + } + } + + }, + + edit: { label: 'label.edit', action: function(args) { @@ -1201,6 +1234,7 @@ allowedActions.push("restart"); allowedActions.push("destroy"); allowedActions.push("changeService"); + allowedActions.push("reset"); if (isAdmin()) allowedActions.push("migrate"); @@ -1222,6 +1256,7 @@ allowedActions.push("edit"); allowedActions.push("start"); allowedActions.push("destroy"); + allowedActions.push("reset"); if(isAdmin()) allowedActions.push("migrateToAnotherStorage"); From 9e90ff58e955c0908e14fa527995838f2a00b425 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Wed, 5 Dec 2012 13:18:25 -0800 Subject: [PATCH 028/145] CLOUDSTACK-536: Remove legacy CloudPlatform files --- ui/images/citrix-logo-darkbg.png | Bin 2799 -> 0 bytes ui/images/logo-cloudplatform.png | Bin 1726 -> 0 bytes ui/images/logo-login.png | Bin 8923 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ui/images/citrix-logo-darkbg.png delete mode 100644 ui/images/logo-cloudplatform.png delete mode 100644 ui/images/logo-login.png diff --git a/ui/images/citrix-logo-darkbg.png b/ui/images/citrix-logo-darkbg.png deleted file mode 100644 index 22d99b828b8594771350a4e3f1c7190911029856..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2799 zcmaJ@cUV*B9u8%XC_#`RY6u(2!h{h(G=rf;wv1XNBnJpI!z4hYh$Sd8j3|hgRS;05 z3KkF$4NJg*P%X14f(*Gui4ciMu_!lKwfB$fJM8K{9k zAh3r!(O0(OW$zXhCE54>Q1I`vMW06s;`y;6c<~et0NO)ig#%Cz1|<^k1t_#5hr0nM z5J=vH?jOVpB75SfECzzIjzRDlY#AE_a&qCbDbyH%2Mq@z=}c$Xf~XA!rPG{Yfmkw% z%q9R)boT@f;Fqx9pPCRub)dmqc0rx^IGF$g;8CD_#`jDvj_(ZnsEd>B*Ud;6^dp29 z;|%*ds35X8l)&NuP%Hukr=o1pP+JTFjX^nJ9IT->C^QO*wn3uo;Aj*MYllOjp`RX@ z%o~Rmf%7H0e)1(dIm4oOJT?xAjE|2;#P39~IFU%SgM$MSWrMV_fy)qZ?hz)B!iO`t z#-A040GG<4vw3tD6S}TQ31`LfoMEy^|4xCy{vyldekzl!U`RfNjYK0*>nVK(lF9!c z%3yp!b9uhNKk@!gVXprXHh}a6xU5(XRo1u&<8@bT9DxH+cr1=Ti}n5IDtbq;cr0!d ziw!0CVG(F3nL?#A*DW6zWHQc!$>mX)RKSDi43lXf=yV#6K*ADZ{fM*E$%Tz+n02Rwg&$h3XtaP5r0JlDW{{H4d>tAc4 zg|S!Q%L6ak4`!Yg28J(V!<9O)?a#8*w{H2ypuwPy>(zd{sUaafo-xJ612gq8FOty;C9NdcX6M#aEB7 zM@l3V)r*m0C7V5^-7Q|F-tF0Uq^0GBg~dtI;S$MM-OMUCyaOXyd+OzKAT)FX_uug2 zlbxx8EU$R`V;^ARM@|x4^hA1IW?mQo%oyr!sm^nB)L&gqzwd)WAu<(l<{VGkvfyPl^^PmREEW1c0afaZ*J2HiS*hy`|KCwn^yzh zmMJ{xZJ6_&xRZITRCGhP_fU<(YU0s1i>epXP{e!blayikcgrz6NOJOr*?^|y3YGV0 zlA9BP=UJWs)z%qHsUoGDJ5J*ujRT+nG;&Y%%5RwV<*QS ztWpF@d(GBT+|tbgCJyU7dHCi#@9+GK=QPH<4(m16q(!-pHu~Y`Qq5C32P$_O5!yp} zgQl0V-caEoBgwAieQO9r5=a!cFeDw2K2^*##R#(N(TTHR-I@D;+9hvU*obE^;A=mi ztbTS20~PJ!4nId^ZOrOldpL5|N?$iCzu*|gQ5j~wpU=2nselO_S1@o4h>eY{F#u#d--EG3L$0Tmg!G}J zu|oYrwTbzVS0lBC15(;7Tr8#?1qaQxX^Z-A9L~+nO~8xdwx<|mTGkpHoyo!c(L5e^ zFk4u9(uFP2G{hwih9A*3O;{3Bx^$hQ73}Rtw!H31wzI0*WD;`fR34P_a!h32TU7jK zn}tC9juzT_XR)ZrP_DDJ%9>Mf7~QwoQh?Nx+_|;uXu^wW7)cZP3zNO{BsOYvSoLZT z)9I)1g_}~{f~Rgz-5ld$V<$^2k9icIRk$AUD8(RO#q_+}L-b_f&)F6}zP=9%Z|#;! zr8D~k&yvkCr!PL9Z&@SDsuwoZvZuqjq%m@?t$6HMo z)8VS-TB_jorW}jf@bDI>|_H@UjQtM$cRM&!Th6+Q(YTA#Fk- z*u-pq&U5gQ6-D+caT_voF_m0+>1OZ0I#2HHk1G#@CI+$Z+b=>?(}H;pg!%y~6?AK^x`mx(ufLk==?oZPz1 zs{(s0?+g#0f5fybo0-wk`^hjrp1p8UrBtY~t*6^QKu6T)o5pOkb};2Eg9T;Z=Y7*W z@|`p_2`0bclzWUaw zasxr)ZuqiU?(|>L#;!siH1`brX(xUXZnkNw<3ayGz zV^hqltKDlu`h)>szj41^N253BURJhQ9;{W&z2K`>vzD>4hrm6lLvMDjEA?@IIQ zxstl>B4DSV(n`j5&C*JZA>CxT=Ia+V&H_dLC6Pw0mtvItyBy&})n9L%eb2nmMy~lF tagojiUrLrwavzc#Gitf2Rr%h$9W)tCKJC0*`FQ;o)PuC2cnu#W_z(I$zgPeO diff --git a/ui/images/logo-cloudplatform.png b/ui/images/logo-cloudplatform.png deleted file mode 100644 index f749ec74d6a891f633ed587f4f99beccce1517fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1726 zcmeAS@N?(olHy`uVBq!ia0vp^AAneagAGXPWPjZYq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~;1Ffc1+hD4M^`1)8S=jZArg4F0$^BXQ!4Z zB&DWj=GiK}-@RW+Av48RDcsc8z_-9TH6zobswg$M$}c3jDm&RSMakYy!KT6rXh3di zNuokUZcbjYRfVk**jy_h8zii+qySb@l5ML5aa4qFfP!;=QL2Keo`G(%fti7VnW3Jc zv5C34xsHO7fuVuEfswwUk*=Y+m9dePfq?=PC;@FNN=dT{a&d#&1?1T(Wt5Z@Sn2DR zmzV368|&p4rRy77T3Uk4Ff!5ws?aU2%qvN((9J7WhMC}!TAW;zSx}OhpQivaF)=B> zw8T~k=u(Imatq+b<`qMO2^e7d6^RAXA5U@OLIpfLqk_XCnHBU3rkmHH&+u2 zS7Renm|mCsATTyALtl;P{bldG)xGXdO%EgvITPB2|qOtnA(eg$$DAI^HyMPG4gbA45_&F zW=`Y8O$Gw3AD`tbOlwdr0Kx>$Af{;wsvev{O;Z$9Wq^!-MxV>>oK{g-vAq2IzL{q@ zl01xlZ_;lmEVG)+B4ptwIg$kmb34fpE%my^H7x+x-dvS(*?t-+KNn_2fXIanJmc~zr+@9EAfKkogRuv~zY&Y0h$Q zO5W+0^Yh~7o`{E4_b(lO@JB3J`Fr;V%gw*`IL|K+o7=X~drO1!lwHqnN!`3Tz0_%| z*qp;rVjO=oul;Uth+VKQ%gKz_Q1j=ntK}yX@7(CY1I?V>oxsXD*JG(`xg4D`fXZG?xsxH z<6AB~>28RgIyJ9y#pQ1-50snFeHE#?sC@50)b({C(U&>Dzn9+r{)PR|#eag0>t%V~ zzf7C<_p;-w(>&idJnvUr-uQ45`d`8$fgc<#4QijLQG?zM?Jpma#Y z@%mccr&EvgJv}gMlkkc?6IJ$4eJk{Lx5y*Q71=RgPYK7|)bCv%ak=m8tjvO&%~Pw_ zto6B*;B@kW*!`$&1y|G`hZ$Zup*-Vbye8*QTge#$PK?4%8VOFIgp5ebpo9!WHl6>O aco+nXUg`00009a7bBm000XU z000XU0RWnu7ytkYPiaF#P*7-ZbZ>KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z000;UNkl1jg}0*pW`#>jwBV(^k+gq_W4k_OynYtz;^ zP1>HeCnwlWTI$5dMfFLOv^l3WIf)aWwuw#Rv?cKdw!vVVMFPa;AhaQgMMzIi(pzS~ zw|~4Dd3fkaVw0Wb{mz*Knwfj&&eiX`-*3AkB7{I|>oK@87>i-=-ZyaZ;ze*FP#B4z ztgIBtWD>HhK$0XZUc4Aykt7MR*wB*Kckh1e-1+mLkR+LxmKJaS+-E=Yx4~erQwTA3 zFQpV*aO~c_7wzrsP!t8@ivU0_J4*;bDwP5N6cmI}URDN4RxoGIY)}G>jEunN^P#Qn zG-5+>Fvb7?j4?!`QM9x)!{_rs2te0$FvdU#K{}nr```aQG&HP4Nl6Jf=Qw!qAYORk zWdwtPvFE2!X*4vfgk>7oy?YmASw=FML~H9|zo=uOft;5kf$gB_xwcB$Fxl{r)_7 z^OBcq6nZrbtm`@g0Y79}a_w53b8fkSB!oZ+0ZL(V&MnS4{5~JjX%$C~v|?aj5RxS2 zXFo4_nQjJlecsa2QdCt{VODiD2*vSz`wqOgckde;0Rch?bX~`qH6MK1=kuMnY#YZ< zoPeh37#&T(?^p8do0q)2TLAVlEu|DSbLXT2{=lQDRBEKBr}sVpSg>Hh_IdN>J&{Z# zd3$F^hIN?)MNyE)ZeH>-O#r5pLXxBs##j+!%oIZO1JDTp(&-ciV}qDKe;x*7v2(V~ zzgAve{sbWejIn{f-d+?G6d)cShN37S<3yFGQylZ3Fvf%=$yePE=N!m{$OR#UAQLjb zM1JoRpB}I276A1C8a?Ma0c-=%1Ry?6n;`&E02`e9-ixvYz$O4K09HEZqR!YSlZoE{ zM!fs_9DUV0@8SL3yqD*EVgM6DiWN!vLQhZc$GSSZ=3BO{5K082EEWj(_7g&$rj+hs zjDblKQmOQ(HBI|NMNu@y7}s@OF%07=LdZ!;lD;E^u%`fE3LpXC+W`Ck`6hsr7a)WX z5JCiienQATLdf#~hO_!n2qAw@2&p54XaI;1B2`!zdE_f!`SQ80uI{^DetE}NDW$5X zZ-o%@5`d=w7yu|CfHDeThx4yjT7DZDm{3aZyKtd@i>7Jw z2qB6K9EZiKlF8(fp`rMO>gwwM3Iu|G-{0RqkW40TZEx@Rl%mL>l)|!X2+rRK27~9% zbf5VY=X|V>Nn{wnPXPo0eE4z}1t=u|U|+m=@y`YZ2HTb|U-nf($WEKv&{#x+D?bs+S=}OQ&~R6hZ84GHZEPd^bJDDaaC34 zA2`tbeMONg-Sd+-cl`bDZ#em*AO5h)vaLCmWtD|Op^+)D69DXVlxJ%exHmcq z=7RkH8;B=jvW?FC)Bt$a!{FCj);sLllH*$Rw}o}H8873@X3SpN)6@57Z@#&2TRNRy zEJ>0=DFvm}Wj;7RQ_e-Ct?l%ejvYI;RhA`CN=GG$x!1uM1*OymAl!3TaM;dq*)>8k zASQ$`N@*Y#i`{zUNb8eAi1$Sz5fl~{f^)$srI$RHF$P(dxey!`6*GEnzkSuWii(Q* zHBAE{1WaN`CX)pR4jla2f&B-IUwduW=2$FNDa$elA<#4(!C)}?(T{#~Q%On5Zw3Yj zN*QHoMNtYQNwOzU8W+4x4#Q-FbE~7YJ3WAp{thwlRsauqShDe57=t_C@!ux!jsaNL zb(ofgj*gDT=YH|r_W+?}f=vQK2yo89IfrfAuKx$lIV4H4tE;OI6%-V}wrwRxWSMw< zP`ABTy!|?3qT~6mjIoR1aIjOBrI>raq9_;~9IR<>ZvJv+Vc`%0IRj<3Z6h8ZMorD! zU8`5G`Yr&=G%W}rpePDDIyyGQ+_+hD+F+RM;DGBJ5m1Y=U;eK z)zm?&Pg0EX(p8 zIC${S-G1E#ZvOoFzpkmN`8T)x62L`D=^Lq33Y_!bj5D{59%Y=0N!;RqxXC%D>OXFA z{CM{ma?a&4=fwoUrFu_4>vOap^4zn-8N>CEcorK@#Uy?*>)qWkZ5-#FHf8-hAtdSZU7pt^guu3K z-{|OQFCpZ9UDrQT9F2Z{$;~%EX?Yk|(=@DJecMwN73F_mnC2e>cmNP50Tg9}PgPaD zx3_PQ5b|c=CI$OXeN z#`;neWvmZXRZ&@4+11cc|1DXT2C}S(enQAW0Bt$I;6_<@PEjeFrohx*-?1Z0(Of0m z=?&w z+UT6Gcjk9})^oSG@e&FE9UbjTPfyRiZV?6`U>F7#En4)e_cb(pnK9{*VHl=qnj=DB z`)#+~_6O_Mt$ldmf(0-6eEv(yDlY{K7v0@GFf9v`B;n?p7a<%D`7F~M0}JOIfk4n# zRaM1I2ShIEW&WhFC0y_Vx~N&QVfQ z^2RNI6T9aqK2!LWw z`-eQ>BA)xNb)FlY@vQWWZ(Ej*)Mw3UljquwtoFs8`Pm4dh62F(^A~&r1A}+C5nJ2l zkR(Z;Gkf-bu3oh&9f?FBgn%STuq+z@&aYU$Y^$d0aLw(UVQz_`q_`NjuU>`P+FGR2 zDVoiYs;bdNix!g=D^@stk#T+3a5#KRb@j{*y}ftgLNtc#a{-vW&jIbJ)NC08G;YArv3_&^_OtKX2ZijLRU#77PG<@#00#%$>rdx-6w=a(>})Pm1PR(=Y2ietJ{Zvo>5~|1O)l z;BA@0;^hTYwlCe}VXFG~z&tm3-f3Ho>rGj)5U%L2T zqW7Z!5Dtg!Kp@clPOg@~<~(BAc1Q>TpU($XO=ECy5W!#&!C(*r0|T%u3&~_+()_Mv z+t77m()%<`n{Xj8O*4>Ar-PCtL6Rg0A$TMbX{oQTf3UK$a?jbbXVKq(VZx0PPVfz@ zR^0~EG{HGnUV7=J$2&Va8ze~@8zUhEf)Lu)c6xnRSNCUw!QdGB6NvGzh(-qz_k=S>~vUXS@h=>PMkM2$M zAp{a*NTpH*Z|&RnwwY8LRO4rXYmCvdmCdSN8*jg+&p@-YFu< zCAMv&va%A5jcZ|=CfeFguYL8^*S>C9mhz7OZ^P>g`+Pq1_VzAoJ<|GDKA$p{wh}^M z!GZ-?v0??Dc;bnPOsASF2=c6V%*~-GGG}y($``*5%KKg^F4^b_s<|xHJ=odV^~iw(&2Ooy`V1j-`;jB9dpkS3K06c} zn%~^g{I!fy-}r%AmPLw-qyG~K1bSU?QA*jVQ>X5E@x_;#{C?k*`jHre;2Z}JHqU$E zg%>x+dAyZa(yYqtrJn znv=;Xa|j_`S-5b)KM_JwuBAXJC5I0m{`_;#{qir;sT3)7zGsz-fmz0P4!r&LZ@zl! z)Tujy!4QB{r~}u+Qg1GMNg$`PN&1-F>EK4rL6IEQ3i> zroY@nZ}KqfmMH{!YO>l*<{NFy!4BTY@wOa{QlG;D$Yn`Hb3|GjF@5EaQO_K0n`9BZ zULd}fd7d5syS`yXMa8zYYu7ws7>4eek=`0;Z*>x547#or96o&HqrJUn!5GtSlrNkq zbChx6LVrez@#81H$~nK=EdkAdm|OzhaJYasu3dxHqenlt zXU`j7^85Y7aSNcTD(+tM!KT8Z!kq;L1!{f$if_rXY`9Du30@Vq3TPp)rT)8~4oFRNaBAo#*KXa7M{3t+=@OAC@m)_Dw}m&bjr^E||SP z14vg?%-B6^)~v@J#w#>U6P9Ip583^{TTjhxE_?6EM1qClrmrl^ysWL;KAlzzdU|^4 zvSrI2_WS+AhLO3KF@|&J&d+(}wO!vUFE5`zV@8Fc>xR$m%QP);&I6RfdgayE?%clp z`G2-;%kiTvBoYZMT)1HOnl&H%_MAC$48|Bjq0s)ix}{I2QmL`$3n8$3_v;U}pKkw% zrfDqmeXqQff;Q8}%u^URjZ!tFEs85g|y2!$E{Xq3)`x%7c<53rYz% z7o@zrtcMVSK){c1I1EZDqS0tyRaNCd#w5WQMPXrtghHV+KEF>8LQqvz2}&pga1Ovh zH+V$|A?4*|orez}qSZ5JHs5vEo&R{~(Ba=#6xlI>1(J!RzxC*`4=-A@@cT1oRvnOK zNpo0~F~+o;Zn}vM4GrBZN%T}r&0O2rs6Z4&vF^F2@oxfwK-{)%6h# z7+7o=rXop95JHehrr7EB_SNxt{59LQ$B_HM58OGK(rt5CVm&S|t=sAxSCVqr>L}R8 zELLFF<*slU#7PIkKoF}<5FT!3arp|?8MI-T*YcaA2HHS|!{`_)Wg z&aZZ!r$vYm0{iwiV{~)`hGC$u?<__~M-ht+!Lm#g6%|z`lgXQVdU~UgNW?5DDeegc zgU3#{w_BB!RhTtvCO&rGhw%2vHo2##*XNqrBJ)jY9e}AQGODX*fl`W#0|Rn*_n81= zlxG;wCUb6@qx*b{!8ym7uI@~GKoUX(J-#)C5SkFesI9Gq&*#I@W5>d7TFLQanPHf8 z;lkR)*|X=Z(a{kp91cY+%T8;Wt}S1_OgVAlcp+nw>YDq8VUUW73bim2u}VryAxRSY zdi$Ixw7~Glh%_=X5|AXxiGqXJw(SEj0_StN5CR(?_!HzMFYgKi|LmEc;*Y-YM@S?R z;Jo(|ztJ?!^Oj|ucTH&5?Dc>Kw#{MNwyEp7=>@Riscp6_3zSlrrfKTBZZbyQO$cM# z32obkuIny+YrReE7GpoD1>tD~EyKoO7a5m&?A3t*B$OgkO-gK+N zyeT2hIf{#m;rIKYrd3#$jaY1O!uO9v3Lzly^iO__^`HJ^UYqjr?f_VlBs}x8pF&X- z9BpmI+`02`%hEaw#fK1fn91)CAP@*56bc~}3?dSVU~q5%{TI&Si(mXa`uhhF8H|Ba zHpalwXcVbb3XeXz8MofL9Gf?9hGla^BC)YQX=0itqQ%AV`xJcrk%u9;zyl9#gk~5J zT;OsBwozPM3|W>@SXc-l1k&j=N=r-O_xnKz!Ja*D+;{3!+d4&2Aj^{b*Cb|c-~Ow= zoHuXYo0L+hssL@jY8n7>zSo%9`D2;}jvYIO{rmUh#EIibCX-03>C6`@2_U#Y zFcbtO1pD^w10e+c{r#E9cXoy~QJ$e*HMTOYAckd-RSL9FaQFqZX+8^;vB{4+IfUU;&-v9c_W`M8ta=YGOw$}5m8 zqh{`0EL*l58z1~KhK6Fec(MN@ue|c=)0(E2xP6+Yi6u)G|3hVE<)h(n7)OpA#)~gJ zkHNthlF0;sOm6#~J;sxd!@K#xxO6XbUh*=144f^DF?gf9lgU)>ovcpTyC_@WTsW7n=-_{oo- zf~u Date: Wed, 5 Dec 2012 17:46:32 -0700 Subject: [PATCH 029/145] Summary: master - Fix typo in createvolume.sh Detail: createvolume.sh had '$qemu-img' in one spot instead of '$qemu_img' as it uses everywhere else Signed-off-by: Marcus Sorensen 1354754792 -0700 --- scripts/storage/qcow2/createvolume.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/storage/qcow2/createvolume.sh b/scripts/storage/qcow2/createvolume.sh index cfafed156f9..10fa6dd617b 100755 --- a/scripts/storage/qcow2/createvolume.sh +++ b/scripts/storage/qcow2/createvolume.sh @@ -99,7 +99,7 @@ create_from_file() { local volimg="$2" local volname=$3 if [ -b $volimg ]; then - $qemu-img convert -f raw -O qcow2 "$volimg" /$volfs/$volname + $qemu_img convert -f raw -O qcow2 "$volimg" /$volfs/$volname else $qemu_img convert -f qcow2 -O qcow2 "$volimg" /$volfs/$volname >& /dev/null fi From 7ce2227108dd0ffe9d2f7bd75ab1b36190053266 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Wed, 5 Dec 2012 17:54:01 -0700 Subject: [PATCH 030/145] Summary: master - Copy qcow2 instead of converting if source and dest are qcow2 Detail: If source image is qcow2, and we want a qcow2 image, then doing a convert strips off compression and any snapshots the user had in that image. If a backing file exists, we stick with convert so we can pull in both the backing file and the COW image, otherwise we just cp the qcow2 file. This is also faster Signed-off-by: Marcus Sorensen 1354755241 -0700 --- .../kvm/storage/LibvirtStorageAdaptor.java | 14 ++++++++++---- scripts/storage/qcow2/create_private_template.sh | 8 +++++++- scripts/storage/qcow2/createtmplt.sh | 6 ++++++ scripts/storage/qcow2/createvolume.sh | 6 ++++++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java index 6c55743696d..2a603cb0f47 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java @@ -688,10 +688,16 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { PhysicalDiskFormat destFormat = newDisk.getFormat(); if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() != StoragePoolType.RBD)) { - Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat - + " -O " + destFormat - + " " + sourcePath - + " " + destPath); + if (sourceFormat.equals(destFormat) && + Script.runSimpleBashScript("qemu-img info " + sourcePath + "|grep backing") == null) { + Script.runSimpleBashScript("cp -f " + sourcePath + " " + destPath); + + } else { + Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat + + " -O " + destFormat + + " " + sourcePath + + " " + destPath); + } } else if ((srcPool.getType() != StoragePoolType.RBD) && (destPool.getType() == StoragePoolType.RBD)) { Script.runSimpleBashScript("qemu-img convert -f " + sourceFormat + " -O " + destFormat diff --git a/scripts/storage/qcow2/create_private_template.sh b/scripts/storage/qcow2/create_private_template.sh index 4b93380bc52..8e9e26c4104 100755 --- a/scripts/storage/qcow2/create_private_template.sh +++ b/scripts/storage/qcow2/create_private_template.sh @@ -31,7 +31,13 @@ create_template() { local fspath=$1 local destpath=$2 - qemu-img convert -O qcow2 /$fspath $destpath + # if backing image exists, we need to combine them, otherwise + # copy the image to preserve snapshots/compression + if $qemu_img info "$tmpltimg" | grep -q backing; then + qemu-img convert -O qcow2 /$fspath $destpath + else + cp -f /$fspath $destpath + fi if [ $? -gt 0 ]; then printf " Failed to export template $destpath\n" >&2 diff --git a/scripts/storage/qcow2/createtmplt.sh b/scripts/storage/qcow2/createtmplt.sh index 84d2ba80b8c..152268f651a 100755 --- a/scripts/storage/qcow2/createtmplt.sh +++ b/scripts/storage/qcow2/createtmplt.sh @@ -100,7 +100,13 @@ create_from_file() { if [ -b $tmpltimg ]; then $qemu_img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname else + # if backing image exists, we need to combine them, otherwise + # copy the image to preserve snapshots/compression + if $qemu_img info "$tmpltimg" | grep -q backing; then $qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null + else + cp -f $tmpltimg /$tmpltfs/$tmpltname + fi fi if [ "$cleanup" == "true" ] diff --git a/scripts/storage/qcow2/createvolume.sh b/scripts/storage/qcow2/createvolume.sh index 10fa6dd617b..527aa68db28 100755 --- a/scripts/storage/qcow2/createvolume.sh +++ b/scripts/storage/qcow2/createvolume.sh @@ -101,7 +101,13 @@ create_from_file() { if [ -b $volimg ]; then $qemu_img convert -f raw -O qcow2 "$volimg" /$volfs/$volname else + # if backing image exists, we need to combine them, otherwise + # copy the image to preserve snapshots/compression + if $qemu_img info "$volimg" | grep -q backing; then $qemu_img convert -f qcow2 -O qcow2 "$volimg" /$volfs/$volname >& /dev/null + else + cp -f $volimg /$volfs/$volname + fi fi if [ "$cleanup" == "true" ] From 21819dafb5e5ab03e0b769018b3df630dcaf0a56 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 6 Dec 2012 00:56:04 +0000 Subject: [PATCH 031/145] Summary: Devcloud tests for vm life cycle Detail: VM Life cycle tests needed minor changes to run them against a devcloud - basic zone, local storage envrioment. Signed-off-by: Prasanna Santhanam 1354760111 -0800 --- test/integration/smoke/test_vm_life_cycle.py | 39 ++++++++++++++------ tools/marvin/marvin/integration/lib/base.py | 1 + tools/marvin/marvin/setup.py | 8 +++- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py index 50c75d109e9..1633c538342 100644 --- a/test/integration/smoke/test_vm_life_cycle.py +++ b/test/integration/smoke/test_vm_life_cycle.py @@ -90,7 +90,7 @@ class Services: "displaytext": "Small Instance", "cpunumber": 1, "cpuspeed": 100, - "memory": 256 + "memory": 256, }, "medium": { @@ -100,7 +100,7 @@ class Services: "displaytext": "Medium Instance", "cpunumber": 1, "cpuspeed": 100, - "memory": 256 + "memory": 256, } }, "iso": # ISO settings for Attach/Detach ISO tests @@ -125,7 +125,6 @@ class Services: #Migrate VM to hostid "ostype": 'CentOS 5.3 (64-bit)', # CentOS 5.3 (64-bit) - "mode":'advanced', } @@ -139,6 +138,14 @@ class TestDeployVM(cloudstackTestCase): # Get Zone, Domain and templates domain = get_domain(self.apiclient, self.services) zone = get_zone(self.apiclient, self.services) + self.services['mode'] = zone.networktype + + #if local storage is enabled, alter the offerings to use localstorage + #this step is needed for devcloud + if zone.localstorageenabled == True: + self.services["service_offerings"]["tiny"]["storagetype"] = 'local' + self.services["service_offerings"]["small"]["storagetype"] = 'local' + self.services["service_offerings"]["medium"]["storagetype"] = 'local' template = get_template( self.apiclient, @@ -170,7 +177,7 @@ class TestDeployVM(cloudstackTestCase): self.account ] - @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"]) + @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"]) def test_deploy_vm(self): """Test Deploy Virtual Machine """ @@ -185,7 +192,8 @@ class TestDeployVM(cloudstackTestCase): self.services["small"], accountid=self.account.account.name, domainid=self.account.account.domainid, - serviceofferingid=self.service_offering.id + serviceofferingid=self.service_offering.id, + mode=self.services['mode'] ) list_vm_response = list_virtual_machines( @@ -242,6 +250,15 @@ class TestVMLifeCycle(cloudstackTestCase): # Get Zone, Domain and templates domain = get_domain(cls.api_client, cls.services) zone = get_zone(cls.api_client, cls.services) + cls.services['mode'] = zone.networktype + + #if local storage is enabled, alter the offerings to use localstorage + #this step is needed for devcloud + if zone.localstorageenabled == True: + cls.services["service_offerings"]["tiny"]["storagetype"] = 'local' + cls.services["service_offerings"]["small"]["storagetype"] = 'local' + cls.services["service_offerings"]["medium"]["storagetype"] = 'local' + template = get_template( cls.api_client, zone.id, @@ -319,7 +336,7 @@ class TestVMLifeCycle(cloudstackTestCase): return - @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"]) + @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"]) def test_01_stop_vm(self): """Test Stop Virtual Machine """ @@ -355,7 +372,7 @@ class TestVMLifeCycle(cloudstackTestCase): ) return - @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"]) + @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"]) def test_02_start_vm(self): """Test Start Virtual Machine """ @@ -393,7 +410,7 @@ class TestVMLifeCycle(cloudstackTestCase): ) return - @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"]) + @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"]) def test_03_reboot_vm(self): """Test Reboot Virtual Machine """ @@ -669,7 +686,7 @@ class TestVMLifeCycle(cloudstackTestCase): ) return - @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"]) + @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"]) def test_06_destroy_vm(self): """Test destroy Virtual Machine """ @@ -705,7 +722,7 @@ class TestVMLifeCycle(cloudstackTestCase): ) return - @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"]) + @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"]) def test_07_restore_vm(self): """Test recover Virtual Machine """ @@ -818,7 +835,7 @@ class TestVMLifeCycle(cloudstackTestCase): @attr(configuration = "expunge.interval") @attr(configuration = "expunge.delay") - @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"]) + @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg"]) def test_09_expunge_vm(self): """Test destroy(expunge) Virtual Machine """ diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py index 66754bd292f..044c9108307 100644 --- a/tools/marvin/marvin/integration/lib/base.py +++ b/tools/marvin/marvin/integration/lib/base.py @@ -1039,6 +1039,7 @@ class ServiceOffering: cmd.displaytext = services["displaytext"] cmd.memory = services["memory"] cmd.name = services["name"] + cmd.storagetype = services["storagetype"] # Service Offering private to that domain if domainid: diff --git a/tools/marvin/marvin/setup.py b/tools/marvin/marvin/setup.py index dea67df8f89..07ff5b5a577 100644 --- a/tools/marvin/marvin/setup.py +++ b/tools/marvin/marvin/setup.py @@ -16,7 +16,13 @@ # under the License. import os -from setuptools import setup +try: + from setuptools import setup, find_packages +except ImportError: + from distribute_setup import use_setuptools + use_setuptools() + from setuptools import setup, find_packages + def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read().strip() From 28bbf6c52798c9bd298952844250fbc3cb92dce0 Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Thu, 25 Oct 2012 20:35:34 +0530 Subject: [PATCH 032/145] Summary: partical check-in for L4-L7 network services in the shared network in the advanced zone Details: - changed associateIPAddr API to accept shared network Id and account Id. Ip will be owned by tuple (account Id, network Id) - chaged createNetwork API to accpet CIDR when network offering has external networking device providers Bug ID:CLOUDSTACK-312 enable L4-L7 network services in the shared network in the advanced zone --- .../api/commands/AssociateIPAddrCmd.java | 3 +- api/src/com/cloud/network/NetworkService.java | 3 +- .../com/cloud/network/NetworkManagerImpl.java | 117 +++++++++++++++++- .../cloud/network/MockNetworkManagerImpl.java | 34 ++--- .../com/cloud/vpc/MockNetworkManagerImpl.java | 46 ++----- 5 files changed, 140 insertions(+), 63 deletions(-) diff --git a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java b/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java index 7aaa5b5790b..878a9fc4667 100644 --- a/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java +++ b/api/src/com/cloud/api/commands/AssociateIPAddrCmd.java @@ -216,7 +216,8 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { @Override public void create() throws ResourceAllocationException{ try { - IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), false, getZoneId()); + IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId()); + if (ip != null) { this.setEntityId(ip.getId()); } else { diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index a20056152eb..e7b6defd413 100755 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -41,7 +41,8 @@ public interface NetworkService { List getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner); - IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException, + + IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException; boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException; diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 9841f106523..ece31c32da7 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -1016,6 +1016,38 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override @ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "allocating Ip", create = true) + public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) + throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { + if (networkId != null) { + Network network = _networksDao.findById(networkId); + if (network == null) { + throw new InvalidParameterValueException("Invalid network id is given"); + } + + if (network.getGuestType() == Network.GuestType.Shared) { + DataCenter zone = _configMgr.getZone(zoneId); + if (zone == null) { + throw new InvalidParameterValueException("Invalid zone Id is given"); + } + + // if shared network in the advanced zone, then check the caller against the network for 'AccessType.UseNetwork' + if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) && zone.getNetworkType() == NetworkType.Advanced) { + Account caller = UserContext.current().getCaller(); + long callerUserId = UserContext.current().getCallerUserId(); + _accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); + } + return allocateIp(ipOwner, false, caller, callerUserId, zone); + } else { + throw new InvalidParameterValueException("Associate IP address can only called on the shared networks in the advanced zone" + + " with Firewall/Source Nat/Static Nat/Port Forwarding/Load balancing services enabled"); + } + } + } + + return allocateIP(ipOwner, false, zoneId); + } public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { @@ -2472,6 +2504,70 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } + private void checkSharedNetworkCidrOverlap(Long zoneId, String cidr) { + if (zoneId == null) { + return; + } + + if (cidr == null) { + return; + } + + List networks = _networksDao.listByZone(zoneId); + Map networkToCidr = new HashMap(); + for (NetworkVO network : networks) { + if (network.getGuestType() == GuestType.Isolated) { + continue; + } + if (network.getCidr() != null) { + networkToCidr.put(network.getId(), network.getCidr()); + } + } + + //TODO: check for CIDR overlap with all possible CIDR for guest networks in the zone + //when using external networking + + if (networkToCidr == null || networkToCidr.isEmpty()) { + return; + } + + for (long networkId : networkToCidr.keySet()) { + String ntwkCidr = networkToCidr.get(networkId); + if (NetUtils.isNetworksOverlap(ntwkCidr, cidr)) { + throw new InvalidParameterValueException("Warning: The specified existing network has conflict CIDR subnets with new network!"); + } + } + } + + public void checkVirtualNetworkCidrOverlap(Long zoneId, String cidr) { + if (zoneId == null) { + return; + } + if (cidr == null) { + return; + } + List networks = _networksDao.listByZone(zoneId); + Map networkToCidr = new HashMap(); + for (NetworkVO network : networks) { + if (network.getGuestType() != GuestType.Isolated) { + continue; + } + if (network.getCidr() != null) { + networkToCidr.put(network.getId(), network.getCidr()); + } + } + if (networkToCidr == null || networkToCidr.isEmpty()) { + return; + } + + for (long networkId : networkToCidr.keySet()) { + String ntwkCidr = networkToCidr.get(networkId); + if (NetUtils.isNetworksOverlap(ntwkCidr, cidr)) { + throw new InvalidParameterValueException("Warning: The specified existing network has conflict CIDR subnets with new network!"); + } + } + } + @Override @DB @ActionEvent(eventType = EventTypes.EVENT_NETWORK_CREATE, eventDescription = "creating network") @@ -2667,7 +2763,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Collection ntwkProviders = finalizeServicesAndProvidersForNetwork(ntwkOff, physicalNetworkId).values(); if (cidr != null && providersConfiguredForExternalNetworking(ntwkProviders)) { - throw new InvalidParameterValueException("Cannot specify CIDR when using network offering with external devices!"); + if (ntwkOff.getGuestType() == GuestType.Shared && (zone.getNetworkType() == NetworkType.Advanced) && + isSharedNetworkOfferingWithServices(networkOfferingId)) { + // validate if CIDR specified overlaps with any of the CIDR's allocated for isolated networks and shared networks in the zone + checkSharedNetworkCidrOverlap(zoneId, cidr); + } else { + throw new InvalidParameterValueException("Cannot specify CIDR when using network offering with external devices!"); + } } @@ -4380,6 +4482,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag return false; } + public boolean isSharedNetworkOfferingWithServices(long networkOfferingId) { + NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId); + if ( (networkOffering.getGuestType() == Network.GuestType.Shared) && ( + areServicesSupportedByNetworkOffering(networkOfferingId, Service.SourceNat) || + areServicesSupportedByNetworkOffering(networkOfferingId, Service.StaticNat) || + areServicesSupportedByNetworkOffering(networkOfferingId, Service.Firewall) || + areServicesSupportedByNetworkOffering(networkOfferingId, Service.PortForwarding) || + areServicesSupportedByNetworkOffering(networkOfferingId, Service.Lb))) { + return true; + } + return false; + } + @Override public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) { return (_ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(networkOfferingId, services)); diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java index a038e71c3a9..76b911a722e 100755 --- a/server/test/com/cloud/network/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java @@ -16,14 +16,6 @@ // under the License. package com.cloud.network; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ejb.Local; -import javax.naming.ConfigurationException; - import com.cloud.acl.ControlledEntity.ACLType; import com.cloud.api.commands.CreateNetworkCmd; import com.cloud.api.commands.ListNetworksCmd; @@ -35,12 +27,7 @@ import com.cloud.dc.Vlan.VlanType; import com.cloud.deploy.DataCenterDeployment; import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeploymentPlan; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientAddressCapacityException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InsufficientVirtualNetworkCapcityException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.*; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.Network.Capability; import com.cloud.network.Network.GuestType; @@ -61,13 +48,14 @@ import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.utils.Pair; import com.cloud.utils.component.Manager; -import com.cloud.vm.Nic; -import com.cloud.vm.NicProfile; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.VirtualMachineProfile; -import com.cloud.vm.VirtualMachineProfileImpl; +import com.cloud.vm.*; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; @Local(value = { NetworkManager.class, NetworkService.class }) public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkService { @@ -796,10 +784,10 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS } /* (non-Javadoc) - * @see com.cloud.network.NetworkService#allocateIP(com.cloud.user.Account, boolean, long) + * @see com.cloud.network.NetworkService#allocateIP(com.cloud.user.Account, long, Long) */ @Override - public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { + public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { // TODO Auto-generated method stub return null; } diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java index dc0e880996e..3536d66ea4f 100644 --- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java @@ -16,17 +16,6 @@ // under the License. package com.cloud.vpc; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ejb.Local; -import javax.naming.ConfigurationException; - -import org.apache.log4j.Logger; - import com.cloud.acl.ControlledEntity.ACLType; import com.cloud.api.commands.CreateNetworkCmd; import com.cloud.api.commands.ListNetworksCmd; @@ -38,30 +27,14 @@ import com.cloud.dc.Vlan.VlanType; import com.cloud.deploy.DataCenterDeployment; import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeploymentPlan; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientAddressCapacityException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InsufficientVirtualNetworkCapcityException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.*; import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.network.IPAddressVO; -import com.cloud.network.IpAddress; -import com.cloud.network.Network; +import com.cloud.network.*; import com.cloud.network.Network.Capability; import com.cloud.network.Network.GuestType; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; -import com.cloud.network.NetworkManager; -import com.cloud.network.NetworkProfile; -import com.cloud.network.NetworkService; -import com.cloud.network.NetworkVO; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PhysicalNetwork; -import com.cloud.network.PhysicalNetworkServiceProvider; -import com.cloud.network.PhysicalNetworkSetupInfo; -import com.cloud.network.PhysicalNetworkTrafficType; -import com.cloud.network.PublicIpAddress; import com.cloud.network.addr.PublicIp; import com.cloud.network.dao.NetworkServiceMapDao; import com.cloud.network.element.NetworkElement; @@ -80,14 +53,13 @@ import com.cloud.utils.Pair; import com.cloud.utils.component.Adapters; import com.cloud.utils.component.Inject; import com.cloud.utils.component.Manager; -import com.cloud.vm.Nic; -import com.cloud.vm.NicProfile; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.VirtualMachineProfile; -import com.cloud.vm.VirtualMachineProfileImpl; +import com.cloud.vm.*; import com.cloud.vpc.dao.MockVpcVirtualRouterElement; +import org.apache.log4j.Logger; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; +import java.util.*; @Local(value = { NetworkManager.class, NetworkService.class }) public class MockNetworkManagerImpl implements NetworkManager, Manager{ @@ -1493,7 +1465,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager{ * @see com.cloud.network.NetworkService#allocateIP(com.cloud.user.Account, boolean, long) */ @Override - public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { + public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { // TODO Auto-generated method stub return null; } From 0de5a145e4f06420a4eb1867309af674c16ace7c Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Fri, 26 Oct 2012 19:39:38 +0530 Subject: [PATCH 033/145] Summary: partical check-in for L4-L7 network services in the shared network in the advanced zone Summary: change 'shared network' in advanced zone with L4-L7 services to go through network implement phase. Add ACL checks to associate IP to shared network in the advanced zone Bug ID:CLOUDSTACK-312 enable L4-L7 network services in the shared network in the advanced zone Conflicts: server/src/com/cloud/network/NetworkManagerImpl.java --- .../com/cloud/network/NetworkManagerImpl.java | 208 ++++++------------ 1 file changed, 71 insertions(+), 137 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index ece31c32da7..0ac44fa2176 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -16,45 +16,11 @@ // under the License. package com.cloud.network; -import java.net.URI; -import java.security.InvalidParameterException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.ejb.Local; -import javax.naming.ConfigurationException; - -import org.apache.log4j.Logger; - import com.cloud.acl.ControlledEntity.ACLType; import com.cloud.acl.SecurityChecker.AccessType; import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; -import com.cloud.agent.api.AgentControlAnswer; -import com.cloud.agent.api.AgentControlCommand; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.CheckNetworkAnswer; -import com.cloud.agent.api.CheckNetworkCommand; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.StartupCommand; -import com.cloud.agent.api.StartupRoutingCommand; +import com.cloud.agent.api.*; import com.cloud.agent.api.to.NicTO; import com.cloud.alert.AlertManager; import com.cloud.api.commands.CreateNetworkCmd; @@ -65,15 +31,9 @@ import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.Resource.ResourceType; import com.cloud.configuration.dao.ConfigurationDao; -import com.cloud.dc.AccountVlanMapVO; -import com.cloud.dc.DataCenter; +import com.cloud.dc.*; import com.cloud.dc.DataCenter.NetworkType; -import com.cloud.dc.DataCenterVO; -import com.cloud.dc.Pod; -import com.cloud.dc.PodVlanMapVO; -import com.cloud.dc.Vlan; import com.cloud.dc.Vlan.VlanType; -import com.cloud.dc.VlanVO; import com.cloud.dc.dao.AccountVlanMapDao; import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.PodVlanMapDao; @@ -89,17 +49,7 @@ import com.cloud.event.EventTypes; import com.cloud.event.UsageEventVO; import com.cloud.event.dao.EventDao; import com.cloud.event.dao.UsageEventDao; -import com.cloud.exception.AccountLimitException; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.ConnectionException; -import com.cloud.exception.InsufficientAddressCapacityException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InsufficientVirtualNetworkCapcityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.PermissionDeniedException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.exception.UnsupportedServiceException; +import com.cloud.exception.*; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.Status; @@ -117,47 +67,15 @@ import com.cloud.network.Networks.TrafficType; import com.cloud.network.PhysicalNetwork.BroadcastDomainRange; import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType; import com.cloud.network.addr.PublicIp; -import com.cloud.network.dao.FirewallRulesDao; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.LoadBalancerDao; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkDomainDao; -import com.cloud.network.dao.NetworkServiceMapDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; -import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao; -import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; -import com.cloud.network.element.ConnectivityProvider; -import com.cloud.network.element.DhcpServiceProvider; -import com.cloud.network.element.FirewallServiceProvider; -import com.cloud.network.element.SourceNatServiceProvider; -import com.cloud.network.element.IpDeployer; -import com.cloud.network.element.LoadBalancingServiceProvider; -import com.cloud.network.element.NetworkACLServiceProvider; -import com.cloud.network.element.NetworkElement; -import com.cloud.network.element.PortForwardingServiceProvider; -import com.cloud.network.element.RemoteAccessVPNServiceProvider; -import com.cloud.network.element.Site2SiteVpnServiceProvider; -import com.cloud.network.element.StaticNatServiceProvider; -import com.cloud.network.element.UserDataServiceProvider; -import com.cloud.network.element.VirtualRouterElement; -import com.cloud.network.element.VpcVirtualRouterElement; +import com.cloud.network.dao.*; +import com.cloud.network.element.*; import com.cloud.network.guru.NetworkGuru; import com.cloud.network.lb.LoadBalancingRule; import com.cloud.network.lb.LoadBalancingRule.LbDestination; import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy; import com.cloud.network.lb.LoadBalancingRulesManager; -import com.cloud.network.rules.FirewallManager; -import com.cloud.network.rules.FirewallRule; +import com.cloud.network.rules.*; import com.cloud.network.rules.FirewallRule.Purpose; -import com.cloud.network.rules.FirewallRuleVO; -import com.cloud.network.rules.PortForwardingRule; -import com.cloud.network.rules.PortForwardingRuleVO; -import com.cloud.network.rules.RulesManager; -import com.cloud.network.rules.StaticNat; -import com.cloud.network.rules.StaticNatRule; -import com.cloud.network.rules.StaticNatRuleImpl; import com.cloud.network.rules.dao.PortForwardingRulesDao; import com.cloud.network.vpc.NetworkACLManager; import com.cloud.network.vpc.PrivateIpVO; @@ -176,16 +94,9 @@ import com.cloud.projects.ProjectManager; import com.cloud.server.ResourceTag.TaggedResourceType; import com.cloud.tags.ResourceTagVO; import com.cloud.tags.dao.ResourceTagDao; -import com.cloud.user.Account; -import com.cloud.user.AccountManager; -import com.cloud.user.AccountVO; -import com.cloud.user.DomainManager; -import com.cloud.user.ResourceLimitService; -import com.cloud.user.User; -import com.cloud.user.UserContext; +import com.cloud.user.*; import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.UserStatisticsDao; -import com.cloud.uservm.UserVm; import com.cloud.utils.AnnotationHelper; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; @@ -193,35 +104,32 @@ import com.cloud.utils.component.Adapters; import com.cloud.utils.component.Inject; import com.cloud.utils.component.Manager; import com.cloud.utils.concurrency.NamedThreadFactory; -import com.cloud.utils.db.DB; -import com.cloud.utils.db.Filter; -import com.cloud.utils.db.JoinBuilder; +import com.cloud.utils.db.*; import com.cloud.utils.db.JoinBuilder.JoinType; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.SearchCriteria.Op; -import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.Ip; import com.cloud.utils.net.NetUtils; -import com.cloud.vm.Nic; -import com.cloud.vm.Nic.ReservationStrategy; -import com.cloud.vm.NicProfile; -import com.cloud.vm.NicVO; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.ReservationContextImpl; -import com.cloud.vm.SecondaryStorageVmVO; -import com.cloud.vm.UserVmVO; -import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.VirtualMachine; +import com.cloud.vm.*; import com.cloud.vm.VirtualMachine.Type; -import com.cloud.vm.VirtualMachineProfile; -import com.cloud.vm.VirtualMachineProfileImpl; import com.cloud.vm.dao.DomainRouterDao; import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.VMInstanceDao; import edu.emory.mathcs.backport.java.util.Collections; +import org.apache.log4j.Logger; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; +import java.net.URI; +import java.security.InvalidParameterException; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * NetworkManagerImpl implements NetworkManager. @@ -1163,7 +1071,17 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag IPAddressVO ipToAssoc = _ipAddressDao.findById(ipId); if (ipToAssoc != null) { - _accountMgr.checkAccess(caller, null, true, ipToAssoc); + Network network = _networksDao.findById(networkId); + if (network == null) { + throw new InvalidParameterValueException("Invalid network id is given"); + } + + DataCenter zone = _configMgr.getZone(network.getDataCenterId()); + if (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced && isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { + _accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network); + } else { + _accountMgr.checkAccess(caller, null, true, ipToAssoc); + } owner = _accountMgr.getAccount(ipToAssoc.getAllocatedToAccountId()); } else { s_logger.debug("Unable to find ip address by id: " + ipId); @@ -1187,21 +1105,24 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // allow associating IP addresses to guest network only if (network.getTrafficType() != TrafficType.Guest) { - throw new InvalidParameterValueException("Ip address can be associated to the network with trafficType " + - TrafficType.Guest); + throw new InvalidParameterValueException("Ip address can be associated to the network with trafficType " + TrafficType.Guest); } - // Check that network belongs to IP owner - skip this check for Basic zone as there is just one guest network, - // and it belongs to the system - if (zone.getNetworkType() != NetworkType.Basic && network.getAccountId() != owner.getId()) { - throw new InvalidParameterValueException("The owner of the network is not the same as owner of the IP"); + // Check that network belongs to IP owner - skip this check + // - if zone is basic zone as there is just one guest network, + // - if shared network in Advanced zone + // - and it belongs to the system + if (network.getAccountId() != owner.getId()) { + if (zone.getNetworkType() != NetworkType.Basic && !(zone.getNetworkType() == NetworkType.Advanced && network.getGuestType() == Network.GuestType.Shared)) { + throw new InvalidParameterValueException("The owner of the network is not the same as owner of the IP"); + } } - - // In Advance zone only allow to do IP assoc for Isolated networks with source nat service enabled - if (zone.getNetworkType() == NetworkType.Advanced && - !(network.getGuestType() == GuestType.Isolated && areServicesSupportedInNetwork(network.getId(), - Service.SourceNat))) { - throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + + + // In Advance zone only allow to do IP assoc + // - for Isolated networks with source nat service enabled + // - for shared networks with source nat service enabled + if (zone.getNetworkType() == NetworkType.Advanced && (!areServicesSupportedInNetwork(network.getId(), Service.SourceNat))) { + throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + " ip address can be associated only to the network of guest type " + GuestType.Isolated + " with the " + Service.SourceNat.getName() + " enabled"); } @@ -1971,12 +1892,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag try { NetworkGuru guru = _networkGurus.get(network.getGuruName()); Network.State state = network.getState(); - if (state == Network.State.Implemented || state == Network.State.Setup || state == Network.State.Implementing) { + if (state == Network.State.Implemented || state == Network.State.Implementing) { s_logger.debug("Network id=" + networkId + " is already implemented"); implemented.set(guru, network); return implemented; } + if (state == Network.State.Setup) { + DataCenterVO zone = _dcDao.findById(network.getDataCenterId()); + if (!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) || (zone.getNetworkType() == NetworkType.Basic)) { + s_logger.debug("Network id=" + networkId + " is already implemented"); + implemented.set(guru, network); + return implemented; + } + } + if (s_logger.isDebugEnabled()) { s_logger.debug("Asking " + guru.getName() + " to implement " + network); } @@ -2020,19 +1950,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } - private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, - NetworkVO network, NetworkOfferingVO offering) + private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, + NetworkVO network, NetworkOfferingVO offering) throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException { - // If this is a 1) guest virtual network 2) network has sourceNat service 3) network offering does not support a - // Shared source NAT rule, - // associate a source NAT IP (if one isn't already associated with the network) + + // Associate a source NAT IP (if one isn't already associated with the network) if this is a + // 1) 'Isolated' or 'Shared' guest virtual network in the advance zone + // 2) network has sourceNat service + // 3) network offering does not support a shared source NAT rule boolean sharedSourceNat = offering.getSharedSourceNat(); + DataCenter zone = _dcDao.findById(network.getDataCenterId()); + if (!sharedSourceNat && areServicesSupportedInNetwork(network.getId(), Service.SourceNat) + && (network.getGuestType() == Network.GuestType.Isolated || + (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced))) { - if (network.getGuestType() == Network.GuestType.Isolated - && areServicesSupportedInNetwork(network.getId(), Service.SourceNat) - && !sharedSourceNat) { - List ips = null; if (network.getVpcId() != null) { ips = _ipAddressDao.listByAssociatedVpc(network.getVpcId(), true); @@ -2062,9 +1994,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId()); } + if (s_logger.isDebugEnabled()) { s_logger.debug("Asking " + element.getName() + " to implemenet " + network); } + if (!element.implement(network, offering, dest, context)) { CloudRuntimeException ex = new CloudRuntimeException("Failed to implement provider " + element.getProvider().getName() + " for network with specified id"); ex.addProxyObject(network, network.getId(), "networkId"); From 6657246cd44629c30e6ea21cc4bbd43a42788e12 Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Fri, 26 Oct 2012 19:31:05 +0530 Subject: [PATCH 034/145] Summary: partical check-in for L4-L7 network services in the shared network in the advanced zone Changing the F5, NetScaler, SRX network elemetns to handle both 'isolated networks' and 'shared networks' in the advanced zone Bug ID:CLOUDSTACK-312 enable L4-L7 network services in the shared network in the advanced zone --- .../cloud/network/element/F5ExternalLoadBalancerElement.java | 2 +- .../network/element/JuniperSRXExternalFirewallElement.java | 3 ++- .../src/com/cloud/network/element/NetscalerElement.java | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java index 00114f2575f..579a4628c74 100644 --- a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java +++ b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java @@ -117,7 +117,7 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan ConfigurationDao _configDao; private boolean canHandle(Network config) { - if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) { + if ((config.getGuestType() != Network.GuestType.Isolated && config.getGuestType() != Network.GuestType.Shared) || config.getTrafficType() != TrafficType.Guest) { s_logger.trace("Not handling network with Type " + config.getGuestType() + " and traffic type " + config.getTrafficType()); return false; } diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java b/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java index 6e815476804..95bc031726a 100644 --- a/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java +++ b/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java @@ -125,7 +125,8 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan private boolean canHandle(Network network, Service service) { DataCenter zone = _configMgr.getZone(network.getDataCenterId()); - if ((zone.getNetworkType() == NetworkType.Advanced && network.getGuestType() != Network.GuestType.Isolated) || (zone.getNetworkType() == NetworkType.Basic && network.getGuestType() != Network.GuestType.Shared)) { + if ((zone.getNetworkType() == NetworkType.Advanced && !(network.getGuestType() == Network.GuestType.Isolated || network.getGuestType() == Network.GuestType.Shared )) + || (zone.getNetworkType() == NetworkType.Basic && network.getGuestType() != Network.GuestType.Shared)) { s_logger.trace("Element " + getProvider().getName() + "is not handling network type = " + network.getGuestType()); return false; } diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java index 4ec1c072991..987e937952d 100644 --- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java +++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java @@ -149,7 +149,8 @@ StaticNatServiceProvider { private boolean canHandle(Network config, Service service) { DataCenter zone = _dcDao.findById(config.getDataCenterId()); - boolean handleInAdvanceZone = (zone.getNetworkType() == NetworkType.Advanced && config.getGuestType() == Network.GuestType.Isolated && config.getTrafficType() == TrafficType.Guest); + boolean handleInAdvanceZone = (zone.getNetworkType() == NetworkType.Advanced && + (config.getGuestType() == Network.GuestType.Isolated || config.getGuestType() == Network.GuestType.Shared) && config.getTrafficType() == TrafficType.Guest); boolean handleInBasicZone = (zone.getNetworkType() == NetworkType.Basic && config.getGuestType() == Network.GuestType.Shared && config.getTrafficType() == TrafficType.Guest); if (!(handleInAdvanceZone || handleInBasicZone)) { From d4c604cfd8ec6b385de7abf694a936e89add0f38 Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Mon, 29 Oct 2012 17:14:21 +0530 Subject: [PATCH 035/145] Summary: partical check-in for L4-L7 network services in the shared network in the advanced zone Details : ensure that CIDR specified for shared network does not overlap with any CloudStack generated CIDR's for isaolated guest networks when using external networking devices Bug ID:CLOUDSTACK-312 enable L4-L7 network services in the shared network in the advanced zone Conflicts: server/src/com/cloud/network/NetworkManagerImpl.java --- .../com/cloud/network/NetworkManagerImpl.java | 80 ++++++++++++------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 0ac44fa2176..39d7f54bd0c 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -924,14 +924,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override @ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "allocating Ip", create = true) - public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) + public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException { + if (networkId != null) { Network network = _networksDao.findById(networkId); if (network == null) { throw new InvalidParameterValueException("Invalid network id is given"); } - if (network.getGuestType() == Network.GuestType.Shared) { DataCenter zone = _configMgr.getZone(zoneId); if (zone == null) { @@ -946,9 +946,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (s_logger.isDebugEnabled()) { s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); } - return allocateIp(ipOwner, false, caller, callerUserId, zone); + return allocateIp(ipOwner, false, caller, zone); } else { - throw new InvalidParameterValueException("Associate IP address can only called on the shared networks in the advanced zone" + + throw new InvalidParameterValueException("Associate IP address can only be called on the shared networks in the advanced zone" + " with Firewall/Source Nat/Static Nat/Port Forwarding/Load balancing services enabled"); } } @@ -966,11 +966,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag DataCenter zone = _configMgr.getZone(zoneId); - return allocateIp(ipOwner, isSystem, caller, callerUserId, zone); + return allocateIp(ipOwner, isSystem, caller, zone); } @DB - public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerUserId, DataCenter zone) + public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, DataCenter zone) throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException { @@ -991,7 +991,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Account accountToLock = null; try { if (s_logger.isDebugEnabled()) { - s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId()); + s_logger.debug("Associate IP address called by the user " + caller.getId()); } accountToLock = _accountDao.acquireInLockTable(ipOwner.getId()); if (accountToLock == null) { @@ -1077,8 +1077,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } DataCenter zone = _configMgr.getZone(network.getDataCenterId()); - if (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced && isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { - _accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network); + if (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced) { + if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) { + _accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network); + } else { + throw new InvalidParameterValueException("IP can be associated with guest network of 'shared' type only if" + + "network service Source Nat, Static Nat, Port Forwarding, Load balancing, firewall are enabled in the network"); + } } else { _accountMgr.checkAccess(caller, null, true, ipToAssoc); } @@ -1950,6 +1955,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } + @Override + public boolean equals(Object o) { + return super.equals(o); //To change body of overridden methods use File | Settings | File Templates. + } + private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, NetworkVO network, NetworkOfferingVO offering) throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException { @@ -2438,17 +2448,36 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } } - private void checkSharedNetworkCidrOverlap(Long zoneId, String cidr) { - if (zoneId == null) { - return; - } - - if (cidr == null) { + private void checkSharedNetworkCidrOverlap(Long zoneId, long physicalNetworkId, String cidr) { + if (zoneId == null || cidr == null) { return; } + DataCenter zone = _dcDao.findById(zoneId); List networks = _networksDao.listByZone(zoneId); Map networkToCidr = new HashMap(); + + // check for CIDR overlap with all possible CIDR for isolated guest networks + // in the zone when using external networking + PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId); + if (pNetwork.getVnet() != null) { + String vlanRange[] = pNetwork.getVnet().split("-"); + int lowestVlanTag = Integer.valueOf(vlanRange[0]); + int highestVlanTag = Integer.valueOf(vlanRange[1]); + for (int vlan=lowestVlanTag; vlan <= highestVlanTag; ++vlan) { + int offset = vlan - lowestVlanTag; + String globalVlanBits = _configDao.getValue(Config.GuestVlanBits.key()); + int cidrSize = 8 + Integer.parseInt(globalVlanBits); + String guestNetworkCidr = zone.getGuestNetworkCidr(); + String[] cidrTuple = guestNetworkCidr.split("\\/"); + long newCidrAddress = (NetUtils.ip2Long(cidrTuple[0]) & 0xff000000) | (offset << (32 - cidrSize)); + if (NetUtils.isNetworksOverlap(NetUtils.long2Ip(newCidrAddress), cidr)) { + throw new InvalidParameterValueException("Specified CIDR for shared network conflict with CIDR that is reserved for zone vlan " + vlan); + } + } + } + + // check for CIDR overlap with all CIDR's of the shared networks in the zone for (NetworkVO network : networks) { if (network.getGuestType() == GuestType.Isolated) { continue; @@ -2457,22 +2486,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag networkToCidr.put(network.getId(), network.getCidr()); } } - - //TODO: check for CIDR overlap with all possible CIDR for guest networks in the zone - //when using external networking - - if (networkToCidr == null || networkToCidr.isEmpty()) { - return; - } - - for (long networkId : networkToCidr.keySet()) { - String ntwkCidr = networkToCidr.get(networkId); - if (NetUtils.isNetworksOverlap(ntwkCidr, cidr)) { - throw new InvalidParameterValueException("Warning: The specified existing network has conflict CIDR subnets with new network!"); + if (networkToCidr != null && !networkToCidr.isEmpty()) { + for (long networkId : networkToCidr.keySet()) { + String ntwkCidr = networkToCidr.get(networkId); + if (NetUtils.isNetworksOverlap(ntwkCidr, cidr)) { + throw new InvalidParameterValueException("Specified CIDR for shared network conflict with CIDR of a shared network in the zone."); + } } } } - public void checkVirtualNetworkCidrOverlap(Long zoneId, String cidr) { if (zoneId == null) { return; @@ -2700,7 +2722,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (ntwkOff.getGuestType() == GuestType.Shared && (zone.getNetworkType() == NetworkType.Advanced) && isSharedNetworkOfferingWithServices(networkOfferingId)) { // validate if CIDR specified overlaps with any of the CIDR's allocated for isolated networks and shared networks in the zone - checkSharedNetworkCidrOverlap(zoneId, cidr); + checkSharedNetworkCidrOverlap(zoneId, pNtwk.getId(), cidr); } else { throw new InvalidParameterValueException("Cannot specify CIDR when using network offering with external devices!"); } From 7fcfcdf91e49d64375171c9ae7fe61067aa59b6e Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Thu, 6 Dec 2012 13:06:18 +0530 Subject: [PATCH 036/145] Summary: check-in for L4-L7 network services in the shared network in the advanced zone Details: 1). Added validation to check the Vlan Id specified in the createNetwork() does not overlap with any of the vlan's used by isolated networks or shared networks in the zone. 2). state change for shared network with services to go to 'Setup' state on network shutdown instead of 'Allocated' Bug ID:CLOUDSTACK-312 enable L4-L7 network services in the shared network in the advanced zone --- .../com/cloud/network/NetworkManagerImpl.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 39d7f54bd0c..b3fdf32aa7f 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -2911,10 +2911,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId); } } else { - //don't allow to create Shared network with Vlan that already exists in the zone for Isolated networks - if (_networksDao.countByZoneUriAndGuestType(zoneId, uri, GuestType.Isolated) > 0) { - throw new InvalidParameterValueException("Isolated network with vlan " + vlanId + " already exists " + - "in zone " + zoneId); + //don't allow to creating shared network with given Vlan ID, if there already exists a isolated network or + //shared network with same Vlan ID in the zone + if (_networksDao.countByZoneUriAndGuestType(zoneId, uri, GuestType.Isolated) > 0 || + _networksDao.countByZoneUriAndGuestType(zoneId, uri, GuestType.Shared) > 0) { + throw new InvalidParameterValueException("There is a isolated/shared network with vlan id: " + vlanId + " already exists " + "in zone " + zoneId); } } } @@ -3502,7 +3503,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag applyProfileToNetwork(network, profile); - network.setState(Network.State.Allocated); + DataCenterVO zone = _dcDao.findById(network.getDataCenterId()); + if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) && (zone.getNetworkType() == NetworkType.Advanced)) { + network.setState(Network.State.Setup); + } else { + network.setState(Network.State.Allocated); + } + network.setRestartRequired(false); _networksDao.update(network.getId(), network); _networksDao.clearCheckForGc(networkId); From b0955e43ff24ec849a86609faff9edeb98bcbcc9 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Sun, 2 Dec 2012 12:02:00 -0800 Subject: [PATCH 037/145] Put the mockito version in the central version list --- plugins/network-elements/nicira-nvp/pom.xml | 8 -------- pom.xml | 1 + 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml index 294e88be9db..70f85607e4a 100644 --- a/plugins/network-elements/nicira-nvp/pom.xml +++ b/plugins/network-elements/nicira-nvp/pom.xml @@ -26,12 +26,4 @@ 4.1.0-SNAPSHOT ../../pom.xml - - - org.mockito - mockito-all - 1.9.5 - test - - diff --git a/pom.xml b/pom.xml index 4a4276e981a..2c2600b552f 100644 --- a/pom.xml +++ b/pom.xml @@ -81,6 +81,7 @@ 1.2 1.0-20081010.060147 4.1 + 1.9.5 From 700050a713575e59c72bdcecae2f341f85180c60 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Sun, 2 Dec 2012 12:02:19 -0800 Subject: [PATCH 038/145] More unittests for NiciraNvpResource Add some basic unittest for NatRule --- .../com/cloud/network/nicira/NatRuleTest.java | 47 +++ .../resource/NiciraNvpResourceTest.java | 355 +++++++++++++++++- 2 files changed, 392 insertions(+), 10 deletions(-) create mode 100644 plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java new file mode 100644 index 00000000000..88c5402822d --- /dev/null +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java @@ -0,0 +1,47 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 com.cloud.network.nicira; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.google.gson.Gson; + +public class NatRuleTest { + + Gson gson = new Gson(); + + @Test + public void testNatRuleEncoding() { + NatRule rn1 = new NatRule(); + rn1.setToDestinationIpAddressMax("10.10.10.10"); + rn1.setToDestinationIpAddressMin("10.10.10.10"); + rn1.setToDestinationPort(80); + Match mr1 = new Match(); + mr1.setSourceIpAddresses("11.11.11.11/24"); + mr1.setEthertype("IPv4"); + mr1.setProtocol(6); + rn1.setMatch(mr1); + + + String jsonString = gson.toJson(rn1); + NatRule dnr = gson.fromJson(jsonString, NatRule.class); + + assertTrue(rn1.equals(dnr)); + } +} diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java index 7632703aecd..3fdd3e3f28a 100644 --- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java @@ -27,21 +27,58 @@ import javax.naming.ConfigurationException; import org.junit.Before; import org.junit.Test; - +import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer; +import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand; +import com.cloud.agent.api.CreateLogicalRouterAnswer; +import com.cloud.agent.api.CreateLogicalRouterCommand; +import com.cloud.agent.api.CreateLogicalSwitchAnswer; +import com.cloud.agent.api.CreateLogicalSwitchCommand; +import com.cloud.agent.api.CreateLogicalSwitchPortAnswer; +import com.cloud.agent.api.CreateLogicalSwitchPortCommand; +import com.cloud.agent.api.DeleteLogicalRouterAnswer; +import com.cloud.agent.api.DeleteLogicalRouterCommand; +import com.cloud.agent.api.DeleteLogicalSwitchAnswer; +import com.cloud.agent.api.DeleteLogicalSwitchCommand; +import com.cloud.agent.api.DeleteLogicalSwitchPortAnswer; +import com.cloud.agent.api.DeleteLogicalSwitchPortCommand; +import com.cloud.agent.api.FindLogicalSwitchPortAnswer; +import com.cloud.agent.api.FindLogicalSwitchPortCommand; +import com.cloud.agent.api.PingCommand; +import com.cloud.agent.api.StartupCommand; +import com.cloud.agent.api.UpdateLogicalSwitchPortAnswer; +import com.cloud.agent.api.UpdateLogicalSwitchPortCommand; import com.cloud.host.Host; +import com.cloud.network.nicira.Attachment; +import com.cloud.network.nicira.ControlClusterStatus; +import com.cloud.network.nicira.LogicalRouterConfig; +import com.cloud.network.nicira.LogicalRouterPort; +import com.cloud.network.nicira.LogicalSwitch; +import com.cloud.network.nicira.LogicalSwitchPort; +import com.cloud.network.nicira.NatRule; import com.cloud.network.nicira.NiciraNvpApi; +import com.cloud.network.nicira.NiciraNvpApiException; +import com.cloud.network.nicira.NiciraNvpList; public class NiciraNvpResourceTest { NiciraNvpApi _nvpApi = mock(NiciraNvpApi.class); NiciraNvpResource _resource; + Map _parameters; @Before - public void setUp() { + public void setUp() throws ConfigurationException { _resource = new NiciraNvpResource() { protected NiciraNvpApi createNiciraNvpApi() { return _nvpApi; } }; + + _parameters = new HashMap(); + _parameters.put("name","nvptestdevice"); + _parameters.put("ip","127.0.0.1"); + _parameters.put("adminuser","adminuser"); + _parameters.put("guid", "aaaaa-bbbbb-ccccc"); + _parameters.put("zoneId", "blublub"); + _parameters.put("adminpass","adminpass"); } @Test (expected=ConfigurationException.class) @@ -51,14 +88,7 @@ public class NiciraNvpResourceTest { @Test public void resourceConfigure() throws ConfigurationException { - Map parameters = new HashMap(); - parameters.put("name","nvptestdevice"); - parameters.put("ip","127.0.0.1"); - parameters.put("adminuser","adminuser"); - parameters.put("guid", "aaaaa-bbbbb-ccccc"); - parameters.put("zoneId", "blublub"); - parameters.put("adminpass","adminpass"); - _resource.configure("NiciraNvpResource", parameters); + _resource.configure("NiciraNvpResource", _parameters); verify(_nvpApi).setAdminCredentials("adminuser", "adminpass"); verify(_nvpApi).setControllerAddress("127.0.0.1"); @@ -71,4 +101,309 @@ public class NiciraNvpResourceTest { assertTrue(_resource.getType() == Host.Type.L2Networking); } + @Test + public void testInitialization() throws ConfigurationException { + _resource.configure("NiciraNvpResource", _parameters); + + StartupCommand[] sc = _resource.initialize(); + assertTrue(sc.length ==1); + assertTrue("aaaaa-bbbbb-ccccc".equals(sc[0].getGuid())); + assertTrue("nvptestdevice".equals(sc[0].getName())); + assertTrue("blublub".equals(sc[0].getDataCenter())); + } + + @Test + public void testPingCommandStatusOk() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + ControlClusterStatus ccs = mock(ControlClusterStatus.class); + when(ccs.getClusterStatus()).thenReturn("stable"); + when(_nvpApi.getControlClusterStatus()).thenReturn(ccs); + + PingCommand ping = _resource.getCurrentStatus(42); + assertTrue(ping != null); + assertTrue(ping.getHostId() == 42); + assertTrue(ping.getHostType() == Host.Type.L2Networking); + } + + @Test + public void testPingCommandStatusFail() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + ControlClusterStatus ccs = mock(ControlClusterStatus.class); + when(ccs.getClusterStatus()).thenReturn("unstable"); + when(_nvpApi.getControlClusterStatus()).thenReturn(ccs); + + PingCommand ping = _resource.getCurrentStatus(42); + assertTrue(ping == null); + } + + @Test + public void testPingCommandStatusApiException() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + ControlClusterStatus ccs = mock(ControlClusterStatus.class); + when(ccs.getClusterStatus()).thenReturn("unstable"); + when(_nvpApi.getControlClusterStatus()).thenThrow(new NiciraNvpApiException()); + + PingCommand ping = _resource.getCurrentStatus(42); + assertTrue(ping == null); + } + + @Test + public void testRetries() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalSwitch ls = mock(LogicalSwitch.class); + when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc"); + when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException()).thenThrow(new NiciraNvpApiException()).thenReturn(ls); + + CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner"); + CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc); + assertTrue(clsa.getResult()); + } + + @Test + public void testCreateLogicalSwitch() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalSwitch ls = mock(LogicalSwitch.class); + when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc"); + when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenReturn(ls); + + CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner"); + CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc); + assertTrue(clsa.getResult()); + assertTrue("cccc".equals(clsa.getLogicalSwitchUuid())); + } + + @Test + public void testCreateLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalSwitch ls = mock(LogicalSwitch.class); + when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc"); + when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException()); + + CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner"); + CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc); + assertFalse(clsa.getResult()); + } + + @Test + public void testDeleteLogicalSwitch() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc"); + DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc); + assertTrue(dlsa.getResult()); + } + + @Test + public void testDeleteLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitch((String)any()); + + DeleteLogicalSwitchCommand dlsc = new DeleteLogicalSwitchCommand("cccc"); + DeleteLogicalSwitchAnswer dlsa = (DeleteLogicalSwitchAnswer) _resource.executeRequest(dlsc); + assertFalse(dlsa.getResult()); + } + + @Test + public void testCreateLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalSwitchPort lsp = mock(LogicalSwitchPort.class); + when(lsp.getUuid()).thenReturn("eeee"); + when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp); + + CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname"); + CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc); + assertTrue(clspa.getResult()); + assertTrue("eeee".equals(clspa.getLogicalSwitchPortUuid())); + + } + + @Test + public void testCreateLogicalSwitchPortApiExceptionInCreate() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalSwitchPort lsp = mock(LogicalSwitchPort.class); + when(lsp.getUuid()).thenReturn("eeee"); + when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenThrow(new NiciraNvpApiException()); + + CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname"); + CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc); + assertFalse(clspa.getResult()); + } + + @Test + public void testCreateLogicalSwitchPortApiExceptionInModify() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalSwitchPort lsp = mock(LogicalSwitchPort.class); + when(lsp.getUuid()).thenReturn("eeee"); + when(_nvpApi.createLogicalSwitchPort(eq("cccc"), (LogicalSwitchPort) any())).thenReturn(lsp); + doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String)any(), (String)any(), (Attachment)any()); + + + CreateLogicalSwitchPortCommand clspc = new CreateLogicalSwitchPortCommand("cccc", "dddd", "owner", "nicname"); + CreateLogicalSwitchPortAnswer clspa = (CreateLogicalSwitchPortAnswer) _resource.executeRequest(clspc); + assertFalse(clspa.getResult()); + verify(_nvpApi, atLeastOnce()).deleteLogicalSwitchPort((String) any(), (String) any()); + } + + @Test + public void testDeleteLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalSwitchPort((String) any(), (String) any()); + DeleteLogicalSwitchPortAnswer dlspa = (DeleteLogicalSwitchPortAnswer) _resource.executeRequest(new DeleteLogicalSwitchPortCommand("aaaa","bbbb")); + assertFalse(dlspa.getResult()); + } + + @Test + public void testUpdateLogicalSwitchPortException() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalSwitchPortAttachment((String) any(), (String) any(), (Attachment) any()); + UpdateLogicalSwitchPortAnswer dlspa = (UpdateLogicalSwitchPortAnswer) _resource.executeRequest( + new UpdateLogicalSwitchPortCommand("aaaa","bbbb","cccc","owner","nicname")); + assertFalse(dlspa.getResult()); + } + + @Test + public void testFindLogicalSwitchPort() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + @SuppressWarnings("unchecked") + NiciraNvpList lspl = (NiciraNvpList)mock(NiciraNvpList.class); + when(lspl.getResultCount()).thenReturn(1); + when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl); + + FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb")); + assertTrue(flspa.getResult()); + } + + @Test + public void testFindLogicalSwitchPortNotFound() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + @SuppressWarnings("unchecked") + NiciraNvpList lspl = (NiciraNvpList)mock(NiciraNvpList.class); + when(lspl.getResultCount()).thenReturn(0); + when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenReturn(lspl); + + FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb")); + assertFalse(flspa.getResult()); + } + + @Test + public void testFindLogicalSwitchPortApiException() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + when(_nvpApi.findLogicalSwitchPortsByUuid("aaaa", "bbbb")).thenThrow(new NiciraNvpApiException()); + + FindLogicalSwitchPortAnswer flspa = (FindLogicalSwitchPortAnswer) _resource.executeRequest(new FindLogicalSwitchPortCommand("aaaa", "bbbb")); + assertFalse(flspa.getResult()); + } + + @Test + public void testCreateLogicalRouter() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalRouterConfig lrc = mock(LogicalRouterConfig.class); + LogicalRouterPort lrp = mock(LogicalRouterPort.class); + LogicalSwitchPort lsp = mock(LogicalSwitchPort.class); + when(lrc.getUuid()).thenReturn("ccccc"); + when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee"); + when(lsp.getUuid()).thenReturn("fffff"); + when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc); + when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp); + when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp); + CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner"); + CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc); + + assertTrue(clra.getResult()); + assertTrue("ccccc".equals(clra.getLogicalRouterUuid())); + verify(_nvpApi, atLeast(1)).createLogicalRouterNatRule((String) any(), (NatRule) any()); + } + + @Test + public void testCreateLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenThrow(new NiciraNvpApiException()); + CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner"); + CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc); + + assertFalse(clra.getResult()); + } + + @Test + public void testCreateLogicalRouterApiExceptionRollbackRouter() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalRouterConfig lrc = mock(LogicalRouterConfig.class); + when(lrc.getUuid()).thenReturn("ccccc"); + when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc); + when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenThrow(new NiciraNvpApiException()); + CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner"); + CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc); + + assertFalse(clra.getResult()); + verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc")); + } + + @Test + public void testCreateLogicalRouterApiExceptionRollbackRouterAndSwitchPort() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + LogicalRouterConfig lrc = mock(LogicalRouterConfig.class); + LogicalRouterPort lrp = mock(LogicalRouterPort.class); + LogicalSwitchPort lsp = mock(LogicalSwitchPort.class); + when(lrc.getUuid()).thenReturn("ccccc"); + when(lrp.getUuid()).thenReturn("ddddd").thenReturn("eeeee"); + when(lsp.getUuid()).thenReturn("fffff"); + when(_nvpApi.createLogicalRouter((LogicalRouterConfig)any())).thenReturn(lrc); + when(_nvpApi.createLogicalRouterPort(eq("ccccc"), (LogicalRouterPort)any())).thenReturn(lrp); + when(_nvpApi.createLogicalSwitchPort(eq("bbbbb"), (LogicalSwitchPort)any())).thenReturn(lsp); + when(_nvpApi.createLogicalRouterNatRule((String) any(), (NatRule)any())).thenThrow(new NiciraNvpApiException()); + CreateLogicalRouterCommand clrc = new CreateLogicalRouterCommand("aaaaa", 50, "bbbbb", "lrouter", "publiccidr", "nexthop", "internalcidr", "owner"); + CreateLogicalRouterAnswer clra = (CreateLogicalRouterAnswer) _resource.executeRequest(clrc); + + assertFalse(clra.getResult()); + verify(_nvpApi, atLeast(1)).deleteLogicalRouter(eq("ccccc")); + verify(_nvpApi, atLeast(1)).deleteLogicalSwitchPort(eq("bbbbb"), eq("fffff")); + } + + @Test + public void testDeleteLogicalRouterApiException() throws ConfigurationException,NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + doThrow(new NiciraNvpApiException()).when(_nvpApi).deleteLogicalRouter(eq("aaaaa")); + DeleteLogicalRouterAnswer dlspa = (DeleteLogicalRouterAnswer) _resource.executeRequest(new DeleteLogicalRouterCommand("aaaaa")); + assertFalse(dlspa.getResult()); + } + + @Test + public void testConfigurePublicIpsOnLogicalRouterApiException() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + + ConfigurePublicIpsOnLogicalRouterCommand cmd = mock(ConfigurePublicIpsOnLogicalRouterCommand.class); + @SuppressWarnings("unchecked") + NiciraNvpList list = mock(NiciraNvpList.class); + + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + when(cmd.getL3GatewayServiceUuid()).thenReturn("bbbbb"); + doThrow(new NiciraNvpApiException()).when(_nvpApi).modifyLogicalRouterPort((String) any(), (LogicalRouterPort) any()); + when(_nvpApi.findLogicalRouterPortByGatewayServiceUuid("aaaaa","bbbbb")).thenReturn(list); + + ConfigurePublicIpsOnLogicalRouterAnswer answer = + (ConfigurePublicIpsOnLogicalRouterAnswer) _resource.executeRequest(cmd); + assertFalse(answer.getResult()); + + } } + From 48308ec0703b3c60f6b931681ec81978cea4cbf4 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Wed, 5 Dec 2012 16:28:29 +0100 Subject: [PATCH 039/145] Redoing NatRule usage and some fixes based on issues found while writing unittests --- .../network/nicira/DestinationNatRule.java | 24 ---- .../src/com/cloud/network/nicira/Match.java | 120 ++++++++++++++++++ .../src/com/cloud/network/nicira/NatRule.java | 110 ++++++++++++++++ .../cloud/network/nicira/NiciraNvpApi.java | 9 +- .../cloud/network/nicira/SourceNatRule.java | 27 ---- .../network/resource/NiciraNvpResource.java | 68 ++++++---- 6 files changed, 277 insertions(+), 81 deletions(-) delete mode 100644 plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java delete mode 100644 plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java deleted file mode 100644 index f1ea9052a41..00000000000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/DestinationNatRule.java +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 com.cloud.network.nicira; - -public class DestinationNatRule extends NatRule { - { - type = "DestinationNatRule"; - } - -} diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java index ce5205ba47f..034a7de13d9 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java @@ -128,6 +128,126 @@ public class Match { public void setDestinationIpAddressesNot(Boolean destination_ip_addresses_not) { this.destination_ip_addresses_not = destination_ip_addresses_not; } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime + * result + + ((destination_ip_addresses == null) ? 0 + : destination_ip_addresses.hashCode()); + result = prime + * result + + ((destination_ip_addresses_not == null) ? 0 + : destination_ip_addresses_not.hashCode()); + result = prime + * result + + ((destination_port_max == null) ? 0 : destination_port_max + .hashCode()); + result = prime + * result + + ((destination_port_min == null) ? 0 : destination_port_min + .hashCode()); + result = prime + * result + + ((destination_port_not == null) ? 0 : destination_port_not + .hashCode()); + result = prime * result + + ((ethertype == null) ? 0 : ethertype.hashCode()); + result = prime * result + + ((protocol == null) ? 0 : protocol.hashCode()); + result = prime + * result + + ((source_ip_addresses == null) ? 0 : source_ip_addresses + .hashCode()); + result = prime + * result + + ((source_ip_addresses_not == null) ? 0 + : source_ip_addresses_not.hashCode()); + result = prime * result + + ((source_port_max == null) ? 0 : source_port_max.hashCode()); + result = prime * result + + ((source_port_min == null) ? 0 : source_port_min.hashCode()); + result = prime * result + + ((source_port_not == null) ? 0 : source_port_not.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Match other = (Match) obj; + if (destination_ip_addresses == null) { + if (other.destination_ip_addresses != null) + return false; + } else if (!destination_ip_addresses + .equals(other.destination_ip_addresses)) + return false; + if (destination_ip_addresses_not == null) { + if (other.destination_ip_addresses_not != null) + return false; + } else if (!destination_ip_addresses_not + .equals(other.destination_ip_addresses_not)) + return false; + if (destination_port_max == null) { + if (other.destination_port_max != null) + return false; + } else if (!destination_port_max.equals(other.destination_port_max)) + return false; + if (destination_port_min == null) { + if (other.destination_port_min != null) + return false; + } else if (!destination_port_min.equals(other.destination_port_min)) + return false; + if (destination_port_not == null) { + if (other.destination_port_not != null) + return false; + } else if (!destination_port_not.equals(other.destination_port_not)) + return false; + if (ethertype == null) { + if (other.ethertype != null) + return false; + } else if (!ethertype.equals(other.ethertype)) + return false; + if (protocol == null) { + if (other.protocol != null) + return false; + } else if (!protocol.equals(other.protocol)) + return false; + if (source_ip_addresses == null) { + if (other.source_ip_addresses != null) + return false; + } else if (!source_ip_addresses.equals(other.source_ip_addresses)) + return false; + if (source_ip_addresses_not == null) { + if (other.source_ip_addresses_not != null) + return false; + } else if (!source_ip_addresses_not + .equals(other.source_ip_addresses_not)) + return false; + if (source_port_max == null) { + if (other.source_port_max != null) + return false; + } else if (!source_port_max.equals(other.source_port_max)) + return false; + if (source_port_min == null) { + if (other.source_port_min != null) + return false; + } else if (!source_port_min.equals(other.source_port_min)) + return false; + if (source_port_not == null) { + if (other.source_port_not != null) + return false; + } else if (!source_port_not.equals(other.source_port_not)) + return false; + return true; + } } diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java index 7255ab67d39..46437071be9 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java @@ -110,4 +110,114 @@ public class NatRule { public String getType() { return type; } + + public void setType(String type) { + this.type = type; + } + + @Override + public int hashCode() { + final int prime = 42; + int result = 1; + result = prime * result + ((match == null) ? 0 : match.hashCode()); + result = prime + * result + + ((to_destination_ip_address_max == null) ? 0 + : to_destination_ip_address_max.hashCode()); + result = prime + * result + + ((to_destination_ip_address_min == null) ? 0 + : to_destination_ip_address_min.hashCode()); + result = prime + * result + + ((to_destination_port == null) ? 0 : to_destination_port + .hashCode()); + result = prime + * result + + ((to_source_ip_address_max == null) ? 0 + : to_source_ip_address_max.hashCode()); + result = prime + * result + + ((to_source_ip_address_min == null) ? 0 + : to_source_ip_address_min.hashCode()); + result = prime + * result + + ((to_source_port_max == null) ? 0 : to_source_port_max + .hashCode()); + result = prime + * result + + ((to_source_port_min == null) ? 0 : to_source_port_min + .hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((uuid == null) ? 0 : uuid.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NatRule other = (NatRule) obj; + if (match == null) { + if (other.match != null) + return false; + } else if (!match.equals(other.match)) + return false; + if (to_destination_ip_address_max == null) { + if (other.to_destination_ip_address_max != null) + return false; + } else if (!to_destination_ip_address_max + .equals(other.to_destination_ip_address_max)) + return false; + if (to_destination_ip_address_min == null) { + if (other.to_destination_ip_address_min != null) + return false; + } else if (!to_destination_ip_address_min + .equals(other.to_destination_ip_address_min)) + return false; + if (to_destination_port == null) { + if (other.to_destination_port != null) + return false; + } else if (!to_destination_port.equals(other.to_destination_port)) + return false; + if (to_source_ip_address_max == null) { + if (other.to_source_ip_address_max != null) + return false; + } else if (!to_source_ip_address_max + .equals(other.to_source_ip_address_max)) + return false; + if (to_source_ip_address_min == null) { + if (other.to_source_ip_address_min != null) + return false; + } else if (!to_source_ip_address_min + .equals(other.to_source_ip_address_min)) + return false; + if (to_source_port_max == null) { + if (other.to_source_port_max != null) + return false; + } else if (!to_source_port_max.equals(other.to_source_port_max)) + return false; + if (to_source_port_min == null) { + if (other.to_source_port_min != null) + return false; + } else if (!to_source_port_min.equals(other.to_source_port_min)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + if (uuid == null) { + if (other.uuid != null) + return false; + } else if (!uuid.equals(other.uuid)) + return false; + return true; + } + + } diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java index bfab2485b24..351ff7ce524 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java @@ -240,14 +240,7 @@ public class NiciraNvpApi { public NatRule createLogicalRouterNatRule(String logicalRouterUuid, NatRule natRule) throws NiciraNvpApiException { String uri = "/ws.v1/lrouter/" + logicalRouterUuid + "/nat"; - if (natRule instanceof SourceNatRule) { - return executeCreateObject(natRule, new TypeToken(){}.getType(), uri, Collections.emptyMap()); - } - else if (natRule instanceof DestinationNatRule) { - return executeCreateObject(natRule, new TypeToken(){}.getType(), uri, Collections.emptyMap()); - } - - throw new NiciraNvpApiException("Unknown NatRule type"); + return executeCreateObject(natRule, new TypeToken(){}.getType(), uri, Collections.emptyMap()); } public void modifyLogicalRouterNatRule(String logicalRouterUuid, NatRule natRule) throws NiciraNvpApiException { diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java deleted file mode 100644 index acbf21e18af..00000000000 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/SourceNatRule.java +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 com.cloud.network.nicira; - -/** - * - */ -public class SourceNatRule extends NatRule { - { - type = "SourceNatRule"; - } - -} diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java index b297e7f979d..960b098c986 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java @@ -60,9 +60,7 @@ import com.cloud.agent.api.to.PortForwardingRuleTO; import com.cloud.agent.api.to.StaticNatRuleTO; import com.cloud.host.Host; import com.cloud.host.Host.Type; -import com.cloud.network.nicira.Attachment; import com.cloud.network.nicira.ControlClusterStatus; -import com.cloud.network.nicira.DestinationNatRule; import com.cloud.network.nicira.L3GatewayAttachment; import com.cloud.network.nicira.LogicalRouterConfig; import com.cloud.network.nicira.LogicalRouterPort; @@ -77,13 +75,10 @@ import com.cloud.network.nicira.NiciraNvpTag; import com.cloud.network.nicira.PatchAttachment; import com.cloud.network.nicira.RouterNextHop; import com.cloud.network.nicira.SingleDefaultRouteImplictRoutingConfig; -import com.cloud.network.nicira.SourceNatRule; import com.cloud.network.nicira.TransportZoneBinding; import com.cloud.network.nicira.VifAttachment; import com.cloud.resource.ServerResource; -import edu.emory.mathcs.backport.java.util.Arrays; - public class NiciraNvpResource implements ServerResource { private static final Logger s_logger = Logger.getLogger(NiciraNvpResource.class); @@ -307,7 +302,13 @@ public class NiciraNvpResource implements ServerResource { LogicalSwitchPort logicalSwitchPort = new LogicalSwitchPort(attachmentUuid, tags, true); LogicalSwitchPort newPort = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, logicalSwitchPort); - _niciraNvpApi.modifyLogicalSwitchPortAttachment(cmd.getLogicalSwitchUuid(), newPort.getUuid(), new VifAttachment(attachmentUuid)); + try { + _niciraNvpApi.modifyLogicalSwitchPortAttachment(cmd.getLogicalSwitchUuid(), newPort.getUuid(), new VifAttachment(attachmentUuid)); + } catch (NiciraNvpApiException ex) { + s_logger.warn("modifyLogicalSwitchPort failed after switchport was created, removing switchport"); + _niciraNvpApi.deleteLogicalSwitchPort(cmd.getLogicalSwitchUuid(), newPort.getUuid()); + throw (ex); // Rethrow the original exception + } return new CreateLogicalSwitchPortAnswer(cmd, true, "Logical switch port " + newPort.getUuid() + " created", newPort.getUuid()); } catch (NiciraNvpApiException e) { if (numRetries > 0) { @@ -404,6 +405,9 @@ public class NiciraNvpResource implements ServerResource { new RouterNextHop(publicNetworkNextHopIp))); lrc = _niciraNvpApi.createLogicalRouter(lrc); + // store the switchport for rollback + LogicalSwitchPort lsp = null; + try { // Create the outside port for the router LogicalRouterPort lrpo = new LogicalRouterPort(); @@ -433,7 +437,7 @@ public class NiciraNvpResource implements ServerResource { lrpi = _niciraNvpApi.createLogicalRouterPort(lrc.getUuid(),lrpi); // Create the inside port on the lswitch - LogicalSwitchPort lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", 40), tags, true); + lsp = new LogicalSwitchPort(truncate(routerName + "-inside-port", 40), tags, true); lsp = _niciraNvpApi.createLogicalSwitchPort(logicalSwitchUuid, lsp); // Attach the inside router port to the lswitch port with a PatchAttachment @@ -445,7 +449,8 @@ public class NiciraNvpResource implements ServerResource { new PatchAttachment(lrpi.getUuid())); // Setup the source nat rule - SourceNatRule snr = new SourceNatRule(); + NatRule snr = new NatRule(); + snr.setType("SourceNatRule"); snr.setToSourceIpAddressMin(publicNetworkIpAddress.split("/")[0]); snr.setToSourceIpAddressMax(publicNetworkIpAddress.split("/")[0]); Match match = new Match(); @@ -454,10 +459,12 @@ public class NiciraNvpResource implements ServerResource { _niciraNvpApi.createLogicalRouterNatRule(lrc.getUuid(), snr); } catch (NiciraNvpApiException e) { // We need to destroy the router if we already created it - // this will also take care of any router ports - // TODO Clean up the switchport + // this will also take care of any router ports and rules try { _niciraNvpApi.deleteLogicalRouter(lrc.getUuid()); + if (lsp != null) { + _niciraNvpApi.deleteLogicalSwitchPort(logicalSwitchUuid, lsp.getUuid()); + } } catch (NiciraNvpApiException ex) {} throw e; @@ -498,7 +505,8 @@ public class NiciraNvpResource implements ServerResource { lrp.setIpAddresses(cmd.getPublicCidrs()); _niciraNvpApi.modifyLogicalRouterPort(cmd.getLogicalRouterUuid(), lrp); - return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Logical Router deleted (uuid " + cmd.getLogicalRouterUuid() + ")"); + return new ConfigurePublicIpsOnLogicalRouterAnswer(cmd, true, "Configured " + cmd.getPublicCidrs().size() + + " ip addresses on logical router uuid " + cmd.getLogicalRouterUuid()); } catch (NiciraNvpApiException e) { if (numRetries > 0) { return retry(cmd, --numRetries); @@ -581,21 +589,23 @@ public class NiciraNvpResource implements ServerResource { // create the dnat rule Match m = new Match(); m.setDestinationIpAddresses(outsideCidr); - DestinationNatRule newDnatRule = new DestinationNatRule(); + NatRule newDnatRule = new NatRule(); + newDnatRule.setType("DestinationNatRule"); newDnatRule.setMatch(m); newDnatRule.setToDestinationIpAddressMin(insideIp); newDnatRule.setToDestinationIpAddressMax(insideIp); - newDnatRule = (DestinationNatRule) _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newDnatRule); + newDnatRule = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newDnatRule); s_logger.debug("Created " + natRuleToString(newDnatRule)); // create matching snat rule m = new Match(); m.setSourceIpAddresses(insideIp + "/32"); - SourceNatRule newSnatRule = new SourceNatRule(); + NatRule newSnatRule = new NatRule(); + newSnatRule.setType("SourceNatRule"); newSnatRule.setMatch(m); newSnatRule.setToSourceIpAddressMin(outsideIp); newSnatRule.setToSourceIpAddressMax(outsideIp); - newSnatRule = (SourceNatRule) _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newSnatRule); + newSnatRule = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newSnatRule); s_logger.debug("Created " + natRuleToString(newSnatRule)); } @@ -698,12 +708,13 @@ public class NiciraNvpResource implements ServerResource { } m.setDestinationPortMin(rule.getSrcPortRange()[0]); m.setDestinationPortMax(rule.getSrcPortRange()[1]); - DestinationNatRule newDnatRule = new DestinationNatRule(); + NatRule newDnatRule = new NatRule(); + newDnatRule.setType("DestinationNatRule"); newDnatRule.setMatch(m); newDnatRule.setToDestinationIpAddressMin(insideIp); newDnatRule.setToDestinationIpAddressMax(insideIp); newDnatRule.setToDestinationPort(rule.getDstPortRange()[0]); - newDnatRule = (DestinationNatRule) _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newDnatRule); + newDnatRule = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newDnatRule); s_logger.debug("Created " + natRuleToString(newDnatRule)); // create matching snat rule @@ -717,13 +728,14 @@ public class NiciraNvpResource implements ServerResource { } m.setSourcePortMin(rule.getDstPortRange()[0]); m.setSourcePortMax(rule.getDstPortRange()[1]); - SourceNatRule newSnatRule = new SourceNatRule(); + NatRule newSnatRule = new NatRule(); + newSnatRule.setType("SourceNatRule"); newSnatRule.setMatch(m); newSnatRule.setToSourceIpAddressMin(outsideIp); newSnatRule.setToSourceIpAddressMax(outsideIp); newSnatRule.setToSourcePortMin(rule.getSrcPortRange()[0]); newSnatRule.setToSourcePortMax(rule.getSrcPortRange()[1]); - newSnatRule = (SourceNatRule) _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newSnatRule); + newSnatRule = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newSnatRule); s_logger.debug("Created " + natRuleToString(newSnatRule)); } @@ -749,9 +761,8 @@ public class NiciraNvpResource implements ServerResource { } private Answer retry(Command cmd, int numRetries) { - int numRetriesRemaining = numRetries - 1; - s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetriesRemaining); - return executeRequest(cmd, numRetriesRemaining); + s_logger.warn("Retrying " + cmd.getClass().getSimpleName() + ". Number of retries remaining: " + numRetries); + return executeRequest(cmd, numRetries); } private String natRuleToString(NatRule rule) { @@ -808,4 +819,17 @@ public class NiciraNvpResource implements ServerResource { } } + private NatRule[] generateStaticNatRulePair(String insideIp, String outsideIp) { + NatRule[] rulepair = new NatRule[2]; + rulepair[0] = new NatRule(); + rulepair[0].setType("DestinationNatRule"); + rulepair[1] = new NatRule(); + rulepair[1].setType("SourceNatRule"); + + //FIXME Implement + + return rulepair; + + } + } From a0d6ca617f871aacdc277d02b2631459ab10793e Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Thu, 6 Dec 2012 13:44:30 +0100 Subject: [PATCH 040/145] Make variable naming consistent with the superclass. The field was called brandnew in portforwaringto and alreadyadded in firewallruleto. This leads to confusion as the effect is completely opposite. Small fix for wrong parameter order --- api/src/com/cloud/agent/api/to/PortForwardingRuleTO.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/com/cloud/agent/api/to/PortForwardingRuleTO.java b/api/src/com/cloud/agent/api/to/PortForwardingRuleTO.java index c99a3766642..19673a6e4c7 100644 --- a/api/src/com/cloud/agent/api/to/PortForwardingRuleTO.java +++ b/api/src/com/cloud/agent/api/to/PortForwardingRuleTO.java @@ -39,8 +39,8 @@ public class PortForwardingRuleTO extends FirewallRuleTO { this.dstPortRange = new int[] { rule.getDestinationPortStart(), rule.getDestinationPortEnd() }; } - protected PortForwardingRuleTO(long id, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, boolean revoked, boolean brandNew) { - super(id, srcIp,null, protocol, srcPortStart, srcPortEnd, revoked, brandNew, FirewallRule.Purpose.PortForwarding, null,0,0); + public PortForwardingRuleTO(long id, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol, boolean revoked, boolean alreadyAdded) { + super(id, null, srcIp, protocol, srcPortStart, srcPortEnd, revoked, alreadyAdded, FirewallRule.Purpose.PortForwarding, null,0,0); this.dstIp = dstIp; this.dstPortRange = new int[] { dstPortStart, dstPortEnd }; } From 22ef646b23da64a80b2e10cfd68dd15919de3006 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Thu, 6 Dec 2012 14:37:24 +0100 Subject: [PATCH 041/145] Add more unittests for NiciraNvpResource --- .../resource/NiciraNvpResourceTest.java | 387 ++++++++++++++++++ 1 file changed, 387 insertions(+) diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java index 3fdd3e3f28a..0c7bb70be7a 100644 --- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java @@ -19,16 +19,25 @@ package com.cloud.network.resource; import static org.junit.Assert.*; import static org.mockito.Mockito.*; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.naming.ConfigurationException; import org.junit.Before; import org.junit.Test; +import org.mockito.ArgumentMatcher; + +import com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterAnswer; +import com.cloud.agent.api.ConfigurePortForwardingRulesOnLogicalRouterCommand; import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterAnswer; import com.cloud.agent.api.ConfigurePublicIpsOnLogicalRouterCommand; +import com.cloud.agent.api.ConfigureStaticNatRulesOnLogicalRouterAnswer; +import com.cloud.agent.api.ConfigureStaticNatRulesOnLogicalRouterCommand; import com.cloud.agent.api.CreateLogicalRouterAnswer; import com.cloud.agent.api.CreateLogicalRouterCommand; import com.cloud.agent.api.CreateLogicalSwitchAnswer; @@ -47,6 +56,8 @@ import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.UpdateLogicalSwitchPortAnswer; import com.cloud.agent.api.UpdateLogicalSwitchPortCommand; +import com.cloud.agent.api.to.PortForwardingRuleTO; +import com.cloud.agent.api.to.StaticNatRuleTO; import com.cloud.host.Host; import com.cloud.network.nicira.Attachment; import com.cloud.network.nicira.ControlClusterStatus; @@ -405,5 +416,381 @@ public class NiciraNvpResourceTest { assertFalse(answer.getResult()); } + + @Test + public void testConfigureStaticNatRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class); + StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + // Mock the api create calls + NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]); + + ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + assertTrue(a.getResult()); + verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher() { + @Override + public boolean matches(Object argument) { + NatRule rule = (NatRule) argument; + if (rule.getType().equals("DestinationNatRule") && + rule.getToDestinationIpAddressMin().equals("10.10.10.10")) { + return true; + } + if (rule.getType().equals("SourceNatRule") && + rule.getToSourceIpAddressMin().equals("11.11.11.11")) { + return true; + } + return false; + } })); + } + + @Test + public void testConfigureStaticNatRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class); + StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api create calls + NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(storedRules.getResultCount()).thenReturn(2); + when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair)); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + assertTrue(a.getResult()); + verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher() { + @Override + public boolean matches(Object argument) { + NatRule rule = (NatRule) argument; + if (rule.getType().equals("DestinationNatRule") && + rule.getToDestinationIpAddressMin().equals("10.10.10.10")) { + return true; + } + if (rule.getType().equals("SourceNatRule") && + rule.getToSourceIpAddressMin().equals("11.11.11.11")) { + return true; + } + return false; + } })); + } + + @Test + public void testConfigureStaticNatRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class); + StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, true, false); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api create calls + NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(storedRules.getResultCount()).thenReturn(2); + when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair)); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + assertTrue(a.getResult()); + verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher() { + @Override + public boolean matches(Object argument) { + String uuid = (String) argument; + if ("bbbbb".equals(uuid) || "ccccc".equals(uuid)) { + return true; + } + return false; + } })); + } + + @Test + public void testConfigureStaticNatRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigureStaticNatRulesOnLogicalRouterCommand cmd = mock(ConfigureStaticNatRulesOnLogicalRouterCommand.class); + StaticNatRuleTO rule = new StaticNatRuleTO(1,"11.11.11.11", null, null, "10.10.10.10", null, null, null, false, false); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api create calls + NatRule[] rulepair = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException()); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(storedRules.getResultCount()).thenReturn(0); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + ConfigureStaticNatRulesOnLogicalRouterAnswer a = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + assertFalse(a.getResult()); + verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq("bbbbb")); + } + + @Test + public void testConfigurePortForwardingRulesOnLogicalRouter() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class); + PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + // Mock the api create calls + NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]); + + ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + assertTrue(a.getResult()); + verify(_nvpApi, atLeast(2)).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher() { + @Override + public boolean matches(Object argument) { + NatRule rule = (NatRule) argument; + if (rule.getType().equals("DestinationNatRule") && + rule.getToDestinationIpAddressMin().equals("10.10.10.10")) { + return true; + } + if (rule.getType().equals("SourceNatRule") && + rule.getToSourceIpAddressMin().equals("11.11.11.11")) { + return true; + } + return false; + } })); + } + + @Test + public void testConfigurePortForwardingRulesOnLogicalRouterExistingRules() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class); + PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, true); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api create calls + NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(storedRules.getResultCount()).thenReturn(2); + when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair)); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + assertTrue(a.getResult()); + verify(_nvpApi, never()).createLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher() { + @Override + public boolean matches(Object argument) { + NatRule rule = (NatRule) argument; + if (rule.getType().equals("DestinationNatRule") && + rule.getToDestinationIpAddressMin().equals("10.10.10.10")) { + return true; + } + if (rule.getType().equals("SourceNatRule") && + rule.getToSourceIpAddressMin().equals("11.11.11.11")) { + return true; + } + return false; + } })); + } + + @Test + public void testConfigurePortForwardingRulesOnLogicalRouterRemoveRules() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class); + PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", true, true); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api create calls + NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(storedRules.getResultCount()).thenReturn(2); + when(storedRules.getResults()).thenReturn(Arrays.asList(rulepair)); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + assertTrue(a.getResult()); + verify(_nvpApi, atLeast(2)).deleteLogicalRouterNatRule(eq("aaaaa"), argThat(new ArgumentMatcher() { + @Override + public boolean matches(Object argument) { + String uuid = (String) argument; + if ("bbbbb".equals(uuid) || "ccccc".equals(uuid)) { + return true; + } + return false; + } })); + } + + @Test + public void testConfigurePortForwardingRulesOnLogicalRouterRollback() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class); + PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 80, "10.10.10.10", 8080, 8080, "tcp", false, false); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api create calls + NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80}, "tcp"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenThrow(new NiciraNvpApiException()); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(storedRules.getResultCount()).thenReturn(0); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + assertFalse(a.getResult()); + verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq("bbbbb")); + } + + @Test + public void testGenerateStaticNatRulePair() { + NatRule[] rules = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11"); + assertTrue("DestinationNatRule".equals(rules[0].getType())); + assertTrue("SourceNatRule".equals(rules[1].getType())); + + assertTrue(rules[0].getToDestinationIpAddressMin().equals("10.10.10.10") && rules[0].getToDestinationIpAddressMax().equals("10.10.10.10")); + assertTrue(rules[0].getToDestinationPort() == null); + assertTrue(rules[0].getMatch().getDestinationIpAddresses().equals("11.11.11.11")); + + assertTrue(rules[1].getToSourceIpAddressMin().equals("11.11.11.11") && rules[1].getToSourceIpAddressMax().equals("11.11.11.11")); + assertTrue(rules[1].getToSourcePortMin() == null && rules[1].getToSourcePortMax() == null); + assertTrue(rules[1].getMatch().getSourceIpAddresses().equals("10.10.10.10")); + } + + @Test + public void testGeneratePortForwardingRulePair() { + NatRule[] rules = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 8080, 8080 }, "11.11.11.11", new int[] { 80, 80 }, "tcp" ); + assertTrue("DestinationNatRule".equals(rules[0].getType())); + assertTrue("SourceNatRule".equals(rules[1].getType())); + + assertTrue(rules[0].getToDestinationIpAddressMin().equals("10.10.10.10") && rules[0].getToDestinationIpAddressMax().equals("10.10.10.10")); + assertTrue(rules[0].getToDestinationPort() == 8080); + assertTrue(rules[0].getMatch().getDestinationIpAddresses().equals("11.11.11.11")); + assertTrue(rules[0].getMatch().getDestinationPortMin() == 80 && rules[0].getMatch().getDestinationPortMax() == 80); + assertTrue(rules[0].getMatch().getEthertype().equals("IPv4") && rules[0].getMatch().getProtocol() == 6); + + assertTrue(rules[1].getToSourceIpAddressMin().equals("11.11.11.11") && rules[1].getToSourceIpAddressMax().equals("11.11.11.11")); + assertTrue(rules[1].getToSourcePortMin() == 80 && rules[1].getToSourcePortMax() == 80); + assertTrue(rules[1].getMatch().getSourceIpAddresses().equals("10.10.10.10")); + assertTrue(rules[1].getMatch().getSourcePortMin() == 8080 && rules[1].getMatch().getSourcePortMax() == 8080); + assertTrue(rules[1].getMatch().getEthertype().equals("IPv4") && rules[1].getMatch().getProtocol() == 6); + } } From cfd2a0bdf8c9945f646af0961dc0fb635adc6449 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Thu, 6 Dec 2012 14:41:12 +0100 Subject: [PATCH 042/145] Fixes for some bug discovered while writing unittests Rewritten handling for static nat and port forwarding, should make some more sense now and the complex functions are split in smaller units. Fix a small bug in Match Add equals function to NatRule that ignores the uuid field. --- .../src/com/cloud/network/nicira/Match.java | 2 +- .../src/com/cloud/network/nicira/NatRule.java | 59 ++++ .../network/resource/NiciraNvpResource.java | 261 ++++++++---------- 3 files changed, 170 insertions(+), 152 deletions(-) diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java index 034a7de13d9..0c4e677536c 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/Match.java @@ -41,7 +41,7 @@ public class Match { this.protocol = protocol; } - public Integer getSource_port_min() { + public Integer getSourcePortMin() { return source_port_min; } diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java index 46437071be9..b66ffa89b77 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NatRule.java @@ -219,5 +219,64 @@ public class NatRule { return true; } + public boolean equalsIgnoreUuid(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NatRule other = (NatRule) obj; + if (match == null) { + if (other.match != null) + return false; + } else if (!match.equals(other.match)) + return false; + if (to_destination_ip_address_max == null) { + if (other.to_destination_ip_address_max != null) + return false; + } else if (!to_destination_ip_address_max + .equals(other.to_destination_ip_address_max)) + return false; + if (to_destination_ip_address_min == null) { + if (other.to_destination_ip_address_min != null) + return false; + } else if (!to_destination_ip_address_min + .equals(other.to_destination_ip_address_min)) + return false; + if (to_destination_port == null) { + if (other.to_destination_port != null) + return false; + } else if (!to_destination_port.equals(other.to_destination_port)) + return false; + if (to_source_ip_address_max == null) { + if (other.to_source_ip_address_max != null) + return false; + } else if (!to_source_ip_address_max + .equals(other.to_source_ip_address_max)) + return false; + if (to_source_ip_address_min == null) { + if (other.to_source_ip_address_min != null) + return false; + } else if (!to_source_ip_address_min + .equals(other.to_source_ip_address_min)) + return false; + if (to_source_port_max == null) { + if (other.to_source_port_max != null) + return false; + } else if (!to_source_port_max.equals(other.to_source_port_max)) + return false; + if (to_source_port_min == null) { + if (other.to_source_port_min != null) + return false; + } else if (!to_source_port_min.equals(other.to_source_port_min)) + return false; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; + } } diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java index 960b098c986..3dd0145ff99 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java @@ -526,56 +526,37 @@ public class NiciraNvpResource implements ServerResource { // Any other SourceNat rule should have a corresponding DestinationNat rule for (StaticNatRuleTO rule : cmd.getRules()) { - // Find if a DestinationNat rule exists for this rule - String insideIp = rule.getDstIp(); - String insideCidr = rule.getDstIp() + "/32"; - String outsideIp = rule.getSrcIp(); - String outsideCidr = rule.getSrcIp() + "/32"; - + + NatRule[] rulepair = generateStaticNatRulePair(rule.getDstIp(), rule.getSrcIp()); + NatRule incoming = null; NatRule outgoing = null; for (NatRule storedRule : existingRules.getResults()) { - if ("SourceNatRule".equals(storedRule.getType())) { - if (outsideIp.equals(storedRule.getToSourceIpAddressMin()) && - outsideIp.equals(storedRule.getToSourceIpAddressMax()) && - storedRule.getToSourcePortMin() == null) { - // The outgoing rule exists - outgoing = storedRule; - } - } - if ("DestinationNatRule".equals(storedRule.getType()) && - storedRule.getToDestinationPort() != null) { - // Skip PortForwarding rules - continue; - } - // Compare against Ip as it should be a /32 cidr and the /32 is omitted - if (outsideIp.equals(storedRule.getMatch().getDestinationIpAddresses())) { + if (storedRule.equalsIgnoreUuid(rulepair[1])) { + // The outgoing rule exists + outgoing = storedRule; + s_logger.debug("Found matching outgoing rule " + outgoing.getUuid()); + if (incoming != null) { + break; + } + } + else if (storedRule.equalsIgnoreUuid(rulepair[0])) { // The incoming rule exists incoming = storedRule; + s_logger.debug("Found matching incoming rule " + incoming.getUuid()); + if (outgoing != null) { + break; + } } } if (incoming != null && outgoing != null) { - if (insideIp.equals(incoming.getToDestinationIpAddressMin())) { - if (rule.revoked()) { - s_logger.debug("Deleting incoming rule " + incoming.getUuid()); - _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid()); - - s_logger.debug("Deleting outgoing rule " + outgoing.getUuid()); - _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid()); - } - } - else { - s_logger.debug("Updating outgoing rule " + outgoing.getUuid()); - outgoing.setToDestinationIpAddressMin(insideIp); - outgoing.setToDestinationIpAddressMax(insideIp); - _niciraNvpApi.modifyLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing); - - s_logger.debug("Updating incoming rule " + outgoing.getUuid()); - incoming.setToSourceIpAddressMin(insideIp); - incoming.setToSourceIpAddressMax(insideIp); - _niciraNvpApi.modifyLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming); - break; + if (rule.revoked()) { + s_logger.debug("Deleting incoming rule " + incoming.getUuid()); + _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid()); + + s_logger.debug("Deleting outgoing rule " + outgoing.getUuid()); + _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid()); } } else { @@ -585,28 +566,17 @@ public class NiciraNvpResource implements ServerResource { break; } - // api createLogicalRouterNatRule - // create the dnat rule - Match m = new Match(); - m.setDestinationIpAddresses(outsideCidr); - NatRule newDnatRule = new NatRule(); - newDnatRule.setType("DestinationNatRule"); - newDnatRule.setMatch(m); - newDnatRule.setToDestinationIpAddressMin(insideIp); - newDnatRule.setToDestinationIpAddressMax(insideIp); - newDnatRule = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newDnatRule); - s_logger.debug("Created " + natRuleToString(newDnatRule)); - - // create matching snat rule - m = new Match(); - m.setSourceIpAddresses(insideIp + "/32"); - NatRule newSnatRule = new NatRule(); - newSnatRule.setType("SourceNatRule"); - newSnatRule.setMatch(m); - newSnatRule.setToSourceIpAddressMin(outsideIp); - newSnatRule.setToSourceIpAddressMax(outsideIp); - newSnatRule = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newSnatRule); - s_logger.debug("Created " + natRuleToString(newSnatRule)); + rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]); + s_logger.debug("Created " + natRuleToString(rulepair[0])); + + try { + rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]); + s_logger.debug("Created " + natRuleToString(rulepair[1])); + } catch (NiciraNvpApiException ex) { + s_logger.debug("Failed to create SourceNatRule, rolling back DestinationNatRule"); + _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid()); + throw ex; // Rethrow original exception + } } } @@ -619,7 +589,6 @@ public class NiciraNvpResource implements ServerResource { return new ConfigureStaticNatRulesOnLogicalRouterAnswer(cmd, e); } } - } private Answer executeRequest(ConfigurePortForwardingRulesOnLogicalRouterCommand cmd, int numRetries) { @@ -630,63 +599,41 @@ public class NiciraNvpResource implements ServerResource { // Any other SourceNat rule should have a corresponding DestinationNat rule for (PortForwardingRuleTO rule : cmd.getRules()) { - if (rule.isAlreadyAdded()) { + if (rule.isAlreadyAdded() && !rule.revoked()) { // Don't need to do anything continue; } - // Find if a DestinationNat rule exists for this rule - String insideIp = rule.getDstIp(); - String insideCidr = rule.getDstIp() + "/32"; - String outsideIp = rule.getSrcIp(); - String outsideCidr = rule.getSrcIp() + "/32"; + NatRule[] rulepair = generatePortForwardingRulePair(rule.getDstIp(), rule.getDstPortRange(), rule.getSrcIp(), rule.getSrcPortRange(), rule.getProtocol()); NatRule incoming = null; NatRule outgoing = null; for (NatRule storedRule : existingRules.getResults()) { - if ("SourceNatRule".equals(storedRule.getType())) { - if (outsideIp.equals(storedRule.getToSourceIpAddressMin()) && - outsideIp.equals(storedRule.getToSourceIpAddressMax()) && - storedRule.getToSourcePortMin() == rule.getSrcPortRange()[0] && - storedRule.getToSourcePortMax() == rule.getSrcPortRange()[1]) { - // The outgoing rule exists - outgoing = storedRule; - } - } - else if ("DestinationNatRule".equals(storedRule.getType())) { - if (insideIp.equals(storedRule.getToDestinationIpAddressMin()) && - insideIp.equals(storedRule.getToDestinationIpAddressMax()) && - storedRule.getToDestinationPort() == rule.getDstPortRange()[0]) { - // The incoming rule exists - incoming = storedRule; - } + if (storedRule.equalsIgnoreUuid(rulepair[1])) { + // The outgoing rule exists + outgoing = storedRule; + s_logger.debug("Found matching outgoing rule " + outgoing.getUuid()); + if (incoming != null) { + break; + } + } + else if (storedRule.equalsIgnoreUuid(rulepair[0])) { + // The incoming rule exists + incoming = storedRule; + s_logger.debug("Found matching incoming rule " + incoming.getUuid()); + if (outgoing != null) { + break; + } } } if (incoming != null && outgoing != null) { - if (insideIp.equals(incoming.getToDestinationIpAddressMin())) { - if (rule.revoked()) { - s_logger.debug("Deleting incoming rule " + incoming.getUuid()); - _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid()); - - s_logger.debug("Deleting outgoing rule " + outgoing.getUuid()); - _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid()); - } - } - else { - s_logger.debug("Updating outgoing rule " + outgoing.getUuid()); - outgoing.setToDestinationIpAddressMin(insideIp); - outgoing.setToDestinationIpAddressMax(insideIp); - outgoing.setToDestinationPort(rule.getDstPortRange()[0]); - _niciraNvpApi.modifyLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing); - - s_logger.debug("Updating incoming rule " + outgoing.getUuid()); - incoming.setToSourceIpAddressMin(insideIp); - incoming.setToSourceIpAddressMax(insideIp); - incoming.setToSourcePortMin(rule.getSrcPortRange()[0]); - incoming.setToSourcePortMax(rule.getSrcPortRange()[1]); - _niciraNvpApi.modifyLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming); - break; + if (rule.revoked()) { + s_logger.debug("Deleting incoming rule " + incoming.getUuid()); + _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), incoming.getUuid()); + + s_logger.debug("Deleting outgoing rule " + outgoing.getUuid()); + _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), outgoing.getUuid()); } } else { @@ -696,47 +643,17 @@ public class NiciraNvpResource implements ServerResource { break; } - // api createLogicalRouterNatRule - // create the dnat rule - Match m = new Match(); - m.setDestinationIpAddresses(outsideCidr); - if ("tcp".equals(rule.getProtocol())) { - m.setProtocol(6); - } - else if ("udp".equals(rule.getProtocol())) { - m.setProtocol(17); - } - m.setDestinationPortMin(rule.getSrcPortRange()[0]); - m.setDestinationPortMax(rule.getSrcPortRange()[1]); - NatRule newDnatRule = new NatRule(); - newDnatRule.setType("DestinationNatRule"); - newDnatRule.setMatch(m); - newDnatRule.setToDestinationIpAddressMin(insideIp); - newDnatRule.setToDestinationIpAddressMax(insideIp); - newDnatRule.setToDestinationPort(rule.getDstPortRange()[0]); - newDnatRule = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newDnatRule); - s_logger.debug("Created " + natRuleToString(newDnatRule)); + rulepair[0] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0]); + s_logger.debug("Created " + natRuleToString(rulepair[0])); - // create matching snat rule - m = new Match(); - m.setSourceIpAddresses(insideIp + "/32"); - if ("tcp".equals(rule.getProtocol())) { - m.setProtocol(6); + try { + rulepair[1] = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[1]); + s_logger.debug("Created " + natRuleToString(rulepair[1])); + } catch (NiciraNvpApiException ex) { + s_logger.warn("NiciraNvpApiException during create call, rolling back previous create"); + _niciraNvpApi.deleteLogicalRouterNatRule(cmd.getLogicalRouterUuid(), rulepair[0].getUuid()); + throw ex; // Rethrow the original exception } - else if ("udp".equals(rule.getProtocol())) { - m.setProtocol(17); - } - m.setSourcePortMin(rule.getDstPortRange()[0]); - m.setSourcePortMax(rule.getDstPortRange()[1]); - NatRule newSnatRule = new NatRule(); - newSnatRule.setType("SourceNatRule"); - newSnatRule.setMatch(m); - newSnatRule.setToSourceIpAddressMin(outsideIp); - newSnatRule.setToSourceIpAddressMax(outsideIp); - newSnatRule.setToSourcePortMin(rule.getSrcPortRange()[0]); - newSnatRule.setToSourcePortMax(rule.getSrcPortRange()[1]); - newSnatRule = _niciraNvpApi.createLogicalRouterNatRule(cmd.getLogicalRouterUuid(), newSnatRule); - s_logger.debug("Created " + natRuleToString(newSnatRule)); } } @@ -779,7 +696,7 @@ public class NiciraNvpResource implements ServerResource { natRuleStr.append(" "); natRuleStr.append(m.getSourceIpAddresses()); natRuleStr.append(" ["); - natRuleStr.append(m.getSource_port_min()); + natRuleStr.append(m.getSourcePortMin()); natRuleStr.append("-"); natRuleStr.append(m.getSourcePortMax()); natRuleStr.append(" ] -> "); @@ -819,17 +736,59 @@ public class NiciraNvpResource implements ServerResource { } } - private NatRule[] generateStaticNatRulePair(String insideIp, String outsideIp) { + protected NatRule[] generateStaticNatRulePair(String insideIp, String outsideIp) { NatRule[] rulepair = new NatRule[2]; rulepair[0] = new NatRule(); rulepair[0].setType("DestinationNatRule"); rulepair[1] = new NatRule(); rulepair[1].setType("SourceNatRule"); - //FIXME Implement + Match m = new Match(); + m.setDestinationIpAddresses(outsideIp); + rulepair[0].setMatch(m); + rulepair[0].setToDestinationIpAddressMin(insideIp); + rulepair[0].setToDestinationIpAddressMax(insideIp); + + // create matching snat rule + m = new Match(); + m.setSourceIpAddresses(insideIp); + rulepair[1].setMatch(m); + rulepair[1].setToSourceIpAddressMin(outsideIp); + rulepair[1].setToSourceIpAddressMax(outsideIp); return rulepair; } + protected NatRule[] generatePortForwardingRulePair(String insideIp, int[] insidePorts, String outsideIp, int[] outsidePorts, String protocol) { + // Start with a basic static nat rule, then add port and protocol details + NatRule[] rulepair = generateStaticNatRulePair(insideIp, outsideIp); + + rulepair[0].setToDestinationPort(insidePorts[0]); + rulepair[0].getMatch().setDestinationPortMin(outsidePorts[0]); + rulepair[0].getMatch().setDestinationPortMax(outsidePorts[1]); + rulepair[0].getMatch().setEthertype("IPv4"); + if ("tcp".equals(protocol)) { + rulepair[0].getMatch().setProtocol(6); + } + else if ("udp".equals(protocol)) { + rulepair[0].getMatch().setProtocol(17); + } + + rulepair[1].setToSourcePortMin(outsidePorts[0]); + rulepair[1].setToSourcePortMax(outsidePorts[1]); + rulepair[1].getMatch().setSourcePortMin(insidePorts[0]); + rulepair[1].getMatch().setSourcePortMax(insidePorts[1]); + rulepair[1].getMatch().setEthertype("IPv4"); + if ("tcp".equals(protocol)) { + rulepair[1].getMatch().setProtocol(6); + } + else if ("udp".equals(protocol)) { + rulepair[1].getMatch().setProtocol(17); + } + + return rulepair; + + } + } From 1fbf2a2864700208453aa322be0d52e33eef6fac Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Thu, 6 Dec 2012 16:50:56 +0100 Subject: [PATCH 043/145] Fix bug in Port Forwarding Nicira NVP can't handle a range of port when implementing port forwarding, so return an error message when a rule is being implemented that uses port ranges. Include unittest to verify this behaviour --- .../network/resource/NiciraNvpResource.java | 4 +++ .../resource/NiciraNvpResourceTest.java | 36 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java index 3dd0145ff99..12ed72a1fd5 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/resource/NiciraNvpResource.java @@ -604,6 +604,10 @@ public class NiciraNvpResource implements ServerResource { continue; } + if (rule.getDstPortRange()[0] != rule.getDstPortRange()[1]) { + return new ConfigurePortForwardingRulesOnLogicalRouterAnswer(cmd, false, "Nicira NVP doesn't support port ranges for port forwarding"); + } + NatRule[] rulepair = generatePortForwardingRulePair(rule.getDstIp(), rule.getDstPortRange(), rule.getSrcIp(), rule.getSrcPortRange(), rule.getProtocol()); NatRule incoming = null; diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java index 0c7bb70be7a..e3789108f34 100644 --- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/resource/NiciraNvpResourceTest.java @@ -758,7 +758,41 @@ public class NiciraNvpResourceTest { assertFalse(a.getResult()); verify(_nvpApi, atLeastOnce()).deleteLogicalRouterNatRule(eq("aaaaa"), eq("bbbbb")); } - + + @Test + public void testConfigurePortForwardingRulesOnLogicalRouterPortRange() throws ConfigurationException, NiciraNvpApiException { + _resource.configure("NiciraNvpResource", _parameters); + /* StaticNat + * Outside IP: 11.11.11.11 + * Inside IP: 10.10.10.10 + */ + + // Mock the command + ConfigurePortForwardingRulesOnLogicalRouterCommand cmd = mock(ConfigurePortForwardingRulesOnLogicalRouterCommand.class); + PortForwardingRuleTO rule = new PortForwardingRuleTO(1,"11.11.11.11", 80, 85, "10.10.10.10", 80, 85, "tcp", false, false); + List rules = new ArrayList(); + rules.add(rule); + when(cmd.getRules()).thenReturn(rules); + when(cmd.getLogicalRouterUuid()).thenReturn("aaaaa"); + + // Mock the api find call + @SuppressWarnings("unchecked") + NiciraNvpList storedRules = mock(NiciraNvpList.class); + when(_nvpApi.findNatRulesByLogicalRouterUuid("aaaaa")).thenReturn(storedRules); + + // Mock the api create calls + NatRule[] rulepair = _resource.generatePortForwardingRulePair("10.10.10.10", new int[] { 80, 85 }, "11.11.11.11", new int[] { 80, 85}, "tcp"); + rulepair[0].setUuid("bbbbb"); + rulepair[1].setUuid("ccccc"); + when(_nvpApi.createLogicalRouterNatRule(eq("aaaaa"), (NatRule)any())).thenReturn(rulepair[0]).thenReturn(rulepair[1]); + + ConfigurePortForwardingRulesOnLogicalRouterAnswer a = (ConfigurePortForwardingRulesOnLogicalRouterAnswer) _resource.executeRequest(cmd); + + // The expected result is false, Nicira does not support port ranges in DNAT + assertFalse(a.getResult()); + + } + @Test public void testGenerateStaticNatRulePair() { NatRule[] rules = _resource.generateStaticNatRulePair("10.10.10.10", "11.11.11.11"); From 391e873bd94df1f9bcd8e897910e1d5b9c20f84f Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Thu, 6 Dec 2012 10:43:50 -0800 Subject: [PATCH 044/145] CLOUDSTACK-537: cloudstack UI - Advanced SG-enabled zone - zone wizard - cluster dropdown - Make "KVM" the 1st option in dropdown. --- ui/scripts/zoneWizard.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js index ef874d4eb3d..92e2230d760 100755 --- a/ui/scripts/zoneWizard.js +++ b/ui/scripts/zoneWizard.js @@ -368,9 +368,14 @@ success: function(json) { var items = json.listhypervisorsresponse.hypervisor; var array1 = []; + + var firstOption = "XenServer"; + if(args.context.zones[0]['network-model'] == "Advanced" && args.context.zones[0]['zone-advanced-sg-enabled'] == "on") + firstOption = "KVM"; + if(items != null) { for(var i = 0; i < items.length; i++) { - if(items[i].name == "XenServer") + if(items[i].name == firstOption) array1.unshift({id: items[i].name, description: items[i].name}); else array1.push({id: items[i].name, description: items[i].name}); From 75e51a03aacf947ab51d2ff0d75db33cc8dcb4f3 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 6 Dec 2012 13:14:13 -0800 Subject: [PATCH 045/145] Egress UI: Fix columns -If startport or endport are blank, still show the blank columns to keep alignment correct. --- ui/scripts/network.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 7cdf9771c28..333e1fba71c 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -1198,6 +1198,14 @@ startport: 'All', endport: 'All' }); + } else if (rule.protocol == 'tcp' || rule.protocol == 'udp') { + if (!rule.startport) { + rule.startport = ' '; + } + + if (!rule.endport) { + rule.endport = ' '; + } } return rule; From cd238b4aab8b48934c6876ab6d05c07670354a87 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Thu, 6 Dec 2012 14:34:49 -0800 Subject: [PATCH 046/145] Don't show egress rules tab for SRX-based networks --- ui/scripts/network.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 333e1fba71c..3150b901342 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -804,6 +804,7 @@ tabFilter: function(args) { var networkOfferingHavingELB = false; var hasNetworkACL = false; + var hasSRXFirewall = false; var isVPC = false; var isAdvancedSGZone = false; var hiddenTabs = []; @@ -832,6 +833,18 @@ } }); } + + if (thisService.name == 'Firewall') { + $(thisService.provider).each(function() { + if (this.name == 'JuniperSRX') { + hasSRXFirewall = true; + + return false; + } + + return true; + }); + } }); } }); @@ -854,7 +867,7 @@ hiddenTabs.push("addloadBalancer"); } - if (isVPC || isAdvancedSGZone) { + if (isVPC || isAdvancedSGZone || hasSRXFirewall) { hiddenTabs.push('egressRules'); } From 4fe64948813ce1955bde09abc8c9aa8f8c81d831 Mon Sep 17 00:00:00 2001 From: Joe Brockmeier Date: Fri, 7 Dec 2012 08:46:32 -0600 Subject: [PATCH 047/145] CLOUDSTACK-480: Adding mention to install nfs-kernel-server to Install Guide --- ...l~432ff7ecbe1efface7fedf482be8a89518f3cd33 | 31 +++++++++++++++++++ docs/en-US/hypervisor-installation.xml~HEAD | 31 +++++++++++++++++++ .../en-US/nfs-shares-on-management-server.xml | 7 ++++- 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 docs/en-US/hypervisor-installation.xml~432ff7ecbe1efface7fedf482be8a89518f3cd33 create mode 100644 docs/en-US/hypervisor-installation.xml~HEAD diff --git a/docs/en-US/hypervisor-installation.xml~432ff7ecbe1efface7fedf482be8a89518f3cd33 b/docs/en-US/hypervisor-installation.xml~432ff7ecbe1efface7fedf482be8a89518f3cd33 new file mode 100644 index 00000000000..b0fc9f46ddb --- /dev/null +++ b/docs/en-US/hypervisor-installation.xml~432ff7ecbe1efface7fedf482be8a89518f3cd33 @@ -0,0 +1,31 @@ + + +%BOOK_ENTITIES; +]> + + + + + Hypervisor Installation + + + + + diff --git a/docs/en-US/hypervisor-installation.xml~HEAD b/docs/en-US/hypervisor-installation.xml~HEAD new file mode 100644 index 00000000000..b0fc9f46ddb --- /dev/null +++ b/docs/en-US/hypervisor-installation.xml~HEAD @@ -0,0 +1,31 @@ + + +%BOOK_ENTITIES; +]> + + + + + Hypervisor Installation + + + + + diff --git a/docs/en-US/nfs-shares-on-management-server.xml b/docs/en-US/nfs-shares-on-management-server.xml index 2c9b324d1a2..c000ce4818d 100644 --- a/docs/en-US/nfs-shares-on-management-server.xml +++ b/docs/en-US/nfs-shares-on-management-server.xml @@ -23,10 +23,15 @@ -->

- Using the Management Server As the NFS Server + Using the Management Server as the NFS Server This section tells how to set up NFS shares for primary and secondary storage on the same node with the Management Server. This is more typical of a trial installation, but is technically possible in a larger deployment. It is assumed that you will have less than 16TB of storage on the host. The exact commands for the following steps may vary depending on your operating system version. + On Ubuntu/Debian systems, you'll need to install the nfs-kernel-server package: + +$ sudo apt-get install nfs-kernel-server + + On the Management Server host, create two directories that you will use for primary and secondary storage. For example: # mkdir -p /export/primary From 3ab8a65a394cf22bb5d2acaededda6dbef5a6043 Mon Sep 17 00:00:00 2001 From: Joe Brockmeier Date: Fri, 7 Dec 2012 08:49:18 -0600 Subject: [PATCH 048/145] removing garbage files --- ...l~432ff7ecbe1efface7fedf482be8a89518f3cd33 | 31 ------------------- docs/en-US/hypervisor-installation.xml~HEAD | 31 ------------------- 2 files changed, 62 deletions(-) delete mode 100644 docs/en-US/hypervisor-installation.xml~432ff7ecbe1efface7fedf482be8a89518f3cd33 delete mode 100644 docs/en-US/hypervisor-installation.xml~HEAD diff --git a/docs/en-US/hypervisor-installation.xml~432ff7ecbe1efface7fedf482be8a89518f3cd33 b/docs/en-US/hypervisor-installation.xml~432ff7ecbe1efface7fedf482be8a89518f3cd33 deleted file mode 100644 index b0fc9f46ddb..00000000000 --- a/docs/en-US/hypervisor-installation.xml~432ff7ecbe1efface7fedf482be8a89518f3cd33 +++ /dev/null @@ -1,31 +0,0 @@ - - -%BOOK_ENTITIES; -]> - - - - - Hypervisor Installation - - - - - diff --git a/docs/en-US/hypervisor-installation.xml~HEAD b/docs/en-US/hypervisor-installation.xml~HEAD deleted file mode 100644 index b0fc9f46ddb..00000000000 --- a/docs/en-US/hypervisor-installation.xml~HEAD +++ /dev/null @@ -1,31 +0,0 @@ - - -%BOOK_ENTITIES; -]> - - - - - Hypervisor Installation - - - - - From fa207d2b4de41a0799ccdb3d3a70f48184b31979 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Fri, 7 Dec 2012 15:54:59 +0100 Subject: [PATCH 049/145] Add unittests for NiciraNvpApi Added some unittests for the NiciraNvpApi. These tests mainly validate the logic of the execute methods, which are the main thing in this class. Other methods are basically wrappers around these functions. Changed NiciraNvpApi to have a factory method for obtaining the HttpMethod. This makes it easier to mock it. Changed the executeMethods in NiciraNvpApi to protected so the unittests have access. Fixed a bug in NiciraNvpApi where releaseconnection was not called in some cases. --- .../cloud/network/nicira/NiciraNvpApi.java | 107 ++++--- .../network/nicira/NiciraNvpApiTest.java | 302 ++++++++++++++++++ 2 files changed, 373 insertions(+), 36 deletions(-) create mode 100644 plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java diff --git a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java index 351ff7ce524..3e8e0285bfe 100644 --- a/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java +++ b/plugins/network-elements/nicira-nvp/src/com/cloud/network/nicira/NiciraNvpApi.java @@ -41,7 +41,9 @@ import javax.net.ssl.X509TrustManager; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpConnectionManager; import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpMethod; import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; @@ -71,9 +73,42 @@ public class NiciraNvpApi { private String _adminpass; private HttpClient _client; + + /* This factory method is protected so we can extend this + * in the unittests. + */ + protected HttpClient createHttpClient() { + return new HttpClient(s_httpClientManager); + } + + protected HttpMethod createMethod(String type, String uri) throws NiciraNvpApiException { + String url; + try { + url = new URL(_protocol, _host, "/ws.v1/login").toString(); + } catch (MalformedURLException e) { + s_logger.error("Unable to build Nicira API URL", e); + throw new NiciraNvpApiException("Unable to build Nicira API URL", e); + } + + if ("post".equalsIgnoreCase(type)) { + return new PostMethod(url); + } + else if ("get".equalsIgnoreCase(type)) { + return new GetMethod(url); + } + else if ("delete".equalsIgnoreCase(type)) { + return new DeleteMethod(url); + } + else if ("put".equalsIgnoreCase(type)) { + return new PutMethod(url); + } + else { + throw new NiciraNvpApiException("Requesting unknown method type"); + } + } public NiciraNvpApi() { - _client = new HttpClient(s_httpClientManager); + _client = createHttpClient(); _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); try { @@ -100,9 +135,15 @@ public class NiciraNvpApi { * The method returns false if the login failed or the connection could not be made. * */ - private void login() throws NiciraNvpApiException { + protected void login() throws NiciraNvpApiException { String url; + if (_host == null || _host.isEmpty() || + _adminuser == null || _adminuser.isEmpty() || + _adminpass == null || _adminpass.isEmpty()) { + throw new NiciraNvpApiException("Hostname/credentials are null or empty"); + } + try { url = new URL(_protocol, _host, "/ws.v1/login").toString(); } catch (MalformedURLException e) { @@ -294,18 +335,16 @@ public class NiciraNvpApi { return executeRetrieveObject(new TypeToken>(){}.getType(), uri, params); } - private void executeUpdateObject(T newObject, String uri, Map parameters) throws NiciraNvpApiException { - String url; - try { - url = new URL(_protocol, _host, uri).toString(); - } catch (MalformedURLException e) { - s_logger.error("Unable to build Nicira API URL", e); - throw new NiciraNvpApiException("Connection to NVP Failed"); + protected void executeUpdateObject(T newObject, String uri, Map parameters) throws NiciraNvpApiException { + if (_host == null || _host.isEmpty() || + _adminuser == null || _adminuser.isEmpty() || + _adminpass == null || _adminpass.isEmpty()) { + throw new NiciraNvpApiException("Hostname/credentials are null or empty"); } Gson gson = new Gson(); - PutMethod pm = new PutMethod(url); + PutMethod pm = (PutMethod) createMethod("put", uri); pm.setRequestHeader("Content-Type", "application/json"); try { pm.setRequestEntity(new StringRequestEntity( @@ -325,18 +364,16 @@ public class NiciraNvpApi { pm.releaseConnection(); } - private T executeCreateObject(T newObject, Type returnObjectType, String uri, Map parameters) throws NiciraNvpApiException { - String url; - try { - url = new URL(_protocol, _host, uri).toString(); - } catch (MalformedURLException e) { - s_logger.error("Unable to build Nicira API URL", e); - throw new NiciraNvpApiException("Unable to build Nicira API URL", e); + protected T executeCreateObject(T newObject, Type returnObjectType, String uri, Map parameters) throws NiciraNvpApiException { + if (_host == null || _host.isEmpty() || + _adminuser == null || _adminuser.isEmpty() || + _adminpass == null || _adminpass.isEmpty()) { + throw new NiciraNvpApiException("Hostname/credentials are null or empty"); } Gson gson = new Gson(); - PostMethod pm = new PostMethod(url); + PostMethod pm = (PostMethod) createMethod("post", uri); pm.setRequestHeader("Content-Type", "application/json"); try { pm.setRequestEntity(new StringRequestEntity( @@ -366,16 +403,14 @@ public class NiciraNvpApi { return result; } - private void executeDeleteObject(String uri) throws NiciraNvpApiException { - String url; - try { - url = new URL(_protocol, _host, uri).toString(); - } catch (MalformedURLException e) { - s_logger.error("Unable to build Nicira API URL", e); - throw new NiciraNvpApiException("Unable to build Nicira API URL", e); + protected void executeDeleteObject(String uri) throws NiciraNvpApiException { + if (_host == null || _host.isEmpty() || + _adminuser == null || _adminuser.isEmpty() || + _adminpass == null || _adminpass.isEmpty()) { + throw new NiciraNvpApiException("Hostname/credentials are null or empty"); } - - DeleteMethod dm = new DeleteMethod(url); + + DeleteMethod dm = (DeleteMethod) createMethod("delete", uri); dm.setRequestHeader("Content-Type", "application/json"); executeMethod(dm); @@ -389,16 +424,14 @@ public class NiciraNvpApi { dm.releaseConnection(); } - private T executeRetrieveObject(Type returnObjectType, String uri, Map parameters) throws NiciraNvpApiException { - String url; - try { - url = new URL(_protocol, _host, uri).toString(); - } catch (MalformedURLException e) { - s_logger.error("Unable to build Nicira API URL", e); - throw new NiciraNvpApiException("Unable to build Nicira API URL", e); + protected T executeRetrieveObject(Type returnObjectType, String uri, Map parameters) throws NiciraNvpApiException { + if (_host == null || _host.isEmpty() || + _adminuser == null || _adminuser.isEmpty() || + _adminpass == null || _adminpass.isEmpty()) { + throw new NiciraNvpApiException("Hostname/credentials are null or empty"); } - GetMethod gm = new GetMethod(url); + GetMethod gm = (GetMethod) createMethod("get", uri); gm.setRequestHeader("Content-Type", "application/json"); if (parameters != null && !parameters.isEmpty()) { List nameValuePairs = new ArrayList(parameters.size()); @@ -430,7 +463,7 @@ public class NiciraNvpApi { return returnValue; } - private void executeMethod(HttpMethodBase method) throws NiciraNvpApiException { + protected void executeMethod(HttpMethodBase method) throws NiciraNvpApiException { try { _client.executeMethod(method); if (method.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { @@ -441,9 +474,11 @@ public class NiciraNvpApi { } } catch (HttpException e) { s_logger.error("HttpException caught while trying to connect to the Nicira NVP Controller", e); + method.releaseConnection(); throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e); } catch (IOException e) { s_logger.error("IOException caught while trying to connect to the Nicira NVP Controller", e); + method.releaseConnection(); throw new NiciraNvpApiException("API call to Nicira NVP Controller Failed", e); } } diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java new file mode 100644 index 00000000000..51d961864a0 --- /dev/null +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java @@ -0,0 +1,302 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 com.cloud.network.nicira; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; + +import java.io.IOException; +import java.util.Collections; + +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.methods.DeleteMethod; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.PutMethod; +import org.apache.commons.httpclient.params.HttpClientParams; +import org.apache.http.HttpStatus; +import org.junit.Before; +import org.junit.Test; + +public class NiciraNvpApiTest { + NiciraNvpApi _api; + HttpClient _client = mock(HttpClient.class); + HttpMethod _method; + + @Before + public void setUp() { + HttpClientParams hmp = mock(HttpClientParams.class); + when (_client.getParams()).thenReturn(hmp); + _api = new NiciraNvpApi() { + @Override + protected HttpClient createHttpClient() { + return _client; + } + + @Override + protected HttpMethod createMethod(String type, String uri) { + return _method; + } + }; + _api.setAdminCredentials("admin", "adminpass"); + _api.setControllerAddress("localhost"); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteLoginWithoutHostname() throws NiciraNvpApiException { + _api.setControllerAddress(null); + _api.login(); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteLoginWithoutCredentials() throws NiciraNvpApiException { + _api.setAdminCredentials(null, null); + _api.login(); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteUpdateObjectWithoutHostname() throws NiciraNvpApiException { + _api.setControllerAddress(null); + _api.executeUpdateObject(new String(), "/", Collections. emptyMap()); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteUpdateObjectWithoutCredentials() throws NiciraNvpApiException { + _api.setAdminCredentials(null, null); + _api.executeUpdateObject(new String(), "/", Collections. emptyMap()); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteCreateObjectWithoutHostname() throws NiciraNvpApiException { + _api.setControllerAddress(null); + _api.executeCreateObject(new String(), String.class, "/", Collections. emptyMap()); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteCreateObjectWithoutCredentials() throws NiciraNvpApiException { + _api.setAdminCredentials(null, null); + _api.executeCreateObject(new String(), String.class, "/", Collections. emptyMap()); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteDeleteObjectWithoutHostname() throws NiciraNvpApiException { + _api.setControllerAddress(null); + _api.executeDeleteObject("/"); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteDeleteObjectWithoutCredentials() throws NiciraNvpApiException { + _api.setAdminCredentials(null, null); + _api.executeDeleteObject("/"); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteRetrieveObjectWithoutHostname() throws NiciraNvpApiException { + _api.setControllerAddress(null); + _api.executeRetrieveObject(String.class, "/", Collections. emptyMap()); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteRetrieveObjectWithoutCredentials() throws NiciraNvpApiException { + _api.setAdminCredentials(null, null); + _api.executeDeleteObject("/"); + } + + @Test + public void executeMethodTest() throws NiciraNvpApiException { + GetMethod gm = mock(GetMethod.class); + + when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK); + _api.executeMethod(gm); + verify(gm, times(1)).getStatusCode(); + } + + /* Bit of a roundabout way to ensure that login is called after an un authorized result + * It not possible to properly mock login() + */ + @Test (expected=NiciraNvpApiException.class) + public void executeMethodTestWithLogin() throws NiciraNvpApiException, HttpException, IOException { + GetMethod gm = mock(GetMethod.class); + when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException()); + when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED); + _api.executeMethod(gm); + verify(gm, times(1)).getStatusCode(); + } + + @Test + public void testExecuteCreateObject() throws NiciraNvpApiException, IOException { + LogicalSwitch ls = new LogicalSwitch(); + _method = mock(PostMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED); + when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }"); + ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections. emptyMap()); + assertTrue("aaaa".equals(ls.getUuid())); + verify(_method, times(1)).releaseConnection(); + + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteCreateObjectFailure() throws NiciraNvpApiException, IOException { + LogicalSwitch ls = new LogicalSwitch(); + _method = mock(PostMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + Header header = mock(Header.class); + when(header.getValue()).thenReturn("text/html"); + when(_method.getResponseHeader("Content-Type")).thenReturn(header); + when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + try { + ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections. emptyMap()); + } finally { + verify(_method, times(1)).releaseConnection(); + } + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteCreateObjectException() throws NiciraNvpApiException, IOException { + LogicalSwitch ls = new LogicalSwitch(); + when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException()); + _method = mock(PostMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + Header header = mock(Header.class); + when(header.getValue()).thenReturn("text/html"); + when(_method.getResponseHeader("Content-Type")).thenReturn(header); + when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + try { + ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections. emptyMap()); + } finally { + verify(_method, times(1)).releaseConnection(); + } + } + + @Test + public void testExecuteUpdateObject() throws NiciraNvpApiException, IOException { + LogicalSwitch ls = new LogicalSwitch(); + _method = mock(PutMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK); + _api.executeUpdateObject(ls, "/", Collections. emptyMap()); + verify(_method, times(1)).releaseConnection(); + verify(_client, times(1)).executeMethod(_method); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteUpdateObjectFailure() throws NiciraNvpApiException, IOException { + LogicalSwitch ls = new LogicalSwitch(); + _method = mock(PutMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + Header header = mock(Header.class); + when(header.getValue()).thenReturn("text/html"); + when(_method.getResponseHeader("Content-Type")).thenReturn(header); + when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + try { + _api.executeUpdateObject(ls, "/", Collections. emptyMap()); + } finally { + verify(_method, times(1)).releaseConnection(); + } + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteUpdateObjectException() throws NiciraNvpApiException, IOException { + LogicalSwitch ls = new LogicalSwitch(); + _method = mock(PutMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK); + when(_client.executeMethod((HttpMethod) any())).thenThrow(new IOException()); + try { + _api.executeUpdateObject(ls, "/", Collections. emptyMap()); + } finally { + verify(_method, times(1)).releaseConnection(); + } + } + + @Test + public void testExecuteDeleteObject() throws NiciraNvpApiException, IOException { + _method = mock(DeleteMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT); + _api.executeDeleteObject("/"); + verify(_method, times(1)).releaseConnection(); + verify(_client, times(1)).executeMethod(_method); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteDeleteObjectFailure() throws NiciraNvpApiException, IOException { + _method = mock(DeleteMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + Header header = mock(Header.class); + when(header.getValue()).thenReturn("text/html"); + when(_method.getResponseHeader("Content-Type")).thenReturn(header); + when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + try { + _api.executeDeleteObject("/"); + } finally { + verify(_method, times(1)).releaseConnection(); + } + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteDeleteObjectException() throws NiciraNvpApiException, IOException { + _method = mock(DeleteMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT); + when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException()); + try { + _api.executeDeleteObject("/"); + } finally { + verify(_method, times(1)).releaseConnection(); + } + } + + @Test + public void testExecuteRetrieveObject() throws NiciraNvpApiException, IOException { + _method = mock(GetMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK); + when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }"); + _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections. emptyMap()); + verify(_method, times(1)).releaseConnection(); + verify(_client, times(1)).executeMethod(_method); + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteRetrieveObjectFailure() throws NiciraNvpApiException, IOException { + _method = mock(GetMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR); + when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }"); + Header header = mock(Header.class); + when(header.getValue()).thenReturn("text/html"); + when(_method.getResponseHeader("Content-Type")).thenReturn(header); + when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + try { + _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections. emptyMap()); + } finally { + verify(_method, times(1)).releaseConnection(); + } + } + + @Test (expected=NiciraNvpApiException.class) + public void testExecuteRetrieveObjectException() throws NiciraNvpApiException, IOException { + _method = mock(GetMethod.class); + when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK); + when(_method.getResponseBodyAsString()).thenReturn("{ \"uuid\" : \"aaaa\" }"); + when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException()); + try { + _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections. emptyMap()); + } finally { + verify(_method, times(1)).releaseConnection(); + } + } + +} From 2b74b6e82781825c67b499b3a12120d088be5dd8 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Fri, 7 Dec 2012 15:58:56 +0100 Subject: [PATCH 050/145] Start removing the old ant build files Removed all build.xml files from the plugins --- .../user-concentrated-pod/build.xml | 128 ---------------- .../user-dispersing/build.xml | 128 ---------------- plugins/file-systems/netapp/build.xml | 129 ----------------- plugins/host-allocators/random/build.xml | 128 ---------------- plugins/hypervisors/kvm/build.xml | 137 ------------------ plugins/hypervisors/ovm/build.xml | 136 ----------------- plugins/hypervisors/vmware/build.xml | 135 ----------------- plugins/hypervisors/xen/build.xml | 135 ----------------- .../elastic-loadbalancer/build.xml | 129 ----------------- plugins/network-elements/f5/build.xml | 129 ----------------- .../network-elements/juniper-srx/build.xml | 129 ----------------- .../midokura-midonet/build.xml | 17 --- plugins/network-elements/netscaler/build.xml | 129 ----------------- plugins/network-elements/nicira-nvp/build.xml | 129 ----------------- plugins/network-elements/ovs/build.xml | 129 ----------------- plugins/storage-allocators/random/build.xml | 128 ---------------- plugins/user-authenticators/ldap/build.xml | 128 ---------------- plugins/user-authenticators/md5/build.xml | 128 ---------------- .../user-authenticators/plain-text/build.xml | 128 ---------------- 19 files changed, 2359 deletions(-) delete mode 100755 plugins/deployment-planners/user-concentrated-pod/build.xml delete mode 100755 plugins/deployment-planners/user-dispersing/build.xml delete mode 100755 plugins/file-systems/netapp/build.xml delete mode 100755 plugins/host-allocators/random/build.xml delete mode 100755 plugins/hypervisors/kvm/build.xml delete mode 100755 plugins/hypervisors/ovm/build.xml delete mode 100755 plugins/hypervisors/vmware/build.xml delete mode 100755 plugins/hypervisors/xen/build.xml delete mode 100755 plugins/network-elements/elastic-loadbalancer/build.xml delete mode 100755 plugins/network-elements/f5/build.xml delete mode 100755 plugins/network-elements/juniper-srx/build.xml delete mode 100644 plugins/network-elements/midokura-midonet/build.xml delete mode 100755 plugins/network-elements/netscaler/build.xml delete mode 100644 plugins/network-elements/nicira-nvp/build.xml delete mode 100755 plugins/network-elements/ovs/build.xml delete mode 100755 plugins/storage-allocators/random/build.xml delete mode 100755 plugins/user-authenticators/ldap/build.xml delete mode 100755 plugins/user-authenticators/md5/build.xml delete mode 100755 plugins/user-authenticators/plain-text/build.xml diff --git a/plugins/deployment-planners/user-concentrated-pod/build.xml b/plugins/deployment-planners/user-concentrated-pod/build.xml deleted file mode 100755 index d63f33476b3..00000000000 --- a/plugins/deployment-planners/user-concentrated-pod/build.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/deployment-planners/user-dispersing/build.xml b/plugins/deployment-planners/user-dispersing/build.xml deleted file mode 100755 index ba72332586a..00000000000 --- a/plugins/deployment-planners/user-dispersing/build.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/file-systems/netapp/build.xml b/plugins/file-systems/netapp/build.xml deleted file mode 100755 index 6326e144f6a..00000000000 --- a/plugins/file-systems/netapp/build.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/host-allocators/random/build.xml b/plugins/host-allocators/random/build.xml deleted file mode 100755 index 6cb8fd8980e..00000000000 --- a/plugins/host-allocators/random/build.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/hypervisors/kvm/build.xml b/plugins/hypervisors/kvm/build.xml deleted file mode 100755 index 9a572496fc3..00000000000 --- a/plugins/hypervisors/kvm/build.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/hypervisors/ovm/build.xml b/plugins/hypervisors/ovm/build.xml deleted file mode 100755 index 8113d725daa..00000000000 --- a/plugins/hypervisors/ovm/build.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/hypervisors/vmware/build.xml b/plugins/hypervisors/vmware/build.xml deleted file mode 100755 index f6bcd435ae4..00000000000 --- a/plugins/hypervisors/vmware/build.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/hypervisors/xen/build.xml b/plugins/hypervisors/xen/build.xml deleted file mode 100755 index 9d3406f0ae2..00000000000 --- a/plugins/hypervisors/xen/build.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/network-elements/elastic-loadbalancer/build.xml b/plugins/network-elements/elastic-loadbalancer/build.xml deleted file mode 100755 index 66e42cedbd2..00000000000 --- a/plugins/network-elements/elastic-loadbalancer/build.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/network-elements/f5/build.xml b/plugins/network-elements/f5/build.xml deleted file mode 100755 index 47fcb1c6181..00000000000 --- a/plugins/network-elements/f5/build.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/network-elements/juniper-srx/build.xml b/plugins/network-elements/juniper-srx/build.xml deleted file mode 100755 index 7b8138a2ee2..00000000000 --- a/plugins/network-elements/juniper-srx/build.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/network-elements/midokura-midonet/build.xml b/plugins/network-elements/midokura-midonet/build.xml deleted file mode 100644 index 6b826e700eb..00000000000 --- a/plugins/network-elements/midokura-midonet/build.xml +++ /dev/null @@ -1,17 +0,0 @@ - - diff --git a/plugins/network-elements/netscaler/build.xml b/plugins/network-elements/netscaler/build.xml deleted file mode 100755 index dcf8663de4b..00000000000 --- a/plugins/network-elements/netscaler/build.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/network-elements/nicira-nvp/build.xml b/plugins/network-elements/nicira-nvp/build.xml deleted file mode 100644 index 2d84c5c455f..00000000000 --- a/plugins/network-elements/nicira-nvp/build.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/network-elements/ovs/build.xml b/plugins/network-elements/ovs/build.xml deleted file mode 100755 index 718720b7736..00000000000 --- a/plugins/network-elements/ovs/build.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/storage-allocators/random/build.xml b/plugins/storage-allocators/random/build.xml deleted file mode 100755 index e5fcebebbc8..00000000000 --- a/plugins/storage-allocators/random/build.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/user-authenticators/ldap/build.xml b/plugins/user-authenticators/ldap/build.xml deleted file mode 100755 index c0ae8b89d18..00000000000 --- a/plugins/user-authenticators/ldap/build.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/user-authenticators/md5/build.xml b/plugins/user-authenticators/md5/build.xml deleted file mode 100755 index eee2fc70bff..00000000000 --- a/plugins/user-authenticators/md5/build.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/user-authenticators/plain-text/build.xml b/plugins/user-authenticators/plain-text/build.xml deleted file mode 100755 index a59bb5d9e65..00000000000 --- a/plugins/user-authenticators/plain-text/build.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - Cloud Stack ant build file - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 9c8eba1da3ee4499d5fb2edc0c732ffa34298d36 Mon Sep 17 00:00:00 2001 From: Hugo Trippaers Date: Fri, 7 Dec 2012 17:34:14 +0100 Subject: [PATCH 051/145] Fix the tests Note to self, surefire actually runs with assertions enabled where junit inside eclipse doesn't. Sure surefire will mark tests as failed when an assertion is triggered. Take care when mocking stuff. --- .../test/com/cloud/network/nicira/NiciraNvpApiTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java index 51d961864a0..42eb96e42d8 100644 --- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java +++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java @@ -161,6 +161,7 @@ public class NiciraNvpApiTest { when(header.getValue()).thenReturn("text/html"); when(_method.getResponseHeader("Content-Type")).thenReturn(header); when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + when(_method.isRequestSent()).thenReturn(true); try { ls = _api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections. emptyMap()); } finally { @@ -204,6 +205,7 @@ public class NiciraNvpApiTest { when(header.getValue()).thenReturn("text/html"); when(_method.getResponseHeader("Content-Type")).thenReturn(header); when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + when(_method.isRequestSent()).thenReturn(true); try { _api.executeUpdateObject(ls, "/", Collections. emptyMap()); } finally { @@ -241,6 +243,7 @@ public class NiciraNvpApiTest { when(header.getValue()).thenReturn("text/html"); when(_method.getResponseHeader("Content-Type")).thenReturn(header); when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + when(_method.isRequestSent()).thenReturn(true); try { _api.executeDeleteObject("/"); } finally { @@ -279,6 +282,7 @@ public class NiciraNvpApiTest { when(header.getValue()).thenReturn("text/html"); when(_method.getResponseHeader("Content-Type")).thenReturn(header); when(_method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later."); + when(_method.isRequestSent()).thenReturn(true); try { _api.executeRetrieveObject(LogicalSwitch.class, "/", Collections. emptyMap()); } finally { From ac50c2699c30c6c13209e904ab28a53593218f3f Mon Sep 17 00:00:00 2001 From: Joe Brockmeier Date: Fri, 7 Dec 2012 13:48:42 -0600 Subject: [PATCH 052/145] CLOUDSTACK-395: Added xrefs to about-primary-storage and about-secondary-storage --- docs/en-US/primary-storage.xml | 3 ++- docs/en-US/secondary-storage.xml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/en-US/primary-storage.xml b/docs/en-US/primary-storage.xml index 7010868d24b..e1736a9d30e 100644 --- a/docs/en-US/primary-storage.xml +++ b/docs/en-US/primary-storage.xml @@ -24,7 +24,8 @@
Primary Storage - This section gives concepts and technical details about &PRODUCT; primary storage. For information about how to install and configure primary storage through the &PRODUCT; UI, see the Advanced Installation Guide. + This section gives concepts and technical details about &PRODUCT; primary storage. For information about how to install and configure primary storage through the &PRODUCT; UI, see the Installation Guide. + diff --git a/docs/en-US/secondary-storage.xml b/docs/en-US/secondary-storage.xml index e755b56734d..a254b1e2f6e 100644 --- a/docs/en-US/secondary-storage.xml +++ b/docs/en-US/secondary-storage.xml @@ -24,6 +24,7 @@
Secondary Storage - This section gives concepts and technical details about &PRODUCT; secondary storage. For information about how to install and configure secondary storage through the &PRODUCT; UI, see the Advanced Installation Guide. + This section gives concepts and technical details about &PRODUCT; secondary storage. For information about how to install and configure secondary storage through the &PRODUCT; UI, see the Advanced Installation Guide. +
From 5b7b47048b6aac0ccb437c3177d55dfebcea8086 Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Fri, 7 Dec 2012 13:10:36 -0800 Subject: [PATCH 053/145] Add missing tooltips Add missing doc tooltips for the following dialogs: -Add VPN customer gateway -Add ISO -Enter project token -Add compute offering -Add system offering -Add network offering --- ui/scripts/configuration.js | 14 +++- ui/scripts/docs.js | 148 ++++++++++++++++++++++++++++++++++++ ui/scripts/network.js | 13 ++++ ui/scripts/projects.js | 4 +- ui/scripts/templates.js | 9 +++ 5 files changed, 183 insertions(+), 5 deletions(-) diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index bb16138726e..dc5f8f004c3 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -506,6 +506,7 @@ }, domainId: { label: 'label.domain', + docID: 'helpSystemOfferingDomain', dependsOn: 'isPublic', select: function(args) { $.ajax({ @@ -866,6 +867,7 @@ }, domainId: { label: 'label.domain', + docID: 'helpDiskOfferingDomain', dependsOn: 'isPublic', select: function(args) { $.ajax({ @@ -1352,7 +1354,7 @@ fields: { name: { label: 'label.name', validation: { required: true }, docID: 'helpNetworkOfferingName' }, - displayText: { label: 'label.description', validation: { required: true } }, + displayText: { label: 'label.description', validation: { required: true }, docID: 'helpNetworkOfferingDescription' }, networkRate: { label: 'label.network.rate.megabytes', docID: 'helpNetworkOfferingNetworkRate' }, @@ -1397,6 +1399,7 @@ useVpc: { label: 'VPC', + docID: 'helpNetworkOfferingVPC', isBoolean: true, onChange: function(args) { var $checkbox = args.$checkbox; @@ -1542,6 +1545,7 @@ //show or hide upon checked services and selected providers above (begin) serviceOfferingId: { label: 'label.system.offering', + docID: 'helpNetworkOfferingSystemOffering', select: function(args) { $.ajax({ url: createURL('listServiceOfferings&issystem=true&systemvmtype=domainrouter'), @@ -1576,6 +1580,7 @@ label: "label.redundant.router.capability", isHidden: true, dependsOn: 'service.SourceNat.isEnabled', + docID: 'helpNetworkOfferingRedundantRouterCapability', isBoolean: true }, @@ -1600,6 +1605,7 @@ }, "service.Lb.lbIsolationDropdown": { label: 'label.LB.isolation', + docID: 'helpNetworkOfferingLBIsolation', isHidden: true, select: function(args) { args.response.success({ @@ -1612,6 +1618,7 @@ }, "service.Lb.inlineModeDropdown": { label: 'Mode', + docID: 'helpNetworkOfferingMode', select: function(args) { var items = []; items.push({id: "false", description: "side by side"}); @@ -1628,15 +1635,16 @@ "service.StaticNat.associatePublicIP": { label: 'Associate Public IP', + docID: 'helpNetworkOfferingAssociatePublicIP', isBoolean: true, isHidden: true }, //show or hide upon checked services and selected providers above (end) - conservemode: { label: 'label.conserve.mode', isBoolean: true }, + conservemode: { label: 'label.conserve.mode', isBoolean: true , docID: 'helpNetworkOfferingConserveMode'}, - tags: { label: 'label.tags' }, + tags: { label: 'label.tags', docID: 'helpNetworkOfferingTags' }, availability: { label: 'label.availability', diff --git a/ui/scripts/docs.js b/ui/scripts/docs.js index 56d919d485a..5a38613f076 100755 --- a/ui/scripts/docs.js +++ b/ui/scripts/docs.js @@ -174,6 +174,10 @@ cloudStack.docs = { desc: 'Yes makes the offering available to all domains. No limits the scope to a subdomain; you will be prompted for the subdomain\'s name.', externalLink: '' }, + helpDiskOfferingDomain: { + desc: 'Select the subdomain in which this offering is available', + externalLink: '' + }, // Add domain helpDomainName: { desc: 'Any desired name for the new sub-domain. Must be unique within the current domain.', @@ -361,6 +365,10 @@ cloudStack.docs = { desc: 'Any desired name for the network offering', externalLink: '' }, + helpNetworkOfferingDescription: { + desc: 'A short description of the offering that can be displayed to users', + externalLink: '' + }, helpNetworkOfferingNetworkRate: { desc: 'Allowed data transfer rate in MB per second', externalLink: '' @@ -377,6 +385,38 @@ cloudStack.docs = { desc: '(Isolated guest networks only) Indicate whether a VLAN should be specified when this offering is used', externalLink: '' }, + helpNetworkOfferingVPC: { + desc: 'Specify whether this offering is for a virtual private cloud', + externalLink: '' + }, + helpNetworkOfferingSystemOffering: { + desc: 'Choose the system service offering that you want the virtual routers to use in this network', + externalLink: '' + }, + helpNetworkOfferingLBIsolation: { + desc: 'Specify what type of load balancer isolation you want for the network: Shared or Dedicated', + externalLink: '' + }, + helpNetworkOfferingMode: { + desc: 'Choose Inline or Side by Side to specify whether a firewall is placed in front of the load balancing device (inline) or in parallel with it (side-by-side)', + externalLink: '' + }, + helpNetworkOfferingAssociatePublicIP: { + desc: 'Select this option if you want to assign a public IP address to the VMs deployed in the guest network', + externalLink: '' + }, + helpNetworkOfferingRedundantRouterCapability: { + desc: 'Select this option if you want to use two virtual routers in the network for uninterrupted connection: one operating as the master virtual router and the other as the backup', + externalLink: '' + }, + helpNetworkOfferingConserveMode: { + desc: 'Check this box to use conserve mode, where network resources are allocated only when the first VM starts. You can define more than one service on the same public IP only when conserve mode is on.', + externalLink: '' + }, + helpNetworkOfferingTags: { + desc: 'Network tag to specify which physical network to use', + externalLink: '' + }, // Add pod helpPodZone: { desc: 'The zone where you want to add the pod', @@ -570,6 +610,10 @@ cloudStack.docs = { desc: 'Yes makes the offering available to all domains. No limits the scope to a subdomain; you will be prompted for the subdomain\'s name.', externalLink: '' }, + helpSystemOfferingDomain: { + desc: 'Select the subdomain in which this offering is available', + externalLink: '' + }, // Add tier helpTierName: { desc: 'A unique name for the tier', @@ -671,17 +715,121 @@ cloudStack.docs = { desc: 'The netmask associated with the VPC gateway', externalLink: '' }, + // Add VPN customer gateway + helpVPNGatewayName: { + desc: 'A unique name for the VPN customer gateway', + externalLink: '' + }, + helpVPNGatewayGateway: { + desc: 'The IP address for the remote gateway', + externalLink: '' + }, + helpVPNGatewayCIDRList: { + desc: 'The guest CIDR list of the remote subnets. Enter a CIDR or a comma-separated list. Do not overlap the VPC\'s CIDR or another guest CIDR.', + externalLink: '' + }, + helpVPNGatewayIPsecPresharedKey: { + desc: 'Enter a secret key value. The endpoints of the VPN share a secret key. This is used to authenticate the customer gateway and the VPC VPN gateway to each other.', + externalLink: '' + }, + helpVPNGatewayIKEEncryption: { + desc: 'Enter AES128, AES192, AES256, or 3DES to specify the Internet Key Exchange (IKE) policy for phase-1. Authentication is accomplished with Preshared Keys.', + externalLink: '' + }, + helpVPNGatewayIKEHash: { + desc: 'Enter SHA1 or MD5 to specify the IKE hash algorithm for phase-1', + externalLink: '' + }, + helpVPNGatewayIKEDH: { + desc: 'Enter Group-5 (1536-bit), Group-2 (1024-bit), or None to specify the public-key cryptography protocol to use. The 1536-bit Diffie-Hellman group is used within IKE to establish session keys.', + externalLink: '' + }, + helpVPNGatewayESPEncryption: { + desc: 'Enter AES128, AES192, AES256, or 3DES to specify the Encapsulating Security Payload (ESP) algorithm within phase-2', + externalLink: '' + }, + helpVPNGatewayESPHash: { + desc: 'Enter SHA1 or MD5 to specify the Encapsulating Security Payload (ESP) hash for phase-2', + externalLink: '' + }, + helpVPNGatewayPerfectForwardSecrecy: { + desc: 'Choose Group-5 (1536-bit), Group-2 (1024-bit), or None to specify whether to enforce a new Diffie-Hellman key exchange and, if so, what size of DH group to use', + externalLink: '' + }, + helpVPNGatewayIKELifetime: { + desc: 'The phase-1 lifetime of the security association in seconds. Whenever the time expires, a new phase-1 exchange is performed.', + externalLink: '' + }, + helpVPNGatewayESPLifetime: { + desc: 'The phase-2 lifetime of the security association in seconds. Whenever the time expires, a re-key is initiated to provide a new IPsec encryption and authentication session keys.', + externalLink: '' + }, + helpVPNGatewayDeadPeerDetection: { + desc: 'Check this to make the virtual router query its IKE peer at regular intervals to ensure continued availability. It is recommended to have the same DPD setting on both sides of the VPN connection.', + externalLink: '' + }, // Copy template helpCopyTemplateDestination: { desc: 'The zone to which you want to copy the template', externalLink: '' }, + // Enter token + helpEnterTokenProjectID: { + desc: 'Unique identifying number for the project. Use the number you received in the invitation email', + externalLink: '' + }, + helpEnterTokenToken: { + desc: 'Unique security code that authorizes you to accept the project invitation. Use the token you received in the invitation email', + externalLink: '' + }, // Register template helpRegisterTemplate: { desc: '', externalLink: '' }, // Register template + helpRegisterTemplate: { + desc: '', + externalLink: '' + }, + // Register ISO + helpRegisterISOName: { + desc: 'A unique name for the ISO. This will be visible to users, so choose something descriptive.', + externalLink: '' + }, + helpRegisterISODescription: { + desc: 'Display text describing the ISO. This will be visible to users, so choose something descriptive.', + externalLink: '' + }, + helpRegisterISOURL: { + desc: 'The Management Server will download the file from the specified URL, such as http://my.web.server/filename.iso', + externalLink: '' + }, + helpRegisterISOZone: { + desc: 'Choose the zone where you want the ISO to be available, or All Zones to make it available throughout the cloud', + externalLink: '' + }, + helpRegisterISOBootable: { + desc: 'Indicate whether the machine can be booted using this ISO', + externalLink: '' + }, + helpRegisterISOOSType: { + desc: 'Operating system of the VM represented by the ISO. If the OS type of the ISO is not listed, choose Other.', + externalLink: '' + }, + helpRegisterISOExtractable: { + desc: 'Whether the ISO is extractable or not', + externalLink: '' + }, + helpRegisterISOPublic: { + desc: 'Check this to make the ISO accessible to all users. The ISO will appear in the Community ISOs list.', + externalLink: '' + }, + helpRegisterISOFeatured: { + desc: 'Check this to make the ISO more prominent for users. The ISO will appear in the Featured ISOs list.', + externalLink: '' + }, + // Register template helpRegisterTemplateName: { desc: 'A unique name for the template. This will be visible to users, so choose something descriptive.', externalLink: '' diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 3150b901342..23b1d3072c3 100755 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -4550,6 +4550,7 @@ fields: { name: { label: 'label.name', + docID: 'helpVPNGatewayName', validation: { required: true } }, gateway: { @@ -4563,21 +4564,25 @@ }, gateway: { label: 'label.gateway', + docID: 'helpVPNGatewayGateway', validation: { required: true } }, cidrlist: { label: 'label.CIDR.list', desc:'Please enter a comma separated list of CIDRs if more than one', + docID: 'helpVPNGatewayCIDRList', validation: { required: true } }, ipsecpsk: { label: 'label.IPsec.preshared.key', + docID: 'helpVPNGatewayIPsecPresharedKey', validation: { required: true } }, //IKE Policy ikeEncryption: { label: 'label.IKE.encryption', + docID: 'helpVPNGatewayIKEEncryption', select: function(args) { var items = []; items.push({id: '3des', description: '3des'}); @@ -4589,6 +4594,7 @@ }, ikeHash: { label: 'label.IKE.hash', + docID: 'helpVPNGatewayIKEHash', select: function(args) { var items = []; items.push({id: 'md5', description: 'md5'}); @@ -4598,6 +4604,7 @@ }, ikeDh: { label: 'label.IKE.DH', + docID: 'helpVPNGatewayIKEDH', select: function(args) { var items = []; items.push({id: '', description: 'None'}); @@ -4610,6 +4617,7 @@ //ESP Policy espEncryption: { label: 'label.ESP.encryption', + docID: 'helpVPNGatewayESPLifetime', select: function(args) { var items = []; items.push({id: '3des', description: '3des'}); @@ -4621,6 +4629,7 @@ }, espHash: { label: 'label.ESP.hash', + docID: 'helpVPNGatewayESPHash', select: function(args) { var items = []; items.push({id: 'md5', description: 'md5'}); @@ -4630,6 +4639,7 @@ }, perfectForwardSecrecy: { label: 'label.perfect.forward.secrecy', + docID: 'helpVPNGatewayPerfectForwardSecrecy', select: function(args) { var items = []; items.push({id: '', description: 'None'}); @@ -4641,17 +4651,20 @@ ikelifetime: { label: 'label.IKE.lifetime', + docID: 'helpVPNGatewayIKELifetime', defaultValue: '86400', validation: { required: false, number: true } }, esplifetime: { label: 'label.ESP.lifetime', + docID: 'helpVPNGatewayESPLifetime', defaultValue: '3600', validation: { required: false, number: true } }, dpd: { label: 'label.dead.peer.detection', + docID: 'helpVPNGatewayDeadPeerDetection', isBoolean: true, isChecked: false } diff --git a/ui/scripts/projects.js b/ui/scripts/projects.js index 8310ecf0e4c..31b68e7a338 100644 --- a/ui/scripts/projects.js +++ b/ui/scripts/projects.js @@ -1026,8 +1026,8 @@ createForm: { desc: 'message.enter.token', fields: { - projectid: { label: 'label.project.id', validation: { required: true }}, - token: { label: 'label.token', validation: { required: true }} + projectid: { label: 'label.project.id', validation: { required: true, docID: 'helpEnterTokenProjectID' }}, + token: { label: 'label.token', docID: 'helpEnterTokenToken', validation: { required: true }} } }, action: function(args) { diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index 96c00b7317e..3c49789472c 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -836,18 +836,22 @@ fields: { name: { label: 'label.name', + docID: 'helpRegisterISOName', validation: { required: true } }, description: { label: 'label.description', + docID: 'helpRegisterISODescription', validation: { required: true } }, url: { label: 'URL', + docID: 'helpRegisterISOURL', validation: { required: true } }, zone: { label: 'label.zone', + docID: 'helpRegisterISOZone', select: function(args) { $.ajax({ url: createURL("listZones&available=true"), @@ -870,12 +874,14 @@ isBootable: { label: "label.bootable", + docID: 'helpRegisterISOBootable', isBoolean: true, isChecked: true }, osTypeId: { label: 'label.os.type', + docID: 'helpRegisterISOOSType', dependsOn: 'isBootable', isHidden: false, validation: { required: true }, @@ -899,17 +905,20 @@ isExtractable: { label: "extractable", + docID: 'helpRegisterISOExtractable', isBoolean: true }, isPublic: { label: "label.public", + docID: 'helpRegisterISOPublic', isBoolean: true, isHidden: true }, isFeatured: { label: "label.featured", + docID: 'helpRegisterISOFeatured', isBoolean: true, isHidden: true } From 8ff8673f730c6c27d0f5f2f138ccffe0cb15709b Mon Sep 17 00:00:00 2001 From: ilya musayev Date: Fri, 7 Dec 2012 15:16:22 -0500 Subject: [PATCH 054/145] Fixed ARP issue that affected VmWare with Adavanced Network Zone that use Multiple vSwitches --- patches/systemvm/debian/config/etc/init.d/cloud-early-config | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config index 11380b4105d..64459fd6118 100755 --- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config +++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config @@ -364,6 +364,11 @@ setup_common() { ping -n -c 3 $LOCAL_GW & sleep 3 pkill ping + #This code is added to address ARP issue by pinging MGMT_GW + MGMT_GW=$(echo $MGMTNET | awk -F "." '{print $1"."$2"."$3".1"}') + ping -n -c 3 $MGMT_GW & + sleep 3 + pkill ping fi } From d1e49a05002d6130df739341398b90744bb24928 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Fri, 7 Dec 2012 14:34:43 -0800 Subject: [PATCH 055/145] Marvin: testClient close calls try to close the dbConnection dbConnections are auto-managed do not need explicit closing Signed-off-by: Prasanna Santhanam 1354919683 -0800 --- tools/marvin/marvin/cloudstackTestClient.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py index 2bf14a00386..80ae07da461 100644 --- a/tools/marvin/marvin/cloudstackTestClient.py +++ b/tools/marvin/marvin/cloudstackTestClient.py @@ -119,8 +119,6 @@ class cloudstackTestClient(object): def close(self): if self.connection is not None: self.connection.close() - if self.dbConnection is not None: - self.dbConnection.close() def getDbConnection(self): return self.dbConnection From 1ed2f4bf041af8188375cc66520574913c956483 Mon Sep 17 00:00:00 2001 From: Joe Brockmeier Date: Fri, 7 Dec 2012 17:11:19 -0600 Subject: [PATCH 056/145] CLOUDSTACK-507 removing private key from expected response section in API docs --- api/src/com/cloud/api/response/SSHKeyPairResponse.java | 1 - 1 file changed, 1 deletion(-) diff --git a/api/src/com/cloud/api/response/SSHKeyPairResponse.java b/api/src/com/cloud/api/response/SSHKeyPairResponse.java index 16a29974338..c955335f633 100644 --- a/api/src/com/cloud/api/response/SSHKeyPairResponse.java +++ b/api/src/com/cloud/api/response/SSHKeyPairResponse.java @@ -28,7 +28,6 @@ public class SSHKeyPairResponse extends BaseResponse { @SerializedName("fingerprint") @Param(description="Fingerprint of the public key") private String fingerprint; - @SerializedName("privatekey") @Param(description="Private key") private String privateKey; public SSHKeyPairResponse() {} From a7d7f85e40ca4ba58c02d4f8bf17f1f74bc6e54a Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Fri, 7 Dec 2012 17:16:02 -0800 Subject: [PATCH 057/145] Marvin doesn't require python 2.7, the tests do To compile marvin using maven any standard python interpreter above 2.4 is sufficient. The tests under test/integration will need 2.7 to run. Signed-off-by: Prasanna Santhanam 1354929362 -0800 --- tools/marvin/setup.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/marvin/setup.py b/tools/marvin/setup.py index f0de384bfea..fea53d07f8a 100644 --- a/tools/marvin/setup.py +++ b/tools/marvin/setup.py @@ -20,10 +20,6 @@ from setuptools import setup from sys import version import sys -if version < "2.7": - print "Marvin needs at least python 2.7, found : \n%s"%version - sys.exit(1) - setup(name="Marvin", version="0.1.0", description="Marvin - Python client for testing cloudstack", From 9d6bdf9cf94dff0f5f6b428928c78cf872900a27 Mon Sep 17 00:00:00 2001 From: Joe Brockmeier Date: Sun, 9 Dec 2012 10:12:34 -0600 Subject: [PATCH 058/145] CLOUDSTACK-389: Added language to clear up confusion about iSCSI only. --- docs/en-US/management-server-install-nfs-shares.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/en-US/management-server-install-nfs-shares.xml b/docs/en-US/management-server-install-nfs-shares.xml index 28e3fa30de1..e917a8e0b6c 100644 --- a/docs/en-US/management-server-install-nfs-shares.xml +++ b/docs/en-US/management-server-install-nfs-shares.xml @@ -25,11 +25,13 @@
Prepare NFS Shares &PRODUCT; needs a place to keep primary and secondary storage (see Cloud Infrastructure Overview). Both of these can be NFS shares. This section tells how to set up the NFS shares before adding the storage to &PRODUCT;. - For primary storage, you can use iSCSI instead. + Alternative Storage + NFS is not the only option for primary or secondary storage. For example, you may use a Ceph RDB cluster, GlusterFS, iSCSI, and otthers. + The requirements for primary and secondary storage are described in: - About Primary Storage - About Secondary Storage + + A production installation typically uses a separate NFS server. See . You can also use the Management Server node as the NFS server. This is more typical of a trial installation, but is technically possible in a larger deployment. See . From 2bd877616bd7f17c592385e60e01459dd27097bd Mon Sep 17 00:00:00 2001 From: Joe Brockmeier Date: Sun, 9 Dec 2012 11:09:48 -0600 Subject: [PATCH 059/145] CLOUDSTACK-400: documening procedure to update MySQL password. Also added a few xrefs in other documents that were missing them. --- docs/en-US/about-password-encryption.xml | 4 +- docs/en-US/change-database-config.xml | 4 +- docs/en-US/change-database-password.xml | 74 +++++++++++++++++++ docs/en-US/manage-cloud.xml | 3 +- .../management-server-install-systemvm.xml | 3 +- 5 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 docs/en-US/change-database-password.xml diff --git a/docs/en-US/about-password-encryption.xml b/docs/en-US/about-password-encryption.xml index 3f7c4c84350..3cd84d19508 100644 --- a/docs/en-US/about-password-encryption.xml +++ b/docs/en-US/about-password-encryption.xml @@ -54,8 +54,8 @@ external source during Management Server startup. This key can be provided in one of two ways: loaded from a file or provided by the &PRODUCT; administrator. The &PRODUCT; database has a new configuration setting that lets it know which of these methods will be used. If the encryption - type is set to “file,†the key must be in a file in a known location. If the encryption type is - set to “web,†the administrator runs the utility + type is set to "file," the key must be in a file in a known location. If the encryption type is + set to "web," the administrator runs the utility com.cloud.utils.crypt.EncryptionSecretKeySender, which relays the key to the Management Server over a known port. The encryption type, database secret key, and Management Server secret key are set during diff --git a/docs/en-US/change-database-config.xml b/docs/en-US/change-database-config.xml index fadb64c27e7..34e767251e0 100644 --- a/docs/en-US/change-database-config.xml +++ b/docs/en-US/change-database-config.xml @@ -24,5 +24,5 @@
Changing the Database Configuration - The &PRODUCT; Management Server stores database configuration information (e.g., hostname, port, credentials) in the file /etc/cloud/management/db.properties. To effect a change, edit this file on each Management Server, then restart the Management Server. -
\ No newline at end of file + The &PRODUCT; Management Server stores database configuration information (e.g., hostname, port, credentials) in the file /etc/cloud/management/db.properties. To effect a change, edit this file on each Management Server, then restart the Management Server. +
diff --git a/docs/en-US/change-database-password.xml b/docs/en-US/change-database-password.xml new file mode 100644 index 00000000000..9041ade9f26 --- /dev/null +++ b/docs/en-US/change-database-password.xml @@ -0,0 +1,74 @@ + + +%BOOK_ENTITIES; +]> + + + +
+ Changing the Database Password + You may need to change the password for the MySQL account used by CloudStack. If so, you'll need to change the password in MySQL, and then add the encrypted password to /etc/cloud/management/db.properties. + + Before changing the password, you'll need to stop CloudStack's management server and the usage engine if you've deployed that component. + +# service cloud-management stop +# service cloud-usage stop + + + + Next, you'll update the password for the CloudStack user on the MySQL server. + +# mysql -u root -p + + At the MySQL shell, you'll change the password and flush privileges: + +update mysql.user set password=PASSWORD("newpassword123") where User='cloud'; +flush privileges; +quit; + + + + The next step is to encrypt the password and copy the encrypted password to CloudStack's database configuration (/etc/cloud/management/db.properties). + +# java -classpath /usr/share/java/cloud-jasypt-1.8.jar \ +org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI encrypt.sh \ +input="newpassword123" password="`cat /etc/cloud/management/key`" \ +verbose=false + + +File encryption type + Note that this is for the file encryption type. If you're using the web encryption type (see ) then you'll use password="management_server_secret_key" + + + + Now, you'll update /etc/cloud/management/db.properties with the new ciphertext. Open /etc/cloud/management/db.properties in a text editor, and update these parameters: + +db.cloud.password=ENC(encrypted_password_from_above) +db.usage.password=ENC(encrypted_password_from_above) + + + + After copying the new password over, you can now start CloudStack (and the usage engine, if necessary). + + # service cloud-management start + # service cloud-usage start + + +
diff --git a/docs/en-US/manage-cloud.xml b/docs/en-US/manage-cloud.xml index 3e29d09cdc1..f5df2c62325 100644 --- a/docs/en-US/manage-cloud.xml +++ b/docs/en-US/manage-cloud.xml @@ -26,7 +26,8 @@ Managing the Cloud + - \ No newline at end of file + diff --git a/docs/en-US/management-server-install-systemvm.xml b/docs/en-US/management-server-install-systemvm.xml index 6cd1ef7a0ff..df2c3738abf 100644 --- a/docs/en-US/management-server-install-systemvm.xml +++ b/docs/en-US/management-server-install-systemvm.xml @@ -37,8 +37,7 @@ If your secondary storage mount point is not named /mnt/secondary, substitute your own mount point name. If you set the &PRODUCT; database encryption type to "web" when you set up the database, - you must now add the parameter -s <management-server-secret-key>. See About Password - and Key Encryption. + you must now add the parameter -s <management-server-secret-key>. See . This process will require approximately 5 GB of free space on the local file system and up to 30 minutes each time it runs. From 18d7595292f336093e5c586b544d911f5a70ac5d Mon Sep 17 00:00:00 2001 From: Sebastien Goasguen Date: Fri, 7 Dec 2012 17:58:18 +0100 Subject: [PATCH 060/145] Prepare docs for transifex translation --- ....0.xml => Book_Info_Release_Notes_4-0.xml} | 0 docs/en-US/Release_Notes.xml | 2 +- ...nds-4.0.xml => added-API-commands-4-0.xml} | 0 ...ds-4.0.xml => changed-apicommands-4-0.xml} | 0 ...-policy-pfwd-rule-usage-record-format.xml} | 0 ...=> ongoing-config-of-ext-firewalls-lb.xml} | 0 docs/en-US/provisioning-steps.xml.orig | 42 ------------------- docs/en-US/troubleshooting.xml | 6 +-- ...lesht-dataloss-on-exp-primary-storage.xml} | 0 ...lesht-mtn-mode-not-working-on-vCenter.xml} | 0 10 files changed, 4 insertions(+), 46 deletions(-) rename docs/en-US/{Book_Info_Release_Notes_4.0.xml => Book_Info_Release_Notes_4-0.xml} (100%) rename docs/en-US/{added-API-commands-4.0.xml => added-API-commands-4-0.xml} (100%) rename docs/en-US/{changed-apicommands-4.0.xml => changed-apicommands-4-0.xml} (100%) rename docs/en-US/{loadbalancer-policy-port-forwarding-rule-usage-record-format.xml => lb-policy-pfwd-rule-usage-record-format.xml} (100%) rename docs/en-US/{ongoing-configuration-of-external-firewalls-loadbalancer.xml => ongoing-config-of-ext-firewalls-lb.xml} (100%) delete mode 100644 docs/en-US/provisioning-steps.xml.orig rename docs/en-US/{troubleshooting-dataloss-on-exported-primary-storage.xml => troublesht-dataloss-on-exp-primary-storage.xml} (100%) rename docs/en-US/{troubleshooting-maintenance-mode-not-working-on-vCenter.xml => troublesht-mtn-mode-not-working-on-vCenter.xml} (100%) diff --git a/docs/en-US/Book_Info_Release_Notes_4.0.xml b/docs/en-US/Book_Info_Release_Notes_4-0.xml similarity index 100% rename from docs/en-US/Book_Info_Release_Notes_4.0.xml rename to docs/en-US/Book_Info_Release_Notes_4-0.xml diff --git a/docs/en-US/Release_Notes.xml b/docs/en-US/Release_Notes.xml index 17f9079cc01..c8cc6869737 100644 --- a/docs/en-US/Release_Notes.xml +++ b/docs/en-US/Release_Notes.xml @@ -19,7 +19,7 @@ under the License. --> - + Submitting Feedback and Getting Help The Apache CloudStack project has mailing lists for users and developers. These are the diff --git a/docs/en-US/added-API-commands-4.0.xml b/docs/en-US/added-API-commands-4-0.xml similarity index 100% rename from docs/en-US/added-API-commands-4.0.xml rename to docs/en-US/added-API-commands-4-0.xml diff --git a/docs/en-US/changed-apicommands-4.0.xml b/docs/en-US/changed-apicommands-4-0.xml similarity index 100% rename from docs/en-US/changed-apicommands-4.0.xml rename to docs/en-US/changed-apicommands-4-0.xml diff --git a/docs/en-US/loadbalancer-policy-port-forwarding-rule-usage-record-format.xml b/docs/en-US/lb-policy-pfwd-rule-usage-record-format.xml similarity index 100% rename from docs/en-US/loadbalancer-policy-port-forwarding-rule-usage-record-format.xml rename to docs/en-US/lb-policy-pfwd-rule-usage-record-format.xml diff --git a/docs/en-US/ongoing-configuration-of-external-firewalls-loadbalancer.xml b/docs/en-US/ongoing-config-of-ext-firewalls-lb.xml similarity index 100% rename from docs/en-US/ongoing-configuration-of-external-firewalls-loadbalancer.xml rename to docs/en-US/ongoing-config-of-ext-firewalls-lb.xml diff --git a/docs/en-US/provisioning-steps.xml.orig b/docs/en-US/provisioning-steps.xml.orig deleted file mode 100644 index b532783b2d2..00000000000 --- a/docs/en-US/provisioning-steps.xml.orig +++ /dev/null @@ -1,42 +0,0 @@ - - -%BOOK_ENTITIES; -]> - - - - - Steps to Provisioning Your Cloud Infrastructure - This section tells how to add zones, pods, clusters, hosts, storage, and networks to your cloud. If you are unfamiliar with these entities, please begin by looking through . - - - - - - - - - -<<<<<<< HEAD - -
-======= - ->>>>>>> Promote sections to chapters: Cloud Infrastructure Concepts and Provisioning Steps. diff --git a/docs/en-US/troubleshooting.xml b/docs/en-US/troubleshooting.xml index dd736fe18e0..24ecab5489a 100644 --- a/docs/en-US/troubleshooting.xml +++ b/docs/en-US/troubleshooting.xml @@ -26,10 +26,10 @@ Troubleshooting - + - + - \ No newline at end of file + diff --git a/docs/en-US/troubleshooting-dataloss-on-exported-primary-storage.xml b/docs/en-US/troublesht-dataloss-on-exp-primary-storage.xml similarity index 100% rename from docs/en-US/troubleshooting-dataloss-on-exported-primary-storage.xml rename to docs/en-US/troublesht-dataloss-on-exp-primary-storage.xml diff --git a/docs/en-US/troubleshooting-maintenance-mode-not-working-on-vCenter.xml b/docs/en-US/troublesht-mtn-mode-not-working-on-vCenter.xml similarity index 100% rename from docs/en-US/troubleshooting-maintenance-mode-not-working-on-vCenter.xml rename to docs/en-US/troublesht-mtn-mode-not-working-on-vCenter.xml From 400d29be850cd16ba1fd155dc6bfa78e7a75df27 Mon Sep 17 00:00:00 2001 From: Sebastien Goasguen Date: Fri, 7 Dec 2012 18:06:19 +0100 Subject: [PATCH 061/145] Modify docs for transifex translation --- docs/en-US/usage-record-format.xml | 2 +- docs/en-US/whats-new.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en-US/usage-record-format.xml b/docs/en-US/usage-record-format.xml index d40bd63a91e..7f7db06df26 100644 --- a/docs/en-US/usage-record-format.xml +++ b/docs/en-US/usage-record-format.xml @@ -29,7 +29,7 @@ - +
diff --git a/docs/en-US/whats-new.xml b/docs/en-US/whats-new.xml index 5f13db3a854..77b3ec3df22 100644 --- a/docs/en-US/whats-new.xml +++ b/docs/en-US/whats-new.xml @@ -27,8 +27,8 @@ The following describes any new major features of each &PRODUCT; version as it applies to API usage.
What's New in the API for 4.0 - - + +
What's New in the API for 3.0 From 8466ff1e1f8071424e6b439c691ac9e24a429188 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Sun, 9 Dec 2012 21:45:13 -0800 Subject: [PATCH 062/145] Marvin: Provide a userApiClient for executing with user permissions The getUserApiClient attribute in cloudstackTestClient provides a user level api client that executes all API calls with permissions of a given user instead of the default admin --- tools/marvin/marvin/TestCaseExecuteEngine.py | 4 ++-- tools/marvin/marvin/cloudstackTestCase.py | 2 +- tools/marvin/marvin/cloudstackTestClient.py | 17 +++++++++++------ tools/marvin/marvin/marvinPlugin.py | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/marvin/marvin/TestCaseExecuteEngine.py b/tools/marvin/marvin/TestCaseExecuteEngine.py index 06a8d72a00d..3c34c7efdfc 100644 --- a/tools/marvin/marvin/TestCaseExecuteEngine.py +++ b/tools/marvin/marvin/TestCaseExecuteEngine.py @@ -87,8 +87,8 @@ class TestCaseExecuteEngine(object): setattr(test, "config", self.config) setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger)) setattr(test.__class__, "clstestclient", self.testclient) - if hasattr(test, "UserName"): - self.testclient.createNewApiClient(test.UserName, test.DomainName, test.AcctType) + if hasattr(test, "user"): #attribute when test is entirely executed as user + self.testclient.createUserApiClient(test.UserName, test.DomainName, test.AcctType) def run(self): if self.suite: diff --git a/tools/marvin/marvin/cloudstackTestCase.py b/tools/marvin/marvin/cloudstackTestCase.py index 4ec764c58bf..7e557f8e6e6 100644 --- a/tools/marvin/marvin/cloudstackTestCase.py +++ b/tools/marvin/marvin/cloudstackTestCase.py @@ -31,7 +31,7 @@ import cloudstackTestClient # cls.AcctType = self.accounttype # return Wrapped -def UserName(Name, DomainName, AcctType): +def user(Name, DomainName, AcctType): def wrapper(cls): orig_init = cls.__init__ def __init__(self, *args, **kws): diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py index 80ae07da461..2502656a997 100644 --- a/tools/marvin/marvin/cloudstackTestClient.py +++ b/tools/marvin/marvin/cloudstackTestClient.py @@ -58,7 +58,7 @@ class cloudstackTestClient(object): """Generate Random Strings of variable length""" return ''.join(random.choice(chars) for x in range(size)) - def createNewApiClient(self, UserName, DomainName, acctType=0): + def createUserApiClient(self, UserName, DomainName, acctType=0): if not self.isAdminContext(): return self.apiClient @@ -88,7 +88,7 @@ class cloudstackTestClient(object): createAcctCmd = createAccount.createAccountCmd() createAcctCmd.accounttype = acctType createAcctCmd.domainid = domId - createAcctCmd.email = "test-" + self.random_gen() + "@citrix.com" + createAcctCmd.email = "test-" + self.random_gen() + "@cloudstack.org" createAcctCmd.firstname = UserName createAcctCmd.lastname = UserName createAcctCmd.password = mdf_pass @@ -111,10 +111,10 @@ class cloudstackTestClient(object): apiKey = registerUserRes.apikey securityKey = registerUserRes.secretkey - nConnection = cloudstackConnection.cloudConnection(self.connection.mgtSvr, self.connection.port, apiKey, securityKey, self.connection.asyncTimeout, self.connection.logging) - self.connection.close() - self.connection = nConnection - self.apiClient = cloudstackAPIClient.CloudStackAPIClient(self.connection) + newUserConnection = cloudstackConnection.cloudConnection(self.connection.mgtSvr, self.connection.port, apiKey, securityKey, self.connection.asyncTimeout, self.connection.logging) + self.userApiClient = cloudstackAPIClient.CloudStackAPIClient(newUserConnection) + self.userApiClient.connection = newUserConnection + return self.userApiClient def close(self): if self.connection is not None: @@ -136,6 +136,11 @@ class cloudstackTestClient(object): def getApiClient(self): return self.apiClient + + def getUserApiClient(self): + if hasattr(self, "userApiClient"): + return self.userApiClient + return None '''FixME, httplib has issue if more than one thread submitted''' def submitCmdsAndWait(self, cmds, workers=1): diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py index 01fbd6e39b1..c52596e6d43 100644 --- a/tools/marvin/marvin/marvinPlugin.py +++ b/tools/marvin/marvin/marvinPlugin.py @@ -119,6 +119,6 @@ class MarvinPlugin(Plugin): setattr(test, "config", self.config) setattr(test, "debug", partial(testCaseLogger, logger=testcaselogger)) setattr(test, "clstestclient", self.testclient) - if hasattr(test, "UserName"): - self.testclient.createNewApiClient(test.UserName, test.DomainName, test.AcctType) + if hasattr(test, "user"): #when the class-level attr applied. all test runs as 'user' + self.testclient.createUserApiClient(test.UserName, test.DomainName, test.AcctType) From 3ba8dc455f446f695225ee06efa81258067fb236 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Sun, 9 Dec 2012 22:04:27 -0800 Subject: [PATCH 063/145] Smoke Tests: incorrect self reference in setUpClass should be cls.apiClient and not self.apiClient --- test/integration/smoke/test_iso.py | 2 +- tools/marvin/marvin/cloudstackTestClient.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index fc726721c9b..23c5786b37b 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -218,7 +218,7 @@ class TestISO(cloudstackTestCase): cls.services["account"] = cls.account.account.name # Finding the OsTypeId from Ostype ostypes = list_os_types( - self.apiclient, + cls.apiclient, description=self.services["ostype"] ) if not isinstance(ostypes, list): diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py index 2502656a997..cb63179f40f 100644 --- a/tools/marvin/marvin/cloudstackTestClient.py +++ b/tools/marvin/marvin/cloudstackTestClient.py @@ -137,7 +137,13 @@ class cloudstackTestClient(object): def getApiClient(self): return self.apiClient - def getUserApiClient(self): + def getUserApiClient(self, account, domain, type=0): + """ + 0 - user + 1 - admin + 2 - domain admin + """ + self.createUserApiClient(account, domain, type) if hasattr(self, "userApiClient"): return self.userApiClient return None From 7d4e65740b574a7ffd0c3cbaba9d930f2e930951 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Sun, 9 Dec 2012 22:14:02 -0800 Subject: [PATCH 064/145] marvin: assertion check when fetching featured templates --- tools/marvin/marvin/integration/lib/common.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py index de68178d0be..05c6a1ac6bb 100644 --- a/tools/marvin/marvin/integration/lib/common.py +++ b/tools/marvin/marvin/integration/lib/common.py @@ -126,6 +126,7 @@ def get_template(apiclient, zoneid, ostype, services=None): list_templates = apiclient.listTemplates(cmd) + assert len(list_templates) > 0 for template in list_templates: if template.ostypeid == ostypeid: return template From e49b3b27dee9e108d45bb54affdffd2939680104 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Sun, 9 Dec 2012 23:13:24 -0800 Subject: [PATCH 065/145] marvin: storagetype reference only when attr present reference the storagetype only when present. storagetype is reqd only for devcloud style tests --- test/integration/smoke/test_iso.py | 2 +- tools/marvin/marvin/integration/lib/base.py | 3 ++- tools/marvin/marvin/integration/lib/common.py | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py index 23c5786b37b..22d424f86cc 100644 --- a/test/integration/smoke/test_iso.py +++ b/test/integration/smoke/test_iso.py @@ -218,7 +218,7 @@ class TestISO(cloudstackTestCase): cls.services["account"] = cls.account.account.name # Finding the OsTypeId from Ostype ostypes = list_os_types( - cls.apiclient, + cls.api_client, description=self.services["ostype"] ) if not isinstance(ostypes, list): diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py index 044c9108307..149a47c0663 100644 --- a/tools/marvin/marvin/integration/lib/base.py +++ b/tools/marvin/marvin/integration/lib/base.py @@ -1039,7 +1039,8 @@ class ServiceOffering: cmd.displaytext = services["displaytext"] cmd.memory = services["memory"] cmd.name = services["name"] - cmd.storagetype = services["storagetype"] + if hasattr(cmd, "storagetype"): + cmd.storagetype = services["storagetype"] # Service Offering private to that domain if domainid: diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py index 05c6a1ac6bb..cc9e6cb09f0 100644 --- a/tools/marvin/marvin/integration/lib/common.py +++ b/tools/marvin/marvin/integration/lib/common.py @@ -64,6 +64,7 @@ def get_domain(apiclient, services=None): domains = apiclient.listDomains(cmd) if isinstance(domains, list): + assert len(domains) > 0 return domains[0] else: raise Exception("Failed to find specified domain.") @@ -80,6 +81,7 @@ def get_zone(apiclient, services=None): zones = apiclient.listZones(cmd) if isinstance(zones, list): + assert len(zones) > 0 return zones[0] else: raise Exception("Failed to find specified zone.") @@ -98,6 +100,7 @@ def get_pod(apiclient, zoneid, services=None): pods = apiclient.listPods(cmd) if isinstance(pods, list): + assert len(pods) > 0 return pods[0] else: raise Exception("Exception: Failed to find specified pod.") From 238c55fb6e40220cbbf60b241a902cdc7ccf8d37 Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Mon, 10 Dec 2012 13:56:51 +0530 Subject: [PATCH 066/145] CLOUDSTACK-596 : DeployVM command takes a lot of time to return job id Issue happens while deploying VM in advanced zone and 'networkids' parameter is not passed to deployVM command. In this case CS tries to identify a default guest network to be used for deploying VM. This logic is not optimized and latency increases with increase in user accounts and guest networks. Optimized logic for getting default network. Signed-off-by: Koushik Das Signed-off-by: Abhinandan Prateek --- .../com/cloud/network/NetworkManagerImpl.java | 13 +-------- .../src/com/cloud/network/dao/NetworkDao.java | 2 ++ .../com/cloud/network/dao/NetworkDaoImpl.java | 27 +++++++++++++++++-- .../src/com/cloud/vm/UserVmManagerImpl.java | 7 ++--- .../com/cloud/vpc/dao/MockNetworkDaoImpl.java | 9 +++++++ 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index b3fdf32aa7f..3f8b08519ad 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -4540,18 +4540,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag @Override public List listNetworksForAccount(long accountId, long zoneId, Network.GuestType type) { - List accountNetworks = new ArrayList(); - List zoneNetworks = _networksDao.listByZone(zoneId); - - for (NetworkVO network : zoneNetworks) { - if (!isNetworkSystem(network)) { - if (network.getGuestType() == Network.GuestType.Shared || !_networksDao.listBy(accountId, network.getId()).isEmpty()) { - if (type == null || type == network.getGuestType()) { - accountNetworks.add(network); - } - } - } - } + List accountNetworks = _networksDao.listNetworksByAccount(accountId, zoneId, type, false); return accountNetworks; } diff --git a/server/src/com/cloud/network/dao/NetworkDao.java b/server/src/com/cloud/network/dao/NetworkDao.java index a2e37b7b33b..4079955c2e9 100644 --- a/server/src/com/cloud/network/dao/NetworkDao.java +++ b/server/src/com/cloud/network/dao/NetworkDao.java @@ -108,4 +108,6 @@ public interface NetworkDao extends GenericDao { long countVpcNetworks(long vpcId); + List listNetworksByAccount(long accountId, long zoneId, Network.GuestType type, boolean isSystem); + } diff --git a/server/src/com/cloud/network/dao/NetworkDaoImpl.java b/server/src/com/cloud/network/dao/NetworkDaoImpl.java index cbfec895b32..8228393f93f 100644 --- a/server/src/com/cloud/network/dao/NetworkDaoImpl.java +++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java @@ -72,8 +72,8 @@ public class NetworkDaoImpl extends GenericDaoBase implements N final SearchBuilder SourceNATSearch; final GenericSearchBuilder CountByZoneAndURI; final GenericSearchBuilder VpcNetworksCount; - - + final SearchBuilder OfferingAccountNetworkSearch; + ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class); NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class); NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class); @@ -202,6 +202,17 @@ public class NetworkDaoImpl extends GenericDaoBase implements N VpcNetworksCount.select(null, Func.COUNT, VpcNetworksCount.entity().getId()); VpcNetworksCount.done(); + OfferingAccountNetworkSearch = createSearchBuilder(); + OfferingAccountNetworkSearch.select(null, Func.DISTINCT, OfferingAccountNetworkSearch.entity().getId()); + SearchBuilder ntwkOfferingJoin = _ntwkOffDao.createSearchBuilder(); + ntwkOfferingJoin.and("isSystem", ntwkOfferingJoin.entity().isSystemOnly(), Op.EQ); + OfferingAccountNetworkSearch.join("ntwkOfferingSearch", ntwkOfferingJoin, OfferingAccountNetworkSearch.entity().getNetworkOfferingId(), ntwkOfferingJoin.entity().getId(), JoinBuilder.JoinType.LEFT); + SearchBuilder ntwkAccountJoin = _accountsDao.createSearchBuilder(); + ntwkAccountJoin.and("accountId", ntwkAccountJoin.entity().getAccountId(), Op.EQ); + OfferingAccountNetworkSearch.join("ntwkAccountSearch", ntwkAccountJoin, OfferingAccountNetworkSearch.entity().getId(), ntwkAccountJoin.entity().getNetworkId(), JoinBuilder.JoinType.INNER); + OfferingAccountNetworkSearch.and("zoneId", OfferingAccountNetworkSearch.entity().getDataCenterId(), Op.EQ); + OfferingAccountNetworkSearch.and("type", OfferingAccountNetworkSearch.entity().getGuestType(), Op.EQ); + OfferingAccountNetworkSearch.done(); } @Override @@ -551,4 +562,16 @@ public class NetworkDaoImpl extends GenericDaoBase implements N sc.setParameters("vpcId", vpcId); return customSearch(sc, null).get(0); } + + @Override + public List listNetworksByAccount(long accountId, long zoneId, Network.GuestType type, boolean isSystem) { + SearchCriteria sc = OfferingAccountNetworkSearch.create(); + sc.setJoinParameters("ntwkOfferingSearch", "isSystem", isSystem); + sc.setJoinParameters("ntwkAccountSearch", "accountId", accountId); + sc.setParameters("zoneId", zoneId); + sc.setParameters("type", type); + + List networks = search(sc, null); + return networks; + } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 837e3f7d146..eeb1c78a44f 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2262,7 +2262,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) { // get Virtual networks List virtualNetworks = _networkMgr.listNetworksForAccount(owner.getId(), zone.getId(), Network.GuestType.Isolated); - if (virtualNetworks.isEmpty()) { long physicalNetworkId = _networkMgr.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType()); // Validate physical network @@ -2278,7 +2277,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager } else if (virtualNetworks.size() > 1) { throw new InvalidParameterValueException("More than 1 default Isolated networks are found for account " + owner + "; please specify networkIds"); } else { - defaultNetwork = virtualNetworks.get(0); + defaultNetwork = _networkDao.findById(virtualNetworks.get(0).getId()); } } else { throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled); @@ -3701,7 +3700,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) { // get Virtual networks List virtualNetworks = _networkMgr.listNetworksForAccount(newAccount.getId(), zone.getId(), Network.GuestType.Isolated); - if (virtualNetworks.isEmpty()) { long physicalNetworkId = _networkMgr.findPhysicalNetworkId(zone.getId(), requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType()); // Validate physical network @@ -3709,7 +3707,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (physicalNetwork == null) { throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags()); } - s_logger.debug("Creating network for account " + newAccount + " from the network offering id=" + requiredOfferings.get(0).getId() + " as a part of deployVM process"); Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(), @@ -3720,7 +3717,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager throw new InvalidParameterValueException("More than 1 default Isolated networks are found " + "for account " + newAccount + "; please specify networkIds"); } else { - defaultNetwork = virtualNetworks.get(0); + defaultNetwork = _networkDao.findById(virtualNetworks.get(0).getId()); } } else { throw new InvalidParameterValueException("Required network offering id=" + requiredOfferings.get(0).getId() + " is not in " + NetworkOffering.State.Enabled); diff --git a/server/test/com/cloud/vpc/dao/MockNetworkDaoImpl.java b/server/test/com/cloud/vpc/dao/MockNetworkDaoImpl.java index 2a675b3a217..509d9c72f73 100644 --- a/server/test/com/cloud/vpc/dao/MockNetworkDaoImpl.java +++ b/server/test/com/cloud/vpc/dao/MockNetworkDaoImpl.java @@ -342,4 +342,13 @@ public class MockNetworkDaoImpl extends GenericDaoBase implemen return 0; } + /* (non-Javadoc) + * @see com.cloud.network.dao.NetworkDao#listNetworksByAccount(long, long, com.cloud.network.Network.GuestType, boolean) + */ + @Override + public List listNetworksByAccount(long accountId, long zoneId, GuestType type, boolean isSystem) { + // TODO Auto-generated method stub + return null; + } + } From 540524267495494e0a62bb95b57e0b88f5737bac Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Thu, 6 Dec 2012 13:50:36 +0530 Subject: [PATCH 067/145] master - Bug ID: CLOUDSTACK-369. Unable to add XenServer 6.1 to cloudstack. Created a new resource for XS 6.1. Also introduced a guest map for the list of supported os. Signed-off-by: Devdeep Singh Signed-off-by: Abhinandan Prateek --- .../xen/discoverer/XcpServerDiscoverer.java | 27 ++-- .../hypervisor/xen/resource/CitrixHelper.java | 143 ++++++++++++++++++ .../xen/resource/XenServer610Resource.java | 58 +++++++ 3 files changed, 215 insertions(+), 13 deletions(-) create mode 100644 plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java index 9faceaae3bd..48f9681d48c 100755 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java @@ -70,6 +70,7 @@ import com.cloud.hypervisor.xen.resource.XenServer56Resource; import com.cloud.hypervisor.xen.resource.XenServer56SP2Resource; import com.cloud.hypervisor.xen.resource.XenServer600Resource; import com.cloud.hypervisor.xen.resource.XenServer602Resource; +import com.cloud.hypervisor.xen.resource.XenServer610Resource; import com.cloud.hypervisor.xen.resource.XenServerConnectionPool; import com.cloud.resource.Discoverer; import com.cloud.resource.DiscovererBase; @@ -436,9 +437,9 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.2")) return new XenServer602Resource(); - - if (prodBrand.equals("XenServer") && prodVersion.startsWith("6.0.9")) - return new XenServer602Resource(); + + if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0")) + return new XenServer610Resource(); if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.100")) { String prodVersionTextShort = record.softwareVersion.get("product_version_text_short").trim(); @@ -448,18 +449,18 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L return new XenServer56FP1Resource(); } } - + if (prodBrand.equals("XCP_Kronos")) { return new XcpOssResource(); } - - String msg = "Only support XCP 1.0.0, 1.1.0, 1.5 beta; XenServer 5.6, XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.0.9 but this one is " + prodBrand + " " + prodVersion; - _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg); - s_logger.debug(msg); - throw new RuntimeException(msg); + + String msg = "Only support XCP 1.0.0, 1.1.0, 1.5 beta; XenServer 5.6, XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion; + _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId, podId, msg, msg); + s_logger.debug(msg); + throw new RuntimeException(msg); } - + protected void serverConfig() { String value = _params.get(Config.XenSetupMultipath.key()); _setupMultipath = Boolean.parseBoolean(value); @@ -589,8 +590,8 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L resource = XenServer600Resource.class.getName(); } else if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.2")) { resource = XenServer602Resource.class.getName(); - } else if (prodBrand.equals("XenServer") && prodVersion.startsWith("6.0.9")) { - resource = XenServer602Resource.class.getName(); + } else if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0")) { + resource = XenServer610Resource.class.getName(); } else if(prodBrand.equals("XenServer") && prodVersion.equals("5.6.100")) { String prodVersionTextShort = details.get("product_version_text_short").trim(); if("5.6 SP2".equals(prodVersionTextShort)) { @@ -603,7 +604,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L } if( resource == null ){ - String msg = "Only support XCP 1.0.0, 1.1.0, 1.5 beta; XenServer 5.6, 5.6 FP1, 5.6 SP2 and Xenserver 6.0 , 6.0.2, 6.0.9 but this one is " + prodBrand + " " + prodVersion; + String msg = "Only support XCP 1.0.0, 1.1.0, 1.5 beta; XenServer 5.6, 5.6 FP1, 5.6 SP2 and Xenserver 6.0 , 6.0.2, 6.1.0 but this one is " + prodBrand + " " + prodVersion; s_logger.debug(msg); throw new RuntimeException(msg); } diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java index bbb1ecfdb95..1b8496ff287 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixHelper.java @@ -33,6 +33,7 @@ public class CitrixHelper { private static final HashMap _xenServer56FP2GuestOsMap = new HashMap(70); private static final HashMap _xenServer600GuestOsMap = new HashMap(70); private static final HashMap _xenServer602GuestOsMap = new HashMap(70); + private static final HashMap _xenServer610GuestOsMap = new HashMap(70); private static final ArrayList _guestOsList = new ArrayList(70); @@ -554,6 +555,134 @@ public class CitrixHelper { _xenServer602GuestOsMap.put("Other PV (64-bit)", "CentOS 5 (64-bit)"); } + static { + _xenServer610GuestOsMap.put("CentOS 4.5 (32-bit)", "CentOS 4.5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 4.6 (32-bit)", "CentOS 4.6 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 4.7 (32-bit)", "CentOS 4.7 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 4.8 (32-bit)", "CentOS 4.8 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.0 (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.0 (64-bit)", "CentOS 5 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.1 (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.1 (64-bit)", "CentOS 5 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.2 (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.2 (64-bit)", "CentOS 5 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.3 (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.3 (64-bit)", "CentOS 5 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.4 (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.4 (64-bit)", "CentOS 5 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.5 (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.5 (64-bit)", "CentOS 5 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.6 (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.6 (64-bit)", "CentOS 5 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.7 (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 5.7 (64-bit)", "CentOS 5 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 6.0 (32-bit)", "CentOS 6.0 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 6.0 (64-bit)", "CentOS 6.0 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 6.1 (32-bit)", "CentOS 6.1 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 6.1 (64-bit)", "CentOS 6.1 (64-bit)"); + _xenServer610GuestOsMap.put("CentOS 6.2 (32-bit)", "CentOS 6.2 (32-bit)"); + _xenServer610GuestOsMap.put("CentOS 6.2 (64-bit)", "CentOS 6.2 (64-bit)"); + _xenServer610GuestOsMap.put("Debian GNU/Linux 5.0 (32-bit)", "Debian Lenny 5.0 (32-bit)"); + _xenServer610GuestOsMap.put("Debian GNU/Linux 6(32-bit)", "Debian Squeeze 6.0 (32-bit)"); + _xenServer610GuestOsMap.put("Debian GNU/Linux 6(64-bit)", "Debian Squeeze 6.0 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.0 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.0 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.1 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.1 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.2 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.2 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.3 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.3 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.4 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.4 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.5 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.5 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.6 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.6 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.7 (32-bit)", "Oracle Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 5.7 (64-bit)", "Oracle Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 6.0 (32-bit)", "Oracle Enterprise Linux 6.0 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 6.0 (64-bit)", "Oracle Enterprise Linux 6.0 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 6.1 (32-bit)", "Oracle Enterprise Linux 6.1 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 6.1 (64-bit)", "Oracle Enterprise Linux 6.1 (64-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 6.2 (32-bit)", "Oracle Enterprise Linux 6.2 (32-bit)"); + _xenServer610GuestOsMap.put("Oracle Enterprise Linux 6.2 (64-bit)", "Oracle Enterprise Linux 6.2 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 4.5 (32-bit)", "Red Hat Enterprise Linux 4.5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 4.6 (32-bit)", "Red Hat Enterprise Linux 4.6 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 4.7 (32-bit)", "Red Hat Enterprise Linux 4.7 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 4.8 (32-bit)", "Red Hat Enterprise Linux 4.8 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.0 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.0 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.1 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.1 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.2 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.2 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.3 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.3 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.4 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.4 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.5 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.5 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.6 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.6 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.7 (32-bit)", "Red Hat Enterprise Linux 5 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 5.7 (64-bit)", "Red Hat Enterprise Linux 5 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 6.0 (32-bit)", "Red Hat Enterprise Linux 6.0 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 6.0 (64-bit)", "Red Hat Enterprise Linux 6.0 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 6.1 (32-bit)", "Red Hat Enterprise Linux 6.1 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 6.1 (64-bit)", "Red Hat Enterprise Linux 6.1 (64-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 6.2 (32-bit)", "Red Hat Enterprise Linux 6.2 (32-bit)"); + _xenServer610GuestOsMap.put("Red Hat Enterprise Linux 6.2 (64-bit)", "Red Hat Enterprise Linux 6.2 (64-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 9 SP4 (32-bit)", "SUSE Linux Enterprise Server 10 SP1 (32-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 10 SP1 (32-bit)", "SUSE Linux Enterprise Server 10 SP1 (32-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 10 SP1 (64-bit)", "SUSE Linux Enterprise Server 10 SP1 (64-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 10 SP2 (32-bit)", "SUSE Linux Enterprise Server 10 SP2 (32-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 10 SP2 (64-bit)", "SUSE Linux Enterprise Server 10 SP2 (64-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 10 SP3 (32-bit)", "SUSE Linux Enterprise Server 10 SP3 (32-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 10 SP3 (64-bit)", "SUSE Linux Enterprise Server 10 SP3 (64-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 10 SP4 (32-bit)", "SUSE Linux Enterprise Server 10 SP4 (32-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 10 SP4 (64-bit)", "SUSE Linux Enterprise Server 10 SP4 (64-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 11 (32-bit)", "SUSE Linux Enterprise Server 11 (32-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 11 (64-bit)", "SUSE Linux Enterprise Server 11 (64-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 11 SP1 (32-bit)", "SUSE Linux Enterprise Server 11 SP1 (32-bit)"); + _xenServer610GuestOsMap.put("SUSE Linux Enterprise Server 11 SP1 (64-bit)", "SUSE Linux Enterprise Server 11 SP1 (64-bit)"); + _xenServer610GuestOsMap.put("Windows 7 (32-bit)", "Windows 7 (32-bit)"); + _xenServer610GuestOsMap.put("Windows 7 (64-bit)", "Windows 7 (64-bit)"); + _xenServer610GuestOsMap.put("Windows 8 (32-bit)", "Windows 8 (32-bit) (experimental)"); + _xenServer610GuestOsMap.put("Windows 8 (64-bit)", "Windows 7 (64-bit) (experimental)"); + _xenServer610GuestOsMap.put("Windows Server 2003 (32-bit)", "Windows Server 2003 (32-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2003 (64-bit)", "Windows Server 2003 (64-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2003 PAE (32-bit)", "Windows Server 2003 PAE (32-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2003 Enterprise Edition(32-bit)", "Windows Server 2003 (32-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2003 Enterprise Edition(64-bit)", "Windows Server 2003 (64-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2003 DataCenter Edition(32-bit)", "Windows Server 2003 (32-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2003 DataCenter Edition(64-bit)", "Windows Server 2003 (64-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2003 Standard Edition(32-bit)", "Windows Server 2003 (32-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2003 Standard Edition(64-bit)", "Windows Server 2003 (64-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2008 (32-bit)", "Windows Server 2008 (32-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2008 (64-bit)", "Windows Server 2008 (64-bit)"); + _xenServer610GuestOsMap.put("Windows Server 2008 R2 (64-bit)", "Windows Server 2008 R2 (64-bit)"); + _xenServer610GuestOsMap.put("Windows Server 8 (64-bit)", "Windows Server 8 (64-bit) (experimental)"); + _xenServer610GuestOsMap.put("Windows Vista (32-bit)", "Windows Vista (32-bit)"); + _xenServer610GuestOsMap.put("Windows XP SP3 (32-bit)", "Windows XP SP3 (32-bit)"); + _xenServer610GuestOsMap.put("Ubuntu 10.04 (32-bit)", "Ubuntu Lucid Lynx 10.04 (32-bit)"); + _xenServer610GuestOsMap.put("Ubuntu 10.04 (64-bit)", "Ubuntu Lucid Lynx 10.04 (64-bit)"); + _xenServer610GuestOsMap.put("Ubuntu 10.10 (32-bit)", "Ubuntu Maverick Meerkat 10.10 (32-bit) (experimental)"); + _xenServer610GuestOsMap.put("Ubuntu 10.10 (64-bit)", "Ubuntu Maverick Meerkat 10.10 (64-bit) (experimental)"); + _xenServer610GuestOsMap.put("Other Linux (32-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other Linux (64-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other (32-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other (64-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other CentOS (32-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other CentOS (64-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other Ubuntu (32-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other Ubuntu (64-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other SUSE Linux(32-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other SUSE Linux(64-bit)", "Other install media"); + _xenServer610GuestOsMap.put("Other PV (32-bit)", "CentOS 5 (32-bit)"); + _xenServer610GuestOsMap.put("Other PV (64-bit)", "CentOS 5 (64-bit)"); + } + public static String getXcpGuestOsType(String stdType) { String guestOS = _xcp100GuestOsMap.get(stdType); if (guestOS == null) { @@ -636,4 +765,18 @@ public class CitrixHelper { } return guestOS; } + + public static String getXenServer610GuestOsType(String stdType, boolean bootFromCD) { + String guestOS = _xenServer610GuestOsMap.get(stdType); + if (guestOS == null) { + if (!bootFromCD) { + s_logger.debug("Can't find the guest os: " + stdType + " mapping into XenServer 6.1.0 guestOS type, start it as HVM guest"); + guestOS = "Other install media"; + } else { + String msg = "XenServer 6.1.0 DOES NOT support Guest OS type " + stdType; + s_logger.warn(msg); + } + } + return guestOS; + } } diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java new file mode 100644 index 00000000000..17ad3e62383 --- /dev/null +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServer610Resource.java @@ -0,0 +1,58 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 com.cloud.hypervisor.xen.resource; + + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.ejb.Local; + +import org.apache.log4j.Logger; + +import com.cloud.resource.ServerResource; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; + + +@Local(value=ServerResource.class) +public class XenServer610Resource extends XenServer56FP1Resource { + private static final Logger s_logger = Logger.getLogger(XenServer610Resource.class); + + public XenServer610Resource() { + super(); + } + + @Override + protected String getGuestOsType(String stdType, boolean bootFromCD) { + return CitrixHelper.getXenServer602GuestOsType(stdType, bootFromCD); + } + + @Override + protected List getPatchFiles() { + List files = new ArrayList(); + String patch = "scripts/vm/hypervisor/xenserver/xenserver60/patch"; + String patchfilePath = Script.findScript("" , patch); + if (patchfilePath == null) { + throw new CloudRuntimeException("Unable to find patch file " + patch); + } + File file = new File(patchfilePath); + files.add(file); + return files; + } +} From 199806c1be28c9706090d55c63ffb814c3cb80be Mon Sep 17 00:00:00 2001 From: Kishan Kavala Date: Mon, 10 Dec 2012 19:37:57 +0530 Subject: [PATCH 068/145] CLOUDSTACK-560 : Add default zone column to account table in cloud_usage table in fresh install and upgrade --- setup/db/create-schema-premium.sql | 1 + setup/db/db/schema-302to40.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/setup/db/create-schema-premium.sql b/setup/db/create-schema-premium.sql index d84718ee56a..2f86c0b9ab5 100644 --- a/setup/db/create-schema-premium.sql +++ b/setup/db/create-schema-premium.sql @@ -136,6 +136,7 @@ CREATE TABLE `cloud_usage`.`account` ( `removed` datetime COMMENT 'date removed', `cleanup_needed` tinyint(1) NOT NULL default '0', `network_domain` varchar(100) COMMENT 'Network domain name of the Vms of the account', + `default_zone_id` bigint unsigned, CONSTRAINT `uc_account__uuid` UNIQUE (`uuid`), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/setup/db/db/schema-302to40.sql b/setup/db/db/schema-302to40.sql index 0c4efa33025..a947ac1bee6 100644 --- a/setup/db/db/schema-302to40.sql +++ b/setup/db/db/schema-302to40.sql @@ -477,3 +477,4 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'manag UPDATE `cloud`.`configuration` set description ='Uuid of the service offering used by console proxy; if NULL - system offering will be used' where name ='consoleproxy.service.offering'; UPDATE `cloud`.`user` SET PASSWORD=RAND() WHERE id=1; +ALTER TABLE `cloud_usage`.`account` ADD COLUMN `default_zone_id` bigint unsigned; From cb35d83b85dcd9a210080d1ce2b27dad55d30511 Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Tue, 11 Dec 2012 04:22:09 +0530 Subject: [PATCH 069/145] CLOUDSTACK-604:When editting pod/cluster in UI, there's no save button: A generic issue with the widget where the content from another tab to the adjacent one gets appended :resolved by making the detailsView widget change --- ui/scripts/ui/widgets/detailView.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index 60fbfb9c7e2..4b4fbd5a477 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -942,6 +942,8 @@ }).appendTo($tabContent); } + $detailView.find('.detail-group:hidden').html(''); + if (tabs.listView) { return $('
').listView({ context: args.context, From 432ea9c7d4aff3f7e682f2951f49ed3e95778d9f Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Tue, 11 Dec 2012 23:06:13 +0530 Subject: [PATCH 070/145] CLOUDSTACK-265: provide option to turn-off automatic public IP association for each VM when using EIP service. - introduces Capability in the network offering, which decides when EIP service is enabled, by defualt public IP should be assigned to the VM or not - default network offering with EIP/ELB service will still work with old EIP semantics, i.e) assign a public IP to each VM on start --- api/src/com/cloud/network/Network.java | 11 +- .../com/cloud/offering/NetworkOffering.java | 2 + .../ConfigurationManagerImpl.java | 142 ++++++------------ .../cloud/network/rules/RulesManagerImpl.java | 40 ++--- .../cloud/offerings/NetworkOfferingVO.java | 28 ++-- .../cloud/server/ConfigurationServerImpl.java | 49 ++---- .../com/cloud/upgrade/dao/Upgrade40to41.java | 38 +++++ .../src/com/cloud/vm/UserVmManagerImpl.java | 140 +++-------------- setup/db/create-schema.sql | 1 + setup/db/db/schema-40to41.sql | 23 +++ 10 files changed, 186 insertions(+), 288 deletions(-) create mode 100644 setup/db/db/schema-40to41.sql diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index d38f7401682..188ef92e57b 100644 --- a/api/src/com/cloud/network/Network.java +++ b/api/src/com/cloud/network/Network.java @@ -16,11 +16,6 @@ // under the License. package com.cloud.network; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - import com.cloud.acl.ControlledEntity; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; @@ -28,6 +23,11 @@ import com.cloud.network.Networks.TrafficType; import com.cloud.utils.fsm.FiniteState; import com.cloud.utils.fsm.StateMachine; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + /** * owned by an account. */ @@ -168,6 +168,7 @@ public interface Network extends ControlledEntity { public static final Capability AllowDnsSuffixModification = new Capability("AllowDnsSuffixModification"); public static final Capability RedundantRouter = new Capability("RedundantRouter"); public static final Capability ElasticIp = new Capability("ElasticIp"); + public static final Capability AssociatePublicIP = new Capability("AssociatePublicIP"); public static final Capability ElasticLb = new Capability("ElasticLb"); public static final Capability AutoScaleCounters = new Capability("AutoScaleCounters"); diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java index a514ccf17f4..29828ab6172 100644 --- a/api/src/com/cloud/offering/NetworkOffering.java +++ b/api/src/com/cloud/offering/NetworkOffering.java @@ -105,6 +105,8 @@ public interface NetworkOffering { boolean getElasticIp(); + boolean getAssociatePublicIP(); + boolean getElasticLb(); boolean getSpecifyIpRanges(); diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index ef940e89f61..33baaf12ca4 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -16,110 +16,35 @@ // under the License. package com.cloud.configuration; -import java.net.URI; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import javax.ejb.Local; -import javax.naming.ConfigurationException; -import javax.naming.Context; -import javax.naming.NamingException; -import javax.naming.directory.DirContext; -import javax.naming.directory.InitialDirContext; - -import org.apache.log4j.Logger; - import com.cloud.acl.SecurityChecker; import com.cloud.alert.AlertManager; import com.cloud.api.ApiConstants.LDAPParams; import com.cloud.api.ApiDBUtils; -import com.cloud.api.commands.CreateDiskOfferingCmd; -import com.cloud.api.commands.CreateNetworkOfferingCmd; -import com.cloud.api.commands.CreateServiceOfferingCmd; -import com.cloud.api.commands.CreateVlanIpRangeCmd; -import com.cloud.api.commands.CreateZoneCmd; -import com.cloud.api.commands.DeleteDiskOfferingCmd; -import com.cloud.api.commands.DeleteNetworkOfferingCmd; -import com.cloud.api.commands.DeletePodCmd; -import com.cloud.api.commands.DeleteServiceOfferingCmd; -import com.cloud.api.commands.DeleteVlanIpRangeCmd; -import com.cloud.api.commands.DeleteZoneCmd; -import com.cloud.api.commands.LDAPConfigCmd; -import com.cloud.api.commands.LDAPRemoveCmd; -import com.cloud.api.commands.ListNetworkOfferingsCmd; -import com.cloud.api.commands.UpdateCfgCmd; -import com.cloud.api.commands.UpdateDiskOfferingCmd; -import com.cloud.api.commands.UpdateNetworkOfferingCmd; -import com.cloud.api.commands.UpdatePodCmd; -import com.cloud.api.commands.UpdateServiceOfferingCmd; -import com.cloud.api.commands.UpdateZoneCmd; +import com.cloud.api.commands.*; import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.Resource.ResourceType; import com.cloud.configuration.dao.ConfigurationDao; -import com.cloud.dc.AccountVlanMapVO; -import com.cloud.dc.ClusterVO; -import com.cloud.dc.DataCenter; +import com.cloud.dc.*; import com.cloud.dc.DataCenter.NetworkType; -import com.cloud.dc.DataCenterIpAddressVO; -import com.cloud.dc.DataCenterLinkLocalIpAddressVO; -import com.cloud.dc.DataCenterVO; -import com.cloud.dc.HostPodVO; -import com.cloud.dc.Pod; -import com.cloud.dc.PodVlanMapVO; -import com.cloud.dc.Vlan; import com.cloud.dc.Vlan.VlanType; -import com.cloud.dc.VlanVO; -import com.cloud.dc.dao.AccountVlanMapDao; -import com.cloud.dc.dao.ClusterDao; -import com.cloud.dc.dao.DataCenterDao; -import com.cloud.dc.dao.DataCenterIpAddressDao; -import com.cloud.dc.dao.DataCenterLinkLocalIpAddressDaoImpl; -import com.cloud.dc.dao.HostPodDao; -import com.cloud.dc.dao.PodVlanMapDao; -import com.cloud.dc.dao.VlanDao; +import com.cloud.dc.dao.*; import com.cloud.deploy.DataCenterDeployment; import com.cloud.domain.Domain; import com.cloud.domain.DomainVO; import com.cloud.domain.dao.DomainDao; import com.cloud.event.ActionEvent; import com.cloud.event.EventTypes; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.PermissionDeniedException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.*; import com.cloud.host.HostVO; import com.cloud.hypervisor.Hypervisor.HypervisorType; -import com.cloud.network.IPAddressVO; -import com.cloud.network.Network; +import com.cloud.network.*; import com.cloud.network.Network.Capability; import com.cloud.network.Network.GuestType; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; -import com.cloud.network.NetworkManager; -import com.cloud.network.NetworkVO; import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PhysicalNetwork; -import com.cloud.network.PhysicalNetworkVO; -import com.cloud.network.dao.FirewallRulesDao; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao; -import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; +import com.cloud.network.dao.*; import com.cloud.network.vpc.VpcManager; import com.cloud.offering.DiskOffering; import com.cloud.offering.NetworkOffering; @@ -142,12 +67,7 @@ import com.cloud.storage.dao.SwiftDao; import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.swift.SwiftManager; import com.cloud.test.IPRangeConfig; -import com.cloud.user.Account; -import com.cloud.user.AccountManager; -import com.cloud.user.AccountVO; -import com.cloud.user.ResourceLimitService; -import com.cloud.user.User; -import com.cloud.user.UserContext; +import com.cloud.user.*; import com.cloud.user.dao.AccountDao; import com.cloud.utils.NumbersUtil; import com.cloud.utils.StringUtils; @@ -163,8 +83,20 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; import com.cloud.vm.VirtualMachine; import com.cloud.vm.dao.NicDao; - import edu.emory.mathcs.backport.java.util.Arrays; +import org.apache.log4j.Logger; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; +import javax.naming.Context; +import javax.naming.NamingException; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import java.net.URI; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; @Local(value = { ConfigurationManager.class, ConfigurationService.class }) public class ConfigurationManagerImpl implements ConfigurationManager, ConfigurationService { @@ -3138,20 +3070,33 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura void validateStaticNatServiceCapablities(Map staticNatServiceCapabilityMap) { if (staticNatServiceCapabilityMap != null && !staticNatServiceCapabilityMap.isEmpty()) { - if (staticNatServiceCapabilityMap.keySet().size() > 1) { - throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " capabilitiy can be sepcified for static nat service"); + if (staticNatServiceCapabilityMap.keySet().size() > 2) { + throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " and " + Capability.AssociatePublicIP.getName() + " capabilitiy can be sepcified for static nat service"); } - + boolean eipEnabled = false; + boolean eipDisabled = false; + boolean associatePublicIP = true; for (Capability capability : staticNatServiceCapabilityMap.keySet()) { String value = staticNatServiceCapabilityMap.get(capability); if (capability == Capability.ElasticIp) { - boolean enabled = value.contains("true"); - boolean disabled = value.contains("false"); - if (!enabled && !disabled) { + eipEnabled = value.contains("true"); + eipDisabled = value.contains("false"); + if (!eipEnabled && !eipDisabled) { throw new InvalidParameterValueException("Unknown specified value for " + Capability.ElasticIp.getName()); } + } else if (capability == Capability.AssociatePublicIP) { + if (value.contains("true")) { + associatePublicIP = true; + } else if (value.contains("false")) { + associatePublicIP = false; + } else { + throw new InvalidParameterValueException("Unknown specified value for " + Capability.AssociatePublicIP.getName()); + } } else { - throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " capabilitiy can be sepcified for static nat service"); + throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " and " + Capability.AssociatePublicIP.getName() + " capabilitiy can be sepcified for static nat service"); + } + if (eipDisabled && associatePublicIP) { + throw new InvalidParameterValueException("Capability " + Capability.AssociatePublicIP.getName() + " can only be set when capability " + Capability.ElasticIp.getName() + " is true"); } } } @@ -3205,6 +3150,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura boolean sharedSourceNat = false; boolean redundantRouter = false; boolean elasticIp = false; + boolean associatePublicIp = false; if (serviceCapabilityMap != null && !serviceCapabilityMap.isEmpty()) { Map lbServiceCapabilityMap = serviceCapabilityMap.get(Service.Lb); @@ -3245,13 +3191,17 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura String param = staticNatServiceCapabilityMap.get(Capability.ElasticIp); if (param != null) { elasticIp = param.contains("true"); + String associatePublicIP = staticNatServiceCapabilityMap.get(Capability.AssociatePublicIP); + if (associatePublicIP != null) { + associatePublicIp = associatePublicIP.contains("true"); + } } } } NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, networkRate, multicastRate, isDefault, availability, tags, type, conserveMode, dedicatedLb, - sharedSourceNat, redundantRouter, elasticIp, elasticLb, specifyIpRanges); + sharedSourceNat, redundantRouter, elasticIp, elasticLb, associatePublicIp, specifyIpRanges); if (serviceOfferingId != null) { offering.setServiceOfferingId(serviceOfferingId); diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java index a4e0722c0b2..02d186d9b3b 100755 --- a/server/src/com/cloud/network/rules/RulesManagerImpl.java +++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java @@ -16,17 +16,6 @@ // under the License. package com.cloud.network.rules; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ejb.Local; -import javax.naming.ConfigurationException; - -import org.apache.log4j.Logger; - import com.cloud.api.commands.ListPortForwardingRulesCmd; import com.cloud.configuration.ConfigurationManager; import com.cloud.domain.dao.DomainDao; @@ -61,18 +50,12 @@ import com.cloud.user.AccountManager; import com.cloud.user.DomainManager; import com.cloud.user.UserContext; import com.cloud.uservm.UserVm; -import com.cloud.utils.IdentityProxy; import com.cloud.utils.Pair; import com.cloud.utils.Ternary; import com.cloud.utils.component.Inject; import com.cloud.utils.component.Manager; -import com.cloud.utils.db.DB; -import com.cloud.utils.db.Filter; -import com.cloud.utils.db.JoinBuilder; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.*; import com.cloud.utils.db.SearchCriteria.Op; -import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.Ip; import com.cloud.vm.Nic; @@ -81,6 +64,11 @@ import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.Type; import com.cloud.vm.dao.NicDao; import com.cloud.vm.dao.UserVmDao; +import org.apache.log4j.Logger; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; +import java.util.*; @Local(value = { RulesManager.class, RulesService.class }) public class RulesManagerImpl implements RulesManager, RulesService, Manager { @@ -1185,11 +1173,12 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { Network guestNetwork = _networkMgr.getNetwork(ipAddress.getAssociatedWithNetworkId()); NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId()); if (offering.getElasticIp()) { - getSystemIpAndEnableStaticNatForVm(_vmDao.findById(vmId), true); - return true; - } else { - return disableStaticNat(ipId, caller, ctx.getCallerUserId(), false); + if (offering.getAssociatePublicIP()) { + getSystemIpAndEnableStaticNatForVm(_vmDao.findById(vmId), true); + return true; + } } + return disableStaticNat(ipId, caller, ctx.getCallerUserId(), false); } @Override @@ -1375,7 +1364,11 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { Network guestNetwork = _networkMgr.getNetwork(nic.getNetworkId()); NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId()); if (offering.getElasticIp()) { - + boolean isSystemVM = (vm.getType() == Type.ConsoleProxy || vm.getType() == Type.SecondaryStorageVm); + // for user VM's associate public IP only if offering is marked to associate a public IP by default on start of VM + if (!isSystemVM && !offering.getAssociatePublicIP()) { + continue; + } // check if there is already static nat enabled if (_ipAddressDao.findByAssociatedVmId(vm.getId()) != null && !getNewIp) { s_logger.debug("Vm " + vm + " already has ip associated with it in guest network " + guestNetwork); @@ -1390,7 +1383,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager { s_logger.debug("Allocated system ip " + ip + ", now enabling static nat on it for vm " + vm); - boolean isSystemVM = (vm.getType() == Type.ConsoleProxy || vm.getType() == Type.SecondaryStorageVm); try { success = enableStaticNat(ip.getId(), vm.getId(), guestNetwork.getId(), isSystemVM); } catch (NetworkRuleConflictException ex) { diff --git a/server/src/com/cloud/offerings/NetworkOfferingVO.java b/server/src/com/cloud/offerings/NetworkOfferingVO.java index 77407560c7e..2570b70f630 100755 --- a/server/src/com/cloud/offerings/NetworkOfferingVO.java +++ b/server/src/com/cloud/offerings/NetworkOfferingVO.java @@ -16,24 +16,16 @@ // under the License. package com.cloud.offerings; -import java.util.Date; -import java.util.UUID; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - import com.cloud.api.Identity; import com.cloud.network.Network; import com.cloud.network.Networks.TrafficType; import com.cloud.offering.NetworkOffering; import com.cloud.utils.db.GenericDao; +import javax.persistence.*; +import java.util.Date; +import java.util.UUID; + @Entity @Table(name = "network_offerings") public class NetworkOfferingVO implements NetworkOffering, Identity { @@ -122,6 +114,9 @@ public class NetworkOfferingVO implements NetworkOffering, Identity { @Column(name = "elastic_lb_service") boolean elasticLb; + @Column(name = "eip_associate_public_ip") + boolean eipAssociatePublicIp; + @Override public String getDisplayText() { return displayText; @@ -282,18 +277,20 @@ public class NetworkOfferingVO implements NetworkOffering, Identity { this.redundantRouter = false; this.elasticIp = false; this.elasticLb = false; + this.eipAssociatePublicIp = true; this.specifyIpRanges = specifyIpRanges; } public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault, Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean dedicatedLb, boolean sharedSourceNat, boolean redundantRouter, boolean elasticIp, boolean elasticLb, - boolean specifyIpRanges) { + boolean associatePublicIP, boolean specifyIpRanges) { this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges); this.dedicatedLB = dedicatedLb; this.sharedSourceNat = sharedSourceNat; this.redundantRouter = redundantRouter; this.elasticIp = elasticIp; this.elasticLb = elasticLb; + this.eipAssociatePublicIp = associatePublicIP; } public NetworkOfferingVO() { @@ -355,6 +352,11 @@ public class NetworkOfferingVO implements NetworkOffering, Identity { return elasticIp; } + @Override + public boolean getAssociatePublicIP() { + return eipAssociatePublicIp; + } + @Override public boolean getElasticLb() { return elasticLb; diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java index d2f0bb01a3e..c0c29ed8eb8 100755 --- a/server/src/com/cloud/server/ConfigurationServerImpl.java +++ b/server/src/com/cloud/server/ConfigurationServerImpl.java @@ -16,33 +16,6 @@ // under the License. package com.cloud.server; -import java.io.DataInputStream; -import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.security.NoSuchAlgorithmException; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.UUID; -import java.util.regex.Pattern; - -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; - -import org.apache.commons.codec.binary.Base64; -import org.apache.log4j.Logger; - import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationVO; import com.cloud.configuration.Resource; @@ -72,11 +45,7 @@ import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; import com.cloud.network.dao.NetworkDao; -import com.cloud.network.guru.ControlNetworkGuru; -import com.cloud.network.guru.DirectPodBasedNetworkGuru; -import com.cloud.network.guru.PodBasedNetworkGuru; -import com.cloud.network.guru.PublicNetworkGuru; -import com.cloud.network.guru.StorageNetworkGuru; +import com.cloud.network.guru.*; import com.cloud.offering.NetworkOffering; import com.cloud.offering.NetworkOffering.Availability; import com.cloud.offerings.NetworkOfferingServiceMapVO; @@ -102,6 +71,20 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; import com.cloud.utils.script.Script; import com.cloud.uuididentity.dao.IdentityDao; +import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; + +import javax.crypto.KeyGenerator; +import javax.crypto.SecretKey; +import java.io.*; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.security.NoSuchAlgorithmException; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.*; +import java.util.regex.Pattern; public class ConfigurationServerImpl implements ConfigurationServer { public static final Logger s_logger = Logger.getLogger(ConfigurationServerImpl.class.getName()); @@ -988,7 +971,7 @@ public class ConfigurationServerImpl implements ConfigurationServer { "Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, false, true, null, null, true, Availability.Optional, - null, Network.GuestType.Shared, true, false, false, false, true, true, true); + null, Network.GuestType.Shared, true, false, false, false, true, true, true, true); defaultNetscalerNetworkOffering.setState(NetworkOffering.State.Enabled); defaultNetscalerNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetscalerNetworkOffering); diff --git a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java index 5067f39d011..393aefd744c 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java @@ -17,8 +17,13 @@ package com.cloud.upgrade.dao; +import com.cloud.utils.exception.CloudRuntimeException; + import java.io.File; import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; /** * @author htrippaers @@ -70,6 +75,7 @@ public class Upgrade40to41 extends Upgrade30xBase implements DbUpgrade { */ @Override public void performDataMigration(Connection conn) { + upgradeEIPNetworkOfferings(conn); } /* (non-Javadoc) @@ -80,4 +86,36 @@ public class Upgrade40to41 extends Upgrade30xBase implements DbUpgrade { return new File[0]; } + private void upgradeEIPNetworkOfferings(Connection conn) { + PreparedStatement pstmt = null; + ResultSet rs = null; + + try { + pstmt = conn.prepareStatement("select id, elastic_ip_service from `cloud`.`network_offerings` where traffic_type='Guest'"); + rs = pstmt.executeQuery(); + while (rs.next()) { + long id = rs.getLong(1); + // check if elastic IP service is enabled for network offering + if (rs.getLong(2) != 0) { + //update network offering with eip_associate_public_ip set to true + pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set eip_associate_public_ip=? where id=?"); + pstmt.setBoolean(1, true); + pstmt.setLong(2, id); + pstmt.executeUpdate(); + } + } + } catch (SQLException e) { + throw new CloudRuntimeException("Unable to set elastic_ip_service for network offerings with EIP service enabled.", e); + } finally { + try { + if (rs != null) { + rs.close(); + } + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + } + } + } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index eeb1c78a44f..02d630f31fd 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -16,41 +16,10 @@ // under the License. package com.cloud.vm; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import javax.ejb.Local; -import javax.naming.ConfigurationException; - -import org.apache.commons.codec.binary.Base64; -import org.apache.log4j.Logger; - import com.cloud.acl.ControlledEntity.ACLType; import com.cloud.acl.SecurityChecker.AccessType; import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.AttachIsoCommand; -import com.cloud.agent.api.AttachVolumeAnswer; -import com.cloud.agent.api.AttachVolumeCommand; -import com.cloud.agent.api.ComputeChecksumCommand; -import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; -import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; -import com.cloud.agent.api.GetVmStatsAnswer; -import com.cloud.agent.api.GetVmStatsCommand; -import com.cloud.agent.api.SnapshotCommand; -import com.cloud.agent.api.StartAnswer; -import com.cloud.agent.api.StopAnswer; -import com.cloud.agent.api.UpgradeSnapshotCommand; -import com.cloud.agent.api.VmStatsEntry; +import com.cloud.agent.api.*; import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; @@ -59,22 +28,7 @@ import com.cloud.agent.manager.Commands; import com.cloud.alert.AlertManager; import com.cloud.api.ApiDBUtils; import com.cloud.api.BaseCmd; -import com.cloud.api.commands.AssignVMCmd; -import com.cloud.api.commands.AttachVolumeCmd; -import com.cloud.api.commands.CreateTemplateCmd; -import com.cloud.api.commands.CreateVMGroupCmd; -import com.cloud.api.commands.DeleteVMGroupCmd; -import com.cloud.api.commands.DeployVMCmd; -import com.cloud.api.commands.DestroyVMCmd; -import com.cloud.api.commands.DetachVolumeCmd; -import com.cloud.api.commands.ListVMsCmd; -import com.cloud.api.commands.RebootVMCmd; -import com.cloud.api.commands.RecoverVMCmd; -import com.cloud.api.commands.ResetVMPasswordCmd; -import com.cloud.api.commands.RestoreVMCmd; -import com.cloud.api.commands.StartVMCmd; -import com.cloud.api.commands.UpdateVMCmd; -import com.cloud.api.commands.UpgradeVMCmd; +import com.cloud.api.commands.*; import com.cloud.async.AsyncJobExecutor; import com.cloud.async.AsyncJobManager; import com.cloud.async.AsyncJobVO; @@ -99,37 +53,18 @@ import com.cloud.event.ActionEvent; import com.cloud.event.EventTypes; import com.cloud.event.UsageEventVO; import com.cloud.event.dao.UsageEventDao; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ManagementServerException; -import com.cloud.exception.OperationTimedoutException; -import com.cloud.exception.PermissionDeniedException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.exception.StorageUnavailableException; -import com.cloud.exception.VirtualMachineMigrationException; +import com.cloud.exception.*; import com.cloud.ha.HighAvailabilityManager; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao; -import com.cloud.network.IPAddressVO; -import com.cloud.network.LoadBalancerVMMapVO; -import com.cloud.network.Network; +import com.cloud.network.*; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; -import com.cloud.network.NetworkManager; -import com.cloud.network.NetworkVO; import com.cloud.network.Networks.TrafficType; -import com.cloud.network.PhysicalNetwork; -import com.cloud.network.dao.FirewallRulesDao; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.LoadBalancerVMMapDao; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkServiceMapDao; -import com.cloud.network.dao.PhysicalNetworkDao; +import com.cloud.network.dao.*; import com.cloud.network.element.UserDataServiceProvider; import com.cloud.network.lb.LoadBalancingRulesManager; import com.cloud.network.rules.FirewallManager; @@ -159,50 +94,19 @@ import com.cloud.server.Criteria; import com.cloud.server.ResourceTag.TaggedResourceType; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; -import com.cloud.storage.DiskOfferingVO; -import com.cloud.storage.GuestOSVO; -import com.cloud.storage.Snapshot; -import com.cloud.storage.SnapshotVO; -import com.cloud.storage.Storage; +import com.cloud.storage.*; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Storage.TemplateType; -import com.cloud.storage.StorageManager; -import com.cloud.storage.StoragePool; -import com.cloud.storage.StoragePoolStatus; -import com.cloud.storage.StoragePoolVO; -import com.cloud.storage.VMTemplateHostVO; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; -import com.cloud.storage.VMTemplateVO; -import com.cloud.storage.VMTemplateZoneVO; -import com.cloud.storage.Volume; import com.cloud.storage.Volume.Type; -import com.cloud.storage.VolumeHostVO; -import com.cloud.storage.VolumeVO; -import com.cloud.storage.dao.DiskOfferingDao; -import com.cloud.storage.dao.GuestOSDao; -import com.cloud.storage.dao.SnapshotDao; -import com.cloud.storage.dao.StoragePoolDao; -import com.cloud.storage.dao.VMTemplateDao; -import com.cloud.storage.dao.VMTemplateDetailsDao; -import com.cloud.storage.dao.VMTemplateHostDao; -import com.cloud.storage.dao.VMTemplateZoneDao; -import com.cloud.storage.dao.VolumeDao; -import com.cloud.storage.dao.VolumeHostDao; +import com.cloud.storage.dao.*; import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.tags.ResourceTagVO; import com.cloud.tags.dao.ResourceTagDao; import com.cloud.template.VirtualMachineTemplate; import com.cloud.template.VirtualMachineTemplate.BootloaderType; -import com.cloud.user.Account; -import com.cloud.user.AccountManager; -import com.cloud.user.AccountService; -import com.cloud.user.AccountVO; -import com.cloud.user.ResourceLimitService; -import com.cloud.user.SSHKeyPair; -import com.cloud.user.User; -import com.cloud.user.UserContext; -import com.cloud.user.UserVO; +import com.cloud.user.*; import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.SSHKeyPairDao; import com.cloud.user.dao.UserDao; @@ -216,24 +120,22 @@ import com.cloud.utils.component.Inject; import com.cloud.utils.component.Manager; import com.cloud.utils.concurrency.NamedThreadFactory; import com.cloud.utils.crypt.RSAHelper; -import com.cloud.utils.db.DB; -import com.cloud.utils.db.Filter; -import com.cloud.utils.db.GlobalLock; -import com.cloud.utils.db.JoinBuilder; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.Transaction; +import com.cloud.utils.db.*; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.ExecutionException; import com.cloud.utils.fsm.NoTransitionException; import com.cloud.utils.net.NetUtils; import com.cloud.vm.VirtualMachine.State; -import com.cloud.vm.dao.InstanceGroupDao; -import com.cloud.vm.dao.InstanceGroupVMMapDao; -import com.cloud.vm.dao.NicDao; -import com.cloud.vm.dao.UserVmDao; -import com.cloud.vm.dao.UserVmDetailsDao; -import com.cloud.vm.dao.VMInstanceDao; +import com.cloud.vm.dao.*; +import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; +import java.util.*; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; @Local(value = { UserVmManager.class, UserVmService.class }) public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager { @@ -2857,6 +2759,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (ip != null && ip.getSystem()) { UserContext ctx = UserContext.current(); try { + long networkId = ip.getAssociatedWithNetworkId(); + Network guestNetwork = _networkMgr.getNetwork(networkId); + NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId()); + assert (offering.getAssociatePublicIP() == true) : "User VM should not have system owned public IP associated with it when offering configured not to associate public IP."; _rulesMgr.disableStaticNat(ip.getId(), ctx.getCaller(), ctx.getCallerUserId(), true); } catch (Exception ex) { s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index fff084e6336..b0457d7ef3e 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -303,6 +303,7 @@ CREATE TABLE `cloud`.`network_offerings` ( `state` char(32) COMMENT 'state of the network offering that has Disabled value by default', `guest_type` char(32) COMMENT 'type of guest network that can be shared or isolated', `elastic_ip_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides elastic ip service', + `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.', `elastic_lb_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides elastic lb service', `specify_ip_ranges` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides an ability to define ip ranges', PRIMARY KEY (`id`), diff --git a/setup/db/db/schema-40to41.sql b/setup/db/db/schema-40to41.sql new file mode 100644 index 00000000000..51afde47bfe --- /dev/null +++ b/setup/db/db/schema-40to41.sql @@ -0,0 +1,23 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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. + +--; +-- Schema upgrade from 4.0 to 4.1.0; +--; + + +ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`; From 561dccfe9d36490f747463041ede8a46020c80e6 Mon Sep 17 00:00:00 2001 From: Joe Brockmeier Date: Wed, 12 Dec 2012 11:21:14 -0600 Subject: [PATCH 071/145] Fixing an oops, left out a tag... --- docs/en-US/change-database-password.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/en-US/change-database-password.xml b/docs/en-US/change-database-password.xml index 9041ade9f26..0ab52675e3c 100644 --- a/docs/en-US/change-database-password.xml +++ b/docs/en-US/change-database-password.xml @@ -25,6 +25,7 @@
Changing the Database Password You may need to change the password for the MySQL account used by CloudStack. If so, you'll need to change the password in MySQL, and then add the encrypted password to /etc/cloud/management/db.properties. + Before changing the password, you'll need to stop CloudStack's management server and the usage engine if you've deployed that component. @@ -54,7 +55,7 @@ verbose=false File encryption type - Note that this is for the file encryption type. If you're using the web encryption type (see ) then you'll use password="management_server_secret_key" + Note that this is for the file encryption type. If you're using the web encryption type then you'll use password="management_server_secret_key" @@ -71,4 +72,5 @@ db.usage.password=ENC(encrypted_password_from_above) # service cloud-usage start +
From 864ab37e13476d8c58b19a004a68fe7e5b2c5955 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Wed, 12 Dec 2012 11:07:28 -0800 Subject: [PATCH 072/145] marvin lib: changes for accomodating vpc related apis new apis for the integration lib for VPCOffering, VPC, NetworkACL Apis. Also some extra checks from for avoiding KeyErrors in the Services dict. --- tools/marvin/marvin/integration/lib/base.py | 207 ++++++++++++++++-- tools/marvin/marvin/integration/lib/common.py | 7 + tools/marvin/marvin/integration/lib/utils.py | 7 +- 3 files changed, 200 insertions(+), 21 deletions(-) diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py index 149a47c0663..e8c3b25bd89 100644 --- a/tools/marvin/marvin/integration/lib/base.py +++ b/tools/marvin/marvin/integration/lib/base.py @@ -203,16 +203,19 @@ class VirtualMachine: def __init__(self, items, services): self.__dict__.update(items) - self.username = services["username"] - self.password = services["password"] - self.ssh_port = services["ssh_port"] + if "username" in services: + self.username = services["username"] + if "password" in services: + self.password = services["password"] + if "ssh_port" in services: + self.ssh_port = services["ssh_port"] self.ssh_client = None #extract out the ipaddress self.ipaddress = self.nic[0].ipaddress @classmethod def create(cls, apiclient, services, templateid=None, accountid=None, - domainid=None, networkids=None, serviceofferingid=None, + domainid=None, zoneid=None, networkids=None, serviceofferingid=None, securitygroupids=None, projectid=None, startvm=None, diskofferingid=None, hostid=None, mode='basic'): """Create the instance""" @@ -224,7 +227,10 @@ class VirtualMachine: elif "serviceoffering" in services: cmd.serviceofferingid = services["serviceoffering"] - cmd.zoneid = services["zoneid"] + if zoneid: + cmd.zoneid = zoneid + elif "zoneid" in services: + cmd.zoneid = services["zoneid"] cmd.hypervisor = services["hypervisor"] if accountid: @@ -838,7 +844,7 @@ class PublicIPAddress: @classmethod def create(cls, apiclient, accountid=None, zoneid=None, domainid=None, - services=None, networkid=None, projectid=None): + services=None, networkid=None, projectid=None, vpcid=None): """Associate Public IP address""" cmd = associateIpAddress.associateIpAddressCmd() @@ -860,6 +866,9 @@ class PublicIPAddress: if projectid: cmd.projectid = projectid + + if vpcid: + cmd.vpcid = vpcid return PublicIPAddress(apiclient.associateIpAddress(cmd).__dict__) def delete(self, apiclient): @@ -886,7 +895,7 @@ class NATRule: @classmethod def create(cls, apiclient, virtual_machine, services, ipaddressid=None, - projectid=None): + projectid=None, networkid=None): """Create Port forwarding rule""" cmd = createPortForwardingRule.createPortForwardingRuleCmd() @@ -903,6 +912,9 @@ class NATRule: if projectid: cmd.projectid = projectid + if networkid: + cmd.networkid = networkid + return NATRule(apiclient.createPortForwardingRule(cmd).__dict__) def delete(self, apiclient): @@ -928,7 +940,7 @@ class StaticNATRule: self.__dict__.update(items) @classmethod - def create(cls, apiclient, services, ipaddressid=None): + def create(cls, apiclient, services, ipaddressid=None, vpcid=None): """Creates static ip forwarding rule""" cmd = createIpForwardingRule.createIpForwardingRuleCmd() @@ -946,6 +958,9 @@ class StaticNATRule: elif "ipaddressid" in services: cmd.ipaddressid = services["ipaddressid"] + if vpcid: + cmd.vpcid = vpcid + return StaticNATRule(apiclient.createIpForwardingRule(cmd).__dict__) def delete(self, apiclient): @@ -991,7 +1006,7 @@ class FireWallRule: @classmethod def create(cls, apiclient, ipaddressid, protocol, cidrlist=None, - startport=None, endport=None, projectid=None): + startport=None, endport=None, projectid=None, vpcid=None): """Create Firewall Rule""" cmd = createFirewallRule.createFirewallRuleCmd() cmd.ipaddressid = ipaddressid @@ -1006,6 +1021,9 @@ class FireWallRule: if projectid: cmd.projectid = projectid + if vpcid: + cmd.vpcid = vpcid + return FireWallRule(apiclient.createFirewallRule(cmd).__dict__) def delete(self, apiclient): @@ -1039,7 +1057,7 @@ class ServiceOffering: cmd.displaytext = services["displaytext"] cmd.memory = services["memory"] cmd.name = services["name"] - if hasattr(cmd, "storagetype"): + if "storagetype" in services: cmd.storagetype = services["storagetype"] # Service Offering private to that domain @@ -1505,7 +1523,8 @@ class Network: @classmethod def create(cls, apiclient, services, accountid=None, domainid=None, - networkofferingid=None, projectid=None, zoneid=None): + networkofferingid=None, projectid=None, zoneid=None, + gateway=None, netmask=None, vpcid=None, guestcidr=None): """Create Network for account""" cmd = createNetwork.createNetworkCmd() cmd.name = services["name"] @@ -1521,9 +1540,13 @@ class Network: elif "zoneid" in services: cmd.zoneid = services["zoneid"] - if "gateway" in services: + if gateway: + cmd.gateway = gateway + elif "gateway" in services: cmd.gateway = services["gateway"] - if "netmask" in services: + if netmask: + cmd.netmask = netmask + elif "netmask" in services: cmd.netmask = services["netmask"] if "startip" in services: cmd.startip = services["startip"] @@ -1540,7 +1563,10 @@ class Network: cmd.domainid = domainid if projectid: cmd.projectid = projectid - + if guestcidr: + cmd.guestcidr = guestcidr + if vpcid: + cmd.vpcid = vpcid return Network(apiclient.createNetwork(cmd).__dict__) def delete(self, apiclient): @@ -1564,7 +1590,7 @@ class Network: cmd = restartNetwork.restartNetworkCmd() cmd.id = self.id if cleanup: - cmd.cleanup = cleanup + cmd.cleanup = cleanup return(apiclient.restartNetwork(cmd)) @classmethod @@ -1576,6 +1602,50 @@ class Network: return(apiclient.listNetworks(cmd)) +class NetworkACL: + """Manage Network ACL lifecycle""" + + def __init__(self, items): + self.__dict__.update(items) + + @classmethod + def create(cls, apiclient, networkid, services, traffictype=None): + """Create network ACL rules(Ingress/Egress)""" + + cmd = createNetworkACL.createNetworkACLCmd() + cmd.networkid = networkid + if "protocol" in services: + cmd.protocol = services["protocol"] + + if services["protocol"] == 'ICMP': + cmd.icmptype = -1 + cmd.icmpcode = -1 + else: + cmd.startport = services["startport"] + cmd.endport = services["endport"] + + cmd.cidrlist = services["cidrlist"] + if traffictype: + cmd.traffictype = traffictype + # Defaulted to Ingress + return NetworkACL(apiclient.createNetworkACL(cmd).__dict__) + + def delete(self, apiclient): + """Delete network acl""" + + cmd = deleteNetworkACL.deleteNetworkACLCmd() + cmd.id = self.id + return apiclient.deleteNetworkACL(cmd) + + @classmethod + def list(cls, apiclient, **kwargs): + """List Network ACLs""" + + cmd = listNetworkACLs.listNetworkACLsCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return(apiclient.listNetworkACLs(cmd)) + + class Vpn: """Manage VPN life cycle""" @@ -1584,7 +1654,7 @@ class Vpn: @classmethod def create(cls, apiclient, publicipid, account=None, domainid=None, - projectid=None): + projectid=None, vpcid=None): """Create VPN for Public IP address""" cmd = createRemoteAccessVpn.createRemoteAccessVpnCmd() cmd.publicipid = publicipid @@ -1594,6 +1664,8 @@ class Vpn: cmd.domainid = domainid if projectid: cmd.projectid = projectid + if vpcid: + cmd.vpcid = vpcid return Vpn(apiclient.createRemoteAccessVpn(cmd).__dict__) def delete(self, apiclient): @@ -2211,3 +2283,106 @@ class NetworkServiceProvider: cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd() [setattr(cmd, k, v) for k, v in kwargs.items()] return(apiclient.listNetworkServiceProviders(cmd)) + +class VpcOffering: + """Manage VPC offerings""" + + def __init__(self, items): + self.__dict__.update(items) + + @classmethod + def create(cls, apiclient, services): + """Create vpc offering""" + + cmd = createVPCOffering.createVPCOfferingCmd() + cmd.name = "-".join([services["name"], random_gen()]) + cmd.displaytext = services["displaytext"] + cmd.supportedServices = services["supportedservices"] + return VpcOffering(apiclient.createVPCOffering(cmd).__dict__) + + def update(self, apiclient, name=None, displaytext=None, state=None): + """Updates existing VPC offering""" + + cmd = updateVPCOffering.updateVPCOfferingCmd() + cmd.id = self.id + if name: + cmd.name = name + if displaytext: + cmd.displaytext = displaytext + if state: + cmd.state = state + return apiclient.updateVPCOffering(cmd) + + @classmethod + def list(cls, apiclient, **kwargs): + """List the VPC offerings based on criteria specified""" + + cmd = listVPCOfferings.listVPCOfferingsCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return(apiclient.listVPCOfferings(cmd)) + + def delete(self, apiclient): + """Deletes existing VPC offering""" + + cmd = deleteVPCOffering.deleteVPCOfferingCmd() + cmd.id = self.id + return apiclient.deleteVPCOffering(cmd) + + +class VPC: + """Manage Virtual Private Connection""" + + def __init__(self, items): + self.__dict__.update(items) + + @classmethod + def create(cls, apiclient, services, vpcofferingid, + zoneid, networkDomain=None, account=None, domainid=None): + """Creates the virtual private connection (VPC)""" + + cmd = createVPC.createVPCCmd() + cmd.name = "-".join([services["name"], random_gen()]) + cmd.displaytext = "-".join([services["displaytext"], random_gen()]) + cmd.vpcofferingid = vpcofferingid + cmd.zoneid = zoneid + cmd.cidr = services["cidr"] + if account: + cmd.account = account + if domainid: + cmd.domainid = domainid + if networkDomain: + cmd.networkDomain = networkDomain + return VPC(apiclient.createVPC(cmd).__dict__) + + def update(self, apiclient, name=None, displaytext=None): + """Updates VPC configurations""" + + cmd = updateVPC.updateVPCCmd() + cmd.id = self.id + if name: + cmd.name = name + if displaytext: + cmd.displaytext = displaytext + return (apiclient.updateVPC(cmd)) + + def delete(self, apiclient): + """Delete VPC network""" + + cmd = deleteVPC.deleteVPCCmd() + cmd.id = self.id + return apiclient.deleteVPC(cmd) + + def restart(self, apiclient): + """Restarts the VPC connections""" + + cmd = restartVPC.restartVPCCmd() + cmd.id = self.id + return apiclient.restartVPC(cmd) + + @classmethod + def list(cls, apiclient, **kwargs): + """List VPCs""" + + cmd = listVPCs.listVPCsCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return(apiclient.listVPCs(cmd)) diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py index cc9e6cb09f0..5f90110c367 100644 --- a/tools/marvin/marvin/integration/lib/common.py +++ b/tools/marvin/marvin/integration/lib/common.py @@ -559,3 +559,10 @@ def list_resource_limits(apiclient, **kwargs): cmd = listResourceLimits.listResourceLimitsCmd() [setattr(cmd, k, v) for k, v in kwargs.items()] return(apiclient.listResourceLimits(cmd)) + +def list_vpc_offerings(apiclient, **kwargs): + """ Lists VPC offerings """ + + cmd = listVPCOfferings.listVPCOfferingsCmd() + [setattr(cmd, k, v) for k, v in kwargs.items()] + return(apiclient.listVPCOfferings(cmd)) \ No newline at end of file diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py index 05aed798a24..cff24a1b2d5 100644 --- a/tools/marvin/marvin/integration/lib/utils.py +++ b/tools/marvin/marvin/integration/lib/utils.py @@ -21,9 +21,6 @@ import marvin import time from marvin.remoteSSHClient import remoteSSHClient from marvin.cloudstackAPI import * -from marvin import cloudstackConnection -#from cloudstackConnection import cloudConnection -from marvin import configGenerator import logging import string import random @@ -136,12 +133,12 @@ def format_volume_to_ext3(ssh_client, device="/dev/sda"): def fetch_api_client(config_file='datacenterCfg'): """Fetch the Cloudstack API Client""" - config = configGenerator.get_setup_config(config_file) + config = marvin.configGenerator.get_setup_config(config_file) mgt = config.mgtSvr[0] testClientLogger = logging.getLogger("testClient") asyncTimeout = 3600 return cloudstackAPIClient.CloudStackAPIClient( - cloudstackConnection.cloudConnection( + marvin.cloudstackConnection.cloudConnection( mgt.mgtSvrIp, mgt.port, mgt.apiKey, From 41dd38c86b0ac3f2c235c06162a5c12cf930aa8e Mon Sep 17 00:00:00 2001 From: Radhika PC Date: Thu, 13 Dec 2012 04:05:49 +0530 Subject: [PATCH 073/145] Docs for Elastic IP and display name in vCenter --- docs/en-US/about-working-with-vms.xml | 87 ++++-- docs/en-US/append-displayname-vms.xml | 84 +++++ docs/en-US/creating-network-offerings.xml | 353 +++++++++++++++------- docs/en-US/elastic-ip.xml | 73 +++++ docs/en-US/networks.xml | 1 + docs/en-US/virtual-machines.xml | 1 + 6 files changed, 460 insertions(+), 139 deletions(-) create mode 100644 docs/en-US/append-displayname-vms.xml create mode 100644 docs/en-US/elastic-ip.xml diff --git a/docs/en-US/about-working-with-vms.xml b/docs/en-US/about-working-with-vms.xml index 47153e2f374..df71f05f8ef 100644 --- a/docs/en-US/about-working-with-vms.xml +++ b/docs/en-US/about-working-with-vms.xml @@ -3,37 +3,62 @@ %BOOK_ENTITIES; ]> - - -
- About Working with Virtual Machines - &PRODUCT; provides administrators with complete control over the lifecycle of all guest VMs executing in the cloud. &PRODUCT; provides several guest management operations for end users and administrators. VMs may be stopped, started, rebooted, and destroyed. - Guest VMs have a name and group. VM names and groups are opaque to &PRODUCT; and are available for end users to organize their VMs. Each VM can have three names for use in different contexts. Only two of these names can be controlled by the user: - - Instance name – a unique, immutable ID that is generated by &PRODUCT; and can not be modified by the user. This name conforms to the requirements in IETF RFC 1123. - Display name – the name displayed in the &PRODUCT; web UI. Can be set by the user. Defaults to instance name. - Name – host name that the DHCP server assigns to the VM. Can be set by the user. Defaults to instance name - - Guest VMs can be configured to be Highly Available (HA). An HA-enabled VM is monitored by the system. If the system detects that the VM is down, it will attempt to restart the VM, possibly on a different host. For more information, see HA-Enabled Virtual Machines on - Each new VM is allocated one public IP address. When the VM is started, &PRODUCT; automatically creates a static NAT between this public IP address and the private IP address of the VM. - If elastic IP is in use (with the NetScaler load balancer), the IP address initially allocated to the new VM is not marked as elastic. The user must replace the automatically configured IP with a specifically acquired elastic IP, and set up the static NAT mapping between this new IP and the guest VM’s private IP. The VM’s original IP address is then released and returned to the pool of available public IPs. - &PRODUCT; cannot distinguish a guest VM that was shut down by the user (such as with the “shutdown†command in Linux) from a VM that shut down unexpectedly. If an HA-enabled VM is shut down from inside the VM, &PRODUCT; will restart it. To shut down an HA-enabled VM, you must go through the &PRODUCT; UI or API. + About Working with Virtual Machines + &PRODUCT; provides administrators with complete control over the lifecycle of all guest VMs + executing in the cloud. &PRODUCT; provides several guest management operations for end users and + administrators. VMs may be stopped, started, rebooted, and destroyed. + Guest VMs have a name and group. VM names and groups are opaque to &PRODUCT; and are + available for end users to organize their VMs. Each VM can have three names for use in different + contexts. Only two of these names can be controlled by the user: + + + Instance name – a unique, immutable ID that is generated by &PRODUCT; and can not + be modified by the user. This name conforms to the requirements in IETF RFC 1123. + + + Display name – the name displayed in the &PRODUCT; web UI. Can be set by the user. + Defaults to instance name. + + + Name – host name that the DHCP server assigns to the VM. Can be set by the user. + Defaults to instance name + + + + You can append the display name of a guest VM to its internal name. For more information, + see . + + Guest VMs can be configured to be Highly Available (HA). An HA-enabled VM is monitored by + the system. If the system detects that the VM is down, it will attempt to restart the VM, + possibly on a different host. For more information, see HA-Enabled Virtual Machines on + Each new VM is allocated one public IP address. When the VM is started, &PRODUCT; + automatically creates a static NAT between this public IP address and the private IP address of + the VM. + If elastic IP is in use (with the NetScaler load balancer), the IP address initially + allocated to the new VM is not marked as elastic. The user must replace the automatically + configured IP with a specifically acquired elastic IP, and set up the static NAT mapping between + this new IP and the guest VM’s private IP. The VM’s original IP address is then released and + returned to the pool of available public IPs. Optionally, you can also decide not to allocate a + public IP to a VM in an EIP-enabled Basic zone. For more information on Elastic IP, see . + &PRODUCT; cannot distinguish a guest VM that was shut down by the user (such as with the + “shutdown†command in Linux) from a VM that shut down unexpectedly. If an HA-enabled VM is shut + down from inside the VM, &PRODUCT; will restart it. To shut down an HA-enabled VM, you must go + through the &PRODUCT; UI or API.
- diff --git a/docs/en-US/append-displayname-vms.xml b/docs/en-US/append-displayname-vms.xml new file mode 100644 index 00000000000..ff0752cadc1 --- /dev/null +++ b/docs/en-US/append-displayname-vms.xml @@ -0,0 +1,84 @@ + + +%BOOK_ENTITIES; +]> + +
+ Appending a Display Name to the Guest VM’s Internal Name + Every guest VM has an internal name. The host uses the internal name to identify the guest + VMs. &PRODUCT; gives you an option to provide a guest VM with a display name. You can set this + display name as the internal name so that the vCenter can use it to identify the guest VM. A new + global parameter, vm.instancename.flag, has now been added to achieve this functionality. + The default format of the internal name is + i-<user_id>-<vm_id>-<instance.name>, where instance.name is a global + parameter. However, If vm.instancename.flag is set to true, and if a display name is provided + during the creation of a guest VM, the display name is appended to the internal name of the + guest VM on the host. This makes the internal name format as + i-<user_id>-<vm_id>-<displayName>. The default value of vm.instancename.flag + is set to false. This feature is intended to make the correlation between instance names and + internal names easier in large data center deployments. + The following table explains how a VM name is displayed in different scenarios. + + + + + + + + + + User-Provided Display Name + vm.instancename.flag + Hostname on the VM + Name on vCenter + Internal Name + + + + + Yes + True + Display name + i-<user_id>-<vm_id>-displayName + i-<user_id>-<vm_id>-displayName + + + No + True + UUID + i-<user_id>-<vm_id>-<instance.name> + i-<user_id>-<vm_id>-<instance.name> + + + Yes + False + Display name + i-<user_id>-<vm_id>-<instance.name> + i-<user_id>-<vm_id>-<instance.name> + + + No + False + UUID + i-<user_id>-<vm_id>-<instance.name> + i-<user_id>-<vm_id>-<instance.name> + + + + +
diff --git a/docs/en-US/creating-network-offerings.xml b/docs/en-US/creating-network-offerings.xml index ab569200641..6e0315def69 100644 --- a/docs/en-US/creating-network-offerings.xml +++ b/docs/en-US/creating-network-offerings.xml @@ -3,115 +3,252 @@ %BOOK_ENTITIES; ]> - - -
- Creating a New Network Offering - To create a network offering: - - Log in with admin privileges to the &PRODUCT; UI. - In the left navigation bar, click Service Offerings. - In Select Offering, choose Network Offering. - Click Add Network Offering. - In the dialog, make the following choices: - - Name. Any desired name for the network offering - Description. A short description of the offering that can be displayed to users - Network Rate. Allowed data transfer rate in MB per second - Traffic Type. The type of network traffic that will be carried on the network - Guest Type. Choose whether the guest network is isolated or shared. For a description of these terms, see - Specify VLAN. (Isolated guest networks only) Indicate whether a VLAN should be specified when this offering is used - Supported Services. Select one or more of the possible network services. For some services, you must also choose the service provider; for example, if you select Load Balancer, you can choose the &PRODUCT; virtual router or any other load balancers that have been configured in the cloud. Depending on which services you choose, additional fields may appear in the rest of the dialog box.Based on the guest network type selected, you can see the following supported services: - - - - Supported Services - Description - Isolated - Shared - - - - - DHCP - - Supported - Supported - - - DNS - - Supported - Supported - - - Load Balancer - If you select Load Balancer, you can choose the &PRODUCT; virtual router or any other load balancers that have been configured in the cloud. - Supported - Supported - - - Source NAT - If you select Source NAT, you can choose the &PRODUCT; virtual router or any other Source NAT providers that have been configured in the cloud. - Supported - Supported - - - Static NAT - If you select Static NAT, you can choose the &PRODUCT; virtual router or any other Static NAT providers that have been configured in the cloud. - Supported - Supported - - - Port Forwarding - If you select Port Forwarding, you can choose the &PRODUCT; virtual router or any other Port Forwarding providers that have been configured in the cloud. - Supported - Not Supported - - - VPN - - Supported - Not Supported - - - User Data - - Not Supported - Supported - - - Security Groups - See . - Not Supported - Supported - - - - + Creating a New Network Offering + To create a network offering: + + + Log in with admin privileges to the &PRODUCT; UI. + + + In the left navigation bar, click Service Offerings. + + + In Select Offering, choose Network Offering. + + + Click Add Network Offering. + The Add Network Offering dialog is displayed: + + + In the dialog, make the following choices: + + + Name. Any desired name for the network + offering. + + + Description. A short description of the offering + that can be displayed to users. + + + Network Rate. Allowed data transfer rate in MB per + second. + + + Guest Type. Select whether the guest network is + isolated or shared. For a description of these terms, see . + + + Specify VLAN. (Isolated guest networks only) + Indicates whether a VLAN should be specified when this offering is used. + + + Supported Services. Select one or more of the + possible network services. For some services, you must also choose the service provider; + for example, if you select Load Balancer, you can choose the &PRODUCT; virtual router or + any other load balancers that have been configured in the cloud. Depending on which + services you choose, additional fields may appear in the rest of the dialog box. + Based on the guest network type selected, you can see the following supported + services: + + + + + Supported Services + Description + Isolated + Shared + + + + + DHCP + For more information, see . + Supported + Supported + + + DNS + For more information, see . + Supported + Supported + + + Load Balancer + If you select Load Balancer, you can choose the &PRODUCT; virtual + router or any other load balancers that have been configured in the + cloud. + Supported + Not Supported + + + Firewall + For more information, see . + Supported + Supported + + + Source NAT + If you select Source NAT, you can choose the &PRODUCT; virtual router + or any other Source NAT providers that have been configured in the + cloud. + Supported + Supported + + + Static NAT + If you select Static NAT, you can choose the &PRODUCT; virtual router + or any other Static NAT providers that have been configured in the + cloud. + Supported + Supported + + + Port Forwarding + If you select Port Forwarding, you can choose the &PRODUCT; virtual + router or any other Port Forwarding providers that have been configured in the + cloud. + Supported + Supported + + + VPN + For more information, see . + Supported + Supported + + + User Data + For more information, see . + Supported + Supported + + + Network ACL + For more information, see . + Supported + Supported + + + Security Groups + For more information, see . + Supported + Supported + + + + + + + System Offering: Available only when the service + provider for any of the services selected is Virtual Router. Choose the system service + offering that you want the virtual routers to use in this network. For example, if you + selected Load Balancer in Supported Services and select a Virtual Router to provide load + balancing, the System Offering field appears so you can choose between the &PRODUCT; + default system service offering and any custom system service offerings that have been + defined by the &PRODUCT; root administrator. For more information, see System Service + Offerings. + + + LB Isolation: Specify what type of load balancer + isolation you want for the network: Shared or Dedicated. + Dedicated: If you select dedicated LB isolation, a + dedicated load balancer device is assigned for the network from the pool of dedicated + load balancer devices provisioned in the zone. If no sufficient dedicated load balancer + devices are available in the zone, network creation fails. Dedicated device is a good + choice for the high-traffic networks that make full use of the device's + resources. + Shared: If you select shared LB isolation, a shared + load balancer device is assigned for the network from the pool of shared load balancer + devices provisioned in the zone. While provisioning &PRODUCT; picks the shared load + balancer device that is used by the least number of accounts. Once the device reaches + its maximum capacity, the device will not be allocated to a new account. + + + Mode: You can select either Inline mode or Side by + Side mode: + Inline mode: Supported only for Juniper SRX + firewall and BigF5 load balancer devices. In inline mode, a firewall device is placed in + front of a load balancing device. The firewall acts as the gateway for all the incoming + traffic, then redirect the load balancing traffic to the load balancer behind it. The + load balancer in this case will not have the direct access to the public network. + Side by Side: In side by side mode, a firewall + device is deployed in parallel with the load balancer device. So the traffic to the load + balancer public IP is not routed through the firewall, and therefore, is exposed to the + public network. + + + Associate Public IP: Select this option if you want + to assign a public IP address to the VMs deployed in the guest network. This option is + available only if + + + Guest network is shared. - System Offering. If the service provider for any of the services selected in Supported Services is a virtual router, the System Offering field appears. Choose the system service offering that you want virtual routers to use in this network. For example, if you selected Load Balancer in Supported Services and selected a virtual router to provide load balancing, the System Offering field appears so you can choose between the &PRODUCT; default system service offering and any custom system service offerings that have been defined by the &PRODUCT; root administrator. For more information, see System Service Offerings. - Redundant router capability. (v3.0.3 and greater) Available only when Virtual Router is selected as the Source NAT provider. Select this option if you want to use two virtual routers in the network for uninterrupted connection: one operating as the master virtual router and the other as the backup. The master virtual router receives requests from and sends responses to the user’s VM. The backup virtual router is activated only when the master is down. After the failover, the backup becomes the master virtual router. &PRODUCT; deploys the routers on different hosts to ensure reliability if one host is down. - Conserve mode. Indicate whether to use conserve mode. In this mode, network resources are allocated only when the first virtual machine starts in the network - Tags. Network tag to specify which physical network to use - - Click Add. - + + Supported load balancer provider is Netscaler. + + + StaticNAT is enabled. + + + Elastic IP is enabled. + + + For information on Elastic IP, see . + + + Redundant router capability: (v3.0.3 and greater) + Available only when Virtual Router is selected as the Source NAT provider. Select this + option if you want to use two virtual routers in the network for uninterrupted + connection: one operating as the master virtual router and the other as the backup. The + master virtual router receives requests from and sends responses to the user’s VM. The + backup virtual router is activated only when the master is down. After the failover, the + backup becomes the master virtual router. &PRODUCT; deploys the routers on different + hosts to ensure reliability if one host is down. + + + Conserve mode: Specify whether to use conserve + mode. In this mode, network resources are allocated only when the first virtual machine + starts in the network. When the conservative mode is off, the public IP can only be used + for a single service. For example, a public IP used for a port forwarding rule cannot be + used for defining other services, such as SaticNAT or load balancing. When the conserve + mode is on, you can define more than one service on the same public IP. + + If StaticNAT is enabled, irrespective of the status of the conserve mode, no port + forwarding or load balancing rule can be created for the IP. However, you can add the + firewall rules by using the createFirewallRule command. + + + + Tags: Network tag to specify which physical network + to use. + + + + + Click Add. + +
diff --git a/docs/en-US/elastic-ip.xml b/docs/en-US/elastic-ip.xml new file mode 100644 index 00000000000..fa3795ae0de --- /dev/null +++ b/docs/en-US/elastic-ip.xml @@ -0,0 +1,73 @@ + + +%BOOK_ENTITIES; +]> + +
+ About Elastic IP + Elastic IP (EIP) addresses are the IP addresses that are associated with an account, and act + as static IP addresses. The account owner has the complete control over the Elastic IP addresses + that belong to the account. You can allocate an Elastic IP to a VM of your choice from the EIP + pool of your account. Later if required you can reassign the IP address to a different VM. This + feature is extremely helpful during VM failure. Instead of replacing the VM which is down, the + IP address can be reassigned to a new VM in your account. Similar to the public IP address, EIPs + are mapped to their associated private IP addresses by using StacticNAT. + The EIP work flow is as follows: + + + When a user VM is deployed, a public IP is automatically acquired from the pool of + public IPs configured in the zone. This IP is owned by the VM's account. + + + Each VM will have its own private IP. When the user VM starts, the public IP is mapped + to the private IP of the VM by using StaticNAT. + + + This default public IP will be released in two cases: + + + When the VM is stopped. When the VM starts, it again receives a new public IP, not + necessarily be the one allocated initially, from the pool of Public IPs. + + + The user acquires a public IP. This public IP associated with the account will not + be mapped to any private IP. However, the user can enable StaticNAT to associate this IP + to the private IP of a VM in the account. The StaticNAT rule for the public IP can be + disabled at any time. When StaticNAT is disabled, a new public IP is allocated from the + pool, which is not necessarily be the one allocated initially. + + + + + However, for the deployments where public IPs are limited resources, you have the + flexibility to choose not to allocate a public IP by default. From &PRODUCT; 3.0.6 onwards, you + can use the Associate public IP option to turn on or off the automatic public IP assignment in + the EIP-enabled Basic zones. If you turn off the automatic public IP assignment while creating a + network offering, only a private IP is assigned to a VM when it's deployed with the same network + offering. Later, the user can acquire an IP for the VM and enable staticNAT. The section gives you more information on the Associate + public IP option. + + The Associate public IP feature is designed only for the user VMs. The System VMs continue + to get both public IP and private by default irrespective of the network offering + configuration. + + In the case of new deployments, which uses the default shared network offering with EIP + and ELB services to create shared network in the Basic zone, will continue allocating public IPs + to each user VMs. +
diff --git a/docs/en-US/networks.xml b/docs/en-US/networks.xml index a7b9ea12466..8a0f9fa357f 100644 --- a/docs/en-US/networks.xml +++ b/docs/en-US/networks.xml @@ -43,6 +43,7 @@ + \ No newline at end of file diff --git a/docs/en-US/virtual-machines.xml b/docs/en-US/virtual-machines.xml index 7c74932b649..d0ab01520fc 100644 --- a/docs/en-US/virtual-machines.xml +++ b/docs/en-US/virtual-machines.xml @@ -27,6 +27,7 @@ + From c8926de01838d70891425fa630aa57e7a76d852e Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 12 Dec 2012 14:30:12 -0800 Subject: [PATCH 074/145] CS-17074: cloudstack UI - Advanced SG-enabled zone - Zone Wizard - When Advanced option is selected and Security Groups checkbox is checked, hypervisor dropdown will list only KVM option (if KVM is in listHypervisors API response). --- ui/scripts/zoneWizard.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/scripts/zoneWizard.js b/ui/scripts/zoneWizard.js index 92e2230d760..0bfcaad8085 100755 --- a/ui/scripts/zoneWizard.js +++ b/ui/scripts/zoneWizard.js @@ -370,11 +370,20 @@ var array1 = []; var firstOption = "XenServer"; - if(args.context.zones[0]['network-model'] == "Advanced" && args.context.zones[0]['zone-advanced-sg-enabled'] == "on") + var nonSupportedHypervisors = {}; + if(args.context.zones[0]['network-model'] == "Advanced" && args.context.zones[0]['zone-advanced-sg-enabled'] == "on") { firstOption = "KVM"; + nonSupportedHypervisors["XenServer"] = 1; //to developers: comment this line if you need to test Advanced SG-enabled zone with XenServer hypervisor + nonSupportedHypervisors["VMware"] = 1; + nonSupportedHypervisors["BareMetal"] = 1; + nonSupportedHypervisors["Ovm"] = 1; + } if(items != null) { for(var i = 0; i < items.length; i++) { + if(items[i].name in nonSupportedHypervisors) + continue; + if(items[i].name == firstOption) array1.unshift({id: items[i].name, description: items[i].name}); else From 1551b982c4f733bd85a72f48c9f7eb9782462ddd Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 12 Dec 2012 15:21:03 -0800 Subject: [PATCH 075/145] cli: Handle command breaks, ctrl+c, don't break the shell - Fix handles shell loop - Handles any control breaks without breaking the shell - Handles ctrl+c to start afresh on the shell Signed-off-by: Rohit Yadav --- tools/cli/cloudmonkey/cloudmonkey.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py index 8ceba4a0a15..250ea68a5f1 100644 --- a/tools/cli/cloudmonkey/cloudmonkey.py +++ b/tools/cli/cloudmonkey/cloudmonkey.py @@ -65,7 +65,7 @@ logger = logging.getLogger(__name__) completions = cloudstackAPI.__all__ -class CloudStackShell(cmd.Cmd): +class CloudStackShell(cmd.Cmd, object): intro = ("☠Apache CloudStack 🵠cloudmonkey " + __version__ + ". Type help or ? to list commands.\n") ruler = "=" @@ -133,6 +133,15 @@ class CloudStackShell(cmd.Cmd): def emptyline(self): pass + def cmdloop(self, intro=None): + print self.intro + while True: + try: + super(CloudStackShell, self).cmdloop(intro = "") + self.postloop() + except KeyboardInterrupt: + print("^C") + def print_shell(self, *args): try: for arg in args: @@ -273,7 +282,6 @@ class CloudStackShell(cmd.Cmd): x.partition("=")[2]], args[1:])[x] for x in range(len(args) - 1)) - # FIXME: With precaching, dynamic loading can be removed api_cmd_str = "%sCmd" % api_name api_mod = self.get_api_module(api_name, [api_cmd_str]) if api_mod is None: @@ -466,7 +474,7 @@ class CloudStackShell(cmd.Cmd): """ Quit on Ctrl+d or EOF """ - return True + sys.exit() def main(): From b5eec20f5e9a1777c0cb138551833803978d69b6 Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Thu, 13 Dec 2012 05:22:20 +0530 Subject: [PATCH 076/145] Revert "Docs for Elastic IP and display name in vCenter" This reverts commit 41dd38c86b0ac3f2c235c06162a5c12cf930aa8e. --- docs/en-US/about-working-with-vms.xml | 87 ++---- docs/en-US/append-displayname-vms.xml | 84 ----- docs/en-US/creating-network-offerings.xml | 353 +++++++--------------- docs/en-US/elastic-ip.xml | 73 ----- docs/en-US/networks.xml | 1 - docs/en-US/virtual-machines.xml | 1 - 6 files changed, 139 insertions(+), 460 deletions(-) delete mode 100644 docs/en-US/append-displayname-vms.xml delete mode 100644 docs/en-US/elastic-ip.xml diff --git a/docs/en-US/about-working-with-vms.xml b/docs/en-US/about-working-with-vms.xml index df71f05f8ef..47153e2f374 100644 --- a/docs/en-US/about-working-with-vms.xml +++ b/docs/en-US/about-working-with-vms.xml @@ -3,62 +3,37 @@ %BOOK_ENTITIES; ]> - +
- About Working with Virtual Machines - &PRODUCT; provides administrators with complete control over the lifecycle of all guest VMs - executing in the cloud. &PRODUCT; provides several guest management operations for end users and - administrators. VMs may be stopped, started, rebooted, and destroyed. - Guest VMs have a name and group. VM names and groups are opaque to &PRODUCT; and are - available for end users to organize their VMs. Each VM can have three names for use in different - contexts. Only two of these names can be controlled by the user: - - - Instance name – a unique, immutable ID that is generated by &PRODUCT; and can not - be modified by the user. This name conforms to the requirements in IETF RFC 1123. - - - Display name – the name displayed in the &PRODUCT; web UI. Can be set by the user. - Defaults to instance name. - - - Name – host name that the DHCP server assigns to the VM. Can be set by the user. - Defaults to instance name - - - - You can append the display name of a guest VM to its internal name. For more information, - see . - - Guest VMs can be configured to be Highly Available (HA). An HA-enabled VM is monitored by - the system. If the system detects that the VM is down, it will attempt to restart the VM, - possibly on a different host. For more information, see HA-Enabled Virtual Machines on - Each new VM is allocated one public IP address. When the VM is started, &PRODUCT; - automatically creates a static NAT between this public IP address and the private IP address of - the VM. - If elastic IP is in use (with the NetScaler load balancer), the IP address initially - allocated to the new VM is not marked as elastic. The user must replace the automatically - configured IP with a specifically acquired elastic IP, and set up the static NAT mapping between - this new IP and the guest VM’s private IP. The VM’s original IP address is then released and - returned to the pool of available public IPs. Optionally, you can also decide not to allocate a - public IP to a VM in an EIP-enabled Basic zone. For more information on Elastic IP, see . - &PRODUCT; cannot distinguish a guest VM that was shut down by the user (such as with the - “shutdown†command in Linux) from a VM that shut down unexpectedly. If an HA-enabled VM is shut - down from inside the VM, &PRODUCT; will restart it. To shut down an HA-enabled VM, you must go - through the &PRODUCT; UI or API. + About Working with Virtual Machines + &PRODUCT; provides administrators with complete control over the lifecycle of all guest VMs executing in the cloud. &PRODUCT; provides several guest management operations for end users and administrators. VMs may be stopped, started, rebooted, and destroyed. + Guest VMs have a name and group. VM names and groups are opaque to &PRODUCT; and are available for end users to organize their VMs. Each VM can have three names for use in different contexts. Only two of these names can be controlled by the user: + + Instance name – a unique, immutable ID that is generated by &PRODUCT; and can not be modified by the user. This name conforms to the requirements in IETF RFC 1123. + Display name – the name displayed in the &PRODUCT; web UI. Can be set by the user. Defaults to instance name. + Name – host name that the DHCP server assigns to the VM. Can be set by the user. Defaults to instance name + + Guest VMs can be configured to be Highly Available (HA). An HA-enabled VM is monitored by the system. If the system detects that the VM is down, it will attempt to restart the VM, possibly on a different host. For more information, see HA-Enabled Virtual Machines on + Each new VM is allocated one public IP address. When the VM is started, &PRODUCT; automatically creates a static NAT between this public IP address and the private IP address of the VM. + If elastic IP is in use (with the NetScaler load balancer), the IP address initially allocated to the new VM is not marked as elastic. The user must replace the automatically configured IP with a specifically acquired elastic IP, and set up the static NAT mapping between this new IP and the guest VM’s private IP. The VM’s original IP address is then released and returned to the pool of available public IPs. + &PRODUCT; cannot distinguish a guest VM that was shut down by the user (such as with the “shutdown†command in Linux) from a VM that shut down unexpectedly. If an HA-enabled VM is shut down from inside the VM, &PRODUCT; will restart it. To shut down an HA-enabled VM, you must go through the &PRODUCT; UI or API.
+ diff --git a/docs/en-US/append-displayname-vms.xml b/docs/en-US/append-displayname-vms.xml deleted file mode 100644 index ff0752cadc1..00000000000 --- a/docs/en-US/append-displayname-vms.xml +++ /dev/null @@ -1,84 +0,0 @@ - - -%BOOK_ENTITIES; -]> - -
- Appending a Display Name to the Guest VM’s Internal Name - Every guest VM has an internal name. The host uses the internal name to identify the guest - VMs. &PRODUCT; gives you an option to provide a guest VM with a display name. You can set this - display name as the internal name so that the vCenter can use it to identify the guest VM. A new - global parameter, vm.instancename.flag, has now been added to achieve this functionality. - The default format of the internal name is - i-<user_id>-<vm_id>-<instance.name>, where instance.name is a global - parameter. However, If vm.instancename.flag is set to true, and if a display name is provided - during the creation of a guest VM, the display name is appended to the internal name of the - guest VM on the host. This makes the internal name format as - i-<user_id>-<vm_id>-<displayName>. The default value of vm.instancename.flag - is set to false. This feature is intended to make the correlation between instance names and - internal names easier in large data center deployments. - The following table explains how a VM name is displayed in different scenarios. - - - - - - - - - - User-Provided Display Name - vm.instancename.flag - Hostname on the VM - Name on vCenter - Internal Name - - - - - Yes - True - Display name - i-<user_id>-<vm_id>-displayName - i-<user_id>-<vm_id>-displayName - - - No - True - UUID - i-<user_id>-<vm_id>-<instance.name> - i-<user_id>-<vm_id>-<instance.name> - - - Yes - False - Display name - i-<user_id>-<vm_id>-<instance.name> - i-<user_id>-<vm_id>-<instance.name> - - - No - False - UUID - i-<user_id>-<vm_id>-<instance.name> - i-<user_id>-<vm_id>-<instance.name> - - - - -
diff --git a/docs/en-US/creating-network-offerings.xml b/docs/en-US/creating-network-offerings.xml index 6e0315def69..ab569200641 100644 --- a/docs/en-US/creating-network-offerings.xml +++ b/docs/en-US/creating-network-offerings.xml @@ -3,252 +3,115 @@ %BOOK_ENTITIES; ]> - +
- Creating a New Network Offering - To create a network offering: - - - Log in with admin privileges to the &PRODUCT; UI. - - - In the left navigation bar, click Service Offerings. - - - In Select Offering, choose Network Offering. - - - Click Add Network Offering. - The Add Network Offering dialog is displayed: - - - In the dialog, make the following choices: - - - Name. Any desired name for the network - offering. - - - Description. A short description of the offering - that can be displayed to users. - - - Network Rate. Allowed data transfer rate in MB per - second. - - - Guest Type. Select whether the guest network is - isolated or shared. For a description of these terms, see . - - - Specify VLAN. (Isolated guest networks only) - Indicates whether a VLAN should be specified when this offering is used. - - - Supported Services. Select one or more of the - possible network services. For some services, you must also choose the service provider; - for example, if you select Load Balancer, you can choose the &PRODUCT; virtual router or - any other load balancers that have been configured in the cloud. Depending on which - services you choose, additional fields may appear in the rest of the dialog box. - Based on the guest network type selected, you can see the following supported - services: - - - - - Supported Services - Description - Isolated - Shared - - - - - DHCP - For more information, see . - Supported - Supported - - - DNS - For more information, see . - Supported - Supported - - - Load Balancer - If you select Load Balancer, you can choose the &PRODUCT; virtual - router or any other load balancers that have been configured in the - cloud. - Supported - Not Supported - - - Firewall - For more information, see . - Supported - Supported - - - Source NAT - If you select Source NAT, you can choose the &PRODUCT; virtual router - or any other Source NAT providers that have been configured in the - cloud. - Supported - Supported - - - Static NAT - If you select Static NAT, you can choose the &PRODUCT; virtual router - or any other Static NAT providers that have been configured in the - cloud. - Supported - Supported - - - Port Forwarding - If you select Port Forwarding, you can choose the &PRODUCT; virtual - router or any other Port Forwarding providers that have been configured in the - cloud. - Supported - Supported - - - VPN - For more information, see . - Supported - Supported - - - User Data - For more information, see . - Supported - Supported - - - Network ACL - For more information, see . - Supported - Supported - - - Security Groups - For more information, see . - Supported - Supported - - - - - - - System Offering: Available only when the service - provider for any of the services selected is Virtual Router. Choose the system service - offering that you want the virtual routers to use in this network. For example, if you - selected Load Balancer in Supported Services and select a Virtual Router to provide load - balancing, the System Offering field appears so you can choose between the &PRODUCT; - default system service offering and any custom system service offerings that have been - defined by the &PRODUCT; root administrator. For more information, see System Service - Offerings. - - - LB Isolation: Specify what type of load balancer - isolation you want for the network: Shared or Dedicated. - Dedicated: If you select dedicated LB isolation, a - dedicated load balancer device is assigned for the network from the pool of dedicated - load balancer devices provisioned in the zone. If no sufficient dedicated load balancer - devices are available in the zone, network creation fails. Dedicated device is a good - choice for the high-traffic networks that make full use of the device's - resources. - Shared: If you select shared LB isolation, a shared - load balancer device is assigned for the network from the pool of shared load balancer - devices provisioned in the zone. While provisioning &PRODUCT; picks the shared load - balancer device that is used by the least number of accounts. Once the device reaches - its maximum capacity, the device will not be allocated to a new account. - - - Mode: You can select either Inline mode or Side by - Side mode: - Inline mode: Supported only for Juniper SRX - firewall and BigF5 load balancer devices. In inline mode, a firewall device is placed in - front of a load balancing device. The firewall acts as the gateway for all the incoming - traffic, then redirect the load balancing traffic to the load balancer behind it. The - load balancer in this case will not have the direct access to the public network. - Side by Side: In side by side mode, a firewall - device is deployed in parallel with the load balancer device. So the traffic to the load - balancer public IP is not routed through the firewall, and therefore, is exposed to the - public network. - - - Associate Public IP: Select this option if you want - to assign a public IP address to the VMs deployed in the guest network. This option is - available only if - - - Guest network is shared. + Creating a New Network Offering + To create a network offering: + + Log in with admin privileges to the &PRODUCT; UI. + In the left navigation bar, click Service Offerings. + In Select Offering, choose Network Offering. + Click Add Network Offering. + In the dialog, make the following choices: + + Name. Any desired name for the network offering + Description. A short description of the offering that can be displayed to users + Network Rate. Allowed data transfer rate in MB per second + Traffic Type. The type of network traffic that will be carried on the network + Guest Type. Choose whether the guest network is isolated or shared. For a description of these terms, see + Specify VLAN. (Isolated guest networks only) Indicate whether a VLAN should be specified when this offering is used + Supported Services. Select one or more of the possible network services. For some services, you must also choose the service provider; for example, if you select Load Balancer, you can choose the &PRODUCT; virtual router or any other load balancers that have been configured in the cloud. Depending on which services you choose, additional fields may appear in the rest of the dialog box.Based on the guest network type selected, you can see the following supported services: + + + + Supported Services + Description + Isolated + Shared + + + + + DHCP + + Supported + Supported + + + DNS + + Supported + Supported + + + Load Balancer + If you select Load Balancer, you can choose the &PRODUCT; virtual router or any other load balancers that have been configured in the cloud. + Supported + Supported + + + Source NAT + If you select Source NAT, you can choose the &PRODUCT; virtual router or any other Source NAT providers that have been configured in the cloud. + Supported + Supported + + + Static NAT + If you select Static NAT, you can choose the &PRODUCT; virtual router or any other Static NAT providers that have been configured in the cloud. + Supported + Supported + + + Port Forwarding + If you select Port Forwarding, you can choose the &PRODUCT; virtual router or any other Port Forwarding providers that have been configured in the cloud. + Supported + Not Supported + + + VPN + + Supported + Not Supported + + + User Data + + Not Supported + Supported + + + Security Groups + See . + Not Supported + Supported + + + + - - Supported load balancer provider is Netscaler. - - - StaticNAT is enabled. - - - Elastic IP is enabled. - - - For information on Elastic IP, see . - - - Redundant router capability: (v3.0.3 and greater) - Available only when Virtual Router is selected as the Source NAT provider. Select this - option if you want to use two virtual routers in the network for uninterrupted - connection: one operating as the master virtual router and the other as the backup. The - master virtual router receives requests from and sends responses to the user’s VM. The - backup virtual router is activated only when the master is down. After the failover, the - backup becomes the master virtual router. &PRODUCT; deploys the routers on different - hosts to ensure reliability if one host is down. - - - Conserve mode: Specify whether to use conserve - mode. In this mode, network resources are allocated only when the first virtual machine - starts in the network. When the conservative mode is off, the public IP can only be used - for a single service. For example, a public IP used for a port forwarding rule cannot be - used for defining other services, such as SaticNAT or load balancing. When the conserve - mode is on, you can define more than one service on the same public IP. - - If StaticNAT is enabled, irrespective of the status of the conserve mode, no port - forwarding or load balancing rule can be created for the IP. However, you can add the - firewall rules by using the createFirewallRule command. - - - - Tags: Network tag to specify which physical network - to use. - - - - - Click Add. - - + System Offering. If the service provider for any of the services selected in Supported Services is a virtual router, the System Offering field appears. Choose the system service offering that you want virtual routers to use in this network. For example, if you selected Load Balancer in Supported Services and selected a virtual router to provide load balancing, the System Offering field appears so you can choose between the &PRODUCT; default system service offering and any custom system service offerings that have been defined by the &PRODUCT; root administrator. For more information, see System Service Offerings. + Redundant router capability. (v3.0.3 and greater) Available only when Virtual Router is selected as the Source NAT provider. Select this option if you want to use two virtual routers in the network for uninterrupted connection: one operating as the master virtual router and the other as the backup. The master virtual router receives requests from and sends responses to the user’s VM. The backup virtual router is activated only when the master is down. After the failover, the backup becomes the master virtual router. &PRODUCT; deploys the routers on different hosts to ensure reliability if one host is down. + Conserve mode. Indicate whether to use conserve mode. In this mode, network resources are allocated only when the first virtual machine starts in the network + Tags. Network tag to specify which physical network to use + + Click Add. +
diff --git a/docs/en-US/elastic-ip.xml b/docs/en-US/elastic-ip.xml deleted file mode 100644 index fa3795ae0de..00000000000 --- a/docs/en-US/elastic-ip.xml +++ /dev/null @@ -1,73 +0,0 @@ - - -%BOOK_ENTITIES; -]> - -
- About Elastic IP - Elastic IP (EIP) addresses are the IP addresses that are associated with an account, and act - as static IP addresses. The account owner has the complete control over the Elastic IP addresses - that belong to the account. You can allocate an Elastic IP to a VM of your choice from the EIP - pool of your account. Later if required you can reassign the IP address to a different VM. This - feature is extremely helpful during VM failure. Instead of replacing the VM which is down, the - IP address can be reassigned to a new VM in your account. Similar to the public IP address, EIPs - are mapped to their associated private IP addresses by using StacticNAT. - The EIP work flow is as follows: - - - When a user VM is deployed, a public IP is automatically acquired from the pool of - public IPs configured in the zone. This IP is owned by the VM's account. - - - Each VM will have its own private IP. When the user VM starts, the public IP is mapped - to the private IP of the VM by using StaticNAT. - - - This default public IP will be released in two cases: - - - When the VM is stopped. When the VM starts, it again receives a new public IP, not - necessarily be the one allocated initially, from the pool of Public IPs. - - - The user acquires a public IP. This public IP associated with the account will not - be mapped to any private IP. However, the user can enable StaticNAT to associate this IP - to the private IP of a VM in the account. The StaticNAT rule for the public IP can be - disabled at any time. When StaticNAT is disabled, a new public IP is allocated from the - pool, which is not necessarily be the one allocated initially. - - - - - However, for the deployments where public IPs are limited resources, you have the - flexibility to choose not to allocate a public IP by default. From &PRODUCT; 3.0.6 onwards, you - can use the Associate public IP option to turn on or off the automatic public IP assignment in - the EIP-enabled Basic zones. If you turn off the automatic public IP assignment while creating a - network offering, only a private IP is assigned to a VM when it's deployed with the same network - offering. Later, the user can acquire an IP for the VM and enable staticNAT. The section gives you more information on the Associate - public IP option. - - The Associate public IP feature is designed only for the user VMs. The System VMs continue - to get both public IP and private by default irrespective of the network offering - configuration. - - In the case of new deployments, which uses the default shared network offering with EIP - and ELB services to create shared network in the Basic zone, will continue allocating public IPs - to each user VMs. -
diff --git a/docs/en-US/networks.xml b/docs/en-US/networks.xml index 8a0f9fa357f..a7b9ea12466 100644 --- a/docs/en-US/networks.xml +++ b/docs/en-US/networks.xml @@ -43,7 +43,6 @@ - \ No newline at end of file diff --git a/docs/en-US/virtual-machines.xml b/docs/en-US/virtual-machines.xml index d0ab01520fc..7c74932b649 100644 --- a/docs/en-US/virtual-machines.xml +++ b/docs/en-US/virtual-machines.xml @@ -27,7 +27,6 @@ - From 1e7450173923c8de6e29e8ad505bcb1369ee2d8d Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Thu, 13 Dec 2012 09:40:39 -0500 Subject: [PATCH 077/145] CLOUDSTACK-594: Updating the xenserver java bindings used by cloudstack. Updating the java bindings that are used in cloudstack with the latest one. This is part 1 of the change and it removes the older bindings. 1. https://reviews.apache.org/r/8566/ - removes the old bindings. 2. https://reviews.apache.org/r/8567/ - introduces the latest bindings. 3. https://reviews.apache.org/r/8568/ - adds the customization's made to them for cloudstack. Signed-off-by: Chip Childers --- .../src/com/xensource/xenapi/APIVersion.java | 100 - .../src/com/xensource/xenapi/Auth.java | 112 - .../src/com/xensource/xenapi/Blob.java | 401 - .../src/com/xensource/xenapi/Bond.java | 393 - .../src/com/xensource/xenapi/Connection.java | 385 - .../src/com/xensource/xenapi/Console.java | 414 - .../src/com/xensource/xenapi/Crashdump.java | 353 - .../src/com/xensource/xenapi/DataSource.java | 159 - .../src/com/xensource/xenapi/Event.java | 258 - .../src/com/xensource/xenapi/Host.java | 2769 ---- .../src/com/xensource/xenapi/HostCpu.java | 531 - .../com/xensource/xenapi/HostCrashdump.java | 412 - .../src/com/xensource/xenapi/HostMetrics.java | 368 - .../src/com/xensource/xenapi/HostPatch.java | 547 - .../src/com/xensource/xenapi/Marshalling.java | 76 - .../src/com/xensource/xenapi/Message.java | 315 - .../src/com/xensource/xenapi/Network.java | 727 - .../src/com/xensource/xenapi/PBD.java | 537 - .../src/com/xensource/xenapi/PIF.java | 1231 -- .../src/com/xensource/xenapi/PIFMetrics.java | 528 - .../src/com/xensource/xenapi/Pool.java | 2294 ---- .../src/com/xensource/xenapi/PoolPatch.java | 622 - .../src/com/xensource/xenapi/Role.java | 359 - .../src/com/xensource/xenapi/SM.java | 523 - .../src/com/xensource/xenapi/SR.java | 1477 -- .../src/com/xensource/xenapi/Secret.java | 312 - .../src/com/xensource/xenapi/Session.java | 670 - .../src/com/xensource/xenapi/Subject.java | 391 - .../src/com/xensource/xenapi/Task.java | 683 - .../src/com/xensource/xenapi/Tunnel.java | 469 - .../src/com/xensource/xenapi/Types.java | 11096 ---------------- .../src/com/xensource/xenapi/User.java | 379 - .../src/com/xensource/xenapi/VBD.java | 1156 -- .../src/com/xensource/xenapi/VBDMetrics.java | 344 - .../src/com/xensource/xenapi/VDI.java | 1815 --- .../src/com/xensource/xenapi/VIF.java | 842 -- .../src/com/xensource/xenapi/VIFMetrics.java | 344 - .../src/com/xensource/xenapi/VLAN.java | 416 - .../src/com/xensource/xenapi/VM.java | 4270 ------ .../com/xensource/xenapi/VMGuestMetrics.java | 482 - .../src/com/xensource/xenapi/VMMetrics.java | 505 - .../src/com/xensource/xenapi/VMPP.java | 1153 -- .../src/com/xensource/xenapi/VTPM.java | 285 - .../com/xensource/xenapi/XenAPIObject.java | 35 - 44 files changed, 41538 deletions(-) delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Auth.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Blob.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Bond.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Connection.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Console.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/DataSource.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Event.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Host.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Message.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Network.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PBD.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PIF.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Pool.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Role.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/SM.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/SR.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Secret.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Session.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Subject.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Task.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Types.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/User.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VBD.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VDI.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VIF.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VLAN.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VM.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VMPP.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VTPM.java delete mode 100644 deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java diff --git a/deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java b/deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java deleted file mode 100644 index 763b98f2260..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -public enum APIVersion -{ - API_1_1, API_1_2, API_1_3, API_1_4, API_1_5, API_1_6, API_1_7, UNKNOWN; - - public static APIVersion latest() - { - return API_1_7; - } - - public static APIVersion fromMajorMinor(long major, long minor) - { - if (major == 1 && minor == 7) - { - return API_1_7; - } - else if (major == 1 && minor == 6) - { - return API_1_6; - } - else if (major == 1 && minor == 5) - { - return API_1_5; - } - else if (major == 1 && minor == 4) - { - return API_1_4; - } - else if (major == 1 && minor == 3) - { - return API_1_3; - } - else if (major == 1 && minor == 2) - { - return API_1_2; - } - else if (major == 1 && minor == 1) - { - return API_1_1; - } - else - { - return UNKNOWN; - } - } - - @Override - public String toString() - { - switch (this) - { - case API_1_1: - return "1.1"; - case API_1_2: - return "1.2"; - case API_1_3: - return "1.3"; - case API_1_4: - return "1.4"; - case API_1_5: - return "1.5"; - case API_1_6: - return "1.6"; - case API_1_7: - return "1.7"; - default: - return "Unknown"; - } - } -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Auth.java b/deps/XenServerJava/src/com/xensource/xenapi/Auth.java deleted file mode 100644 index 1bf615e1ea4..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Auth.java +++ /dev/null @@ -1,112 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * Management of remote authentication services - * - * @author Citrix Systems, Inc. - */ -public class Auth extends XenAPIObject { - - - public String toWireString() { - return null; - } - - /** - * This call queries the external directory service to obtain the subject_identifier as a string from the human-readable subject_name - * - * @param subjectName The human-readable subject_name, such as a username or a groupname - * @return the subject_identifier obtained from the external directory service - */ - public static String getSubjectIdentifier(Connection c, String subjectName) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "auth.get_subject_identifier"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * This call queries the external directory service to obtain the user information (e.g. username, organization etc) from the specified subject_identifier - * - * @param subjectIdentifier A string containing the subject_identifier, unique in the external directory service - * @return key-value pairs containing at least a key called subject_name - */ - public static Map getSubjectInformationFromIdentifier(Connection c, String subjectIdentifier) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "auth.get_subject_information_from_identifier"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * This calls queries the external directory service to obtain the transitively-closed set of groups that the the subject_identifier is member of. - * - * @param subjectIdentifier A string containing the subject_identifier, unique in the external directory service - * @return set of subject_identifiers that provides the group membership of subject_identifier passed as argument, it contains, recursively, all groups a subject_identifier is member of. - */ - public static Set getGroupMembership(Connection c, String subjectIdentifier) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "auth.get_group_membership"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Blob.java b/deps/XenServerJava/src/com/xensource/xenapi/Blob.java deleted file mode 100644 index 7d3ad582264..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Blob.java +++ /dev/null @@ -1,401 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A placeholder for a binary blob - * - * @author Citrix Systems, Inc. - */ -public class Blob extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Blob(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Blob, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Blob) - { - Blob other = (Blob) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Blob - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "size", this.size); - print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); - print.printf("%1$20s: %2$s\n", "mimeType", this.mimeType); - return writer.toString(); - } - - /** - * Convert a blob.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("size", this.size == null ? 0 : this.size); - map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); - map.put("mime_type", this.mimeType == null ? "" : this.mimeType); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * Size of the binary data, in bytes - */ - public Long size; - /** - * Time at which the data in the blob was last updated - */ - public Date lastUpdated; - /** - * The mime type associated with this object. Defaults to 'application/octet-stream' if the empty string is supplied - */ - public String mimeType; - } - - /** - * Get a record containing the current state of the given blob. - * - * @return all fields from the object - */ - public Blob.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBlobRecord(result); - } - - /** - * Get a reference to the blob instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Blob getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBlob(result); - } - - /** - * Get all the blob instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfBlob(result); - } - - /** - * Get the uuid field of the given blob. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given blob. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given blob. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the size field of the given blob. - * - * @return value of the field - */ - public Long getSize(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_size"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the last_updated field of the given blob. - * - * @return value of the field - */ - public Date getLastUpdated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_last_updated"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the mime_type field of the given blob. - * - * @return value of the field - */ - public String getMimeType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_mime_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Set the name/label field of the given blob. - * - * @param label New value to set - */ - public void setNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.set_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the name/description field of the given blob. - * - * @param description New value to set - */ - public void setNameDescription(Connection c, String description) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.set_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a placeholder for a binary blob - * - * @param mimeType The mime-type of the blob. Defaults to 'application/octet-stream' if the empty string is supplied - * @return The reference to the created blob - */ - public static Blob create(Connection c, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBlob(result); - } - - /** - * - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the blobs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfBlob(result); - } - - /** - * Return a map of blob references to blob records for all blobs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "blob.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfBlobBlobRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Bond.java b/deps/XenServerJava/src/com/xensource/xenapi/Bond.java deleted file mode 100644 index ee67e3c49e0..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Bond.java +++ /dev/null @@ -1,393 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * - * - * @author Citrix Systems, Inc. - */ -public class Bond extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Bond(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Bond, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Bond) - { - Bond other = (Bond) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Bond - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "master", this.master); - print.printf("%1$20s: %2$s\n", "slaves", this.slaves); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a Bond.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("master", this.master == null ? new PIF("OpaqueRef:NULL") : this.master); - map.put("slaves", this.slaves == null ? new LinkedHashSet() : this.slaves); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * The bonded interface - */ - public PIF master; - /** - * The interfaces which are part of this bond - */ - public Set slaves; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given Bond. - * - * @return all fields from the object - */ - public Bond.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBondRecord(result); - } - - /** - * Get a reference to the Bond instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Bond getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBond(result); - } - - /** - * Get the uuid field of the given Bond. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the master field of the given Bond. - * - * @return value of the field - */ - public PIF getMaster(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.get_master"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Get the slaves field of the given Bond. - * - * @return value of the field - */ - public Set getSlaves(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.get_slaves"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPIF(result); - } - - /** - * Get the other_config field of the given Bond. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given Bond. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given Bond. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given Bond. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create an interface bond - * - * @param network Network to add the bonded PIF to - * @param members PIFs to add to this bond - * @param MAC The MAC address to use on the bond itself. If this parameter is the empty string then the bond will inherit its MAC address from the first of the specified 'members' - * @return Task - */ - public static Task createAsync(Connection c, Network network, Set members, String MAC) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.Bond.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(members), Marshalling.toXMLRPC(MAC)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create an interface bond - * - * @param network Network to add the bonded PIF to - * @param members PIFs to add to this bond - * @param MAC The MAC address to use on the bond itself. If this parameter is the empty string then the bond will inherit its MAC address from the first of the specified 'members' - * @return The reference of the created Bond object - */ - public static Bond create(Connection c, Network network, Set members, String MAC) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(members), Marshalling.toXMLRPC(MAC)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBond(result); - } - - /** - * Destroy an interface bond - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.Bond.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy an interface bond - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the Bonds known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfBond(result); - } - - /** - * Return a map of Bond references to Bond records for all Bonds known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Bond.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfBondBondRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Connection.java b/deps/XenServerJava/src/com/xensource/xenapi/Connection.java deleted file mode 100644 index 6c205a2a605..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Connection.java +++ /dev/null @@ -1,385 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import java.net.URL; -import java.util.Map; -import java.util.TimeZone; - -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.client.XmlRpcClient; -import org.apache.xmlrpc.client.XmlRpcClientConfig; -import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; -import org.apache.xmlrpc.client.XmlRpcHttpClientConfig; -import org.apache.xmlrpc.client.XmlRpcSun15HttpTransportFactory; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.SessionAuthenticationFailed; -import com.xensource.xenapi.Types.XenAPIException; - -/** - * Represents a connection to a XenServer. Creating a new instance of this class initialises a new XmlRpcClient that is - * then used by all method calls: each method call in xenapi takes a Connection as a parameter, composes an XMLRPC - * method call, and dispatches it on the Connection's client via the dispatch method. - */ -public class Connection -{ - /** - * The version of the bindings that this class belongs to. - */ - public static final String BINDINGS_VERSION = "5.6.100-1"; - - /** - * true if the connection is to the Rio edition of XenServer. Certain function calls are not allowed. - * - * @deprecated Use getAPIVersion() instead. - */ - @Deprecated - public Boolean rioConnection = false; - - private APIVersion apiVersion; - - protected int _wait = 600; - - /** - * Updated when Session.login_with_password() is called. - */ - public APIVersion getAPIVersion() - { - return apiVersion; - } - - /** - * The opaque reference to the session used by this connection - */ - private String sessionReference; - - /** - * As seen by the xmlrpc library. From our point of view it's a server. - */ - private final XmlRpcClient client; - - private final boolean deprecatedConstructorUsed; - - /** - * Creates a connection to a particular server using a given username and password. This object can then be passed - * in to any other API calls. - * - * This constructor calls Session.loginWithPassword, passing itself as the first parameter. - * - * When this constructor is used, a call to dispose() (also called in the Connection's finalizer) will attempt a - * Session.logout on this connection. - * - * @deprecated Use a constructor that takes a URL as the first parameter instead. - */ - @Deprecated - public Connection(String client, String username, String password) throws java.net.MalformedURLException, - XmlRpcException, BadServerResponse, SessionAuthenticationFailed, XenAPIException - { - deprecatedConstructorUsed = true; - - // To login normally we call login_with_password(username, password, "1.X"). On rio this call fails and we - // should use login_with_password(username,password) instead, and note that we are talking to a rio host so that we - // can refuse to make certain miami-specific calls - final String ApiVersion = APIVersion.latest().toString(); - this.client = getClientFromURL(new URL(client)); - try - { - //first try to login the modern way - this.sessionReference = loginWithPassword(this.client, username, password, ApiVersion); - } catch (BadServerResponse e) - { - //oops, something went wrong - String[] errDesc = e.errorDescription; - //was the problem that the host was running rio? If so it will have complained that it got three parameters - //instead of two. Let us carefully verify the details of this complaint - if (0 == errDesc[0].compareTo("MESSAGE_PARAMETER_COUNT_MISMATCH") - && 0 == errDesc[1].compareTo("session.login_with_password") - && 0 == errDesc[2].compareTo("2") - && 0 == errDesc[3].compareTo("3")) - { - //and if so, we can have another go, using the older login method, and see how that goes. - this.sessionReference = loginWithPassword(this.client, username, password); - //success!. Note that we are talking to an old host on this connection - this.rioConnection = true; - } else - { - //Hmm... Can't solve this here. Let upstairs know about the problem. - throw e; - } - } - - try - { - setAPIVersion(new Session(sessionReference)); - } - catch (XenAPIException exn) - { - dispose(); - throw exn; - } - catch (XmlRpcException exn) - { - dispose(); - throw exn; - } - } - - /** - * Creates a connection to a particular server using a given username and password. This object can then be passed - * in to any other API calls. - * - * Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it, - * passing the Connection as a parameter. No attempt to connect to the server is made until login is called. - * - * When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually - * logging out the Session. - */ - public Connection(URL url, int wait) - { - deprecatedConstructorUsed = false; - _wait = wait; - this.client = getClientFromURL(url); - } - - /** - * Creates a connection to a particular server using a given username and password. This object can then be passed - * in to any other API calls. - * - * The additional sessionReference parameter must be a reference to a logged-in Session. Any method calls on this - * Connection will use it. This constructor does not call Session.loginWithPassword, and dispose() on the resulting - * Connection object does not call Session.logout. The programmer is responsible for ensuring the Session is logged - * in and out correctly. - */ - public Connection(URL url, String sessionReference) - { - deprecatedConstructorUsed = false; - - this.client = getClientFromURL(url); - this.sessionReference = sessionReference; - } - - protected void finalize() throws Throwable - { - dispose(); - super.finalize(); - } - - /** - * Nothrow guarantee. - */ - public void dispose() - { - if (!deprecatedConstructorUsed) - { - // We only need to do the Session.logout if they used the old deprecated constructor. - return; - } - - try - { - if (sessionReference != null) - { - String method_call = "session.logout"; - Object[] method_params = { Marshalling.toXMLRPC(this.sessionReference) }; - client.execute(method_call, method_params); - sessionReference = null; - } - } - catch (XmlRpcException exn) - { - } - } - - /** - * @deprecated The programmer is now responsible for calling login/logout themselves. - */ - @Deprecated - private static String loginWithPassword(XmlRpcClient client, String username, String password) - throws BadServerResponse, XmlRpcException, SessionAuthenticationFailed - { - String method_call = "session.login_with_password"; - Object[] method_params = { Marshalling.toXMLRPC(username), Marshalling.toXMLRPC(password) }; - Map response = (Map) client.execute(method_call, method_params); - if (response.get("Status").equals("Success")) - { - return (String) response.get("Value"); - } else if (response.get("Status").equals("Failure")) - { - Object[] error = (Object[]) response.get("ErrorDescription"); - if (error[0].equals("SESSION_AUTHENTICATION_FAILED")) - { - throw new SessionAuthenticationFailed(); - } - } - throw new BadServerResponse(response); - } - - /** - * @deprecated The programmer is now responsible for calling login/logout themselves. - */ - @Deprecated - private static String loginWithPassword(XmlRpcClient client, String username, String password, String ApiVersion) - throws BadServerResponse, XmlRpcException, SessionAuthenticationFailed - { - String method_call = "session.login_with_password"; - Object[] method_params = { Marshalling.toXMLRPC(username), Marshalling.toXMLRPC(password), - Marshalling.toXMLRPC(ApiVersion) }; - Map response = (Map) client.execute(method_call, method_params); - if (response.get("Status").equals("Success")) - { - return (String) response.get("Value"); - } else if (response.get("Status").equals("Failure")) - { - Object[] error = (Object[]) response.get("ErrorDescription"); - if (error[0].equals("SESSION_AUTHENTICATION_FAILED")) - { - throw new SessionAuthenticationFailed(); - } - } - throw new BadServerResponse(response); - } - - private XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); - - public XmlRpcClientConfigImpl getConfig() - { - return config; - } - private XmlRpcClient getClientFromURL(URL url) - { - config.setTimeZone(TimeZone.getTimeZone("UTC")); - config.setServerURL(url); - config.setReplyTimeout(_wait * 1000); - config.setConnectionTimeout(5000); - XmlRpcClient client = new XmlRpcClient(); - client.setConfig(config); - return client; - } - - /* - * Because the binding calls are constructing their own parameter lists, they need to be able to get to - * the session reference directly. This is all rather ugly and needs redone - * Changed to public to allow easier integration with HTTP-level streaming interface, - * see CA-15447 - */ - public String getSessionReference() - { - return this.sessionReference; - } - - /** - * The (auto-generated parts of) the bindings dispatch XMLRPC calls on this Connection's client through this method. - */ - protected Map dispatch(String method_call, Object[] method_params) throws XmlRpcException, XenAPIException - { - Map response = (Map) client.execute(method_call, method_params); - - if (!deprecatedConstructorUsed) - { - // We are using the new-style constructor which doesn't perform login. - // Set this Connection's Session reference from the value returned on the wire. - if (method_call.equals("session.login_with_password") && - response.get("Status").equals("Success")) - { - // Store the Session reference and ask the server what the - // API version it's using is. - Session session = Types.toSession(response.get("Value")); - sessionReference = session.ref; - setAPIVersion(session); - } - else if (method_call.equals("session.slave_local_login_with_password") && - response.get("Status").equals("Success")) - { - // Store the Session reference and assume API version 1.2. - sessionReference = Types.toSession(response.get("Value")).ref; - apiVersion = APIVersion.API_1_2; - } - else if (method_call.equals("session.logout")) - { - // Work around a bug in XenServer 5.0 and below. - // session.login_with_password should have rejected us with - // HOST_IS_SLAVE, but instead we don't find out until later. - // We don't want to leak the session, so we need to log out - // this session from the master instead. - if (response.get("Status").equals("Failure")) - { - Object[] error = (Object[]) response.get("ErrorDescription"); - if (error.length == 2 && error[0].equals("HOST_IS_SLAVE")) - { - try - { - URL client_url = - ((XmlRpcHttpClientConfig)client.getClientConfig()).getServerURL(); - Connection tmp_conn = - new Connection(new URL(client_url.getProtocol(), - (String)error[1], - client_url.getPort(), - client_url.getFile()), _wait); - tmp_conn.sessionReference = sessionReference; - try - { - Session.logout(tmp_conn); - } - finally - { - tmp_conn.dispose(); - } - } - catch (Exception exn2) - { - // Ignore -- we're going to throw HostIsSlave anyway. - } - } - } - - // Clear the stored Session reference. - this.sessionReference = null; - } - } - - return Types.checkResponse(response); - } - - - private void setAPIVersion(Session session) throws XenAPIException, XmlRpcException - { - try - { - long major = session.getThisHost(this).getAPIVersionMajor(this); - long minor = session.getThisHost(this).getAPIVersionMinor(this); - apiVersion = APIVersion.fromMajorMinor(major, minor); - } - catch (BadServerResponse exn) - { - apiVersion = APIVersion.API_1_1; - } - } -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Console.java b/deps/XenServerJava/src/com/xensource/xenapi/Console.java deleted file mode 100644 index e73e685a468..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Console.java +++ /dev/null @@ -1,414 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A console - * - * @author Citrix Systems, Inc. - */ -public class Console extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Console(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Console, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Console) - { - Console other = (Console) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Console - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "protocol", this.protocol); - print.printf("%1$20s: %2$s\n", "location", this.location); - print.printf("%1$20s: %2$s\n", "VM", this.VM); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a console.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("protocol", this.protocol == null ? Types.ConsoleProtocol.UNRECOGNIZED : this.protocol); - map.put("location", this.location == null ? "" : this.location); - map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * the protocol used by this console - */ - public Types.ConsoleProtocol protocol; - /** - * URI for the console service - */ - public String location; - /** - * VM to which this console is attached - */ - public VM VM; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given console. - * - * @return all fields from the object - */ - public Console.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toConsoleRecord(result); - } - - /** - * Get a reference to the console instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Console getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toConsole(result); - } - - /** - * Create a new console instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, Console.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.console.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new console instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static Console create(Connection c, Console.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toConsole(result); - } - - /** - * Destroy the specified console instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.console.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified console instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the uuid field of the given console. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the protocol field of the given console. - * - * @return value of the field - */ - public Types.ConsoleProtocol getProtocol(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_protocol"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toConsoleProtocol(result); - } - - /** - * Get the location field of the given console. - * - * @return value of the field - */ - public String getLocation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_location"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the VM field of the given console. - * - * @return value of the field - */ - public VM getVM(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_VM"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Get the other_config field of the given console. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given console. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given console. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given console. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the consoles known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfConsole(result); - } - - /** - * Return a map of console references to console records for all consoles known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "console.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfConsoleConsoleRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java b/deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java deleted file mode 100644 index 31cf4180c9f..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java +++ /dev/null @@ -1,353 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A VM crashdump - * - * @author Citrix Systems, Inc. - */ -public class Crashdump extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Crashdump(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Crashdump, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Crashdump) - { - Crashdump other = (Crashdump) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Crashdump - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "VM", this.VM); - print.printf("%1$20s: %2$s\n", "VDI", this.VDI); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a crashdump.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); - map.put("VDI", this.VDI == null ? new VDI("OpaqueRef:NULL") : this.VDI); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * the virtual machine - */ - public VM VM; - /** - * the virtual disk - */ - public VDI VDI; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given crashdump. - * - * @return all fields from the object - */ - public Crashdump.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toCrashdumpRecord(result); - } - - /** - * Get a reference to the crashdump instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Crashdump getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toCrashdump(result); - } - - /** - * Get the uuid field of the given crashdump. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the VM field of the given crashdump. - * - * @return value of the field - */ - public VM getVM(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.get_VM"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Get the VDI field of the given crashdump. - * - * @return value of the field - */ - public VDI getVDI(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.get_VDI"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Get the other_config field of the given crashdump. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given crashdump. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given crashdump. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given crashdump. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Destroy the specified crashdump - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.crashdump.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified crashdump - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the crashdumps known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfCrashdump(result); - } - - /** - * Return a map of crashdump references to crashdump records for all crashdumps known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "crashdump.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfCrashdumpCrashdumpRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/DataSource.java b/deps/XenServerJava/src/com/xensource/xenapi/DataSource.java deleted file mode 100644 index aebe39b7b1e..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/DataSource.java +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * Data sources for logging in RRDs - * - * @author Citrix Systems, Inc. - */ -public class DataSource extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - DataSource(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a DataSource, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof DataSource) - { - DataSource other = (DataSource) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a DataSource - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "enabled", this.enabled); - print.printf("%1$20s: %2$s\n", "standard", this.standard); - print.printf("%1$20s: %2$s\n", "units", this.units); - print.printf("%1$20s: %2$s\n", "min", this.min); - print.printf("%1$20s: %2$s\n", "max", this.max); - print.printf("%1$20s: %2$s\n", "value", this.value); - return writer.toString(); - } - - /** - * Convert a data_source.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("enabled", this.enabled == null ? false : this.enabled); - map.put("standard", this.standard == null ? false : this.standard); - map.put("units", this.units == null ? "" : this.units); - map.put("min", this.min == null ? 0.0 : this.min); - map.put("max", this.max == null ? 0.0 : this.max); - map.put("value", this.value == null ? 0.0 : this.value); - return map; - } - - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * true if the data source is being logged - */ - public Boolean enabled; - /** - * true if the data source is enabled by default. Non-default data sources cannot be disabled - */ - public Boolean standard; - /** - * the units of the value - */ - public String units; - /** - * the minimum value of the data source - */ - public Double min; - /** - * the maximum value of the data source - */ - public Double max; - /** - * current value of the data source - */ - public Double value; - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Event.java b/deps/XenServerJava/src/com/xensource/xenapi/Event.java deleted file mode 100644 index 36ebf457abf..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Event.java +++ /dev/null @@ -1,258 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * Asynchronous event registration and handling - * - * @author Citrix Systems, Inc. - */ -public class Event extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Event(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Event, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Event) - { - Event other = (Event) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Event - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "id", this.id); - print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp); - print.printf("%1$20s: %2$s\n", "clazz", this.clazz); - print.printf("%1$20s: %2$s\n", "operation", this.operation); - print.printf("%1$20s: %2$s\n", "ref", this.ref); - print.printf("%1$20s: %2$s\n", "objUuid", this.objUuid); - print.printf("%1$20s: %2$s\n", "snapshot", this.snapshot); - return writer.toString(); - } - - /** - * Convert a event.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("id", this.id == null ? 0 : this.id); - map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp); - map.put("class", this.clazz == null ? "" : this.clazz); - map.put("operation", this.operation == null ? Types.EventOperation.UNRECOGNIZED : this.operation); - map.put("ref", this.ref == null ? "" : this.ref); - map.put("obj_uuid", this.objUuid == null ? "" : this.objUuid); - map.put("snapshot", this.snapshot); - return map; - } - - /** - * An ID, monotonically increasing, and local to the current session - */ - public Long id; - /** - * The time at which the event occurred - */ - public Date timestamp; - /** - * The name of the class of the object that changed - */ - public String clazz; - /** - * The operation that was performed - */ - public Types.EventOperation operation; - /** - * A reference to the object that changed - */ - public String ref; - /** - * The uuid of the object that changed - */ - public String objUuid; - /** - * The record of the database object that was added, changed or deleted - * (the actual type will be VM.Record, VBD.Record or similar) - */ - public Object snapshot; - } - - /** - * Registers this session with the event system. Specifying the empty list will register for all classes. - * - * @param classes register for events for the indicated classes - * @return Task - */ - public static Task registerAsync(Connection c, Set classes) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.event.register"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Registers this session with the event system. Specifying the empty list will register for all classes. - * - * @param classes register for events for the indicated classes - */ - public static void register(Connection c, Set classes) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "event.register"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Unregisters this session with the event system - * - * @param classes remove this session's registration for the indicated classes - * @return Task - */ - public static Task unregisterAsync(Connection c, Set classes) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.event.unregister"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Unregisters this session with the event system - * - * @param classes remove this session's registration for the indicated classes - */ - public static void unregister(Connection c, Set classes) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "event.unregister"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Blocking call which returns a (possibly empty) batch of events - * - * @return the batch of events - */ - public static Set next(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SessionNotRegistered, - Types.EventsLost { - String method_call = "event.next"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfEventRecord(result); - } - - /** - * Return the ID of the next event to be generated by the system - * - * @return the event ID - */ - public static Long getCurrentId(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "event.get_current_id"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Host.java b/deps/XenServerJava/src/com/xensource/xenapi/Host.java deleted file mode 100644 index d17609838cb..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Host.java +++ /dev/null @@ -1,2769 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A physical host - * - * @author Citrix Systems, Inc. - */ -public class Host extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Host(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Host, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Host) - { - Host other = (Host) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Host - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "memoryOverhead", this.memoryOverhead); - print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); - print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); - print.printf("%1$20s: %2$s\n", "APIVersionMajor", this.APIVersionMajor); - print.printf("%1$20s: %2$s\n", "APIVersionMinor", this.APIVersionMinor); - print.printf("%1$20s: %2$s\n", "APIVersionVendor", this.APIVersionVendor); - print.printf("%1$20s: %2$s\n", "APIVersionVendorImplementation", this.APIVersionVendorImplementation); - print.printf("%1$20s: %2$s\n", "enabled", this.enabled); - print.printf("%1$20s: %2$s\n", "softwareVersion", this.softwareVersion); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "capabilities", this.capabilities); - print.printf("%1$20s: %2$s\n", "cpuConfiguration", this.cpuConfiguration); - print.printf("%1$20s: %2$s\n", "schedPolicy", this.schedPolicy); - print.printf("%1$20s: %2$s\n", "supportedBootloaders", this.supportedBootloaders); - print.printf("%1$20s: %2$s\n", "residentVMs", this.residentVMs); - print.printf("%1$20s: %2$s\n", "logging", this.logging); - print.printf("%1$20s: %2$s\n", "PIFs", this.PIFs); - print.printf("%1$20s: %2$s\n", "suspendImageSr", this.suspendImageSr); - print.printf("%1$20s: %2$s\n", "crashDumpSr", this.crashDumpSr); - print.printf("%1$20s: %2$s\n", "crashdumps", this.crashdumps); - print.printf("%1$20s: %2$s\n", "patches", this.patches); - print.printf("%1$20s: %2$s\n", "PBDs", this.PBDs); - print.printf("%1$20s: %2$s\n", "hostCPUs", this.hostCPUs); - print.printf("%1$20s: %2$s\n", "cpuInfo", this.cpuInfo); - print.printf("%1$20s: %2$s\n", "hostname", this.hostname); - print.printf("%1$20s: %2$s\n", "address", this.address); - print.printf("%1$20s: %2$s\n", "metrics", this.metrics); - print.printf("%1$20s: %2$s\n", "licenseParams", this.licenseParams); - print.printf("%1$20s: %2$s\n", "haStatefiles", this.haStatefiles); - print.printf("%1$20s: %2$s\n", "haNetworkPeers", this.haNetworkPeers); - print.printf("%1$20s: %2$s\n", "blobs", this.blobs); - print.printf("%1$20s: %2$s\n", "tags", this.tags); - print.printf("%1$20s: %2$s\n", "externalAuthType", this.externalAuthType); - print.printf("%1$20s: %2$s\n", "externalAuthServiceName", this.externalAuthServiceName); - print.printf("%1$20s: %2$s\n", "externalAuthConfiguration", this.externalAuthConfiguration); - print.printf("%1$20s: %2$s\n", "edition", this.edition); - print.printf("%1$20s: %2$s\n", "licenseServer", this.licenseServer); - print.printf("%1$20s: %2$s\n", "biosStrings", this.biosStrings); - print.printf("%1$20s: %2$s\n", "powerOnMode", this.powerOnMode); - print.printf("%1$20s: %2$s\n", "powerOnConfig", this.powerOnConfig); - print.printf("%1$20s: %2$s\n", "localCacheSr", this.localCacheSr); - return writer.toString(); - } - - /** - * Convert a host.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("memory_overhead", this.memoryOverhead == null ? 0 : this.memoryOverhead); - map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); - map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); - map.put("API_version_major", this.APIVersionMajor == null ? 0 : this.APIVersionMajor); - map.put("API_version_minor", this.APIVersionMinor == null ? 0 : this.APIVersionMinor); - map.put("API_version_vendor", this.APIVersionVendor == null ? "" : this.APIVersionVendor); - map.put("API_version_vendor_implementation", this.APIVersionVendorImplementation == null ? new HashMap() : this.APIVersionVendorImplementation); - map.put("enabled", this.enabled == null ? false : this.enabled); - map.put("software_version", this.softwareVersion == null ? new HashMap() : this.softwareVersion); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("capabilities", this.capabilities == null ? new LinkedHashSet() : this.capabilities); - map.put("cpu_configuration", this.cpuConfiguration == null ? new HashMap() : this.cpuConfiguration); - map.put("sched_policy", this.schedPolicy == null ? "" : this.schedPolicy); - map.put("supported_bootloaders", this.supportedBootloaders == null ? new LinkedHashSet() : this.supportedBootloaders); - map.put("resident_VMs", this.residentVMs == null ? new LinkedHashSet() : this.residentVMs); - map.put("logging", this.logging == null ? new HashMap() : this.logging); - map.put("PIFs", this.PIFs == null ? new LinkedHashSet() : this.PIFs); - map.put("suspend_image_sr", this.suspendImageSr == null ? new SR("OpaqueRef:NULL") : this.suspendImageSr); - map.put("crash_dump_sr", this.crashDumpSr == null ? new SR("OpaqueRef:NULL") : this.crashDumpSr); - map.put("crashdumps", this.crashdumps == null ? new LinkedHashSet() : this.crashdumps); - map.put("patches", this.patches == null ? new LinkedHashSet() : this.patches); - map.put("PBDs", this.PBDs == null ? new LinkedHashSet() : this.PBDs); - map.put("host_CPUs", this.hostCPUs == null ? new LinkedHashSet() : this.hostCPUs); - map.put("cpu_info", this.cpuInfo == null ? new HashMap() : this.cpuInfo); - map.put("hostname", this.hostname == null ? "" : this.hostname); - map.put("address", this.address == null ? "" : this.address); - map.put("metrics", this.metrics == null ? new HostMetrics("OpaqueRef:NULL") : this.metrics); - map.put("license_params", this.licenseParams == null ? new HashMap() : this.licenseParams); - map.put("ha_statefiles", this.haStatefiles == null ? new LinkedHashSet() : this.haStatefiles); - map.put("ha_network_peers", this.haNetworkPeers == null ? new LinkedHashSet() : this.haNetworkPeers); - map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); - map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); - map.put("external_auth_type", this.externalAuthType == null ? "" : this.externalAuthType); - map.put("external_auth_service_name", this.externalAuthServiceName == null ? "" : this.externalAuthServiceName); - map.put("external_auth_configuration", this.externalAuthConfiguration == null ? new HashMap() : this.externalAuthConfiguration); - map.put("edition", this.edition == null ? "" : this.edition); - map.put("license_server", this.licenseServer == null ? new HashMap() : this.licenseServer); - map.put("bios_strings", this.biosStrings == null ? new HashMap() : this.biosStrings); - map.put("power_on_mode", this.powerOnMode == null ? "" : this.powerOnMode); - map.put("power_on_config", this.powerOnConfig == null ? new HashMap() : this.powerOnConfig); - map.put("local_cache_sr", this.localCacheSr == null ? new SR("OpaqueRef:NULL") : this.localCacheSr); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * Virtualization memory overhead (bytes). - */ - public Long memoryOverhead; - /** - * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. - */ - public Set allowedOperations; - /** - * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. - */ - public Map currentOperations; - /** - * major version number - */ - public Long APIVersionMajor; - /** - * minor version number - */ - public Long APIVersionMinor; - /** - * identification of vendor - */ - public String APIVersionVendor; - /** - * details of vendor implementation - */ - public Map APIVersionVendorImplementation; - /** - * True if the host is currently enabled - */ - public Boolean enabled; - /** - * version strings - */ - public Map softwareVersion; - /** - * additional configuration - */ - public Map otherConfig; - /** - * Xen capabilities - */ - public Set capabilities; - /** - * The CPU configuration on this host. May contain keys such as "nr_nodes", "sockets_per_node", "cores_per_socket", or "threads_per_core" - */ - public Map cpuConfiguration; - /** - * Scheduler policy currently in force on this host - */ - public String schedPolicy; - /** - * a list of the bootloaders installed on the machine - */ - public Set supportedBootloaders; - /** - * list of VMs currently resident on host - */ - public Set residentVMs; - /** - * logging configuration - */ - public Map logging; - /** - * physical network interfaces - */ - public Set PIFs; - /** - * The SR in which VDIs for suspend images are created - */ - public SR suspendImageSr; - /** - * The SR in which VDIs for crash dumps are created - */ - public SR crashDumpSr; - /** - * Set of host crash dumps - */ - public Set crashdumps; - /** - * Set of host patches - */ - public Set patches; - /** - * physical blockdevices - */ - public Set PBDs; - /** - * The physical CPUs on this host - */ - public Set hostCPUs; - /** - * Details about the physical CPUs on this host - */ - public Map cpuInfo; - /** - * The hostname of this host - */ - public String hostname; - /** - * The address by which this host can be contacted from any other host in the pool - */ - public String address; - /** - * metrics associated with this host - */ - public HostMetrics metrics; - /** - * State of the current license - */ - public Map licenseParams; - /** - * The set of statefiles accessible from this host - */ - public Set haStatefiles; - /** - * The set of hosts visible via the network from this host - */ - public Set haNetworkPeers; - /** - * Binary blobs associated with this host - */ - public Map blobs; - /** - * user-specified tags for categorization purposes - */ - public Set tags; - /** - * type of external authentication service configured; empty if none configured. - */ - public String externalAuthType; - /** - * name of external authentication service configured; empty if none configured. - */ - public String externalAuthServiceName; - /** - * configuration specific to external authentication service - */ - public Map externalAuthConfiguration; - /** - * XenServer edition - */ - public String edition; - /** - * Contact information of the license server - */ - public Map licenseServer; - /** - * BIOS strings - */ - public Map biosStrings; - /** - * The power on mode - */ - public String powerOnMode; - /** - * The power on config - */ - public Map powerOnConfig; - /** - * The SR that is used as a local cache - */ - public SR localCacheSr; - } - - /** - * Get a record containing the current state of the given host. - * - * @return all fields from the object - */ - public Host.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostRecord(result); - } - - /** - * Get a reference to the host instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Host getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get all the host instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHost(result); - } - - /** - * Get the uuid field of the given host. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given host. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given host. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the memory/overhead field of the given host. - * - * @return value of the field - */ - public Long getMemoryOverhead(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_memory_overhead"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the allowed_operations field of the given host. - * - * @return value of the field - */ - public Set getAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostAllowedOperations(result); - } - - /** - * Get the current_operations field of the given host. - * - * @return value of the field - */ - public Map getCurrentOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_current_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringHostAllowedOperations(result); - } - - /** - * Get the API_version/major field of the given host. - * - * @return value of the field - */ - public Long getAPIVersionMajor(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_API_version_major"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the API_version/minor field of the given host. - * - * @return value of the field - */ - public Long getAPIVersionMinor(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_API_version_minor"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the API_version/vendor field of the given host. - * - * @return value of the field - */ - public String getAPIVersionVendor(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_API_version_vendor"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the API_version/vendor_implementation field of the given host. - * - * @return value of the field - */ - public Map getAPIVersionVendorImplementation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_API_version_vendor_implementation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the enabled field of the given host. - * - * @return value of the field - */ - public Boolean getEnabled(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the software_version field of the given host. - * - * @return value of the field - */ - public Map getSoftwareVersion(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_software_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the other_config field of the given host. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the capabilities field of the given host. - * - * @return value of the field - */ - public Set getCapabilities(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_capabilities"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the cpu_configuration field of the given host. - * - * @return value of the field - */ - public Map getCpuConfiguration(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_cpu_configuration"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the sched_policy field of the given host. - * - * @return value of the field - */ - public String getSchedPolicy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_sched_policy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the supported_bootloaders field of the given host. - * - * @return value of the field - */ - public Set getSupportedBootloaders(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_supported_bootloaders"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the resident_VMs field of the given host. - * - * @return value of the field - */ - public Set getResidentVMs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_resident_VMs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVM(result); - } - - /** - * Get the logging field of the given host. - * - * @return value of the field - */ - public Map getLogging(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_logging"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the PIFs field of the given host. - * - * @return value of the field - */ - public Set getPIFs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_PIFs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPIF(result); - } - - /** - * Get the suspend_image_sr field of the given host. - * - * @return value of the field - */ - public SR getSuspendImageSr(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_suspend_image_sr"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Get the crash_dump_sr field of the given host. - * - * @return value of the field - */ - public SR getCrashDumpSr(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_crash_dump_sr"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Get the crashdumps field of the given host. - * - * @return value of the field - */ - public Set getCrashdumps(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_crashdumps"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostCrashdump(result); - } - - /** - * Get the patches field of the given host. - * - * @return value of the field - */ - public Set getPatches(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_patches"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostPatch(result); - } - - /** - * Get the PBDs field of the given host. - * - * @return value of the field - */ - public Set getPBDs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_PBDs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPBD(result); - } - - /** - * Get the host_CPUs field of the given host. - * - * @return value of the field - */ - public Set getHostCPUs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_host_CPUs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostCpu(result); - } - - /** - * Get the cpu_info field of the given host. - * - * @return value of the field - */ - public Map getCpuInfo(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_cpu_info"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the hostname field of the given host. - * - * @return value of the field - */ - public String getHostname(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_hostname"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the address field of the given host. - * - * @return value of the field - */ - public String getAddress(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_address"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the metrics field of the given host. - * - * @return value of the field - */ - public HostMetrics getMetrics(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_metrics"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostMetrics(result); - } - - /** - * Get the license_params field of the given host. - * - * @return value of the field - */ - public Map getLicenseParams(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_license_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the ha_statefiles field of the given host. - * - * @return value of the field - */ - public Set getHaStatefiles(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_ha_statefiles"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the ha_network_peers field of the given host. - * - * @return value of the field - */ - public Set getHaNetworkPeers(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_ha_network_peers"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the blobs field of the given host. - * - * @return value of the field - */ - public Map getBlobs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_blobs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringBlob(result); - } - - /** - * Get the tags field of the given host. - * - * @return value of the field - */ - public Set getTags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the external_auth_type field of the given host. - * - * @return value of the field - */ - public String getExternalAuthType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_external_auth_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the external_auth_service_name field of the given host. - * - * @return value of the field - */ - public String getExternalAuthServiceName(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_external_auth_service_name"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the external_auth_configuration field of the given host. - * - * @return value of the field - */ - public Map getExternalAuthConfiguration(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_external_auth_configuration"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the edition field of the given host. - * - * @return value of the field - */ - public String getEdition(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_edition"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the license_server field of the given host. - * - * @return value of the field - */ - public Map getLicenseServer(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_license_server"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the bios_strings field of the given host. - * - * @return value of the field - */ - public Map getBiosStrings(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_bios_strings"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the power_on_mode field of the given host. - * - * @return value of the field - */ - public String getPowerOnMode(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_power_on_mode"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the power_on_config field of the given host. - * - * @return value of the field - */ - public Map getPowerOnConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_power_on_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the local_cache_sr field of the given host. - * - * @return value of the field - */ - public SR getLocalCacheSr(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_local_cache_sr"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Set the name/label field of the given host. - * - * @param label New value to set - */ - public void setNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the name/description field of the given host. - * - * @param description New value to set - */ - public void setNameDescription(Connection c, String description) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given host. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given host. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given host. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the logging field of the given host. - * - * @param logging New value to set - */ - public void setLogging(Connection c, Map logging) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_logging"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(logging)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the logging field of the given host. - * - * @param key Key to add - * @param value Value to add - */ - public void addToLogging(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.add_to_logging"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the logging field of the given host. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromLogging(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.remove_from_logging"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the suspend_image_sr field of the given host. - * - * @param suspendImageSr New value to set - */ - public void setSuspendImageSr(Connection c, SR suspendImageSr) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_suspend_image_sr"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(suspendImageSr)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the crash_dump_sr field of the given host. - * - * @param crashDumpSr New value to set - */ - public void setCrashDumpSr(Connection c, SR crashDumpSr) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_crash_dump_sr"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(crashDumpSr)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the hostname field of the given host. - * - * @param hostname New value to set - */ - public void setHostname(Connection c, String hostname) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_hostname"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(hostname)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the address field of the given host. - * - * @param address New value to set - */ - public void setAddress(Connection c, String address) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_address"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(address)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the tags field of the given host. - * - * @param tags New value to set - */ - public void setTags(Connection c, Set tags) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given value to the tags field of the given host. If the value is already in that Set, then do nothing. - * - * @param value New value to add - */ - public void addTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.add_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given value from the tags field of the given host. If the value is not in that Set, then do nothing. - * - * @param value Value to remove - */ - public void removeTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.remove_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the license_server field of the given host. - * - * @param licenseServer New value to set - */ - public void setLicenseServer(Connection c, Map licenseServer) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_license_server"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(licenseServer)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the license_server field of the given host. - * - * @param key Key to add - * @param value Value to add - */ - public void addToLicenseServer(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.add_to_license_server"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the license_server field of the given host. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromLicenseServer(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.remove_from_license_server"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Puts the host into a state in which no new VMs can be started. Currently active VMs on the host continue to execute. - * - * @return Task - */ - public Task disableAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.disable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Puts the host into a state in which no new VMs can be started. Currently active VMs on the host continue to execute. - * - */ - public void disable(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.disable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Puts the host into a state in which new VMs can be started. - * - * @return Task - */ - public Task enableAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.enable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Puts the host into a state in which new VMs can be started. - * - */ - public void enable(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.enable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Shutdown the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.) - * - * @return Task - */ - public Task shutdownAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.shutdown"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Shutdown the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.) - * - */ - public void shutdown(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.shutdown"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Reboot the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.) - * - * @return Task - */ - public Task rebootAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.reboot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Reboot the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.) - * - */ - public void reboot(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.reboot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the host xen dmesg. - * - * @return Task - */ - public Task dmesgAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.dmesg"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Get the host xen dmesg. - * - * @return dmesg string - */ - public String dmesg(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.dmesg"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the host xen dmesg, and clear the buffer. - * - * @return Task - */ - public Task dmesgClearAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.dmesg_clear"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Get the host xen dmesg, and clear the buffer. - * - * @return dmesg string - */ - public String dmesgClear(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.dmesg_clear"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the host's log file - * - * @return Task - */ - public Task getLogAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.get_log"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Get the host's log file - * - * @return The contents of the host's primary log file - */ - public String getLog(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_log"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Inject the given string as debugging keys into Xen - * - * @param keys The keys to send - * @return Task - */ - public Task sendDebugKeysAsync(Connection c, String keys) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.send_debug_keys"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(keys)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Inject the given string as debugging keys into Xen - * - * @param keys The keys to send - */ - public void sendDebugKeys(Connection c, String keys) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.send_debug_keys"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(keys)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Run xen-bugtool --yestoall and upload the output to Citrix support - * - * @param url The URL to upload to - * @param options Extra configuration operations - * @return Task - */ - public Task bugreportUploadAsync(Connection c, String url, Map options) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.bugreport_upload"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Run xen-bugtool --yestoall and upload the output to Citrix support - * - * @param url The URL to upload to - * @param options Extra configuration operations - */ - public void bugreportUpload(Connection c, String url, Map options) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.bugreport_upload"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * List all supported methods - * - * @return The name of every supported method. - */ - public static Set listMethods(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.list_methods"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Apply a new license to a host - * - * @param contents The contents of the license file, base64 encoded - * @return Task - */ - public Task licenseApplyAsync(Connection c, String contents) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.LicenseProcessingError { - String method_call = "Async.host.license_apply"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(contents)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Apply a new license to a host - * - * @param contents The contents of the license file, base64 encoded - */ - public void licenseApply(Connection c, String contents) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.LicenseProcessingError { - String method_call = "host.license_apply"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(contents)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Destroy specified host record in database - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy specified host record in database - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Attempt to power-on the host (if the capability exists). - * - * @return Task - */ - public Task powerOnAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.power_on"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Attempt to power-on the host (if the capability exists). - * - */ - public void powerOn(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.power_on"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call disables HA on the local host. This should only be used with extreme care. - * - */ - public static void emergencyHaDisable(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.emergency_ha_disable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @return A set of data sources - */ - public Set getDataSources(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_data_sources"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfDataSourceRecord(result); - } - - /** - * Start recording the specified data source - * - * @param dataSource The data source to record - */ - public void recordDataSource(Connection c, String dataSource) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.record_data_source"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Query the latest value of the specified data source - * - * @param dataSource The data source to query - * @return The latest value, averaged over the last 5 seconds - */ - public Double queryDataSource(Connection c, String dataSource) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.query_data_source"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Forget the recorded statistics related to the specified data source - * - * @param dataSource The data source whose archives are to be forgotten - */ - public void forgetDataSourceArchives(Connection c, String dataSource) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.forget_data_source_archives"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Check this host can be evacuated. - * - * @return Task - */ - public Task assertCanEvacuateAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.assert_can_evacuate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Check this host can be evacuated. - * - */ - public void assertCanEvacuate(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.assert_can_evacuate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a set of VMs which prevent the host being evacuated, with per-VM error codes - * - * @return Task - */ - public Task getVmsWhichPreventEvacuationAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.get_vms_which_prevent_evacuation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Return a set of VMs which prevent the host being evacuated, with per-VM error codes - * - * @return VMs which block evacuation together with reasons - */ - public Map> getVmsWhichPreventEvacuation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_vms_which_prevent_evacuation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVMSetOfString(result); - } - - /** - * Return a set of VMs which are not co-operating with the host's memory control system - * - * @return Task - */ - public Task getUncooperativeResidentVMsAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.get_uncooperative_resident_VMs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Return a set of VMs which are not co-operating with the host's memory control system - * - * @return VMs which are not co-operating - */ - public Set getUncooperativeResidentVMs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_uncooperative_resident_VMs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVM(result); - } - - /** - * Migrate all VMs off of this host, where possible. - * - * @return Task - */ - public Task evacuateAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.evacuate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Migrate all VMs off of this host, where possible. - * - */ - public void evacuate(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.evacuate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Re-configure syslog logging - * - * @return Task - */ - public Task syslogReconfigureAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.syslog_reconfigure"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Re-configure syslog logging - * - */ - public void syslogReconfigure(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.syslog_reconfigure"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Reconfigure the management network interface - * - * @param pif reference to a PIF object corresponding to the management interface - * @return Task - */ - public static Task managementReconfigureAsync(Connection c, PIF pif) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.management_reconfigure"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(pif)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Reconfigure the management network interface - * - * @param pif reference to a PIF object corresponding to the management interface - */ - public static void managementReconfigure(Connection c, PIF pif) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.management_reconfigure"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(pif)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Reconfigure the management network interface. Should only be used if Host.management_reconfigure is impossible because the network configuration is broken. - * - * @param iface name of the interface to use as a management interface - */ - public static void localManagementReconfigure(Connection c, String iface) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.local_management_reconfigure"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(iface)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Disable the management network interface - * - */ - public static void managementDisable(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.management_disable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @return An XML fragment containing the system status capabilities. - */ - public String getSystemStatusCapabilities(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_system_status_capabilities"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Restarts the agent after a 10 second pause. WARNING: this is a dangerous operation. Any operations in progress will be aborted, and unrecoverable data loss may occur. The caller is responsible for ensuring that there are no operations in progress when this method is called. - * - * @return Task - */ - public Task restartAgentAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.restart_agent"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Restarts the agent after a 10 second pause. WARNING: this is a dangerous operation. Any operations in progress will be aborted, and unrecoverable data loss may occur. The caller is responsible for ensuring that there are no operations in progress when this method is called. - * - */ - public void restartAgent(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.restart_agent"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Shuts the agent down after a 10 second pause. WARNING: this is a dangerous operation. Any operations in progress will be aborted, and unrecoverable data loss may occur. The caller is responsible for ensuring that there are no operations in progress when this method is called. - * - */ - public static void shutdownAgent(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.shutdown_agent"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the host name to the specified string. Both the API and lower-level system hostname are changed immediately. - * - * @param hostname The new host name - */ - public void setHostnameLive(Connection c, String hostname) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.HostNameInvalid { - String method_call = "host.set_hostname_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(hostname)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Computes the amount of free memory on the host. - * - * @return Task - */ - public Task computeFreeMemoryAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.compute_free_memory"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Computes the amount of free memory on the host. - * - * @return the amount of free memory on the host. - */ - public Long computeFreeMemory(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.compute_free_memory"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Computes the virtualization memory overhead of a host. - * - * @return Task - */ - public Task computeMemoryOverheadAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.compute_memory_overhead"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Computes the virtualization memory overhead of a host. - * - * @return the virtualization memory overhead of the host. - */ - public Long computeMemoryOverhead(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.compute_memory_overhead"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * This causes the synchronisation of the non-database data (messages, RRDs and so on) stored on the master to be synchronised with the host - * - */ - public void syncData(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.sync_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This causes the RRDs to be backed up to the master - * - * @param delay Delay in seconds from when the call is received to perform the backup - */ - public void backupRrds(Connection c, Double delay) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.backup_rrds"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(delay)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this host - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return Task - */ - public Task createNewBlobAsync(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this host - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return The reference of the blob, needed for populating its data - */ - public Blob createNewBlob(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBlob(result); - } - - /** - * Call a XenAPI plugin on this host - * - * @param plugin The name of the plugin - * @param fn The name of the function within the plugin - * @param args Arguments for the function - * @return Task - */ - public Task callPluginAsync(Connection c, String plugin, String fn, Map args) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.call_plugin"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(plugin), Marshalling.toXMLRPC(fn), Marshalling.toXMLRPC(args)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Call a XenAPI plugin on this host - * - * @param plugin The name of the plugin - * @param fn The name of the function within the plugin - * @param args Arguments for the function - * @return Result from the plugin - */ - public String callPlugin(Connection c, String plugin, String fn, Map args) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.call_plugin"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(plugin), Marshalling.toXMLRPC(fn), Marshalling.toXMLRPC(args)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * This call queries the host's clock for the current time - * - * @return The current time - */ - public Date getServertime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_servertime"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * This call queries the host's clock for the current time in the host's local timezone - * - * @return The current local time - */ - public Date getServerLocaltime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_server_localtime"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * This call enables external authentication on a host - * - * @param config A list of key-values containing the configuration data - * @param serviceName The name of the service - * @param authType The type of authentication (e.g. AD for Active Directory) - */ - public void enableExternalAuth(Connection c, Map config, String serviceName, String authType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.enable_external_auth"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config), Marshalling.toXMLRPC(serviceName), Marshalling.toXMLRPC(authType)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call disables external authentication on the local host - * - * @param config Optional parameters as a list of key-values containing the configuration data - */ - public void disableExternalAuth(Connection c, Map config) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.disable_external_auth"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Retrieves recommended host migrations to perform when evacuating the host from the wlb server. If a VM cannot be migrated from the host the reason is listed instead of a recommendation. - * - * @return Task - */ - public Task retrieveWlbEvacuateRecommendationsAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.retrieve_wlb_evacuate_recommendations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Retrieves recommended host migrations to perform when evacuating the host from the wlb server. If a VM cannot be migrated from the host the reason is listed instead of a recommendation. - * - * @return VMs and the reasons why they would block evacuation, or their target host recommended by the wlb server - */ - public Map> retrieveWlbEvacuateRecommendations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.retrieve_wlb_evacuate_recommendations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVMSetOfString(result); - } - - /** - * Get the installed server SSL certificate. - * - * @return Task - */ - public Task getServerCertificateAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.get_server_certificate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Get the installed server SSL certificate. - * - * @return The installed server SSL certificate, in PEM form. - */ - public String getServerCertificate(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_server_certificate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Change to another edition, or reactivate the current edition after a license has expired. This may be subject to the successful checkout of an appropriate license. - * - * @param edition The requested edition - */ - public void applyEdition(Connection c, String edition) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.apply_edition"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(edition)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Refresh the list of installed Supplemental Packs. - * - * @return Task - */ - public Task refreshPackInfoAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.refresh_pack_info"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Refresh the list of installed Supplemental Packs. - * - */ - public void refreshPackInfo(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.refresh_pack_info"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the power-on-mode, host, user and password - * - * @param powerOnMode power-on-mode can be empty,iLO,wake-on-lan, DRAC or other - * @param powerOnConfig Power on config - * @return Task - */ - public Task setPowerOnModeAsync(Connection c, String powerOnMode, Map powerOnConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host.set_power_on_mode"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(powerOnMode), Marshalling.toXMLRPC(powerOnConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the power-on-mode, host, user and password - * - * @param powerOnMode power-on-mode can be empty,iLO,wake-on-lan, DRAC or other - * @param powerOnConfig Power on config - */ - public void setPowerOnMode(Connection c, String powerOnMode, Map powerOnConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_power_on_mode"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(powerOnMode), Marshalling.toXMLRPC(powerOnConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the CPU features to be used after a reboot, if the given features string is valid. - * - * @param features The features string (32 hexadecimal digits) - */ - public void setCpuFeatures(Connection c, String features) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.set_cpu_features"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(features)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the feature mask, such that after a reboot all features of the CPU are enabled. - * - */ - public void resetCpuFeatures(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.reset_cpu_features"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Enable the use of a local SR for caching purposes - * - * @param sr The SR to use as a local cache - */ - public void enableLocalStorageCaching(Connection c, SR sr) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.enable_local_storage_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Disable the use of a local SR for caching purposes - * - */ - public void disableLocalStorageCaching(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.disable_local_storage_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the hosts known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHost(result); - } - - /** - * Return a map of host references to host records for all hosts known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfHostHostRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java b/deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java deleted file mode 100644 index 7c7809e0897..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java +++ /dev/null @@ -1,531 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A physical CPU - * - * @author Citrix Systems, Inc. - */ -public class HostCpu extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - HostCpu(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a HostCpu, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof HostCpu) - { - HostCpu other = (HostCpu) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a HostCpu - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "host", this.host); - print.printf("%1$20s: %2$s\n", "number", this.number); - print.printf("%1$20s: %2$s\n", "vendor", this.vendor); - print.printf("%1$20s: %2$s\n", "speed", this.speed); - print.printf("%1$20s: %2$s\n", "modelname", this.modelname); - print.printf("%1$20s: %2$s\n", "family", this.family); - print.printf("%1$20s: %2$s\n", "model", this.model); - print.printf("%1$20s: %2$s\n", "stepping", this.stepping); - print.printf("%1$20s: %2$s\n", "flags", this.flags); - print.printf("%1$20s: %2$s\n", "features", this.features); - print.printf("%1$20s: %2$s\n", "utilisation", this.utilisation); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a host_cpu.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); - map.put("number", this.number == null ? 0 : this.number); - map.put("vendor", this.vendor == null ? "" : this.vendor); - map.put("speed", this.speed == null ? 0 : this.speed); - map.put("modelname", this.modelname == null ? "" : this.modelname); - map.put("family", this.family == null ? 0 : this.family); - map.put("model", this.model == null ? 0 : this.model); - map.put("stepping", this.stepping == null ? "" : this.stepping); - map.put("flags", this.flags == null ? "" : this.flags); - map.put("features", this.features == null ? "" : this.features); - map.put("utilisation", this.utilisation == null ? 0.0 : this.utilisation); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * the host the CPU is in - */ - public Host host; - /** - * the number of the physical CPU within the host - */ - public Long number; - /** - * the vendor of the physical CPU - */ - public String vendor; - /** - * the speed of the physical CPU - */ - public Long speed; - /** - * the model name of the physical CPU - */ - public String modelname; - /** - * the family (number) of the physical CPU - */ - public Long family; - /** - * the model number of the physical CPU - */ - public Long model; - /** - * the stepping of the physical CPU - */ - public String stepping; - /** - * the flags of the physical CPU (a decoded version of the features field) - */ - public String flags; - /** - * the physical CPU feature bitmap - */ - public String features; - /** - * the current CPU utilisation - */ - public Double utilisation; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given host_cpu. - * @deprecated - * - * @return all fields from the object - */ - @Deprecated public HostCpu.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostCpuRecord(result); - } - - /** - * Get a reference to the host_cpu instance with the specified UUID. - * @deprecated - * - * @param uuid UUID of object to return - * @return reference to the object - */ - @Deprecated public static HostCpu getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostCpu(result); - } - - /** - * Get the uuid field of the given host_cpu. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the host field of the given host_cpu. - * - * @return value of the field - */ - public Host getHost(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_host"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the number field of the given host_cpu. - * - * @return value of the field - */ - public Long getNumber(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_number"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the vendor field of the given host_cpu. - * - * @return value of the field - */ - public String getVendor(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_vendor"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the speed field of the given host_cpu. - * - * @return value of the field - */ - public Long getSpeed(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_speed"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the modelname field of the given host_cpu. - * - * @return value of the field - */ - public String getModelname(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_modelname"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the family field of the given host_cpu. - * - * @return value of the field - */ - public Long getFamily(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_family"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the model field of the given host_cpu. - * - * @return value of the field - */ - public Long getModel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_model"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the stepping field of the given host_cpu. - * - * @return value of the field - */ - public String getStepping(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_stepping"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the flags field of the given host_cpu. - * - * @return value of the field - */ - public String getFlags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_flags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the features field of the given host_cpu. - * - * @return value of the field - */ - public String getFeatures(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_features"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the utilisation field of the given host_cpu. - * - * @return value of the field - */ - public Double getUtilisation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_utilisation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the other_config field of the given host_cpu. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given host_cpu. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given host_cpu. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given host_cpu. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the host_cpus known to the system. - * @deprecated - * - * @return references to all objects - */ - @Deprecated public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostCpu(result); - } - - /** - * Return a map of host_cpu references to host_cpu records for all host_cpus known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_cpu.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfHostCpuHostCpuRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java b/deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java deleted file mode 100644 index b166073185d..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java +++ /dev/null @@ -1,412 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * Represents a host crash dump - * - * @author Citrix Systems, Inc. - */ -public class HostCrashdump extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - HostCrashdump(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a HostCrashdump, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof HostCrashdump) - { - HostCrashdump other = (HostCrashdump) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a HostCrashdump - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "host", this.host); - print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp); - print.printf("%1$20s: %2$s\n", "size", this.size); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a host_crashdump.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); - map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp); - map.put("size", this.size == null ? 0 : this.size); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * Host the crashdump relates to - */ - public Host host; - /** - * Time the crash happened - */ - public Date timestamp; - /** - * Size of the crashdump - */ - public Long size; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given host_crashdump. - * - * @return all fields from the object - */ - public HostCrashdump.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostCrashdumpRecord(result); - } - - /** - * Get a reference to the host_crashdump instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static HostCrashdump getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostCrashdump(result); - } - - /** - * Get the uuid field of the given host_crashdump. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the host field of the given host_crashdump. - * - * @return value of the field - */ - public Host getHost(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_host"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the timestamp field of the given host_crashdump. - * - * @return value of the field - */ - public Date getTimestamp(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_timestamp"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the size field of the given host_crashdump. - * - * @return value of the field - */ - public Long getSize(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_size"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the other_config field of the given host_crashdump. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given host_crashdump. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given host_crashdump. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given host_crashdump. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Destroy specified host crash dump, removing it from the disk. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host_crashdump.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy specified host crash dump, removing it from the disk. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Upload the specified host crash dump to a specified URL - * - * @param url The URL to upload to - * @param options Extra configuration operations - * @return Task - */ - public Task uploadAsync(Connection c, String url, Map options) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host_crashdump.upload"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Upload the specified host crash dump to a specified URL - * - * @param url The URL to upload to - * @param options Extra configuration operations - */ - public void upload(Connection c, String url, Map options) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.upload"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the host_crashdumps known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostCrashdump(result); - } - - /** - * Return a map of host_crashdump references to host_crashdump records for all host_crashdumps known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_crashdump.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfHostCrashdumpHostCrashdumpRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java deleted file mode 100644 index 2a682c806d5..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java +++ /dev/null @@ -1,368 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * The metrics associated with a host - * - * @author Citrix Systems, Inc. - */ -public class HostMetrics extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - HostMetrics(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a HostMetrics, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof HostMetrics) - { - HostMetrics other = (HostMetrics) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a HostMetrics - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "memoryTotal", this.memoryTotal); - print.printf("%1$20s: %2$s\n", "memoryFree", this.memoryFree); - print.printf("%1$20s: %2$s\n", "live", this.live); - print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a host_metrics.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("memory_total", this.memoryTotal == null ? 0 : this.memoryTotal); - map.put("memory_free", this.memoryFree == null ? 0 : this.memoryFree); - map.put("live", this.live == null ? false : this.live); - map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * Total host memory (bytes) - */ - public Long memoryTotal; - /** - * Free host memory (bytes) - */ - public Long memoryFree; - /** - * Pool master thinks this host is live - */ - public Boolean live; - /** - * Time at which this information was last updated - */ - public Date lastUpdated; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given host_metrics. - * - * @return all fields from the object - */ - public HostMetrics.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostMetricsRecord(result); - } - - /** - * Get a reference to the host_metrics instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static HostMetrics getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostMetrics(result); - } - - /** - * Get the uuid field of the given host_metrics. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the memory/total field of the given host_metrics. - * - * @return value of the field - */ - public Long getMemoryTotal(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_memory_total"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the memory/free field of the given host_metrics. - * @deprecated - * - * @return value of the field - */ - @Deprecated public Long getMemoryFree(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_memory_free"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the live field of the given host_metrics. - * - * @return value of the field - */ - public Boolean getLive(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the last_updated field of the given host_metrics. - * - * @return value of the field - */ - public Date getLastUpdated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_last_updated"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the other_config field of the given host_metrics. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given host_metrics. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given host_metrics. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given host_metrics. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the host_metrics instances known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostMetrics(result); - } - - /** - * Return a map of host_metrics references to host_metrics records for all host_metrics instances known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_metrics.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfHostMetricsHostMetricsRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java b/deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java deleted file mode 100644 index b871ed90c85..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java +++ /dev/null @@ -1,547 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * Represents a patch stored on a server - * - * @author Citrix Systems, Inc. - */ -public class HostPatch extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - HostPatch(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a HostPatch, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof HostPatch) - { - HostPatch other = (HostPatch) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a HostPatch - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "version", this.version); - print.printf("%1$20s: %2$s\n", "host", this.host); - print.printf("%1$20s: %2$s\n", "applied", this.applied); - print.printf("%1$20s: %2$s\n", "timestampApplied", this.timestampApplied); - print.printf("%1$20s: %2$s\n", "size", this.size); - print.printf("%1$20s: %2$s\n", "poolPatch", this.poolPatch); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a host_patch.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("version", this.version == null ? "" : this.version); - map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); - map.put("applied", this.applied == null ? false : this.applied); - map.put("timestamp_applied", this.timestampApplied == null ? new Date(0) : this.timestampApplied); - map.put("size", this.size == null ? 0 : this.size); - map.put("pool_patch", this.poolPatch == null ? new PoolPatch("OpaqueRef:NULL") : this.poolPatch); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * Patch version number - */ - public String version; - /** - * Host the patch relates to - */ - public Host host; - /** - * True if the patch has been applied - */ - public Boolean applied; - /** - * Time the patch was applied - */ - public Date timestampApplied; - /** - * Size of the patch - */ - public Long size; - /** - * The patch applied - */ - public PoolPatch poolPatch; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given host_patch. - * - * @return all fields from the object - */ - public HostPatch.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostPatchRecord(result); - } - - /** - * Get a reference to the host_patch instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static HostPatch getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHostPatch(result); - } - - /** - * Get all the host_patch instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostPatch(result); - } - - /** - * Get the uuid field of the given host_patch. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given host_patch. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given host_patch. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the version field of the given host_patch. - * - * @return value of the field - */ - public String getVersion(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the host field of the given host_patch. - * - * @return value of the field - */ - public Host getHost(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_host"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the applied field of the given host_patch. - * - * @return value of the field - */ - public Boolean getApplied(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_applied"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the timestamp_applied field of the given host_patch. - * - * @return value of the field - */ - public Date getTimestampApplied(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_timestamp_applied"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the size field of the given host_patch. - * - * @return value of the field - */ - public Long getSize(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_size"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the pool_patch field of the given host_patch. - * - * @return value of the field - */ - public PoolPatch getPoolPatch(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_pool_patch"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPoolPatch(result); - } - - /** - * Get the other_config field of the given host_patch. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given host_patch. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given host_patch. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given host_patch. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Destroy the specified host patch, removing it from the disk. This does NOT reverse the patch - * @deprecated - * - * @return Task - */ - @Deprecated public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host_patch.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified host patch, removing it from the disk. This does NOT reverse the patch - * @deprecated - * - */ - @Deprecated public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Apply the selected patch and return its output - * @deprecated - * - * @return Task - */ - @Deprecated public Task applyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.host_patch.apply"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Apply the selected patch and return its output - * @deprecated - * - * @return the output of the patch application process - */ - @Deprecated public String apply(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.apply"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Return a list of all the host_patchs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostPatch(result); - } - - /** - * Return a map of host_patch references to host_patch records for all host_patchs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "host_patch.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfHostPatchHostPatchRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java b/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java deleted file mode 100644 index 2603381c643..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import java.util.*; - -/** - * Marshalls Java types onto the wire. - * Does not cope with records. Use individual record.toMap() - */ -public final class Marshalling { - /** - * Converts Integers to Strings - * and Sets to Lists recursively. - */ - public static Object toXMLRPC(Object o) { - if (o instanceof String || - o instanceof Boolean || - o instanceof Double || - o instanceof Date) { - return o; - } else if (o instanceof Long) { - return o.toString(); - } else if (o instanceof Map) { - Map result = new HashMap(); - Map m = (Map)o; - for (Object k : m.keySet()) - { - result.put(toXMLRPC(k), toXMLRPC(m.get(k))); - } - return result; - } else if (o instanceof Set) { - List result = new ArrayList(); - for (Object e : ((Set)o)) - { - result.add(toXMLRPC(e)); - } - return result; - } else if (o instanceof XenAPIObject) { - return ((XenAPIObject) o).toWireString(); - } else if (o instanceof Enum) { - return o.toString(); - }else if (o == null){ - return ""; - } else { - throw new RuntimeException ("=============don't know how to marshall:({[" + o + "]})"); - } - } -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Message.java b/deps/XenServerJava/src/com/xensource/xenapi/Message.java deleted file mode 100644 index d7b50360699..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Message.java +++ /dev/null @@ -1,315 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * An message for the attention of the administrator - * - * @author Citrix Systems, Inc. - */ -public class Message extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Message(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Message, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Message) - { - Message other = (Message) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Message - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "name", this.name); - print.printf("%1$20s: %2$s\n", "priority", this.priority); - print.printf("%1$20s: %2$s\n", "cls", this.cls); - print.printf("%1$20s: %2$s\n", "objUuid", this.objUuid); - print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp); - print.printf("%1$20s: %2$s\n", "body", this.body); - return writer.toString(); - } - - /** - * Convert a message.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name", this.name == null ? "" : this.name); - map.put("priority", this.priority == null ? 0 : this.priority); - map.put("cls", this.cls == null ? Types.Cls.UNRECOGNIZED : this.cls); - map.put("obj_uuid", this.objUuid == null ? "" : this.objUuid); - map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp); - map.put("body", this.body == null ? "" : this.body); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * The name of the message - */ - public String name; - /** - * The message priority, 0 being low priority - */ - public Long priority; - /** - * The class of the object this message is associated with - */ - public Types.Cls cls; - /** - * The uuid of the object this message is associated with - */ - public String objUuid; - /** - * The time at which the message was created - */ - public Date timestamp; - /** - * The body of the message - */ - public String body; - } - - /** - * - * - * @param name The name of the message - * @param priority The priority of the message - * @param cls The class of object this message is associated with - * @param objUuid The uuid of the object this message is associated with - * @param body The body of the message - * @return The reference of the created message - */ - public static Message create(Connection c, String name, Long priority, Types.Cls cls, String objUuid, String body) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(priority), Marshalling.toXMLRPC(cls), Marshalling.toXMLRPC(objUuid), Marshalling.toXMLRPC(body)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMessage(result); - } - - /** - * - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param cls The class of object - * @param objUuid The uuid of the object - * @param since The cutoff time - * @return The relevant messages - */ - public static Map get(Connection c, Types.Cls cls, String objUuid, Date since) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.get"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(cls), Marshalling.toXMLRPC(objUuid), Marshalling.toXMLRPC(since)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfMessageMessageRecord(result); - } - - /** - * - * - * @return The references to the messages - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfMessage(result); - } - - /** - * - * - * @param since The cutoff time - * @return The relevant messages - */ - public static Map getSince(Connection c, Date since) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.get_since"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(since)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfMessageMessageRecord(result); - } - - /** - * - * - * @return The message record - */ - public Message.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMessageRecord(result); - } - - /** - * - * - * @param uuid The uuid of the message - * @return The message reference - */ - public static Message getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMessage(result); - } - - /** - * - * - * @return The messages - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfMessageMessageRecord(result); - } - - /** - * - * - * @param expr The expression to match (not currently used) - * @return The messages - */ - public static Map getAllRecordsWhere(Connection c, String expr) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "message.get_all_records_where"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(expr)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfMessageMessageRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Network.java b/deps/XenServerJava/src/com/xensource/xenapi/Network.java deleted file mode 100644 index 7b1282d5ffc..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Network.java +++ /dev/null @@ -1,727 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A virtual network - * - * @author Citrix Systems, Inc. - */ -public class Network extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Network(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Network, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Network) - { - Network other = (Network) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Network - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); - print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); - print.printf("%1$20s: %2$s\n", "VIFs", this.VIFs); - print.printf("%1$20s: %2$s\n", "PIFs", this.PIFs); - print.printf("%1$20s: %2$s\n", "MTU", this.MTU); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "bridge", this.bridge); - print.printf("%1$20s: %2$s\n", "blobs", this.blobs); - print.printf("%1$20s: %2$s\n", "tags", this.tags); - return writer.toString(); - } - - /** - * Convert a network.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); - map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); - map.put("VIFs", this.VIFs == null ? new LinkedHashSet() : this.VIFs); - map.put("PIFs", this.PIFs == null ? new LinkedHashSet() : this.PIFs); - map.put("MTU", this.MTU == null ? 0 : this.MTU); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("bridge", this.bridge == null ? "" : this.bridge); - map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); - map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. - */ - public Set allowedOperations; - /** - * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. - */ - public Map currentOperations; - /** - * list of connected vifs - */ - public Set VIFs; - /** - * list of connected pifs - */ - public Set PIFs; - /** - * MTU in octets - */ - public Long MTU; - /** - * additional configuration - */ - public Map otherConfig; - /** - * name of the bridge corresponding to this network on the local host - */ - public String bridge; - /** - * Binary blobs associated with this network - */ - public Map blobs; - /** - * user-specified tags for categorization purposes - */ - public Set tags; - } - - /** - * Get a record containing the current state of the given network. - * - * @return all fields from the object - */ - public Network.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toNetworkRecord(result); - } - - /** - * Get a reference to the network instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Network getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toNetwork(result); - } - - /** - * Create a new network instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, Network.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.network.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new network instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static Network create(Connection c, Network.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toNetwork(result); - } - - /** - * Destroy the specified network instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.network.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified network instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get all the network instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfNetwork(result); - } - - /** - * Get the uuid field of the given network. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given network. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given network. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the allowed_operations field of the given network. - * - * @return value of the field - */ - public Set getAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfNetworkOperations(result); - } - - /** - * Get the current_operations field of the given network. - * - * @return value of the field - */ - public Map getCurrentOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_current_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringNetworkOperations(result); - } - - /** - * Get the VIFs field of the given network. - * - * @return value of the field - */ - public Set getVIFs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_VIFs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVIF(result); - } - - /** - * Get the PIFs field of the given network. - * - * @return value of the field - */ - public Set getPIFs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_PIFs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPIF(result); - } - - /** - * Get the MTU field of the given network. - * - * @return value of the field - */ - public Long getMTU(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_MTU"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the other_config field of the given network. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the bridge field of the given network. - * - * @return value of the field - */ - public String getBridge(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_bridge"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the blobs field of the given network. - * - * @return value of the field - */ - public Map getBlobs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_blobs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringBlob(result); - } - - /** - * Get the tags field of the given network. - * - * @return value of the field - */ - public Set getTags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Set the name/label field of the given network. - * - * @param label New value to set - */ - public void setNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.set_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the name/description field of the given network. - * - * @param description New value to set - */ - public void setNameDescription(Connection c, String description) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.set_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the MTU field of the given network. - * - * @param MTU New value to set - */ - public void setMTU(Connection c, Long MTU) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.set_MTU"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(MTU)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given network. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given network. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given network. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the tags field of the given network. - * - * @param tags New value to set - */ - public void setTags(Connection c, Set tags) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.set_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given value to the tags field of the given network. If the value is already in that Set, then do nothing. - * - * @param value New value to add - */ - public void addTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.add_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given value from the tags field of the given network. If the value is not in that Set, then do nothing. - * - * @param value Value to remove - */ - public void removeTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.remove_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this pool - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return Task - */ - public Task createNewBlobAsync(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.network.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this pool - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return The reference of the blob, needed for populating its data - */ - public Blob createNewBlob(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBlob(result); - } - - /** - * Return a list of all the networks known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfNetwork(result); - } - - /** - * Return a map of network references to network records for all networks known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "network.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfNetworkNetworkRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PBD.java b/deps/XenServerJava/src/com/xensource/xenapi/PBD.java deleted file mode 100644 index 0a1e60d354a..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PBD.java +++ /dev/null @@ -1,537 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * The physical block devices through which hosts access SRs - * - * @author Citrix Systems, Inc. - */ -public class PBD extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - PBD(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a PBD, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof PBD) - { - PBD other = (PBD) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a PBD - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "host", this.host); - print.printf("%1$20s: %2$s\n", "SR", this.SR); - print.printf("%1$20s: %2$s\n", "deviceConfig", this.deviceConfig); - print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a PBD.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); - map.put("SR", this.SR == null ? new SR("OpaqueRef:NULL") : this.SR); - map.put("device_config", this.deviceConfig == null ? new HashMap() : this.deviceConfig); - map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * physical machine on which the pbd is available - */ - public Host host; - /** - * the storage repository that the pbd realises - */ - public SR SR; - /** - * a config string to string map that is provided to the host's SR-backend-driver - */ - public Map deviceConfig; - /** - * is the SR currently attached on this host? - */ - public Boolean currentlyAttached; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given PBD. - * - * @return all fields from the object - */ - public PBD.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPBDRecord(result); - } - - /** - * Get a reference to the PBD instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static PBD getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPBD(result); - } - - /** - * Create a new PBD instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, PBD.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PBD.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new PBD instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static PBD create(Connection c, PBD.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPBD(result); - } - - /** - * Destroy the specified PBD instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PBD.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified PBD instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the uuid field of the given PBD. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the host field of the given PBD. - * - * @return value of the field - */ - public Host getHost(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_host"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the SR field of the given PBD. - * - * @return value of the field - */ - public SR getSR(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_SR"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Get the device_config field of the given PBD. - * - * @return value of the field - */ - public Map getDeviceConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_device_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the currently_attached field of the given PBD. - * - * @return value of the field - */ - public Boolean getCurrentlyAttached(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_currently_attached"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the other_config field of the given PBD. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given PBD. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given PBD. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given PBD. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Activate the specified PBD, causing the referenced SR to be attached and scanned - * - * @return Task - */ - public Task plugAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrUnknownDriver { - String method_call = "Async.PBD.plug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Activate the specified PBD, causing the referenced SR to be attached and scanned - * - */ - public void plug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrUnknownDriver { - String method_call = "PBD.plug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Deactivate the specified PBD, causing the referenced SR to be detached and nolonger scanned - * - * @return Task - */ - public Task unplugAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PBD.unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Deactivate the specified PBD, causing the referenced SR to be detached and nolonger scanned - * - */ - public void unplug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the PBD's device_config field - * - * @param value The new value of the PBD's device_config - * @return Task - */ - public Task setDeviceConfigAsync(Connection c, Map value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PBD.set_device_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Sets the PBD's device_config field - * - * @param value The new value of the PBD's device_config - */ - public void setDeviceConfig(Connection c, Map value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.set_device_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the PBDs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPBD(result); - } - - /** - * Return a map of PBD references to PBD records for all PBDs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PBD.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfPBDPBDRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PIF.java b/deps/XenServerJava/src/com/xensource/xenapi/PIF.java deleted file mode 100644 index bb0629446a6..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PIF.java +++ /dev/null @@ -1,1231 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A physical network interface (note separate VLANs are represented as several PIFs) - * - * @author Citrix Systems, Inc. - */ -public class PIF extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - PIF(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a PIF, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof PIF) - { - PIF other = (PIF) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a PIF - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "device", this.device); - print.printf("%1$20s: %2$s\n", "network", this.network); - print.printf("%1$20s: %2$s\n", "host", this.host); - print.printf("%1$20s: %2$s\n", "MAC", this.MAC); - print.printf("%1$20s: %2$s\n", "MTU", this.MTU); - print.printf("%1$20s: %2$s\n", "VLAN", this.VLAN); - print.printf("%1$20s: %2$s\n", "metrics", this.metrics); - print.printf("%1$20s: %2$s\n", "physical", this.physical); - print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); - print.printf("%1$20s: %2$s\n", "ipConfigurationMode", this.ipConfigurationMode); - print.printf("%1$20s: %2$s\n", "IP", this.IP); - print.printf("%1$20s: %2$s\n", "netmask", this.netmask); - print.printf("%1$20s: %2$s\n", "gateway", this.gateway); - print.printf("%1$20s: %2$s\n", "DNS", this.DNS); - print.printf("%1$20s: %2$s\n", "bondSlaveOf", this.bondSlaveOf); - print.printf("%1$20s: %2$s\n", "bondMasterOf", this.bondMasterOf); - print.printf("%1$20s: %2$s\n", "VLANMasterOf", this.VLANMasterOf); - print.printf("%1$20s: %2$s\n", "VLANSlaveOf", this.VLANSlaveOf); - print.printf("%1$20s: %2$s\n", "management", this.management); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "disallowUnplug", this.disallowUnplug); - print.printf("%1$20s: %2$s\n", "tunnelAccessPIFOf", this.tunnelAccessPIFOf); - print.printf("%1$20s: %2$s\n", "tunnelTransportPIFOf", this.tunnelTransportPIFOf); - return writer.toString(); - } - - /** - * Convert a PIF.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("device", this.device == null ? "" : this.device); - map.put("network", this.network == null ? new Network("OpaqueRef:NULL") : this.network); - map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); - map.put("MAC", this.MAC == null ? "" : this.MAC); - map.put("MTU", this.MTU == null ? 0 : this.MTU); - map.put("VLAN", this.VLAN == null ? 0 : this.VLAN); - map.put("metrics", this.metrics == null ? new PIFMetrics("OpaqueRef:NULL") : this.metrics); - map.put("physical", this.physical == null ? false : this.physical); - map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); - map.put("ip_configuration_mode", this.ipConfigurationMode == null ? Types.IpConfigurationMode.UNRECOGNIZED : this.ipConfigurationMode); - map.put("IP", this.IP == null ? "" : this.IP); - map.put("netmask", this.netmask == null ? "" : this.netmask); - map.put("gateway", this.gateway == null ? "" : this.gateway); - map.put("DNS", this.DNS == null ? "" : this.DNS); - map.put("bond_slave_of", this.bondSlaveOf == null ? new Bond("OpaqueRef:NULL") : this.bondSlaveOf); - map.put("bond_master_of", this.bondMasterOf == null ? new LinkedHashSet() : this.bondMasterOf); - map.put("VLAN_master_of", this.VLANMasterOf == null ? new VLAN("OpaqueRef:NULL") : this.VLANMasterOf); - map.put("VLAN_slave_of", this.VLANSlaveOf == null ? new LinkedHashSet() : this.VLANSlaveOf); - map.put("management", this.management == null ? false : this.management); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("disallow_unplug", this.disallowUnplug == null ? false : this.disallowUnplug); - map.put("tunnel_access_PIF_of", this.tunnelAccessPIFOf == null ? new LinkedHashSet() : this.tunnelAccessPIFOf); - map.put("tunnel_transport_PIF_of", this.tunnelTransportPIFOf == null ? new LinkedHashSet() : this.tunnelTransportPIFOf); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * machine-readable name of the interface (e.g. eth0) - */ - public String device; - /** - * virtual network to which this pif is connected - */ - public Network network; - /** - * physical machine to which this pif is connected - */ - public Host host; - /** - * ethernet MAC address of physical interface - */ - public String MAC; - /** - * MTU in octets - */ - public Long MTU; - /** - * VLAN tag for all traffic passing through this interface - */ - public Long VLAN; - /** - * metrics associated with this PIF - */ - public PIFMetrics metrics; - /** - * true if this represents a physical network interface - */ - public Boolean physical; - /** - * true if this interface is online - */ - public Boolean currentlyAttached; - /** - * Sets if and how this interface gets an IP address - */ - public Types.IpConfigurationMode ipConfigurationMode; - /** - * IP address - */ - public String IP; - /** - * IP netmask - */ - public String netmask; - /** - * IP gateway - */ - public String gateway; - /** - * IP address of DNS servers to use - */ - public String DNS; - /** - * Indicates which bond this interface is part of - */ - public Bond bondSlaveOf; - /** - * Indicates this PIF represents the results of a bond - */ - public Set bondMasterOf; - /** - * Indicates wich VLAN this interface receives untagged traffic from - */ - public VLAN VLANMasterOf; - /** - * Indicates which VLANs this interface transmits tagged traffic to - */ - public Set VLANSlaveOf; - /** - * Indicates whether the control software is listening for connections on this interface - */ - public Boolean management; - /** - * Additional configuration - */ - public Map otherConfig; - /** - * Prevent this PIF from being unplugged; set this to notify the management tool-stack that the PIF has a special use and should not be unplugged under any circumstances (e.g. because you're running storage traffic over it) - */ - public Boolean disallowUnplug; - /** - * Indicates to which tunnel this PIF gives access - */ - public Set tunnelAccessPIFOf; - /** - * Indicates to which tunnel this PIF provides transport - */ - public Set tunnelTransportPIFOf; - } - - /** - * Get a record containing the current state of the given PIF. - * - * @return all fields from the object - */ - public PIF.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIFRecord(result); - } - - /** - * Get a reference to the PIF instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static PIF getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Get the uuid field of the given PIF. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the device field of the given PIF. - * - * @return value of the field - */ - public String getDevice(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_device"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the network field of the given PIF. - * - * @return value of the field - */ - public Network getNetwork(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_network"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toNetwork(result); - } - - /** - * Get the host field of the given PIF. - * - * @return value of the field - */ - public Host getHost(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_host"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the MAC field of the given PIF. - * - * @return value of the field - */ - public String getMAC(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_MAC"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the MTU field of the given PIF. - * - * @return value of the field - */ - public Long getMTU(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_MTU"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the VLAN field of the given PIF. - * - * @return value of the field - */ - public Long getVLAN(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_VLAN"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the metrics field of the given PIF. - * - * @return value of the field - */ - public PIFMetrics getMetrics(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_metrics"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIFMetrics(result); - } - - /** - * Get the physical field of the given PIF. - * - * @return value of the field - */ - public Boolean getPhysical(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_physical"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the currently_attached field of the given PIF. - * - * @return value of the field - */ - public Boolean getCurrentlyAttached(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_currently_attached"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the ip_configuration_mode field of the given PIF. - * - * @return value of the field - */ - public Types.IpConfigurationMode getIpConfigurationMode(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_ip_configuration_mode"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toIpConfigurationMode(result); - } - - /** - * Get the IP field of the given PIF. - * - * @return value of the field - */ - public String getIP(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_IP"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the netmask field of the given PIF. - * - * @return value of the field - */ - public String getNetmask(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_netmask"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the gateway field of the given PIF. - * - * @return value of the field - */ - public String getGateway(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_gateway"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the DNS field of the given PIF. - * - * @return value of the field - */ - public String getDNS(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_DNS"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the bond_slave_of field of the given PIF. - * - * @return value of the field - */ - public Bond getBondSlaveOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_bond_slave_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBond(result); - } - - /** - * Get the bond_master_of field of the given PIF. - * - * @return value of the field - */ - public Set getBondMasterOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_bond_master_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfBond(result); - } - - /** - * Get the VLAN_master_of field of the given PIF. - * - * @return value of the field - */ - public VLAN getVLANMasterOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_VLAN_master_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVLAN(result); - } - - /** - * Get the VLAN_slave_of field of the given PIF. - * - * @return value of the field - */ - public Set getVLANSlaveOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_VLAN_slave_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVLAN(result); - } - - /** - * Get the management field of the given PIF. - * - * @return value of the field - */ - public Boolean getManagement(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_management"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the other_config field of the given PIF. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the disallow_unplug field of the given PIF. - * - * @return value of the field - */ - public Boolean getDisallowUnplug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_disallow_unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the tunnel_access_PIF_of field of the given PIF. - * - * @return value of the field - */ - public Set getTunnelAccessPIFOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_tunnel_access_PIF_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfTunnel(result); - } - - /** - * Get the tunnel_transport_PIF_of field of the given PIF. - * - * @return value of the field - */ - public Set getTunnelTransportPIFOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_tunnel_transport_PIF_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfTunnel(result); - } - - /** - * Set the other_config field of the given PIF. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given PIF. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given PIF. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the disallow_unplug field of the given PIF. - * - * @param disallowUnplug New value to set - */ - public void setDisallowUnplug(Connection c, Boolean disallowUnplug) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.set_disallow_unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(disallowUnplug)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a VLAN interface from an existing physical interface. This call is deprecated: use VLAN.create instead - * @deprecated - * - * @param device physical interface on which to create the VLAN interface - * @param network network to which this interface should be connected - * @param host physical machine to which this PIF is connected - * @param VLAN VLAN tag for the new interface - * @return Task - */ - @Deprecated public static Task createVLANAsync(Connection c, String device, Network network, Host host, Long VLAN) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VlanTagInvalid { - String method_call = "Async.PIF.create_VLAN"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(VLAN)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a VLAN interface from an existing physical interface. This call is deprecated: use VLAN.create instead - * @deprecated - * - * @param device physical interface on which to create the VLAN interface - * @param network network to which this interface should be connected - * @param host physical machine to which this PIF is connected - * @param VLAN VLAN tag for the new interface - * @return The reference of the created PIF object - */ - @Deprecated public static PIF createVLAN(Connection c, String device, Network network, Host host, Long VLAN) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VlanTagInvalid { - String method_call = "PIF.create_VLAN"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(VLAN)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Destroy the PIF object (provided it is a VLAN interface). This call is deprecated: use VLAN.destroy or Bond.destroy instead - * @deprecated - * - * @return Task - */ - @Deprecated public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.PifIsPhysical { - String method_call = "Async.PIF.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the PIF object (provided it is a VLAN interface). This call is deprecated: use VLAN.destroy or Bond.destroy instead - * @deprecated - * - */ - @Deprecated public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.PifIsPhysical { - String method_call = "PIF.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Reconfigure the IP address settings for this interface - * - * @param mode whether to use dynamic/static/no-assignment - * @param IP the new IP address - * @param netmask the new netmask - * @param gateway the new gateway - * @param DNS the new DNS settings - * @return Task - */ - public Task reconfigureIpAsync(Connection c, Types.IpConfigurationMode mode, String IP, String netmask, String gateway, String DNS) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PIF.reconfigure_ip"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(IP), Marshalling.toXMLRPC(netmask), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Reconfigure the IP address settings for this interface - * - * @param mode whether to use dynamic/static/no-assignment - * @param IP the new IP address - * @param netmask the new netmask - * @param gateway the new gateway - * @param DNS the new DNS settings - */ - public void reconfigureIp(Connection c, Types.IpConfigurationMode mode, String IP, String netmask, String gateway, String DNS) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.reconfigure_ip"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(IP), Marshalling.toXMLRPC(netmask), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Scan for physical interfaces on a host and create PIF objects to represent them - * - * @param host The host on which to scan - * @return Task - */ - public static Task scanAsync(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PIF.scan"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Scan for physical interfaces on a host and create PIF objects to represent them - * - * @param host The host on which to scan - */ - public static void scan(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.scan"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Scan for physical interfaces on a host and create PIF objects to represent them. Use BIOS-based device names. - * - * @param host The host on which to scan - * @return Task - */ - public static Task scanBiosAsync(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PIF.scan_bios"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Scan for physical interfaces on a host and create PIF objects to represent them. Use BIOS-based device names. - * - * @param host The host on which to scan - * @return List of newly created PIFs - */ - public static Set scanBios(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.scan_bios"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPIF(result); - } - - /** - * Create a PIF object matching a particular network interface - * - * @param host The host on which the interface exists - * @param MAC The MAC address of the interface - * @param device The device name to use for the interface - * @return Task - */ - public static Task introduceAsync(Connection c, Host host, String MAC, String device) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PIF.introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(device)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a PIF object matching a particular network interface - * - * @param host The host on which the interface exists - * @param MAC The MAC address of the interface - * @param device The device name to use for the interface - * @return The reference of the created PIF object - */ - public static PIF introduce(Connection c, Host host, String MAC, String device) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(device)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Destroy the PIF object matching a particular network interface - * - * @return Task - */ - public Task forgetAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.PifTunnelStillExists { - String method_call = "Async.PIF.forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the PIF object matching a particular network interface - * - */ - public void forget(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.PifTunnelStillExists { - String method_call = "PIF.forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Attempt to bring down a physical interface - * - * @return Task - */ - public Task unplugAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PIF.unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Attempt to bring down a physical interface - * - */ - public void unplug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Attempt to bring up a physical interface - * - * @return Task - */ - public Task plugAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.TransportPifNotConfigured { - String method_call = "Async.PIF.plug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Attempt to bring up a physical interface - * - */ - public void plug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.TransportPifNotConfigured { - String method_call = "PIF.plug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a new PIF record in the database only - * - * @param device - * @param network - * @param host - * @param MAC - * @param MTU - * @param VLAN - * @param physical - * @param ipConfigurationMode - * @param IP - * @param netmask - * @param gateway - * @param DNS - * @param bondSlaveOf - * @param VLANMasterOf - * @param management - * @param otherConfig - * @param disallowUnplug - * @return Task - */ - public static Task dbIntroduceAsync(Connection c, String device, Network network, Host host, String MAC, Long MTU, Long VLAN, Boolean physical, Types.IpConfigurationMode ipConfigurationMode, String IP, String netmask, String gateway, String DNS, Bond bondSlaveOf, VLAN VLANMasterOf, Boolean management, Map otherConfig, Boolean disallowUnplug) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PIF.db_introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(MTU), Marshalling.toXMLRPC(VLAN), Marshalling.toXMLRPC(physical), Marshalling.toXMLRPC(ipConfigurationMode), Marshalling.toXMLRPC(IP), Marshalling.toXMLRPC(netmask), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS), Marshalling.toXMLRPC(bondSlaveOf), Marshalling.toXMLRPC(VLANMasterOf), Marshalling.toXMLRPC(management), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(disallowUnplug)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new PIF record in the database only - * - * @param device - * @param network - * @param host - * @param MAC - * @param MTU - * @param VLAN - * @param physical - * @param ipConfigurationMode - * @param IP - * @param netmask - * @param gateway - * @param DNS - * @param bondSlaveOf - * @param VLANMasterOf - * @param management - * @param otherConfig - * @param disallowUnplug - * @return The ref of the newly created PIF record. - */ - public static PIF dbIntroduce(Connection c, String device, Network network, Host host, String MAC, Long MTU, Long VLAN, Boolean physical, Types.IpConfigurationMode ipConfigurationMode, String IP, String netmask, String gateway, String DNS, Bond bondSlaveOf, VLAN VLANMasterOf, Boolean management, Map otherConfig, Boolean disallowUnplug) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.db_introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(MTU), Marshalling.toXMLRPC(VLAN), Marshalling.toXMLRPC(physical), Marshalling.toXMLRPC(ipConfigurationMode), Marshalling.toXMLRPC(IP), Marshalling.toXMLRPC(netmask), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS), Marshalling.toXMLRPC(bondSlaveOf), Marshalling.toXMLRPC(VLANMasterOf), Marshalling.toXMLRPC(management), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(disallowUnplug)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Destroy a PIF database record. - * - * @return Task - */ - public Task dbForgetAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.PIF.db_forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy a PIF database record. - * - */ - public void dbForget(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.db_forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the PIFs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPIF(result); - } - - /** - * Return a map of PIF references to PIF records for all PIFs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfPIFPIFRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java deleted file mode 100644 index 34417d3cea3..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java +++ /dev/null @@ -1,528 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * The metrics associated with a physical network interface - * - * @author Citrix Systems, Inc. - */ -public class PIFMetrics extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - PIFMetrics(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a PIFMetrics, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof PIFMetrics) - { - PIFMetrics other = (PIFMetrics) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a PIFMetrics - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs); - print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs); - print.printf("%1$20s: %2$s\n", "carrier", this.carrier); - print.printf("%1$20s: %2$s\n", "vendorId", this.vendorId); - print.printf("%1$20s: %2$s\n", "vendorName", this.vendorName); - print.printf("%1$20s: %2$s\n", "deviceId", this.deviceId); - print.printf("%1$20s: %2$s\n", "deviceName", this.deviceName); - print.printf("%1$20s: %2$s\n", "speed", this.speed); - print.printf("%1$20s: %2$s\n", "duplex", this.duplex); - print.printf("%1$20s: %2$s\n", "pciBusPath", this.pciBusPath); - print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a PIF_metrics.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs); - map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs); - map.put("carrier", this.carrier == null ? false : this.carrier); - map.put("vendor_id", this.vendorId == null ? "" : this.vendorId); - map.put("vendor_name", this.vendorName == null ? "" : this.vendorName); - map.put("device_id", this.deviceId == null ? "" : this.deviceId); - map.put("device_name", this.deviceName == null ? "" : this.deviceName); - map.put("speed", this.speed == null ? 0 : this.speed); - map.put("duplex", this.duplex == null ? false : this.duplex); - map.put("pci_bus_path", this.pciBusPath == null ? "" : this.pciBusPath); - map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * Read bandwidth (KiB/s) - */ - public Double ioReadKbs; - /** - * Write bandwidth (KiB/s) - */ - public Double ioWriteKbs; - /** - * Report if the PIF got a carrier or not - */ - public Boolean carrier; - /** - * Report vendor ID - */ - public String vendorId; - /** - * Report vendor name - */ - public String vendorName; - /** - * Report device ID - */ - public String deviceId; - /** - * Report device name - */ - public String deviceName; - /** - * Speed of the link (if available) - */ - public Long speed; - /** - * Full duplex capability of the link (if available) - */ - public Boolean duplex; - /** - * PCI bus path of the pif (if available) - */ - public String pciBusPath; - /** - * Time at which this information was last updated - */ - public Date lastUpdated; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given PIF_metrics. - * - * @return all fields from the object - */ - public PIFMetrics.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIFMetricsRecord(result); - } - - /** - * Get a reference to the PIF_metrics instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static PIFMetrics getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIFMetrics(result); - } - - /** - * Get the uuid field of the given PIF_metrics. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the io/read_kbs field of the given PIF_metrics. - * - * @return value of the field - */ - public Double getIoReadKbs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_io_read_kbs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the io/write_kbs field of the given PIF_metrics. - * - * @return value of the field - */ - public Double getIoWriteKbs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_io_write_kbs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the carrier field of the given PIF_metrics. - * - * @return value of the field - */ - public Boolean getCarrier(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_carrier"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the vendor_id field of the given PIF_metrics. - * - * @return value of the field - */ - public String getVendorId(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_vendor_id"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the vendor_name field of the given PIF_metrics. - * - * @return value of the field - */ - public String getVendorName(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_vendor_name"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the device_id field of the given PIF_metrics. - * - * @return value of the field - */ - public String getDeviceId(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_device_id"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the device_name field of the given PIF_metrics. - * - * @return value of the field - */ - public String getDeviceName(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_device_name"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the speed field of the given PIF_metrics. - * - * @return value of the field - */ - public Long getSpeed(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_speed"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the duplex field of the given PIF_metrics. - * - * @return value of the field - */ - public Boolean getDuplex(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_duplex"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the pci_bus_path field of the given PIF_metrics. - * - * @return value of the field - */ - public String getPciBusPath(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_pci_bus_path"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the last_updated field of the given PIF_metrics. - * - * @return value of the field - */ - public Date getLastUpdated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_last_updated"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the other_config field of the given PIF_metrics. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given PIF_metrics. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given PIF_metrics. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given PIF_metrics. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the PIF_metrics instances known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPIFMetrics(result); - } - - /** - * Return a map of PIF_metrics references to PIF_metrics records for all PIF_metrics instances known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "PIF_metrics.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfPIFMetricsPIFMetricsRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Pool.java b/deps/XenServerJava/src/com/xensource/xenapi/Pool.java deleted file mode 100644 index 1b06094afe3..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Pool.java +++ /dev/null @@ -1,2294 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * Pool-wide information - * - * @author Citrix Systems, Inc. - */ -public class Pool extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Pool(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Pool, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Pool) - { - Pool other = (Pool) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Pool - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "master", this.master); - print.printf("%1$20s: %2$s\n", "defaultSR", this.defaultSR); - print.printf("%1$20s: %2$s\n", "suspendImageSR", this.suspendImageSR); - print.printf("%1$20s: %2$s\n", "crashDumpSR", this.crashDumpSR); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "haEnabled", this.haEnabled); - print.printf("%1$20s: %2$s\n", "haConfiguration", this.haConfiguration); - print.printf("%1$20s: %2$s\n", "haStatefiles", this.haStatefiles); - print.printf("%1$20s: %2$s\n", "haHostFailuresToTolerate", this.haHostFailuresToTolerate); - print.printf("%1$20s: %2$s\n", "haPlanExistsFor", this.haPlanExistsFor); - print.printf("%1$20s: %2$s\n", "haAllowOvercommit", this.haAllowOvercommit); - print.printf("%1$20s: %2$s\n", "haOvercommitted", this.haOvercommitted); - print.printf("%1$20s: %2$s\n", "blobs", this.blobs); - print.printf("%1$20s: %2$s\n", "tags", this.tags); - print.printf("%1$20s: %2$s\n", "guiConfig", this.guiConfig); - print.printf("%1$20s: %2$s\n", "wlbUrl", this.wlbUrl); - print.printf("%1$20s: %2$s\n", "wlbUsername", this.wlbUsername); - print.printf("%1$20s: %2$s\n", "wlbEnabled", this.wlbEnabled); - print.printf("%1$20s: %2$s\n", "wlbVerifyCert", this.wlbVerifyCert); - print.printf("%1$20s: %2$s\n", "redoLogEnabled", this.redoLogEnabled); - print.printf("%1$20s: %2$s\n", "redoLogVdi", this.redoLogVdi); - print.printf("%1$20s: %2$s\n", "vswitchController", this.vswitchController); - print.printf("%1$20s: %2$s\n", "restrictions", this.restrictions); - return writer.toString(); - } - - /** - * Convert a pool.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("master", this.master == null ? new Host("OpaqueRef:NULL") : this.master); - map.put("default_SR", this.defaultSR == null ? new SR("OpaqueRef:NULL") : this.defaultSR); - map.put("suspend_image_SR", this.suspendImageSR == null ? new SR("OpaqueRef:NULL") : this.suspendImageSR); - map.put("crash_dump_SR", this.crashDumpSR == null ? new SR("OpaqueRef:NULL") : this.crashDumpSR); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("ha_enabled", this.haEnabled == null ? false : this.haEnabled); - map.put("ha_configuration", this.haConfiguration == null ? new HashMap() : this.haConfiguration); - map.put("ha_statefiles", this.haStatefiles == null ? new LinkedHashSet() : this.haStatefiles); - map.put("ha_host_failures_to_tolerate", this.haHostFailuresToTolerate == null ? 0 : this.haHostFailuresToTolerate); - map.put("ha_plan_exists_for", this.haPlanExistsFor == null ? 0 : this.haPlanExistsFor); - map.put("ha_allow_overcommit", this.haAllowOvercommit == null ? false : this.haAllowOvercommit); - map.put("ha_overcommitted", this.haOvercommitted == null ? false : this.haOvercommitted); - map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); - map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); - map.put("gui_config", this.guiConfig == null ? new HashMap() : this.guiConfig); - map.put("wlb_url", this.wlbUrl == null ? "" : this.wlbUrl); - map.put("wlb_username", this.wlbUsername == null ? "" : this.wlbUsername); - map.put("wlb_enabled", this.wlbEnabled == null ? false : this.wlbEnabled); - map.put("wlb_verify_cert", this.wlbVerifyCert == null ? false : this.wlbVerifyCert); - map.put("redo_log_enabled", this.redoLogEnabled == null ? false : this.redoLogEnabled); - map.put("redo_log_vdi", this.redoLogVdi == null ? new VDI("OpaqueRef:NULL") : this.redoLogVdi); - map.put("vswitch_controller", this.vswitchController == null ? "" : this.vswitchController); - map.put("restrictions", this.restrictions == null ? new HashMap() : this.restrictions); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * Short name - */ - public String nameLabel; - /** - * Description - */ - public String nameDescription; - /** - * The host that is pool master - */ - public Host master; - /** - * Default SR for VDIs - */ - public SR defaultSR; - /** - * The SR in which VDIs for suspend images are created - */ - public SR suspendImageSR; - /** - * The SR in which VDIs for crash dumps are created - */ - public SR crashDumpSR; - /** - * additional configuration - */ - public Map otherConfig; - /** - * true if HA is enabled on the pool, false otherwise - */ - public Boolean haEnabled; - /** - * The current HA configuration - */ - public Map haConfiguration; - /** - * HA statefile VDIs in use - */ - public Set haStatefiles; - /** - * Number of host failures to tolerate before the Pool is declared to be overcommitted - */ - public Long haHostFailuresToTolerate; - /** - * Number of future host failures we have managed to find a plan for. Once this reaches zero any future host failures will cause the failure of protected VMs. - */ - public Long haPlanExistsFor; - /** - * If set to false then operations which would cause the Pool to become overcommitted will be blocked. - */ - public Boolean haAllowOvercommit; - /** - * True if the Pool is considered to be overcommitted i.e. if there exist insufficient physical resources to tolerate the configured number of host failures - */ - public Boolean haOvercommitted; - /** - * Binary blobs associated with this pool - */ - public Map blobs; - /** - * user-specified tags for categorization purposes - */ - public Set tags; - /** - * gui-specific configuration for pool - */ - public Map guiConfig; - /** - * Url for the configured workload balancing host - */ - public String wlbUrl; - /** - * Username for accessing the workload balancing host - */ - public String wlbUsername; - /** - * true if workload balancing is enabled on the pool, false otherwise - */ - public Boolean wlbEnabled; - /** - * true if communication with the WLB server should enforce SSL certificate verification. - */ - public Boolean wlbVerifyCert; - /** - * true a redo-log is to be used other than when HA is enabled, false otherwise - */ - public Boolean redoLogEnabled; - /** - * indicates the VDI to use for the redo-log other than when HA is enabled - */ - public VDI redoLogVdi; - /** - * address of the vswitch controller - */ - public String vswitchController; - /** - * Pool-wide restrictions currently in effect - */ - public Map restrictions; - } - - /** - * Get a record containing the current state of the given pool. - * - * @return all fields from the object - */ - public Pool.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPoolRecord(result); - } - - /** - * Get a reference to the pool instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Pool getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPool(result); - } - - /** - * Get the uuid field of the given pool. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name_label field of the given pool. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name_description field of the given pool. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the master field of the given pool. - * - * @return value of the field - */ - public Host getMaster(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_master"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the default_SR field of the given pool. - * - * @return value of the field - */ - public SR getDefaultSR(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_default_SR"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Get the suspend_image_SR field of the given pool. - * - * @return value of the field - */ - public SR getSuspendImageSR(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_suspend_image_SR"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Get the crash_dump_SR field of the given pool. - * - * @return value of the field - */ - public SR getCrashDumpSR(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_crash_dump_SR"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Get the other_config field of the given pool. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the ha_enabled field of the given pool. - * - * @return value of the field - */ - public Boolean getHaEnabled(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_ha_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the ha_configuration field of the given pool. - * - * @return value of the field - */ - public Map getHaConfiguration(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_ha_configuration"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the ha_statefiles field of the given pool. - * - * @return value of the field - */ - public Set getHaStatefiles(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_ha_statefiles"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the ha_host_failures_to_tolerate field of the given pool. - * - * @return value of the field - */ - public Long getHaHostFailuresToTolerate(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_ha_host_failures_to_tolerate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the ha_plan_exists_for field of the given pool. - * - * @return value of the field - */ - public Long getHaPlanExistsFor(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_ha_plan_exists_for"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the ha_allow_overcommit field of the given pool. - * - * @return value of the field - */ - public Boolean getHaAllowOvercommit(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_ha_allow_overcommit"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the ha_overcommitted field of the given pool. - * - * @return value of the field - */ - public Boolean getHaOvercommitted(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_ha_overcommitted"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the blobs field of the given pool. - * - * @return value of the field - */ - public Map getBlobs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_blobs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringBlob(result); - } - - /** - * Get the tags field of the given pool. - * - * @return value of the field - */ - public Set getTags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the gui_config field of the given pool. - * - * @return value of the field - */ - public Map getGuiConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_gui_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the wlb_url field of the given pool. - * - * @return value of the field - */ - public String getWlbUrl(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_wlb_url"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the wlb_username field of the given pool. - * - * @return value of the field - */ - public String getWlbUsername(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_wlb_username"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the wlb_enabled field of the given pool. - * - * @return value of the field - */ - public Boolean getWlbEnabled(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_wlb_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the wlb_verify_cert field of the given pool. - * - * @return value of the field - */ - public Boolean getWlbVerifyCert(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_wlb_verify_cert"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the redo_log_enabled field of the given pool. - * - * @return value of the field - */ - public Boolean getRedoLogEnabled(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_redo_log_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the redo_log_vdi field of the given pool. - * - * @return value of the field - */ - public VDI getRedoLogVdi(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_redo_log_vdi"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Get the vswitch_controller field of the given pool. - * - * @return value of the field - */ - public String getVswitchController(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_vswitch_controller"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the restrictions field of the given pool. - * - * @return value of the field - */ - public Map getRestrictions(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_restrictions"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the name_label field of the given pool. - * - * @param nameLabel New value to set - */ - public void setNameLabel(Connection c, String nameLabel) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(nameLabel)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the name_description field of the given pool. - * - * @param nameDescription New value to set - */ - public void setNameDescription(Connection c, String nameDescription) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(nameDescription)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the default_SR field of the given pool. - * - * @param defaultSR New value to set - */ - public void setDefaultSR(Connection c, SR defaultSR) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_default_SR"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(defaultSR)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the suspend_image_SR field of the given pool. - * - * @param suspendImageSR New value to set - */ - public void setSuspendImageSR(Connection c, SR suspendImageSR) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_suspend_image_SR"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(suspendImageSR)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the crash_dump_SR field of the given pool. - * - * @param crashDumpSR New value to set - */ - public void setCrashDumpSR(Connection c, SR crashDumpSR) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_crash_dump_SR"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(crashDumpSR)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given pool. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given pool. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given pool. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the ha_allow_overcommit field of the given pool. - * - * @param haAllowOvercommit New value to set - */ - public void setHaAllowOvercommit(Connection c, Boolean haAllowOvercommit) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_ha_allow_overcommit"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(haAllowOvercommit)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the tags field of the given pool. - * - * @param tags New value to set - */ - public void setTags(Connection c, Set tags) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given value to the tags field of the given pool. If the value is already in that Set, then do nothing. - * - * @param value New value to add - */ - public void addTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.add_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given value from the tags field of the given pool. If the value is not in that Set, then do nothing. - * - * @param value Value to remove - */ - public void removeTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.remove_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the gui_config field of the given pool. - * - * @param guiConfig New value to set - */ - public void setGuiConfig(Connection c, Map guiConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_gui_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(guiConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the gui_config field of the given pool. - * - * @param key Key to add - * @param value Value to add - */ - public void addToGuiConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.add_to_gui_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the gui_config field of the given pool. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromGuiConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.remove_from_gui_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the wlb_enabled field of the given pool. - * - * @param wlbEnabled New value to set - */ - public void setWlbEnabled(Connection c, Boolean wlbEnabled) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_wlb_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(wlbEnabled)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the wlb_verify_cert field of the given pool. - * - * @param wlbVerifyCert New value to set - */ - public void setWlbVerifyCert(Connection c, Boolean wlbVerifyCert) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_wlb_verify_cert"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(wlbVerifyCert)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Instruct host to join a new pool - * - * @param masterAddress The hostname of the master of the pool to join - * @param masterUsername The username of the master (for initial authentication) - * @param masterPassword The password for the master (for initial authentication) - * @return Task - */ - public static Task joinAsync(Connection c, String masterAddress, String masterUsername, String masterPassword) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.JoiningHostCannotContainSharedSrs { - String method_call = "Async.pool.join"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress), Marshalling.toXMLRPC(masterUsername), Marshalling.toXMLRPC(masterPassword)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Instruct host to join a new pool - * - * @param masterAddress The hostname of the master of the pool to join - * @param masterUsername The username of the master (for initial authentication) - * @param masterPassword The password for the master (for initial authentication) - */ - public static void join(Connection c, String masterAddress, String masterUsername, String masterPassword) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.JoiningHostCannotContainSharedSrs { - String method_call = "pool.join"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress), Marshalling.toXMLRPC(masterUsername), Marshalling.toXMLRPC(masterPassword)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Instruct host to join a new pool - * - * @param masterAddress The hostname of the master of the pool to join - * @param masterUsername The username of the master (for initial authentication) - * @param masterPassword The password for the master (for initial authentication) - * @return Task - */ - public static Task joinForceAsync(Connection c, String masterAddress, String masterUsername, String masterPassword) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.join_force"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress), Marshalling.toXMLRPC(masterUsername), Marshalling.toXMLRPC(masterPassword)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Instruct host to join a new pool - * - * @param masterAddress The hostname of the master of the pool to join - * @param masterUsername The username of the master (for initial authentication) - * @param masterPassword The password for the master (for initial authentication) - */ - public static void joinForce(Connection c, String masterAddress, String masterUsername, String masterPassword) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.join_force"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress), Marshalling.toXMLRPC(masterUsername), Marshalling.toXMLRPC(masterPassword)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Instruct a pool master to eject a host from the pool - * - * @param host The host to eject - * @return Task - */ - public static Task ejectAsync(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.eject"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Instruct a pool master to eject a host from the pool - * - * @param host The host to eject - */ - public static void eject(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.eject"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Instruct host that's currently a slave to transition to being master - * - */ - public static void emergencyTransitionToMaster(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.emergency_transition_to_master"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Instruct a slave already in a pool that the master has changed - * - * @param masterAddress The hostname of the master - */ - public static void emergencyResetMaster(Connection c, String masterAddress) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.emergency_reset_master"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Instruct a pool master, M, to try and contact its slaves and, if slaves are in emergency mode, reset their master address to M. - * - * @return Task - */ - public static Task recoverSlavesAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.recover_slaves"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Instruct a pool master, M, to try and contact its slaves and, if slaves are in emergency mode, reset their master address to M. - * - * @return list of hosts whose master address were succesfully reset - */ - public static Set recoverSlaves(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.recover_slaves"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHost(result); - } - - /** - * Create PIFs, mapping a network to the same physical interface/VLAN on each host. This call is deprecated: use Pool.create_VLAN_from_PIF instead. - * - * @param device physical interface on which to create the VLAN interface - * @param network network to which this interface should be connected - * @param VLAN VLAN tag for the new interface - * @return Task - */ - public static Task createVLANAsync(Connection c, String device, Network network, Long VLAN) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VlanTagInvalid { - String method_call = "Async.pool.create_VLAN"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(VLAN)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create PIFs, mapping a network to the same physical interface/VLAN on each host. This call is deprecated: use Pool.create_VLAN_from_PIF instead. - * - * @param device physical interface on which to create the VLAN interface - * @param network network to which this interface should be connected - * @param VLAN VLAN tag for the new interface - * @return The references of the created PIF objects - */ - public static Set createVLAN(Connection c, String device, Network network, Long VLAN) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VlanTagInvalid { - String method_call = "pool.create_VLAN"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(VLAN)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPIF(result); - } - - /** - * Create a pool-wide VLAN by taking the PIF. - * - * @param pif physical interface on any particular host, that identifies the PIF on which to create the (pool-wide) VLAN interface - * @param network network to which this interface should be connected - * @param VLAN VLAN tag for the new interface - * @return Task - */ - public static Task createVLANFromPIFAsync(Connection c, PIF pif, Network network, Long VLAN) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VlanTagInvalid { - String method_call = "Async.pool.create_VLAN_from_PIF"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(pif), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(VLAN)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a pool-wide VLAN by taking the PIF. - * - * @param pif physical interface on any particular host, that identifies the PIF on which to create the (pool-wide) VLAN interface - * @param network network to which this interface should be connected - * @param VLAN VLAN tag for the new interface - * @return The references of the created PIF objects - */ - public static Set createVLANFromPIF(Connection c, PIF pif, Network network, Long VLAN) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VlanTagInvalid { - String method_call = "pool.create_VLAN_from_PIF"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(pif), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(VLAN)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPIF(result); - } - - /** - * Turn on High Availability mode - * - * @param heartbeatSrs Set of SRs to use for storage heartbeating. - * @param configuration Detailed HA configuration to apply - * @return Task - */ - public static Task enableHaAsync(Connection c, Set heartbeatSrs, Map configuration) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.enable_ha"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(heartbeatSrs), Marshalling.toXMLRPC(configuration)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Turn on High Availability mode - * - * @param heartbeatSrs Set of SRs to use for storage heartbeating. - * @param configuration Detailed HA configuration to apply - */ - public static void enableHa(Connection c, Set heartbeatSrs, Map configuration) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.enable_ha"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(heartbeatSrs), Marshalling.toXMLRPC(configuration)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Turn off High Availability mode - * - * @return Task - */ - public static Task disableHaAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.disable_ha"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Turn off High Availability mode - * - */ - public static void disableHa(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.disable_ha"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Forcibly synchronise the database now - * - * @return Task - */ - public static Task syncDatabaseAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.sync_database"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Forcibly synchronise the database now - * - */ - public static void syncDatabase(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.sync_database"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Perform an orderly handover of the role of master to the referenced host. - * - * @param host The host who should become the new master - * @return Task - */ - public static Task designateNewMasterAsync(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.designate_new_master"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Perform an orderly handover of the role of master to the referenced host. - * - * @param host The host who should become the new master - */ - public static void designateNewMaster(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.designate_new_master"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * When this call returns the VM restart logic will not run for the requested number of seconds. If the argument is zero then the restart thread is immediately unblocked - * - * @param seconds The number of seconds to block the restart thread for - */ - public static void haPreventRestartsFor(Connection c, Long seconds) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.ha_prevent_restarts_for"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(seconds)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Returns true if a VM failover plan exists for up to 'n' host failures - * - * @param n The number of host failures to plan for - * @return true if a failover plan exists for the supplied number of host failures - */ - public static Boolean haFailoverPlanExists(Connection c, Long n) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.ha_failover_plan_exists"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(n)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Returns the maximum number of host failures we could tolerate before we would be unable to restart configured VMs - * - * @return maximum value for ha_host_failures_to_tolerate given current configuration - */ - public static Long haComputeMaxHostFailuresToTolerate(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.ha_compute_max_host_failures_to_tolerate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Returns the maximum number of host failures we could tolerate before we would be unable to restart the provided VMs - * - * @param configuration Map of protected VM reference to restart priority - * @return maximum value for ha_host_failures_to_tolerate given provided configuration - */ - public static Long haComputeHypotheticalMaxHostFailuresToTolerate(Connection c, Map configuration) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.ha_compute_hypothetical_max_host_failures_to_tolerate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(configuration)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Return a VM failover plan assuming a given subset of hosts fail - * - * @param failedHosts The set of hosts to assume have failed - * @param failedVms The set of VMs to restart - * @return VM failover plan: a map of VM to host to restart the host on - */ - public static Map> haComputeVmFailoverPlan(Connection c, Set failedHosts, Set failedVms) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.ha_compute_vm_failover_plan"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(failedHosts), Marshalling.toXMLRPC(failedVms)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVMMapOfStringString(result); - } - - /** - * Set the maximum number of host failures to consider in the HA VM restart planner - * - * @param value New number of host failures to consider - * @return Task - */ - public Task setHaHostFailuresToTolerateAsync(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.set_ha_host_failures_to_tolerate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the maximum number of host failures to consider in the HA VM restart planner - * - * @param value New number of host failures to consider - */ - public void setHaHostFailuresToTolerate(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_ha_host_failures_to_tolerate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this pool - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return Task - */ - public Task createNewBlobAsync(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this pool - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return The reference of the blob, needed for populating its data - */ - public Blob createNewBlob(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBlob(result); - } - - /** - * This call enables external authentication on all the hosts of the pool - * - * @param config A list of key-values containing the configuration data - * @param serviceName The name of the service - * @param authType The type of authentication (e.g. AD for Active Directory) - */ - public void enableExternalAuth(Connection c, Map config, String serviceName, String authType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.enable_external_auth"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config), Marshalling.toXMLRPC(serviceName), Marshalling.toXMLRPC(authType)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call disables external authentication on all the hosts of the pool - * - * @param config Optional parameters as a list of key-values containing the configuration data - */ - public void disableExternalAuth(Connection c, Map config) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.disable_external_auth"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call asynchronously detects if the external authentication configuration in any slave is different from that in the master and raises appropriate alerts - * - */ - public void detectNonhomogeneousExternalAuth(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.detect_nonhomogeneous_external_auth"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Initializes workload balancing monitoring on this pool with the specified wlb server - * - * @param wlbUrl The ip address and port to use when accessing the wlb server - * @param wlbUsername The username used to authenticate with the wlb server - * @param wlbPassword The password used to authenticate with the wlb server - * @param xenserverUsername The usernamed used by the wlb server to authenticate with the xenserver - * @param xenserverPassword The password used by the wlb server to authenticate with the xenserver - * @return Task - */ - public static Task initializeWlbAsync(Connection c, String wlbUrl, String wlbUsername, String wlbPassword, String xenserverUsername, String xenserverPassword) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.initialize_wlb"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(wlbUrl), Marshalling.toXMLRPC(wlbUsername), Marshalling.toXMLRPC(wlbPassword), Marshalling.toXMLRPC(xenserverUsername), Marshalling.toXMLRPC(xenserverPassword)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Initializes workload balancing monitoring on this pool with the specified wlb server - * - * @param wlbUrl The ip address and port to use when accessing the wlb server - * @param wlbUsername The username used to authenticate with the wlb server - * @param wlbPassword The password used to authenticate with the wlb server - * @param xenserverUsername The usernamed used by the wlb server to authenticate with the xenserver - * @param xenserverPassword The password used by the wlb server to authenticate with the xenserver - */ - public static void initializeWlb(Connection c, String wlbUrl, String wlbUsername, String wlbPassword, String xenserverUsername, String xenserverPassword) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.initialize_wlb"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(wlbUrl), Marshalling.toXMLRPC(wlbUsername), Marshalling.toXMLRPC(wlbPassword), Marshalling.toXMLRPC(xenserverUsername), Marshalling.toXMLRPC(xenserverPassword)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Permanently deconfigures workload balancing monitoring on this pool - * - * @return Task - */ - public static Task deconfigureWlbAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.deconfigure_wlb"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Permanently deconfigures workload balancing monitoring on this pool - * - */ - public static void deconfigureWlb(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.deconfigure_wlb"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the pool optimization criteria for the workload balancing server - * - * @param config The configuration to use in optimizing this pool - * @return Task - */ - public static Task sendWlbConfigurationAsync(Connection c, Map config) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.send_wlb_configuration"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(config)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Sets the pool optimization criteria for the workload balancing server - * - * @param config The configuration to use in optimizing this pool - */ - public static void sendWlbConfiguration(Connection c, Map config) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.send_wlb_configuration"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(config)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Retrieves the pool optimization criteria from the workload balancing server - * - * @return Task - */ - public static Task retrieveWlbConfigurationAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.retrieve_wlb_configuration"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Retrieves the pool optimization criteria from the workload balancing server - * - * @return The configuration used in optimizing this pool - */ - public static Map retrieveWlbConfiguration(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.retrieve_wlb_configuration"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Retrieves vm migrate recommendations for the pool from the workload balancing server - * - * @return Task - */ - public static Task retrieveWlbRecommendationsAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.retrieve_wlb_recommendations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Retrieves vm migrate recommendations for the pool from the workload balancing server - * - * @return The list of vm migration recommendations - */ - public static Map> retrieveWlbRecommendations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.retrieve_wlb_recommendations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVMSetOfString(result); - } - - /** - * Send the given body to the given host and port, using HTTPS, and print the response. This is used for debugging the SSL layer. - * - * @param host - * @param port - * @param body - * @return Task - */ - public static Task sendTestPostAsync(Connection c, String host, Long port, String body) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.send_test_post"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(port), Marshalling.toXMLRPC(body)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Send the given body to the given host and port, using HTTPS, and print the response. This is used for debugging the SSL layer. - * - * @param host - * @param port - * @param body - * @return The response - */ - public static String sendTestPost(Connection c, String host, Long port, String body) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.send_test_post"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(port), Marshalling.toXMLRPC(body)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Install an SSL certificate pool-wide. - * - * @param name A name to give the certificate - * @param cert The certificate - * @return Task - */ - public static Task certificateInstallAsync(Connection c, String name, String cert) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.certificate_install"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(cert)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Install an SSL certificate pool-wide. - * - * @param name A name to give the certificate - * @param cert The certificate - */ - public static void certificateInstall(Connection c, String name, String cert) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.certificate_install"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(cert)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove an SSL certificate. - * - * @param name The certificate name - * @return Task - */ - public static Task certificateUninstallAsync(Connection c, String name) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.certificate_uninstall"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Remove an SSL certificate. - * - * @param name The certificate name - */ - public static void certificateUninstall(Connection c, String name) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.certificate_uninstall"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * List all installed SSL certificates. - * - * @return Task - */ - public static Task certificateListAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.certificate_list"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * List all installed SSL certificates. - * - * @return All installed certificates - */ - public static Set certificateList(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.certificate_list"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Install an SSL certificate revocation list, pool-wide. - * - * @param name A name to give the CRL - * @param cert The CRL - * @return Task - */ - public static Task crlInstallAsync(Connection c, String name, String cert) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.crl_install"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(cert)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Install an SSL certificate revocation list, pool-wide. - * - * @param name A name to give the CRL - * @param cert The CRL - */ - public static void crlInstall(Connection c, String name, String cert) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.crl_install"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(cert)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove an SSL certificate revocation list. - * - * @param name The CRL name - * @return Task - */ - public static Task crlUninstallAsync(Connection c, String name) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.crl_uninstall"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Remove an SSL certificate revocation list. - * - * @param name The CRL name - */ - public static void crlUninstall(Connection c, String name) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.crl_uninstall"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * List all installed SSL certificate revocation lists. - * - * @return Task - */ - public static Task crlListAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.crl_list"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * List all installed SSL certificate revocation lists. - * - * @return All installed CRLs - */ - public static Set crlList(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.crl_list"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Sync SSL certificates from master to slaves. - * - * @return Task - */ - public static Task certificateSyncAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.certificate_sync"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Sync SSL certificates from master to slaves. - * - */ - public static void certificateSync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.certificate_sync"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Enable the redo log on the given SR and start using it, unless HA is enabled. - * - * @param sr SR to hold the redo log. - * @return Task - */ - public static Task enableRedoLogAsync(Connection c, SR sr) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.enable_redo_log"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(sr)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Enable the redo log on the given SR and start using it, unless HA is enabled. - * - * @param sr SR to hold the redo log. - */ - public static void enableRedoLog(Connection c, SR sr) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.enable_redo_log"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(sr)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Disable the redo log if in use, unless HA is enabled. - * - * @return Task - */ - public static Task disableRedoLogAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.disable_redo_log"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Disable the redo log if in use, unless HA is enabled. - * - */ - public static void disableRedoLog(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.disable_redo_log"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the IP address of the vswitch controller. - * - * @param address IP address of the vswitch controller. - * @return Task - */ - public static Task setVswitchControllerAsync(Connection c, String address) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.set_vswitch_controller"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(address)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the IP address of the vswitch controller. - * - * @param address IP address of the vswitch controller. - */ - public static void setVswitchController(Connection c, String address) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.set_vswitch_controller"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(address)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call tests if a location is valid - * - * @param config Location config settings to test - * @return An XMLRPC result - */ - public String testArchiveTarget(Connection c, Map config) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.test_archive_target"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * This call attempts to enable pool-wide local storage caching - * - * @return Task - */ - public Task enableLocalStorageCachingAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.enable_local_storage_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * This call attempts to enable pool-wide local storage caching - * - */ - public void enableLocalStorageCaching(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.enable_local_storage_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call disables pool-wide local storage caching - * - * @return Task - */ - public Task disableLocalStorageCachingAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool.disable_local_storage_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * This call disables pool-wide local storage caching - * - */ - public void disableLocalStorageCaching(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.disable_local_storage_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the pools known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPool(result); - } - - /** - * Return a map of pool references to pool records for all pools known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfPoolPoolRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java b/deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java deleted file mode 100644 index b2740247838..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java +++ /dev/null @@ -1,622 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * Pool-wide patches - * - * @author Citrix Systems, Inc. - */ -public class PoolPatch extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - PoolPatch(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a PoolPatch, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof PoolPatch) - { - PoolPatch other = (PoolPatch) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a PoolPatch - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "version", this.version); - print.printf("%1$20s: %2$s\n", "size", this.size); - print.printf("%1$20s: %2$s\n", "poolApplied", this.poolApplied); - print.printf("%1$20s: %2$s\n", "hostPatches", this.hostPatches); - print.printf("%1$20s: %2$s\n", "afterApplyGuidance", this.afterApplyGuidance); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a pool_patch.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("version", this.version == null ? "" : this.version); - map.put("size", this.size == null ? 0 : this.size); - map.put("pool_applied", this.poolApplied == null ? false : this.poolApplied); - map.put("host_patches", this.hostPatches == null ? new LinkedHashSet() : this.hostPatches); - map.put("after_apply_guidance", this.afterApplyGuidance == null ? new LinkedHashSet() : this.afterApplyGuidance); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * Patch version number - */ - public String version; - /** - * Size of the patch - */ - public Long size; - /** - * This patch should be applied across the entire pool - */ - public Boolean poolApplied; - /** - * This hosts this patch is applied to. - */ - public Set hostPatches; - /** - * What the client should do after this patch has been applied. - */ - public Set afterApplyGuidance; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given pool_patch. - * - * @return all fields from the object - */ - public PoolPatch.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPoolPatchRecord(result); - } - - /** - * Get a reference to the pool_patch instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static PoolPatch getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPoolPatch(result); - } - - /** - * Get all the pool_patch instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPoolPatch(result); - } - - /** - * Get the uuid field of the given pool_patch. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given pool_patch. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given pool_patch. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the version field of the given pool_patch. - * - * @return value of the field - */ - public String getVersion(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the size field of the given pool_patch. - * - * @return value of the field - */ - public Long getSize(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_size"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the pool_applied field of the given pool_patch. - * - * @return value of the field - */ - public Boolean getPoolApplied(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_pool_applied"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the host_patches field of the given pool_patch. - * - * @return value of the field - */ - public Set getHostPatches(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_host_patches"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHostPatch(result); - } - - /** - * Get the after_apply_guidance field of the given pool_patch. - * - * @return value of the field - */ - public Set getAfterApplyGuidance(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_after_apply_guidance"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfAfterApplyGuidance(result); - } - - /** - * Get the other_config field of the given pool_patch. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given pool_patch. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given pool_patch. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given pool_patch. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Apply the selected patch to a host and return its output - * - * @param host The host to apply the patch too - * @return Task - */ - public Task applyAsync(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool_patch.apply"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Apply the selected patch to a host and return its output - * - * @param host The host to apply the patch too - * @return the output of the patch application process - */ - public String apply(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.apply"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Apply the selected patch to all hosts in the pool and return a map of host_ref -> patch output - * - * @return Task - */ - public Task poolApplyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool_patch.pool_apply"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Apply the selected patch to all hosts in the pool and return a map of host_ref -> patch output - * - */ - public void poolApply(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.pool_apply"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Execute the precheck stage of the selected patch on a host and return its output - * - * @param host The host to run the prechecks on - * @return Task - */ - public Task precheckAsync(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool_patch.precheck"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Execute the precheck stage of the selected patch on a host and return its output - * - * @param host The host to run the prechecks on - * @return the output of the patch prechecks - */ - public String precheck(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.precheck"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Removes the patch's files from all hosts in the pool, but does not remove the database entries - * - * @return Task - */ - public Task cleanAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool_patch.clean"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Removes the patch's files from all hosts in the pool, but does not remove the database entries - * - */ - public void clean(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.clean"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Removes the patch's files from all hosts in the pool, and removes the database entries. Only works on unapplied patches. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.pool_patch.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Removes the patch's files from all hosts in the pool, and removes the database entries. Only works on unapplied patches. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the pool_patchs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPoolPatch(result); - } - - /** - * Return a map of pool_patch references to pool_patch records for all pool_patchs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "pool_patch.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfPoolPatchPoolPatchRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Role.java b/deps/XenServerJava/src/com/xensource/xenapi/Role.java deleted file mode 100644 index c64d18fae3f..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Role.java +++ /dev/null @@ -1,359 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A set of permissions associated with a subject - * - * @author Citrix Systems, Inc. - */ -public class Role extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Role(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Role, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Role) - { - Role other = (Role) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Role - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "subroles", this.subroles); - return writer.toString(); - } - - /** - * Convert a role.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("subroles", this.subroles == null ? new LinkedHashSet() : this.subroles); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a short user-friendly name for the role - */ - public String nameLabel; - /** - * what this role is for - */ - public String nameDescription; - /** - * a list of pointers to other roles or permissions - */ - public Set subroles; - } - - /** - * Get a record containing the current state of the given role. - * - * @return all fields from the object - */ - public Role.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toRoleRecord(result); - } - - /** - * Get a reference to the role instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Role getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toRole(result); - } - - /** - * Get all the role instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfRole(result); - } - - /** - * Get the uuid field of the given role. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given role. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given role. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the subroles field of the given role. - * - * @return value of the field - */ - public Set getSubroles(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_subroles"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfRole(result); - } - - /** - * This call returns a list of permissions given a role - * - * @return a list of permissions - */ - public Set getPermissions(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_permissions"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfRole(result); - } - - /** - * This call returns a list of permission names given a role - * - * @return a list of permission names - */ - public Set getPermissionsNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_permissions_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * This call returns a list of roles given a permission - * - * @return a list of references to roles - */ - public Set getByPermission(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_by_permission"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfRole(result); - } - - /** - * This call returns a list of roles given a permission name - * - * @param label The short friendly name of the role - * @return a list of references to roles - */ - public static Set getByPermissionNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_by_permission_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfRole(result); - } - - /** - * Return a list of all the roles known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfRole(result); - } - - /** - * Return a map of role references to role records for all roles known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "role.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfRoleRoleRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/SM.java b/deps/XenServerJava/src/com/xensource/xenapi/SM.java deleted file mode 100644 index 12b6a821abb..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/SM.java +++ /dev/null @@ -1,523 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A storage manager plugin - * - * @author Citrix Systems, Inc. - */ -public class SM extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - SM(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a SM, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof SM) - { - SM other = (SM) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a SM - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "type", this.type); - print.printf("%1$20s: %2$s\n", "vendor", this.vendor); - print.printf("%1$20s: %2$s\n", "copyright", this.copyright); - print.printf("%1$20s: %2$s\n", "version", this.version); - print.printf("%1$20s: %2$s\n", "requiredApiVersion", this.requiredApiVersion); - print.printf("%1$20s: %2$s\n", "configuration", this.configuration); - print.printf("%1$20s: %2$s\n", "capabilities", this.capabilities); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "driverFilename", this.driverFilename); - return writer.toString(); - } - - /** - * Convert a SM.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("type", this.type == null ? "" : this.type); - map.put("vendor", this.vendor == null ? "" : this.vendor); - map.put("copyright", this.copyright == null ? "" : this.copyright); - map.put("version", this.version == null ? "" : this.version); - map.put("required_api_version", this.requiredApiVersion == null ? "" : this.requiredApiVersion); - map.put("configuration", this.configuration == null ? new HashMap() : this.configuration); - map.put("capabilities", this.capabilities == null ? new LinkedHashSet() : this.capabilities); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("driver_filename", this.driverFilename == null ? "" : this.driverFilename); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * SR.type - */ - public String type; - /** - * Vendor who created this plugin - */ - public String vendor; - /** - * Entity which owns the copyright of this plugin - */ - public String copyright; - /** - * Version of the plugin - */ - public String version; - /** - * Minimum SM API version required on the server - */ - public String requiredApiVersion; - /** - * names and descriptions of device config keys - */ - public Map configuration; - /** - * capabilities of the SM plugin - */ - public Set capabilities; - /** - * additional configuration - */ - public Map otherConfig; - /** - * filename of the storage driver - */ - public String driverFilename; - } - - /** - * Get a record containing the current state of the given SM. - * - * @return all fields from the object - */ - public SM.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSMRecord(result); - } - - /** - * Get a reference to the SM instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static SM getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSM(result); - } - - /** - * Get all the SM instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfSM(result); - } - - /** - * Get the uuid field of the given SM. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given SM. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given SM. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the type field of the given SM. - * - * @return value of the field - */ - public String getType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the vendor field of the given SM. - * - * @return value of the field - */ - public String getVendor(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_vendor"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the copyright field of the given SM. - * - * @return value of the field - */ - public String getCopyright(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_copyright"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the version field of the given SM. - * - * @return value of the field - */ - public String getVersion(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the required_api_version field of the given SM. - * - * @return value of the field - */ - public String getRequiredApiVersion(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_required_api_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the configuration field of the given SM. - * - * @return value of the field - */ - public Map getConfiguration(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_configuration"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the capabilities field of the given SM. - * - * @return value of the field - */ - public Set getCapabilities(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_capabilities"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the other_config field of the given SM. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the driver_filename field of the given SM. - * - * @return value of the field - */ - public String getDriverFilename(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_driver_filename"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Set the other_config field of the given SM. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given SM. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given SM. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the SMs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfSM(result); - } - - /** - * Return a map of SM references to SM records for all SMs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SM.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfSMSMRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/SR.java b/deps/XenServerJava/src/com/xensource/xenapi/SR.java deleted file mode 100644 index 0f64aa58ca2..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/SR.java +++ /dev/null @@ -1,1477 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A storage repository - * - * @author Citrix Systems, Inc. - */ -public class SR extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - SR(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a SR, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof SR) - { - SR other = (SR) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a SR - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); - print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); - print.printf("%1$20s: %2$s\n", "VDIs", this.VDIs); - print.printf("%1$20s: %2$s\n", "PBDs", this.PBDs); - print.printf("%1$20s: %2$s\n", "virtualAllocation", this.virtualAllocation); - print.printf("%1$20s: %2$s\n", "physicalUtilisation", this.physicalUtilisation); - print.printf("%1$20s: %2$s\n", "physicalSize", this.physicalSize); - print.printf("%1$20s: %2$s\n", "type", this.type); - print.printf("%1$20s: %2$s\n", "contentType", this.contentType); - print.printf("%1$20s: %2$s\n", "shared", this.shared); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "tags", this.tags); - print.printf("%1$20s: %2$s\n", "smConfig", this.smConfig); - print.printf("%1$20s: %2$s\n", "blobs", this.blobs); - print.printf("%1$20s: %2$s\n", "localCacheEnabled", this.localCacheEnabled); - return writer.toString(); - } - - /** - * Convert a SR.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); - map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); - map.put("VDIs", this.VDIs == null ? new LinkedHashSet() : this.VDIs); - map.put("PBDs", this.PBDs == null ? new LinkedHashSet() : this.PBDs); - map.put("virtual_allocation", this.virtualAllocation == null ? 0 : this.virtualAllocation); - map.put("physical_utilisation", this.physicalUtilisation == null ? 0 : this.physicalUtilisation); - map.put("physical_size", this.physicalSize == null ? 0 : this.physicalSize); - map.put("type", this.type == null ? "" : this.type); - map.put("content_type", this.contentType == null ? "" : this.contentType); - map.put("shared", this.shared == null ? false : this.shared); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); - map.put("sm_config", this.smConfig == null ? new HashMap() : this.smConfig); - map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); - map.put("local_cache_enabled", this.localCacheEnabled == null ? false : this.localCacheEnabled); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. - */ - public Set allowedOperations; - /** - * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. - */ - public Map currentOperations; - /** - * all virtual disks known to this storage repository - */ - public Set VDIs; - /** - * describes how particular hosts can see this storage repository - */ - public Set PBDs; - /** - * sum of virtual_sizes of all VDIs in this storage repository (in bytes) - */ - public Long virtualAllocation; - /** - * physical space currently utilised on this storage repository (in bytes). Note that for sparse disk formats, physical_utilisation may be less than virtual_allocation - */ - public Long physicalUtilisation; - /** - * total physical size of the repository (in bytes) - */ - public Long physicalSize; - /** - * type of the storage repository - */ - public String type; - /** - * the type of the SR's content, if required (e.g. ISOs) - */ - public String contentType; - /** - * true if this SR is (capable of being) shared between multiple hosts - */ - public Boolean shared; - /** - * additional configuration - */ - public Map otherConfig; - /** - * user-specified tags for categorization purposes - */ - public Set tags; - /** - * SM dependent data - */ - public Map smConfig; - /** - * Binary blobs associated with this SR - */ - public Map blobs; - /** - * True if this SR is assigned to be the local cache for its host - */ - public Boolean localCacheEnabled; - } - - /** - * Get a record containing the current state of the given SR. - * - * @return all fields from the object - */ - public SR.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSRRecord(result); - } - - /** - * Get a reference to the SR instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static SR getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Get all the SR instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfSR(result); - } - - /** - * Get the uuid field of the given SR. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given SR. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given SR. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the allowed_operations field of the given SR. - * - * @return value of the field - */ - public Set getAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfStorageOperations(result); - } - - /** - * Get the current_operations field of the given SR. - * - * @return value of the field - */ - public Map getCurrentOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_current_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringStorageOperations(result); - } - - /** - * Get the VDIs field of the given SR. - * - * @return value of the field - */ - public Set getVDIs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_VDIs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVDI(result); - } - - /** - * Get the PBDs field of the given SR. - * - * @return value of the field - */ - public Set getPBDs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_PBDs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfPBD(result); - } - - /** - * Get the virtual_allocation field of the given SR. - * - * @return value of the field - */ - public Long getVirtualAllocation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_virtual_allocation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the physical_utilisation field of the given SR. - * - * @return value of the field - */ - public Long getPhysicalUtilisation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_physical_utilisation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the physical_size field of the given SR. - * - * @return value of the field - */ - public Long getPhysicalSize(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_physical_size"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the type field of the given SR. - * - * @return value of the field - */ - public String getType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the content_type field of the given SR. - * - * @return value of the field - */ - public String getContentType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_content_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the shared field of the given SR. - * - * @return value of the field - */ - public Boolean getShared(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_shared"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the other_config field of the given SR. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the tags field of the given SR. - * - * @return value of the field - */ - public Set getTags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the sm_config field of the given SR. - * - * @return value of the field - */ - public Map getSmConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_sm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the blobs field of the given SR. - * - * @return value of the field - */ - public Map getBlobs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_blobs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringBlob(result); - } - - /** - * Get the local_cache_enabled field of the given SR. - * - * @return value of the field - */ - public Boolean getLocalCacheEnabled(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_local_cache_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Set the name/label field of the given SR. - * - * @param label New value to set - */ - public void setNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the name/description field of the given SR. - * - * @param description New value to set - */ - public void setNameDescription(Connection c, String description) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given SR. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given SR. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given SR. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the tags field of the given SR. - * - * @param tags New value to set - */ - public void setTags(Connection c, Set tags) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given value to the tags field of the given SR. If the value is already in that Set, then do nothing. - * - * @param value New value to add - */ - public void addTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.add_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given value from the tags field of the given SR. If the value is not in that Set, then do nothing. - * - * @param value Value to remove - */ - public void removeTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.remove_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the sm_config field of the given SR. - * - * @param smConfig New value to set - */ - public void setSmConfig(Connection c, Map smConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_sm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the sm_config field of the given SR. - * - * @param key Key to add - * @param value Value to add - */ - public void addToSmConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.add_to_sm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the sm_config field of the given SR. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromSmConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.remove_from_sm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a new Storage Repository and introduce it into the managed system, creating both SR record and PBD record to attach it to current host (with specified device_config parameters) - * - * @param host The host to create/make the SR on - * @param deviceConfig The device config string that will be passed to backend SR driver - * @param physicalSize The physical size of the new storage repository - * @param nameLabel The name of the new storage repository - * @param nameDescription The description of the new storage repository - * @param type The type of the SR; used to specify the SR backend driver to use - * @param contentType The type of the new SRs content, if required (e.g. ISOs) - * @param shared True if the SR (is capable of) being shared by multiple hosts - * @param smConfig Storage backend specific configuration options - * @return Task - */ - public static Task createAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException, - Types.SrUnknownDriver { - - if(c.rioConnection){ - if (smConfig.isEmpty()){ - return rioCreateAsync(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, shared); - } else { - throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiCreateAsync(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, shared, smConfig); - } - } - - - - private static Task rioCreateAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared) throws - BadServerResponse, - XmlRpcException, - XenAPIException, - Types.SrUnknownDriver { - String method_call = "Async.SR.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - private static Task miamiCreateAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws - BadServerResponse, - XmlRpcException, - XenAPIException, - Types.SrUnknownDriver { - String method_call = "Async.SR.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new Storage Repository and introduce it into the managed system, creating both SR record and PBD record to attach it to current host (with specified device_config parameters) - * - * @param host The host to create/make the SR on - * @param deviceConfig The device config string that will be passed to backend SR driver - * @param physicalSize The physical size of the new storage repository - * @param nameLabel The name of the new storage repository - * @param nameDescription The description of the new storage repository - * @param type The type of the SR; used to specify the SR backend driver to use - * @param contentType The type of the new SRs content, if required (e.g. ISOs) - * @param shared True if the SR (is capable of) being shared by multiple hosts - * @param smConfig Storage backend specific configuration options - * @return The reference of the newly created Storage Repository. - */ - public static SR create(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException, - Types.SrUnknownDriver { - - if(c.rioConnection){ - if (smConfig.isEmpty()){ - return rioCreate(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, shared); - } else { - throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiCreate(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, shared, smConfig); - } - } - - - - private static SR rioCreate(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared) throws - BadServerResponse, - XmlRpcException, - XenAPIException, - Types.SrUnknownDriver { - String method_call = "SR.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - private static SR miamiCreate(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws - BadServerResponse, - XmlRpcException, - XenAPIException, - Types.SrUnknownDriver { - String method_call = "SR.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Introduce a new Storage Repository into the managed system - * - * @param uuid The uuid assigned to the introduced SR - * @param nameLabel The name of the new storage repository - * @param nameDescription The description of the new storage repository - * @param type The type of the SR; used to specify the SR backend driver to use - * @param contentType The type of the new SRs content, if required (e.g. ISOs) - * @param shared True if the SR (is capable of) being shared by multiple hosts - * @param smConfig Storage backend specific configuration options - * @return Task - */ - public static Task introduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException { - - if(c.rioConnection){ - if (smConfig.isEmpty()){ - return rioIntroduceAsync(c, uuid, nameLabel, nameDescription, type, contentType, shared); - } else { - throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiIntroduceAsync(c, uuid, nameLabel, nameDescription, type, contentType, shared, smConfig); - } - } - - - - private static Task rioIntroduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "Async.SR.introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - private static Task miamiIntroduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "Async.SR.introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Introduce a new Storage Repository into the managed system - * - * @param uuid The uuid assigned to the introduced SR - * @param nameLabel The name of the new storage repository - * @param nameDescription The description of the new storage repository - * @param type The type of the SR; used to specify the SR backend driver to use - * @param contentType The type of the new SRs content, if required (e.g. ISOs) - * @param shared True if the SR (is capable of) being shared by multiple hosts - * @param smConfig Storage backend specific configuration options - * @return The reference of the newly introduced Storage Repository. - */ - public static SR introduce(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException { - - if(c.rioConnection){ - if (smConfig.isEmpty()){ - return rioIntroduce(c, uuid, nameLabel, nameDescription, type, contentType, shared); - } else { - throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiIntroduce(c, uuid, nameLabel, nameDescription, type, contentType, shared, smConfig); - } - } - - - - private static SR rioIntroduce(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "SR.introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - private static SR miamiIntroduce(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "SR.introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Create a new Storage Repository on disk. This call is deprecated: use SR.create instead. - * @deprecated - * - * @param host The host to create/make the SR on - * @param deviceConfig The device config string that will be passed to backend SR driver - * @param physicalSize The physical size of the new storage repository - * @param nameLabel The name of the new storage repository - * @param nameDescription The description of the new storage repository - * @param type The type of the SR; used to specify the SR backend driver to use - * @param contentType The type of the new SRs content, if required (e.g. ISOs) - * @param smConfig Storage backend specific configuration options - * @return Task - */ - @Deprecated public static Task makeAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Map smConfig) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException { - - if(c.rioConnection){ - if (smConfig.isEmpty()){ - return rioMakeAsync(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType); - } else { - throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiMakeAsync(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, smConfig); - } - } - - - - @Deprecated private static Task rioMakeAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "Async.SR.make"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - @Deprecated private static Task miamiMakeAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Map smConfig) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "Async.SR.make"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new Storage Repository on disk. This call is deprecated: use SR.create instead. - * @deprecated - * - * @param host The host to create/make the SR on - * @param deviceConfig The device config string that will be passed to backend SR driver - * @param physicalSize The physical size of the new storage repository - * @param nameLabel The name of the new storage repository - * @param nameDescription The description of the new storage repository - * @param type The type of the SR; used to specify the SR backend driver to use - * @param contentType The type of the new SRs content, if required (e.g. ISOs) - * @param smConfig Storage backend specific configuration options - * @return The uuid of the newly created Storage Repository. - */ - @Deprecated public static String make(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Map smConfig) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException { - - if(c.rioConnection){ - if (smConfig.isEmpty()){ - return rioMake(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType); - } else { - throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiMake(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, smConfig); - } - } - - - - @Deprecated private static String rioMake(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "SR.make"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - @Deprecated private static String miamiMake(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Map smConfig) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "SR.make"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Destroy specified SR, removing SR-record from database and remove SR from disk. (In order to affect this operation the appropriate device_config is read from the specified SR's PBD on current host) - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrHasPbd { - String method_call = "Async.SR.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy specified SR, removing SR-record from database and remove SR from disk. (In order to affect this operation the appropriate device_config is read from the specified SR's PBD on current host) - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrHasPbd { - String method_call = "SR.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Removing specified SR-record from database, without attempting to remove SR from disk - * - * @return Task - */ - public Task forgetAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrHasPbd { - String method_call = "Async.SR.forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Removing specified SR-record from database, without attempting to remove SR from disk - * - */ - public void forget(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrHasPbd { - String method_call = "SR.forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Refresh the fields on the SR object - * - * @return Task - */ - public Task updateAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.SR.update"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Refresh the fields on the SR object - * - */ - public void update(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.update"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a set of all the SR types supported by the system - * - * @return the supported SR types - */ - public static Set getSupportedTypes(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_supported_types"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Refreshes the list of VDIs associated with an SR - * - * @return Task - */ - public Task scanAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.SR.scan"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Refreshes the list of VDIs associated with an SR - * - */ - public void scan(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.scan"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Perform a backend-specific scan, using the given device_config. If the device_config is complete, then this will return a list of the SRs present of this type on the device, if any. If the device_config is partial, then a backend-specific scan will be performed, returning results that will guide the user in improving the device_config. - * - * @param host The host to create/make the SR on - * @param deviceConfig The device config string that will be passed to backend SR driver - * @param type The type of the SR; used to specify the SR backend driver to use - * @param smConfig Storage backend specific configuration options - * @return Task - */ - public static Task probeAsync(Connection c, Host host, Map deviceConfig, String type, Map smConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.SR.probe"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Perform a backend-specific scan, using the given device_config. If the device_config is complete, then this will return a list of the SRs present of this type on the device, if any. If the device_config is partial, then a backend-specific scan will be performed, returning results that will guide the user in improving the device_config. - * - * @param host The host to create/make the SR on - * @param deviceConfig The device config string that will be passed to backend SR driver - * @param type The type of the SR; used to specify the SR backend driver to use - * @param smConfig Storage backend specific configuration options - * @return An XML fragment containing the scan results. These are specific to the scan being performed, and the backend. - */ - public static String probe(Connection c, Host host, Map deviceConfig, String type, Map smConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.probe"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Sets the shared flag on the SR - * - * @param value True if the SR is shared - * @return Task - */ - public Task setSharedAsync(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.SR.set_shared"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Sets the shared flag on the SR - * - * @param value True if the SR is shared - */ - public void setShared(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_shared"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this SR - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return Task - */ - public Task createNewBlobAsync(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.SR.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this SR - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return The reference of the blob, needed for populating its data - */ - public Blob createNewBlob(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBlob(result); - } - - /** - * Sets the SR's physical_size field - * - * @param value The new value of the SR's physical_size - */ - public void setPhysicalSize(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_physical_size"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the SR's virtual_allocation field - * - * @param value The new value of the SR's virtual_allocation - */ - public void setVirtualAllocation(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_virtual_allocation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the SR's physical_utilisation field - * - * @param value The new value of the SR's physical utilisation - */ - public void setPhysicalUtilisation(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.set_physical_utilisation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Returns successfully if the given SR can host an HA statefile. Otherwise returns an error to explain why not - * - * @return Task - */ - public Task assertCanHostHaStatefileAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.SR.assert_can_host_ha_statefile"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Returns successfully if the given SR can host an HA statefile. Otherwise returns an error to explain why not - * - */ - public void assertCanHostHaStatefile(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.assert_can_host_ha_statefile"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the SRs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfSR(result); - } - - /** - * Return a map of SR references to SR records for all SRs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "SR.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfSRSRRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Secret.java b/deps/XenServerJava/src/com/xensource/xenapi/Secret.java deleted file mode 100644 index 3a211a050a7..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Secret.java +++ /dev/null @@ -1,312 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A secret - * - * @author Citrix Systems, Inc. - */ -public class Secret extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Secret(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Secret, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Secret) - { - Secret other = (Secret) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Secret - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "value", this.value); - return writer.toString(); - } - - /** - * Convert a secret.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("value", this.value == null ? "" : this.value); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * the secret - */ - public String value; - } - - /** - * Get a record containing the current state of the given secret. - * - * @return all fields from the object - */ - public Secret.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSecretRecord(result); - } - - /** - * Get a reference to the secret instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Secret getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSecret(result); - } - - /** - * Create a new secret instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, Secret.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.secret.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new secret instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static Secret create(Connection c, Secret.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSecret(result); - } - - /** - * Destroy the specified secret instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.secret.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified secret instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the uuid field of the given secret. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the value field of the given secret. - * - * @return value of the field - */ - public String getValue(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.get_value"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Set the value field of the given secret. - * - * @param value New value to set - */ - public void setValue(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.set_value"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the secrets known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfSecret(result); - } - - /** - * Return a map of secret references to secret records for all secrets known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "secret.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfSecretSecretRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Session.java b/deps/XenServerJava/src/com/xensource/xenapi/Session.java deleted file mode 100644 index 9be3388304b..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Session.java +++ /dev/null @@ -1,670 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A session - * - * @author Citrix Systems, Inc. - */ -public class Session extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Session(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Session, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Session) - { - Session other = (Session) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Session - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "thisHost", this.thisHost); - print.printf("%1$20s: %2$s\n", "thisUser", this.thisUser); - print.printf("%1$20s: %2$s\n", "lastActive", this.lastActive); - print.printf("%1$20s: %2$s\n", "pool", this.pool); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "isLocalSuperuser", this.isLocalSuperuser); - print.printf("%1$20s: %2$s\n", "subject", this.subject); - print.printf("%1$20s: %2$s\n", "validationTime", this.validationTime); - print.printf("%1$20s: %2$s\n", "authUserSid", this.authUserSid); - print.printf("%1$20s: %2$s\n", "authUserName", this.authUserName); - print.printf("%1$20s: %2$s\n", "rbacPermissions", this.rbacPermissions); - print.printf("%1$20s: %2$s\n", "tasks", this.tasks); - print.printf("%1$20s: %2$s\n", "parent", this.parent); - return writer.toString(); - } - - /** - * Convert a session.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("this_host", this.thisHost == null ? new Host("OpaqueRef:NULL") : this.thisHost); - map.put("this_user", this.thisUser == null ? new User("OpaqueRef:NULL") : this.thisUser); - map.put("last_active", this.lastActive == null ? new Date(0) : this.lastActive); - map.put("pool", this.pool == null ? false : this.pool); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("is_local_superuser", this.isLocalSuperuser == null ? false : this.isLocalSuperuser); - map.put("subject", this.subject == null ? new Subject("OpaqueRef:NULL") : this.subject); - map.put("validation_time", this.validationTime == null ? new Date(0) : this.validationTime); - map.put("auth_user_sid", this.authUserSid == null ? "" : this.authUserSid); - map.put("auth_user_name", this.authUserName == null ? "" : this.authUserName); - map.put("rbac_permissions", this.rbacPermissions == null ? new LinkedHashSet() : this.rbacPermissions); - map.put("tasks", this.tasks == null ? new LinkedHashSet() : this.tasks); - map.put("parent", this.parent == null ? new Session("OpaqueRef:NULL") : this.parent); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * Currently connected host - */ - public Host thisHost; - /** - * Currently connected user - */ - public User thisUser; - /** - * Timestamp for last time session was active - */ - public Date lastActive; - /** - * True if this session relates to a intra-pool login, false otherwise - */ - public Boolean pool; - /** - * additional configuration - */ - public Map otherConfig; - /** - * true iff this session was created using local superuser credentials - */ - public Boolean isLocalSuperuser; - /** - * references the subject instance that created the session. If a session instance has is_local_superuser set, then the value of this field is undefined. - */ - public Subject subject; - /** - * time when session was last validated - */ - public Date validationTime; - /** - * the subject identifier of the user that was externally authenticated. If a session instance has is_local_superuser set, then the value of this field is undefined. - */ - public String authUserSid; - /** - * the subject name of the user that was externally authenticated. If a session instance has is_local_superuser set, then the value of this field is undefined. - */ - public String authUserName; - /** - * list with all RBAC permissions for this session - */ - public Set rbacPermissions; - /** - * list of tasks created using the current session - */ - public Set tasks; - /** - * references the parent session that created this session - */ - public Session parent; - } - - /** - * Get a record containing the current state of the given session. - * - * @return all fields from the object - */ - public Session.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSessionRecord(result); - } - - /** - * Get a reference to the session instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Session getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSession(result); - } - - /** - * Get the uuid field of the given session. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the this_host field of the given session. - * - * @return value of the field - */ - public Host getThisHost(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_this_host"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the this_user field of the given session. - * - * @return value of the field - */ - public User getThisUser(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_this_user"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toUser(result); - } - - /** - * Get the last_active field of the given session. - * - * @return value of the field - */ - public Date getLastActive(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_last_active"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the pool field of the given session. - * - * @return value of the field - */ - public Boolean getPool(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_pool"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the other_config field of the given session. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the is_local_superuser field of the given session. - * - * @return value of the field - */ - public Boolean getIsLocalSuperuser(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_is_local_superuser"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the subject field of the given session. - * - * @return value of the field - */ - public Subject getSubject(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_subject"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSubject(result); - } - - /** - * Get the validation_time field of the given session. - * - * @return value of the field - */ - public Date getValidationTime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_validation_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the auth_user_sid field of the given session. - * - * @return value of the field - */ - public String getAuthUserSid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_auth_user_sid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the auth_user_name field of the given session. - * - * @return value of the field - */ - public String getAuthUserName(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_auth_user_name"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the rbac_permissions field of the given session. - * - * @return value of the field - */ - public Set getRbacPermissions(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_rbac_permissions"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the tasks field of the given session. - * - * @return value of the field - */ - public Set getTasks(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_tasks"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfTask(result); - } - - /** - * Get the parent field of the given session. - * - * @return value of the field - */ - public Session getParent(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_parent"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSession(result); - } - - /** - * Set the other_config field of the given session. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given session. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given session. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Attempt to authenticate the user, returning a session reference if successful - * - * @param uname Username for login. - * @param pwd Password for login. - * @param version Client API version. - * @return reference of newly created session - */ - public static Session loginWithPassword(Connection c, String uname, String pwd, String version) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SessionAuthenticationFailed { - String method_call = "session.login_with_password"; - Object[] method_params = {Marshalling.toXMLRPC(uname), Marshalling.toXMLRPC(pwd), Marshalling.toXMLRPC(version)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSession(result); - } - - /** - * Log out of a session - * - */ - public static void logout(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.logout"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Change the account password; if your session is authenticated with root priviledges then the old_pwd is validated and the new_pwd is set regardless - * - * @param oldPwd Old password for account - * @param newPwd New password for account - */ - public static void changePassword(Connection c, String oldPwd, String newPwd) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.change_password"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(oldPwd), Marshalling.toXMLRPC(newPwd)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Authenticate locally against a slave in emergency mode. Note the resulting sessions are only good for use on this host. - * - * @param uname Username for login. - * @param pwd Password for login. - * @return ID of newly created session - */ - public static Session slaveLocalLoginWithPassword(Connection c, String uname, String pwd) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.slave_local_login_with_password"; - Object[] method_params = {Marshalling.toXMLRPC(uname), Marshalling.toXMLRPC(pwd)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSession(result); - } - - /** - * Log out of local session. - * - */ - public static void localLogout(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.local_logout"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the user subject-identifiers of all existing sessions - * - * @return Task - */ - public static Task getAllSubjectIdentifiersAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.session.get_all_subject_identifiers"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Return a list of all the user subject-identifiers of all existing sessions - * - * @return The list of user subject-identifiers of all existing sessions - */ - public static Set getAllSubjectIdentifiers(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.get_all_subject_identifiers"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Log out all sessions associated to a user subject-identifier, except the session associated with the context calling this function - * - * @param subjectIdentifier User subject-identifier of the sessions to be destroyed - * @return Task - */ - public static Task logoutSubjectIdentifierAsync(Connection c, String subjectIdentifier) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.session.logout_subject_identifier"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Log out all sessions associated to a user subject-identifier, except the session associated with the context calling this function - * - * @param subjectIdentifier User subject-identifier of the sessions to be destroyed - */ - public static void logoutSubjectIdentifier(Connection c, String subjectIdentifier) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "session.logout_subject_identifier"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)}; - Map response = c.dispatch(method_call, method_params); - return; - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Subject.java b/deps/XenServerJava/src/com/xensource/xenapi/Subject.java deleted file mode 100644 index e760a5f751e..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Subject.java +++ /dev/null @@ -1,391 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A user or group that can log in xapi - * - * @author Citrix Systems, Inc. - */ -public class Subject extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Subject(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Subject, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Subject) - { - Subject other = (Subject) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Subject - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "subjectIdentifier", this.subjectIdentifier); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "roles", this.roles); - return writer.toString(); - } - - /** - * Convert a subject.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("subject_identifier", this.subjectIdentifier == null ? "" : this.subjectIdentifier); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("roles", this.roles == null ? new LinkedHashSet() : this.roles); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * the subject identifier, unique in the external directory service - */ - public String subjectIdentifier; - /** - * additional configuration - */ - public Map otherConfig; - /** - * the roles associated with this subject - */ - public Set roles; - } - - /** - * Get a record containing the current state of the given subject. - * - * @return all fields from the object - */ - public Subject.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSubjectRecord(result); - } - - /** - * Get a reference to the subject instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Subject getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSubject(result); - } - - /** - * Create a new subject instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, Subject.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.subject.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new subject instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static Subject create(Connection c, Subject.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSubject(result); - } - - /** - * Destroy the specified subject instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.subject.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified subject instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the uuid field of the given subject. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the subject_identifier field of the given subject. - * - * @return value of the field - */ - public String getSubjectIdentifier(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_subject_identifier"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the other_config field of the given subject. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the roles field of the given subject. - * - * @return value of the field - */ - public Set getRoles(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_roles"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfRole(result); - } - - /** - * This call adds a new role to a subject - * - * @param role The unique role reference - */ - public void addToRoles(Connection c, Role role) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.add_to_roles"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(role)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call removes a role from a subject - * - * @param role The unique role reference in the subject's roles field - */ - public void removeFromRoles(Connection c, Role role) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.remove_from_roles"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(role)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call returns a list of permission names given a subject - * - * @return a list of permission names - */ - public Set getPermissionsNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_permissions_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Return a list of all the subjects known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfSubject(result); - } - - /** - * Return a map of subject references to subject records for all subjects known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "subject.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfSubjectSubjectRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Task.java b/deps/XenServerJava/src/com/xensource/xenapi/Task.java deleted file mode 100644 index 884b283a91f..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Task.java +++ /dev/null @@ -1,683 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A long-running asynchronous task - * - * @author Citrix Systems, Inc. - */ -public class Task extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Task(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Task, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Task) - { - Task other = (Task) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Task - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); - print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); - print.printf("%1$20s: %2$s\n", "created", this.created); - print.printf("%1$20s: %2$s\n", "finished", this.finished); - print.printf("%1$20s: %2$s\n", "status", this.status); - print.printf("%1$20s: %2$s\n", "residentOn", this.residentOn); - print.printf("%1$20s: %2$s\n", "progress", this.progress); - print.printf("%1$20s: %2$s\n", "type", this.type); - print.printf("%1$20s: %2$s\n", "result", this.result); - print.printf("%1$20s: %2$s\n", "errorInfo", this.errorInfo); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "subtaskOf", this.subtaskOf); - print.printf("%1$20s: %2$s\n", "subtasks", this.subtasks); - return writer.toString(); - } - - /** - * Convert a task.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); - map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); - map.put("created", this.created == null ? new Date(0) : this.created); - map.put("finished", this.finished == null ? new Date(0) : this.finished); - map.put("status", this.status == null ? Types.TaskStatusType.UNRECOGNIZED : this.status); - map.put("resident_on", this.residentOn == null ? new Host("OpaqueRef:NULL") : this.residentOn); - map.put("progress", this.progress == null ? 0.0 : this.progress); - map.put("type", this.type == null ? "" : this.type); - map.put("result", this.result == null ? "" : this.result); - map.put("error_info", this.errorInfo == null ? new LinkedHashSet() : this.errorInfo); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("subtask_of", this.subtaskOf == null ? new Task("OpaqueRef:NULL") : this.subtaskOf); - map.put("subtasks", this.subtasks == null ? new LinkedHashSet() : this.subtasks); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. - */ - public Set allowedOperations; - /** - * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. - */ - public Map currentOperations; - /** - * Time task was created - */ - public Date created; - /** - * Time task finished (i.e. succeeded or failed). If task-status is pending, then the value of this field has no meaning - */ - public Date finished; - /** - * current status of the task - */ - public Types.TaskStatusType status; - /** - * the host on which the task is running - */ - public Host residentOn; - /** - * if the task is still pending, this field contains the estimated fraction complete (0.-1.). If task has completed (successfully or unsuccessfully) this should be 1. - */ - public Double progress; - /** - * if the task has completed successfully, this field contains the type of the encoded result (i.e. name of the class whose reference is in the result field). Undefined otherwise. - */ - public String type; - /** - * if the task has completed successfully, this field contains the result value (either Void or an object reference). Undefined otherwise. - */ - public String result; - /** - * if the task has failed, this field contains the set of associated error strings. Undefined otherwise. - */ - public Set errorInfo; - /** - * additional configuration - */ - public Map otherConfig; - /** - * Ref pointing to the task this is a substask of. - */ - public Task subtaskOf; - /** - * List pointing to all the substasks. - */ - public Set subtasks; - } - - /** - * Get a record containing the current state of the given task. - * - * @return all fields from the object - */ - public Task.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTaskRecord(result); - } - - /** - * Get a reference to the task instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Task getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Get all the task instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfTask(result); - } - - /** - * Get the uuid field of the given task. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given task. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given task. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the allowed_operations field of the given task. - * - * @return value of the field - */ - public Set getAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfTaskAllowedOperations(result); - } - - /** - * Get the current_operations field of the given task. - * - * @return value of the field - */ - public Map getCurrentOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_current_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringTaskAllowedOperations(result); - } - - /** - * Get the created field of the given task. - * - * @return value of the field - */ - public Date getCreated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_created"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the finished field of the given task. - * - * @return value of the field - */ - public Date getFinished(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_finished"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the status field of the given task. - * - * @return value of the field - */ - public Types.TaskStatusType getStatus(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_status"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTaskStatusType(result); - } - - /** - * Get the resident_on field of the given task. - * - * @return value of the field - */ - public Host getResidentOn(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_resident_on"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the progress field of the given task. - * - * @return value of the field - */ - public Double getProgress(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_progress"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the type field of the given task. - * - * @return value of the field - */ - public String getType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the result field of the given task. - * - * @return value of the field - */ - public String getResult(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_result"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the error_info field of the given task. - * - * @return value of the field - */ - public Set getErrorInfo(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_error_info"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the other_config field of the given task. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the subtask_of field of the given task. - * - * @return value of the field - */ - public Task getSubtaskOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_subtask_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Get the subtasks field of the given task. - * - * @return value of the field - */ - public Set getSubtasks(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_subtasks"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfTask(result); - } - - /** - * Set the other_config field of the given task. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given task. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given task. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a new task object which must be manually destroyed. - * - * @param label short label for the new task - * @param description longer description for the new task - * @return The reference of the created task object - */ - public static Task create(Connection c, String label, String description) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label), Marshalling.toXMLRPC(description)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the task object - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Request that a task be cancelled. Note that a task may fail to be cancelled and may complete or fail normally and note that, even when a task does cancel, it might take an arbitrary amount of time. - * - * @return Task - */ - public Task cancelAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.OperationNotAllowed { - String method_call = "Async.task.cancel"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Request that a task be cancelled. Note that a task may fail to be cancelled and may complete or fail normally and note that, even when a task does cancel, it might take an arbitrary amount of time. - * - */ - public void cancel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.OperationNotAllowed { - String method_call = "task.cancel"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the tasks known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfTask(result); - } - - /** - * Return a map of task references to task records for all tasks known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "task.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfTaskTaskRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java b/deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java deleted file mode 100644 index 17475238ed4..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java +++ /dev/null @@ -1,469 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A tunnel for network traffic - * - * @author Citrix Systems, Inc. - */ -public class Tunnel extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - Tunnel(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a Tunnel, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof Tunnel) - { - Tunnel other = (Tunnel) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a Tunnel - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "accessPIF", this.accessPIF); - print.printf("%1$20s: %2$s\n", "transportPIF", this.transportPIF); - print.printf("%1$20s: %2$s\n", "status", this.status); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a tunnel.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("access_PIF", this.accessPIF == null ? new PIF("OpaqueRef:NULL") : this.accessPIF); - map.put("transport_PIF", this.transportPIF == null ? new PIF("OpaqueRef:NULL") : this.transportPIF); - map.put("status", this.status == null ? new HashMap() : this.status); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * The interface through which the tunnel is accessed - */ - public PIF accessPIF; - /** - * The interface used by the tunnel - */ - public PIF transportPIF; - /** - * Status information about the tunnel - */ - public Map status; - /** - * Additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given tunnel. - * - * @return all fields from the object - */ - public Tunnel.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTunnelRecord(result); - } - - /** - * Get a reference to the tunnel instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static Tunnel getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTunnel(result); - } - - /** - * Get the uuid field of the given tunnel. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the access_PIF field of the given tunnel. - * - * @return value of the field - */ - public PIF getAccessPIF(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_access_PIF"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Get the transport_PIF field of the given tunnel. - * - * @return value of the field - */ - public PIF getTransportPIF(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_transport_PIF"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Get the status field of the given tunnel. - * - * @return value of the field - */ - public Map getStatus(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_status"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the other_config field of the given tunnel. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the status field of the given tunnel. - * - * @param status New value to set - */ - public void setStatus(Connection c, Map status) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.set_status"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(status)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the status field of the given tunnel. - * - * @param key Key to add - * @param value Value to add - */ - public void addToStatus(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.add_to_status"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the status field of the given tunnel. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromStatus(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.remove_from_status"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given tunnel. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given tunnel. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given tunnel. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a tunnel - * - * @param transportPIF PIF which receives the tagged traffic - * @param network Network to receive the tunnelled traffic - * @return Task - */ - public static Task createAsync(Connection c, PIF transportPIF, Network network) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.OpenvswitchNotActive, - Types.TransportPifNotConfigured, - Types.IsTunnelAccessPif { - String method_call = "Async.tunnel.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(transportPIF), Marshalling.toXMLRPC(network)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a tunnel - * - * @param transportPIF PIF which receives the tagged traffic - * @param network Network to receive the tunnelled traffic - * @return The reference of the created tunnel object - */ - public static Tunnel create(Connection c, PIF transportPIF, Network network) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.OpenvswitchNotActive, - Types.TransportPifNotConfigured, - Types.IsTunnelAccessPif { - String method_call = "tunnel.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(transportPIF), Marshalling.toXMLRPC(network)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTunnel(result); - } - - /** - * Destroy a tunnel - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.tunnel.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy a tunnel - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the tunnels known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfTunnel(result); - } - - /** - * Return a map of tunnel references to tunnel records for all tunnels known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "tunnel.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfTunnelTunnelRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Types.java b/deps/XenServerJava/src/com/xensource/xenapi/Types.java deleted file mode 100644 index 31ac11a09eb..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Types.java +++ /dev/null @@ -1,11096 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import java.util.Date; -import java.util.Map; -import java.util.HashMap; -import java.util.Set; -import java.util.LinkedHashSet; -import java.io.IOException; - -import java.util.regex.Pattern; -import java.util.regex.Matcher; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * This class holds vital marshalling functions, enum types and exceptions. - * - * @author Citrix Systems, Inc. - */ -public class Types -{ - /** - * Interface for all Record classes - */ - public static interface Record - { - /** - * Convert a Record to a Map - */ - Map toMap(); - } - - /** - * Helper method. - */ - private static String[] ObjectArrayToStringArray(Object[] objArray) - { - String[] result = new String[objArray.length]; - for (int i = 0; i < objArray.length; i++) - { - result[i] = (String) objArray[i]; - } - return result; - } - - /** - * Base class for all XenAPI Exceptions - */ - public static class XenAPIException extends IOException { - public final String shortDescription; - public final String[] errorDescription; - - XenAPIException(String shortDescription) - { - this.shortDescription = shortDescription; - this.errorDescription = null; - } - - XenAPIException(String[] errorDescription) - { - this.errorDescription = errorDescription; - - if (errorDescription.length > 0) - { - shortDescription = errorDescription[0]; - } else - { - shortDescription = ""; - } - } - - public String toString() - { - if (errorDescription == null) - { - return shortDescription; - } else if (errorDescription.length == 0) - { - return ""; - } - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < errorDescription.length - 1; i++) - { - sb.append(errorDescription[i]); - } - sb.append(errorDescription[errorDescription.length - 1]); - - return sb.toString(); - } - } - /** - * Thrown if the response from the server contains an invalid status. - */ - public static class BadServerResponse extends XenAPIException - { - public BadServerResponse(Map response) - { - super(ObjectArrayToStringArray((Object[]) response.get("ErrorDescription"))); - } - } - - public static class BadAsyncResult extends XenAPIException - { - public final String result; - - public BadAsyncResult(String result) - { - super(result); - this.result = result; - } - } - - /* - * A call has been made which should not be made against this version of host. - * Probably the host is out of date and cannot handle this call, or is - * unable to comply with the details of the call. For instance SR.create - * on Miami (4.1) hosts takes an smConfig parameter, which must be an empty map - * when making this call on Rio (4.0) hosts. - */ - public static class VersionException extends XenAPIException - { - public final String result; - - public VersionException(String result) - { - super(result); - this.result = result; - } - } - - private static String parseResult(String result) throws BadAsyncResult - { - Pattern pattern = Pattern.compile("(.*)"); - Matcher matcher = pattern.matcher(result); - matcher.find(); - - if (matcher.groupCount() != 1) - { - throw new Types.BadAsyncResult("Can't interpret: " + result); - } - - return matcher.group(1); - } - /** - * Checks the provided server response was successful. If the call failed, throws a XenAPIException. If the server - * returned an invalid response, throws a BadServerResponse. Otherwise, returns the server response as passed in. - */ - static Map checkResponse(Map response) throws XenAPIException, BadServerResponse - { - if (response.get("Status").equals("Success")) - { - return response; - } - - if (response.get("Status").equals("Failure")) - { - String[] ErrorDescription = ObjectArrayToStringArray((Object[]) response.get("ErrorDescription")); - - if (ErrorDescription[0].equals("RESTORE_TARGET_MISSING_DEVICE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.RestoreTargetMissingDevice(p1); - } - if (ErrorDescription[0].equals("WLB_TIMEOUT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.WlbTimeout(p1); - } - if (ErrorDescription[0].equals("MAC_DOES_NOT_EXIST")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.MacDoesNotExist(p1); - } - if (ErrorDescription[0].equals("HANDLE_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.HandleInvalid(p1, p2); - } - if (ErrorDescription[0].equals("DEVICE_ALREADY_ATTACHED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.DeviceAlreadyAttached(p1); - } - if (ErrorDescription[0].equals("INVALID_IP_ADDRESS_SPECIFIED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.InvalidIpAddressSpecified(p1); - } - if (ErrorDescription[0].equals("SR_NOT_EMPTY")) - { - throw new Types.SrNotEmpty(); - } - if (ErrorDescription[0].equals("VM_HVM_REQUIRED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmHvmRequired(p1); - } - if (ErrorDescription[0].equals("PIF_TUNNEL_STILL_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PifTunnelStillExists(p1); - } - if (ErrorDescription[0].equals("PIF_BOND_NEEDS_MORE_MEMBERS")) - { - throw new Types.PifBondNeedsMoreMembers(); - } - if (ErrorDescription[0].equals("PIF_ALREADY_BONDED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PifAlreadyBonded(p1); - } - if (ErrorDescription[0].equals("VLAN_TAG_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VlanTagInvalid(p1); - } - if (ErrorDescription[0].equals("HOST_IS_SLAVE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostIsSlave(p1); - } - if (ErrorDescription[0].equals("SR_HAS_MULTIPLE_PBDS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrHasMultiplePbds(p1); - } - if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_INVALID_OU")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthEnableFailedInvalidOu(p1, p2); - } - if (ErrorDescription[0].equals("IMPORT_ERROR_SOME_CHECKSUMS_FAILED")) - { - throw new Types.ImportErrorSomeChecksumsFailed(); - } - if (ErrorDescription[0].equals("OPENVSWITCH_NOT_ACTIVE")) - { - throw new Types.OpenvswitchNotActive(); - } - if (ErrorDescription[0].equals("CANNOT_FIND_OEM_BACKUP_PARTITION")) - { - throw new Types.CannotFindOemBackupPartition(); - } - if (ErrorDescription[0].equals("PIF_DEVICE_NOT_FOUND")) - { - throw new Types.PifDeviceNotFound(); - } - if (ErrorDescription[0].equals("DOMAIN_BUILDER_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.DomainBuilderError(p1, p2, p3); - } - if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_VM_RUNNING")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PatchPrecheckFailedVmRunning(p1); - } - if (ErrorDescription[0].equals("HA_HOST_CANNOT_SEE_PEERS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.HaHostCannotSeePeers(p1, p2, p3); - } - if (ErrorDescription[0].equals("POOL_AUTH_DISABLE_FAILED_PERMISSION_DENIED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthDisableFailedPermissionDenied(p1, p2); - } - if (ErrorDescription[0].equals("PERMISSION_DENIED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PermissionDenied(p1); - } - if (ErrorDescription[0].equals("SSL_VERIFY_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SslVerifyError(p1); - } - if (ErrorDescription[0].equals("SR_ATTACH_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrAttachFailed(p1); - } - if (ErrorDescription[0].equals("SUBJECT_ALREADY_EXISTS")) - { - throw new Types.SubjectAlreadyExists(); - } - if (ErrorDescription[0].equals("HA_LOST_STATEFILE")) - { - throw new Types.HaLostStatefile(); - } - if (ErrorDescription[0].equals("HA_NOT_ENABLED")) - { - throw new Types.HaNotEnabled(); - } - if (ErrorDescription[0].equals("HA_HEARTBEAT_DAEMON_STARTUP_FAILED")) - { - throw new Types.HaHeartbeatDaemonStartupFailed(); - } - if (ErrorDescription[0].equals("SESSION_NOT_REGISTERED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SessionNotRegistered(p1); - } - if (ErrorDescription[0].equals("VM_NO_SUSPEND_SR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmNoSuspendSr(p1); - } - if (ErrorDescription[0].equals("PATCH_APPLY_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PatchApplyFailed(p1); - } - if (ErrorDescription[0].equals("VDI_READONLY")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VdiReadonly(p1); - } - if (ErrorDescription[0].equals("SR_FULL")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.SrFull(p1, p2); - } - if (ErrorDescription[0].equals("VDI_NOT_AVAILABLE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VdiNotAvailable(p1); - } - if (ErrorDescription[0].equals("XMLRPC_UNMARSHAL_FAILURE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XmlrpcUnmarshalFailure(p1, p2); - } - if (ErrorDescription[0].equals("CRL_ALREADY_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CrlAlreadyExists(p1); - } - if (ErrorDescription[0].equals("HOST_MASTER_CANNOT_TALK_BACK")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostMasterCannotTalkBack(p1); - } - if (ErrorDescription[0].equals("XAPI_HOOK_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - String p4 = ErrorDescription.length > 4 ? ErrorDescription[4] : ""; - throw new Types.XapiHookFailed(p1, p2, p3, p4); - } - if (ErrorDescription[0].equals("IMPORT_INCOMPATIBLE_VERSION")) - { - throw new Types.ImportIncompatibleVersion(); - } - if (ErrorDescription[0].equals("UNKNOWN_BOOTLOADER")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.UnknownBootloader(p1, p2); - } - if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_PROV_NOT_LOADED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XenVssReqErrorProvNotLoaded(p1, p2); - } - if (ErrorDescription[0].equals("SR_VDI_LOCKING_FAILED")) - { - throw new Types.SrVdiLockingFailed(); - } - if (ErrorDescription[0].equals("PIF_IS_PHYSICAL")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PifIsPhysical(p1); - } - if (ErrorDescription[0].equals("MAP_DUPLICATE_KEY")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - String p4 = ErrorDescription.length > 4 ? ErrorDescription[4] : ""; - throw new Types.MapDuplicateKey(p1, p2, p3, p4); - } - if (ErrorDescription[0].equals("MISSING_CONNECTION_DETAILS")) - { - throw new Types.MissingConnectionDetails(); - } - if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_CREATING_SNAPSHOT_XML_STRING")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XenVssReqErrorCreatingSnapshotXmlString(p1, p2); - } - if (ErrorDescription[0].equals("BOOTLOADER_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.BootloaderFailed(p1, p2); - } - if (ErrorDescription[0].equals("WLB_XENSERVER_MALFORMED_RESPONSE")) - { - throw new Types.WlbXenserverMalformedResponse(); - } - if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_DUPLICATE_HOSTNAME")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthEnableFailedDuplicateHostname(p1, p2); - } - if (ErrorDescription[0].equals("SYSTEM_STATUS_RETRIEVAL_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SystemStatusRetrievalFailed(p1); - } - if (ErrorDescription[0].equals("VDI_IN_USE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VdiInUse(p1, p2); - } - if (ErrorDescription[0].equals("HOST_NOT_LIVE")) - { - throw new Types.HostNotLive(); - } - if (ErrorDescription[0].equals("CERTIFICATE_ALREADY_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CertificateAlreadyExists(p1); - } - if (ErrorDescription[0].equals("SR_HAS_NO_PBDS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrHasNoPbds(p1); - } - if (ErrorDescription[0].equals("INVALID_PATCH")) - { - throw new Types.InvalidPatch(); - } - if (ErrorDescription[0].equals("SR_INDESTRUCTIBLE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrIndestructible(p1); - } - if (ErrorDescription[0].equals("HA_ABORT_NEW_MASTER")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HaAbortNewMaster(p1); - } - if (ErrorDescription[0].equals("WLB_MALFORMED_RESPONSE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.WlbMalformedResponse(p1, p2, p3); - } - if (ErrorDescription[0].equals("POOL_JOINING_HOST_MUST_HAVE_PHYSICAL_MANAGEMENT_NIC")) - { - throw new Types.PoolJoiningHostMustHavePhysicalManagementNic(); - } - if (ErrorDescription[0].equals("WLB_XENSERVER_AUTHENTICATION_FAILED")) - { - throw new Types.WlbXenserverAuthenticationFailed(); - } - if (ErrorDescription[0].equals("CANNOT_RESET_CONTROL_DOMAIN")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CannotResetControlDomain(p1); - } - if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_UNKNOWN_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PatchPrecheckFailedUnknownError(p1, p2); - } - if (ErrorDescription[0].equals("HOST_CANNOT_ATTACH_NETWORK")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.HostCannotAttachNetwork(p1, p2); - } - if (ErrorDescription[0].equals("WLB_URL_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.WlbUrlInvalid(p1); - } - if (ErrorDescription[0].equals("DUPLICATE_VM")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.DuplicateVm(p1); - } - if (ErrorDescription[0].equals("HOST_CANNOT_DESTROY_SELF")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostCannotDestroySelf(p1); - } - if (ErrorDescription[0].equals("HOST_BROKEN")) - { - throw new Types.HostBroken(); - } - if (ErrorDescription[0].equals("VM_CHECKPOINT_RESUME_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmCheckpointResumeFailed(p1); - } - if (ErrorDescription[0].equals("VM_TOO_MANY_VCPUS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmTooManyVcpus(p1); - } - if (ErrorDescription[0].equals("HOST_IS_LIVE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostIsLive(p1); - } - if (ErrorDescription[0].equals("IMPORT_ERROR_ATTACHED_DISKS_NOT_FOUND")) - { - throw new Types.ImportErrorAttachedDisksNotFound(); - } - if (ErrorDescription[0].equals("VBD_NOT_UNPLUGGABLE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VbdNotUnpluggable(p1); - } - if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_CREATING_SNAPSHOT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XenVssReqErrorCreatingSnapshot(p1, p2); - } - if (ErrorDescription[0].equals("CANNOT_ENABLE_REDO_LOG")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CannotEnableRedoLog(p1); - } - if (ErrorDescription[0].equals("CANNOT_EVACUATE_HOST")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CannotEvacuateHost(p1); - } - if (ErrorDescription[0].equals("NO_HOSTS_AVAILABLE")) - { - throw new Types.NoHostsAvailable(); - } - if (ErrorDescription[0].equals("DEVICE_ATTACH_TIMEOUT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.DeviceAttachTimeout(p1, p2); - } - if (ErrorDescription[0].equals("INVALID_DEVICE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.InvalidDevice(p1); - } - if (ErrorDescription[0].equals("PBD_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.PbdExists(p1, p2, p3); - } - if (ErrorDescription[0].equals("WLB_XENSERVER_CONNECTION_REFUSED")) - { - throw new Types.WlbXenserverConnectionRefused(); - } - if (ErrorDescription[0].equals("HOST_CANNOT_READ_METRICS")) - { - throw new Types.HostCannotReadMetrics(); - } - if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthEnableFailed(p1, p2); - } - if (ErrorDescription[0].equals("VM_SNAPSHOT_WITH_QUIESCE_NOT_SUPPORTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VmSnapshotWithQuiesceNotSupported(p1, p2); - } - if (ErrorDescription[0].equals("LICENSE_DOES_NOT_SUPPORT_POOLING")) - { - throw new Types.LicenseDoesNotSupportPooling(); - } - if (ErrorDescription[0].equals("HOST_UNKNOWN_TO_MASTER")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostUnknownToMaster(p1); - } - if (ErrorDescription[0].equals("WLB_CONNECTION_REFUSED")) - { - throw new Types.WlbConnectionRefused(); - } - if (ErrorDescription[0].equals("VM_SNAPSHOT_WITH_QUIESCE_PLUGIN_DEOS_NOT_RESPOND")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmSnapshotWithQuiescePluginDeosNotRespond(p1); - } - if (ErrorDescription[0].equals("VM_REQUIRES_SR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VmRequiresSr(p1, p2); - } - if (ErrorDescription[0].equals("VM_NO_CRASHDUMP_SR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmNoCrashdumpSr(p1); - } - if (ErrorDescription[0].equals("HA_NOT_INSTALLED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HaNotInstalled(p1); - } - if (ErrorDescription[0].equals("DUPLICATE_PIF_DEVICE_NAME")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.DuplicatePifDeviceName(p1); - } - if (ErrorDescription[0].equals("VM_BAD_POWER_STATE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.VmBadPowerState(p1, p2, p3); - } - if (ErrorDescription[0].equals("WLB_DISABLED")) - { - throw new Types.WlbDisabled(); - } - if (ErrorDescription[0].equals("POOL_JOINING_EXTERNAL_AUTH_MISMATCH")) - { - throw new Types.PoolJoiningExternalAuthMismatch(); - } - if (ErrorDescription[0].equals("VM_BIOS_STRINGS_ALREADY_SET")) - { - throw new Types.VmBiosStringsAlreadySet(); - } - if (ErrorDescription[0].equals("WLB_XENSERVER_UNKNOWN_HOST")) - { - throw new Types.WlbXenserverUnknownHost(); - } - if (ErrorDescription[0].equals("HA_HOST_CANNOT_ACCESS_STATEFILE")) - { - throw new Types.HaHostCannotAccessStatefile(); - } - if (ErrorDescription[0].equals("VM_FAILED_SHUTDOWN_ACKNOWLEDGMENT")) - { - throw new Types.VmFailedShutdownAcknowledgment(); - } - if (ErrorDescription[0].equals("AUTH_SERVICE_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthServiceError(p1); - } - if (ErrorDescription[0].equals("HOST_IN_EMERGENCY_MODE")) - { - throw new Types.HostInEmergencyMode(); - } - if (ErrorDescription[0].equals("HOST_DISABLED_UNTIL_REBOOT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostDisabledUntilReboot(p1); - } - if (ErrorDescription[0].equals("DEFAULT_SR_NOT_FOUND")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.DefaultSrNotFound(p1); - } - if (ErrorDescription[0].equals("DEVICE_ALREADY_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.DeviceAlreadyExists(p1); - } - if (ErrorDescription[0].equals("SR_NOT_SHARABLE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.SrNotSharable(p1, p2); - } - if (ErrorDescription[0].equals("AUTH_DISABLE_FAILED_PERMISSION_DENIED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthDisableFailedPermissionDenied(p1); - } - if (ErrorDescription[0].equals("LICENSE_CANNOT_DOWNGRADE_WHILE_IN_POOL")) - { - throw new Types.LicenseCannotDowngradeWhileInPool(); - } - if (ErrorDescription[0].equals("RBAC_PERMISSION_DENIED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.RbacPermissionDenied(p1, p2); - } - if (ErrorDescription[0].equals("TOO_MANY_PENDING_TASKS")) - { - throw new Types.TooManyPendingTasks(); - } - if (ErrorDescription[0].equals("VM_SNAPSHOT_WITH_QUIESCE_TIMEOUT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmSnapshotWithQuiesceTimeout(p1); - } - if (ErrorDescription[0].equals("PATCH_ALREADY_APPLIED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PatchAlreadyApplied(p1); - } - if (ErrorDescription[0].equals("SR_UUID_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrUuidExists(p1); - } - if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED_DOMAIN_LOOKUP_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthEnableFailedDomainLookupFailed(p1); - } - if (ErrorDescription[0].equals("INVALID_FEATURE_STRING")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.InvalidFeatureString(p1); - } - if (ErrorDescription[0].equals("WLB_NOT_INITIALIZED")) - { - throw new Types.WlbNotInitialized(); - } - if (ErrorDescription[0].equals("OPERATION_BLOCKED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.OperationBlocked(p1, p2); - } - if (ErrorDescription[0].equals("PROVISION_ONLY_ALLOWED_ON_TEMPLATE")) - { - throw new Types.ProvisionOnlyAllowedOnTemplate(); - } - if (ErrorDescription[0].equals("VM_SHUTDOWN_TIMEOUT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VmShutdownTimeout(p1, p2); - } - if (ErrorDescription[0].equals("NETWORK_CONTAINS_PIF")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.NetworkContainsPif(p1); - } - if (ErrorDescription[0].equals("ROLE_ALREADY_EXISTS")) - { - throw new Types.RoleAlreadyExists(); - } - if (ErrorDescription[0].equals("JOINING_HOST_SERVICE_FAILED")) - { - throw new Types.JoiningHostServiceFailed(); - } - if (ErrorDescription[0].equals("VDI_MISSING")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VdiMissing(p1, p2); - } - if (ErrorDescription[0].equals("VBD_TRAY_LOCKED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VbdTrayLocked(p1); - } - if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_PERMISSION_DENIED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthEnableFailedPermissionDenied(p1, p2); - } - if (ErrorDescription[0].equals("UUID_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.UuidInvalid(p1, p2); - } - if (ErrorDescription[0].equals("LICENCE_RESTRICTION")) - { - throw new Types.LicenceRestriction(); - } - if (ErrorDescription[0].equals("VIF_IN_USE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VifInUse(p1, p2); - } - if (ErrorDescription[0].equals("ONLY_ALLOWED_ON_OEM_EDITION")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.OnlyAllowedOnOemEdition(p1); - } - if (ErrorDescription[0].equals("VDI_IS_A_PHYSICAL_DEVICE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VdiIsAPhysicalDevice(p1); - } - if (ErrorDescription[0].equals("LICENSE_PROCESSING_ERROR")) - { - throw new Types.LicenseProcessingError(); - } - if (ErrorDescription[0].equals("CRL_DOES_NOT_EXIST")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CrlDoesNotExist(p1); - } - if (ErrorDescription[0].equals("TASK_CANCELLED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.TaskCancelled(p1); - } - if (ErrorDescription[0].equals("VM_CRASHED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmCrashed(p1); - } - if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_DOMAIN_LOOKUP_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthEnableFailedDomainLookupFailed(p1, p2); - } - if (ErrorDescription[0].equals("HA_SHOULD_BE_FENCED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HaShouldBeFenced(p1); - } - if (ErrorDescription[0].equals("VM_UNSAFE_BOOT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmUnsafeBoot(p1); - } - if (ErrorDescription[0].equals("PIF_HAS_NO_NETWORK_CONFIGURATION")) - { - throw new Types.PifHasNoNetworkConfiguration(); - } - if (ErrorDescription[0].equals("TOO_BUSY")) - { - throw new Types.TooBusy(); - } - if (ErrorDescription[0].equals("VALUE_NOT_SUPPORTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.ValueNotSupported(p1, p2, p3); - } - if (ErrorDescription[0].equals("SESSION_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SessionInvalid(p1); - } - if (ErrorDescription[0].equals("HA_CONSTRAINT_VIOLATION_NETWORK_NOT_SHARED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HaConstraintViolationNetworkNotShared(p1); - } - if (ErrorDescription[0].equals("HA_FAILED_TO_FORM_LIVESET")) - { - throw new Types.HaFailedToFormLiveset(); - } - if (ErrorDescription[0].equals("PIF_CANNOT_BOND_CROSS_HOST")) - { - throw new Types.PifCannotBondCrossHost(); - } - if (ErrorDescription[0].equals("SR_REQUIRES_UPGRADE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrRequiresUpgrade(p1); - } - if (ErrorDescription[0].equals("CERTIFICATE_DOES_NOT_EXIST")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CertificateDoesNotExist(p1); - } - if (ErrorDescription[0].equals("HA_OPERATION_WOULD_BREAK_FAILOVER_PLAN")) - { - throw new Types.HaOperationWouldBreakFailoverPlan(); - } - if (ErrorDescription[0].equals("CANNOT_FETCH_PATCH")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CannotFetchPatch(p1); - } - if (ErrorDescription[0].equals("CANNOT_FIND_PATCH")) - { - throw new Types.CannotFindPatch(); - } - if (ErrorDescription[0].equals("DB_UNIQUENESS_CONSTRAINT_VIOLATION")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.DbUniquenessConstraintViolation(p1, p2, p3); - } - if (ErrorDescription[0].equals("VM_REQUIRES_NETWORK")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VmRequiresNetwork(p1, p2); - } - if (ErrorDescription[0].equals("VBD_NOT_EMPTY")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VbdNotEmpty(p1); - } - if (ErrorDescription[0].equals("HOST_NOT_ENOUGH_FREE_MEMORY")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.HostNotEnoughFreeMemory(p1, p2); - } - if (ErrorDescription[0].equals("VM_MIGRATE_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - String p4 = ErrorDescription.length > 4 ? ErrorDescription[4] : ""; - throw new Types.VmMigrateFailed(p1, p2, p3, p4); - } - if (ErrorDescription[0].equals("SR_OPERATION_NOT_SUPPORTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrOperationNotSupported(p1); - } - if (ErrorDescription[0].equals("DEVICE_NOT_ATTACHED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.DeviceNotAttached(p1); - } - if (ErrorDescription[0].equals("HOST_DISABLED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostDisabled(p1); - } - if (ErrorDescription[0].equals("SYSTEM_STATUS_MUST_USE_TAR_ON_OEM")) - { - throw new Types.SystemStatusMustUseTarOnOem(); - } - if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_PREPARING_WRITERS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XenVssReqErrorPreparingWriters(p1, p2); - } - if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthEnableFailed(p1); - } - if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_CONTAIN_SHARED_SRS")) - { - throw new Types.JoiningHostCannotContainSharedSrs(); - } - if (ErrorDescription[0].equals("VM_NO_VCPUS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmNoVcpus(p1); - } - if (ErrorDescription[0].equals("INVALID_PATCH_WITH_LOG")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.InvalidPatchWithLog(p1); - } - if (ErrorDescription[0].equals("SR_DEVICE_IN_USE")) - { - throw new Types.SrDeviceInUse(); - } - if (ErrorDescription[0].equals("HOST_CD_DRIVE_EMPTY")) - { - throw new Types.HostCdDriveEmpty(); - } - if (ErrorDescription[0].equals("HA_HOST_IS_ARMED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HaHostIsArmed(p1); - } - if (ErrorDescription[0].equals("LICENSE_EXPIRED")) - { - throw new Types.LicenseExpired(); - } - if (ErrorDescription[0].equals("SESSION_AUTHENTICATION_FAILED")) - { - throw new Types.SessionAuthenticationFailed(); - } - if (ErrorDescription[0].equals("PIF_IS_VLAN")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PifIsVlan(p1); - } - if (ErrorDescription[0].equals("VMPP_ARCHIVE_MORE_FREQUENT_THAN_BACKUP")) - { - throw new Types.VmppArchiveMoreFrequentThanBackup(); - } - if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_BE_MASTER_OF_OTHER_HOSTS")) - { - throw new Types.JoiningHostCannotBeMasterOfOtherHosts(); - } - if (ErrorDescription[0].equals("HOST_HAS_RESIDENT_VMS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostHasResidentVms(p1); - } - if (ErrorDescription[0].equals("VM_CHECKPOINT_SUSPEND_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmCheckpointSuspendFailed(p1); - } - if (ErrorDescription[0].equals("PIF_IS_MANAGEMENT_INTERFACE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PifIsManagementInterface(p1); - } - if (ErrorDescription[0].equals("MAC_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.MacInvalid(p1); - } - if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_START_SNAPSHOT_SET_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XenVssReqErrorStartSnapshotSetFailed(p1, p2); - } - if (ErrorDescription[0].equals("VBD_IS_EMPTY")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VbdIsEmpty(p1); - } - if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.PatchPrecheckFailedWrongServerVersion(p1, p2, p3); - } - if (ErrorDescription[0].equals("CANNOT_FIND_STATE_PARTITION")) - { - throw new Types.CannotFindStatePartition(); - } - if (ErrorDescription[0].equals("AUTH_UNKNOWN_TYPE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthUnknownType(p1); - } - if (ErrorDescription[0].equals("WLB_AUTHENTICATION_FAILED")) - { - throw new Types.WlbAuthenticationFailed(); - } - if (ErrorDescription[0].equals("NOT_IN_EMERGENCY_MODE")) - { - throw new Types.NotInEmergencyMode(); - } - if (ErrorDescription[0].equals("AUTH_DISABLE_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthDisableFailed(p1); - } - if (ErrorDescription[0].equals("NETWORK_ALREADY_CONNECTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.NetworkAlreadyConnected(p1, p2); - } - if (ErrorDescription[0].equals("VDI_INCOMPATIBLE_TYPE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VdiIncompatibleType(p1, p2); - } - if (ErrorDescription[0].equals("WLB_UNKNOWN_HOST")) - { - throw new Types.WlbUnknownHost(); - } - if (ErrorDescription[0].equals("IMPORT_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.ImportError(p1); - } - if (ErrorDescription[0].equals("SR_UNKNOWN_DRIVER")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrUnknownDriver(p1); - } - if (ErrorDescription[0].equals("AUTH_DISABLE_FAILED_WRONG_CREDENTIALS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthDisableFailedWrongCredentials(p1); - } - if (ErrorDescription[0].equals("VM_HALTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmHalted(p1); - } - if (ErrorDescription[0].equals("FEATURE_RESTRICTED")) - { - throw new Types.FeatureRestricted(); - } - if (ErrorDescription[0].equals("CRL_NAME_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CrlNameInvalid(p1); - } - if (ErrorDescription[0].equals("HOST_POWER_ON_MODE_DISABLED")) - { - throw new Types.HostPowerOnModeDisabled(); - } - if (ErrorDescription[0].equals("ACTIVATION_WHILE_NOT_FREE")) - { - throw new Types.ActivationWhileNotFree(); - } - if (ErrorDescription[0].equals("XENAPI_PLUGIN_FAILURE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.XenapiPluginFailure(p1, p2, p3); - } - if (ErrorDescription[0].equals("MAC_STILL_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.MacStillExists(p1); - } - if (ErrorDescription[0].equals("HOST_IN_USE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.HostInUse(p1, p2, p3); - } - if (ErrorDescription[0].equals("HA_TOO_FEW_HOSTS")) - { - throw new Types.HaTooFewHosts(); - } - if (ErrorDescription[0].equals("WLB_CONNECTION_RESET")) - { - throw new Types.WlbConnectionReset(); - } - if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_WRONG_CREDENTIALS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthEnableFailedWrongCredentials(p1, p2); - } - if (ErrorDescription[0].equals("PATCH_IS_APPLIED")) - { - throw new Types.PatchIsApplied(); - } - if (ErrorDescription[0].equals("SR_HAS_PBD")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.SrHasPbd(p1); - } - if (ErrorDescription[0].equals("HOST_STILL_BOOTING")) - { - throw new Types.HostStillBooting(); - } - if (ErrorDescription[0].equals("WLB_MALFORMED_REQUEST")) - { - throw new Types.WlbMalformedRequest(); - } - if (ErrorDescription[0].equals("OBJECT_NOLONGER_EXISTS")) - { - throw new Types.ObjectNolongerExists(); - } - if (ErrorDescription[0].equals("HOSTS_NOT_HOMOGENEOUS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostsNotHomogeneous(p1); - } - if (ErrorDescription[0].equals("POOL_JOINING_HOST_MUST_HAVE_SAME_PRODUCT_VERSION")) - { - throw new Types.PoolJoiningHostMustHaveSameProductVersion(); - } - if (ErrorDescription[0].equals("PIF_VLAN_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PifVlanExists(p1); - } - if (ErrorDescription[0].equals("LICENSE_CHECKOUT_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.LicenseCheckoutError(p1); - } - if (ErrorDescription[0].equals("CERTIFICATE_LIBRARY_CORRUPT")) - { - throw new Types.CertificateLibraryCorrupt(); - } - if (ErrorDescription[0].equals("VDI_NOT_MANAGED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VdiNotManaged(p1); - } - if (ErrorDescription[0].equals("INVALID_EDITION")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.InvalidEdition(p1); - } - if (ErrorDescription[0].equals("PATCH_ALREADY_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PatchAlreadyExists(p1); - } - if (ErrorDescription[0].equals("OUT_OF_SPACE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.OutOfSpace(p1); - } - if (ErrorDescription[0].equals("IMPORT_ERROR_PREMATURE_EOF")) - { - throw new Types.ImportErrorPrematureEof(); - } - if (ErrorDescription[0].equals("VM_MEMORY_SIZE_TOO_LOW")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmMemorySizeTooLow(p1); - } - if (ErrorDescription[0].equals("VMPP_HAS_VM")) - { - throw new Types.VmppHasVm(); - } - if (ErrorDescription[0].equals("HOST_NOT_DISABLED")) - { - throw new Types.HostNotDisabled(); - } - if (ErrorDescription[0].equals("FIELD_TYPE_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.FieldTypeError(p1); - } - if (ErrorDescription[0].equals("SLAVE_REQUIRES_MANAGEMENT_INTERFACE")) - { - throw new Types.SlaveRequiresManagementInterface(); - } - if (ErrorDescription[0].equals("VM_IS_TEMPLATE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmIsTemplate(p1); - } - if (ErrorDescription[0].equals("VM_IS_PROTECTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmIsProtected(p1); - } - if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_HAVE_RUNNING_VMS")) - { - throw new Types.JoiningHostCannotHaveRunningVms(); - } - if (ErrorDescription[0].equals("VM_REQUIRES_VDI")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VmRequiresVdi(p1, p2); - } - if (ErrorDescription[0].equals("VBD_CDS_MUST_BE_READONLY")) - { - throw new Types.VbdCdsMustBeReadonly(); - } - if (ErrorDescription[0].equals("LICENSE_FILE_DEPRECATED")) - { - throw new Types.LicenseFileDeprecated(); - } - if (ErrorDescription[0].equals("CANNOT_CREATE_STATE_FILE")) - { - throw new Types.CannotCreateStateFile(); - } - if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_HAVE_VMS_WITH_CURRENT_OPERATIONS")) - { - throw new Types.JoiningHostCannotHaveVmsWithCurrentOperations(); - } - if (ErrorDescription[0].equals("MESSAGE_PARAMETER_COUNT_MISMATCH")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.MessageParameterCountMismatch(p1, p2, p3); - } - if (ErrorDescription[0].equals("POOL_AUTH_ALREADY_ENABLED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PoolAuthAlreadyEnabled(p1); - } - if (ErrorDescription[0].equals("RESTORE_INCOMPATIBLE_VERSION")) - { - throw new Types.RestoreIncompatibleVersion(); - } - if (ErrorDescription[0].equals("DEVICE_DETACH_REJECTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.DeviceDetachRejected(p1, p2, p3); - } - if (ErrorDescription[0].equals("AUTH_IS_DISABLED")) - { - throw new Types.AuthIsDisabled(); - } - if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_HAVE_RUNNING_OR_SUSPENDED_VMS")) - { - throw new Types.JoiningHostCannotHaveRunningOrSuspendedVms(); - } - if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_PREREQUISITE_MISSING")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PatchPrecheckFailedPrerequisiteMissing(p1, p2); - } - if (ErrorDescription[0].equals("WLB_XENSERVER_TIMEOUT")) - { - throw new Types.WlbXenserverTimeout(); - } - if (ErrorDescription[0].equals("VM_SNAPSHOT_WITH_QUIESCE_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmSnapshotWithQuiesceFailed(p1); - } - if (ErrorDescription[0].equals("POOL_AUTH_DISABLE_FAILED_WRONG_CREDENTIALS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthDisableFailedWrongCredentials(p1, p2); - } - if (ErrorDescription[0].equals("CERTIFICATE_CORRUPT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CertificateCorrupt(p1); - } - if (ErrorDescription[0].equals("WLB_INTERNAL_ERROR")) - { - throw new Types.WlbInternalError(); - } - if (ErrorDescription[0].equals("VM_REBOOTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmRebooted(p1); - } - if (ErrorDescription[0].equals("CANNOT_CONTACT_HOST")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CannotContactHost(p1); - } - if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_NO_VOLUMES_SUPPORTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XenVssReqErrorNoVolumesSupported(p1, p2); - } - if (ErrorDescription[0].equals("HOST_ITS_OWN_SLAVE")) - { - throw new Types.HostItsOwnSlave(); - } - if (ErrorDescription[0].equals("REDO_LOG_IS_ENABLED")) - { - throw new Types.RedoLogIsEnabled(); - } - if (ErrorDescription[0].equals("VM_MISSING_PV_DRIVERS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmMissingPvDrivers(p1); - } - if (ErrorDescription[0].equals("CERTIFICATE_NAME_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CertificateNameInvalid(p1); - } - if (ErrorDescription[0].equals("IMPORT_ERROR_FAILED_TO_FIND_OBJECT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.ImportErrorFailedToFindObject(p1); - } - if (ErrorDescription[0].equals("VDI_LOCATION_MISSING")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VdiLocationMissing(p1, p2); - } - if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED_PERMISSION_DENIED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthEnableFailedPermissionDenied(p1); - } - if (ErrorDescription[0].equals("PIF_VLAN_STILL_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PifVlanStillExists(p1); - } - if (ErrorDescription[0].equals("VMS_FAILED_TO_COOPERATE")) - { - throw new Types.VmsFailedToCooperate(); - } - if (ErrorDescription[0].equals("NETWORK_CONTAINS_VIF")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.NetworkContainsVif(p1); - } - if (ErrorDescription[0].equals("INVALID_VALUE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.InvalidValue(p1, p2); - } - if (ErrorDescription[0].equals("XENAPI_MISSING_PLUGIN")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.XenapiMissingPlugin(p1); - } - if (ErrorDescription[0].equals("RESTORE_TARGET_MGMT_IF_NOT_IN_BACKUP")) - { - throw new Types.RestoreTargetMgmtIfNotInBackup(); - } - if (ErrorDescription[0].equals("IS_TUNNEL_ACCESS_PIF")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.IsTunnelAccessPif(p1); - } - if (ErrorDescription[0].equals("JOINING_HOST_CONNECTION_FAILED")) - { - throw new Types.JoiningHostConnectionFailed(); - } - if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_ADDING_VOLUME_TO_SNAPSET_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XenVssReqErrorAddingVolumeToSnapsetFailed(p1, p2); - } - if (ErrorDescription[0].equals("SUBJECT_CANNOT_BE_RESOLVED")) - { - throw new Types.SubjectCannotBeResolved(); - } - if (ErrorDescription[0].equals("PROVISION_FAILED_OUT_OF_SPACE")) - { - throw new Types.ProvisionFailedOutOfSpace(); - } - if (ErrorDescription[0].equals("VDI_IS_NOT_ISO")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VdiIsNotIso(p1, p2); - } - if (ErrorDescription[0].equals("MESSAGE_METHOD_UNKNOWN")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.MessageMethodUnknown(p1); - } - if (ErrorDescription[0].equals("VM_CANNOT_DELETE_DEFAULT_TEMPLATE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmCannotDeleteDefaultTemplate(p1); - } - if (ErrorDescription[0].equals("ROLE_NOT_FOUND")) - { - throw new Types.RoleNotFound(); - } - if (ErrorDescription[0].equals("NOT_ALLOWED_ON_OEM_EDITION")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.NotAllowedOnOemEdition(p1); - } - if (ErrorDescription[0].equals("RESTORE_SCRIPT_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.RestoreScriptFailed(p1); - } - if (ErrorDescription[0].equals("INTERNAL_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.InternalError(p1); - } - if (ErrorDescription[0].equals("LICENSE_DOES_NOT_SUPPORT_XHA")) - { - throw new Types.LicenseDoesNotSupportXha(); - } - if (ErrorDescription[0].equals("DEVICE_ALREADY_DETACHED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.DeviceAlreadyDetached(p1); - } - if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED_UNAVAILABLE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthEnableFailedUnavailable(p1); - } - if (ErrorDescription[0].equals("VBD_NOT_REMOVABLE_MEDIA")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VbdNotRemovableMedia(p1); - } - if (ErrorDescription[0].equals("LOCATION_NOT_UNIQUE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.LocationNotUnique(p1, p2); - } - if (ErrorDescription[0].equals("NOT_IMPLEMENTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.NotImplemented(p1); - } - if (ErrorDescription[0].equals("CANNOT_PLUG_VIF")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CannotPlugVif(p1); - } - if (ErrorDescription[0].equals("USER_IS_NOT_LOCAL_SUPERUSER")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.UserIsNotLocalSuperuser(p1); - } - if (ErrorDescription[0].equals("BACKUP_SCRIPT_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.BackupScriptFailed(p1); - } - if (ErrorDescription[0].equals("IMPORT_ERROR_UNEXPECTED_FILE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.ImportErrorUnexpectedFile(p1, p2); - } - if (ErrorDescription[0].equals("AUTH_ALREADY_ENABLED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.AuthAlreadyEnabled(p1, p2); - } - if (ErrorDescription[0].equals("OPERATION_NOT_ALLOWED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.OperationNotAllowed(p1); - } - if (ErrorDescription[0].equals("HA_NO_PLAN")) - { - throw new Types.HaNoPlan(); - } - if (ErrorDescription[0].equals("EVENTS_LOST")) - { - throw new Types.EventsLost(); - } - if (ErrorDescription[0].equals("SR_BACKEND_FAILURE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.SrBackendFailure(p1, p2, p3); - } - if (ErrorDescription[0].equals("DEVICE_DETACH_TIMEOUT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.DeviceDetachTimeout(p1, p2); - } - if (ErrorDescription[0].equals("VM_DUPLICATE_VBD_DEVICE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.VmDuplicateVbdDevice(p1, p2, p3); - } - if (ErrorDescription[0].equals("CRL_CORRUPT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CrlCorrupt(p1); - } - if (ErrorDescription[0].equals("VM_OLD_PV_DRIVERS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; - throw new Types.VmOldPvDrivers(p1, p2, p3); - } - if (ErrorDescription[0].equals("PIF_DOES_NOT_ALLOW_UNPLUG")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.PifDoesNotAllowUnplug(p1); - } - if (ErrorDescription[0].equals("CHANGE_PASSWORD_REJECTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.ChangePasswordRejected(p1); - } - if (ErrorDescription[0].equals("OTHER_OPERATION_IN_PROGRESS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.OtherOperationInProgress(p1, p2); - } - if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_INIT_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.XenVssReqErrorInitFailed(p1, p2); - } - if (ErrorDescription[0].equals("CPU_FEATURE_MASKING_NOT_SUPPORTED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.CpuFeatureMaskingNotSupported(p1); - } - if (ErrorDescription[0].equals("VM_NOT_RESIDENT_HERE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VmNotResidentHere(p1, p2); - } - if (ErrorDescription[0].equals("HOST_OFFLINE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostOffline(p1); - } - if (ErrorDescription[0].equals("POOL_AUTH_DISABLE_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PoolAuthDisableFailed(p1, p2); - } - if (ErrorDescription[0].equals("HOST_HAS_NO_MANAGEMENT_IP")) - { - throw new Types.HostHasNoManagementIp(); - } - if (ErrorDescription[0].equals("TRANSPORT_PIF_NOT_CONFIGURED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.TransportPifNotConfigured(p1); - } - if (ErrorDescription[0].equals("HA_IS_ENABLED")) - { - throw new Types.HaIsEnabled(); - } - if (ErrorDescription[0].equals("VM_REVERT_FAILED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VmRevertFailed(p1, p2); - } - if (ErrorDescription[0].equals("HOST_NAME_INVALID")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HostNameInvalid(p1); - } - if (ErrorDescription[0].equals("DOMAIN_EXISTS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.DomainExists(p1, p2); - } - if (ErrorDescription[0].equals("HA_POOL_IS_ENABLED_BUT_HOST_IS_DISABLED")) - { - throw new Types.HaPoolIsEnabledButHostIsDisabled(); - } - if (ErrorDescription[0].equals("MESSAGE_DEPRECATED")) - { - throw new Types.MessageDeprecated(); - } - if (ErrorDescription[0].equals("HA_CONSTRAINT_VIOLATION_SR_NOT_SHARED")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.HaConstraintViolationSrNotShared(p1); - } - if (ErrorDescription[0].equals("IMPORT_ERROR_CANNOT_HANDLE_CHUNKED")) - { - throw new Types.ImportErrorCannotHandleChunked(); - } - if (ErrorDescription[0].equals("VM_ATTACHED_TO_MORE_THAN_ONE_VDI_WITH_TIMEOFFSET_MARKED_AS_RESET_ON_BOOT")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VmAttachedToMoreThanOneVdiWithTimeoffsetMarkedAsResetOnBoot(p1); - } - if (ErrorDescription[0].equals("NOT_SUPPORTED_DURING_UPGRADE")) - { - throw new Types.NotSupportedDuringUpgrade(); - } - if (ErrorDescription[0].equals("PIF_CONFIGURATION_ERROR")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.PifConfigurationError(p1, p2); - } - if (ErrorDescription[0].equals("INTERFACE_HAS_NO_IP")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.InterfaceHasNoIp(p1); - } - if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED_WRONG_CREDENTIALS")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.AuthEnableFailedWrongCredentials(p1); - } - - // An unknown error occurred - throw new Types.XenAPIException(ErrorDescription); - } - - throw new BadServerResponse(response); - } - - public enum VdiOperations { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Scanning backends for new or deleted VDIs - */ - SCAN, - /** - * Cloning the VDI - */ - CLONE, - /** - * Copying the VDI - */ - COPY, - /** - * Resizing the VDI - */ - RESIZE, - /** - * Resizing the VDI which may or may not be online - */ - RESIZE_ONLINE, - /** - * Snapshotting the VDI - */ - SNAPSHOT, - /** - * Destroying the VDI - */ - DESTROY, - /** - * Forget about the VDI - */ - FORGET, - /** - * Refreshing the fields of the VDI - */ - UPDATE, - /** - * Forcibly unlocking the VDI - */ - FORCE_UNLOCK, - /** - * Generating static configuration - */ - GENERATE_CONFIG, - /** - * Operations on this VDI are temporarily blocked - */ - BLOCKED - }; - - public enum Cls { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * VM - */ - VM, - /** - * Host - */ - HOST, - /** - * SR - */ - SR, - /** - * Pool - */ - POOL, - /** - * VMPP - */ - VMPP - }; - - public enum VdiType { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * a disk that may be replaced on upgrade - */ - SYSTEM, - /** - * a disk that is always preserved on upgrade - */ - USER, - /** - * a disk that may be reformatted on upgrade - */ - EPHEMERAL, - /** - * a disk that stores a suspend image - */ - SUSPEND, - /** - * a disk that stores VM crashdump information - */ - CRASHDUMP, - /** - * a disk used for HA storage heartbeating - */ - HA_STATEFILE, - /** - * a disk used for HA Pool metadata - */ - METADATA, - /** - * a disk used for a general metadata redo-log - */ - REDO_LOG - }; - - public enum AfterApplyGuidance { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * This patch requires HVM guests to be restarted once applied. - */ - RESTARTHVM, - /** - * This patch requires PV guests to be restarted once applied. - */ - RESTARTPV, - /** - * This patch requires the host to be restarted once applied. - */ - RESTARTHOST, - /** - * This patch requires XAPI to be restarted once applied. - */ - RESTARTXAPI - }; - - public enum EventOperation { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * An object has been created - */ - ADD, - /** - * An object has been deleted - */ - DEL, - /** - * An object has been modified - */ - MOD - }; - - public enum TaskAllowedOperations { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * refers to the operation "cancel" - */ - CANCEL - }; - - public enum TaskStatusType { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * task is in progress - */ - PENDING, - /** - * task was completed successfully - */ - SUCCESS, - /** - * task has failed - */ - FAILURE, - /** - * task is being cancelled - */ - CANCELLING, - /** - * task has been cancelled - */ - CANCELLED - }; - - public enum NetworkOperations { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Indicates this network is attaching to a VIF or PIF - */ - ATTACHING - }; - - public enum ConsoleProtocol { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * VT100 terminal - */ - VT100, - /** - * Remote FrameBuffer protocol (as used in VNC) - */ - RFB, - /** - * Remote Desktop Protocol - */ - RDP - }; - - public enum OnCrashBehaviour { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * destroy the VM state - */ - DESTROY, - /** - * record a coredump and then destroy the VM state - */ - COREDUMP_AND_DESTROY, - /** - * restart the VM - */ - RESTART, - /** - * record a coredump and then restart the VM - */ - COREDUMP_AND_RESTART, - /** - * leave the crashed VM paused - */ - PRESERVE, - /** - * rename the crashed VM and start a new copy - */ - RENAME_RESTART - }; - - public enum VmppBackupType { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * The backup is a snapshot - */ - SNAPSHOT, - /** - * The backup is a checkpoint - */ - CHECKPOINT - }; - - public enum OnNormalExit { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * destroy the VM state - */ - DESTROY, - /** - * restart the VM - */ - RESTART - }; - - public enum VifOperations { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Attempting to attach this VIF to a VM - */ - ATTACH, - /** - * Attempting to hotplug this VIF - */ - PLUG, - /** - * Attempting to hot unplug this VIF - */ - UNPLUG - }; - - public enum XenAPIObjects { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * A session - */ - SESSION, - /** - * Management of remote authentication services - */ - AUTH, - /** - * A user or group that can log in xapi - */ - SUBJECT, - /** - * A set of permissions associated with a subject - */ - ROLE, - /** - * A long-running asynchronous task - */ - TASK, - /** - * Asynchronous event registration and handling - */ - EVENT, - /** - * Pool-wide information - */ - POOL, - /** - * Pool-wide patches - */ - POOL_PATCH, - /** - * A virtual machine (or 'guest'). - */ - VM, - /** - * The metrics associated with a VM - */ - VM_METRICS, - /** - * The metrics reported by the guest (as opposed to inferred from outside) - */ - VM_GUEST_METRICS, - /** - * VM Protection Policy - */ - VMPP, - /** - * A physical host - */ - HOST, - /** - * Represents a host crash dump - */ - HOST_CRASHDUMP, - /** - * Represents a patch stored on a server - */ - HOST_PATCH, - /** - * The metrics associated with a host - */ - HOST_METRICS, - /** - * A physical CPU - */ - HOST_CPU, - /** - * A virtual network - */ - NETWORK, - /** - * A virtual network interface - */ - VIF, - /** - * The metrics associated with a virtual network device - */ - VIF_METRICS, - /** - * A physical network interface (note separate VLANs are represented as several PIFs) - */ - PIF, - /** - * The metrics associated with a physical network interface - */ - PIF_METRICS, - /** - * - */ - BOND, - /** - * A VLAN mux/demux - */ - VLAN, - /** - * A storage manager plugin - */ - SM, - /** - * A storage repository - */ - SR, - /** - * A virtual disk image - */ - VDI, - /** - * A virtual block device - */ - VBD, - /** - * The metrics associated with a virtual block device - */ - VBD_METRICS, - /** - * The physical block devices through which hosts access SRs - */ - PBD, - /** - * A VM crashdump - */ - CRASHDUMP, - /** - * A virtual TPM device - */ - VTPM, - /** - * A console - */ - CONSOLE, - /** - * A user of the system - */ - USER, - /** - * Data sources for logging in RRDs - */ - DATA_SOURCE, - /** - * A placeholder for a binary blob - */ - BLOB, - /** - * An message for the attention of the administrator - */ - MESSAGE, - /** - * A secret - */ - SECRET, - /** - * A tunnel for network traffic - */ - TUNNEL - }; - - public enum HostAllowedOperations { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Indicates this host is able to provision another VM - */ - PROVISION, - /** - * Indicates this host is evacuating - */ - EVACUATE, - /** - * Indicates this host is in the process of shutting itself down - */ - SHUTDOWN, - /** - * Indicates this host is in the process of rebooting - */ - REBOOT, - /** - * Indicates this host is in the process of being powered on - */ - POWER_ON, - /** - * This host is starting a VM - */ - VM_START, - /** - * This host is resuming a VM - */ - VM_RESUME, - /** - * This host is the migration target of a VM - */ - VM_MIGRATE - }; - - public enum VmppArchiveFrequency { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Never archive - */ - NEVER, - /** - * Archive after backup - */ - ALWAYS_AFTER_BACKUP, - /** - * Daily archives - */ - DAILY, - /** - * Weekly backups - */ - WEEKLY - }; - - public enum VmppArchiveTargetType { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * No target config - */ - NONE, - /** - * CIFS target config - */ - CIFS, - /** - * NFS target config - */ - NFS - }; - - public enum VbdMode { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * only read-only access will be allowed - */ - RO, - /** - * read-write access will be allowed - */ - RW - }; - - public enum VbdType { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * VBD will appear to guest as CD - */ - CD, - /** - * VBD will appear to guest as disk - */ - DISK - }; - - public enum OnBoot { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * When a VM containing this VDI is started, the contents of the VDI are reset to the state they were in when this flag was last set. - */ - RESET, - /** - * Standard behaviour. - */ - PERSIST - }; - - public enum VbdOperations { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Attempting to attach this VBD to a VM - */ - ATTACH, - /** - * Attempting to eject the media from this VBD - */ - EJECT, - /** - * Attempting to insert new media into this VBD - */ - INSERT, - /** - * Attempting to hotplug this VBD - */ - PLUG, - /** - * Attempting to hot unplug this VBD - */ - UNPLUG, - /** - * Attempting to forcibly unplug this VBD - */ - UNPLUG_FORCE, - /** - * Attempting to pause a block device backend - */ - PAUSE, - /** - * Attempting to unpause a block device backend - */ - UNPAUSE - }; - - public enum VmppBackupFrequency { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Hourly backups - */ - HOURLY, - /** - * Daily backups - */ - DAILY, - /** - * Weekly backups - */ - WEEKLY - }; - - public enum VmPowerState { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * VM is offline and not using any resources - */ - HALTED, - /** - * All resources have been allocated but the VM itself is paused and its vCPUs are not running - */ - PAUSED, - /** - * Running - */ - RUNNING, - /** - * VM state has been saved to disk and it is nolonger running. Note that disks remain in-use while the VM is suspended. - */ - SUSPENDED - }; - - public enum VmOperations { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * refers to the operation "snapshot" - */ - SNAPSHOT, - /** - * refers to the operation "clone" - */ - CLONE, - /** - * refers to the operation "copy" - */ - COPY, - /** - * refers to the operation "create_template" - */ - CREATE_TEMPLATE, - /** - * refers to the operation "revert" - */ - REVERT, - /** - * refers to the operation "checkpoint" - */ - CHECKPOINT, - /** - * refers to the operation "snapshot_with_quiesce" - */ - SNAPSHOT_WITH_QUIESCE, - /** - * refers to the operation "provision" - */ - PROVISION, - /** - * refers to the operation "start" - */ - START, - /** - * refers to the operation "start_on" - */ - START_ON, - /** - * refers to the operation "pause" - */ - PAUSE, - /** - * refers to the operation "unpause" - */ - UNPAUSE, - /** - * refers to the operation "clean_shutdown" - */ - CLEAN_SHUTDOWN, - /** - * refers to the operation "clean_reboot" - */ - CLEAN_REBOOT, - /** - * refers to the operation "hard_shutdown" - */ - HARD_SHUTDOWN, - /** - * refers to the operation "power_state_reset" - */ - POWER_STATE_RESET, - /** - * refers to the operation "hard_reboot" - */ - HARD_REBOOT, - /** - * refers to the operation "suspend" - */ - SUSPEND, - /** - * refers to the operation "csvm" - */ - CSVM, - /** - * refers to the operation "resume" - */ - RESUME, - /** - * refers to the operation "resume_on" - */ - RESUME_ON, - /** - * refers to the operation "pool_migrate" - */ - POOL_MIGRATE, - /** - * refers to the operation "migrate" - */ - MIGRATE, - /** - * refers to the operation "get_boot_record" - */ - GET_BOOT_RECORD, - /** - * refers to the operation "send_sysrq" - */ - SEND_SYSRQ, - /** - * refers to the operation "send_trigger" - */ - SEND_TRIGGER, - /** - * Changing the memory settings - */ - CHANGING_MEMORY_LIVE, - /** - * Waiting for the memory settings to change - */ - AWAITING_MEMORY_LIVE, - /** - * Changing the memory dynamic range - */ - CHANGING_DYNAMIC_RANGE, - /** - * Changing the memory static range - */ - CHANGING_STATIC_RANGE, - /** - * Changing the memory limits - */ - CHANGING_MEMORY_LIMITS, - /** - * Querying the co-operativeness of the VM - */ - GET_COOPERATIVE, - /** - * Changing the shadow memory for a halted VM. - */ - CHANGING_SHADOW_MEMORY, - /** - * Changing the shadow memory for a running VM. - */ - CHANGING_SHADOW_MEMORY_LIVE, - /** - * Changing VCPU settings for a halted VM. - */ - CHANGING_VCPUS, - /** - * Changing VCPU settings for a running VM. - */ - CHANGING_VCPUS_LIVE, - /** - * - */ - ASSERT_OPERATION_VALID, - /** - * Add, remove, query or list data sources - */ - DATA_SOURCE_OP, - /** - * - */ - UPDATE_ALLOWED_OPERATIONS, - /** - * Turning this VM into a template - */ - MAKE_INTO_TEMPLATE, - /** - * importing a VM from a network stream - */ - IMPORT, - /** - * exporting a VM to a network stream - */ - EXPORT, - /** - * exporting VM metadata to a network stream - */ - METADATA_EXPORT, - /** - * Reverting the VM to a previous snapshotted state - */ - REVERTING, - /** - * refers to the act of uninstalling the VM - */ - DESTROY - }; - - public enum IpConfigurationMode { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Do not acquire an IP address - */ - NONE, - /** - * Acquire an IP address by DHCP - */ - DHCP, - /** - * Static IP address configuration - */ - STATIC - }; - - public enum StorageOperations { - /** - * The value does not belong to this enumeration - */ - UNRECOGNIZED, - /** - * Scanning backends for new or deleted VDIs - */ - SCAN, - /** - * Destroying the SR - */ - DESTROY, - /** - * Forgetting about SR - */ - FORGET, - /** - * Plugging a PBD into this SR - */ - PLUG, - /** - * Unplugging a PBD from this SR - */ - UNPLUG, - /** - * Refresh the fields on the SR - */ - UPDATE, - /** - * Creating a new VDI - */ - VDI_CREATE, - /** - * Introducing a new VDI - */ - VDI_INTRODUCE, - /** - * Destroying a VDI - */ - VDI_DESTROY, - /** - * Resizing a VDI - */ - VDI_RESIZE, - /** - * Cloneing a VDI - */ - VDI_CLONE, - /** - * Snapshotting a VDI - */ - VDI_SNAPSHOT - }; - - - /** - * The restore could not be performed because a network interface is missing - */ - public static class RestoreTargetMissingDevice extends XenAPIException { - public final String device; - - /** - * Create a new RestoreTargetMissingDevice - * - * @param device - */ - public RestoreTargetMissingDevice(String device) { - super("The restore could not be performed because a network interface is missing"); - this.device = device; - } - - } - - /** - * The communication with the WLB server timed out. - */ - public static class WlbTimeout extends XenAPIException { - public final String configuredTimeout; - - /** - * Create a new WlbTimeout - * - * @param configuredTimeout - */ - public WlbTimeout(String configuredTimeout) { - super("The communication with the WLB server timed out."); - this.configuredTimeout = configuredTimeout; - } - - } - - /** - * The MAC address specified doesn't exist on this host. - */ - public static class MacDoesNotExist extends XenAPIException { - public final String MAC; - - /** - * Create a new MacDoesNotExist - * - * @param MAC - */ - public MacDoesNotExist(String MAC) { - super("The MAC address specified doesn't exist on this host."); - this.MAC = MAC; - } - - } - - /** - * You gave an invalid object reference. The object may have recently been deleted. The class parameter gives the type of reference given, and the handle parameter echoes the bad value given. - */ - public static class HandleInvalid extends XenAPIException { - public final String clazz; - public final String handle; - - /** - * Create a new HandleInvalid - * - * @param clazz - * @param handle - */ - public HandleInvalid(String clazz, String handle) { - super("You gave an invalid object reference. The object may have recently been deleted. The class parameter gives the type of reference given, and the handle parameter echoes the bad value given."); - this.clazz = clazz; - this.handle = handle; - } - - } - - /** - * The device is already attached to a VM - */ - public static class DeviceAlreadyAttached extends XenAPIException { - public final String device; - - /** - * Create a new DeviceAlreadyAttached - * - * @param device - */ - public DeviceAlreadyAttached(String device) { - super("The device is already attached to a VM"); - this.device = device; - } - - } - - /** - * A required parameter contained an invalid IP address - */ - public static class InvalidIpAddressSpecified extends XenAPIException { - public final String parameter; - - /** - * Create a new InvalidIpAddressSpecified - * - * @param parameter - */ - public InvalidIpAddressSpecified(String parameter) { - super("A required parameter contained an invalid IP address"); - this.parameter = parameter; - } - - } - - /** - * The SR operation cannot be performed because the SR is not empty. - */ - public static class SrNotEmpty extends XenAPIException { - - /** - * Create a new SrNotEmpty - */ - public SrNotEmpty() { - super("The SR operation cannot be performed because the SR is not empty."); - } - - } - - /** - * HVM is required for this operation - */ - public static class VmHvmRequired extends XenAPIException { - public final String vm; - - /** - * Create a new VmHvmRequired - * - * @param vm - */ - public VmHvmRequired(String vm) { - super("HVM is required for this operation"); - this.vm = vm; - } - - } - - /** - * Operation cannot proceed while a tunnel exists on this interface. - */ - public static class PifTunnelStillExists extends XenAPIException { - public final String PIF; - - /** - * Create a new PifTunnelStillExists - * - * @param PIF - */ - public PifTunnelStillExists(String PIF) { - super("Operation cannot proceed while a tunnel exists on this interface."); - this.PIF = PIF; - } - - } - - /** - * A bond must consist of at least two member interfaces - */ - public static class PifBondNeedsMoreMembers extends XenAPIException { - - /** - * Create a new PifBondNeedsMoreMembers - */ - public PifBondNeedsMoreMembers() { - super("A bond must consist of at least two member interfaces"); - } - - } - - /** - * This operation cannot be performed because the pif is bonded. - */ - public static class PifAlreadyBonded extends XenAPIException { - public final String PIF; - - /** - * Create a new PifAlreadyBonded - * - * @param PIF - */ - public PifAlreadyBonded(String PIF) { - super("This operation cannot be performed because the pif is bonded."); - this.PIF = PIF; - } - - } - - /** - * You tried to create a VLAN, but the tag you gave was invalid -- it must be between 0 and 4094. The parameter echoes the VLAN tag you gave. - */ - public static class VlanTagInvalid extends XenAPIException { - public final String VLAN; - - /** - * Create a new VlanTagInvalid - * - * @param VLAN - */ - public VlanTagInvalid(String VLAN) { - super("You tried to create a VLAN, but the tag you gave was invalid -- it must be between 0 and 4094. The parameter echoes the VLAN tag you gave."); - this.VLAN = VLAN; - } - - } - - /** - * You cannot make regular API calls directly on a slave. Please pass API calls via the master host. - */ - public static class HostIsSlave extends XenAPIException { - public final String masterIPAddress; - - /** - * Create a new HostIsSlave - * - * @param masterIPAddress - */ - public HostIsSlave(String masterIPAddress) { - super("You cannot make regular API calls directly on a slave. Please pass API calls via the master host."); - this.masterIPAddress = masterIPAddress; - } - - } - - /** - * The SR.shared flag cannot be set to false while the SR remains connected to multiple hosts - */ - public static class SrHasMultiplePbds extends XenAPIException { - public final String PBD; - - /** - * Create a new SrHasMultiplePbds - * - * @param PBD - */ - public SrHasMultiplePbds(String PBD) { - super("The SR.shared flag cannot be set to false while the SR remains connected to multiple hosts"); - this.PBD = PBD; - } - - } - - /** - * The pool failed to enable external authentication. - */ - public static class PoolAuthEnableFailedInvalidOu extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthEnableFailedInvalidOu - * - * @param host - * @param message - */ - public PoolAuthEnableFailedInvalidOu(String host, String message) { - super("The pool failed to enable external authentication."); - this.host = host; - this.message = message; - } - - } - - /** - * Some data checksums were incorrect; the VM may be corrupt. - */ - public static class ImportErrorSomeChecksumsFailed extends XenAPIException { - - /** - * Create a new ImportErrorSomeChecksumsFailed - */ - public ImportErrorSomeChecksumsFailed() { - super("Some data checksums were incorrect; the VM may be corrupt."); - } - - } - - /** - * This operation needs the OpenVSwitch networking backend to be enabled on all hosts in the pool. - */ - public static class OpenvswitchNotActive extends XenAPIException { - - /** - * Create a new OpenvswitchNotActive - */ - public OpenvswitchNotActive() { - super("This operation needs the OpenVSwitch networking backend to be enabled on all hosts in the pool."); - } - - } - - /** - * The backup partition to stream the updat to cannot be found - */ - public static class CannotFindOemBackupPartition extends XenAPIException { - - /** - * Create a new CannotFindOemBackupPartition - */ - public CannotFindOemBackupPartition() { - super("The backup partition to stream the updat to cannot be found"); - } - - } - - /** - * The specified device was not found. - */ - public static class PifDeviceNotFound extends XenAPIException { - - /** - * Create a new PifDeviceNotFound - */ - public PifDeviceNotFound() { - super("The specified device was not found."); - } - - } - - /** - * An internal error generated by the domain builder. - */ - public static class DomainBuilderError extends XenAPIException { - public final String function; - public final String code; - public final String message; - - /** - * Create a new DomainBuilderError - * - * @param function - * @param code - * @param message - */ - public DomainBuilderError(String function, String code, String message) { - super("An internal error generated by the domain builder."); - this.function = function; - this.code = code; - this.message = message; - } - - } - - /** - * The patch precheck stage failed: there are one or more VMs still running on the server. All VMs must be suspended before the patch can be applied. - */ - public static class PatchPrecheckFailedVmRunning extends XenAPIException { - public final String patch; - - /** - * Create a new PatchPrecheckFailedVmRunning - * - * @param patch - */ - public PatchPrecheckFailedVmRunning(String patch) { - super("The patch precheck stage failed: there are one or more VMs still running on the server. All VMs must be suspended before the patch can be applied."); - this.patch = patch; - } - - } - - /** - * The operation failed because the HA software on the specified host could not see a subset of other hosts. Check your network connectivity. - */ - public static class HaHostCannotSeePeers extends XenAPIException { - public final String host; - public final String all; - public final String subset; - - /** - * Create a new HaHostCannotSeePeers - * - * @param host - * @param all - * @param subset - */ - public HaHostCannotSeePeers(String host, String all, String subset) { - super("The operation failed because the HA software on the specified host could not see a subset of other hosts. Check your network connectivity."); - this.host = host; - this.all = all; - this.subset = subset; - } - - } - - /** - * The pool failed to disable the external authentication of at least one host. - */ - public static class PoolAuthDisableFailedPermissionDenied extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthDisableFailedPermissionDenied - * - * @param host - * @param message - */ - public PoolAuthDisableFailedPermissionDenied(String host, String message) { - super("The pool failed to disable the external authentication of at least one host."); - this.host = host; - this.message = message; - } - - } - - /** - * Caller not allowed to perform this operation. - */ - public static class PermissionDenied extends XenAPIException { - public final String message; - - /** - * Create a new PermissionDenied - * - * @param message - */ - public PermissionDenied(String message) { - super("Caller not allowed to perform this operation."); - this.message = message; - } - - } - - /** - * The remote system's SSL certificate failed to verify against our certificate library. - */ - public static class SslVerifyError extends XenAPIException { - public final String reason; - - /** - * Create a new SslVerifyError - * - * @param reason - */ - public SslVerifyError(String reason) { - super("The remote system's SSL certificate failed to verify against our certificate library."); - this.reason = reason; - } - - } - - /** - * Attaching this SR failed. - */ - public static class SrAttachFailed extends XenAPIException { - public final String sr; - - /** - * Create a new SrAttachFailed - * - * @param sr - */ - public SrAttachFailed(String sr) { - super("Attaching this SR failed."); - this.sr = sr; - } - - } - - /** - * Subject already exists. - */ - public static class SubjectAlreadyExists extends XenAPIException { - - /** - * Create a new SubjectAlreadyExists - */ - public SubjectAlreadyExists() { - super("Subject already exists."); - } - - } - - /** - * This host lost access to the HA statefile. - */ - public static class HaLostStatefile extends XenAPIException { - - /** - * Create a new HaLostStatefile - */ - public HaLostStatefile() { - super("This host lost access to the HA statefile."); - } - - } - - /** - * The operation could not be performed because HA is not enabled on the Pool - */ - public static class HaNotEnabled extends XenAPIException { - - /** - * Create a new HaNotEnabled - */ - public HaNotEnabled() { - super("The operation could not be performed because HA is not enabled on the Pool"); - } - - } - - /** - * The host could not join the liveset because the HA daemon failed to start. - */ - public static class HaHeartbeatDaemonStartupFailed extends XenAPIException { - - /** - * Create a new HaHeartbeatDaemonStartupFailed - */ - public HaHeartbeatDaemonStartupFailed() { - super("The host could not join the liveset because the HA daemon failed to start."); - } - - } - - /** - * This session is not registered to receive events. You must call event.register before event.next. The session handle you are using is echoed. - */ - public static class SessionNotRegistered extends XenAPIException { - public final String handle; - - /** - * Create a new SessionNotRegistered - * - * @param handle - */ - public SessionNotRegistered(String handle) { - super("This session is not registered to receive events. You must call event.register before event.next. The session handle you are using is echoed."); - this.handle = handle; - } - - } - - /** - * This VM does not have a suspend SR specified. - */ - public static class VmNoSuspendSr extends XenAPIException { - public final String vm; - - /** - * Create a new VmNoSuspendSr - * - * @param vm - */ - public VmNoSuspendSr(String vm) { - super("This VM does not have a suspend SR specified."); - this.vm = vm; - } - - } - - /** - * The patch apply failed. Please see attached output. - */ - public static class PatchApplyFailed extends XenAPIException { - public final String output; - - /** - * Create a new PatchApplyFailed - * - * @param output - */ - public PatchApplyFailed(String output) { - super("The patch apply failed. Please see attached output."); - this.output = output; - } - - } - - /** - * The operation required write access but this VDI is read-only - */ - public static class VdiReadonly extends XenAPIException { - public final String vdi; - - /** - * Create a new VdiReadonly - * - * @param vdi - */ - public VdiReadonly(String vdi) { - super("The operation required write access but this VDI is read-only"); - this.vdi = vdi; - } - - } - - /** - * The SR is full. Requested new size exceeds the maximum size - */ - public static class SrFull extends XenAPIException { - public final String requested; - public final String maximum; - - /** - * Create a new SrFull - * - * @param requested - * @param maximum - */ - public SrFull(String requested, String maximum) { - super("The SR is full. Requested new size exceeds the maximum size"); - this.requested = requested; - this.maximum = maximum; - } - - } - - /** - * This operation cannot be performed because this VDI could not be properly attached to the VM. - */ - public static class VdiNotAvailable extends XenAPIException { - public final String vdi; - - /** - * Create a new VdiNotAvailable - * - * @param vdi - */ - public VdiNotAvailable(String vdi) { - super("This operation cannot be performed because this VDI could not be properly attached to the VM."); - this.vdi = vdi; - } - - } - - /** - * The server failed to unmarshal the XMLRPC message; it was expecting one element and received something else. - */ - public static class XmlrpcUnmarshalFailure extends XenAPIException { - public final String expected; - public final String received; - - /** - * Create a new XmlrpcUnmarshalFailure - * - * @param expected - * @param received - */ - public XmlrpcUnmarshalFailure(String expected, String received) { - super("The server failed to unmarshal the XMLRPC message; it was expecting one element and received something else."); - this.expected = expected; - this.received = received; - } - - } - - /** - * A CRL already exists with the specified name. - */ - public static class CrlAlreadyExists extends XenAPIException { - public final String name; - - /** - * Create a new CrlAlreadyExists - * - * @param name - */ - public CrlAlreadyExists(String name) { - super("A CRL already exists with the specified name."); - this.name = name; - } - - } - - /** - * The master reports that it cannot talk back to the slave on the supplied management IP address. - */ - public static class HostMasterCannotTalkBack extends XenAPIException { - public final String ip; - - /** - * Create a new HostMasterCannotTalkBack - * - * @param ip - */ - public HostMasterCannotTalkBack(String ip) { - super("The master reports that it cannot talk back to the slave on the supplied management IP address."); - this.ip = ip; - } - - } - - /** - * 3rd party xapi hook failed - */ - public static class XapiHookFailed extends XenAPIException { - public final String hookName; - public final String reason; - public final String stdout; - public final String exitCode; - - /** - * Create a new XapiHookFailed - * - * @param hookName - * @param reason - * @param stdout - * @param exitCode - */ - public XapiHookFailed(String hookName, String reason, String stdout, String exitCode) { - super("3rd party xapi hook failed"); - this.hookName = hookName; - this.reason = reason; - this.stdout = stdout; - this.exitCode = exitCode; - } - - } - - /** - * The import failed because this export has been created by a different (incompatible) product version - */ - public static class ImportIncompatibleVersion extends XenAPIException { - - /** - * Create a new ImportIncompatibleVersion - */ - public ImportIncompatibleVersion() { - super("The import failed because this export has been created by a different (incompatible) product version"); - } - - } - - /** - * The requested bootloader is unknown - */ - public static class UnknownBootloader extends XenAPIException { - public final String vm; - public final String bootloader; - - /** - * Create a new UnknownBootloader - * - * @param vm - * @param bootloader - */ - public UnknownBootloader(String vm, String bootloader) { - super("The requested bootloader is unknown"); - this.vm = vm; - this.bootloader = bootloader; - } - - } - - /** - * The Citrix XenServer Vss Provider is not loaded - */ - public static class XenVssReqErrorProvNotLoaded extends XenAPIException { - public final String vm; - public final String errorCode; - - /** - * Create a new XenVssReqErrorProvNotLoaded - * - * @param vm - * @param errorCode - */ - public XenVssReqErrorProvNotLoaded(String vm, String errorCode) { - super("The Citrix XenServer Vss Provider is not loaded"); - this.vm = vm; - this.errorCode = errorCode; - } - - } - - /** - * The operation could not proceed because necessary VDIs were already locked at the storage level. - */ - public static class SrVdiLockingFailed extends XenAPIException { - - /** - * Create a new SrVdiLockingFailed - */ - public SrVdiLockingFailed() { - super("The operation could not proceed because necessary VDIs were already locked at the storage level."); - } - - } - - /** - * You tried to destroy a PIF, but it represents an aspect of the physical host configuration, and so cannot be destroyed. The parameter echoes the PIF handle you gave. - */ - public static class PifIsPhysical extends XenAPIException { - public final String PIF; - - /** - * Create a new PifIsPhysical - * - * @param PIF - */ - public PifIsPhysical(String PIF) { - super("You tried to destroy a PIF, but it represents an aspect of the physical host configuration, and so cannot be destroyed. The parameter echoes the PIF handle you gave."); - this.PIF = PIF; - } - - } - - /** - * You tried to add a key-value pair to a map, but that key is already there. - */ - public static class MapDuplicateKey extends XenAPIException { - public final String type; - public final String paramName; - public final String uuid; - public final String key; - - /** - * Create a new MapDuplicateKey - * - * @param type - * @param paramName - * @param uuid - * @param key - */ - public MapDuplicateKey(String type, String paramName, String uuid, String key) { - super("You tried to add a key-value pair to a map, but that key is already there."); - this.type = type; - this.paramName = paramName; - this.uuid = uuid; - this.key = key; - } - - } - - /** - * The license-server connection details (address or port) were missing or incomplete. - */ - public static class MissingConnectionDetails extends XenAPIException { - - /** - * Create a new MissingConnectionDetails - */ - public MissingConnectionDetails() { - super("The license-server connection details (address or port) were missing or incomplete."); - } - - } - - /** - * Could not create the XML string generated by the transportable snapshot - */ - public static class XenVssReqErrorCreatingSnapshotXmlString extends XenAPIException { - public final String vm; - public final String errorCode; - - /** - * Create a new XenVssReqErrorCreatingSnapshotXmlString - * - * @param vm - * @param errorCode - */ - public XenVssReqErrorCreatingSnapshotXmlString(String vm, String errorCode) { - super("Could not create the XML string generated by the transportable snapshot"); - this.vm = vm; - this.errorCode = errorCode; - } - - } - - /** - * The bootloader returned an error - */ - public static class BootloaderFailed extends XenAPIException { - public final String vm; - public final String msg; - - /** - * Create a new BootloaderFailed - * - * @param vm - * @param msg - */ - public BootloaderFailed(String vm, String msg) { - super("The bootloader returned an error"); - this.vm = vm; - this.msg = msg; - } - - } - - /** - * The WLB server reported that XenServer said something to it that WLB wasn't expecting or didn't understand. - */ - public static class WlbXenserverMalformedResponse extends XenAPIException { - - /** - * Create a new WlbXenserverMalformedResponse - */ - public WlbXenserverMalformedResponse() { - super("The WLB server reported that XenServer said something to it that WLB wasn't expecting or didn't understand."); - } - - } - - /** - * The pool failed to enable external authentication. - */ - public static class PoolAuthEnableFailedDuplicateHostname extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthEnableFailedDuplicateHostname - * - * @param host - * @param message - */ - public PoolAuthEnableFailedDuplicateHostname(String host, String message) { - super("The pool failed to enable external authentication."); - this.host = host; - this.message = message; - } - - } - - /** - * Retrieving system status from the host failed. A diagnostic reason suitable for support organisations is also returned. - */ - public static class SystemStatusRetrievalFailed extends XenAPIException { - public final String reason; - - /** - * Create a new SystemStatusRetrievalFailed - * - * @param reason - */ - public SystemStatusRetrievalFailed(String reason) { - super("Retrieving system status from the host failed. A diagnostic reason suitable for support organisations is also returned."); - this.reason = reason; - } - - } - - /** - * This operation cannot be performed because this VDI is in use by some other operation - */ - public static class VdiInUse extends XenAPIException { - public final String vdi; - public final String operation; - - /** - * Create a new VdiInUse - * - * @param vdi - * @param operation - */ - public VdiInUse(String vdi, String operation) { - super("This operation cannot be performed because this VDI is in use by some other operation"); - this.vdi = vdi; - this.operation = operation; - } - - } - - /** - * This operation cannot be completed as the host is not live. - */ - public static class HostNotLive extends XenAPIException { - - /** - * Create a new HostNotLive - */ - public HostNotLive() { - super("This operation cannot be completed as the host is not live."); - } - - } - - /** - * A certificate already exists with the specified name. - */ - public static class CertificateAlreadyExists extends XenAPIException { - public final String name; - - /** - * Create a new CertificateAlreadyExists - * - * @param name - */ - public CertificateAlreadyExists(String name) { - super("A certificate already exists with the specified name."); - this.name = name; - } - - } - - /** - * The SR has no attached PBDs - */ - public static class SrHasNoPbds extends XenAPIException { - public final String sr; - - /** - * Create a new SrHasNoPbds - * - * @param sr - */ - public SrHasNoPbds(String sr) { - super("The SR has no attached PBDs"); - this.sr = sr; - } - - } - - /** - * The uploaded patch file is invalid - */ - public static class InvalidPatch extends XenAPIException { - - /** - * Create a new InvalidPatch - */ - public InvalidPatch() { - super("The uploaded patch file is invalid"); - } - - } - - /** - * The SR could not be destroyed, as the 'indestructible' flag was set on it. - */ - public static class SrIndestructible extends XenAPIException { - public final String sr; - - /** - * Create a new SrIndestructible - * - * @param sr - */ - public SrIndestructible(String sr) { - super("The SR could not be destroyed, as the 'indestructible' flag was set on it."); - this.sr = sr; - } - - } - - /** - * This host cannot accept the proposed new master setting at this time. - */ - public static class HaAbortNewMaster extends XenAPIException { - public final String reason; - - /** - * Create a new HaAbortNewMaster - * - * @param reason - */ - public HaAbortNewMaster(String reason) { - super("This host cannot accept the proposed new master setting at this time."); - this.reason = reason; - } - - } - - /** - * The WLB server said something that XenServer wasn't expecting or didn't understand. The method called on the WLB server, a diagnostic reason, and the response from WLB are returned. - */ - public static class WlbMalformedResponse extends XenAPIException { - public final String method; - public final String reason; - public final String response; - - /** - * Create a new WlbMalformedResponse - * - * @param method - * @param reason - * @param response - */ - public WlbMalformedResponse(String method, String reason, String response) { - super("The WLB server said something that XenServer wasn't expecting or didn't understand. The method called on the WLB server, a diagnostic reason, and the response from WLB are returned."); - this.method = method; - this.reason = reason; - this.response = response; - } - - } - - /** - * The host joining the pool must have a physical management NIC (i.e. the management NIC must not be on a VLAN or bonded PIF). - */ - public static class PoolJoiningHostMustHavePhysicalManagementNic extends XenAPIException { - - /** - * Create a new PoolJoiningHostMustHavePhysicalManagementNic - */ - public PoolJoiningHostMustHavePhysicalManagementNic() { - super("The host joining the pool must have a physical management NIC (i.e. the management NIC must not be on a VLAN or bonded PIF)."); - } - - } - - /** - * The WLB server reported that XenServer rejected its configured authentication details. - */ - public static class WlbXenserverAuthenticationFailed extends XenAPIException { - - /** - * Create a new WlbXenserverAuthenticationFailed - */ - public WlbXenserverAuthenticationFailed() { - super("The WLB server reported that XenServer rejected its configured authentication details."); - } - - } - - /** - * The power-state of a control domain cannot be reset. - */ - public static class CannotResetControlDomain extends XenAPIException { - public final String vm; - - /** - * Create a new CannotResetControlDomain - * - * @param vm - */ - public CannotResetControlDomain(String vm) { - super("The power-state of a control domain cannot be reset."); - this.vm = vm; - } - - } - - /** - * The patch precheck stage failed with an unknown error. See attached info for more details. - */ - public static class PatchPrecheckFailedUnknownError extends XenAPIException { - public final String patch; - public final String info; - - /** - * Create a new PatchPrecheckFailedUnknownError - * - * @param patch - * @param info - */ - public PatchPrecheckFailedUnknownError(String patch, String info) { - super("The patch precheck stage failed with an unknown error. See attached info for more details."); - this.patch = patch; - this.info = info; - } - - } - - /** - * Host cannot attach network (in the case of NIC bonding, this may be because attaching the network on this host would require other networks [that are currently active] to be taken down). - */ - public static class HostCannotAttachNetwork extends XenAPIException { - public final String host; - public final String network; - - /** - * Create a new HostCannotAttachNetwork - * - * @param host - * @param network - */ - public HostCannotAttachNetwork(String host, String network) { - super("Host cannot attach network (in the case of NIC bonding, this may be because attaching the network on this host would require other networks [that are currently active] to be taken down)."); - this.host = host; - this.network = network; - } - - } - - /** - * The WLB URL is invalid. Ensure it is in format: :. The configured/given URL is returned. - */ - public static class WlbUrlInvalid extends XenAPIException { - public final String url; - - /** - * Create a new WlbUrlInvalid - * - * @param url - */ - public WlbUrlInvalid(String url) { - super("The WLB URL is invalid. Ensure it is in format: :. The configured/given URL is returned."); - this.url = url; - } - - } - - /** - * Cannot restore this VM because it would create a duplicate - */ - public static class DuplicateVm extends XenAPIException { - public final String vm; - - /** - * Create a new DuplicateVm - * - * @param vm - */ - public DuplicateVm(String vm) { - super("Cannot restore this VM because it would create a duplicate"); - this.vm = vm; - } - - } - - /** - * The pool master host cannot be removed. - */ - public static class HostCannotDestroySelf extends XenAPIException { - public final String host; - - /** - * Create a new HostCannotDestroySelf - * - * @param host - */ - public HostCannotDestroySelf(String host) { - super("The pool master host cannot be removed."); - this.host = host; - } - - } - - /** - * This host failed in the middle of an automatic failover operation and needs to retry the failover action - */ - public static class HostBroken extends XenAPIException { - - /** - * Create a new HostBroken - */ - public HostBroken() { - super("This host failed in the middle of an automatic failover operation and needs to retry the failover action"); - } - - } - - /** - * An error occured while restoring the memory image of the specified virtual machine - */ - public static class VmCheckpointResumeFailed extends XenAPIException { - public final String vm; - - /** - * Create a new VmCheckpointResumeFailed - * - * @param vm - */ - public VmCheckpointResumeFailed(String vm) { - super("An error occured while restoring the memory image of the specified virtual machine"); - this.vm = vm; - } - - } - - /** - * Too many VCPUs to start this VM - */ - public static class VmTooManyVcpus extends XenAPIException { - public final String vm; - - /** - * Create a new VmTooManyVcpus - * - * @param vm - */ - public VmTooManyVcpus(String vm) { - super("Too many VCPUs to start this VM"); - this.vm = vm; - } - - } - - /** - * This operation cannot be completed as the host is still live. - */ - public static class HostIsLive extends XenAPIException { - public final String host; - - /** - * Create a new HostIsLive - * - * @param host - */ - public HostIsLive(String host) { - super("This operation cannot be completed as the host is still live."); - this.host = host; - } - - } - - /** - * The VM could not be imported because attached disks could not be found. - */ - public static class ImportErrorAttachedDisksNotFound extends XenAPIException { - - /** - * Create a new ImportErrorAttachedDisksNotFound - */ - public ImportErrorAttachedDisksNotFound() { - super("The VM could not be imported because attached disks could not be found."); - } - - } - - /** - * Drive could not be hot-unplugged because it is not marked as unpluggable - */ - public static class VbdNotUnpluggable extends XenAPIException { - public final String vbd; - - /** - * Create a new VbdNotUnpluggable - * - * @param vbd - */ - public VbdNotUnpluggable(String vbd) { - super("Drive could not be hot-unplugged because it is not marked as unpluggable"); - this.vbd = vbd; - } - - } - - /** - * An attempt to create the snapshots failed - */ - public static class XenVssReqErrorCreatingSnapshot extends XenAPIException { - public final String vm; - public final String errorCode; - - /** - * Create a new XenVssReqErrorCreatingSnapshot - * - * @param vm - * @param errorCode - */ - public XenVssReqErrorCreatingSnapshot(String vm, String errorCode) { - super("An attempt to create the snapshots failed"); - this.vm = vm; - this.errorCode = errorCode; - } - - } - - /** - * Could not enable redo log. - */ - public static class CannotEnableRedoLog extends XenAPIException { - public final String reason; - - /** - * Create a new CannotEnableRedoLog - * - * @param reason - */ - public CannotEnableRedoLog(String reason) { - super("Could not enable redo log."); - this.reason = reason; - } - - } - - /** - * This host cannot be evacuated. - */ - public static class CannotEvacuateHost extends XenAPIException { - public final String errors; - - /** - * Create a new CannotEvacuateHost - * - * @param errors - */ - public CannotEvacuateHost(String errors) { - super("This host cannot be evacuated."); - this.errors = errors; - } - - } - - /** - * There were no hosts available to complete the specified operation. - */ - public static class NoHostsAvailable extends XenAPIException { - - /** - * Create a new NoHostsAvailable - */ - public NoHostsAvailable() { - super("There were no hosts available to complete the specified operation."); - } - - } - - /** - * A timeout happened while attempting to attach a device to a VM. - */ - public static class DeviceAttachTimeout extends XenAPIException { - public final String type; - public final String ref; - - /** - * Create a new DeviceAttachTimeout - * - * @param type - * @param ref - */ - public DeviceAttachTimeout(String type, String ref) { - super("A timeout happened while attempting to attach a device to a VM."); - this.type = type; - this.ref = ref; - } - - } - - /** - * The device name is invalid - */ - public static class InvalidDevice extends XenAPIException { - public final String device; - - /** - * Create a new InvalidDevice - * - * @param device - */ - public InvalidDevice(String device) { - super("The device name is invalid"); - this.device = device; - } - - } - - /** - * A PBD already exists connecting the SR to the host - */ - public static class PbdExists extends XenAPIException { - public final String sr; - public final String host; - public final String pbd; - - /** - * Create a new PbdExists - * - * @param sr - * @param host - * @param pbd - */ - public PbdExists(String sr, String host, String pbd) { - super("A PBD already exists connecting the SR to the host"); - this.sr = sr; - this.host = host; - this.pbd = pbd; - } - - } - - /** - * The WLB server reported that XenServer refused it a connection (even though we're connecting perfectly fine in the other direction). - */ - public static class WlbXenserverConnectionRefused extends XenAPIException { - - /** - * Create a new WlbXenserverConnectionRefused - */ - public WlbXenserverConnectionRefused() { - super("The WLB server reported that XenServer refused it a connection (even though we're connecting perfectly fine in the other direction)."); - } - - } - - /** - * The metrics of this host could not be read. - */ - public static class HostCannotReadMetrics extends XenAPIException { - - /** - * Create a new HostCannotReadMetrics - */ - public HostCannotReadMetrics() { - super("The metrics of this host could not be read."); - } - - } - - /** - * The pool failed to enable external authentication. - */ - public static class PoolAuthEnableFailed extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthEnableFailed - * - * @param host - * @param message - */ - public PoolAuthEnableFailed(String host, String message) { - super("The pool failed to enable external authentication."); - this.host = host; - this.message = message; - } - - } - - /** - * The VSS plug-in is not installed on this virtual machine - */ - public static class VmSnapshotWithQuiesceNotSupported extends XenAPIException { - public final String vm; - public final String error; - - /** - * Create a new VmSnapshotWithQuiesceNotSupported - * - * @param vm - * @param error - */ - public VmSnapshotWithQuiesceNotSupported(String vm, String error) { - super("The VSS plug-in is not installed on this virtual machine"); - this.vm = vm; - this.error = error; - } - - } - - /** - * This host cannot join a pool because it's license does not support pooling - */ - public static class LicenseDoesNotSupportPooling extends XenAPIException { - - /** - * Create a new LicenseDoesNotSupportPooling - */ - public LicenseDoesNotSupportPooling() { - super("This host cannot join a pool because it's license does not support pooling"); - } - - } - - /** - * The master says the host is not known to it. Perhaps the Host was deleted from the master's database? Perhaps the slave is pointing to the wrong master? - */ - public static class HostUnknownToMaster extends XenAPIException { - public final String host; - - /** - * Create a new HostUnknownToMaster - * - * @param host - */ - public HostUnknownToMaster(String host) { - super("The master says the host is not known to it. Perhaps the Host was deleted from the master's database? Perhaps the slave is pointing to the wrong master?"); - this.host = host; - } - - } - - /** - * The WLB server refused a connection to XenServer. - */ - public static class WlbConnectionRefused extends XenAPIException { - - /** - * Create a new WlbConnectionRefused - */ - public WlbConnectionRefused() { - super("The WLB server refused a connection to XenServer."); - } - - } - - /** - * The VSS plug-in cannot be contacted - */ - public static class VmSnapshotWithQuiescePluginDeosNotRespond extends XenAPIException { - public final String vm; - - /** - * Create a new VmSnapshotWithQuiescePluginDeosNotRespond - * - * @param vm - */ - public VmSnapshotWithQuiescePluginDeosNotRespond(String vm) { - super("The VSS plug-in cannot be contacted"); - this.vm = vm; - } - - } - - /** - * You attempted to run a VM on a host which doesn't have access to an SR needed by the VM. The VM has at least one VBD attached to a VDI in the SR. - */ - public static class VmRequiresSr extends XenAPIException { - public final String vm; - public final String sr; - - /** - * Create a new VmRequiresSr - * - * @param vm - * @param sr - */ - public VmRequiresSr(String vm, String sr) { - super("You attempted to run a VM on a host which doesn't have access to an SR needed by the VM. The VM has at least one VBD attached to a VDI in the SR."); - this.vm = vm; - this.sr = sr; - } - - } - - /** - * This VM does not have a crashdump SR specified. - */ - public static class VmNoCrashdumpSr extends XenAPIException { - public final String vm; - - /** - * Create a new VmNoCrashdumpSr - * - * @param vm - */ - public VmNoCrashdumpSr(String vm) { - super("This VM does not have a crashdump SR specified."); - this.vm = vm; - } - - } - - /** - * The operation could not be performed because the HA software is not installed on this host. - */ - public static class HaNotInstalled extends XenAPIException { - public final String host; - - /** - * Create a new HaNotInstalled - * - * @param host - */ - public HaNotInstalled(String host) { - super("The operation could not be performed because the HA software is not installed on this host."); - this.host = host; - } - - } - - /** - * A PIF with this specified device name already exists. - */ - public static class DuplicatePifDeviceName extends XenAPIException { - public final String device; - - /** - * Create a new DuplicatePifDeviceName - * - * @param device - */ - public DuplicatePifDeviceName(String device) { - super("A PIF with this specified device name already exists."); - this.device = device; - } - - } - - /** - * You attempted an operation on a VM that was not in an appropriate power state at the time; for example, you attempted to start a VM that was already running. The parameters returned are the VM's handle, and the expected and actual VM state at the time of the call. - */ - public static class VmBadPowerState extends XenAPIException { - public final String vm; - public final String expected; - public final String actual; - - /** - * Create a new VmBadPowerState - * - * @param vm - * @param expected - * @param actual - */ - public VmBadPowerState(String vm, String expected, String actual) { - super("You attempted an operation on a VM that was not in an appropriate power state at the time; for example, you attempted to start a VM that was already running. The parameters returned are the VM's handle, and the expected and actual VM state at the time of the call."); - this.vm = vm; - this.expected = expected; - this.actual = actual; - } - - } - - /** - * This pool has wlb-enabled set to false. - */ - public static class WlbDisabled extends XenAPIException { - - /** - * Create a new WlbDisabled - */ - public WlbDisabled() { - super("This pool has wlb-enabled set to false."); - } - - } - - /** - * Cannot join pool whose external authentication configuration is different. - */ - public static class PoolJoiningExternalAuthMismatch extends XenAPIException { - - /** - * Create a new PoolJoiningExternalAuthMismatch - */ - public PoolJoiningExternalAuthMismatch() { - super("Cannot join pool whose external authentication configuration is different."); - } - - } - - /** - * The BIOS strings for this VM have already been set and cannot be changed anymore. - */ - public static class VmBiosStringsAlreadySet extends XenAPIException { - - /** - * Create a new VmBiosStringsAlreadySet - */ - public VmBiosStringsAlreadySet() { - super("The BIOS strings for this VM have already been set and cannot be changed anymore."); - } - - } - - /** - * The WLB server reported that its configured server name for this XenServer instance failed to resolve in DNS. - */ - public static class WlbXenserverUnknownHost extends XenAPIException { - - /** - * Create a new WlbXenserverUnknownHost - */ - public WlbXenserverUnknownHost() { - super("The WLB server reported that its configured server name for this XenServer instance failed to resolve in DNS."); - } - - } - - /** - * The host could not join the liveset because the HA daemon could not access the heartbeat disk. - */ - public static class HaHostCannotAccessStatefile extends XenAPIException { - - /** - * Create a new HaHostCannotAccessStatefile - */ - public HaHostCannotAccessStatefile() { - super("The host could not join the liveset because the HA daemon could not access the heartbeat disk."); - } - - } - - /** - * VM didn't acknowledge the need to shutdown. - */ - public static class VmFailedShutdownAcknowledgment extends XenAPIException { - - /** - * Create a new VmFailedShutdownAcknowledgment - */ - public VmFailedShutdownAcknowledgment() { - super("VM didn't acknowledge the need to shutdown."); - } - - } - - /** - * Error querying the external directory service. - */ - public static class AuthServiceError extends XenAPIException { - public final String message; - - /** - * Create a new AuthServiceError - * - * @param message - */ - public AuthServiceError(String message) { - super("Error querying the external directory service."); - this.message = message; - } - - } - - /** - * Cannot perform operation as the host is running in emergency mode. - */ - public static class HostInEmergencyMode extends XenAPIException { - - /** - * Create a new HostInEmergencyMode - */ - public HostInEmergencyMode() { - super("Cannot perform operation as the host is running in emergency mode."); - } - - } - - /** - * The specified host is disabled and cannot be re-enabled until after it has rebooted. - */ - public static class HostDisabledUntilReboot extends XenAPIException { - public final String host; - - /** - * Create a new HostDisabledUntilReboot - * - * @param host - */ - public HostDisabledUntilReboot(String host) { - super("The specified host is disabled and cannot be re-enabled until after it has rebooted."); - this.host = host; - } - - } - - /** - * The default SR reference does not point to a valid SR - */ - public static class DefaultSrNotFound extends XenAPIException { - public final String sr; - - /** - * Create a new DefaultSrNotFound - * - * @param sr - */ - public DefaultSrNotFound(String sr) { - super("The default SR reference does not point to a valid SR"); - this.sr = sr; - } - - } - - /** - * A device with the name given already exists on the selected VM - */ - public static class DeviceAlreadyExists extends XenAPIException { - public final String device; - - /** - * Create a new DeviceAlreadyExists - * - * @param device - */ - public DeviceAlreadyExists(String device) { - super("A device with the name given already exists on the selected VM"); - this.device = device; - } - - } - - /** - * The PBD could not be plugged because the SR is in use by another host and is not marked as sharable. - */ - public static class SrNotSharable extends XenAPIException { - public final String sr; - public final String host; - - /** - * Create a new SrNotSharable - * - * @param sr - * @param host - */ - public SrNotSharable(String sr, String host) { - super("The PBD could not be plugged because the SR is in use by another host and is not marked as sharable."); - this.sr = sr; - this.host = host; - } - - } - - /** - * The host failed to disable external authentication. - */ - public static class AuthDisableFailedPermissionDenied extends XenAPIException { - public final String message; - - /** - * Create a new AuthDisableFailedPermissionDenied - * - * @param message - */ - public AuthDisableFailedPermissionDenied(String message) { - super("The host failed to disable external authentication."); - this.message = message; - } - - } - - /** - * Cannot downgrade license while in pool. Please disband the pool first, then downgrade licenses on hosts separately. - */ - public static class LicenseCannotDowngradeWhileInPool extends XenAPIException { - - /** - * Create a new LicenseCannotDowngradeWhileInPool - */ - public LicenseCannotDowngradeWhileInPool() { - super("Cannot downgrade license while in pool. Please disband the pool first, then downgrade licenses on hosts separately."); - } - - } - - /** - * RBAC permission denied. - */ - public static class RbacPermissionDenied extends XenAPIException { - public final String permission; - public final String message; - - /** - * Create a new RbacPermissionDenied - * - * @param permission - * @param message - */ - public RbacPermissionDenied(String permission, String message) { - super("RBAC permission denied."); - this.permission = permission; - this.message = message; - } - - } - - /** - * The request was rejected because there are too many pending tasks on the server. - */ - public static class TooManyPendingTasks extends XenAPIException { - - /** - * Create a new TooManyPendingTasks - */ - public TooManyPendingTasks() { - super("The request was rejected because there are too many pending tasks on the server."); - } - - } - - /** - * The VSS plug-in has timed out - */ - public static class VmSnapshotWithQuiesceTimeout extends XenAPIException { - public final String vm; - - /** - * Create a new VmSnapshotWithQuiesceTimeout - * - * @param vm - */ - public VmSnapshotWithQuiesceTimeout(String vm) { - super("The VSS plug-in has timed out"); - this.vm = vm; - } - - } - - /** - * This patch has already been applied - */ - public static class PatchAlreadyApplied extends XenAPIException { - public final String patch; - - /** - * Create a new PatchAlreadyApplied - * - * @param patch - */ - public PatchAlreadyApplied(String patch) { - super("This patch has already been applied"); - this.patch = patch; - } - - } - - /** - * An SR with that uuid already exists. - */ - public static class SrUuidExists extends XenAPIException { - public final String uuid; - - /** - * Create a new SrUuidExists - * - * @param uuid - */ - public SrUuidExists(String uuid) { - super("An SR with that uuid already exists."); - this.uuid = uuid; - } - - } - - /** - * The host failed to enable external authentication. - */ - public static class AuthEnableFailedDomainLookupFailed extends XenAPIException { - public final String message; - - /** - * Create a new AuthEnableFailedDomainLookupFailed - * - * @param message - */ - public AuthEnableFailedDomainLookupFailed(String message) { - super("The host failed to enable external authentication."); - this.message = message; - } - - } - - /** - * The given feature string is not valid. - */ - public static class InvalidFeatureString extends XenAPIException { - public final String details; - - /** - * Create a new InvalidFeatureString - * - * @param details - */ - public InvalidFeatureString(String details) { - super("The given feature string is not valid."); - this.details = details; - } - - } - - /** - * No WLB connection is configured. - */ - public static class WlbNotInitialized extends XenAPIException { - - /** - * Create a new WlbNotInitialized - */ - public WlbNotInitialized() { - super("No WLB connection is configured."); - } - - } - - /** - * You attempted an operation that was explicitly blocked (see the blocked_operations field of the given object). - */ - public static class OperationBlocked extends XenAPIException { - public final String ref; - public final String code; - - /** - * Create a new OperationBlocked - * - * @param ref - * @param code - */ - public OperationBlocked(String ref, String code) { - super("You attempted an operation that was explicitly blocked (see the blocked_operations field of the given object)."); - this.ref = ref; - this.code = code; - } - - } - - /** - * The provision call can only be invoked on templates, not regular VMs. - */ - public static class ProvisionOnlyAllowedOnTemplate extends XenAPIException { - - /** - * Create a new ProvisionOnlyAllowedOnTemplate - */ - public ProvisionOnlyAllowedOnTemplate() { - super("The provision call can only be invoked on templates, not regular VMs."); - } - - } - - /** - * VM failed to shutdown before the timeout expired - */ - public static class VmShutdownTimeout extends XenAPIException { - public final String vm; - public final String timeout; - - /** - * Create a new VmShutdownTimeout - * - * @param vm - * @param timeout - */ - public VmShutdownTimeout(String vm, String timeout) { - super("VM failed to shutdown before the timeout expired"); - this.vm = vm; - this.timeout = timeout; - } - - } - - /** - * The network contains active PIFs and cannot be deleted. - */ - public static class NetworkContainsPif extends XenAPIException { - public final String pifs; - - /** - * Create a new NetworkContainsPif - * - * @param pifs - */ - public NetworkContainsPif(String pifs) { - super("The network contains active PIFs and cannot be deleted."); - this.pifs = pifs; - } - - } - - /** - * Role already exists. - */ - public static class RoleAlreadyExists extends XenAPIException { - - /** - * Create a new RoleAlreadyExists - */ - public RoleAlreadyExists() { - super("Role already exists."); - } - - } - - /** - * There was an error connecting to the host. the service contacted didn't reply properly. - */ - public static class JoiningHostServiceFailed extends XenAPIException { - - /** - * Create a new JoiningHostServiceFailed - */ - public JoiningHostServiceFailed() { - super("There was an error connecting to the host. the service contacted didn't reply properly."); - } - - } - - /** - * This operation cannot be performed because the specified VDI could not be found on the storage substrate - */ - public static class VdiMissing extends XenAPIException { - public final String sr; - public final String vdi; - - /** - * Create a new VdiMissing - * - * @param sr - * @param vdi - */ - public VdiMissing(String sr, String vdi) { - super("This operation cannot be performed because the specified VDI could not be found on the storage substrate"); - this.sr = sr; - this.vdi = vdi; - } - - } - - /** - * This VM has locked the DVD drive tray, so the disk cannot be ejected - */ - public static class VbdTrayLocked extends XenAPIException { - public final String vbd; - - /** - * Create a new VbdTrayLocked - * - * @param vbd - */ - public VbdTrayLocked(String vbd) { - super("This VM has locked the DVD drive tray, so the disk cannot be ejected"); - this.vbd = vbd; - } - - } - - /** - * The pool failed to enable external authentication. - */ - public static class PoolAuthEnableFailedPermissionDenied extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthEnableFailedPermissionDenied - * - * @param host - * @param message - */ - public PoolAuthEnableFailedPermissionDenied(String host, String message) { - super("The pool failed to enable external authentication."); - this.host = host; - this.message = message; - } - - } - - /** - * The uuid you supplied was invalid. - */ - public static class UuidInvalid extends XenAPIException { - public final String type; - public final String uuid; - - /** - * Create a new UuidInvalid - * - * @param type - * @param uuid - */ - public UuidInvalid(String type, String uuid) { - super("The uuid you supplied was invalid."); - this.type = type; - this.uuid = uuid; - } - - } - - /** - * This operation is not allowed under your license. Please contact your support representative. - */ - public static class LicenceRestriction extends XenAPIException { - - /** - * Create a new LicenceRestriction - */ - public LicenceRestriction() { - super("This operation is not allowed under your license. Please contact your support representative."); - } - - } - - /** - * Network has active VIFs - */ - public static class VifInUse extends XenAPIException { - public final String network; - public final String VIF; - - /** - * Create a new VifInUse - * - * @param network - * @param VIF - */ - public VifInUse(String network, String VIF) { - super("Network has active VIFs"); - this.network = network; - this.VIF = VIF; - } - - } - - /** - * This command is only allowed on the OEM edition. - */ - public static class OnlyAllowedOnOemEdition extends XenAPIException { - public final String command; - - /** - * Create a new OnlyAllowedOnOemEdition - * - * @param command - */ - public OnlyAllowedOnOemEdition(String command) { - super("This command is only allowed on the OEM edition."); - this.command = command; - } - - } - - /** - * The operation cannot be performed on physical device - */ - public static class VdiIsAPhysicalDevice extends XenAPIException { - public final String vdi; - - /** - * Create a new VdiIsAPhysicalDevice - * - * @param vdi - */ - public VdiIsAPhysicalDevice(String vdi) { - super("The operation cannot be performed on physical device"); - this.vdi = vdi; - } - - } - - /** - * There was an error processing your license. Please contact your support representative. - */ - public static class LicenseProcessingError extends XenAPIException { - - /** - * Create a new LicenseProcessingError - */ - public LicenseProcessingError() { - super("There was an error processing your license. Please contact your support representative."); - } - - } - - /** - * The specified CRL does not exist. - */ - public static class CrlDoesNotExist extends XenAPIException { - public final String name; - - /** - * Create a new CrlDoesNotExist - * - * @param name - */ - public CrlDoesNotExist(String name) { - super("The specified CRL does not exist."); - this.name = name; - } - - } - - /** - * The request was asynchronously cancelled. - */ - public static class TaskCancelled extends XenAPIException { - public final String task; - - /** - * Create a new TaskCancelled - * - * @param task - */ - public TaskCancelled(String task) { - super("The request was asynchronously cancelled."); - this.task = task; - } - - } - - /** - * The VM crashed - */ - public static class VmCrashed extends XenAPIException { - public final String vm; - - /** - * Create a new VmCrashed - * - * @param vm - */ - public VmCrashed(String vm) { - super("The VM crashed"); - this.vm = vm; - } - - } - - /** - * The pool failed to enable external authentication. - */ - public static class PoolAuthEnableFailedDomainLookupFailed extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthEnableFailedDomainLookupFailed - * - * @param host - * @param message - */ - public PoolAuthEnableFailedDomainLookupFailed(String host, String message) { - super("The pool failed to enable external authentication."); - this.host = host; - this.message = message; - } - - } - - /** - * Host cannot rejoin pool because it should have fenced (it is not in the master's partition) - */ - public static class HaShouldBeFenced extends XenAPIException { - public final String host; - - /** - * Create a new HaShouldBeFenced - * - * @param host - */ - public HaShouldBeFenced(String host) { - super("Host cannot rejoin pool because it should have fenced (it is not in the master's partition)"); - this.host = host; - } - - } - - /** - * You attempted an operation on a VM that was judged to be unsafe by the server. This can happen if the VM would run on a CPU that has a potentially incompatible set of feature flags to those the VM requires. If you want to override this warning then use the 'force' option. - */ - public static class VmUnsafeBoot extends XenAPIException { - public final String vm; - - /** - * Create a new VmUnsafeBoot - * - * @param vm - */ - public VmUnsafeBoot(String vm) { - super("You attempted an operation on a VM that was judged to be unsafe by the server. This can happen if the VM would run on a CPU that has a potentially incompatible set of feature flags to those the VM requires. If you want to override this warning then use the 'force' option."); - this.vm = vm; - } - - } - - /** - * PIF has no IP configuration (mode curently set to 'none') - */ - public static class PifHasNoNetworkConfiguration extends XenAPIException { - - /** - * Create a new PifHasNoNetworkConfiguration - */ - public PifHasNoNetworkConfiguration() { - super("PIF has no IP configuration (mode curently set to 'none')"); - } - - } - - /** - * The request was rejected because the server is too busy. - */ - public static class TooBusy extends XenAPIException { - - /** - * Create a new TooBusy - */ - public TooBusy() { - super("The request was rejected because the server is too busy."); - } - - } - - /** - * You attempted to set a value that is not supported by this implementation. The fully-qualified field name and the value that you tried to set are returned. Also returned is a developer-only diagnostic reason. - */ - public static class ValueNotSupported extends XenAPIException { - public final String field; - public final String value; - public final String reason; - - /** - * Create a new ValueNotSupported - * - * @param field - * @param value - * @param reason - */ - public ValueNotSupported(String field, String value, String reason) { - super("You attempted to set a value that is not supported by this implementation. The fully-qualified field name and the value that you tried to set are returned. Also returned is a developer-only diagnostic reason."); - this.field = field; - this.value = value; - this.reason = reason; - } - - } - - /** - * You gave an invalid session reference. It may have been invalidated by a server restart, or timed out. You should get a new session handle, using one of the session.login_ calls. This error does not invalidate the current connection. The handle parameter echoes the bad value given. - */ - public static class SessionInvalid extends XenAPIException { - public final String handle; - - /** - * Create a new SessionInvalid - * - * @param handle - */ - public SessionInvalid(String handle) { - super("You gave an invalid session reference. It may have been invalidated by a server restart, or timed out. You should get a new session handle, using one of the session.login_ calls. This error does not invalidate the current connection. The handle parameter echoes the bad value given."); - this.handle = handle; - } - - } - - /** - * This operation cannot be performed because the referenced network is not properly shared. The network must either be entirely virtual or must be physically present via a currently_attached PIF on every host. - */ - public static class HaConstraintViolationNetworkNotShared extends XenAPIException { - public final String network; - - /** - * Create a new HaConstraintViolationNetworkNotShared - * - * @param network - */ - public HaConstraintViolationNetworkNotShared(String network) { - super("This operation cannot be performed because the referenced network is not properly shared. The network must either be entirely virtual or must be physically present via a currently_attached PIF on every host."); - this.network = network; - } - - } - - /** - * HA could not be enabled on the Pool because a liveset could not be formed: check storage and network heartbeat paths. - */ - public static class HaFailedToFormLiveset extends XenAPIException { - - /** - * Create a new HaFailedToFormLiveset - */ - public HaFailedToFormLiveset() { - super("HA could not be enabled on the Pool because a liveset could not be formed: check storage and network heartbeat paths."); - } - - } - - /** - * You cannot bond interfaces across different hosts. - */ - public static class PifCannotBondCrossHost extends XenAPIException { - - /** - * Create a new PifCannotBondCrossHost - */ - public PifCannotBondCrossHost() { - super("You cannot bond interfaces across different hosts."); - } - - } - - /** - * The operation cannot be performed until the SR has been upgraded - */ - public static class SrRequiresUpgrade extends XenAPIException { - public final String SR; - - /** - * Create a new SrRequiresUpgrade - * - * @param SR - */ - public SrRequiresUpgrade(String SR) { - super("The operation cannot be performed until the SR has been upgraded"); - this.SR = SR; - } - - } - - /** - * The specified certificate does not exist. - */ - public static class CertificateDoesNotExist extends XenAPIException { - public final String name; - - /** - * Create a new CertificateDoesNotExist - * - * @param name - */ - public CertificateDoesNotExist(String name) { - super("The specified certificate does not exist."); - this.name = name; - } - - } - - /** - * This operation cannot be performed because it would invalidate VM failover planning such that the system would be unable to guarantee to restart protected VMs after a Host failure. - */ - public static class HaOperationWouldBreakFailoverPlan extends XenAPIException { - - /** - * Create a new HaOperationWouldBreakFailoverPlan - */ - public HaOperationWouldBreakFailoverPlan() { - super("This operation cannot be performed because it would invalidate VM failover planning such that the system would be unable to guarantee to restart protected VMs after a Host failure."); - } - - } - - /** - * The requested update could to be obtained from the master. - */ - public static class CannotFetchPatch extends XenAPIException { - public final String uuid; - - /** - * Create a new CannotFetchPatch - * - * @param uuid - */ - public CannotFetchPatch(String uuid) { - super("The requested update could to be obtained from the master."); - this.uuid = uuid; - } - - } - - /** - * The requested update could not be found. This can occur when you designate a new master or xe patch-clean. Please upload the update again - */ - public static class CannotFindPatch extends XenAPIException { - - /** - * Create a new CannotFindPatch - */ - public CannotFindPatch() { - super("The requested update could not be found. This can occur when you designate a new master or xe patch-clean. Please upload the update again"); - } - - } - - /** - * You attempted an operation which would have resulted in duplicate keys in the database. - */ - public static class DbUniquenessConstraintViolation extends XenAPIException { - public final String table; - public final String field; - public final String value; - - /** - * Create a new DbUniquenessConstraintViolation - * - * @param table - * @param field - * @param value - */ - public DbUniquenessConstraintViolation(String table, String field, String value) { - super("You attempted an operation which would have resulted in duplicate keys in the database."); - this.table = table; - this.field = field; - this.value = value; - } - - } - - /** - * You attempted to run a VM on a host which doesn't have a PIF on a Network needed by the VM. The VM has at least one VIF attached to the Network. - */ - public static class VmRequiresNetwork extends XenAPIException { - public final String vm; - public final String network; - - /** - * Create a new VmRequiresNetwork - * - * @param vm - * @param network - */ - public VmRequiresNetwork(String vm, String network) { - super("You attempted to run a VM on a host which doesn't have a PIF on a Network needed by the VM. The VM has at least one VIF attached to the Network."); - this.vm = vm; - this.network = network; - } - - } - - /** - * Operation could not be performed because the drive is not empty - */ - public static class VbdNotEmpty extends XenAPIException { - public final String vbd; - - /** - * Create a new VbdNotEmpty - * - * @param vbd - */ - public VbdNotEmpty(String vbd) { - super("Operation could not be performed because the drive is not empty"); - this.vbd = vbd; - } - - } - - /** - * Not enough host memory is available to perform this operation - */ - public static class HostNotEnoughFreeMemory extends XenAPIException { - public final String needed; - public final String available; - - /** - * Create a new HostNotEnoughFreeMemory - * - * @param needed - * @param available - */ - public HostNotEnoughFreeMemory(String needed, String available) { - super("Not enough host memory is available to perform this operation"); - this.needed = needed; - this.available = available; - } - - } - - /** - * An error occurred during the migration process. - */ - public static class VmMigrateFailed extends XenAPIException { - public final String vm; - public final String source; - public final String destination; - public final String msg; - - /** - * Create a new VmMigrateFailed - * - * @param vm - * @param source - * @param destination - * @param msg - */ - public VmMigrateFailed(String vm, String source, String destination, String msg) { - super("An error occurred during the migration process."); - this.vm = vm; - this.source = source; - this.destination = destination; - this.msg = msg; - } - - } - - /** - * The SR backend does not support the operation (check the SR's allowed operations) - */ - public static class SrOperationNotSupported extends XenAPIException { - public final String sr; - - /** - * Create a new SrOperationNotSupported - * - * @param sr - */ - public SrOperationNotSupported(String sr) { - super("The SR backend does not support the operation (check the SR's allowed operations)"); - this.sr = sr; - } - - } - - /** - * The operation could not be performed because the VBD was not connected to the VM. - */ - public static class DeviceNotAttached extends XenAPIException { - public final String VBD; - - /** - * Create a new DeviceNotAttached - * - * @param VBD - */ - public DeviceNotAttached(String VBD) { - super("The operation could not be performed because the VBD was not connected to the VM."); - this.VBD = VBD; - } - - } - - /** - * The specified host is disabled. - */ - public static class HostDisabled extends XenAPIException { - public final String host; - - /** - * Create a new HostDisabled - * - * @param host - */ - public HostDisabled(String host) { - super("The specified host is disabled."); - this.host = host; - } - - } - - /** - * You must use tar output to retrieve system status from an OEM host. - */ - public static class SystemStatusMustUseTarOnOem extends XenAPIException { - - /** - * Create a new SystemStatusMustUseTarOnOem - */ - public SystemStatusMustUseTarOnOem() { - super("You must use tar output to retrieve system status from an OEM host."); - } - - } - - /** - * An attempt to prepare VSS writers for the snapshot failed - */ - public static class XenVssReqErrorPreparingWriters extends XenAPIException { - public final String vm; - public final String errorCode; - - /** - * Create a new XenVssReqErrorPreparingWriters - * - * @param vm - * @param errorCode - */ - public XenVssReqErrorPreparingWriters(String vm, String errorCode) { - super("An attempt to prepare VSS writers for the snapshot failed"); - this.vm = vm; - this.errorCode = errorCode; - } - - } - - /** - * The host failed to enable external authentication. - */ - public static class AuthEnableFailed extends XenAPIException { - public final String message; - - /** - * Create a new AuthEnableFailed - * - * @param message - */ - public AuthEnableFailed(String message) { - super("The host failed to enable external authentication."); - this.message = message; - } - - } - - /** - * The host joining the pool cannot contain any shared storage. - */ - public static class JoiningHostCannotContainSharedSrs extends XenAPIException { - - /** - * Create a new JoiningHostCannotContainSharedSrs - */ - public JoiningHostCannotContainSharedSrs() { - super("The host joining the pool cannot contain any shared storage."); - } - - } - - /** - * You need at least 1 VCPU to start a VM - */ - public static class VmNoVcpus extends XenAPIException { - public final String vm; - - /** - * Create a new VmNoVcpus - * - * @param vm - */ - public VmNoVcpus(String vm) { - super("You need at least 1 VCPU to start a VM"); - this.vm = vm; - } - - } - - /** - * The uploaded patch file is invalid. See attached log for more details. - */ - public static class InvalidPatchWithLog extends XenAPIException { - public final String log; - - /** - * Create a new InvalidPatchWithLog - * - * @param log - */ - public InvalidPatchWithLog(String log) { - super("The uploaded patch file is invalid. See attached log for more details."); - this.log = log; - } - - } - - /** - * The SR operation cannot be performed because a device underlying the SR is in use by the host. - */ - public static class SrDeviceInUse extends XenAPIException { - - /** - * Create a new SrDeviceInUse - */ - public SrDeviceInUse() { - super("The SR operation cannot be performed because a device underlying the SR is in use by the host."); - } - - } - - /** - * The host CDROM drive does not contain a valid CD - */ - public static class HostCdDriveEmpty extends XenAPIException { - - /** - * Create a new HostCdDriveEmpty - */ - public HostCdDriveEmpty() { - super("The host CDROM drive does not contain a valid CD"); - } - - } - - /** - * The operation could not be performed while the host is still armed; it must be disarmed first - */ - public static class HaHostIsArmed extends XenAPIException { - public final String host; - - /** - * Create a new HaHostIsArmed - * - * @param host - */ - public HaHostIsArmed(String host) { - super("The operation could not be performed while the host is still armed; it must be disarmed first"); - this.host = host; - } - - } - - /** - * Your license has expired. Please contact your support representative. - */ - public static class LicenseExpired extends XenAPIException { - - /** - * Create a new LicenseExpired - */ - public LicenseExpired() { - super("Your license has expired. Please contact your support representative."); - } - - } - - /** - * The credentials given by the user are incorrect, so access has been denied, and you have not been issued a session handle. - */ - public static class SessionAuthenticationFailed extends XenAPIException { - - /** - * Create a new SessionAuthenticationFailed - */ - public SessionAuthenticationFailed() { - super("The credentials given by the user are incorrect, so access has been denied, and you have not been issued a session handle."); - } - - } - - /** - * You tried to create a VLAN on top of another VLAN - use the underlying physical PIF/bond instead - */ - public static class PifIsVlan extends XenAPIException { - public final String PIF; - - /** - * Create a new PifIsVlan - * - * @param PIF - */ - public PifIsVlan(String PIF) { - super("You tried to create a VLAN on top of another VLAN - use the underlying physical PIF/bond instead"); - this.PIF = PIF; - } - - } - - /** - * Archive more frequent than backup. - */ - public static class VmppArchiveMoreFrequentThanBackup extends XenAPIException { - - /** - * Create a new VmppArchiveMoreFrequentThanBackup - */ - public VmppArchiveMoreFrequentThanBackup() { - super("Archive more frequent than backup."); - } - - } - - /** - * The host joining the pool cannot already be a master of another pool. - */ - public static class JoiningHostCannotBeMasterOfOtherHosts extends XenAPIException { - - /** - * Create a new JoiningHostCannotBeMasterOfOtherHosts - */ - public JoiningHostCannotBeMasterOfOtherHosts() { - super("The host joining the pool cannot already be a master of another pool."); - } - - } - - /** - * This host can not be forgotten because there are some user VMs still running - */ - public static class HostHasResidentVms extends XenAPIException { - public final String host; - - /** - * Create a new HostHasResidentVms - * - * @param host - */ - public HostHasResidentVms(String host) { - super("This host can not be forgotten because there are some user VMs still running"); - this.host = host; - } - - } - - /** - * An error occured while saving the memory image of the specified virtual machine - */ - public static class VmCheckpointSuspendFailed extends XenAPIException { - public final String vm; - - /** - * Create a new VmCheckpointSuspendFailed - * - * @param vm - */ - public VmCheckpointSuspendFailed(String vm) { - super("An error occured while saving the memory image of the specified virtual machine"); - this.vm = vm; - } - - } - - /** - * The operation you requested cannot be performed because the specified PIF is the management interface. - */ - public static class PifIsManagementInterface extends XenAPIException { - public final String PIF; - - /** - * Create a new PifIsManagementInterface - * - * @param PIF - */ - public PifIsManagementInterface(String PIF) { - super("The operation you requested cannot be performed because the specified PIF is the management interface."); - this.PIF = PIF; - } - - } - - /** - * The MAC address specified is not valid. - */ - public static class MacInvalid extends XenAPIException { - public final String MAC; - - /** - * Create a new MacInvalid - * - * @param MAC - */ - public MacInvalid(String MAC) { - super("The MAC address specified is not valid."); - this.MAC = MAC; - } - - } - - /** - * An attempt to start a new VSS snapshot failed - */ - public static class XenVssReqErrorStartSnapshotSetFailed extends XenAPIException { - public final String vm; - public final String errorCode; - - /** - * Create a new XenVssReqErrorStartSnapshotSetFailed - * - * @param vm - * @param errorCode - */ - public XenVssReqErrorStartSnapshotSetFailed(String vm, String errorCode) { - super("An attempt to start a new VSS snapshot failed"); - this.vm = vm; - this.errorCode = errorCode; - } - - } - - /** - * Operation could not be performed because the drive is empty - */ - public static class VbdIsEmpty extends XenAPIException { - public final String vbd; - - /** - * Create a new VbdIsEmpty - * - * @param vbd - */ - public VbdIsEmpty(String vbd) { - super("Operation could not be performed because the drive is empty"); - this.vbd = vbd; - } - - } - - /** - * The patch precheck stage failed: the server is of an incorrect version. - */ - public static class PatchPrecheckFailedWrongServerVersion extends XenAPIException { - public final String patch; - public final String foundVersion; - public final String requiredVersion; - - /** - * Create a new PatchPrecheckFailedWrongServerVersion - * - * @param patch - * @param foundVersion - * @param requiredVersion - */ - public PatchPrecheckFailedWrongServerVersion(String patch, String foundVersion, String requiredVersion) { - super("The patch precheck stage failed: the server is of an incorrect version."); - this.patch = patch; - this.foundVersion = foundVersion; - this.requiredVersion = requiredVersion; - } - - } - - /** - * This operation could not be performed because the state partition could not be found - */ - public static class CannotFindStatePartition extends XenAPIException { - - /** - * Create a new CannotFindStatePartition - */ - public CannotFindStatePartition() { - super("This operation could not be performed because the state partition could not be found"); - } - - } - - /** - * Unknown type of external authentication. - */ - public static class AuthUnknownType extends XenAPIException { - public final String type; - - /** - * Create a new AuthUnknownType - * - * @param type - */ - public AuthUnknownType(String type) { - super("Unknown type of external authentication."); - this.type = type; - } - - } - - /** - * The WLB server rejected our configured authentication details. - */ - public static class WlbAuthenticationFailed extends XenAPIException { - - /** - * Create a new WlbAuthenticationFailed - */ - public WlbAuthenticationFailed() { - super("The WLB server rejected our configured authentication details."); - } - - } - - /** - * This pool is not in emergency mode. - */ - public static class NotInEmergencyMode extends XenAPIException { - - /** - * Create a new NotInEmergencyMode - */ - public NotInEmergencyMode() { - super("This pool is not in emergency mode."); - } - - } - - /** - * The host failed to disable external authentication. - */ - public static class AuthDisableFailed extends XenAPIException { - public final String message; - - /** - * Create a new AuthDisableFailed - * - * @param message - */ - public AuthDisableFailed(String message) { - super("The host failed to disable external authentication."); - this.message = message; - } - - } - - /** - * You tried to create a PIF, but the network you tried to attach it to is already attached to some other PIF, and so the creation failed. - */ - public static class NetworkAlreadyConnected extends XenAPIException { - public final String network; - public final String connectedPIF; - - /** - * Create a new NetworkAlreadyConnected - * - * @param network - * @param connectedPIF - */ - public NetworkAlreadyConnected(String network, String connectedPIF) { - super("You tried to create a PIF, but the network you tried to attach it to is already attached to some other PIF, and so the creation failed."); - this.network = network; - this.connectedPIF = connectedPIF; - } - - } - - /** - * This operation cannot be performed because the specified VDI is of an incompatible type (eg: an HA statefile cannot be attached to a guest) - */ - public static class VdiIncompatibleType extends XenAPIException { - public final String vdi; - public final String type; - - /** - * Create a new VdiIncompatibleType - * - * @param vdi - * @param type - */ - public VdiIncompatibleType(String vdi, String type) { - super("This operation cannot be performed because the specified VDI is of an incompatible type (eg: an HA statefile cannot be attached to a guest)"); - this.vdi = vdi; - this.type = type; - } - - } - - /** - * The configured WLB server name failed to resolve in DNS. - */ - public static class WlbUnknownHost extends XenAPIException { - - /** - * Create a new WlbUnknownHost - */ - public WlbUnknownHost() { - super("The configured WLB server name failed to resolve in DNS."); - } - - } - - /** - * The VM could not be imported. - */ - public static class ImportError extends XenAPIException { - public final String msg; - - /** - * Create a new ImportError - * - * @param msg - */ - public ImportError(String msg) { - super("The VM could not be imported."); - this.msg = msg; - } - - } - - /** - * The SR could not be connected because the driver was not recognised. - */ - public static class SrUnknownDriver extends XenAPIException { - public final String driver; - - /** - * Create a new SrUnknownDriver - * - * @param driver - */ - public SrUnknownDriver(String driver) { - super("The SR could not be connected because the driver was not recognised."); - this.driver = driver; - } - - } - - /** - * The host failed to disable external authentication. - */ - public static class AuthDisableFailedWrongCredentials extends XenAPIException { - public final String message; - - /** - * Create a new AuthDisableFailedWrongCredentials - * - * @param message - */ - public AuthDisableFailedWrongCredentials(String message) { - super("The host failed to disable external authentication."); - this.message = message; - } - - } - - /** - * The VM unexpectedly halted - */ - public static class VmHalted extends XenAPIException { - public final String vm; - - /** - * Create a new VmHalted - * - * @param vm - */ - public VmHalted(String vm) { - super("The VM unexpectedly halted"); - this.vm = vm; - } - - } - - /** - * The use of this feature is restricted. - */ - public static class FeatureRestricted extends XenAPIException { - - /** - * Create a new FeatureRestricted - */ - public FeatureRestricted() { - super("The use of this feature is restricted."); - } - - } - - /** - * The specified CRL name is invalid. - */ - public static class CrlNameInvalid extends XenAPIException { - public final String name; - - /** - * Create a new CrlNameInvalid - * - * @param name - */ - public CrlNameInvalid(String name) { - super("The specified CRL name is invalid."); - this.name = name; - } - - } - - /** - * This operation cannot be completed as the host power on mode is disabled. - */ - public static class HostPowerOnModeDisabled extends XenAPIException { - - /** - * Create a new HostPowerOnModeDisabled - */ - public HostPowerOnModeDisabled() { - super("This operation cannot be completed as the host power on mode is disabled."); - } - - } - - /** - * An activation key can only be applied when the edition is set to 'free'. - */ - public static class ActivationWhileNotFree extends XenAPIException { - - /** - * Create a new ActivationWhileNotFree - */ - public ActivationWhileNotFree() { - super("An activation key can only be applied when the edition is set to 'free'."); - } - - } - - /** - * There was a failure communicating with the plugin. - */ - public static class XenapiPluginFailure extends XenAPIException { - public final String status; - public final String stdout; - public final String stderr; - - /** - * Create a new XenapiPluginFailure - * - * @param status - * @param stdout - * @param stderr - */ - public XenapiPluginFailure(String status, String stdout, String stderr) { - super("There was a failure communicating with the plugin."); - this.status = status; - this.stdout = stdout; - this.stderr = stderr; - } - - } - - /** - * The MAC address specified still exists on this host. - */ - public static class MacStillExists extends XenAPIException { - public final String MAC; - - /** - * Create a new MacStillExists - * - * @param MAC - */ - public MacStillExists(String MAC) { - super("The MAC address specified still exists on this host."); - this.MAC = MAC; - } - - } - - /** - * This operation cannot be completed as the host is in use by (at least) the object of type and ref echoed below. - */ - public static class HostInUse extends XenAPIException { - public final String host; - public final String type; - public final String ref; - - /** - * Create a new HostInUse - * - * @param host - * @param type - * @param ref - */ - public HostInUse(String host, String type, String ref) { - super("This operation cannot be completed as the host is in use by (at least) the object of type and ref echoed below."); - this.host = host; - this.type = type; - this.ref = ref; - } - - } - - /** - * HA can only be enabled for 2 hosts or more. Note that 2 hosts requires a pre-configured quorum tiebreak script. - */ - public static class HaTooFewHosts extends XenAPIException { - - /** - * Create a new HaTooFewHosts - */ - public HaTooFewHosts() { - super("HA can only be enabled for 2 hosts or more. Note that 2 hosts requires a pre-configured quorum tiebreak script."); - } - - } - - /** - * The connection to the WLB server was reset. - */ - public static class WlbConnectionReset extends XenAPIException { - - /** - * Create a new WlbConnectionReset - */ - public WlbConnectionReset() { - super("The connection to the WLB server was reset."); - } - - } - - /** - * The pool failed to enable external authentication. - */ - public static class PoolAuthEnableFailedWrongCredentials extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthEnableFailedWrongCredentials - * - * @param host - * @param message - */ - public PoolAuthEnableFailedWrongCredentials(String host, String message) { - super("The pool failed to enable external authentication."); - this.host = host; - this.message = message; - } - - } - - /** - * The specified patch is applied and cannot be destroyed. - */ - public static class PatchIsApplied extends XenAPIException { - - /** - * Create a new PatchIsApplied - */ - public PatchIsApplied() { - super("The specified patch is applied and cannot be destroyed."); - } - - } - - /** - * The SR is still connected to a host via a PBD. It cannot be destroyed. - */ - public static class SrHasPbd extends XenAPIException { - public final String sr; - - /** - * Create a new SrHasPbd - * - * @param sr - */ - public SrHasPbd(String sr) { - super("The SR is still connected to a host via a PBD. It cannot be destroyed."); - this.sr = sr; - } - - } - - /** - * The host is still booting. - */ - public static class HostStillBooting extends XenAPIException { - - /** - * Create a new HostStillBooting - */ - public HostStillBooting() { - super("The host is still booting."); - } - - } - - /** - * The WLB server rejected XenServer's request as malformed. - */ - public static class WlbMalformedRequest extends XenAPIException { - - /** - * Create a new WlbMalformedRequest - */ - public WlbMalformedRequest() { - super("The WLB server rejected XenServer's request as malformed."); - } - - } - - /** - * The specified object no longer exists. - */ - public static class ObjectNolongerExists extends XenAPIException { - - /** - * Create a new ObjectNolongerExists - */ - public ObjectNolongerExists() { - super("The specified object no longer exists."); - } - - } - - /** - * The hosts in this pool are not homogeneous. - */ - public static class HostsNotHomogeneous extends XenAPIException { - public final String reason; - - /** - * Create a new HostsNotHomogeneous - * - * @param reason - */ - public HostsNotHomogeneous(String reason) { - super("The hosts in this pool are not homogeneous."); - this.reason = reason; - } - - } - - /** - * The host joining the pool must have the same product version as the pool master. - */ - public static class PoolJoiningHostMustHaveSameProductVersion extends XenAPIException { - - /** - * Create a new PoolJoiningHostMustHaveSameProductVersion - */ - public PoolJoiningHostMustHaveSameProductVersion() { - super("The host joining the pool must have the same product version as the pool master."); - } - - } - - /** - * You tried to create a PIF, but it already exists. - */ - public static class PifVlanExists extends XenAPIException { - public final String PIF; - - /** - * Create a new PifVlanExists - * - * @param PIF - */ - public PifVlanExists(String PIF) { - super("You tried to create a PIF, but it already exists."); - this.PIF = PIF; - } - - } - - /** - * The license for the edition you requested is not available. - */ - public static class LicenseCheckoutError extends XenAPIException { - public final String reason; - - /** - * Create a new LicenseCheckoutError - * - * @param reason - */ - public LicenseCheckoutError(String reason) { - super("The license for the edition you requested is not available."); - this.reason = reason; - } - - } - - /** - * The certificate library is corrupt or unreadable. - */ - public static class CertificateLibraryCorrupt extends XenAPIException { - - /** - * Create a new CertificateLibraryCorrupt - */ - public CertificateLibraryCorrupt() { - super("The certificate library is corrupt or unreadable."); - } - - } - - /** - * This operation cannot be performed because the system does not manage this VDI - */ - public static class VdiNotManaged extends XenAPIException { - public final String vdi; - - /** - * Create a new VdiNotManaged - * - * @param vdi - */ - public VdiNotManaged(String vdi) { - super("This operation cannot be performed because the system does not manage this VDI"); - this.vdi = vdi; - } - - } - - /** - * The edition name you supplied is invalid. - */ - public static class InvalidEdition extends XenAPIException { - public final String edition; - - /** - * Create a new InvalidEdition - * - * @param edition - */ - public InvalidEdition(String edition) { - super("The edition name you supplied is invalid."); - this.edition = edition; - } - - } - - /** - * The uploaded patch file already exists - */ - public static class PatchAlreadyExists extends XenAPIException { - public final String uuid; - - /** - * Create a new PatchAlreadyExists - * - * @param uuid - */ - public PatchAlreadyExists(String uuid) { - super("The uploaded patch file already exists"); - this.uuid = uuid; - } - - } - - /** - * There is not enough space to upload the update - */ - public static class OutOfSpace extends XenAPIException { - public final String location; - - /** - * Create a new OutOfSpace - * - * @param location - */ - public OutOfSpace(String location) { - super("There is not enough space to upload the update"); - this.location = location; - } - - } - - /** - * The VM could not be imported; the end of the file was reached prematurely. - */ - public static class ImportErrorPrematureEof extends XenAPIException { - - /** - * Create a new ImportErrorPrematureEof - */ - public ImportErrorPrematureEof() { - super("The VM could not be imported; the end of the file was reached prematurely."); - } - - } - - /** - * The specified VM has too little memory to be started. - */ - public static class VmMemorySizeTooLow extends XenAPIException { - public final String vm; - - /** - * Create a new VmMemorySizeTooLow - * - * @param vm - */ - public VmMemorySizeTooLow(String vm) { - super("The specified VM has too little memory to be started."); - this.vm = vm; - } - - } - - /** - * There is at least on VM assigned to this protection policy. - */ - public static class VmppHasVm extends XenAPIException { - - /** - * Create a new VmppHasVm - */ - public VmppHasVm() { - super("There is at least on VM assigned to this protection policy."); - } - - } - - /** - * This operation cannot be performed because the host is not disabled. Please disable the host and then try again. - */ - public static class HostNotDisabled extends XenAPIException { - - /** - * Create a new HostNotDisabled - */ - public HostNotDisabled() { - super("This operation cannot be performed because the host is not disabled. Please disable the host and then try again."); - } - - } - - /** - * The value specified is of the wrong type - */ - public static class FieldTypeError extends XenAPIException { - public final String field; - - /** - * Create a new FieldTypeError - * - * @param field - */ - public FieldTypeError(String field) { - super("The value specified is of the wrong type"); - this.field = field; - } - - } - - /** - * The management interface on a slave cannot be disabled because the slave would enter emergency mode. - */ - public static class SlaveRequiresManagementInterface extends XenAPIException { - - /** - * Create a new SlaveRequiresManagementInterface - */ - public SlaveRequiresManagementInterface() { - super("The management interface on a slave cannot be disabled because the slave would enter emergency mode."); - } - - } - - /** - * The operation attempted is not valid for a template VM - */ - public static class VmIsTemplate extends XenAPIException { - public final String vm; - - /** - * Create a new VmIsTemplate - * - * @param vm - */ - public VmIsTemplate(String vm) { - super("The operation attempted is not valid for a template VM"); - this.vm = vm; - } - - } - - /** - * This operation cannot be performed because the specified VM is protected by xHA - */ - public static class VmIsProtected extends XenAPIException { - public final String vm; - - /** - * Create a new VmIsProtected - * - * @param vm - */ - public VmIsProtected(String vm) { - super("This operation cannot be performed because the specified VM is protected by xHA"); - this.vm = vm; - } - - } - - /** - * The host joining the pool cannot have any running VMs. - */ - public static class JoiningHostCannotHaveRunningVms extends XenAPIException { - - /** - * Create a new JoiningHostCannotHaveRunningVms - */ - public JoiningHostCannotHaveRunningVms() { - super("The host joining the pool cannot have any running VMs."); - } - - } - - /** - * VM cannot be started because it requires a VDI which cannot be attached - */ - public static class VmRequiresVdi extends XenAPIException { - public final String vm; - public final String vdi; - - /** - * Create a new VmRequiresVdi - * - * @param vm - * @param vdi - */ - public VmRequiresVdi(String vm, String vdi) { - super("VM cannot be started because it requires a VDI which cannot be attached"); - this.vm = vm; - this.vdi = vdi; - } - - } - - /** - * Read/write CDs are not supported - */ - public static class VbdCdsMustBeReadonly extends XenAPIException { - - /** - * Create a new VbdCdsMustBeReadonly - */ - public VbdCdsMustBeReadonly() { - super("Read/write CDs are not supported"); - } - - } - - /** - * This license file is no longer accepted. Please upgrade to the new licensing system. - */ - public static class LicenseFileDeprecated extends XenAPIException { - - /** - * Create a new LicenseFileDeprecated - */ - public LicenseFileDeprecated() { - super("This license file is no longer accepted. Please upgrade to the new licensing system."); - } - - } - - /** - * An HA statefile could not be created, perhaps because no SR with the appropriate capability was found. - */ - public static class CannotCreateStateFile extends XenAPIException { - - /** - * Create a new CannotCreateStateFile - */ - public CannotCreateStateFile() { - super("An HA statefile could not be created, perhaps because no SR with the appropriate capability was found."); - } - - } - - /** - * The host joining the pool cannot have any VMs with active tasks. - */ - public static class JoiningHostCannotHaveVmsWithCurrentOperations extends XenAPIException { - - /** - * Create a new JoiningHostCannotHaveVmsWithCurrentOperations - */ - public JoiningHostCannotHaveVmsWithCurrentOperations() { - super("The host joining the pool cannot have any VMs with active tasks."); - } - - } - - /** - * You tried to call a method with the incorrect number of parameters. The fully-qualified method name that you used, and the number of received and expected parameters are returned. - */ - public static class MessageParameterCountMismatch extends XenAPIException { - public final String method; - public final String expected; - public final String received; - - /** - * Create a new MessageParameterCountMismatch - * - * @param method - * @param expected - * @param received - */ - public MessageParameterCountMismatch(String method, String expected, String received) { - super("You tried to call a method with the incorrect number of parameters. The fully-qualified method name that you used, and the number of received and expected parameters are returned."); - this.method = method; - this.expected = expected; - this.received = received; - } - - } - - /** - * External authentication in this pool is already enabled for at least one host. - */ - public static class PoolAuthAlreadyEnabled extends XenAPIException { - public final String host; - - /** - * Create a new PoolAuthAlreadyEnabled - * - * @param host - */ - public PoolAuthAlreadyEnabled(String host) { - super("External authentication in this pool is already enabled for at least one host."); - this.host = host; - } - - } - - /** - * The restore could not be performed because this backup has been created by a different (incompatible) product version - */ - public static class RestoreIncompatibleVersion extends XenAPIException { - - /** - * Create a new RestoreIncompatibleVersion - */ - public RestoreIncompatibleVersion() { - super("The restore could not be performed because this backup has been created by a different (incompatible) product version"); - } - - } - - /** - * The VM rejected the attempt to detach the device. - */ - public static class DeviceDetachRejected extends XenAPIException { - public final String type; - public final String ref; - public final String msg; - - /** - * Create a new DeviceDetachRejected - * - * @param type - * @param ref - * @param msg - */ - public DeviceDetachRejected(String type, String ref, String msg) { - super("The VM rejected the attempt to detach the device."); - this.type = type; - this.ref = ref; - this.msg = msg; - } - - } - - /** - * External authentication is disabled, unable to resolve subject name. - */ - public static class AuthIsDisabled extends XenAPIException { - - /** - * Create a new AuthIsDisabled - */ - public AuthIsDisabled() { - super("External authentication is disabled, unable to resolve subject name."); - } - - } - - /** - * The host joining the pool cannot have any running or suspended VMs. - */ - public static class JoiningHostCannotHaveRunningOrSuspendedVms extends XenAPIException { - - /** - * Create a new JoiningHostCannotHaveRunningOrSuspendedVms - */ - public JoiningHostCannotHaveRunningOrSuspendedVms() { - super("The host joining the pool cannot have any running or suspended VMs."); - } - - } - - /** - * The patch precheck stage failed: prerequisite patches are missing. - */ - public static class PatchPrecheckFailedPrerequisiteMissing extends XenAPIException { - public final String patch; - public final String prerequisitePatchUuidList; - - /** - * Create a new PatchPrecheckFailedPrerequisiteMissing - * - * @param patch - * @param prerequisitePatchUuidList - */ - public PatchPrecheckFailedPrerequisiteMissing(String patch, String prerequisitePatchUuidList) { - super("The patch precheck stage failed: prerequisite patches are missing."); - this.patch = patch; - this.prerequisitePatchUuidList = prerequisitePatchUuidList; - } - - } - - /** - * The WLB server reported that communication with XenServer timed out. - */ - public static class WlbXenserverTimeout extends XenAPIException { - - /** - * Create a new WlbXenserverTimeout - */ - public WlbXenserverTimeout() { - super("The WLB server reported that communication with XenServer timed out."); - } - - } - - /** - * The quiesced-snapshot operation failed for an unexpected reason - */ - public static class VmSnapshotWithQuiesceFailed extends XenAPIException { - public final String vm; - - /** - * Create a new VmSnapshotWithQuiesceFailed - * - * @param vm - */ - public VmSnapshotWithQuiesceFailed(String vm) { - super("The quiesced-snapshot operation failed for an unexpected reason"); - this.vm = vm; - } - - } - - /** - * The pool failed to disable the external authentication of at least one host. - */ - public static class PoolAuthDisableFailedWrongCredentials extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthDisableFailedWrongCredentials - * - * @param host - * @param message - */ - public PoolAuthDisableFailedWrongCredentials(String host, String message) { - super("The pool failed to disable the external authentication of at least one host."); - this.host = host; - this.message = message; - } - - } - - /** - * The specified certificate is corrupt or unreadable. - */ - public static class CertificateCorrupt extends XenAPIException { - public final String name; - - /** - * Create a new CertificateCorrupt - * - * @param name - */ - public CertificateCorrupt(String name) { - super("The specified certificate is corrupt or unreadable."); - this.name = name; - } - - } - - /** - * The WLB server reported an internal error. - */ - public static class WlbInternalError extends XenAPIException { - - /** - * Create a new WlbInternalError - */ - public WlbInternalError() { - super("The WLB server reported an internal error."); - } - - } - - /** - * The VM unexpectedly rebooted - */ - public static class VmRebooted extends XenAPIException { - public final String vm; - - /** - * Create a new VmRebooted - * - * @param vm - */ - public VmRebooted(String vm) { - super("The VM unexpectedly rebooted"); - this.vm = vm; - } - - } - - /** - * Cannot forward messages because the host cannot be contacted. The host may be switched off or there may be network connectivity problems. - */ - public static class CannotContactHost extends XenAPIException { - public final String host; - - /** - * Create a new CannotContactHost - * - * @param host - */ - public CannotContactHost(String host) { - super("Cannot forward messages because the host cannot be contacted. The host may be switched off or there may be network connectivity problems."); - this.host = host; - } - - } - - /** - * Could not find any volumes supported by the Citrix XenServer Vss Provider - */ - public static class XenVssReqErrorNoVolumesSupported extends XenAPIException { - public final String vm; - public final String errorCode; - - /** - * Create a new XenVssReqErrorNoVolumesSupported - * - * @param vm - * @param errorCode - */ - public XenVssReqErrorNoVolumesSupported(String vm, String errorCode) { - super("Could not find any volumes supported by the Citrix XenServer Vss Provider"); - this.vm = vm; - this.errorCode = errorCode; - } - - } - - /** - * The host is its own slave. Please use pool-emergency-transition-to-master or pool-emergency-reset-master. - */ - public static class HostItsOwnSlave extends XenAPIException { - - /** - * Create a new HostItsOwnSlave - */ - public HostItsOwnSlave() { - super("The host is its own slave. Please use pool-emergency-transition-to-master or pool-emergency-reset-master."); - } - - } - - /** - * The operation could not be performed because a redo log is enabled on the Pool. - */ - public static class RedoLogIsEnabled extends XenAPIException { - - /** - * Create a new RedoLogIsEnabled - */ - public RedoLogIsEnabled() { - super("The operation could not be performed because a redo log is enabled on the Pool."); - } - - } - - /** - * You attempted an operation on a VM which requires PV drivers to be installed but the drivers were not detected. - */ - public static class VmMissingPvDrivers extends XenAPIException { - public final String vm; - - /** - * Create a new VmMissingPvDrivers - * - * @param vm - */ - public VmMissingPvDrivers(String vm) { - super("You attempted an operation on a VM which requires PV drivers to be installed but the drivers were not detected."); - this.vm = vm; - } - - } - - /** - * The specified certificate name is invalid. - */ - public static class CertificateNameInvalid extends XenAPIException { - public final String name; - - /** - * Create a new CertificateNameInvalid - * - * @param name - */ - public CertificateNameInvalid(String name) { - super("The specified certificate name is invalid."); - this.name = name; - } - - } - - /** - * The VM could not be imported because a required object could not be found. - */ - public static class ImportErrorFailedToFindObject extends XenAPIException { - public final String id; - - /** - * Create a new ImportErrorFailedToFindObject - * - * @param id - */ - public ImportErrorFailedToFindObject(String id) { - super("The VM could not be imported because a required object could not be found."); - this.id = id; - } - - } - - /** - * This operation cannot be performed because the specified VDI could not be found in the specified SR - */ - public static class VdiLocationMissing extends XenAPIException { - public final String sr; - public final String location; - - /** - * Create a new VdiLocationMissing - * - * @param sr - * @param location - */ - public VdiLocationMissing(String sr, String location) { - super("This operation cannot be performed because the specified VDI could not be found in the specified SR"); - this.sr = sr; - this.location = location; - } - - } - - /** - * The host failed to enable external authentication. - */ - public static class AuthEnableFailedPermissionDenied extends XenAPIException { - public final String message; - - /** - * Create a new AuthEnableFailedPermissionDenied - * - * @param message - */ - public AuthEnableFailedPermissionDenied(String message) { - super("The host failed to enable external authentication."); - this.message = message; - } - - } - - /** - * Operation cannot proceed while a VLAN exists on this interface. - */ - public static class PifVlanStillExists extends XenAPIException { - public final String PIF; - - /** - * Create a new PifVlanStillExists - * - * @param PIF - */ - public PifVlanStillExists(String PIF) { - super("Operation cannot proceed while a VLAN exists on this interface."); - this.PIF = PIF; - } - - } - - /** - * The given VMs failed to release memory when instructed to do so - */ - public static class VmsFailedToCooperate extends XenAPIException { - - /** - * Create a new VmsFailedToCooperate - */ - public VmsFailedToCooperate() { - super("The given VMs failed to release memory when instructed to do so"); - } - - } - - /** - * The network contains active VIFs and cannot be deleted. - */ - public static class NetworkContainsVif extends XenAPIException { - public final String vifs; - - /** - * Create a new NetworkContainsVif - * - * @param vifs - */ - public NetworkContainsVif(String vifs) { - super("The network contains active VIFs and cannot be deleted."); - this.vifs = vifs; - } - - } - - /** - * The value given is invalid - */ - public static class InvalidValue extends XenAPIException { - public final String field; - public final String value; - - /** - * Create a new InvalidValue - * - * @param field - * @param value - */ - public InvalidValue(String field, String value) { - super("The value given is invalid"); - this.field = field; - this.value = value; - } - - } - - /** - * The requested plugin could not be found. - */ - public static class XenapiMissingPlugin extends XenAPIException { - public final String name; - - /** - * Create a new XenapiMissingPlugin - * - * @param name - */ - public XenapiMissingPlugin(String name) { - super("The requested plugin could not be found."); - this.name = name; - } - - } - - /** - * The restore could not be performed because the host's current management interface is not in the backup. The interfaces mentioned in the backup are: - */ - public static class RestoreTargetMgmtIfNotInBackup extends XenAPIException { - - /** - * Create a new RestoreTargetMgmtIfNotInBackup - */ - public RestoreTargetMgmtIfNotInBackup() { - super("The restore could not be performed because the host's current management interface is not in the backup. The interfaces mentioned in the backup are:"); - } - - } - - /** - * You tried to create a VLAN or tunnel on top of a tunnel access PIF - use the underlying transport PIF instead. - */ - public static class IsTunnelAccessPif extends XenAPIException { - public final String PIF; - - /** - * Create a new IsTunnelAccessPif - * - * @param PIF - */ - public IsTunnelAccessPif(String PIF) { - super("You tried to create a VLAN or tunnel on top of a tunnel access PIF - use the underlying transport PIF instead."); - this.PIF = PIF; - } - - } - - /** - * There was an error connecting to the host while joining it in the pool. - */ - public static class JoiningHostConnectionFailed extends XenAPIException { - - /** - * Create a new JoiningHostConnectionFailed - */ - public JoiningHostConnectionFailed() { - super("There was an error connecting to the host while joining it in the pool."); - } - - } - - /** - * Some volumes to be snapshot could not be added to the VSS snapshot set - */ - public static class XenVssReqErrorAddingVolumeToSnapsetFailed extends XenAPIException { - public final String vm; - public final String errorCode; - - /** - * Create a new XenVssReqErrorAddingVolumeToSnapsetFailed - * - * @param vm - * @param errorCode - */ - public XenVssReqErrorAddingVolumeToSnapsetFailed(String vm, String errorCode) { - super("Some volumes to be snapshot could not be added to the VSS snapshot set"); - this.vm = vm; - this.errorCode = errorCode; - } - - } - - /** - * Subject cannot be resolved by the external directory service. - */ - public static class SubjectCannotBeResolved extends XenAPIException { - - /** - * Create a new SubjectCannotBeResolved - */ - public SubjectCannotBeResolved() { - super("Subject cannot be resolved by the external directory service."); - } - - } - - /** - * The provision call failed because it ran out of space. - */ - public static class ProvisionFailedOutOfSpace extends XenAPIException { - - /** - * Create a new ProvisionFailedOutOfSpace - */ - public ProvisionFailedOutOfSpace() { - super("The provision call failed because it ran out of space."); - } - - } - - /** - * This operation can only be performed on CD VDIs (iso files or CDROM drives) - */ - public static class VdiIsNotIso extends XenAPIException { - public final String vdi; - public final String type; - - /** - * Create a new VdiIsNotIso - * - * @param vdi - * @param type - */ - public VdiIsNotIso(String vdi, String type) { - super("This operation can only be performed on CD VDIs (iso files or CDROM drives)"); - this.vdi = vdi; - this.type = type; - } - - } - - /** - * You tried to call a method that does not exist. The method name that you used is echoed. - */ - public static class MessageMethodUnknown extends XenAPIException { - public final String method; - - /** - * Create a new MessageMethodUnknown - * - * @param method - */ - public MessageMethodUnknown(String method) { - super("You tried to call a method that does not exist. The method name that you used is echoed."); - this.method = method; - } - - } - - /** - * You cannot delete the specified default template. - */ - public static class VmCannotDeleteDefaultTemplate extends XenAPIException { - public final String vm; - - /** - * Create a new VmCannotDeleteDefaultTemplate - * - * @param vm - */ - public VmCannotDeleteDefaultTemplate(String vm) { - super("You cannot delete the specified default template."); - this.vm = vm; - } - - } - - /** - * Role cannot be found. - */ - public static class RoleNotFound extends XenAPIException { - - /** - * Create a new RoleNotFound - */ - public RoleNotFound() { - super("Role cannot be found."); - } - - } - - /** - * This command is not allowed on the OEM edition. - */ - public static class NotAllowedOnOemEdition extends XenAPIException { - public final String command; - - /** - * Create a new NotAllowedOnOemEdition - * - * @param command - */ - public NotAllowedOnOemEdition(String command) { - super("This command is not allowed on the OEM edition."); - this.command = command; - } - - } - - /** - * The restore could not be performed because the restore script failed. Is the file corrupt? - */ - public static class RestoreScriptFailed extends XenAPIException { - public final String log; - - /** - * Create a new RestoreScriptFailed - * - * @param log - */ - public RestoreScriptFailed(String log) { - super("The restore could not be performed because the restore script failed. Is the file corrupt?"); - this.log = log; - } - - } - - /** - * The server failed to handle your request, due to an internal error. The given message may give details useful for debugging the problem. - */ - public static class InternalError extends XenAPIException { - public final String message; - - /** - * Create a new InternalError - * - * @param message - */ - public InternalError(String message) { - super("The server failed to handle your request, due to an internal error. The given message may give details useful for debugging the problem."); - this.message = message; - } - - } - - /** - * XHA cannot be enabled because this host's license does not allow it - */ - public static class LicenseDoesNotSupportXha extends XenAPIException { - - /** - * Create a new LicenseDoesNotSupportXha - */ - public LicenseDoesNotSupportXha() { - super("XHA cannot be enabled because this host's license does not allow it"); - } - - } - - /** - * The device is not currently attached - */ - public static class DeviceAlreadyDetached extends XenAPIException { - public final String device; - - /** - * Create a new DeviceAlreadyDetached - * - * @param device - */ - public DeviceAlreadyDetached(String device) { - super("The device is not currently attached"); - this.device = device; - } - - } - - /** - * The host failed to enable external authentication. - */ - public static class AuthEnableFailedUnavailable extends XenAPIException { - public final String message; - - /** - * Create a new AuthEnableFailedUnavailable - * - * @param message - */ - public AuthEnableFailedUnavailable(String message) { - super("The host failed to enable external authentication."); - this.message = message; - } - - } - - /** - * Media could not be ejected because it is not removable - */ - public static class VbdNotRemovableMedia extends XenAPIException { - public final String vbd; - - /** - * Create a new VbdNotRemovableMedia - * - * @param vbd - */ - public VbdNotRemovableMedia(String vbd) { - super("Media could not be ejected because it is not removable"); - this.vbd = vbd; - } - - } - - /** - * A VDI with the specified location already exists within the SR - */ - public static class LocationNotUnique extends XenAPIException { - public final String SR; - public final String location; - - /** - * Create a new LocationNotUnique - * - * @param SR - * @param location - */ - public LocationNotUnique(String SR, String location) { - super("A VDI with the specified location already exists within the SR"); - this.SR = SR; - this.location = location; - } - - } - - /** - * The function is not implemented - */ - public static class NotImplemented extends XenAPIException { - public final String function; - - /** - * Create a new NotImplemented - * - * @param function - */ - public NotImplemented(String function) { - super("The function is not implemented"); - this.function = function; - } - - } - - /** - * Cannot plug VIF - */ - public static class CannotPlugVif extends XenAPIException { - public final String VIF; - - /** - * Create a new CannotPlugVif - * - * @param VIF - */ - public CannotPlugVif(String VIF) { - super("Cannot plug VIF"); - this.VIF = VIF; - } - - } - - /** - * Only the local superuser can execute this operation - */ - public static class UserIsNotLocalSuperuser extends XenAPIException { - public final String msg; - - /** - * Create a new UserIsNotLocalSuperuser - * - * @param msg - */ - public UserIsNotLocalSuperuser(String msg) { - super("Only the local superuser can execute this operation"); - this.msg = msg; - } - - } - - /** - * The backup could not be performed because the backup script failed. - */ - public static class BackupScriptFailed extends XenAPIException { - public final String log; - - /** - * Create a new BackupScriptFailed - * - * @param log - */ - public BackupScriptFailed(String log) { - super("The backup could not be performed because the backup script failed."); - this.log = log; - } - - } - - /** - * The VM could not be imported because the XVA file is invalid: an unexpected file was encountered. - */ - public static class ImportErrorUnexpectedFile extends XenAPIException { - public final String filenameExpected; - public final String filenameFound; - - /** - * Create a new ImportErrorUnexpectedFile - * - * @param filenameExpected - * @param filenameFound - */ - public ImportErrorUnexpectedFile(String filenameExpected, String filenameFound) { - super("The VM could not be imported because the XVA file is invalid: an unexpected file was encountered."); - this.filenameExpected = filenameExpected; - this.filenameFound = filenameFound; - } - - } - - /** - * External authentication for this host is already enabled. - */ - public static class AuthAlreadyEnabled extends XenAPIException { - public final String currentAuthType; - public final String currentServiceName; - - /** - * Create a new AuthAlreadyEnabled - * - * @param currentAuthType - * @param currentServiceName - */ - public AuthAlreadyEnabled(String currentAuthType, String currentServiceName) { - super("External authentication for this host is already enabled."); - this.currentAuthType = currentAuthType; - this.currentServiceName = currentServiceName; - } - - } - - /** - * You attempted an operation that was not allowed. - */ - public static class OperationNotAllowed extends XenAPIException { - public final String reason; - - /** - * Create a new OperationNotAllowed - * - * @param reason - */ - public OperationNotAllowed(String reason) { - super("You attempted an operation that was not allowed."); - this.reason = reason; - } - - } - - /** - * Cannot find a plan for placement of VMs as there are no other hosts available. - */ - public static class HaNoPlan extends XenAPIException { - - /** - * Create a new HaNoPlan - */ - public HaNoPlan() { - super("Cannot find a plan for placement of VMs as there are no other hosts available."); - } - - } - - /** - * Some events have been lost from the queue and cannot be retrieved. - */ - public static class EventsLost extends XenAPIException { - - /** - * Create a new EventsLost - */ - public EventsLost() { - super("Some events have been lost from the queue and cannot be retrieved."); - } - - } - - /** - * There was an SR backend failure. - */ - public static class SrBackendFailure extends XenAPIException { - public final String status; - public final String stdout; - public final String stderr; - - /** - * Create a new SrBackendFailure - * - * @param status - * @param stdout - * @param stderr - */ - public SrBackendFailure(String status, String stdout, String stderr) { - super("There was an SR backend failure."); - this.status = status; - this.stdout = stdout; - this.stderr = stderr; - } - - } - - /** - * A timeout happened while attempting to detach a device from a VM. - */ - public static class DeviceDetachTimeout extends XenAPIException { - public final String type; - public final String ref; - - /** - * Create a new DeviceDetachTimeout - * - * @param type - * @param ref - */ - public DeviceDetachTimeout(String type, String ref) { - super("A timeout happened while attempting to detach a device from a VM."); - this.type = type; - this.ref = ref; - } - - } - - /** - * The specified VM has a duplicate VBD device and cannot be started. - */ - public static class VmDuplicateVbdDevice extends XenAPIException { - public final String vm; - public final String vbd; - public final String device; - - /** - * Create a new VmDuplicateVbdDevice - * - * @param vm - * @param vbd - * @param device - */ - public VmDuplicateVbdDevice(String vm, String vbd, String device) { - super("The specified VM has a duplicate VBD device and cannot be started."); - this.vm = vm; - this.vbd = vbd; - this.device = device; - } - - } - - /** - * The specified CRL is corrupt or unreadable. - */ - public static class CrlCorrupt extends XenAPIException { - public final String name; - - /** - * Create a new CrlCorrupt - * - * @param name - */ - public CrlCorrupt(String name) { - super("The specified CRL is corrupt or unreadable."); - this.name = name; - } - - } - - /** - * You attempted an operation on a VM which requires a more recent version of the PV drivers. Please upgrade your PV drivers. - */ - public static class VmOldPvDrivers extends XenAPIException { - public final String vm; - public final String major; - public final String minor; - - /** - * Create a new VmOldPvDrivers - * - * @param vm - * @param major - * @param minor - */ - public VmOldPvDrivers(String vm, String major, String minor) { - super("You attempted an operation on a VM which requires a more recent version of the PV drivers. Please upgrade your PV drivers."); - this.vm = vm; - this.major = major; - this.minor = minor; - } - - } - - /** - * The operation you requested cannot be performed because the specified PIF does not allow unplug. - */ - public static class PifDoesNotAllowUnplug extends XenAPIException { - public final String PIF; - - /** - * Create a new PifDoesNotAllowUnplug - * - * @param PIF - */ - public PifDoesNotAllowUnplug(String PIF) { - super("The operation you requested cannot be performed because the specified PIF does not allow unplug."); - this.PIF = PIF; - } - - } - - /** - * The system rejected the password change request; perhaps the new password was too short? - */ - public static class ChangePasswordRejected extends XenAPIException { - public final String msg; - - /** - * Create a new ChangePasswordRejected - * - * @param msg - */ - public ChangePasswordRejected(String msg) { - super("The system rejected the password change request; perhaps the new password was too short?"); - this.msg = msg; - } - - } - - /** - * Another operation involving the object is currently in progress - */ - public static class OtherOperationInProgress extends XenAPIException { - public final String clazz; - public final String object; - - /** - * Create a new OtherOperationInProgress - * - * @param clazz - * @param object - */ - public OtherOperationInProgress(String clazz, String object) { - super("Another operation involving the object is currently in progress"); - this.clazz = clazz; - this.object = object; - } - - } - - /** - * Initialization of the VSS requestor failed - */ - public static class XenVssReqErrorInitFailed extends XenAPIException { - public final String vm; - public final String errorCode; - - /** - * Create a new XenVssReqErrorInitFailed - * - * @param vm - * @param errorCode - */ - public XenVssReqErrorInitFailed(String vm, String errorCode) { - super("Initialization of the VSS requestor failed"); - this.vm = vm; - this.errorCode = errorCode; - } - - } - - /** - * The CPU does not support masking of features. - */ - public static class CpuFeatureMaskingNotSupported extends XenAPIException { - public final String details; - - /** - * Create a new CpuFeatureMaskingNotSupported - * - * @param details - */ - public CpuFeatureMaskingNotSupported(String details) { - super("The CPU does not support masking of features."); - this.details = details; - } - - } - - /** - * The specified VM is not currently resident on the specified host. - */ - public static class VmNotResidentHere extends XenAPIException { - public final String vm; - public final String host; - - /** - * Create a new VmNotResidentHere - * - * @param vm - * @param host - */ - public VmNotResidentHere(String vm, String host) { - super("The specified VM is not currently resident on the specified host."); - this.vm = vm; - this.host = host; - } - - } - - /** - * You attempted an operation which involves a host which could not be contacted. - */ - public static class HostOffline extends XenAPIException { - public final String host; - - /** - * Create a new HostOffline - * - * @param host - */ - public HostOffline(String host) { - super("You attempted an operation which involves a host which could not be contacted."); - this.host = host; - } - - } - - /** - * The pool failed to disable the external authentication of at least one host. - */ - public static class PoolAuthDisableFailed extends XenAPIException { - public final String host; - public final String message; - - /** - * Create a new PoolAuthDisableFailed - * - * @param host - * @param message - */ - public PoolAuthDisableFailed(String host, String message) { - super("The pool failed to disable the external authentication of at least one host."); - this.host = host; - this.message = message; - } - - } - - /** - * The host failed to acquire an IP address on its management interface and therefore cannot contact the master. - */ - public static class HostHasNoManagementIp extends XenAPIException { - - /** - * Create a new HostHasNoManagementIp - */ - public HostHasNoManagementIp() { - super("The host failed to acquire an IP address on its management interface and therefore cannot contact the master."); - } - - } - - /** - * The tunnel transport PIF has no IP configuration set. - */ - public static class TransportPifNotConfigured extends XenAPIException { - public final String PIF; - - /** - * Create a new TransportPifNotConfigured - * - * @param PIF - */ - public TransportPifNotConfigured(String PIF) { - super("The tunnel transport PIF has no IP configuration set."); - this.PIF = PIF; - } - - } - - /** - * The operation could not be performed because HA is enabled on the Pool - */ - public static class HaIsEnabled extends XenAPIException { - - /** - * Create a new HaIsEnabled - */ - public HaIsEnabled() { - super("The operation could not be performed because HA is enabled on the Pool"); - } - - } - - /** - * An error occured while reverting the specified virtual machine to the specified snapshot - */ - public static class VmRevertFailed extends XenAPIException { - public final String vm; - public final String snapshot; - - /** - * Create a new VmRevertFailed - * - * @param vm - * @param snapshot - */ - public VmRevertFailed(String vm, String snapshot) { - super("An error occured while reverting the specified virtual machine to the specified snapshot"); - this.vm = vm; - this.snapshot = snapshot; - } - - } - - /** - * The host name is invalid. - */ - public static class HostNameInvalid extends XenAPIException { - public final String reason; - - /** - * Create a new HostNameInvalid - * - * @param reason - */ - public HostNameInvalid(String reason) { - super("The host name is invalid."); - this.reason = reason; - } - - } - - /** - * The operation could not be performed because a domain still exists for the specified VM. - */ - public static class DomainExists extends XenAPIException { - public final String vm; - public final String domid; - - /** - * Create a new DomainExists - * - * @param vm - * @param domid - */ - public DomainExists(String vm, String domid) { - super("The operation could not be performed because a domain still exists for the specified VM."); - this.vm = vm; - this.domid = domid; - } - - } - - /** - * This host cannot join the pool because the pool has HA enabled but this host has HA disabled. - */ - public static class HaPoolIsEnabledButHostIsDisabled extends XenAPIException { - - /** - * Create a new HaPoolIsEnabledButHostIsDisabled - */ - public HaPoolIsEnabledButHostIsDisabled() { - super("This host cannot join the pool because the pool has HA enabled but this host has HA disabled."); - } - - } - - /** - * This message has been deprecated. - */ - public static class MessageDeprecated extends XenAPIException { - - /** - * Create a new MessageDeprecated - */ - public MessageDeprecated() { - super("This message has been deprecated."); - } - - } - - /** - * This operation cannot be performed because the referenced SR is not properly shared. The SR must both be marked as shared and a currently_attached PBD must exist for each host. - */ - public static class HaConstraintViolationSrNotShared extends XenAPIException { - public final String SR; - - /** - * Create a new HaConstraintViolationSrNotShared - * - * @param SR - */ - public HaConstraintViolationSrNotShared(String SR) { - super("This operation cannot be performed because the referenced SR is not properly shared. The SR must both be marked as shared and a currently_attached PBD must exist for each host."); - this.SR = SR; - } - - } - - /** - * Cannot import VM using chunked encoding. - */ - public static class ImportErrorCannotHandleChunked extends XenAPIException { - - /** - * Create a new ImportErrorCannotHandleChunked - */ - public ImportErrorCannotHandleChunked() { - super("Cannot import VM using chunked encoding."); - } - - } - - /** - * You attempted to start a VM that's attached to more than one VDI with a timeoffset marked as reset-on-boot. - */ - public static class VmAttachedToMoreThanOneVdiWithTimeoffsetMarkedAsResetOnBoot extends XenAPIException { - public final String vm; - - /** - * Create a new VmAttachedToMoreThanOneVdiWithTimeoffsetMarkedAsResetOnBoot - * - * @param vm - */ - public VmAttachedToMoreThanOneVdiWithTimeoffsetMarkedAsResetOnBoot(String vm) { - super("You attempted to start a VM that's attached to more than one VDI with a timeoffset marked as reset-on-boot."); - this.vm = vm; - } - - } - - /** - * This operation is not supported during an upgrade - */ - public static class NotSupportedDuringUpgrade extends XenAPIException { - - /** - * Create a new NotSupportedDuringUpgrade - */ - public NotSupportedDuringUpgrade() { - super("This operation is not supported during an upgrade"); - } - - } - - /** - * An unknown error occurred while attempting to configure an interface. - */ - public static class PifConfigurationError extends XenAPIException { - public final String PIF; - public final String msg; - - /** - * Create a new PifConfigurationError - * - * @param PIF - * @param msg - */ - public PifConfigurationError(String PIF, String msg) { - super("An unknown error occurred while attempting to configure an interface."); - this.PIF = PIF; - this.msg = msg; - } - - } - - /** - * The specified interface cannot be used because it has no IP address - */ - public static class InterfaceHasNoIp extends XenAPIException { - public final String iface; - - /** - * Create a new InterfaceHasNoIp - * - * @param iface - */ - public InterfaceHasNoIp(String iface) { - super("The specified interface cannot be used because it has no IP address"); - this.iface = iface; - } - - } - - /** - * The host failed to enable external authentication. - */ - public static class AuthEnableFailedWrongCredentials extends XenAPIException { - public final String message; - - /** - * Create a new AuthEnableFailedWrongCredentials - * - * @param message - */ - public AuthEnableFailedWrongCredentials(String message) { - super("The host failed to enable external authentication."); - this.message = message; - } - - } - - - public static String toString(Object object) { - if (object == null) { - return null; - } - return (String) object; - } - - public static Long toLong(Object object) { - if (object == null) { - return null; - } - return Long.valueOf((String) object); - } - - public static Double toDouble(Object object) { - if (object == null) { - return null; - } - return (Double) object; - } - - public static Boolean toBoolean(Object object) { - if (object == null) { - return null; - } - return (Boolean) object; - } - - public static Date toDate(Object object) { - if (object == null) { - return null; - } - try { - return (Date) object; - } catch (ClassCastException e){ - //Occasionally the date comes back as an ocaml float rather than - //in the xmlrpc format! Catch this and convert. - return (new Date((long) (1000*Double.parseDouble((String) object)))); - } - } - - public static Types.XenAPIObjects toXenAPIObjects(Object object) { - if (object == null) { - return null; - } - try { - return XenAPIObjects.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return XenAPIObjects.UNRECOGNIZED; - } - } - - public static Types.AfterApplyGuidance toAfterApplyGuidance(Object object) { - if (object == null) { - return null; - } - try { - return AfterApplyGuidance.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return AfterApplyGuidance.UNRECOGNIZED; - } - } - - public static Types.Cls toCls(Object object) { - if (object == null) { - return null; - } - try { - return Cls.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return Cls.UNRECOGNIZED; - } - } - - public static Types.ConsoleProtocol toConsoleProtocol(Object object) { - if (object == null) { - return null; - } - try { - return ConsoleProtocol.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return ConsoleProtocol.UNRECOGNIZED; - } - } - - public static Types.EventOperation toEventOperation(Object object) { - if (object == null) { - return null; - } - try { - return EventOperation.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return EventOperation.UNRECOGNIZED; - } - } - - public static Types.HostAllowedOperations toHostAllowedOperations(Object object) { - if (object == null) { - return null; - } - try { - return HostAllowedOperations.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return HostAllowedOperations.UNRECOGNIZED; - } - } - - public static Types.IpConfigurationMode toIpConfigurationMode(Object object) { - if (object == null) { - return null; - } - try { - return IpConfigurationMode.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return IpConfigurationMode.UNRECOGNIZED; - } - } - - public static Types.NetworkOperations toNetworkOperations(Object object) { - if (object == null) { - return null; - } - try { - return NetworkOperations.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return NetworkOperations.UNRECOGNIZED; - } - } - - public static Types.OnBoot toOnBoot(Object object) { - if (object == null) { - return null; - } - try { - return OnBoot.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return OnBoot.UNRECOGNIZED; - } - } - - public static Types.OnCrashBehaviour toOnCrashBehaviour(Object object) { - if (object == null) { - return null; - } - try { - return OnCrashBehaviour.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return OnCrashBehaviour.UNRECOGNIZED; - } - } - - public static Types.OnNormalExit toOnNormalExit(Object object) { - if (object == null) { - return null; - } - try { - return OnNormalExit.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return OnNormalExit.UNRECOGNIZED; - } - } - - public static Types.StorageOperations toStorageOperations(Object object) { - if (object == null) { - return null; - } - try { - return StorageOperations.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return StorageOperations.UNRECOGNIZED; - } - } - - public static Types.TaskAllowedOperations toTaskAllowedOperations(Object object) { - if (object == null) { - return null; - } - try { - return TaskAllowedOperations.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return TaskAllowedOperations.UNRECOGNIZED; - } - } - - public static Types.TaskStatusType toTaskStatusType(Object object) { - if (object == null) { - return null; - } - try { - return TaskStatusType.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return TaskStatusType.UNRECOGNIZED; - } - } - - public static Types.VbdMode toVbdMode(Object object) { - if (object == null) { - return null; - } - try { - return VbdMode.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VbdMode.UNRECOGNIZED; - } - } - - public static Types.VbdOperations toVbdOperations(Object object) { - if (object == null) { - return null; - } - try { - return VbdOperations.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VbdOperations.UNRECOGNIZED; - } - } - - public static Types.VbdType toVbdType(Object object) { - if (object == null) { - return null; - } - try { - return VbdType.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VbdType.UNRECOGNIZED; - } - } - - public static Types.VdiOperations toVdiOperations(Object object) { - if (object == null) { - return null; - } - try { - return VdiOperations.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VdiOperations.UNRECOGNIZED; - } - } - - public static Types.VdiType toVdiType(Object object) { - if (object == null) { - return null; - } - try { - return VdiType.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VdiType.UNRECOGNIZED; - } - } - - public static Types.VifOperations toVifOperations(Object object) { - if (object == null) { - return null; - } - try { - return VifOperations.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VifOperations.UNRECOGNIZED; - } - } - - public static Types.VmOperations toVmOperations(Object object) { - if (object == null) { - return null; - } - try { - return VmOperations.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VmOperations.UNRECOGNIZED; - } - } - - public static Types.VmPowerState toVmPowerState(Object object) { - if (object == null) { - return null; - } - try { - return VmPowerState.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VmPowerState.UNRECOGNIZED; - } - } - - public static Types.VmppArchiveFrequency toVmppArchiveFrequency(Object object) { - if (object == null) { - return null; - } - try { - return VmppArchiveFrequency.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VmppArchiveFrequency.UNRECOGNIZED; - } - } - - public static Types.VmppArchiveTargetType toVmppArchiveTargetType(Object object) { - if (object == null) { - return null; - } - try { - return VmppArchiveTargetType.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VmppArchiveTargetType.UNRECOGNIZED; - } - } - - public static Types.VmppBackupFrequency toVmppBackupFrequency(Object object) { - if (object == null) { - return null; - } - try { - return VmppBackupFrequency.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VmppBackupFrequency.UNRECOGNIZED; - } - } - - public static Types.VmppBackupType toVmppBackupType(Object object) { - if (object == null) { - return null; - } - try { - return VmppBackupType.valueOf(((String) object).toUpperCase()); - } catch (IllegalArgumentException ex) { - return VmppBackupType.UNRECOGNIZED; - } - } - - public static Set toSetOfString(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - String typed = toString(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfAfterApplyGuidance(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.AfterApplyGuidance typed = toAfterApplyGuidance(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfHostAllowedOperations(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.HostAllowedOperations typed = toHostAllowedOperations(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfNetworkOperations(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.NetworkOperations typed = toNetworkOperations(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfStorageOperations(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.StorageOperations typed = toStorageOperations(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfTaskAllowedOperations(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.TaskAllowedOperations typed = toTaskAllowedOperations(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVbdOperations(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.VbdOperations typed = toVbdOperations(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVdiOperations(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.VdiOperations typed = toVdiOperations(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVifOperations(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.VifOperations typed = toVifOperations(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVmOperations(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Types.VmOperations typed = toVmOperations(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfBond(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Bond typed = toBond(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfPBD(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - PBD typed = toPBD(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfPIF(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - PIF typed = toPIF(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfPIFMetrics(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - PIFMetrics typed = toPIFMetrics(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfSM(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - SM typed = toSM(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfSR(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - SR typed = toSR(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVBD(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VBD typed = toVBD(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVBDMetrics(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VBDMetrics typed = toVBDMetrics(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVDI(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VDI typed = toVDI(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVIF(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VIF typed = toVIF(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVIFMetrics(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VIFMetrics typed = toVIFMetrics(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVLAN(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VLAN typed = toVLAN(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVM(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VM typed = toVM(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVMPP(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VMPP typed = toVMPP(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVMGuestMetrics(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VMGuestMetrics typed = toVMGuestMetrics(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVMMetrics(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VMMetrics typed = toVMMetrics(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfVTPM(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - VTPM typed = toVTPM(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfBlob(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Blob typed = toBlob(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfConsole(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Console typed = toConsole(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfCrashdump(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Crashdump typed = toCrashdump(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfHost(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Host typed = toHost(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfHostCpu(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - HostCpu typed = toHostCpu(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfHostCrashdump(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - HostCrashdump typed = toHostCrashdump(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfHostMetrics(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - HostMetrics typed = toHostMetrics(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfHostPatch(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - HostPatch typed = toHostPatch(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfMessage(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Message typed = toMessage(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfNetwork(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Network typed = toNetwork(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfPool(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Pool typed = toPool(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfPoolPatch(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - PoolPatch typed = toPoolPatch(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfRole(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Role typed = toRole(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfSecret(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Secret typed = toSecret(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfSubject(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Subject typed = toSubject(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfTask(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Task typed = toTask(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfTunnel(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Tunnel typed = toTunnel(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfDataSourceRecord(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - DataSource.Record typed = toDataSourceRecord(item); - result.add(typed); - } - return result; - } - - public static Set toSetOfEventRecord(Object object) { - if (object == null) { - return null; - } - Object[] items = (Object[]) object; - Set result = new LinkedHashSet(); - for(Object item: items) { - Event.Record typed = toEventRecord(item); - result.add(typed); - } - return result; - } - - public static Map toMapOfStringString(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - String value = toString(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringHostAllowedOperations(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Types.HostAllowedOperations value = toHostAllowedOperations(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringNetworkOperations(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Types.NetworkOperations value = toNetworkOperations(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringStorageOperations(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Types.StorageOperations value = toStorageOperations(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringTaskAllowedOperations(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Types.TaskAllowedOperations value = toTaskAllowedOperations(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringVbdOperations(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Types.VbdOperations value = toVbdOperations(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringVdiOperations(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Types.VdiOperations value = toVdiOperations(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringVifOperations(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Types.VifOperations value = toVifOperations(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringVmOperations(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Types.VmOperations value = toVmOperations(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfStringBlob(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - String key = toString(entry.getKey()); - Blob value = toBlob(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfLongLong(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Long key = toLong(entry.getKey()); - Long value = toLong(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfLongDouble(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Long key = toLong(entry.getKey()); - Double value = toDouble(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map> toMapOfLongSetOfString(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map> result = new HashMap>(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Long key = toLong(entry.getKey()); - Set value = toSetOfString(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVmOperationsString(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Types.VmOperations key = toVmOperations(entry.getKey()); - String value = toString(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfBondBondRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Bond key = toBond(entry.getKey()); - Bond.Record value = toBondRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfPBDPBDRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - PBD key = toPBD(entry.getKey()); - PBD.Record value = toPBDRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfPIFPIFRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - PIF key = toPIF(entry.getKey()); - PIF.Record value = toPIFRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfPIFMetricsPIFMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - PIFMetrics key = toPIFMetrics(entry.getKey()); - PIFMetrics.Record value = toPIFMetricsRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfSMSMRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - SM key = toSM(entry.getKey()); - SM.Record value = toSMRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfSRSRRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - SR key = toSR(entry.getKey()); - SR.Record value = toSRRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVBDVBDRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VBD key = toVBD(entry.getKey()); - VBD.Record value = toVBDRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVBDMetricsVBDMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VBDMetrics key = toVBDMetrics(entry.getKey()); - VBDMetrics.Record value = toVBDMetricsRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVDIVDIRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VDI key = toVDI(entry.getKey()); - VDI.Record value = toVDIRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVIFVIFRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VIF key = toVIF(entry.getKey()); - VIF.Record value = toVIFRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVIFMetricsVIFMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VIFMetrics key = toVIFMetrics(entry.getKey()); - VIFMetrics.Record value = toVIFMetricsRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVLANVLANRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VLAN key = toVLAN(entry.getKey()); - VLAN.Record value = toVLANRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVMString(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VM key = toVM(entry.getKey()); - String value = toString(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map> toMapOfVMSetOfString(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map> result = new HashMap>(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VM key = toVM(entry.getKey()); - Set value = toSetOfString(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map> toMapOfVMMapOfStringString(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map> result = new HashMap>(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VM key = toVM(entry.getKey()); - Map value = toMapOfStringString(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVMVMRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VM key = toVM(entry.getKey()); - VM.Record value = toVMRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVMPPVMPPRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VMPP key = toVMPP(entry.getKey()); - VMPP.Record value = toVMPPRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVMGuestMetricsVMGuestMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VMGuestMetrics key = toVMGuestMetrics(entry.getKey()); - VMGuestMetrics.Record value = toVMGuestMetricsRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfVMMetricsVMMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - VMMetrics key = toVMMetrics(entry.getKey()); - VMMetrics.Record value = toVMMetricsRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfBlobBlobRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Blob key = toBlob(entry.getKey()); - Blob.Record value = toBlobRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfConsoleConsoleRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Console key = toConsole(entry.getKey()); - Console.Record value = toConsoleRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfCrashdumpCrashdumpRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Crashdump key = toCrashdump(entry.getKey()); - Crashdump.Record value = toCrashdumpRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map> toMapOfHostSetOfString(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map> result = new HashMap>(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Host key = toHost(entry.getKey()); - Set value = toSetOfString(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfHostHostRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Host key = toHost(entry.getKey()); - Host.Record value = toHostRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfHostCpuHostCpuRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - HostCpu key = toHostCpu(entry.getKey()); - HostCpu.Record value = toHostCpuRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfHostCrashdumpHostCrashdumpRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - HostCrashdump key = toHostCrashdump(entry.getKey()); - HostCrashdump.Record value = toHostCrashdumpRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfHostMetricsHostMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - HostMetrics key = toHostMetrics(entry.getKey()); - HostMetrics.Record value = toHostMetricsRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfHostPatchHostPatchRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - HostPatch key = toHostPatch(entry.getKey()); - HostPatch.Record value = toHostPatchRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfMessageMessageRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Message key = toMessage(entry.getKey()); - Message.Record value = toMessageRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfNetworkNetworkRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Network key = toNetwork(entry.getKey()); - Network.Record value = toNetworkRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfPoolPoolRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Pool key = toPool(entry.getKey()); - Pool.Record value = toPoolRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfPoolPatchPoolPatchRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - PoolPatch key = toPoolPatch(entry.getKey()); - PoolPatch.Record value = toPoolPatchRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfRoleRoleRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Role key = toRole(entry.getKey()); - Role.Record value = toRoleRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfSecretSecretRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Secret key = toSecret(entry.getKey()); - Secret.Record value = toSecretRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfSubjectSubjectRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Subject key = toSubject(entry.getKey()); - Subject.Record value = toSubjectRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfTaskTaskRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Task key = toTask(entry.getKey()); - Task.Record value = toTaskRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Map toMapOfTunnelTunnelRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Map result = new HashMap(); - Set entries = map.entrySet(); - for(Map.Entry entry: entries) { - Tunnel key = toTunnel(entry.getKey()); - Tunnel.Record value = toTunnelRecord(entry.getValue()); - result.put(key, value); - } - return result; - } - - public static Bond toBond(Object object) { - if (object == null) { - return null; - } - return new Bond((String) object); - } - - public static PBD toPBD(Object object) { - if (object == null) { - return null; - } - return new PBD((String) object); - } - - public static PIF toPIF(Object object) { - if (object == null) { - return null; - } - return new PIF((String) object); - } - - public static PIFMetrics toPIFMetrics(Object object) { - if (object == null) { - return null; - } - return new PIFMetrics((String) object); - } - - public static SM toSM(Object object) { - if (object == null) { - return null; - } - return new SM((String) object); - } - - public static SR toSR(Object object) { - if (object == null) { - return null; - } - return new SR((String) object); - } - - public static VBD toVBD(Object object) { - if (object == null) { - return null; - } - return new VBD((String) object); - } - - public static VBDMetrics toVBDMetrics(Object object) { - if (object == null) { - return null; - } - return new VBDMetrics((String) object); - } - - public static VDI toVDI(Object object) { - if (object == null) { - return null; - } - return new VDI((String) object); - } - - public static VIF toVIF(Object object) { - if (object == null) { - return null; - } - return new VIF((String) object); - } - - public static VIFMetrics toVIFMetrics(Object object) { - if (object == null) { - return null; - } - return new VIFMetrics((String) object); - } - - public static VLAN toVLAN(Object object) { - if (object == null) { - return null; - } - return new VLAN((String) object); - } - - public static VM toVM(Object object) { - if (object == null) { - return null; - } - return new VM((String) object); - } - - public static VMPP toVMPP(Object object) { - if (object == null) { - return null; - } - return new VMPP((String) object); - } - - public static VMGuestMetrics toVMGuestMetrics(Object object) { - if (object == null) { - return null; - } - return new VMGuestMetrics((String) object); - } - - public static VMMetrics toVMMetrics(Object object) { - if (object == null) { - return null; - } - return new VMMetrics((String) object); - } - - public static VTPM toVTPM(Object object) { - if (object == null) { - return null; - } - return new VTPM((String) object); - } - - public static Blob toBlob(Object object) { - if (object == null) { - return null; - } - return new Blob((String) object); - } - - public static Console toConsole(Object object) { - if (object == null) { - return null; - } - return new Console((String) object); - } - - public static Crashdump toCrashdump(Object object) { - if (object == null) { - return null; - } - return new Crashdump((String) object); - } - - public static Host toHost(Object object) { - if (object == null) { - return null; - } - return new Host((String) object); - } - - public static HostCpu toHostCpu(Object object) { - if (object == null) { - return null; - } - return new HostCpu((String) object); - } - - public static HostCrashdump toHostCrashdump(Object object) { - if (object == null) { - return null; - } - return new HostCrashdump((String) object); - } - - public static HostMetrics toHostMetrics(Object object) { - if (object == null) { - return null; - } - return new HostMetrics((String) object); - } - - public static HostPatch toHostPatch(Object object) { - if (object == null) { - return null; - } - return new HostPatch((String) object); - } - - public static Message toMessage(Object object) { - if (object == null) { - return null; - } - return new Message((String) object); - } - - public static Network toNetwork(Object object) { - if (object == null) { - return null; - } - return new Network((String) object); - } - - public static Pool toPool(Object object) { - if (object == null) { - return null; - } - return new Pool((String) object); - } - - public static PoolPatch toPoolPatch(Object object) { - if (object == null) { - return null; - } - return new PoolPatch((String) object); - } - - public static Role toRole(Object object) { - if (object == null) { - return null; - } - return new Role((String) object); - } - - public static Secret toSecret(Object object) { - if (object == null) { - return null; - } - return new Secret((String) object); - } - - public static Session toSession(Object object) { - if (object == null) { - return null; - } - return new Session((String) object); - } - - public static Subject toSubject(Object object) { - if (object == null) { - return null; - } - return new Subject((String) object); - } - - public static Task toTask(Object object) { - if (object == null) { - return null; - } - return new Task((String) object); - } - - public static Tunnel toTunnel(Object object) { - if (object == null) { - return null; - } - return new Tunnel((String) object); - } - - public static User toUser(Object object) { - if (object == null) { - return null; - } - return new User((String) object); - } - - public static Bond.Record toBondRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Bond.Record record = new Bond.Record(); - record.uuid = toString(map.get("uuid")); - record.master = toPIF(map.get("master")); - record.slaves = toSetOfPIF(map.get("slaves")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static PBD.Record toPBDRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - PBD.Record record = new PBD.Record(); - record.uuid = toString(map.get("uuid")); - record.host = toHost(map.get("host")); - record.SR = toSR(map.get("SR")); - record.deviceConfig = toMapOfStringString(map.get("device_config")); - record.currentlyAttached = toBoolean(map.get("currently_attached")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static PIF.Record toPIFRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - PIF.Record record = new PIF.Record(); - record.uuid = toString(map.get("uuid")); - record.device = toString(map.get("device")); - record.network = toNetwork(map.get("network")); - record.host = toHost(map.get("host")); - record.MAC = toString(map.get("MAC")); - record.MTU = toLong(map.get("MTU")); - record.VLAN = toLong(map.get("VLAN")); - record.metrics = toPIFMetrics(map.get("metrics")); - record.physical = toBoolean(map.get("physical")); - record.currentlyAttached = toBoolean(map.get("currently_attached")); - record.ipConfigurationMode = toIpConfigurationMode(map.get("ip_configuration_mode")); - record.IP = toString(map.get("IP")); - record.netmask = toString(map.get("netmask")); - record.gateway = toString(map.get("gateway")); - record.DNS = toString(map.get("DNS")); - record.bondSlaveOf = toBond(map.get("bond_slave_of")); - record.bondMasterOf = toSetOfBond(map.get("bond_master_of")); - record.VLANMasterOf = toVLAN(map.get("VLAN_master_of")); - record.VLANSlaveOf = toSetOfVLAN(map.get("VLAN_slave_of")); - record.management = toBoolean(map.get("management")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.disallowUnplug = toBoolean(map.get("disallow_unplug")); - record.tunnelAccessPIFOf = toSetOfTunnel(map.get("tunnel_access_PIF_of")); - record.tunnelTransportPIFOf = toSetOfTunnel(map.get("tunnel_transport_PIF_of")); - return record; - } - - public static PIFMetrics.Record toPIFMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - PIFMetrics.Record record = new PIFMetrics.Record(); - record.uuid = toString(map.get("uuid")); - record.ioReadKbs = toDouble(map.get("io_read_kbs")); - record.ioWriteKbs = toDouble(map.get("io_write_kbs")); - record.carrier = toBoolean(map.get("carrier")); - record.vendorId = toString(map.get("vendor_id")); - record.vendorName = toString(map.get("vendor_name")); - record.deviceId = toString(map.get("device_id")); - record.deviceName = toString(map.get("device_name")); - record.speed = toLong(map.get("speed")); - record.duplex = toBoolean(map.get("duplex")); - record.pciBusPath = toString(map.get("pci_bus_path")); - record.lastUpdated = toDate(map.get("last_updated")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static SM.Record toSMRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - SM.Record record = new SM.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.type = toString(map.get("type")); - record.vendor = toString(map.get("vendor")); - record.copyright = toString(map.get("copyright")); - record.version = toString(map.get("version")); - record.requiredApiVersion = toString(map.get("required_api_version")); - record.configuration = toMapOfStringString(map.get("configuration")); - record.capabilities = toSetOfString(map.get("capabilities")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.driverFilename = toString(map.get("driver_filename")); - return record; - } - - public static SR.Record toSRRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - SR.Record record = new SR.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.allowedOperations = toSetOfStorageOperations(map.get("allowed_operations")); - record.currentOperations = toMapOfStringStorageOperations(map.get("current_operations")); - record.VDIs = toSetOfVDI(map.get("VDIs")); - record.PBDs = toSetOfPBD(map.get("PBDs")); - record.virtualAllocation = toLong(map.get("virtual_allocation")); - record.physicalUtilisation = toLong(map.get("physical_utilisation")); - record.physicalSize = toLong(map.get("physical_size")); - record.type = toString(map.get("type")); - record.contentType = toString(map.get("content_type")); - record.shared = toBoolean(map.get("shared")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.tags = toSetOfString(map.get("tags")); - record.smConfig = toMapOfStringString(map.get("sm_config")); - record.blobs = toMapOfStringBlob(map.get("blobs")); - record.localCacheEnabled = toBoolean(map.get("local_cache_enabled")); - return record; - } - - public static VBD.Record toVBDRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VBD.Record record = new VBD.Record(); - record.uuid = toString(map.get("uuid")); - record.allowedOperations = toSetOfVbdOperations(map.get("allowed_operations")); - record.currentOperations = toMapOfStringVbdOperations(map.get("current_operations")); - record.VM = toVM(map.get("VM")); - record.VDI = toVDI(map.get("VDI")); - record.device = toString(map.get("device")); - record.userdevice = toString(map.get("userdevice")); - record.bootable = toBoolean(map.get("bootable")); - record.mode = toVbdMode(map.get("mode")); - record.type = toVbdType(map.get("type")); - record.unpluggable = toBoolean(map.get("unpluggable")); - record.storageLock = toBoolean(map.get("storage_lock")); - record.empty = toBoolean(map.get("empty")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.currentlyAttached = toBoolean(map.get("currently_attached")); - record.statusCode = toLong(map.get("status_code")); - record.statusDetail = toString(map.get("status_detail")); - record.runtimeProperties = toMapOfStringString(map.get("runtime_properties")); - record.qosAlgorithmType = toString(map.get("qos_algorithm_type")); - record.qosAlgorithmParams = toMapOfStringString(map.get("qos_algorithm_params")); - record.qosSupportedAlgorithms = toSetOfString(map.get("qos_supported_algorithms")); - record.metrics = toVBDMetrics(map.get("metrics")); - return record; - } - - public static VBDMetrics.Record toVBDMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VBDMetrics.Record record = new VBDMetrics.Record(); - record.uuid = toString(map.get("uuid")); - record.ioReadKbs = toDouble(map.get("io_read_kbs")); - record.ioWriteKbs = toDouble(map.get("io_write_kbs")); - record.lastUpdated = toDate(map.get("last_updated")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static VDI.Record toVDIRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VDI.Record record = new VDI.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.allowedOperations = toSetOfVdiOperations(map.get("allowed_operations")); - record.currentOperations = toMapOfStringVdiOperations(map.get("current_operations")); - record.SR = toSR(map.get("SR")); - record.VBDs = toSetOfVBD(map.get("VBDs")); - record.crashDumps = toSetOfCrashdump(map.get("crash_dumps")); - record.virtualSize = toLong(map.get("virtual_size")); - record.physicalUtilisation = toLong(map.get("physical_utilisation")); - record.type = toVdiType(map.get("type")); - record.sharable = toBoolean(map.get("sharable")); - record.readOnly = toBoolean(map.get("read_only")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.storageLock = toBoolean(map.get("storage_lock")); - record.location = toString(map.get("location")); - record.managed = toBoolean(map.get("managed")); - record.missing = toBoolean(map.get("missing")); - record.parent = toVDI(map.get("parent")); - record.xenstoreData = toMapOfStringString(map.get("xenstore_data")); - record.smConfig = toMapOfStringString(map.get("sm_config")); - record.isASnapshot = toBoolean(map.get("is_a_snapshot")); - record.snapshotOf = toVDI(map.get("snapshot_of")); - record.snapshots = toSetOfVDI(map.get("snapshots")); - record.snapshotTime = toDate(map.get("snapshot_time")); - record.tags = toSetOfString(map.get("tags")); - record.allowCaching = toBoolean(map.get("allow_caching")); - record.onBoot = toOnBoot(map.get("on_boot")); - return record; - } - - public static VIF.Record toVIFRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VIF.Record record = new VIF.Record(); - record.uuid = toString(map.get("uuid")); - record.allowedOperations = toSetOfVifOperations(map.get("allowed_operations")); - record.currentOperations = toMapOfStringVifOperations(map.get("current_operations")); - record.device = toString(map.get("device")); - record.network = toNetwork(map.get("network")); - record.VM = toVM(map.get("VM")); - record.MAC = toString(map.get("MAC")); - record.MTU = toLong(map.get("MTU")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.currentlyAttached = toBoolean(map.get("currently_attached")); - record.statusCode = toLong(map.get("status_code")); - record.statusDetail = toString(map.get("status_detail")); - record.runtimeProperties = toMapOfStringString(map.get("runtime_properties")); - record.qosAlgorithmType = toString(map.get("qos_algorithm_type")); - record.qosAlgorithmParams = toMapOfStringString(map.get("qos_algorithm_params")); - record.qosSupportedAlgorithms = toSetOfString(map.get("qos_supported_algorithms")); - record.metrics = toVIFMetrics(map.get("metrics")); - record.MACAutogenerated = toBoolean(map.get("MAC_autogenerated")); - return record; - } - - public static VIFMetrics.Record toVIFMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VIFMetrics.Record record = new VIFMetrics.Record(); - record.uuid = toString(map.get("uuid")); - record.ioReadKbs = toDouble(map.get("io_read_kbs")); - record.ioWriteKbs = toDouble(map.get("io_write_kbs")); - record.lastUpdated = toDate(map.get("last_updated")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static VLAN.Record toVLANRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VLAN.Record record = new VLAN.Record(); - record.uuid = toString(map.get("uuid")); - record.taggedPIF = toPIF(map.get("tagged_PIF")); - record.untaggedPIF = toPIF(map.get("untagged_PIF")); - record.tag = toLong(map.get("tag")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static VM.Record toVMRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VM.Record record = new VM.Record(); - record.uuid = toString(map.get("uuid")); - record.allowedOperations = toSetOfVmOperations(map.get("allowed_operations")); - record.currentOperations = toMapOfStringVmOperations(map.get("current_operations")); - record.powerState = toVmPowerState(map.get("power_state")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.userVersion = toLong(map.get("user_version")); - record.isATemplate = toBoolean(map.get("is_a_template")); - record.suspendVDI = toVDI(map.get("suspend_VDI")); - record.residentOn = toHost(map.get("resident_on")); - record.affinity = toHost(map.get("affinity")); - record.memoryOverhead = toLong(map.get("memory_overhead")); - record.memoryTarget = toLong(map.get("memory_target")); - record.memoryStaticMax = toLong(map.get("memory_static_max")); - record.memoryDynamicMax = toLong(map.get("memory_dynamic_max")); - record.memoryDynamicMin = toLong(map.get("memory_dynamic_min")); - record.memoryStaticMin = toLong(map.get("memory_static_min")); - record.VCPUsParams = toMapOfStringString(map.get("VCPUs_params")); - record.VCPUsMax = toLong(map.get("VCPUs_max")); - record.VCPUsAtStartup = toLong(map.get("VCPUs_at_startup")); - record.actionsAfterShutdown = toOnNormalExit(map.get("actions_after_shutdown")); - record.actionsAfterReboot = toOnNormalExit(map.get("actions_after_reboot")); - record.actionsAfterCrash = toOnCrashBehaviour(map.get("actions_after_crash")); - record.consoles = toSetOfConsole(map.get("consoles")); - record.VIFs = toSetOfVIF(map.get("VIFs")); - record.VBDs = toSetOfVBD(map.get("VBDs")); - record.crashDumps = toSetOfCrashdump(map.get("crash_dumps")); - record.VTPMs = toSetOfVTPM(map.get("VTPMs")); - record.PVBootloader = toString(map.get("PV_bootloader")); - record.PVKernel = toString(map.get("PV_kernel")); - record.PVRamdisk = toString(map.get("PV_ramdisk")); - record.PVArgs = toString(map.get("PV_args")); - record.PVBootloaderArgs = toString(map.get("PV_bootloader_args")); - record.PVLegacyArgs = toString(map.get("PV_legacy_args")); - record.HVMBootPolicy = toString(map.get("HVM_boot_policy")); - record.HVMBootParams = toMapOfStringString(map.get("HVM_boot_params")); - record.HVMShadowMultiplier = toDouble(map.get("HVM_shadow_multiplier")); - record.platform = toMapOfStringString(map.get("platform")); - record.PCIBus = toString(map.get("PCI_bus")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.domid = toLong(map.get("domid")); - record.domarch = toString(map.get("domarch")); - record.lastBootCPUFlags = toMapOfStringString(map.get("last_boot_CPU_flags")); - record.isControlDomain = toBoolean(map.get("is_control_domain")); - record.metrics = toVMMetrics(map.get("metrics")); - record.guestMetrics = toVMGuestMetrics(map.get("guest_metrics")); - record.lastBootedRecord = toString(map.get("last_booted_record")); - record.recommendations = toString(map.get("recommendations")); - record.xenstoreData = toMapOfStringString(map.get("xenstore_data")); - record.haAlwaysRun = toBoolean(map.get("ha_always_run")); - record.haRestartPriority = toString(map.get("ha_restart_priority")); - record.isASnapshot = toBoolean(map.get("is_a_snapshot")); - record.snapshotOf = toVM(map.get("snapshot_of")); - record.snapshots = toSetOfVM(map.get("snapshots")); - record.snapshotTime = toDate(map.get("snapshot_time")); - record.transportableSnapshotId = toString(map.get("transportable_snapshot_id")); - record.blobs = toMapOfStringBlob(map.get("blobs")); - record.tags = toSetOfString(map.get("tags")); - record.blockedOperations = toMapOfVmOperationsString(map.get("blocked_operations")); - record.snapshotInfo = toMapOfStringString(map.get("snapshot_info")); - record.snapshotMetadata = toString(map.get("snapshot_metadata")); - record.parent = toVM(map.get("parent")); - record.children = toSetOfVM(map.get("children")); - record.biosStrings = toMapOfStringString(map.get("bios_strings")); - record.protectionPolicy = toVMPP(map.get("protection_policy")); - record.isSnapshotFromVmpp = toBoolean(map.get("is_snapshot_from_vmpp")); - return record; - } - - public static VMPP.Record toVMPPRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VMPP.Record record = new VMPP.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.isPolicyEnabled = toBoolean(map.get("is_policy_enabled")); - record.backupType = toVmppBackupType(map.get("backup_type")); - record.backupRetentionValue = toLong(map.get("backup_retention_value")); - record.backupFrequency = toVmppBackupFrequency(map.get("backup_frequency")); - record.backupSchedule = toMapOfStringString(map.get("backup_schedule")); - record.isBackupRunning = toBoolean(map.get("is_backup_running")); - record.backupLastRunTime = toDate(map.get("backup_last_run_time")); - record.archiveTargetType = toVmppArchiveTargetType(map.get("archive_target_type")); - record.archiveTargetConfig = toMapOfStringString(map.get("archive_target_config")); - record.archiveFrequency = toVmppArchiveFrequency(map.get("archive_frequency")); - record.archiveSchedule = toMapOfStringString(map.get("archive_schedule")); - record.isArchiveRunning = toBoolean(map.get("is_archive_running")); - record.archiveLastRunTime = toDate(map.get("archive_last_run_time")); - record.VMs = toSetOfVM(map.get("VMs")); - record.isAlarmEnabled = toBoolean(map.get("is_alarm_enabled")); - record.alarmConfig = toMapOfStringString(map.get("alarm_config")); - record.recentAlerts = toSetOfString(map.get("recent_alerts")); - return record; - } - - public static VMGuestMetrics.Record toVMGuestMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VMGuestMetrics.Record record = new VMGuestMetrics.Record(); - record.uuid = toString(map.get("uuid")); - record.osVersion = toMapOfStringString(map.get("os_version")); - record.PVDriversVersion = toMapOfStringString(map.get("PV_drivers_version")); - record.PVDriversUpToDate = toBoolean(map.get("PV_drivers_up_to_date")); - record.memory = toMapOfStringString(map.get("memory")); - record.disks = toMapOfStringString(map.get("disks")); - record.networks = toMapOfStringString(map.get("networks")); - record.other = toMapOfStringString(map.get("other")); - record.lastUpdated = toDate(map.get("last_updated")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.live = toBoolean(map.get("live")); - return record; - } - - public static VMMetrics.Record toVMMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VMMetrics.Record record = new VMMetrics.Record(); - record.uuid = toString(map.get("uuid")); - record.memoryActual = toLong(map.get("memory_actual")); - record.VCPUsNumber = toLong(map.get("VCPUs_number")); - record.VCPUsUtilisation = toMapOfLongDouble(map.get("VCPUs_utilisation")); - record.VCPUsCPU = toMapOfLongLong(map.get("VCPUs_CPU")); - record.VCPUsParams = toMapOfStringString(map.get("VCPUs_params")); - record.VCPUsFlags = toMapOfLongSetOfString(map.get("VCPUs_flags")); - record.state = toSetOfString(map.get("state")); - record.startTime = toDate(map.get("start_time")); - record.installTime = toDate(map.get("install_time")); - record.lastUpdated = toDate(map.get("last_updated")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static VTPM.Record toVTPMRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - VTPM.Record record = new VTPM.Record(); - record.uuid = toString(map.get("uuid")); - record.VM = toVM(map.get("VM")); - record.backend = toVM(map.get("backend")); - return record; - } - - public static Blob.Record toBlobRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Blob.Record record = new Blob.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.size = toLong(map.get("size")); - record.lastUpdated = toDate(map.get("last_updated")); - record.mimeType = toString(map.get("mime_type")); - return record; - } - - public static Console.Record toConsoleRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Console.Record record = new Console.Record(); - record.uuid = toString(map.get("uuid")); - record.protocol = toConsoleProtocol(map.get("protocol")); - record.location = toString(map.get("location")); - record.VM = toVM(map.get("VM")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static Crashdump.Record toCrashdumpRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Crashdump.Record record = new Crashdump.Record(); - record.uuid = toString(map.get("uuid")); - record.VM = toVM(map.get("VM")); - record.VDI = toVDI(map.get("VDI")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static DataSource.Record toDataSourceRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - DataSource.Record record = new DataSource.Record(); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.enabled = toBoolean(map.get("enabled")); - record.standard = toBoolean(map.get("standard")); - record.units = toString(map.get("units")); - record.min = toDouble(map.get("min")); - record.max = toDouble(map.get("max")); - record.value = toDouble(map.get("value")); - return record; - } - - public static Event.Record toEventRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Event.Record record = new Event.Record(); - record.id = toLong(map.get("id")); - record.timestamp = toDate(map.get("timestamp")); - record.clazz = toString(map.get("class")); - record.operation = toEventOperation(map.get("operation")); - record.ref = toString(map.get("ref")); - record.objUuid = toString(map.get("obj_uuid")); - - - Object a,b; - a=map.get("snapshot"); - switch(toXenAPIObjects(record.clazz)) - { - case SESSION: b = toSessionRecord(a); break; - case SUBJECT: b = toSubjectRecord(a); break; - case ROLE: b = toRoleRecord(a); break; - case TASK: b = toTaskRecord(a); break; - case EVENT: b = toEventRecord(a); break; - case POOL: b = toPoolRecord(a); break; - case POOL_PATCH: b = toPoolPatchRecord(a); break; - case VM: b = toVMRecord(a); break; - case VM_METRICS: b = toVMMetricsRecord(a); break; - case VM_GUEST_METRICS: b = toVMGuestMetricsRecord(a); break; - case VMPP: b = toVMPPRecord(a); break; - case HOST: b = toHostRecord(a); break; - case HOST_CRASHDUMP: b = toHostCrashdumpRecord(a); break; - case HOST_PATCH: b = toHostPatchRecord(a); break; - case HOST_METRICS: b = toHostMetricsRecord(a); break; - case HOST_CPU: b = toHostCpuRecord(a); break; - case NETWORK: b = toNetworkRecord(a); break; - case VIF: b = toVIFRecord(a); break; - case VIF_METRICS: b = toVIFMetricsRecord(a); break; - case PIF: b = toPIFRecord(a); break; - case PIF_METRICS: b = toPIFMetricsRecord(a); break; - case BOND: b = toBondRecord(a); break; - case VLAN: b = toVLANRecord(a); break; - case SM: b = toSMRecord(a); break; - case SR: b = toSRRecord(a); break; - case VDI: b = toVDIRecord(a); break; - case VBD: b = toVBDRecord(a); break; - case VBD_METRICS: b = toVBDMetricsRecord(a); break; - case PBD: b = toPBDRecord(a); break; - case CRASHDUMP: b = toCrashdumpRecord(a); break; - case VTPM: b = toVTPMRecord(a); break; - case CONSOLE: b = toConsoleRecord(a); break; - case USER: b = toUserRecord(a); break; - case DATA_SOURCE: b = toDataSourceRecord(a); break; - case BLOB: b = toBlobRecord(a); break; - case MESSAGE: b = toMessageRecord(a); break; - case SECRET: b = toSecretRecord(a); break; - case TUNNEL: b = toTunnelRecord(a); break; - default: throw new RuntimeException("Internal error in auto-generated code whilst unmarshalling event snapshot"); - } - record.snapshot = b; - return record; - } - - public static Host.Record toHostRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Host.Record record = new Host.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.memoryOverhead = toLong(map.get("memory_overhead")); - record.allowedOperations = toSetOfHostAllowedOperations(map.get("allowed_operations")); - record.currentOperations = toMapOfStringHostAllowedOperations(map.get("current_operations")); - record.APIVersionMajor = toLong(map.get("API_version_major")); - record.APIVersionMinor = toLong(map.get("API_version_minor")); - record.APIVersionVendor = toString(map.get("API_version_vendor")); - record.APIVersionVendorImplementation = toMapOfStringString(map.get("API_version_vendor_implementation")); - record.enabled = toBoolean(map.get("enabled")); - record.softwareVersion = toMapOfStringString(map.get("software_version")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.capabilities = toSetOfString(map.get("capabilities")); - record.cpuConfiguration = toMapOfStringString(map.get("cpu_configuration")); - record.schedPolicy = toString(map.get("sched_policy")); - record.supportedBootloaders = toSetOfString(map.get("supported_bootloaders")); - record.residentVMs = toSetOfVM(map.get("resident_VMs")); - record.logging = toMapOfStringString(map.get("logging")); - record.PIFs = toSetOfPIF(map.get("PIFs")); - record.suspendImageSr = toSR(map.get("suspend_image_sr")); - record.crashDumpSr = toSR(map.get("crash_dump_sr")); - record.crashdumps = toSetOfHostCrashdump(map.get("crashdumps")); - record.patches = toSetOfHostPatch(map.get("patches")); - record.PBDs = toSetOfPBD(map.get("PBDs")); - record.hostCPUs = toSetOfHostCpu(map.get("host_CPUs")); - record.cpuInfo = toMapOfStringString(map.get("cpu_info")); - record.hostname = toString(map.get("hostname")); - record.address = toString(map.get("address")); - record.metrics = toHostMetrics(map.get("metrics")); - record.licenseParams = toMapOfStringString(map.get("license_params")); - record.haStatefiles = toSetOfString(map.get("ha_statefiles")); - record.haNetworkPeers = toSetOfString(map.get("ha_network_peers")); - record.blobs = toMapOfStringBlob(map.get("blobs")); - record.tags = toSetOfString(map.get("tags")); - record.externalAuthType = toString(map.get("external_auth_type")); - record.externalAuthServiceName = toString(map.get("external_auth_service_name")); - record.externalAuthConfiguration = toMapOfStringString(map.get("external_auth_configuration")); - record.edition = toString(map.get("edition")); - record.licenseServer = toMapOfStringString(map.get("license_server")); - record.biosStrings = toMapOfStringString(map.get("bios_strings")); - record.powerOnMode = toString(map.get("power_on_mode")); - record.powerOnConfig = toMapOfStringString(map.get("power_on_config")); - record.localCacheSr = toSR(map.get("local_cache_sr")); - return record; - } - - public static HostCpu.Record toHostCpuRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - HostCpu.Record record = new HostCpu.Record(); - record.uuid = toString(map.get("uuid")); - record.host = toHost(map.get("host")); - record.number = toLong(map.get("number")); - record.vendor = toString(map.get("vendor")); - record.speed = toLong(map.get("speed")); - record.modelname = toString(map.get("modelname")); - record.family = toLong(map.get("family")); - record.model = toLong(map.get("model")); - record.stepping = toString(map.get("stepping")); - record.flags = toString(map.get("flags")); - record.features = toString(map.get("features")); - record.utilisation = toDouble(map.get("utilisation")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static HostCrashdump.Record toHostCrashdumpRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - HostCrashdump.Record record = new HostCrashdump.Record(); - record.uuid = toString(map.get("uuid")); - record.host = toHost(map.get("host")); - record.timestamp = toDate(map.get("timestamp")); - record.size = toLong(map.get("size")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static HostMetrics.Record toHostMetricsRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - HostMetrics.Record record = new HostMetrics.Record(); - record.uuid = toString(map.get("uuid")); - record.memoryTotal = toLong(map.get("memory_total")); - record.memoryFree = toLong(map.get("memory_free")); - record.live = toBoolean(map.get("live")); - record.lastUpdated = toDate(map.get("last_updated")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static HostPatch.Record toHostPatchRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - HostPatch.Record record = new HostPatch.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.version = toString(map.get("version")); - record.host = toHost(map.get("host")); - record.applied = toBoolean(map.get("applied")); - record.timestampApplied = toDate(map.get("timestamp_applied")); - record.size = toLong(map.get("size")); - record.poolPatch = toPoolPatch(map.get("pool_patch")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static Message.Record toMessageRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Message.Record record = new Message.Record(); - record.uuid = toString(map.get("uuid")); - record.name = toString(map.get("name")); - record.priority = toLong(map.get("priority")); - record.cls = toCls(map.get("cls")); - record.objUuid = toString(map.get("obj_uuid")); - record.timestamp = toDate(map.get("timestamp")); - record.body = toString(map.get("body")); - return record; - } - - public static Network.Record toNetworkRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Network.Record record = new Network.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.allowedOperations = toSetOfNetworkOperations(map.get("allowed_operations")); - record.currentOperations = toMapOfStringNetworkOperations(map.get("current_operations")); - record.VIFs = toSetOfVIF(map.get("VIFs")); - record.PIFs = toSetOfPIF(map.get("PIFs")); - record.MTU = toLong(map.get("MTU")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.bridge = toString(map.get("bridge")); - record.blobs = toMapOfStringBlob(map.get("blobs")); - record.tags = toSetOfString(map.get("tags")); - return record; - } - - public static Pool.Record toPoolRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Pool.Record record = new Pool.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.master = toHost(map.get("master")); - record.defaultSR = toSR(map.get("default_SR")); - record.suspendImageSR = toSR(map.get("suspend_image_SR")); - record.crashDumpSR = toSR(map.get("crash_dump_SR")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.haEnabled = toBoolean(map.get("ha_enabled")); - record.haConfiguration = toMapOfStringString(map.get("ha_configuration")); - record.haStatefiles = toSetOfString(map.get("ha_statefiles")); - record.haHostFailuresToTolerate = toLong(map.get("ha_host_failures_to_tolerate")); - record.haPlanExistsFor = toLong(map.get("ha_plan_exists_for")); - record.haAllowOvercommit = toBoolean(map.get("ha_allow_overcommit")); - record.haOvercommitted = toBoolean(map.get("ha_overcommitted")); - record.blobs = toMapOfStringBlob(map.get("blobs")); - record.tags = toSetOfString(map.get("tags")); - record.guiConfig = toMapOfStringString(map.get("gui_config")); - record.wlbUrl = toString(map.get("wlb_url")); - record.wlbUsername = toString(map.get("wlb_username")); - record.wlbEnabled = toBoolean(map.get("wlb_enabled")); - record.wlbVerifyCert = toBoolean(map.get("wlb_verify_cert")); - record.redoLogEnabled = toBoolean(map.get("redo_log_enabled")); - record.redoLogVdi = toVDI(map.get("redo_log_vdi")); - record.vswitchController = toString(map.get("vswitch_controller")); - record.restrictions = toMapOfStringString(map.get("restrictions")); - return record; - } - - public static PoolPatch.Record toPoolPatchRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - PoolPatch.Record record = new PoolPatch.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.version = toString(map.get("version")); - record.size = toLong(map.get("size")); - record.poolApplied = toBoolean(map.get("pool_applied")); - record.hostPatches = toSetOfHostPatch(map.get("host_patches")); - record.afterApplyGuidance = toSetOfAfterApplyGuidance(map.get("after_apply_guidance")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static Role.Record toRoleRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Role.Record record = new Role.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.subroles = toSetOfRole(map.get("subroles")); - return record; - } - - public static Secret.Record toSecretRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Secret.Record record = new Secret.Record(); - record.uuid = toString(map.get("uuid")); - record.value = toString(map.get("value")); - return record; - } - - public static Session.Record toSessionRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Session.Record record = new Session.Record(); - record.uuid = toString(map.get("uuid")); - record.thisHost = toHost(map.get("this_host")); - record.thisUser = toUser(map.get("this_user")); - record.lastActive = toDate(map.get("last_active")); - record.pool = toBoolean(map.get("pool")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.isLocalSuperuser = toBoolean(map.get("is_local_superuser")); - record.subject = toSubject(map.get("subject")); - record.validationTime = toDate(map.get("validation_time")); - record.authUserSid = toString(map.get("auth_user_sid")); - record.authUserName = toString(map.get("auth_user_name")); - record.rbacPermissions = toSetOfString(map.get("rbac_permissions")); - record.tasks = toSetOfTask(map.get("tasks")); - record.parent = toSession(map.get("parent")); - return record; - } - - public static Subject.Record toSubjectRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Subject.Record record = new Subject.Record(); - record.uuid = toString(map.get("uuid")); - record.subjectIdentifier = toString(map.get("subject_identifier")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.roles = toSetOfRole(map.get("roles")); - return record; - } - - public static Task.Record toTaskRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Task.Record record = new Task.Record(); - record.uuid = toString(map.get("uuid")); - record.nameLabel = toString(map.get("name_label")); - record.nameDescription = toString(map.get("name_description")); - record.allowedOperations = toSetOfTaskAllowedOperations(map.get("allowed_operations")); - record.currentOperations = toMapOfStringTaskAllowedOperations(map.get("current_operations")); - record.created = toDate(map.get("created")); - record.finished = toDate(map.get("finished")); - record.status = toTaskStatusType(map.get("status")); - record.residentOn = toHost(map.get("resident_on")); - record.progress = toDouble(map.get("progress")); - record.type = toString(map.get("type")); - record.result = toString(map.get("result")); - record.errorInfo = toSetOfString(map.get("error_info")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - record.subtaskOf = toTask(map.get("subtask_of")); - record.subtasks = toSetOfTask(map.get("subtasks")); - return record; - } - - public static Tunnel.Record toTunnelRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - Tunnel.Record record = new Tunnel.Record(); - record.uuid = toString(map.get("uuid")); - record.accessPIF = toPIF(map.get("access_PIF")); - record.transportPIF = toPIF(map.get("transport_PIF")); - record.status = toMapOfStringString(map.get("status")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - public static User.Record toUserRecord(Object object) { - if (object == null) { - return null; - } - Map map = (Map) object; - User.Record record = new User.Record(); - record.uuid = toString(map.get("uuid")); - record.shortName = toString(map.get("short_name")); - record.fullname = toString(map.get("fullname")); - record.otherConfig = toMapOfStringString(map.get("other_config")); - return record; - } - - - public static Bond toBond(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toBond(parseResult(task.getResult(connection))); - } - - public static PBD toPBD(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toPBD(parseResult(task.getResult(connection))); - } - - public static PIF toPIF(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toPIF(parseResult(task.getResult(connection))); - } - - public static PIFMetrics toPIFMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toPIFMetrics(parseResult(task.getResult(connection))); - } - - public static SM toSM(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toSM(parseResult(task.getResult(connection))); - } - - public static SR toSR(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toSR(parseResult(task.getResult(connection))); - } - - public static VBD toVBD(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVBD(parseResult(task.getResult(connection))); - } - - public static VBDMetrics toVBDMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVBDMetrics(parseResult(task.getResult(connection))); - } - - public static VDI toVDI(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVDI(parseResult(task.getResult(connection))); - } - - public static VIF toVIF(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVIF(parseResult(task.getResult(connection))); - } - - public static VIFMetrics toVIFMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVIFMetrics(parseResult(task.getResult(connection))); - } - - public static VLAN toVLAN(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVLAN(parseResult(task.getResult(connection))); - } - - public static VM toVM(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVM(parseResult(task.getResult(connection))); - } - - public static VMPP toVMPP(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVMPP(parseResult(task.getResult(connection))); - } - - public static VMGuestMetrics toVMGuestMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVMGuestMetrics(parseResult(task.getResult(connection))); - } - - public static VMMetrics toVMMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVMMetrics(parseResult(task.getResult(connection))); - } - - public static VTPM toVTPM(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toVTPM(parseResult(task.getResult(connection))); - } - - public static Blob toBlob(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toBlob(parseResult(task.getResult(connection))); - } - - public static Console toConsole(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toConsole(parseResult(task.getResult(connection))); - } - - public static Crashdump toCrashdump(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toCrashdump(parseResult(task.getResult(connection))); - } - - public static Host toHost(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toHost(parseResult(task.getResult(connection))); - } - - public static HostCpu toHostCpu(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toHostCpu(parseResult(task.getResult(connection))); - } - - public static HostCrashdump toHostCrashdump(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toHostCrashdump(parseResult(task.getResult(connection))); - } - - public static HostMetrics toHostMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toHostMetrics(parseResult(task.getResult(connection))); - } - - public static HostPatch toHostPatch(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toHostPatch(parseResult(task.getResult(connection))); - } - - public static Message toMessage(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toMessage(parseResult(task.getResult(connection))); - } - - public static Network toNetwork(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toNetwork(parseResult(task.getResult(connection))); - } - - public static Pool toPool(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toPool(parseResult(task.getResult(connection))); - } - - public static PoolPatch toPoolPatch(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toPoolPatch(parseResult(task.getResult(connection))); - } - - public static Role toRole(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toRole(parseResult(task.getResult(connection))); - } - - public static Secret toSecret(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toSecret(parseResult(task.getResult(connection))); - } - - public static Session toSession(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toSession(parseResult(task.getResult(connection))); - } - - public static Subject toSubject(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toSubject(parseResult(task.getResult(connection))); - } - - public static Task toTask(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toTask(parseResult(task.getResult(connection))); - } - - public static Tunnel toTunnel(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toTunnel(parseResult(task.getResult(connection))); - } - - public static User toUser(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ - return Types.toUser(parseResult(task.getResult(connection))); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/User.java b/deps/XenServerJava/src/com/xensource/xenapi/User.java deleted file mode 100644 index 9cf239d60ee..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/User.java +++ /dev/null @@ -1,379 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A user of the system - * - * @author Citrix Systems, Inc. - */ -public class User extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - User(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a User, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof User) - { - User other = (User) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a User - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "shortName", this.shortName); - print.printf("%1$20s: %2$s\n", "fullname", this.fullname); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a user.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("short_name", this.shortName == null ? "" : this.shortName); - map.put("fullname", this.fullname == null ? "" : this.fullname); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * short name (e.g. userid) - */ - public String shortName; - /** - * full name - */ - public String fullname; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given user. - * @deprecated - * - * @return all fields from the object - */ - @Deprecated public User.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toUserRecord(result); - } - - /** - * Get a reference to the user instance with the specified UUID. - * @deprecated - * - * @param uuid UUID of object to return - * @return reference to the object - */ - @Deprecated public static User getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toUser(result); - } - - /** - * Create a new user instance, and return its handle. - * @deprecated - * - * @param record All constructor arguments - * @return Task - */ - @Deprecated public static Task createAsync(Connection c, User.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.user.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new user instance, and return its handle. - * @deprecated - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - @Deprecated public static User create(Connection c, User.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toUser(result); - } - - /** - * Destroy the specified user instance. - * @deprecated - * - * @return Task - */ - @Deprecated public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.user.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified user instance. - * @deprecated - * - */ - @Deprecated public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the uuid field of the given user. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the short_name field of the given user. - * - * @return value of the field - */ - public String getShortName(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.get_short_name"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the fullname field of the given user. - * - * @return value of the field - */ - public String getFullname(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.get_fullname"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the other_config field of the given user. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the fullname field of the given user. - * - * @param fullname New value to set - */ - public void setFullname(Connection c, String fullname) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.set_fullname"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(fullname)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given user. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given user. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given user. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "user.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VBD.java b/deps/XenServerJava/src/com/xensource/xenapi/VBD.java deleted file mode 100644 index cb793398ee3..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VBD.java +++ /dev/null @@ -1,1156 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A virtual block device - * - * @author Citrix Systems, Inc. - */ -public class VBD extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VBD(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VBD, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VBD) - { - VBD other = (VBD) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VBD - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); - print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); - print.printf("%1$20s: %2$s\n", "VM", this.VM); - print.printf("%1$20s: %2$s\n", "VDI", this.VDI); - print.printf("%1$20s: %2$s\n", "device", this.device); - print.printf("%1$20s: %2$s\n", "userdevice", this.userdevice); - print.printf("%1$20s: %2$s\n", "bootable", this.bootable); - print.printf("%1$20s: %2$s\n", "mode", this.mode); - print.printf("%1$20s: %2$s\n", "type", this.type); - print.printf("%1$20s: %2$s\n", "unpluggable", this.unpluggable); - print.printf("%1$20s: %2$s\n", "storageLock", this.storageLock); - print.printf("%1$20s: %2$s\n", "empty", this.empty); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); - print.printf("%1$20s: %2$s\n", "statusCode", this.statusCode); - print.printf("%1$20s: %2$s\n", "statusDetail", this.statusDetail); - print.printf("%1$20s: %2$s\n", "runtimeProperties", this.runtimeProperties); - print.printf("%1$20s: %2$s\n", "qosAlgorithmType", this.qosAlgorithmType); - print.printf("%1$20s: %2$s\n", "qosAlgorithmParams", this.qosAlgorithmParams); - print.printf("%1$20s: %2$s\n", "qosSupportedAlgorithms", this.qosSupportedAlgorithms); - print.printf("%1$20s: %2$s\n", "metrics", this.metrics); - return writer.toString(); - } - - /** - * Convert a VBD.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); - map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); - map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); - map.put("VDI", this.VDI == null ? new VDI("OpaqueRef:NULL") : this.VDI); - map.put("device", this.device == null ? "" : this.device); - map.put("userdevice", this.userdevice == null ? "" : this.userdevice); - map.put("bootable", this.bootable == null ? false : this.bootable); - map.put("mode", this.mode == null ? Types.VbdMode.UNRECOGNIZED : this.mode); - map.put("type", this.type == null ? Types.VbdType.UNRECOGNIZED : this.type); - map.put("unpluggable", this.unpluggable == null ? false : this.unpluggable); - map.put("storage_lock", this.storageLock == null ? false : this.storageLock); - map.put("empty", this.empty == null ? false : this.empty); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); - map.put("status_code", this.statusCode == null ? 0 : this.statusCode); - map.put("status_detail", this.statusDetail == null ? "" : this.statusDetail); - map.put("runtime_properties", this.runtimeProperties == null ? new HashMap() : this.runtimeProperties); - map.put("qos_algorithm_type", this.qosAlgorithmType == null ? "" : this.qosAlgorithmType); - map.put("qos_algorithm_params", this.qosAlgorithmParams == null ? new HashMap() : this.qosAlgorithmParams); - map.put("qos_supported_algorithms", this.qosSupportedAlgorithms == null ? new LinkedHashSet() : this.qosSupportedAlgorithms); - map.put("metrics", this.metrics == null ? new VBDMetrics("OpaqueRef:NULL") : this.metrics); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. - */ - public Set allowedOperations; - /** - * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. - */ - public Map currentOperations; - /** - * the virtual machine - */ - public VM VM; - /** - * the virtual disk - */ - public VDI VDI; - /** - * device seen by the guest e.g. hda1 - */ - public String device; - /** - * user-friendly device name e.g. 0,1,2,etc. - */ - public String userdevice; - /** - * true if this VBD is bootable - */ - public Boolean bootable; - /** - * the mode the VBD should be mounted with - */ - public Types.VbdMode mode; - /** - * how the VBD will appear to the guest (e.g. disk or CD) - */ - public Types.VbdType type; - /** - * true if this VBD will support hot-unplug - */ - public Boolean unpluggable; - /** - * true if a storage level lock was acquired - */ - public Boolean storageLock; - /** - * if true this represents an empty drive - */ - public Boolean empty; - /** - * additional configuration - */ - public Map otherConfig; - /** - * is the device currently attached (erased on reboot) - */ - public Boolean currentlyAttached; - /** - * error/success code associated with last attach-operation (erased on reboot) - */ - public Long statusCode; - /** - * error/success information associated with last attach-operation status (erased on reboot) - */ - public String statusDetail; - /** - * Device runtime properties - */ - public Map runtimeProperties; - /** - * QoS algorithm to use - */ - public String qosAlgorithmType; - /** - * parameters for chosen QoS algorithm - */ - public Map qosAlgorithmParams; - /** - * supported QoS algorithms for this VBD - */ - public Set qosSupportedAlgorithms; - /** - * metrics associated with this VBD - */ - public VBDMetrics metrics; - } - - /** - * Get a record containing the current state of the given VBD. - * - * @return all fields from the object - */ - public VBD.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVBDRecord(result); - } - - /** - * Get a reference to the VBD instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VBD getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVBD(result); - } - - /** - * Create a new VBD instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, VBD.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VBD.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new VBD instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static VBD create(Connection c, VBD.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVBD(result); - } - - /** - * Destroy the specified VBD instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VBD.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified VBD instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the uuid field of the given VBD. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the allowed_operations field of the given VBD. - * - * @return value of the field - */ - public Set getAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVbdOperations(result); - } - - /** - * Get the current_operations field of the given VBD. - * - * @return value of the field - */ - public Map getCurrentOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_current_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringVbdOperations(result); - } - - /** - * Get the VM field of the given VBD. - * - * @return value of the field - */ - public VM getVM(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_VM"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Get the VDI field of the given VBD. - * - * @return value of the field - */ - public VDI getVDI(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_VDI"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Get the device field of the given VBD. - * - * @return value of the field - */ - public String getDevice(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_device"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the userdevice field of the given VBD. - * - * @return value of the field - */ - public String getUserdevice(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_userdevice"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the bootable field of the given VBD. - * - * @return value of the field - */ - public Boolean getBootable(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_bootable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the mode field of the given VBD. - * - * @return value of the field - */ - public Types.VbdMode getMode(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_mode"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVbdMode(result); - } - - /** - * Get the type field of the given VBD. - * - * @return value of the field - */ - public Types.VbdType getType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVbdType(result); - } - - /** - * Get the unpluggable field of the given VBD. - * - * @return value of the field - */ - public Boolean getUnpluggable(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_unpluggable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the storage_lock field of the given VBD. - * - * @return value of the field - */ - public Boolean getStorageLock(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_storage_lock"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the empty field of the given VBD. - * - * @return value of the field - */ - public Boolean getEmpty(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_empty"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the other_config field of the given VBD. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the currently_attached field of the given VBD. - * - * @return value of the field - */ - public Boolean getCurrentlyAttached(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_currently_attached"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the status_code field of the given VBD. - * - * @return value of the field - */ - public Long getStatusCode(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_status_code"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the status_detail field of the given VBD. - * - * @return value of the field - */ - public String getStatusDetail(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_status_detail"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the runtime_properties field of the given VBD. - * - * @return value of the field - */ - public Map getRuntimeProperties(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_runtime_properties"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the qos/algorithm_type field of the given VBD. - * - * @return value of the field - */ - public String getQosAlgorithmType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_qos_algorithm_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the qos/algorithm_params field of the given VBD. - * - * @return value of the field - */ - public Map getQosAlgorithmParams(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_qos_algorithm_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the qos/supported_algorithms field of the given VBD. - * - * @return value of the field - */ - public Set getQosSupportedAlgorithms(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_qos_supported_algorithms"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the metrics field of the given VBD. - * - * @return value of the field - */ - public VBDMetrics getMetrics(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_metrics"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVBDMetrics(result); - } - - /** - * Set the userdevice field of the given VBD. - * - * @param userdevice New value to set - */ - public void setUserdevice(Connection c, String userdevice) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.set_userdevice"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(userdevice)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the bootable field of the given VBD. - * - * @param bootable New value to set - */ - public void setBootable(Connection c, Boolean bootable) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.set_bootable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootable)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the mode field of the given VBD. - * - * @param mode New value to set - */ - public void setMode(Connection c, Types.VbdMode mode) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.set_mode"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(mode)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the type field of the given VBD. - * - * @param type New value to set - */ - public void setType(Connection c, Types.VbdType type) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.set_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(type)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the unpluggable field of the given VBD. - * - * @param unpluggable New value to set - */ - public void setUnpluggable(Connection c, Boolean unpluggable) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.set_unpluggable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(unpluggable)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given VBD. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VBD. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VBD. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the qos/algorithm_type field of the given VBD. - * - * @param algorithmType New value to set - */ - public void setQosAlgorithmType(Connection c, String algorithmType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.set_qos_algorithm_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(algorithmType)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the qos/algorithm_params field of the given VBD. - * - * @param algorithmParams New value to set - */ - public void setQosAlgorithmParams(Connection c, Map algorithmParams) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.set_qos_algorithm_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(algorithmParams)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the qos/algorithm_params field of the given VBD. - * - * @param key Key to add - * @param value Value to add - */ - public void addToQosAlgorithmParams(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.add_to_qos_algorithm_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the qos/algorithm_params field of the given VBD. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromQosAlgorithmParams(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.remove_from_qos_algorithm_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the media from the device and leave it empty - * - * @return Task - */ - public Task ejectAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VbdNotRemovableMedia, - Types.VbdIsEmpty { - String method_call = "Async.VBD.eject"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Remove the media from the device and leave it empty - * - */ - public void eject(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VbdNotRemovableMedia, - Types.VbdIsEmpty { - String method_call = "VBD.eject"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Insert new media into the device - * - * @param vdi The new VDI to 'insert' - * @return Task - */ - public Task insertAsync(Connection c, VDI vdi) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VbdNotRemovableMedia, - Types.VbdNotEmpty { - String method_call = "Async.VBD.insert"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(vdi)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Insert new media into the device - * - * @param vdi The new VDI to 'insert' - */ - public void insert(Connection c, VDI vdi) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VbdNotRemovableMedia, - Types.VbdNotEmpty { - String method_call = "VBD.insert"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(vdi)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Hotplug the specified VBD, dynamically attaching it to the running VM - * - * @return Task - */ - public Task plugAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VBD.plug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Hotplug the specified VBD, dynamically attaching it to the running VM - * - */ - public void plug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.plug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Hot-unplug the specified VBD, dynamically unattaching it from the running VM - * - * @return Task - */ - public Task unplugAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.DeviceDetachRejected, - Types.DeviceAlreadyDetached { - String method_call = "Async.VBD.unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Hot-unplug the specified VBD, dynamically unattaching it from the running VM - * - */ - public void unplug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.DeviceDetachRejected, - Types.DeviceAlreadyDetached { - String method_call = "VBD.unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Forcibly unplug the specified VBD - * - * @return Task - */ - public Task unplugForceAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VBD.unplug_force"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Forcibly unplug the specified VBD - * - */ - public void unplugForce(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.unplug_force"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Throws an error if this VBD could not be attached to this VM if the VM were running. Intended for debugging. - * - * @return Task - */ - public Task assertAttachableAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VBD.assert_attachable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Throws an error if this VBD could not be attached to this VM if the VM were running. Intended for debugging. - * - */ - public void assertAttachable(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.assert_attachable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VBDs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVBD(result); - } - - /** - * Return a map of VBD references to VBD records for all VBDs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVBDVBDRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java deleted file mode 100644 index 59928e9bd59..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java +++ /dev/null @@ -1,344 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * The metrics associated with a virtual block device - * - * @author Citrix Systems, Inc. - */ -public class VBDMetrics extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VBDMetrics(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VBDMetrics, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VBDMetrics) - { - VBDMetrics other = (VBDMetrics) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VBDMetrics - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs); - print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs); - print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a VBD_metrics.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs); - map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs); - map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * Read bandwidth (KiB/s) - */ - public Double ioReadKbs; - /** - * Write bandwidth (KiB/s) - */ - public Double ioWriteKbs; - /** - * Time at which this information was last updated - */ - public Date lastUpdated; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given VBD_metrics. - * - * @return all fields from the object - */ - public VBDMetrics.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVBDMetricsRecord(result); - } - - /** - * Get a reference to the VBD_metrics instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VBDMetrics getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVBDMetrics(result); - } - - /** - * Get the uuid field of the given VBD_metrics. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the io/read_kbs field of the given VBD_metrics. - * - * @return value of the field - */ - public Double getIoReadKbs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_io_read_kbs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the io/write_kbs field of the given VBD_metrics. - * - * @return value of the field - */ - public Double getIoWriteKbs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_io_write_kbs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the last_updated field of the given VBD_metrics. - * - * @return value of the field - */ - public Date getLastUpdated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_last_updated"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the other_config field of the given VBD_metrics. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given VBD_metrics. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VBD_metrics. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VBD_metrics. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VBD_metrics instances known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVBDMetrics(result); - } - - /** - * Return a map of VBD_metrics references to VBD_metrics records for all VBD_metrics instances known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VBD_metrics.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVBDMetricsVBDMetricsRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VDI.java b/deps/XenServerJava/src/com/xensource/xenapi/VDI.java deleted file mode 100644 index e4d20ebf8ba..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VDI.java +++ /dev/null @@ -1,1815 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A virtual disk image - * - * @author Citrix Systems, Inc. - */ -public class VDI extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VDI(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VDI, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VDI) - { - VDI other = (VDI) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VDI - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); - print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); - print.printf("%1$20s: %2$s\n", "SR", this.SR); - print.printf("%1$20s: %2$s\n", "VBDs", this.VBDs); - print.printf("%1$20s: %2$s\n", "crashDumps", this.crashDumps); - print.printf("%1$20s: %2$s\n", "virtualSize", this.virtualSize); - print.printf("%1$20s: %2$s\n", "physicalUtilisation", this.physicalUtilisation); - print.printf("%1$20s: %2$s\n", "type", this.type); - print.printf("%1$20s: %2$s\n", "sharable", this.sharable); - print.printf("%1$20s: %2$s\n", "readOnly", this.readOnly); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "storageLock", this.storageLock); - print.printf("%1$20s: %2$s\n", "location", this.location); - print.printf("%1$20s: %2$s\n", "managed", this.managed); - print.printf("%1$20s: %2$s\n", "missing", this.missing); - print.printf("%1$20s: %2$s\n", "parent", this.parent); - print.printf("%1$20s: %2$s\n", "xenstoreData", this.xenstoreData); - print.printf("%1$20s: %2$s\n", "smConfig", this.smConfig); - print.printf("%1$20s: %2$s\n", "isASnapshot", this.isASnapshot); - print.printf("%1$20s: %2$s\n", "snapshotOf", this.snapshotOf); - print.printf("%1$20s: %2$s\n", "snapshots", this.snapshots); - print.printf("%1$20s: %2$s\n", "snapshotTime", this.snapshotTime); - print.printf("%1$20s: %2$s\n", "tags", this.tags); - print.printf("%1$20s: %2$s\n", "allowCaching", this.allowCaching); - print.printf("%1$20s: %2$s\n", "onBoot", this.onBoot); - return writer.toString(); - } - - /** - * Convert a VDI.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); - map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); - map.put("SR", this.SR == null ? new SR("OpaqueRef:NULL") : this.SR); - map.put("VBDs", this.VBDs == null ? new LinkedHashSet() : this.VBDs); - map.put("crash_dumps", this.crashDumps == null ? new LinkedHashSet() : this.crashDumps); - map.put("virtual_size", this.virtualSize == null ? 0 : this.virtualSize); - map.put("physical_utilisation", this.physicalUtilisation == null ? 0 : this.physicalUtilisation); - map.put("type", this.type == null ? Types.VdiType.UNRECOGNIZED : this.type); - map.put("sharable", this.sharable == null ? false : this.sharable); - map.put("read_only", this.readOnly == null ? false : this.readOnly); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("storage_lock", this.storageLock == null ? false : this.storageLock); - map.put("location", this.location == null ? "" : this.location); - map.put("managed", this.managed == null ? false : this.managed); - map.put("missing", this.missing == null ? false : this.missing); - map.put("parent", this.parent == null ? new VDI("OpaqueRef:NULL") : this.parent); - map.put("xenstore_data", this.xenstoreData == null ? new HashMap() : this.xenstoreData); - map.put("sm_config", this.smConfig == null ? new HashMap() : this.smConfig); - map.put("is_a_snapshot", this.isASnapshot == null ? false : this.isASnapshot); - map.put("snapshot_of", this.snapshotOf == null ? new VDI("OpaqueRef:NULL") : this.snapshotOf); - map.put("snapshots", this.snapshots == null ? new LinkedHashSet() : this.snapshots); - map.put("snapshot_time", this.snapshotTime == null ? new Date(0) : this.snapshotTime); - map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); - map.put("allow_caching", this.allowCaching == null ? false : this.allowCaching); - map.put("on_boot", this.onBoot == null ? Types.OnBoot.UNRECOGNIZED : this.onBoot); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. - */ - public Set allowedOperations; - /** - * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. - */ - public Map currentOperations; - /** - * storage repository in which the VDI resides - */ - public SR SR; - /** - * list of vbds that refer to this disk - */ - public Set VBDs; - /** - * list of crash dumps that refer to this disk - */ - public Set crashDumps; - /** - * size of disk as presented to the guest (in bytes). Note that, depending on storage backend type, requested size may not be respected exactly - */ - public Long virtualSize; - /** - * amount of physical space that the disk image is currently taking up on the storage repository (in bytes) - */ - public Long physicalUtilisation; - /** - * type of the VDI - */ - public Types.VdiType type; - /** - * true if this disk may be shared - */ - public Boolean sharable; - /** - * true if this disk may ONLY be mounted read-only - */ - public Boolean readOnly; - /** - * additional configuration - */ - public Map otherConfig; - /** - * true if this disk is locked at the storage level - */ - public Boolean storageLock; - /** - * location information - */ - public String location; - /** - * - */ - public Boolean managed; - /** - * true if SR scan operation reported this VDI as not present on disk - */ - public Boolean missing; - /** - * References the parent disk, if this VDI is part of a chain - */ - public VDI parent; - /** - * data to be inserted into the xenstore tree (/local/domain/0/backend/vbd///sm-data) after the VDI is attached. This is generally set by the SM backends on vdi_attach. - */ - public Map xenstoreData; - /** - * SM dependent data - */ - public Map smConfig; - /** - * true if this is a snapshot. - */ - public Boolean isASnapshot; - /** - * Ref pointing to the VDI this snapshot is of. - */ - public VDI snapshotOf; - /** - * List pointing to all the VDIs snapshots. - */ - public Set snapshots; - /** - * Date/time when this snapshot was created. - */ - public Date snapshotTime; - /** - * user-specified tags for categorization purposes - */ - public Set tags; - /** - * true if this VDI is to be cached in the local cache SR - */ - public Boolean allowCaching; - /** - * The behaviour of this VDI on a VM boot - */ - public Types.OnBoot onBoot; - } - - /** - * Get a record containing the current state of the given VDI. - * - * @return all fields from the object - */ - public VDI.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDIRecord(result); - } - - /** - * Get a reference to the VDI instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VDI getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Create a new VDI instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, VDI.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new VDI instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static VDI create(Connection c, VDI.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Destroy the specified VDI instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified VDI instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get all the VDI instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVDI(result); - } - - /** - * Get the uuid field of the given VDI. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given VDI. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given VDI. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the allowed_operations field of the given VDI. - * - * @return value of the field - */ - public Set getAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVdiOperations(result); - } - - /** - * Get the current_operations field of the given VDI. - * - * @return value of the field - */ - public Map getCurrentOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_current_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringVdiOperations(result); - } - - /** - * Get the SR field of the given VDI. - * - * @return value of the field - */ - public SR getSR(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_SR"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSR(result); - } - - /** - * Get the VBDs field of the given VDI. - * - * @return value of the field - */ - public Set getVBDs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_VBDs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVBD(result); - } - - /** - * Get the crash_dumps field of the given VDI. - * - * @return value of the field - */ - public Set getCrashDumps(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_crash_dumps"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfCrashdump(result); - } - - /** - * Get the virtual_size field of the given VDI. - * - * @return value of the field - */ - public Long getVirtualSize(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_virtual_size"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the physical_utilisation field of the given VDI. - * - * @return value of the field - */ - public Long getPhysicalUtilisation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_physical_utilisation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the type field of the given VDI. - * - * @return value of the field - */ - public Types.VdiType getType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVdiType(result); - } - - /** - * Get the sharable field of the given VDI. - * - * @return value of the field - */ - public Boolean getSharable(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_sharable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the read_only field of the given VDI. - * - * @return value of the field - */ - public Boolean getReadOnly(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_read_only"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the other_config field of the given VDI. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the storage_lock field of the given VDI. - * - * @return value of the field - */ - public Boolean getStorageLock(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_storage_lock"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the location field of the given VDI. - * - * @return value of the field - */ - public String getLocation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_location"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the managed field of the given VDI. - * - * @return value of the field - */ - public Boolean getManaged(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_managed"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the missing field of the given VDI. - * - * @return value of the field - */ - public Boolean getMissing(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_missing"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the parent field of the given VDI. - * - * @return value of the field - */ - public VDI getParent(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_parent"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Get the xenstore_data field of the given VDI. - * - * @return value of the field - */ - public Map getXenstoreData(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_xenstore_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the sm_config field of the given VDI. - * - * @return value of the field - */ - public Map getSmConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_sm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the is_a_snapshot field of the given VDI. - * - * @return value of the field - */ - public Boolean getIsASnapshot(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_is_a_snapshot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the snapshot_of field of the given VDI. - * - * @return value of the field - */ - public VDI getSnapshotOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_snapshot_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Get the snapshots field of the given VDI. - * - * @return value of the field - */ - public Set getSnapshots(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_snapshots"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVDI(result); - } - - /** - * Get the snapshot_time field of the given VDI. - * - * @return value of the field - */ - public Date getSnapshotTime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_snapshot_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the tags field of the given VDI. - * - * @return value of the field - */ - public Set getTags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the allow_caching field of the given VDI. - * - * @return value of the field - */ - public Boolean getAllowCaching(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_allow_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the on_boot field of the given VDI. - * - * @return value of the field - */ - public Types.OnBoot getOnBoot(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_on_boot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toOnBoot(result); - } - - /** - * Set the name/label field of the given VDI. - * - * @param label New value to set - */ - public void setNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the name/description field of the given VDI. - * - * @param description New value to set - */ - public void setNameDescription(Connection c, String description) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given VDI. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VDI. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VDI. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the xenstore_data field of the given VDI. - * - * @param xenstoreData New value to set - */ - public void setXenstoreData(Connection c, Map xenstoreData) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_xenstore_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(xenstoreData)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the xenstore_data field of the given VDI. - * - * @param key Key to add - * @param value Value to add - */ - public void addToXenstoreData(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.add_to_xenstore_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the xenstore_data field of the given VDI. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromXenstoreData(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.remove_from_xenstore_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the sm_config field of the given VDI. - * - * @param smConfig New value to set - */ - public void setSmConfig(Connection c, Map smConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_sm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the sm_config field of the given VDI. - * - * @param key Key to add - * @param value Value to add - */ - public void addToSmConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.add_to_sm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the sm_config field of the given VDI. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromSmConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.remove_from_sm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the tags field of the given VDI. - * - * @param tags New value to set - */ - public void setTags(Connection c, Set tags) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given value to the tags field of the given VDI. If the value is already in that Set, then do nothing. - * - * @param value New value to add - */ - public void addTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.add_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given value from the tags field of the given VDI. If the value is not in that Set, then do nothing. - * - * @param value Value to remove - */ - public void removeTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.remove_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Take a read-only snapshot of the VDI, returning a reference to the snapshot. If any driver_params are specified then these are passed through to the storage-specific substrate driver that takes the snapshot. NB the snapshot lives in the same Storage Repository as its parent. - * - * @param driverParams Optional parameters that can be passed through to backend driver in order to specify storage-type-specific snapshot options - * @return Task - */ - public Task snapshotAsync(Connection c, Map driverParams) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException { - - if(c.rioConnection){ - if (driverParams.isEmpty()){ - return rioSnapshotAsync(c); - } else { - throw new Types.VersionException("driverParams parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiSnapshotAsync(c, driverParams); - } - } - - - - private Task rioSnapshotAsync(Connection c) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "Async.VDI.snapshot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - private Task miamiSnapshotAsync(Connection c, Map driverParams) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "Async.VDI.snapshot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(driverParams)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Take a read-only snapshot of the VDI, returning a reference to the snapshot. If any driver_params are specified then these are passed through to the storage-specific substrate driver that takes the snapshot. NB the snapshot lives in the same Storage Repository as its parent. - * - * @param driverParams Optional parameters that can be passed through to backend driver in order to specify storage-type-specific snapshot options - * @return The ID of the newly created VDI. - */ - public VDI snapshot(Connection c, Map driverParams) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException { - - if(c.rioConnection){ - if (driverParams.isEmpty()){ - return rioSnapshot(c); - } else { - throw new Types.VersionException("driverParams parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiSnapshot(c, driverParams); - } - } - - - - private VDI rioSnapshot(Connection c) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "VDI.snapshot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - private VDI miamiSnapshot(Connection c, Map driverParams) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "VDI.snapshot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(driverParams)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Take an exact copy of the VDI and return a reference to the new disk. If any driver_params are specified then these are passed through to the storage-specific substrate driver that implements the clone operation. NB the clone lives in the same Storage Repository as its parent. - * - * @param driverParams Optional parameters that are passed through to the backend driver in order to specify storage-type-specific clone options - * @return Task - */ - public Task createCloneAsync(Connection c, Map driverParams) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException { - - if(c.rioConnection){ - if (driverParams.isEmpty()){ - return rioCreateCloneAsync(c); - } else { - throw new Types.VersionException("driverParams parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiCreateCloneAsync(c, driverParams); - } - } - - - - private Task rioCreateCloneAsync(Connection c) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "Async.VDI.clone"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - private Task miamiCreateCloneAsync(Connection c, Map driverParams) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "Async.VDI.clone"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(driverParams)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Take an exact copy of the VDI and return a reference to the new disk. If any driver_params are specified then these are passed through to the storage-specific substrate driver that implements the clone operation. NB the clone lives in the same Storage Repository as its parent. - * - * @param driverParams Optional parameters that are passed through to the backend driver in order to specify storage-type-specific clone options - * @return The ID of the newly created VDI. - */ - public VDI createClone(Connection c, Map driverParams) throws - BadServerResponse, - VersionException, - XenAPIException, - XmlRpcException { - - if(c.rioConnection){ - if (driverParams.isEmpty()){ - return rioCreateClone(c); - } else { - throw new Types.VersionException("driverParams parameter must be empty map for Rio (legacy XenServer) host"); - } - } else { - return miamiCreateClone(c, driverParams); - } - } - - - - private VDI rioCreateClone(Connection c) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "VDI.clone"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - private VDI miamiCreateClone(Connection c, Map driverParams) throws - BadServerResponse, - XmlRpcException, - XenAPIException { - String method_call = "VDI.clone"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(driverParams)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Resize the VDI. - * - * @param size The new size of the VDI - * @return Task - */ - public Task resizeAsync(Connection c, Long size) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.resize"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(size)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Resize the VDI. - * - * @param size The new size of the VDI - */ - public void resize(Connection c, Long size) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.resize"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(size)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Resize the VDI which may or may not be attached to running guests. - * - * @param size The new size of the VDI - * @return Task - */ - public Task resizeOnlineAsync(Connection c, Long size) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.resize_online"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(size)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Resize the VDI which may or may not be attached to running guests. - * - * @param size The new size of the VDI - */ - public void resizeOnline(Connection c, Long size) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.resize_online"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(size)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a new VDI record in the database only - * - * @param uuid The uuid of the disk to introduce - * @param nameLabel The name of the disk record - * @param nameDescription The description of the disk record - * @param SR The SR that the VDI is in - * @param type The type of the VDI - * @param sharable true if this disk may be shared - * @param readOnly true if this disk may ONLY be mounted read-only - * @param otherConfig additional configuration - * @param location location information - * @param xenstoreData Data to insert into xenstore - * @param smConfig Storage-specific config - * @return Task - */ - public static Task introduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, SR SR, Types.VdiType type, Boolean sharable, Boolean readOnly, Map otherConfig, String location, Map xenstoreData, Map smConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrOperationNotSupported { - String method_call = "Async.VDI.introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(SR), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(sharable), Marshalling.toXMLRPC(readOnly), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(location), Marshalling.toXMLRPC(xenstoreData), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new VDI record in the database only - * - * @param uuid The uuid of the disk to introduce - * @param nameLabel The name of the disk record - * @param nameDescription The description of the disk record - * @param SR The SR that the VDI is in - * @param type The type of the VDI - * @param sharable true if this disk may be shared - * @param readOnly true if this disk may ONLY be mounted read-only - * @param otherConfig additional configuration - * @param location location information - * @param xenstoreData Data to insert into xenstore - * @param smConfig Storage-specific config - * @return The ref of the newly created VDI record. - */ - public static VDI introduce(Connection c, String uuid, String nameLabel, String nameDescription, SR SR, Types.VdiType type, Boolean sharable, Boolean readOnly, Map otherConfig, String location, Map xenstoreData, Map smConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrOperationNotSupported { - String method_call = "VDI.introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(SR), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(sharable), Marshalling.toXMLRPC(readOnly), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(location), Marshalling.toXMLRPC(xenstoreData), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Create a new VDI record in the database only - * - * @param uuid The uuid of the disk to introduce - * @param nameLabel The name of the disk record - * @param nameDescription The description of the disk record - * @param SR The SR that the VDI is in - * @param type The type of the VDI - * @param sharable true if this disk may be shared - * @param readOnly true if this disk may ONLY be mounted read-only - * @param otherConfig additional configuration - * @param location location information - * @param xenstoreData Data to insert into xenstore - * @param smConfig Storage-specific config - * @return Task - */ - public static Task dbIntroduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, SR SR, Types.VdiType type, Boolean sharable, Boolean readOnly, Map otherConfig, String location, Map xenstoreData, Map smConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.db_introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(SR), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(sharable), Marshalling.toXMLRPC(readOnly), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(location), Marshalling.toXMLRPC(xenstoreData), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new VDI record in the database only - * - * @param uuid The uuid of the disk to introduce - * @param nameLabel The name of the disk record - * @param nameDescription The description of the disk record - * @param SR The SR that the VDI is in - * @param type The type of the VDI - * @param sharable true if this disk may be shared - * @param readOnly true if this disk may ONLY be mounted read-only - * @param otherConfig additional configuration - * @param location location information - * @param xenstoreData Data to insert into xenstore - * @param smConfig Storage-specific config - * @return The ref of the newly created VDI record. - */ - public static VDI dbIntroduce(Connection c, String uuid, String nameLabel, String nameDescription, SR SR, Types.VdiType type, Boolean sharable, Boolean readOnly, Map otherConfig, String location, Map xenstoreData, Map smConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.db_introduce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(SR), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(sharable), Marshalling.toXMLRPC(readOnly), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(location), Marshalling.toXMLRPC(xenstoreData), Marshalling.toXMLRPC(smConfig)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Removes a VDI record from the database - * - * @return Task - */ - public Task dbForgetAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.db_forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Removes a VDI record from the database - * - */ - public void dbForget(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.db_forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Ask the storage backend to refresh the fields in the VDI object - * - * @return Task - */ - public Task updateAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrOperationNotSupported { - String method_call = "Async.VDI.update"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Ask the storage backend to refresh the fields in the VDI object - * - */ - public void update(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.SrOperationNotSupported { - String method_call = "VDI.update"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Make a fresh VDI in the specified SR and copy the supplied VDI's data to the new disk - * - * @param sr The destination SR - * @return Task - */ - public Task copyAsync(Connection c, SR sr) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.copy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Make a fresh VDI in the specified SR and copy the supplied VDI's data to the new disk - * - * @param sr The destination SR - * @return The reference of the newly created VDI. - */ - public VDI copy(Connection c, SR sr) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.copy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Sets the VDI's managed field - * - * @param value The new value of the VDI's managed field - */ - public void setManaged(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_managed"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Removes a VDI record from the database - * - * @return Task - */ - public Task forgetAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Removes a VDI record from the database - * - */ - public void forget(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.forget"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the VDI's sharable field - * - * @param value The new value of the VDI's sharable field - */ - public void setSharable(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_sharable"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the VDI's read_only field - * - * @param value The new value of the VDI's read_only field - */ - public void setReadOnly(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_read_only"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the VDI's missing field - * - * @param value The new value of the VDI's missing field - */ - public void setMissing(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_missing"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the VDI's virtual_size field - * - * @param value The new value of the VDI's virtual size - */ - public void setVirtualSize(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_virtual_size"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Sets the VDI's physical_utilisation field - * - * @param value The new value of the VDI's physical utilisation - */ - public void setPhysicalUtilisation(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_physical_utilisation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the on_boot parameter. This value can only be changed when the VDI is not attached to a running VM. - * - * @param value The value to set - * @return Task - */ - public Task setOnBootAsync(Connection c, Types.OnBoot value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.set_on_boot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the value of the on_boot parameter. This value can only be changed when the VDI is not attached to a running VM. - * - * @param value The value to set - */ - public void setOnBoot(Connection c, Types.OnBoot value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_on_boot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the allow_caching parameter. This value can only be changed when the VDI is not attached to a running VM. The caching behaviour is only affected by this flag for VHD-based VDIs that have one parent and no child VHDs. Moreover, caching only takes place when the host running the VM containing this VDI has a nominated SR for local caching. - * - * @param value The value to set - * @return Task - */ - public Task setAllowCachingAsync(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VDI.set_allow_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the value of the allow_caching parameter. This value can only be changed when the VDI is not attached to a running VM. The caching behaviour is only affected by this flag for VHD-based VDIs that have one parent and no child VHDs. Moreover, caching only takes place when the host running the VM containing this VDI has a nominated SR for local caching. - * - * @param value The value to set - */ - public void setAllowCaching(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.set_allow_caching"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VDIs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVDI(result); - } - - /** - * Return a map of VDI references to VDI records for all VDIs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VDI.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVDIVDIRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VIF.java b/deps/XenServerJava/src/com/xensource/xenapi/VIF.java deleted file mode 100644 index 4ba78076b15..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VIF.java +++ /dev/null @@ -1,842 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A virtual network interface - * - * @author Citrix Systems, Inc. - */ -public class VIF extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VIF(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VIF, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VIF) - { - VIF other = (VIF) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VIF - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); - print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); - print.printf("%1$20s: %2$s\n", "device", this.device); - print.printf("%1$20s: %2$s\n", "network", this.network); - print.printf("%1$20s: %2$s\n", "VM", this.VM); - print.printf("%1$20s: %2$s\n", "MAC", this.MAC); - print.printf("%1$20s: %2$s\n", "MTU", this.MTU); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); - print.printf("%1$20s: %2$s\n", "statusCode", this.statusCode); - print.printf("%1$20s: %2$s\n", "statusDetail", this.statusDetail); - print.printf("%1$20s: %2$s\n", "runtimeProperties", this.runtimeProperties); - print.printf("%1$20s: %2$s\n", "qosAlgorithmType", this.qosAlgorithmType); - print.printf("%1$20s: %2$s\n", "qosAlgorithmParams", this.qosAlgorithmParams); - print.printf("%1$20s: %2$s\n", "qosSupportedAlgorithms", this.qosSupportedAlgorithms); - print.printf("%1$20s: %2$s\n", "metrics", this.metrics); - print.printf("%1$20s: %2$s\n", "MACAutogenerated", this.MACAutogenerated); - return writer.toString(); - } - - /** - * Convert a VIF.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); - map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); - map.put("device", this.device == null ? "" : this.device); - map.put("network", this.network == null ? new Network("OpaqueRef:NULL") : this.network); - map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); - map.put("MAC", this.MAC == null ? "" : this.MAC); - map.put("MTU", this.MTU == null ? 0 : this.MTU); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); - map.put("status_code", this.statusCode == null ? 0 : this.statusCode); - map.put("status_detail", this.statusDetail == null ? "" : this.statusDetail); - map.put("runtime_properties", this.runtimeProperties == null ? new HashMap() : this.runtimeProperties); - map.put("qos_algorithm_type", this.qosAlgorithmType == null ? "" : this.qosAlgorithmType); - map.put("qos_algorithm_params", this.qosAlgorithmParams == null ? new HashMap() : this.qosAlgorithmParams); - map.put("qos_supported_algorithms", this.qosSupportedAlgorithms == null ? new LinkedHashSet() : this.qosSupportedAlgorithms); - map.put("metrics", this.metrics == null ? new VIFMetrics("OpaqueRef:NULL") : this.metrics); - map.put("MAC_autogenerated", this.MACAutogenerated == null ? false : this.MACAutogenerated); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. - */ - public Set allowedOperations; - /** - * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. - */ - public Map currentOperations; - /** - * order in which VIF backends are created by xapi - */ - public String device; - /** - * virtual network to which this vif is connected - */ - public Network network; - /** - * virtual machine to which this vif is connected - */ - public VM VM; - /** - * ethernet MAC address of virtual interface, as exposed to guest - */ - public String MAC; - /** - * MTU in octets - */ - public Long MTU; - /** - * additional configuration - */ - public Map otherConfig; - /** - * is the device currently attached (erased on reboot) - */ - public Boolean currentlyAttached; - /** - * error/success code associated with last attach-operation (erased on reboot) - */ - public Long statusCode; - /** - * error/success information associated with last attach-operation status (erased on reboot) - */ - public String statusDetail; - /** - * Device runtime properties - */ - public Map runtimeProperties; - /** - * QoS algorithm to use - */ - public String qosAlgorithmType; - /** - * parameters for chosen QoS algorithm - */ - public Map qosAlgorithmParams; - /** - * supported QoS algorithms for this VIF - */ - public Set qosSupportedAlgorithms; - /** - * metrics associated with this VIF - */ - public VIFMetrics metrics; - /** - * true if the MAC was autogenerated; false indicates it was set manually - */ - public Boolean MACAutogenerated; - } - - /** - * Get a record containing the current state of the given VIF. - * - * @return all fields from the object - */ - public VIF.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVIFRecord(result); - } - - /** - * Get a reference to the VIF instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VIF getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVIF(result); - } - - /** - * Create a new VIF instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, VIF.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VIF.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new VIF instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static VIF create(Connection c, VIF.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVIF(result); - } - - /** - * Destroy the specified VIF instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VIF.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified VIF instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the uuid field of the given VIF. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the allowed_operations field of the given VIF. - * - * @return value of the field - */ - public Set getAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVifOperations(result); - } - - /** - * Get the current_operations field of the given VIF. - * - * @return value of the field - */ - public Map getCurrentOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_current_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringVifOperations(result); - } - - /** - * Get the device field of the given VIF. - * - * @return value of the field - */ - public String getDevice(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_device"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the network field of the given VIF. - * - * @return value of the field - */ - public Network getNetwork(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_network"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toNetwork(result); - } - - /** - * Get the VM field of the given VIF. - * - * @return value of the field - */ - public VM getVM(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_VM"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Get the MAC field of the given VIF. - * - * @return value of the field - */ - public String getMAC(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_MAC"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the MTU field of the given VIF. - * - * @return value of the field - */ - public Long getMTU(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_MTU"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the other_config field of the given VIF. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the currently_attached field of the given VIF. - * - * @return value of the field - */ - public Boolean getCurrentlyAttached(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_currently_attached"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the status_code field of the given VIF. - * - * @return value of the field - */ - public Long getStatusCode(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_status_code"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the status_detail field of the given VIF. - * - * @return value of the field - */ - public String getStatusDetail(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_status_detail"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the runtime_properties field of the given VIF. - * - * @return value of the field - */ - public Map getRuntimeProperties(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_runtime_properties"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the qos/algorithm_type field of the given VIF. - * - * @return value of the field - */ - public String getQosAlgorithmType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_qos_algorithm_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the qos/algorithm_params field of the given VIF. - * - * @return value of the field - */ - public Map getQosAlgorithmParams(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_qos_algorithm_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the qos/supported_algorithms field of the given VIF. - * - * @return value of the field - */ - public Set getQosSupportedAlgorithms(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_qos_supported_algorithms"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the metrics field of the given VIF. - * - * @return value of the field - */ - public VIFMetrics getMetrics(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_metrics"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVIFMetrics(result); - } - - /** - * Get the MAC_autogenerated field of the given VIF. - * - * @return value of the field - */ - public Boolean getMACAutogenerated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_MAC_autogenerated"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Set the other_config field of the given VIF. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VIF. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VIF. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the qos/algorithm_type field of the given VIF. - * - * @param algorithmType New value to set - */ - public void setQosAlgorithmType(Connection c, String algorithmType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.set_qos_algorithm_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(algorithmType)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the qos/algorithm_params field of the given VIF. - * - * @param algorithmParams New value to set - */ - public void setQosAlgorithmParams(Connection c, Map algorithmParams) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.set_qos_algorithm_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(algorithmParams)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the qos/algorithm_params field of the given VIF. - * - * @param key Key to add - * @param value Value to add - */ - public void addToQosAlgorithmParams(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.add_to_qos_algorithm_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the qos/algorithm_params field of the given VIF. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromQosAlgorithmParams(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.remove_from_qos_algorithm_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Hotplug the specified VIF, dynamically attaching it to the running VM - * - * @return Task - */ - public Task plugAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VIF.plug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Hotplug the specified VIF, dynamically attaching it to the running VM - * - */ - public void plug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.plug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Hot-unplug the specified VIF, dynamically unattaching it from the running VM - * - * @return Task - */ - public Task unplugAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VIF.unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Hot-unplug the specified VIF, dynamically unattaching it from the running VM - * - */ - public void unplug(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.unplug"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VIFs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVIF(result); - } - - /** - * Return a map of VIF references to VIF records for all VIFs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVIFVIFRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java deleted file mode 100644 index 6c0212fcaa3..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java +++ /dev/null @@ -1,344 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * The metrics associated with a virtual network device - * - * @author Citrix Systems, Inc. - */ -public class VIFMetrics extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VIFMetrics(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VIFMetrics, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VIFMetrics) - { - VIFMetrics other = (VIFMetrics) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VIFMetrics - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs); - print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs); - print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a VIF_metrics.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs); - map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs); - map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * Read bandwidth (KiB/s) - */ - public Double ioReadKbs; - /** - * Write bandwidth (KiB/s) - */ - public Double ioWriteKbs; - /** - * Time at which this information was last updated - */ - public Date lastUpdated; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given VIF_metrics. - * - * @return all fields from the object - */ - public VIFMetrics.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVIFMetricsRecord(result); - } - - /** - * Get a reference to the VIF_metrics instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VIFMetrics getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVIFMetrics(result); - } - - /** - * Get the uuid field of the given VIF_metrics. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the io/read_kbs field of the given VIF_metrics. - * - * @return value of the field - */ - public Double getIoReadKbs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_io_read_kbs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the io/write_kbs field of the given VIF_metrics. - * - * @return value of the field - */ - public Double getIoWriteKbs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_io_write_kbs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the last_updated field of the given VIF_metrics. - * - * @return value of the field - */ - public Date getLastUpdated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_last_updated"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the other_config field of the given VIF_metrics. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given VIF_metrics. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VIF_metrics. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VIF_metrics. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VIF_metrics instances known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVIFMetrics(result); - } - - /** - * Return a map of VIF_metrics references to VIF_metrics records for all VIF_metrics instances known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VIF_metrics.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVIFMetricsVIFMetricsRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VLAN.java b/deps/XenServerJava/src/com/xensource/xenapi/VLAN.java deleted file mode 100644 index b8c968b1df3..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VLAN.java +++ /dev/null @@ -1,416 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A VLAN mux/demux - * - * @author Citrix Systems, Inc. - */ -public class VLAN extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VLAN(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VLAN, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VLAN) - { - VLAN other = (VLAN) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VLAN - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "taggedPIF", this.taggedPIF); - print.printf("%1$20s: %2$s\n", "untaggedPIF", this.untaggedPIF); - print.printf("%1$20s: %2$s\n", "tag", this.tag); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a VLAN.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("tagged_PIF", this.taggedPIF == null ? new PIF("OpaqueRef:NULL") : this.taggedPIF); - map.put("untagged_PIF", this.untaggedPIF == null ? new PIF("OpaqueRef:NULL") : this.untaggedPIF); - map.put("tag", this.tag == null ? 0 : this.tag); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * interface on which traffic is tagged - */ - public PIF taggedPIF; - /** - * interface on which traffic is untagged - */ - public PIF untaggedPIF; - /** - * VLAN tag in use - */ - public Long tag; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given VLAN. - * - * @return all fields from the object - */ - public VLAN.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVLANRecord(result); - } - - /** - * Get a reference to the VLAN instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VLAN getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVLAN(result); - } - - /** - * Get the uuid field of the given VLAN. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the tagged_PIF field of the given VLAN. - * - * @return value of the field - */ - public PIF getTaggedPIF(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_tagged_PIF"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Get the untagged_PIF field of the given VLAN. - * - * @return value of the field - */ - public PIF getUntaggedPIF(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_untagged_PIF"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toPIF(result); - } - - /** - * Get the tag field of the given VLAN. - * - * @return value of the field - */ - public Long getTag(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_tag"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the other_config field of the given VLAN. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given VLAN. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VLAN. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VLAN. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a VLAN mux/demuxer - * - * @param taggedPIF PIF which receives the tagged traffic - * @param tag VLAN tag to use - * @param network Network to receive the untagged traffic - * @return Task - */ - public static Task createAsync(Connection c, PIF taggedPIF, Long tag, Network network) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VLAN.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(taggedPIF), Marshalling.toXMLRPC(tag), Marshalling.toXMLRPC(network)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a VLAN mux/demuxer - * - * @param taggedPIF PIF which receives the tagged traffic - * @param tag VLAN tag to use - * @param network Network to receive the untagged traffic - * @return The reference of the created VLAN object - */ - public static VLAN create(Connection c, PIF taggedPIF, Long tag, Network network) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.create"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(taggedPIF), Marshalling.toXMLRPC(tag), Marshalling.toXMLRPC(network)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVLAN(result); - } - - /** - * Destroy a VLAN mux/demuxer - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VLAN.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy a VLAN mux/demuxer - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VLANs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVLAN(result); - } - - /** - * Return a map of VLAN references to VLAN records for all VLANs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VLAN.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVLANVLANRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VM.java b/deps/XenServerJava/src/com/xensource/xenapi/VM.java deleted file mode 100644 index 165dcfab4a3..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VM.java +++ /dev/null @@ -1,4270 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A virtual machine (or 'guest'). - * - * @author Citrix Systems, Inc. - */ -public class VM extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VM(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VM, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VM) - { - VM other = (VM) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VM - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); - print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); - print.printf("%1$20s: %2$s\n", "powerState", this.powerState); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "userVersion", this.userVersion); - print.printf("%1$20s: %2$s\n", "isATemplate", this.isATemplate); - print.printf("%1$20s: %2$s\n", "suspendVDI", this.suspendVDI); - print.printf("%1$20s: %2$s\n", "residentOn", this.residentOn); - print.printf("%1$20s: %2$s\n", "affinity", this.affinity); - print.printf("%1$20s: %2$s\n", "memoryOverhead", this.memoryOverhead); - print.printf("%1$20s: %2$s\n", "memoryTarget", this.memoryTarget); - print.printf("%1$20s: %2$s\n", "memoryStaticMax", this.memoryStaticMax); - print.printf("%1$20s: %2$s\n", "memoryDynamicMax", this.memoryDynamicMax); - print.printf("%1$20s: %2$s\n", "memoryDynamicMin", this.memoryDynamicMin); - print.printf("%1$20s: %2$s\n", "memoryStaticMin", this.memoryStaticMin); - print.printf("%1$20s: %2$s\n", "VCPUsParams", this.VCPUsParams); - print.printf("%1$20s: %2$s\n", "VCPUsMax", this.VCPUsMax); - print.printf("%1$20s: %2$s\n", "VCPUsAtStartup", this.VCPUsAtStartup); - print.printf("%1$20s: %2$s\n", "actionsAfterShutdown", this.actionsAfterShutdown); - print.printf("%1$20s: %2$s\n", "actionsAfterReboot", this.actionsAfterReboot); - print.printf("%1$20s: %2$s\n", "actionsAfterCrash", this.actionsAfterCrash); - print.printf("%1$20s: %2$s\n", "consoles", this.consoles); - print.printf("%1$20s: %2$s\n", "VIFs", this.VIFs); - print.printf("%1$20s: %2$s\n", "VBDs", this.VBDs); - print.printf("%1$20s: %2$s\n", "crashDumps", this.crashDumps); - print.printf("%1$20s: %2$s\n", "VTPMs", this.VTPMs); - print.printf("%1$20s: %2$s\n", "PVBootloader", this.PVBootloader); - print.printf("%1$20s: %2$s\n", "PVKernel", this.PVKernel); - print.printf("%1$20s: %2$s\n", "PVRamdisk", this.PVRamdisk); - print.printf("%1$20s: %2$s\n", "PVArgs", this.PVArgs); - print.printf("%1$20s: %2$s\n", "PVBootloaderArgs", this.PVBootloaderArgs); - print.printf("%1$20s: %2$s\n", "PVLegacyArgs", this.PVLegacyArgs); - print.printf("%1$20s: %2$s\n", "HVMBootPolicy", this.HVMBootPolicy); - print.printf("%1$20s: %2$s\n", "HVMBootParams", this.HVMBootParams); - print.printf("%1$20s: %2$s\n", "HVMShadowMultiplier", this.HVMShadowMultiplier); - print.printf("%1$20s: %2$s\n", "platform", this.platform); - print.printf("%1$20s: %2$s\n", "PCIBus", this.PCIBus); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "domid", this.domid); - print.printf("%1$20s: %2$s\n", "domarch", this.domarch); - print.printf("%1$20s: %2$s\n", "lastBootCPUFlags", this.lastBootCPUFlags); - print.printf("%1$20s: %2$s\n", "isControlDomain", this.isControlDomain); - print.printf("%1$20s: %2$s\n", "metrics", this.metrics); - print.printf("%1$20s: %2$s\n", "guestMetrics", this.guestMetrics); - print.printf("%1$20s: %2$s\n", "lastBootedRecord", this.lastBootedRecord); - print.printf("%1$20s: %2$s\n", "recommendations", this.recommendations); - print.printf("%1$20s: %2$s\n", "xenstoreData", this.xenstoreData); - print.printf("%1$20s: %2$s\n", "haAlwaysRun", this.haAlwaysRun); - print.printf("%1$20s: %2$s\n", "haRestartPriority", this.haRestartPriority); - print.printf("%1$20s: %2$s\n", "isASnapshot", this.isASnapshot); - print.printf("%1$20s: %2$s\n", "snapshotOf", this.snapshotOf); - print.printf("%1$20s: %2$s\n", "snapshots", this.snapshots); - print.printf("%1$20s: %2$s\n", "snapshotTime", this.snapshotTime); - print.printf("%1$20s: %2$s\n", "transportableSnapshotId", this.transportableSnapshotId); - print.printf("%1$20s: %2$s\n", "blobs", this.blobs); - print.printf("%1$20s: %2$s\n", "tags", this.tags); - print.printf("%1$20s: %2$s\n", "blockedOperations", this.blockedOperations); - print.printf("%1$20s: %2$s\n", "snapshotInfo", this.snapshotInfo); - print.printf("%1$20s: %2$s\n", "snapshotMetadata", this.snapshotMetadata); - print.printf("%1$20s: %2$s\n", "parent", this.parent); - print.printf("%1$20s: %2$s\n", "children", this.children); - print.printf("%1$20s: %2$s\n", "biosStrings", this.biosStrings); - print.printf("%1$20s: %2$s\n", "protectionPolicy", this.protectionPolicy); - print.printf("%1$20s: %2$s\n", "isSnapshotFromVmpp", this.isSnapshotFromVmpp); - return writer.toString(); - } - - /** - * Convert a VM.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); - map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); - map.put("power_state", this.powerState == null ? Types.VmPowerState.UNRECOGNIZED : this.powerState); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("user_version", this.userVersion == null ? 0 : this.userVersion); - map.put("is_a_template", this.isATemplate == null ? false : this.isATemplate); - map.put("suspend_VDI", this.suspendVDI == null ? new VDI("OpaqueRef:NULL") : this.suspendVDI); - map.put("resident_on", this.residentOn == null ? new Host("OpaqueRef:NULL") : this.residentOn); - map.put("affinity", this.affinity == null ? new Host("OpaqueRef:NULL") : this.affinity); - map.put("memory_overhead", this.memoryOverhead == null ? 0 : this.memoryOverhead); - map.put("memory_target", this.memoryTarget == null ? 0 : this.memoryTarget); - map.put("memory_static_max", this.memoryStaticMax == null ? 0 : this.memoryStaticMax); - map.put("memory_dynamic_max", this.memoryDynamicMax == null ? 0 : this.memoryDynamicMax); - map.put("memory_dynamic_min", this.memoryDynamicMin == null ? 0 : this.memoryDynamicMin); - map.put("memory_static_min", this.memoryStaticMin == null ? 0 : this.memoryStaticMin); - map.put("VCPUs_params", this.VCPUsParams == null ? new HashMap() : this.VCPUsParams); - map.put("VCPUs_max", this.VCPUsMax == null ? 0 : this.VCPUsMax); - map.put("VCPUs_at_startup", this.VCPUsAtStartup == null ? 0 : this.VCPUsAtStartup); - map.put("actions_after_shutdown", this.actionsAfterShutdown == null ? Types.OnNormalExit.UNRECOGNIZED : this.actionsAfterShutdown); - map.put("actions_after_reboot", this.actionsAfterReboot == null ? Types.OnNormalExit.UNRECOGNIZED : this.actionsAfterReboot); - map.put("actions_after_crash", this.actionsAfterCrash == null ? Types.OnCrashBehaviour.UNRECOGNIZED : this.actionsAfterCrash); - map.put("consoles", this.consoles == null ? new LinkedHashSet() : this.consoles); - map.put("VIFs", this.VIFs == null ? new LinkedHashSet() : this.VIFs); - map.put("VBDs", this.VBDs == null ? new LinkedHashSet() : this.VBDs); - map.put("crash_dumps", this.crashDumps == null ? new LinkedHashSet() : this.crashDumps); - map.put("VTPMs", this.VTPMs == null ? new LinkedHashSet() : this.VTPMs); - map.put("PV_bootloader", this.PVBootloader == null ? "" : this.PVBootloader); - map.put("PV_kernel", this.PVKernel == null ? "" : this.PVKernel); - map.put("PV_ramdisk", this.PVRamdisk == null ? "" : this.PVRamdisk); - map.put("PV_args", this.PVArgs == null ? "" : this.PVArgs); - map.put("PV_bootloader_args", this.PVBootloaderArgs == null ? "" : this.PVBootloaderArgs); - map.put("PV_legacy_args", this.PVLegacyArgs == null ? "" : this.PVLegacyArgs); - map.put("HVM_boot_policy", this.HVMBootPolicy == null ? "" : this.HVMBootPolicy); - map.put("HVM_boot_params", this.HVMBootParams == null ? new HashMap() : this.HVMBootParams); - map.put("HVM_shadow_multiplier", this.HVMShadowMultiplier == null ? 0.0 : this.HVMShadowMultiplier); - map.put("platform", this.platform == null ? new HashMap() : this.platform); - map.put("PCI_bus", this.PCIBus == null ? "" : this.PCIBus); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("domid", this.domid == null ? 0 : this.domid); - map.put("domarch", this.domarch == null ? "" : this.domarch); - map.put("last_boot_CPU_flags", this.lastBootCPUFlags == null ? new HashMap() : this.lastBootCPUFlags); - map.put("is_control_domain", this.isControlDomain == null ? false : this.isControlDomain); - map.put("metrics", this.metrics == null ? new VMMetrics("OpaqueRef:NULL") : this.metrics); - map.put("guest_metrics", this.guestMetrics == null ? new VMGuestMetrics("OpaqueRef:NULL") : this.guestMetrics); - map.put("last_booted_record", this.lastBootedRecord == null ? "" : this.lastBootedRecord); - map.put("recommendations", this.recommendations == null ? "" : this.recommendations); - map.put("xenstore_data", this.xenstoreData == null ? new HashMap() : this.xenstoreData); - map.put("ha_always_run", this.haAlwaysRun == null ? false : this.haAlwaysRun); - map.put("ha_restart_priority", this.haRestartPriority == null ? "" : this.haRestartPriority); - map.put("is_a_snapshot", this.isASnapshot == null ? false : this.isASnapshot); - map.put("snapshot_of", this.snapshotOf == null ? new VM("OpaqueRef:NULL") : this.snapshotOf); - map.put("snapshots", this.snapshots == null ? new LinkedHashSet() : this.snapshots); - map.put("snapshot_time", this.snapshotTime == null ? new Date(0) : this.snapshotTime); - map.put("transportable_snapshot_id", this.transportableSnapshotId == null ? "" : this.transportableSnapshotId); - map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); - map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); - map.put("blocked_operations", this.blockedOperations == null ? new HashMap() : this.blockedOperations); - map.put("snapshot_info", this.snapshotInfo == null ? new HashMap() : this.snapshotInfo); - map.put("snapshot_metadata", this.snapshotMetadata == null ? "" : this.snapshotMetadata); - map.put("parent", this.parent == null ? new VM("OpaqueRef:NULL") : this.parent); - map.put("children", this.children == null ? new LinkedHashSet() : this.children); - map.put("bios_strings", this.biosStrings == null ? new HashMap() : this.biosStrings); - map.put("protection_policy", this.protectionPolicy == null ? new VMPP("OpaqueRef:NULL") : this.protectionPolicy); - map.put("is_snapshot_from_vmpp", this.isSnapshotFromVmpp == null ? false : this.isSnapshotFromVmpp); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. - */ - public Set allowedOperations; - /** - * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. - */ - public Map currentOperations; - /** - * Current power state of the machine - */ - public Types.VmPowerState powerState; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * a user version number for this machine - */ - public Long userVersion; - /** - * true if this is a template. Template VMs can never be started, they are used only for cloning other VMs - */ - public Boolean isATemplate; - /** - * The VDI that a suspend image is stored on. (Only has meaning if VM is currently suspended) - */ - public VDI suspendVDI; - /** - * the host the VM is currently resident on - */ - public Host residentOn; - /** - * a host which the VM has some affinity for (or NULL). This is used as a hint to the start call when it decides where to run the VM. Implementations are free to ignore this field. - */ - public Host affinity; - /** - * Virtualization memory overhead (bytes). - */ - public Long memoryOverhead; - /** - * Dynamically-set memory target (bytes). The value of this field indicates the current target for memory available to this VM. - */ - public Long memoryTarget; - /** - * Statically-set (i.e. absolute) maximum (bytes). The value of this field at VM start time acts as a hard limit of the amount of memory a guest can use. New values only take effect on reboot. - */ - public Long memoryStaticMax; - /** - * Dynamic maximum (bytes) - */ - public Long memoryDynamicMax; - /** - * Dynamic minimum (bytes) - */ - public Long memoryDynamicMin; - /** - * Statically-set (i.e. absolute) mininum (bytes). The value of this field indicates the least amount of memory this VM can boot with without crashing. - */ - public Long memoryStaticMin; - /** - * configuration parameters for the selected VCPU policy - */ - public Map VCPUsParams; - /** - * Max number of VCPUs - */ - public Long VCPUsMax; - /** - * Boot number of VCPUs - */ - public Long VCPUsAtStartup; - /** - * action to take after the guest has shutdown itself - */ - public Types.OnNormalExit actionsAfterShutdown; - /** - * action to take after the guest has rebooted itself - */ - public Types.OnNormalExit actionsAfterReboot; - /** - * action to take if the guest crashes - */ - public Types.OnCrashBehaviour actionsAfterCrash; - /** - * virtual console devices - */ - public Set consoles; - /** - * virtual network interfaces - */ - public Set VIFs; - /** - * virtual block devices - */ - public Set VBDs; - /** - * crash dumps associated with this VM - */ - public Set crashDumps; - /** - * virtual TPMs - */ - public Set VTPMs; - /** - * name of or path to bootloader - */ - public String PVBootloader; - /** - * path to the kernel - */ - public String PVKernel; - /** - * path to the initrd - */ - public String PVRamdisk; - /** - * kernel command-line arguments - */ - public String PVArgs; - /** - * miscellaneous arguments for the bootloader - */ - public String PVBootloaderArgs; - /** - * to make Zurich guests boot - */ - public String PVLegacyArgs; - /** - * HVM boot policy - */ - public String HVMBootPolicy; - /** - * HVM boot params - */ - public Map HVMBootParams; - /** - * multiplier applied to the amount of shadow that will be made available to the guest - */ - public Double HVMShadowMultiplier; - /** - * platform-specific configuration - */ - public Map platform; - /** - * PCI bus path for pass-through devices - */ - public String PCIBus; - /** - * additional configuration - */ - public Map otherConfig; - /** - * domain ID (if available, -1 otherwise) - */ - public Long domid; - /** - * Domain architecture (if available, null string otherwise) - */ - public String domarch; - /** - * describes the CPU flags on which the VM was last booted - */ - public Map lastBootCPUFlags; - /** - * true if this is a control domain (domain 0 or a driver domain) - */ - public Boolean isControlDomain; - /** - * metrics associated with this VM - */ - public VMMetrics metrics; - /** - * metrics associated with the running guest - */ - public VMGuestMetrics guestMetrics; - /** - * marshalled value containing VM record at time of last boot, updated dynamically to reflect the runtime state of the domain - */ - public String lastBootedRecord; - /** - * An XML specification of recommended values and ranges for properties of this VM - */ - public String recommendations; - /** - * data to be inserted into the xenstore tree (/local/domain//vm-data) after the VM is created. - */ - public Map xenstoreData; - /** - * if true then the system will attempt to keep the VM running as much as possible. - */ - public Boolean haAlwaysRun; - /** - * Only defined if ha_always_run is set possible values: "best-effort" meaning "try to restart this VM if possible but don't consider the Pool to be overcommitted if this is not possible"; and a numerical restart priority (e.g. 1, 2, 3,...) - */ - public String haRestartPriority; - /** - * true if this is a snapshot. Snapshotted VMs can never be started, they are used only for cloning other VMs - */ - public Boolean isASnapshot; - /** - * Ref pointing to the VM this snapshot is of. - */ - public VM snapshotOf; - /** - * List pointing to all the VM snapshots. - */ - public Set snapshots; - /** - * Date/time when this snapshot was created. - */ - public Date snapshotTime; - /** - * Transportable ID of the snapshot VM - */ - public String transportableSnapshotId; - /** - * Binary blobs associated with this VM - */ - public Map blobs; - /** - * user-specified tags for categorization purposes - */ - public Set tags; - /** - * List of operations which have been explicitly blocked and an error code - */ - public Map blockedOperations; - /** - * Human-readable information concerning this snapshot - */ - public Map snapshotInfo; - /** - * Encoded information about the VM's metadata this is a snapshot of - */ - public String snapshotMetadata; - /** - * Ref pointing to the parent of this VM - */ - public VM parent; - /** - * List pointing to all the children of this VM - */ - public Set children; - /** - * BIOS strings - */ - public Map biosStrings; - /** - * Ref pointing to a protection policy for this VM - */ - public VMPP protectionPolicy; - /** - * true if this snapshot was created by the protection policy - */ - public Boolean isSnapshotFromVmpp; - } - - /** - * Get a record containing the current state of the given VM. - * - * @return all fields from the object - */ - public VM.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMRecord(result); - } - - /** - * Get a reference to the VM instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VM getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Create a new VM instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, VM.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new VM instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static VM create(Connection c, VM.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Destroy the specified VM. The VM is completely removed from the system. This function can only be called when the VM is in the Halted State. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified VM. The VM is completely removed from the system. This function can only be called when the VM is in the Halted State. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get all the VM instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVM(result); - } - - /** - * Get the uuid field of the given VM. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the allowed_operations field of the given VM. - * - * @return value of the field - */ - public Set getAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVmOperations(result); - } - - /** - * Get the current_operations field of the given VM. - * - * @return value of the field - */ - public Map getCurrentOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_current_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringVmOperations(result); - } - - /** - * Get the power_state field of the given VM. - * - * @return value of the field - */ - public Types.VmPowerState getPowerState(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_power_state"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVmPowerState(result); - } - - /** - * Get the name/label field of the given VM. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given VM. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the user_version field of the given VM. - * - * @return value of the field - */ - public Long getUserVersion(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_user_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the is_a_template field of the given VM. - * - * @return value of the field - */ - public Boolean getIsATemplate(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_is_a_template"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the suspend_VDI field of the given VM. - * - * @return value of the field - */ - public VDI getSuspendVDI(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_suspend_VDI"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVDI(result); - } - - /** - * Get the resident_on field of the given VM. - * - * @return value of the field - */ - public Host getResidentOn(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_resident_on"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the affinity field of the given VM. - * - * @return value of the field - */ - public Host getAffinity(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_affinity"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toHost(result); - } - - /** - * Get the memory/overhead field of the given VM. - * - * @return value of the field - */ - public Long getMemoryOverhead(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_memory_overhead"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the memory/target field of the given VM. - * @deprecated - * - * @return value of the field - */ - @Deprecated public Long getMemoryTarget(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_memory_target"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the memory/static_max field of the given VM. - * - * @return value of the field - */ - public Long getMemoryStaticMax(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_memory_static_max"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the memory/dynamic_max field of the given VM. - * - * @return value of the field - */ - public Long getMemoryDynamicMax(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_memory_dynamic_max"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the memory/dynamic_min field of the given VM. - * - * @return value of the field - */ - public Long getMemoryDynamicMin(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_memory_dynamic_min"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the memory/static_min field of the given VM. - * - * @return value of the field - */ - public Long getMemoryStaticMin(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_memory_static_min"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the VCPUs/params field of the given VM. - * - * @return value of the field - */ - public Map getVCPUsParams(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_VCPUs_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the VCPUs/max field of the given VM. - * - * @return value of the field - */ - public Long getVCPUsMax(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_VCPUs_max"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the VCPUs/at_startup field of the given VM. - * - * @return value of the field - */ - public Long getVCPUsAtStartup(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_VCPUs_at_startup"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the actions/after_shutdown field of the given VM. - * - * @return value of the field - */ - public Types.OnNormalExit getActionsAfterShutdown(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_actions_after_shutdown"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toOnNormalExit(result); - } - - /** - * Get the actions/after_reboot field of the given VM. - * - * @return value of the field - */ - public Types.OnNormalExit getActionsAfterReboot(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_actions_after_reboot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toOnNormalExit(result); - } - - /** - * Get the actions/after_crash field of the given VM. - * - * @return value of the field - */ - public Types.OnCrashBehaviour getActionsAfterCrash(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_actions_after_crash"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toOnCrashBehaviour(result); - } - - /** - * Get the consoles field of the given VM. - * - * @return value of the field - */ - public Set getConsoles(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_consoles"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfConsole(result); - } - - /** - * Get the VIFs field of the given VM. - * - * @return value of the field - */ - public Set getVIFs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_VIFs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVIF(result); - } - - /** - * Get the VBDs field of the given VM. - * - * @return value of the field - */ - public Set getVBDs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_VBDs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVBD(result); - } - - /** - * Get the crash_dumps field of the given VM. - * - * @return value of the field - */ - public Set getCrashDumps(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_crash_dumps"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfCrashdump(result); - } - - /** - * Get the VTPMs field of the given VM. - * - * @return value of the field - */ - public Set getVTPMs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_VTPMs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVTPM(result); - } - - /** - * Get the PV/bootloader field of the given VM. - * - * @return value of the field - */ - public String getPVBootloader(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_PV_bootloader"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the PV/kernel field of the given VM. - * - * @return value of the field - */ - public String getPVKernel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_PV_kernel"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the PV/ramdisk field of the given VM. - * - * @return value of the field - */ - public String getPVRamdisk(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_PV_ramdisk"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the PV/args field of the given VM. - * - * @return value of the field - */ - public String getPVArgs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_PV_args"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the PV/bootloader_args field of the given VM. - * - * @return value of the field - */ - public String getPVBootloaderArgs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_PV_bootloader_args"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the PV/legacy_args field of the given VM. - * - * @return value of the field - */ - public String getPVLegacyArgs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_PV_legacy_args"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the HVM/boot_policy field of the given VM. - * - * @return value of the field - */ - public String getHVMBootPolicy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_HVM_boot_policy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the HVM/boot_params field of the given VM. - * - * @return value of the field - */ - public Map getHVMBootParams(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_HVM_boot_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the HVM/shadow_multiplier field of the given VM. - * - * @return value of the field - */ - public Double getHVMShadowMultiplier(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_HVM_shadow_multiplier"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Get the platform field of the given VM. - * - * @return value of the field - */ - public Map getPlatform(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_platform"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the PCI_bus field of the given VM. - * - * @return value of the field - */ - public String getPCIBus(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_PCI_bus"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the other_config field of the given VM. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the domid field of the given VM. - * - * @return value of the field - */ - public Long getDomid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_domid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the domarch field of the given VM. - * - * @return value of the field - */ - public String getDomarch(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_domarch"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the last_boot_CPU_flags field of the given VM. - * - * @return value of the field - */ - public Map getLastBootCPUFlags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_last_boot_CPU_flags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the is_control_domain field of the given VM. - * - * @return value of the field - */ - public Boolean getIsControlDomain(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_is_control_domain"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the metrics field of the given VM. - * - * @return value of the field - */ - public VMMetrics getMetrics(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_metrics"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMMetrics(result); - } - - /** - * Get the guest_metrics field of the given VM. - * - * @return value of the field - */ - public VMGuestMetrics getGuestMetrics(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_guest_metrics"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMGuestMetrics(result); - } - - /** - * Get the last_booted_record field of the given VM. - * - * @return value of the field - */ - public String getLastBootedRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_last_booted_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the recommendations field of the given VM. - * - * @return value of the field - */ - public String getRecommendations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_recommendations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the xenstore_data field of the given VM. - * - * @return value of the field - */ - public Map getXenstoreData(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_xenstore_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the ha_always_run field of the given VM. - * - * @return value of the field - */ - public Boolean getHaAlwaysRun(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_ha_always_run"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the ha_restart_priority field of the given VM. - * - * @return value of the field - */ - public String getHaRestartPriority(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_ha_restart_priority"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the is_a_snapshot field of the given VM. - * - * @return value of the field - */ - public Boolean getIsASnapshot(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_is_a_snapshot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the snapshot_of field of the given VM. - * - * @return value of the field - */ - public VM getSnapshotOf(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_snapshot_of"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Get the snapshots field of the given VM. - * - * @return value of the field - */ - public Set getSnapshots(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_snapshots"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVM(result); - } - - /** - * Get the snapshot_time field of the given VM. - * - * @return value of the field - */ - public Date getSnapshotTime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_snapshot_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the transportable_snapshot_id field of the given VM. - * - * @return value of the field - */ - public String getTransportableSnapshotId(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_transportable_snapshot_id"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the blobs field of the given VM. - * - * @return value of the field - */ - public Map getBlobs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_blobs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringBlob(result); - } - - /** - * Get the tags field of the given VM. - * - * @return value of the field - */ - public Set getTags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the blocked_operations field of the given VM. - * - * @return value of the field - */ - public Map getBlockedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_blocked_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVmOperationsString(result); - } - - /** - * Get the snapshot_info field of the given VM. - * - * @return value of the field - */ - public Map getSnapshotInfo(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_snapshot_info"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the snapshot_metadata field of the given VM. - * - * @return value of the field - */ - public String getSnapshotMetadata(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_snapshot_metadata"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the parent field of the given VM. - * - * @return value of the field - */ - public VM getParent(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_parent"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Get the children field of the given VM. - * - * @return value of the field - */ - public Set getChildren(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_children"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVM(result); - } - - /** - * Get the bios_strings field of the given VM. - * - * @return value of the field - */ - public Map getBiosStrings(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_bios_strings"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the protection_policy field of the given VM. - * - * @return value of the field - */ - public VMPP getProtectionPolicy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_protection_policy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMPP(result); - } - - /** - * Get the is_snapshot_from_vmpp field of the given VM. - * - * @return value of the field - */ - public Boolean getIsSnapshotFromVmpp(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_is_snapshot_from_vmpp"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Set the name/label field of the given VM. - * - * @param label New value to set - */ - public void setNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the name/description field of the given VM. - * - * @param description New value to set - */ - public void setNameDescription(Connection c, String description) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the user_version field of the given VM. - * - * @param userVersion New value to set - */ - public void setUserVersion(Connection c, Long userVersion) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_user_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(userVersion)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the is_a_template field of the given VM. - * - * @param isATemplate New value to set - */ - public void setIsATemplate(Connection c, Boolean isATemplate) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_is_a_template"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(isATemplate)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the affinity field of the given VM. - * - * @param affinity New value to set - */ - public void setAffinity(Connection c, Host affinity) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_affinity"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(affinity)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the VCPUs/params field of the given VM. - * - * @param params New value to set - */ - public void setVCPUsParams(Connection c, Map params) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_VCPUs_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(params)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the VCPUs/params field of the given VM. - * - * @param key Key to add - * @param value Value to add - */ - public void addToVCPUsParams(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.add_to_VCPUs_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the VCPUs/params field of the given VM. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromVCPUsParams(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.remove_from_VCPUs_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the actions/after_shutdown field of the given VM. - * - * @param afterShutdown New value to set - */ - public void setActionsAfterShutdown(Connection c, Types.OnNormalExit afterShutdown) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_actions_after_shutdown"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(afterShutdown)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the actions/after_reboot field of the given VM. - * - * @param afterReboot New value to set - */ - public void setActionsAfterReboot(Connection c, Types.OnNormalExit afterReboot) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_actions_after_reboot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(afterReboot)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the actions/after_crash field of the given VM. - * - * @param afterCrash New value to set - */ - public void setActionsAfterCrash(Connection c, Types.OnCrashBehaviour afterCrash) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_actions_after_crash"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(afterCrash)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the PV/bootloader field of the given VM. - * - * @param bootloader New value to set - */ - public void setPVBootloader(Connection c, String bootloader) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_PV_bootloader"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootloader)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the PV/kernel field of the given VM. - * - * @param kernel New value to set - */ - public void setPVKernel(Connection c, String kernel) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_PV_kernel"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(kernel)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the PV/ramdisk field of the given VM. - * - * @param ramdisk New value to set - */ - public void setPVRamdisk(Connection c, String ramdisk) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_PV_ramdisk"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(ramdisk)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the PV/args field of the given VM. - * - * @param args New value to set - */ - public void setPVArgs(Connection c, String args) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_PV_args"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(args)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the PV/bootloader_args field of the given VM. - * - * @param bootloaderArgs New value to set - */ - public void setPVBootloaderArgs(Connection c, String bootloaderArgs) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_PV_bootloader_args"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootloaderArgs)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the PV/legacy_args field of the given VM. - * - * @param legacyArgs New value to set - */ - public void setPVLegacyArgs(Connection c, String legacyArgs) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_PV_legacy_args"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(legacyArgs)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the HVM/boot_policy field of the given VM. - * - * @param bootPolicy New value to set - */ - public void setHVMBootPolicy(Connection c, String bootPolicy) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_HVM_boot_policy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootPolicy)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the HVM/boot_params field of the given VM. - * - * @param bootParams New value to set - */ - public void setHVMBootParams(Connection c, Map bootParams) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_HVM_boot_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootParams)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the HVM/boot_params field of the given VM. - * - * @param key Key to add - * @param value Value to add - */ - public void addToHVMBootParams(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.add_to_HVM_boot_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the HVM/boot_params field of the given VM. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromHVMBootParams(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.remove_from_HVM_boot_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the platform field of the given VM. - * - * @param platform New value to set - */ - public void setPlatform(Connection c, Map platform) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_platform"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(platform)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the platform field of the given VM. - * - * @param key Key to add - * @param value Value to add - */ - public void addToPlatform(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.add_to_platform"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the platform field of the given VM. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromPlatform(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.remove_from_platform"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the PCI_bus field of the given VM. - * - * @param PCIBus New value to set - */ - public void setPCIBus(Connection c, String PCIBus) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_PCI_bus"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(PCIBus)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the other_config field of the given VM. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VM. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VM. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the recommendations field of the given VM. - * - * @param recommendations New value to set - */ - public void setRecommendations(Connection c, String recommendations) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_recommendations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(recommendations)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the xenstore_data field of the given VM. - * - * @param xenstoreData New value to set - */ - public void setXenstoreData(Connection c, Map xenstoreData) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_xenstore_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(xenstoreData)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the xenstore_data field of the given VM. - * - * @param key Key to add - * @param value Value to add - */ - public void addToXenstoreData(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.add_to_xenstore_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the xenstore_data field of the given VM. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromXenstoreData(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.remove_from_xenstore_data"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the tags field of the given VM. - * - * @param tags New value to set - */ - public void setTags(Connection c, Set tags) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given value to the tags field of the given VM. If the value is already in that Set, then do nothing. - * - * @param value New value to add - */ - public void addTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.add_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given value from the tags field of the given VM. If the value is not in that Set, then do nothing. - * - * @param value Value to remove - */ - public void removeTags(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.remove_tags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the blocked_operations field of the given VM. - * - * @param blockedOperations New value to set - */ - public void setBlockedOperations(Connection c, Map blockedOperations) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_blocked_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(blockedOperations)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the blocked_operations field of the given VM. - * - * @param key Key to add - * @param value Value to add - */ - public void addToBlockedOperations(Connection c, Types.VmOperations key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.add_to_blocked_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the blocked_operations field of the given VM. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromBlockedOperations(Connection c, Types.VmOperations key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.remove_from_blocked_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Snapshots the specified VM, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). - * - * @param newName The name of the snapshotted VM - * @return Task - */ - public Task snapshotAsync(Connection c, String newName) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed { - String method_call = "Async.VM.snapshot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Snapshots the specified VM, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). - * - * @param newName The name of the snapshotted VM - * @return The reference of the newly created VM. - */ - public VM snapshot(Connection c, String newName) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed { - String method_call = "VM.snapshot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Snapshots the specified VM with quiesce, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). - * - * @param newName The name of the snapshotted VM - * @return Task - */ - public Task snapshotWithQuiesceAsync(Connection c, String newName) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed, - Types.VmSnapshotWithQuiesceFailed, - Types.VmSnapshotWithQuiesceTimeout, - Types.VmSnapshotWithQuiescePluginDeosNotRespond, - Types.VmSnapshotWithQuiesceNotSupported { - String method_call = "Async.VM.snapshot_with_quiesce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Snapshots the specified VM with quiesce, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). - * - * @param newName The name of the snapshotted VM - * @return The reference of the newly created VM. - */ - public VM snapshotWithQuiesce(Connection c, String newName) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed, - Types.VmSnapshotWithQuiesceFailed, - Types.VmSnapshotWithQuiesceTimeout, - Types.VmSnapshotWithQuiescePluginDeosNotRespond, - Types.VmSnapshotWithQuiesceNotSupported { - String method_call = "VM.snapshot_with_quiesce"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Clones the specified VM, making a new VM. Clone automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). This function can only be called when the VM is in the Halted State. - * - * @param newName The name of the cloned VM - * @return Task - */ - public Task createCloneAsync(Connection c, String newName) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed { - String method_call = "Async.VM.clone"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Clones the specified VM, making a new VM. Clone automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). This function can only be called when the VM is in the Halted State. - * - * @param newName The name of the cloned VM - * @return The reference of the newly created VM. - */ - public VM createClone(Connection c, String newName) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed { - String method_call = "VM.clone"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Copied the specified VM, making a new VM. Unlike clone, copy does not exploits the capabilities of the underlying storage repository in which the VM's disk images are stored. Instead, copy guarantees that the disk images of the newly created VM will be 'full disks' - i.e. not part of a CoW chain. This function can only be called when the VM is in the Halted State. - * - * @param newName The name of the copied VM - * @param sr An SR to copy all the VM's disks into (if an invalid reference then it uses the existing SRs) - * @return Task - */ - public Task copyAsync(Connection c, String newName, SR sr) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed { - String method_call = "Async.VM.copy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName), Marshalling.toXMLRPC(sr)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Copied the specified VM, making a new VM. Unlike clone, copy does not exploits the capabilities of the underlying storage repository in which the VM's disk images are stored. Instead, copy guarantees that the disk images of the newly created VM will be 'full disks' - i.e. not part of a CoW chain. This function can only be called when the VM is in the Halted State. - * - * @param newName The name of the copied VM - * @param sr An SR to copy all the VM's disks into (if an invalid reference then it uses the existing SRs) - * @return The reference of the newly created VM. - */ - public VM copy(Connection c, String newName, SR sr) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed { - String method_call = "VM.copy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName), Marshalling.toXMLRPC(sr)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Reverts the specified VM to a previous state. - * - * @return Task - */ - public Task revertAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OperationNotAllowed, - Types.SrFull, - Types.VmRevertFailed { - String method_call = "Async.VM.revert"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Reverts the specified VM to a previous state. - * - */ - public void revert(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OperationNotAllowed, - Types.SrFull, - Types.VmRevertFailed { - String method_call = "VM.revert"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Checkpoints the specified VM, making a new VM. Checkpoint automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write) and saves the memory image as well. - * - * @param newName The name of the checkpointed VM - * @return Task - */ - public Task checkpointAsync(Connection c, String newName) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed, - Types.VmCheckpointSuspendFailed, - Types.VmCheckpointResumeFailed { - String method_call = "Async.VM.checkpoint"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Checkpoints the specified VM, making a new VM. Checkpoint automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write) and saves the memory image as well. - * - * @param newName The name of the checkpointed VM - * @return The reference of the newly created VM. - */ - public VM checkpoint(Connection c, String newName) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed, - Types.VmCheckpointSuspendFailed, - Types.VmCheckpointResumeFailed { - String method_call = "VM.checkpoint"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Inspects the disk configuration contained within the VM's other_config, creates VDIs and VBDs and then executes any applicable post-install script. - * - * @return Task - */ - public Task provisionAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed { - String method_call = "Async.VM.provision"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Inspects the disk configuration contained within the VM's other_config, creates VDIs and VBDs and then executes any applicable post-install script. - * - */ - public void provision(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.SrFull, - Types.OperationNotAllowed { - String method_call = "VM.provision"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Start the specified VM. This function can only be called with the VM is in the Halted State. - * - * @param startPaused Instantiate VM in paused state if set to true. - * @param force Attempt to force the VM to start. If this flag is false then the VM may fail pre-boot safety checks (e.g. if the CPU the VM last booted on looks substantially different to the current one) - * @return Task - */ - public Task startAsync(Connection c, Boolean startPaused, Boolean force) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.VmHvmRequired, - Types.VmIsTemplate, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.BootloaderFailed, - Types.UnknownBootloader, - Types.NoHostsAvailable, - Types.LicenceRestriction { - String method_call = "Async.VM.start"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Start the specified VM. This function can only be called with the VM is in the Halted State. - * - * @param startPaused Instantiate VM in paused state if set to true. - * @param force Attempt to force the VM to start. If this flag is false then the VM may fail pre-boot safety checks (e.g. if the CPU the VM last booted on looks substantially different to the current one) - */ - public void start(Connection c, Boolean startPaused, Boolean force) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.VmHvmRequired, - Types.VmIsTemplate, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.BootloaderFailed, - Types.UnknownBootloader, - Types.NoHostsAvailable, - Types.LicenceRestriction { - String method_call = "VM.start"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Start the specified VM on a particular host. This function can only be called with the VM is in the Halted State. - * - * @param host The Host on which to start the VM - * @param startPaused Instantiate VM in paused state if set to true. - * @param force Attempt to force the VM to start. If this flag is false then the VM may fail pre-boot safety checks (e.g. if the CPU the VM last booted on looks substantially different to the current one) - * @return Task - */ - public Task startOnAsync(Connection c, Host host, Boolean startPaused, Boolean force) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.VmIsTemplate, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.BootloaderFailed, - Types.UnknownBootloader { - String method_call = "Async.VM.start_on"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Start the specified VM on a particular host. This function can only be called with the VM is in the Halted State. - * - * @param host The Host on which to start the VM - * @param startPaused Instantiate VM in paused state if set to true. - * @param force Attempt to force the VM to start. If this flag is false then the VM may fail pre-boot safety checks (e.g. if the CPU the VM last booted on looks substantially different to the current one) - */ - public void startOn(Connection c, Host host, Boolean startPaused, Boolean force) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.VmIsTemplate, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.BootloaderFailed, - Types.UnknownBootloader { - String method_call = "VM.start_on"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Pause the specified VM. This can only be called when the specified VM is in the Running state. - * - * @return Task - */ - public Task pauseAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.pause"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Pause the specified VM. This can only be called when the specified VM is in the Running state. - * - */ - public void pause(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.pause"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Resume the specified VM. This can only be called when the specified VM is in the Paused state. - * - * @return Task - */ - public Task unpauseAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.unpause"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Resume the specified VM. This can only be called when the specified VM is in the Paused state. - * - */ - public void unpause(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.unpause"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Attempt to cleanly shutdown the specified VM. (Note: this may not be supported---e.g. if a guest agent is not installed). This can only be called when the specified VM is in the Running state. - * - * @return Task - */ - public Task cleanShutdownAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.clean_shutdown"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Attempt to cleanly shutdown the specified VM. (Note: this may not be supported---e.g. if a guest agent is not installed). This can only be called when the specified VM is in the Running state. - * - */ - public void cleanShutdown(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.clean_shutdown"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Attempt to cleanly shutdown the specified VM (Note: this may not be supported---e.g. if a guest agent is not installed). This can only be called when the specified VM is in the Running state. - * - * @return Task - */ - public Task cleanRebootAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.clean_reboot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Attempt to cleanly shutdown the specified VM (Note: this may not be supported---e.g. if a guest agent is not installed). This can only be called when the specified VM is in the Running state. - * - */ - public void cleanReboot(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.clean_reboot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Stop executing the specified VM without attempting a clean shutdown. - * - * @return Task - */ - public Task hardShutdownAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.hard_shutdown"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Stop executing the specified VM without attempting a clean shutdown. - * - */ - public void hardShutdown(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.hard_shutdown"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Reset the power-state of the VM to halted in the database only. (Used to recover from slave failures in pooling scenarios by resetting the power-states of VMs running on dead slaves to halted.) This is a potentially dangerous operation; use with care. - * - * @return Task - */ - public Task powerStateResetAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.power_state_reset"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Reset the power-state of the VM to halted in the database only. (Used to recover from slave failures in pooling scenarios by resetting the power-states of VMs running on dead slaves to halted.) This is a potentially dangerous operation; use with care. - * - */ - public void powerStateReset(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.power_state_reset"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Stop executing the specified VM without attempting a clean shutdown and immediately restart the VM. - * - * @return Task - */ - public Task hardRebootAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.hard_reboot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Stop executing the specified VM without attempting a clean shutdown and immediately restart the VM. - * - */ - public void hardReboot(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.hard_reboot"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Suspend the specified VM to disk. This can only be called when the specified VM is in the Running state. - * - * @return Task - */ - public Task suspendAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.suspend"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Suspend the specified VM to disk. This can only be called when the specified VM is in the Running state. - * - */ - public void suspend(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.suspend"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Awaken the specified VM and resume it. This can only be called when the specified VM is in the Suspended state. - * - * @param startPaused Resume VM in paused state if set to true. - * @param force Attempt to force the VM to resume. If this flag is false then the VM may fail pre-resume safety checks (e.g. if the CPU the VM was running on looks substantially different to the current one) - * @return Task - */ - public Task resumeAsync(Connection c, Boolean startPaused, Boolean force) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.resume"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Awaken the specified VM and resume it. This can only be called when the specified VM is in the Suspended state. - * - * @param startPaused Resume VM in paused state if set to true. - * @param force Attempt to force the VM to resume. If this flag is false then the VM may fail pre-resume safety checks (e.g. if the CPU the VM was running on looks substantially different to the current one) - */ - public void resume(Connection c, Boolean startPaused, Boolean force) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.resume"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Awaken the specified VM and resume it on a particular Host. This can only be called when the specified VM is in the Suspended state. - * - * @param host The Host on which to resume the VM - * @param startPaused Resume VM in paused state if set to true. - * @param force Attempt to force the VM to resume. If this flag is false then the VM may fail pre-resume safety checks (e.g. if the CPU the VM was running on looks substantially different to the current one) - * @return Task - */ - public Task resumeOnAsync(Connection c, Host host, Boolean startPaused, Boolean force) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "Async.VM.resume_on"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Awaken the specified VM and resume it on a particular Host. This can only be called when the specified VM is in the Suspended state. - * - * @param host The Host on which to resume the VM - * @param startPaused Resume VM in paused state if set to true. - * @param force Attempt to force the VM to resume. If this flag is false then the VM may fail pre-resume safety checks (e.g. if the CPU the VM was running on looks substantially different to the current one) - */ - public void resumeOn(Connection c, Host host, Boolean startPaused, Boolean force) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OperationNotAllowed, - Types.VmIsTemplate { - String method_call = "VM.resume_on"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Migrate a VM to another Host. This can only be called when the specified VM is in the Running state. - * - * @param host The target host - * @param options Extra configuration operations - * @return Task - */ - public Task poolMigrateAsync(Connection c, Host host, Map options) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.VmIsTemplate, - Types.OperationNotAllowed, - Types.VmMigrateFailed, - Types.VmMissingPvDrivers { - String method_call = "Async.VM.pool_migrate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(options)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Migrate a VM to another Host. This can only be called when the specified VM is in the Running state. - * - * @param host The target host - * @param options Extra configuration operations - */ - public void poolMigrate(Connection c, Host host, Map options) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState, - Types.OtherOperationInProgress, - Types.VmIsTemplate, - Types.OperationNotAllowed, - Types.VmMigrateFailed, - Types.VmMissingPvDrivers { - String method_call = "VM.pool_migrate"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(options)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the number of VCPUs for a running VM - * - * @param nvcpu The number of VCPUs - * @return Task - */ - public Task setVCPUsNumberLiveAsync(Connection c, Long nvcpu) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.set_VCPUs_number_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(nvcpu)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the number of VCPUs for a running VM - * - * @param nvcpu The number of VCPUs - */ - public void setVCPUsNumberLive(Connection c, Long nvcpu) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_VCPUs_number_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(nvcpu)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to VM.VCPUs_params, and apply that value on the running VM - * - * @param key The key - * @param value The value - * @return Task - */ - public Task addToVCPUsParamsLiveAsync(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.add_to_VCPUs_params_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Add the given key-value pair to VM.VCPUs_params, and apply that value on the running VM - * - * @param key The key - * @param value The value - */ - public void addToVCPUsParamsLive(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.add_to_VCPUs_params_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the ha_restart_priority field - * - * @param value The value - */ - public void setHaRestartPriority(Connection c, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_ha_restart_priority"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the ha_always_run - * - * @param value The value - */ - public void setHaAlwaysRun(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_ha_always_run"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Computes the virtualization memory overhead of a VM. - * - * @return Task - */ - public Task computeMemoryOverheadAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.compute_memory_overhead"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Computes the virtualization memory overhead of a VM. - * - * @return the virtualization memory overhead of the VM. - */ - public Long computeMemoryOverhead(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.compute_memory_overhead"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Set the value of the memory_dynamic_max field - * - * @param value The new value of memory_dynamic_max - */ - public void setMemoryDynamicMax(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_memory_dynamic_max"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the memory_dynamic_min field - * - * @param value The new value of memory_dynamic_min - */ - public void setMemoryDynamicMin(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_memory_dynamic_min"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the minimum and maximum amounts of physical memory the VM is allowed to use. - * - * @param min The new minimum value - * @param max The new maximum value - * @return Task - */ - public Task setMemoryDynamicRangeAsync(Connection c, Long min, Long max) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.set_memory_dynamic_range"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(min), Marshalling.toXMLRPC(max)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the minimum and maximum amounts of physical memory the VM is allowed to use. - * - * @param min The new minimum value - * @param max The new maximum value - */ - public void setMemoryDynamicRange(Connection c, Long min, Long max) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_memory_dynamic_range"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(min), Marshalling.toXMLRPC(max)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the memory_static_max field - * - * @param value The new value of memory_static_max - */ - public void setMemoryStaticMax(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.HaOperationWouldBreakFailoverPlan { - String method_call = "VM.set_memory_static_max"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the memory_static_min field - * - * @param value The new value of memory_static_min - */ - public void setMemoryStaticMin(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_memory_static_min"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the static (ie boot-time) range of virtual memory that the VM is allowed to use. - * - * @param min The new minimum value - * @param max The new maximum value - * @return Task - */ - public Task setMemoryStaticRangeAsync(Connection c, Long min, Long max) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.set_memory_static_range"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(min), Marshalling.toXMLRPC(max)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the static (ie boot-time) range of virtual memory that the VM is allowed to use. - * - * @param min The new minimum value - * @param max The new maximum value - */ - public void setMemoryStaticRange(Connection c, Long min, Long max) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_memory_static_range"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(min), Marshalling.toXMLRPC(max)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the memory limits of this VM. - * - * @param staticMin The new value of memory_static_min. - * @param staticMax The new value of memory_static_max. - * @param dynamicMin The new value of memory_dynamic_min. - * @param dynamicMax The new value of memory_dynamic_max. - * @return Task - */ - public Task setMemoryLimitsAsync(Connection c, Long staticMin, Long staticMax, Long dynamicMin, Long dynamicMax) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.set_memory_limits"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(staticMin), Marshalling.toXMLRPC(staticMax), Marshalling.toXMLRPC(dynamicMin), Marshalling.toXMLRPC(dynamicMax)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the memory limits of this VM. - * - * @param staticMin The new value of memory_static_min. - * @param staticMax The new value of memory_static_max. - * @param dynamicMin The new value of memory_dynamic_min. - * @param dynamicMax The new value of memory_dynamic_max. - */ - public void setMemoryLimits(Connection c, Long staticMin, Long staticMax, Long dynamicMin, Long dynamicMax) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_memory_limits"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(staticMin), Marshalling.toXMLRPC(staticMax), Marshalling.toXMLRPC(dynamicMin), Marshalling.toXMLRPC(dynamicMax)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the memory target for a running VM - * @deprecated - * - * @param target The target in bytes - * @return Task - */ - @Deprecated public Task setMemoryTargetLiveAsync(Connection c, Long target) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.set_memory_target_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(target)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the memory target for a running VM - * @deprecated - * - * @param target The target in bytes - */ - @Deprecated public void setMemoryTargetLive(Connection c, Long target) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_memory_target_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(target)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Wait for a running VM to reach its current memory target - * @deprecated - * - * @return Task - */ - @Deprecated public Task waitMemoryTargetLiveAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.wait_memory_target_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Wait for a running VM to reach its current memory target - * @deprecated - * - */ - @Deprecated public void waitMemoryTargetLive(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.wait_memory_target_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return true if the VM is currently 'co-operative' i.e. is expected to reach a balloon target and actually has done - * - * @return Task - */ - public Task getCooperativeAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.get_cooperative"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Return true if the VM is currently 'co-operative' i.e. is expected to reach a balloon target and actually has done - * - * @return true if the VM is currently 'co-operative'; false otherwise - */ - public Boolean getCooperative(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_cooperative"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Set the shadow memory multiplier on a halted VM - * - * @param value The new shadow memory multiplier to set - */ - public void setHVMShadowMultiplier(Connection c, Double value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_HVM_shadow_multiplier"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the shadow memory multiplier on a running VM - * - * @param multiplier The new shadow memory multiplier to set - * @return Task - */ - public Task setShadowMultiplierLiveAsync(Connection c, Double multiplier) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.set_shadow_multiplier_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(multiplier)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Set the shadow memory multiplier on a running VM - * - * @param multiplier The new shadow memory multiplier to set - */ - public void setShadowMultiplierLive(Connection c, Double multiplier) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_shadow_multiplier_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(multiplier)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the maximum number of VCPUs for a halted VM - * - * @param value The new maximum number of VCPUs - */ - public void setVCPUsMax(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_VCPUs_max"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the number of startup VCPUs for a halted VM - * - * @param value The new maximum number of VCPUs - */ - public void setVCPUsAtStartup(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_VCPUs_at_startup"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Send the given key as a sysrq to this VM. The key is specified as a single character (a String of length 1). This can only be called when the specified VM is in the Running state. - * - * @param key The key to send - * @return Task - */ - public Task sendSysrqAsync(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState { - String method_call = "Async.VM.send_sysrq"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Send the given key as a sysrq to this VM. The key is specified as a single character (a String of length 1). This can only be called when the specified VM is in the Running state. - * - * @param key The key to send - */ - public void sendSysrq(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState { - String method_call = "VM.send_sysrq"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Send the named trigger to this VM. This can only be called when the specified VM is in the Running state. - * - * @param trigger The trigger to send - * @return Task - */ - public Task sendTriggerAsync(Connection c, String trigger) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState { - String method_call = "Async.VM.send_trigger"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(trigger)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Send the named trigger to this VM. This can only be called when the specified VM is in the Running state. - * - * @param trigger The trigger to send - */ - public void sendTrigger(Connection c, String trigger) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VmBadPowerState { - String method_call = "VM.send_trigger"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(trigger)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Returns the maximum amount of guest memory which will fit, together with overheads, in the supplied amount of physical memory. If 'exact' is true then an exact calculation is performed using the VM's current settings. If 'exact' is false then a more conservative approximation is used - * - * @param total Total amount of physical RAM to fit within - * @param approximate If false the limit is calculated with the guest's current exact configuration. Otherwise a more approximate calculation is performed - * @return Task - */ - public Task maximiseMemoryAsync(Connection c, Long total, Boolean approximate) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.maximise_memory"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(total), Marshalling.toXMLRPC(approximate)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Returns the maximum amount of guest memory which will fit, together with overheads, in the supplied amount of physical memory. If 'exact' is true then an exact calculation is performed using the VM's current settings. If 'exact' is false then a more conservative approximation is used - * - * @param total Total amount of physical RAM to fit within - * @param approximate If false the limit is calculated with the guest's current exact configuration. Otherwise a more approximate calculation is performed - * @return The maximum possible static-max - */ - public Long maximiseMemory(Connection c, Long total, Boolean approximate) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.maximise_memory"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(total), Marshalling.toXMLRPC(approximate)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Returns a record describing the VM's dynamic state, initialised when the VM boots and updated to reflect runtime configuration changes e.g. CPU hotplug - * - * @return A record describing the VM - */ - public VM.Record getBootRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_boot_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMRecord(result); - } - - /** - * - * - * @return A set of data sources - */ - public Set getDataSources(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_data_sources"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfDataSourceRecord(result); - } - - /** - * Start recording the specified data source - * - * @param dataSource The data source to record - */ - public void recordDataSource(Connection c, String dataSource) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.record_data_source"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Query the latest value of the specified data source - * - * @param dataSource The data source to query - * @return The latest value, averaged over the last 5 seconds - */ - public Double queryDataSource(Connection c, String dataSource) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.query_data_source"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDouble(result); - } - - /** - * Forget the recorded statistics related to the specified data source - * - * @param dataSource The data source whose archives are to be forgotten - */ - public void forgetDataSourceArchives(Connection c, String dataSource) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.forget_data_source_archives"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Check to see whether this operation is acceptable in the current state of the system, raising an error if the operation is invalid for some reason - * - * @param op proposed operation - * @return Task - */ - public Task assertOperationValidAsync(Connection c, Types.VmOperations op) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.assert_operation_valid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(op)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Check to see whether this operation is acceptable in the current state of the system, raising an error if the operation is invalid for some reason - * - * @param op proposed operation - */ - public void assertOperationValid(Connection c, Types.VmOperations op) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.assert_operation_valid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(op)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Recomputes the list of acceptable operations - * - * @return Task - */ - public Task updateAllowedOperationsAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.update_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Recomputes the list of acceptable operations - * - */ - public void updateAllowedOperations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.update_allowed_operations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Returns a list of the allowed values that a VBD device field can take - * - * @return The allowed values - */ - public Set getAllowedVBDDevices(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_allowed_VBD_devices"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Returns a list of the allowed values that a VIF device field can take - * - * @return The allowed values - */ - public Set getAllowedVIFDevices(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_allowed_VIF_devices"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Return the list of hosts on which this VM may run. - * - * @return Task - */ - public Task getPossibleHostsAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.get_possible_hosts"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Return the list of hosts on which this VM may run. - * - * @return The possible hosts - */ - public Set getPossibleHosts(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_possible_hosts"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfHost(result); - } - - /** - * Returns an error if the VM could not boot on this host for some reason - * - * @param host The host - * @return Task - */ - public Task assertCanBootHereAsync(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.HostNotEnoughFreeMemory, - Types.VmRequiresSr { - String method_call = "Async.VM.assert_can_boot_here"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Returns an error if the VM could not boot on this host for some reason - * - * @param host The host - */ - public void assertCanBootHere(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.HostNotEnoughFreeMemory, - Types.VmRequiresSr { - String method_call = "VM.assert_can_boot_here"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this VM - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return Task - */ - public Task createNewBlobAsync(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a placeholder for a named binary blob of data that is associated with this VM - * - * @param name The name associated with the blob - * @param mimeType The mime type for the data. Empty string translates to application/octet-stream - * @return The reference of the blob, needed for populating its data - */ - public Blob createNewBlob(Connection c, String name, String mimeType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.create_new_blob"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBlob(result); - } - - /** - * Returns an error if the VM is not considered agile e.g. because it is tied to a resource local to a host - * - * @return Task - */ - public Task assertAgileAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.assert_agile"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Returns an error if the VM is not considered agile e.g. because it is tied to a resource local to a host - * - */ - public void assertAgile(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.assert_agile"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Returns mapping of hosts to ratings, indicating the suitability of starting the VM at that location according to wlb. Rating is replaced with an error if the VM cannot boot there. - * - * @return Task - */ - public Task retrieveWlbRecommendationsAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.retrieve_wlb_recommendations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Returns mapping of hosts to ratings, indicating the suitability of starting the VM at that location according to wlb. Rating is replaced with an error if the VM cannot boot there. - * - * @return The potential hosts and their corresponding recommendations or errors - */ - public Map> retrieveWlbRecommendations(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.retrieve_wlb_recommendations"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfHostSetOfString(result); - } - - /** - * Copy the BIOS strings from the given host to this VM - * - * @param host The host to copy the BIOS strings from - * @return Task - */ - public Task copyBiosStringsAsync(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VM.copy_bios_strings"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Copy the BIOS strings from the given host to this VM - * - * @param host The host to copy the BIOS strings from - */ - public void copyBiosStrings(Connection c, Host host) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.copy_bios_strings"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the protection_policy field - * - * @param value The value - */ - public void setProtectionPolicy(Connection c, VMPP value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.set_protection_policy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VMs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVM(result); - } - - /** - * Return a map of VM references to VM records for all VMs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVMVMRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java deleted file mode 100644 index 8b27955df87..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java +++ /dev/null @@ -1,482 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * The metrics reported by the guest (as opposed to inferred from outside) - * - * @author Citrix Systems, Inc. - */ -public class VMGuestMetrics extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VMGuestMetrics(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VMGuestMetrics, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VMGuestMetrics) - { - VMGuestMetrics other = (VMGuestMetrics) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VMGuestMetrics - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "osVersion", this.osVersion); - print.printf("%1$20s: %2$s\n", "PVDriversVersion", this.PVDriversVersion); - print.printf("%1$20s: %2$s\n", "PVDriversUpToDate", this.PVDriversUpToDate); - print.printf("%1$20s: %2$s\n", "memory", this.memory); - print.printf("%1$20s: %2$s\n", "disks", this.disks); - print.printf("%1$20s: %2$s\n", "networks", this.networks); - print.printf("%1$20s: %2$s\n", "other", this.other); - print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - print.printf("%1$20s: %2$s\n", "live", this.live); - return writer.toString(); - } - - /** - * Convert a VM_guest_metrics.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("os_version", this.osVersion == null ? new HashMap() : this.osVersion); - map.put("PV_drivers_version", this.PVDriversVersion == null ? new HashMap() : this.PVDriversVersion); - map.put("PV_drivers_up_to_date", this.PVDriversUpToDate == null ? false : this.PVDriversUpToDate); - map.put("memory", this.memory == null ? new HashMap() : this.memory); - map.put("disks", this.disks == null ? new HashMap() : this.disks); - map.put("networks", this.networks == null ? new HashMap() : this.networks); - map.put("other", this.other == null ? new HashMap() : this.other); - map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - map.put("live", this.live == null ? false : this.live); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * version of the OS - */ - public Map osVersion; - /** - * version of the PV drivers - */ - public Map PVDriversVersion; - /** - * true if the PV drivers appear to be up to date - */ - public Boolean PVDriversUpToDate; - /** - * free/used/total memory - */ - public Map memory; - /** - * disk configuration/free space - */ - public Map disks; - /** - * network configuration - */ - public Map networks; - /** - * anything else - */ - public Map other; - /** - * Time at which this information was last updated - */ - public Date lastUpdated; - /** - * additional configuration - */ - public Map otherConfig; - /** - * True if the guest is sending heartbeat messages via the guest agent - */ - public Boolean live; - } - - /** - * Get a record containing the current state of the given VM_guest_metrics. - * - * @return all fields from the object - */ - public VMGuestMetrics.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMGuestMetricsRecord(result); - } - - /** - * Get a reference to the VM_guest_metrics instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VMGuestMetrics getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMGuestMetrics(result); - } - - /** - * Get the uuid field of the given VM_guest_metrics. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the os_version field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Map getOsVersion(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_os_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the PV_drivers_version field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Map getPVDriversVersion(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_PV_drivers_version"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the PV_drivers_up_to_date field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Boolean getPVDriversUpToDate(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_PV_drivers_up_to_date"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the memory field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Map getMemory(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_memory"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the disks field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Map getDisks(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_disks"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the networks field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Map getNetworks(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_networks"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the other field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Map getOther(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_other"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the last_updated field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Date getLastUpdated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_last_updated"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the other_config field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the live field of the given VM_guest_metrics. - * - * @return value of the field - */ - public Boolean getLive(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_live"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Set the other_config field of the given VM_guest_metrics. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VM_guest_metrics. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VM_guest_metrics. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VM_guest_metrics instances known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVMGuestMetrics(result); - } - - /** - * Return a map of VM_guest_metrics references to VM_guest_metrics records for all VM_guest_metrics instances known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_guest_metrics.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVMGuestMetricsVMGuestMetricsRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java deleted file mode 100644 index c2d35b35afa..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java +++ /dev/null @@ -1,505 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * The metrics associated with a VM - * - * @author Citrix Systems, Inc. - */ -public class VMMetrics extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VMMetrics(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VMMetrics, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VMMetrics) - { - VMMetrics other = (VMMetrics) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VMMetrics - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "memoryActual", this.memoryActual); - print.printf("%1$20s: %2$s\n", "VCPUsNumber", this.VCPUsNumber); - print.printf("%1$20s: %2$s\n", "VCPUsUtilisation", this.VCPUsUtilisation); - print.printf("%1$20s: %2$s\n", "VCPUsCPU", this.VCPUsCPU); - print.printf("%1$20s: %2$s\n", "VCPUsParams", this.VCPUsParams); - print.printf("%1$20s: %2$s\n", "VCPUsFlags", this.VCPUsFlags); - print.printf("%1$20s: %2$s\n", "state", this.state); - print.printf("%1$20s: %2$s\n", "startTime", this.startTime); - print.printf("%1$20s: %2$s\n", "installTime", this.installTime); - print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); - print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); - return writer.toString(); - } - - /** - * Convert a VM_metrics.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("memory_actual", this.memoryActual == null ? 0 : this.memoryActual); - map.put("VCPUs_number", this.VCPUsNumber == null ? 0 : this.VCPUsNumber); - map.put("VCPUs_utilisation", this.VCPUsUtilisation == null ? new HashMap() : this.VCPUsUtilisation); - map.put("VCPUs_CPU", this.VCPUsCPU == null ? new HashMap() : this.VCPUsCPU); - map.put("VCPUs_params", this.VCPUsParams == null ? new HashMap() : this.VCPUsParams); - map.put("VCPUs_flags", this.VCPUsFlags == null ? new HashMap>() : this.VCPUsFlags); - map.put("state", this.state == null ? new LinkedHashSet() : this.state); - map.put("start_time", this.startTime == null ? new Date(0) : this.startTime); - map.put("install_time", this.installTime == null ? new Date(0) : this.installTime); - map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); - map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * Guest's actual memory (bytes) - */ - public Long memoryActual; - /** - * Current number of VCPUs - */ - public Long VCPUsNumber; - /** - * Utilisation for all of guest's current VCPUs - */ - public Map VCPUsUtilisation; - /** - * VCPU to PCPU map - */ - public Map VCPUsCPU; - /** - * The live equivalent to VM.VCPUs_params - */ - public Map VCPUsParams; - /** - * CPU flags (blocked,online,running) - */ - public Map> VCPUsFlags; - /** - * The state of the guest, eg blocked, dying etc - */ - public Set state; - /** - * Time at which this VM was last booted - */ - public Date startTime; - /** - * Time at which the VM was installed - */ - public Date installTime; - /** - * Time at which this information was last updated - */ - public Date lastUpdated; - /** - * additional configuration - */ - public Map otherConfig; - } - - /** - * Get a record containing the current state of the given VM_metrics. - * - * @return all fields from the object - */ - public VMMetrics.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMMetricsRecord(result); - } - - /** - * Get a reference to the VM_metrics instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VMMetrics getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMMetrics(result); - } - - /** - * Get the uuid field of the given VM_metrics. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the memory/actual field of the given VM_metrics. - * - * @return value of the field - */ - public Long getMemoryActual(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_memory_actual"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the VCPUs/number field of the given VM_metrics. - * - * @return value of the field - */ - public Long getVCPUsNumber(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_VCPUs_number"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the VCPUs/utilisation field of the given VM_metrics. - * - * @return value of the field - */ - public Map getVCPUsUtilisation(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_VCPUs_utilisation"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfLongDouble(result); - } - - /** - * Get the VCPUs/CPU field of the given VM_metrics. - * - * @return value of the field - */ - public Map getVCPUsCPU(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_VCPUs_CPU"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfLongLong(result); - } - - /** - * Get the VCPUs/params field of the given VM_metrics. - * - * @return value of the field - */ - public Map getVCPUsParams(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_VCPUs_params"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the VCPUs/flags field of the given VM_metrics. - * - * @return value of the field - */ - public Map> getVCPUsFlags(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_VCPUs_flags"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfLongSetOfString(result); - } - - /** - * Get the state field of the given VM_metrics. - * - * @return value of the field - */ - public Set getState(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_state"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Get the start_time field of the given VM_metrics. - * - * @return value of the field - */ - public Date getStartTime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_start_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the install_time field of the given VM_metrics. - * - * @return value of the field - */ - public Date getInstallTime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_install_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the last_updated field of the given VM_metrics. - * - * @return value of the field - */ - public Date getLastUpdated(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_last_updated"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the other_config field of the given VM_metrics. - * - * @return value of the field - */ - public Map getOtherConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Set the other_config field of the given VM_metrics. - * - * @param otherConfig New value to set - */ - public void setOtherConfig(Connection c, Map otherConfig) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.set_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Add the given key-value pair to the other_config field of the given VM_metrics. - * - * @param key Key to add - * @param value Value to add - */ - public void addToOtherConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.add_to_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Remove the given key and its corresponding value from the other_config field of the given VM_metrics. If the key is not in that Map, then do nothing. - * - * @param key Key to remove - */ - public void removeFromOtherConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.remove_from_other_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VM_metrics instances known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVMMetrics(result); - } - - /** - * Return a map of VM_metrics references to VM_metrics records for all VM_metrics instances known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VM_metrics.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVMMetricsVMMetricsRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VMPP.java b/deps/XenServerJava/src/com/xensource/xenapi/VMPP.java deleted file mode 100644 index aeb0d03fdbe..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VMPP.java +++ /dev/null @@ -1,1153 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * VM Protection Policy - * - * @author Citrix Systems, Inc. - */ -public class VMPP extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VMPP(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VMPP, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VMPP) - { - VMPP other = (VMPP) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VMPP - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); - print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); - print.printf("%1$20s: %2$s\n", "isPolicyEnabled", this.isPolicyEnabled); - print.printf("%1$20s: %2$s\n", "backupType", this.backupType); - print.printf("%1$20s: %2$s\n", "backupRetentionValue", this.backupRetentionValue); - print.printf("%1$20s: %2$s\n", "backupFrequency", this.backupFrequency); - print.printf("%1$20s: %2$s\n", "backupSchedule", this.backupSchedule); - print.printf("%1$20s: %2$s\n", "isBackupRunning", this.isBackupRunning); - print.printf("%1$20s: %2$s\n", "backupLastRunTime", this.backupLastRunTime); - print.printf("%1$20s: %2$s\n", "archiveTargetType", this.archiveTargetType); - print.printf("%1$20s: %2$s\n", "archiveTargetConfig", this.archiveTargetConfig); - print.printf("%1$20s: %2$s\n", "archiveFrequency", this.archiveFrequency); - print.printf("%1$20s: %2$s\n", "archiveSchedule", this.archiveSchedule); - print.printf("%1$20s: %2$s\n", "isArchiveRunning", this.isArchiveRunning); - print.printf("%1$20s: %2$s\n", "archiveLastRunTime", this.archiveLastRunTime); - print.printf("%1$20s: %2$s\n", "VMs", this.VMs); - print.printf("%1$20s: %2$s\n", "isAlarmEnabled", this.isAlarmEnabled); - print.printf("%1$20s: %2$s\n", "alarmConfig", this.alarmConfig); - print.printf("%1$20s: %2$s\n", "recentAlerts", this.recentAlerts); - return writer.toString(); - } - - /** - * Convert a VMPP.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); - map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); - map.put("is_policy_enabled", this.isPolicyEnabled == null ? false : this.isPolicyEnabled); - map.put("backup_type", this.backupType == null ? Types.VmppBackupType.UNRECOGNIZED : this.backupType); - map.put("backup_retention_value", this.backupRetentionValue == null ? 0 : this.backupRetentionValue); - map.put("backup_frequency", this.backupFrequency == null ? Types.VmppBackupFrequency.UNRECOGNIZED : this.backupFrequency); - map.put("backup_schedule", this.backupSchedule == null ? new HashMap() : this.backupSchedule); - map.put("is_backup_running", this.isBackupRunning == null ? false : this.isBackupRunning); - map.put("backup_last_run_time", this.backupLastRunTime == null ? new Date(0) : this.backupLastRunTime); - map.put("archive_target_type", this.archiveTargetType == null ? Types.VmppArchiveTargetType.UNRECOGNIZED : this.archiveTargetType); - map.put("archive_target_config", this.archiveTargetConfig == null ? new HashMap() : this.archiveTargetConfig); - map.put("archive_frequency", this.archiveFrequency == null ? Types.VmppArchiveFrequency.UNRECOGNIZED : this.archiveFrequency); - map.put("archive_schedule", this.archiveSchedule == null ? new HashMap() : this.archiveSchedule); - map.put("is_archive_running", this.isArchiveRunning == null ? false : this.isArchiveRunning); - map.put("archive_last_run_time", this.archiveLastRunTime == null ? new Date(0) : this.archiveLastRunTime); - map.put("VMs", this.VMs == null ? new LinkedHashSet() : this.VMs); - map.put("is_alarm_enabled", this.isAlarmEnabled == null ? false : this.isAlarmEnabled); - map.put("alarm_config", this.alarmConfig == null ? new HashMap() : this.alarmConfig); - map.put("recent_alerts", this.recentAlerts == null ? new LinkedHashSet() : this.recentAlerts); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * a human-readable name - */ - public String nameLabel; - /** - * a notes field containg human-readable description - */ - public String nameDescription; - /** - * enable or disable this policy - */ - public Boolean isPolicyEnabled; - /** - * type of the backup sub-policy - */ - public Types.VmppBackupType backupType; - /** - * maximum number of backups that should be stored at any time - */ - public Long backupRetentionValue; - /** - * frequency of the backup schedule - */ - public Types.VmppBackupFrequency backupFrequency; - /** - * schedule of the backup containing 'hour', 'min', 'days'. Date/time-related information is in XenServer Local Timezone - */ - public Map backupSchedule; - /** - * true if this protection policy's backup is running - */ - public Boolean isBackupRunning; - /** - * time of the last backup - */ - public Date backupLastRunTime; - /** - * type of the archive target config - */ - public Types.VmppArchiveTargetType archiveTargetType; - /** - * configuration for the archive, including its 'location', 'username', 'password' - */ - public Map archiveTargetConfig; - /** - * frequency of the archive schedule - */ - public Types.VmppArchiveFrequency archiveFrequency; - /** - * schedule of the archive containing 'hour', 'min', 'days'. Date/time-related information is in XenServer Local Timezone - */ - public Map archiveSchedule; - /** - * true if this protection policy's archive is running - */ - public Boolean isArchiveRunning; - /** - * time of the last archive - */ - public Date archiveLastRunTime; - /** - * all VMs attached to this protection policy - */ - public Set VMs; - /** - * true if alarm is enabled for this policy - */ - public Boolean isAlarmEnabled; - /** - * configuration for the alarm - */ - public Map alarmConfig; - /** - * recent alerts - */ - public Set recentAlerts; - } - - /** - * Get a record containing the current state of the given VMPP. - * - * @return all fields from the object - */ - public VMPP.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMPPRecord(result); - } - - /** - * Get a reference to the VMPP instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VMPP getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMPP(result); - } - - /** - * Create a new VMPP instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, VMPP.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VMPP.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new VMPP instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static VMPP create(Connection c, VMPP.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVMPP(result); - } - - /** - * Destroy the specified VMPP instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VMPP.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified VMPP instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get all the VMPP instances with the given label. - * - * @param label label of object to return - * @return references to objects with matching names - */ - public static Set getByNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_by_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVMPP(result); - } - - /** - * Get the uuid field of the given VMPP. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/label field of the given VMPP. - * - * @return value of the field - */ - public String getNameLabel(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the name/description field of the given VMPP. - * - * @return value of the field - */ - public String getNameDescription(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the is_policy_enabled field of the given VMPP. - * - * @return value of the field - */ - public Boolean getIsPolicyEnabled(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_is_policy_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the backup_type field of the given VMPP. - * - * @return value of the field - */ - public Types.VmppBackupType getBackupType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_backup_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVmppBackupType(result); - } - - /** - * Get the backup_retention_value field of the given VMPP. - * - * @return value of the field - */ - public Long getBackupRetentionValue(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_backup_retention_value"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toLong(result); - } - - /** - * Get the backup_frequency field of the given VMPP. - * - * @return value of the field - */ - public Types.VmppBackupFrequency getBackupFrequency(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_backup_frequency"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVmppBackupFrequency(result); - } - - /** - * Get the backup_schedule field of the given VMPP. - * - * @return value of the field - */ - public Map getBackupSchedule(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_backup_schedule"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the is_backup_running field of the given VMPP. - * - * @return value of the field - */ - public Boolean getIsBackupRunning(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_is_backup_running"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the backup_last_run_time field of the given VMPP. - * - * @return value of the field - */ - public Date getBackupLastRunTime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_backup_last_run_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the archive_target_type field of the given VMPP. - * - * @return value of the field - */ - public Types.VmppArchiveTargetType getArchiveTargetType(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_archive_target_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVmppArchiveTargetType(result); - } - - /** - * Get the archive_target_config field of the given VMPP. - * - * @return value of the field - */ - public Map getArchiveTargetConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_archive_target_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the archive_frequency field of the given VMPP. - * - * @return value of the field - */ - public Types.VmppArchiveFrequency getArchiveFrequency(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_archive_frequency"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVmppArchiveFrequency(result); - } - - /** - * Get the archive_schedule field of the given VMPP. - * - * @return value of the field - */ - public Map getArchiveSchedule(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_archive_schedule"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the is_archive_running field of the given VMPP. - * - * @return value of the field - */ - public Boolean getIsArchiveRunning(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_is_archive_running"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the archive_last_run_time field of the given VMPP. - * - * @return value of the field - */ - public Date getArchiveLastRunTime(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_archive_last_run_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toDate(result); - } - - /** - * Get the VMs field of the given VMPP. - * - * @return value of the field - */ - public Set getVMs(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_VMs"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVM(result); - } - - /** - * Get the is_alarm_enabled field of the given VMPP. - * - * @return value of the field - */ - public Boolean getIsAlarmEnabled(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_is_alarm_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toBoolean(result); - } - - /** - * Get the alarm_config field of the given VMPP. - * - * @return value of the field - */ - public Map getAlarmConfig(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_alarm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfStringString(result); - } - - /** - * Get the recent_alerts field of the given VMPP. - * - * @return value of the field - */ - public Set getRecentAlerts(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_recent_alerts"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * Set the name/label field of the given VMPP. - * - * @param label New value to set - */ - public void setNameLabel(Connection c, String label) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_name_label"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the name/description field of the given VMPP. - * - * @param description New value to set - */ - public void setNameDescription(Connection c, String description) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_name_description"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the is_policy_enabled field of the given VMPP. - * - * @param isPolicyEnabled New value to set - */ - public void setIsPolicyEnabled(Connection c, Boolean isPolicyEnabled) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_is_policy_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(isPolicyEnabled)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the backup_type field of the given VMPP. - * - * @param backupType New value to set - */ - public void setBackupType(Connection c, Types.VmppBackupType backupType) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_backup_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(backupType)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * This call executes the protection policy immediately - * - * @return An XMLRPC result - */ - public String protectNow(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.protect_now"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * This call archives the snapshot provided as a parameter - * - * @param snapshot The snapshot to archive - * @return An XMLRPC result - */ - public static String archiveNow(Connection c, VM snapshot) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.archive_now"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(snapshot)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * This call fetches a history of alerts for a given protection policy - * - * @param hoursFromNow how many hours in the past the oldest record to fetch is - * @return A list of alerts encoded in xml - */ - public Set getAlerts(Connection c, Long hoursFromNow) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_alerts"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(hoursFromNow)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfString(result); - } - - /** - * - * - * @param value the value to set - */ - public void setBackupRetentionValue(Connection c, Long value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_backup_retention_value"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the backup_frequency field - * - * @param value the backup frequency - */ - public void setBackupFrequency(Connection c, Types.VmppBackupFrequency value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_backup_frequency"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param value the value to set - */ - public void setBackupSchedule(Connection c, Map value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_backup_schedule"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the archive_frequency field - * - * @param value the archive frequency - */ - public void setArchiveFrequency(Connection c, Types.VmppArchiveFrequency value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_archive_frequency"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param value the value to set - */ - public void setArchiveSchedule(Connection c, Map value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_archive_schedule"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the archive_target_config_type field - * - * @param value the archive target config type - */ - public void setArchiveTargetType(Connection c, Types.VmppArchiveTargetType value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_archive_target_type"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param value the value to set - */ - public void setArchiveTargetConfig(Connection c, Map value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_archive_target_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Set the value of the is_alarm_enabled field - * - * @param value true if alarm is enabled for this policy - */ - public void setIsAlarmEnabled(Connection c, Boolean value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_is_alarm_enabled"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param value the value to set - */ - public void setAlarmConfig(Connection c, Map value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_alarm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param key the key to add - * @param value the value to add - */ - public void addToBackupSchedule(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.add_to_backup_schedule"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param key the key to add - * @param value the value to add - */ - public void addToArchiveTargetConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.add_to_archive_target_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param key the key to add - * @param value the value to add - */ - public void addToArchiveSchedule(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.add_to_archive_schedule"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param key the key to add - * @param value the value to add - */ - public void addToAlarmConfig(Connection c, String key, String value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.add_to_alarm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param key the key to remove - */ - public void removeFromBackupSchedule(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.remove_from_backup_schedule"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param key the key to remove - */ - public void removeFromArchiveTargetConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.remove_from_archive_target_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param key the key to remove - */ - public void removeFromArchiveSchedule(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.remove_from_archive_schedule"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param key the key to remove - */ - public void removeFromAlarmConfig(Connection c, String key) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.remove_from_alarm_config"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param value the value to set - */ - public void setBackupLastRunTime(Connection c, Date value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_backup_last_run_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * - * - * @param value the value to set - */ - public void setArchiveLastRunTime(Connection c, Date value) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.set_archive_last_run_time"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Return a list of all the VMPPs known to the system. - * - * @return references to all objects - */ - public static Set getAll(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_all"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toSetOfVMPP(result); - } - - /** - * Return a map of VMPP references to VMPP records for all VMPPs known to the system. - * - * @return records of all objects - */ - public static Map getAllRecords(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VMPP.get_all_records"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toMapOfVMPPVMPPRecord(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VTPM.java b/deps/XenServerJava/src/com/xensource/xenapi/VTPM.java deleted file mode 100644 index c82fa3f4606..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VTPM.java +++ /dev/null @@ -1,285 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -import com.xensource.xenapi.Types.BadServerResponse; -import com.xensource.xenapi.Types.VersionException; -import com.xensource.xenapi.Types.XenAPIException; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import org.apache.xmlrpc.XmlRpcException; - -/** - * A virtual TPM device - * - * @author Citrix Systems, Inc. - */ -public class VTPM extends XenAPIObject { - - /** - * The XenAPI reference to this object. - */ - protected final String ref; - - /** - * For internal use only. - */ - VTPM(String ref) { - this.ref = ref; - } - - public String toWireString() { - return this.ref; - } - - /** - * If obj is a VTPM, compares XenAPI references for equality. - */ - @Override - public boolean equals(Object obj) - { - if (obj != null && obj instanceof VTPM) - { - VTPM other = (VTPM) obj; - return other.ref.equals(this.ref); - } else - { - return false; - } - } - - @Override - public int hashCode() - { - return ref.hashCode(); - } - - /** - * Represents all the fields in a VTPM - */ - public static class Record implements Types.Record { - public String toString() { - StringWriter writer = new StringWriter(); - PrintWriter print = new PrintWriter(writer); - print.printf("%1$20s: %2$s\n", "uuid", this.uuid); - print.printf("%1$20s: %2$s\n", "VM", this.VM); - print.printf("%1$20s: %2$s\n", "backend", this.backend); - return writer.toString(); - } - - /** - * Convert a VTPM.Record to a Map - */ - public Map toMap() { - Map map = new HashMap(); - map.put("uuid", this.uuid == null ? "" : this.uuid); - map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); - map.put("backend", this.backend == null ? new VM("OpaqueRef:NULL") : this.backend); - return map; - } - - /** - * Unique identifier/object reference - */ - public String uuid; - /** - * the virtual machine - */ - public VM VM; - /** - * the domain where the backend is located - */ - public VM backend; - } - - /** - * Get a record containing the current state of the given VTPM. - * - * @return all fields from the object - */ - public VTPM.Record getRecord(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VTPM.get_record"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVTPMRecord(result); - } - - /** - * Get a reference to the VTPM instance with the specified UUID. - * - * @param uuid UUID of object to return - * @return reference to the object - */ - public static VTPM getByUuid(Connection c, String uuid) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VTPM.get_by_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVTPM(result); - } - - /** - * Create a new VTPM instance, and return its handle. - * - * @param record All constructor arguments - * @return Task - */ - public static Task createAsync(Connection c, VTPM.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VTPM.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Create a new VTPM instance, and return its handle. - * - * @param record All constructor arguments - * @return reference to the newly created object - */ - public static VTPM create(Connection c, VTPM.Record record) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VTPM.create"; - String session = c.getSessionReference(); - Map record_map = record.toMap(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVTPM(result); - } - - /** - * Destroy the specified VTPM instance. - * - * @return Task - */ - public Task destroyAsync(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "Async.VTPM.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toTask(result); - } - - /** - * Destroy the specified VTPM instance. - * - */ - public void destroy(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VTPM.destroy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - return; - } - - /** - * Get the uuid field of the given VTPM. - * - * @return value of the field - */ - public String getUuid(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VTPM.get_uuid"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toString(result); - } - - /** - * Get the VM field of the given VTPM. - * - * @return value of the field - */ - public VM getVM(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VTPM.get_VM"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - - /** - * Get the backend field of the given VTPM. - * - * @return value of the field - */ - public VM getBackend(Connection c) throws - BadServerResponse, - XenAPIException, - XmlRpcException { - String method_call = "VTPM.get_backend"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; - Map response = c.dispatch(method_call, method_params); - Object result = response.get("Value"); - return Types.toVM(result); - } - -} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java b/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java deleted file mode 100644 index b500024255b..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) Citrix Systems, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1) Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2) Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package com.xensource.xenapi; - -public abstract class XenAPIObject -{ - public abstract String toWireString(); -} From 2ce2645cd1b1897f79c2ec7f33ece11ca11d8bff Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Thu, 13 Dec 2012 09:41:49 -0500 Subject: [PATCH 078/145] CLOUDSTACK-594: Updating the XenServer java bindings used in cloudstack - part2 Updating the xenserver java bindings used in cloudstack. This is part 2 of the change and it introduces the latest java bindings published with XenServer 6.1. 1. https://reviews.apache.org/r/8566/ - removes the old bindings. 2. https://reviews.apache.org/r/8567/ - introduces the latest bindings. 3. https://reviews.apache.org/r/8568/ - adds the customization's made to them for cloudstack. Signed-off-by: Chip Childers --- .../src/com/xensource/xenapi/APIVersion.java | 118 + .../src/com/xensource/xenapi/Auth.java | 114 + .../src/com/xensource/xenapi/Blob.java | 446 + .../src/com/xensource/xenapi/Bond.java | 564 + .../src/com/xensource/xenapi/Connection.java | 380 + .../src/com/xensource/xenapi/Console.java | 419 + .../src/com/xensource/xenapi/Crashdump.java | 358 + .../src/com/xensource/xenapi/DRTask.java | 303 + .../src/com/xensource/xenapi/DataSource.java | 164 + .../src/com/xensource/xenapi/Event.java | 304 + .../src/com/xensource/xenapi/GPUGroup.java | 445 + .../src/com/xensource/xenapi/Host.java | 2919 ++++ .../src/com/xensource/xenapi/HostCpu.java | 536 + .../com/xensource/xenapi/HostCrashdump.java | 417 + .../src/com/xensource/xenapi/HostMetrics.java | 373 + .../src/com/xensource/xenapi/HostPatch.java | 552 + .../src/com/xensource/xenapi/Marshalling.java | 76 + .../src/com/xensource/xenapi/Message.java | 320 + .../src/com/xensource/xenapi/Network.java | 791 + .../src/com/xensource/xenapi/PBD.java | 542 + .../src/com/xensource/xenapi/PCI.java | 418 + .../src/com/xensource/xenapi/PGPU.java | 349 + .../src/com/xensource/xenapi/PIF.java | 1374 ++ .../src/com/xensource/xenapi/PIFMetrics.java | 533 + .../src/com/xensource/xenapi/Pool.java | 2324 +++ .../src/com/xensource/xenapi/PoolPatch.java | 693 + .../src/com/xensource/xenapi/Role.java | 364 + .../src/com/xensource/xenapi/SM.java | 528 + .../src/com/xensource/xenapi/SR.java | 1639 ++ .../src/com/xensource/xenapi/Secret.java | 389 + .../src/com/xensource/xenapi/Session.java | 675 + .../src/com/xensource/xenapi/Subject.java | 396 + .../src/com/xensource/xenapi/Task.java | 688 + .../src/com/xensource/xenapi/Tunnel.java | 474 + .../src/com/xensource/xenapi/Types.java | 13057 ++++++++++++++++ .../src/com/xensource/xenapi/User.java | 384 + .../src/com/xensource/xenapi/VBD.java | 1161 ++ .../src/com/xensource/xenapi/VBDMetrics.java | 349 + .../src/com/xensource/xenapi/VDI.java | 2100 +++ .../src/com/xensource/xenapi/VGPU.java | 446 + .../src/com/xensource/xenapi/VIF.java | 1186 ++ .../src/com/xensource/xenapi/VIFMetrics.java | 349 + .../src/com/xensource/xenapi/VLAN.java | 421 + .../src/com/xensource/xenapi/VM.java | 4891 ++++++ .../src/com/xensource/xenapi/VMAppliance.java | 655 + .../com/xensource/xenapi/VMGuestMetrics.java | 487 + .../src/com/xensource/xenapi/VMMetrics.java | 510 + .../src/com/xensource/xenapi/VMPP.java | 1158 ++ .../src/com/xensource/xenapi/VTPM.java | 290 + .../com/xensource/xenapi/XenAPIObject.java | 35 + 50 files changed, 48464 insertions(+) create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Auth.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Blob.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Bond.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Connection.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Console.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/DRTask.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/DataSource.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Event.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/GPUGroup.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Host.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Message.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Network.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PBD.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PCI.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PGPU.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PIF.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Pool.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Role.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/SM.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/SR.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Secret.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Session.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Subject.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Task.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/Types.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/User.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VBD.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VDI.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VGPU.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VIF.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VLAN.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VM.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VMAppliance.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VMPP.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/VTPM.java create mode 100644 deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java diff --git a/deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java b/deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java new file mode 100644 index 00000000000..174cf5ad581 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java @@ -0,0 +1,118 @@ +/* Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.xensource.xenapi; + +public enum APIVersion +{ + API_1_1, API_1_2, API_1_3, API_1_4, API_1_5, API_1_6, API_1_7, API_1_8, API_1_9, API_1_10, UNKNOWN; + + public static APIVersion latest() + { + return API_1_10; + } + + public static APIVersion fromMajorMinor(long major, long minor) + { + if (major == 1 && minor == 10) + { + return API_1_10; + } + else if (major == 1 && minor == 9) + { + return API_1_9; + } + else if (major == 1 && minor == 8) + { + return API_1_8; + } + else if (major == 1 && minor == 7) + { + return API_1_7; + } + else if (major == 1 && minor == 6) + { + return API_1_6; + } + else if (major == 1 && minor == 5) + { + return API_1_5; + } + else if (major == 1 && minor == 4) + { + return API_1_4; + } + else if (major == 1 && minor == 3) + { + return API_1_3; + } + else if (major == 1 && minor == 2) + { + return API_1_2; + } + else if (major == 1 && minor == 1) + { + return API_1_1; + } + else + { + return UNKNOWN; + } + } + + @Override + public String toString() + { + switch (this) + { + case API_1_1: + return "1.1"; + case API_1_2: + return "1.2"; + case API_1_3: + return "1.3"; + case API_1_4: + return "1.4"; + case API_1_5: + return "1.5"; + case API_1_6: + return "1.6"; + case API_1_7: + return "1.7"; + case API_1_8: + return "1.8"; + case API_1_9: + return "1.9"; + case API_1_10: + return "1.10"; + default: + return "Unknown"; + } + } +} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Auth.java b/deps/XenServerJava/src/com/xensource/xenapi/Auth.java new file mode 100644 index 00000000000..fd84390d2a5 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Auth.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * Management of remote authentication services + * + * @author Citrix Systems, Inc. + */ +public class Auth extends XenAPIObject { + + + public String toWireString() { + return null; + } + + /** + * This call queries the external directory service to obtain the subject_identifier as a string from the human-readable subject_name + * + * @param subjectName The human-readable subject_name, such as a username or a groupname + * @return the subject_identifier obtained from the external directory service + */ + public static String getSubjectIdentifier(Connection c, String subjectName) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "auth.get_subject_identifier"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * This call queries the external directory service to obtain the user information (e.g. username, organization etc) from the specified subject_identifier + * + * @param subjectIdentifier A string containing the subject_identifier, unique in the external directory service + * @return key-value pairs containing at least a key called subject_name + */ + public static Map getSubjectInformationFromIdentifier(Connection c, String subjectIdentifier) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "auth.get_subject_information_from_identifier"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * This calls queries the external directory service to obtain the transitively-closed set of groups that the the subject_identifier is member of. + * + * @param subjectIdentifier A string containing the subject_identifier, unique in the external directory service + * @return set of subject_identifiers that provides the group membership of subject_identifier passed as argument, it contains, recursively, all groups a subject_identifier is member of. + */ + public static Set getGroupMembership(Connection c, String subjectIdentifier) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "auth.get_group_membership"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Blob.java b/deps/XenServerJava/src/com/xensource/xenapi/Blob.java new file mode 100644 index 00000000000..eeff12e709b --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Blob.java @@ -0,0 +1,446 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A placeholder for a binary blob + * + * @author Citrix Systems, Inc. + */ +public class Blob extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Blob(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Blob, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Blob) + { + Blob other = (Blob) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Blob + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "size", this.size); + print.printf("%1$20s: %2$s\n", "_public", this._public); + print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); + print.printf("%1$20s: %2$s\n", "mimeType", this.mimeType); + return writer.toString(); + } + + /** + * Convert a blob.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("size", this.size == null ? 0 : this.size); + map.put("public", this._public == null ? false : this._public); + map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); + map.put("mime_type", this.mimeType == null ? "" : this.mimeType); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * Size of the binary data, in bytes + */ + public Long size; + /** + * True if the blob is publicly accessible + */ + public Boolean _public; + /** + * Time at which the data in the blob was last updated + */ + public Date lastUpdated; + /** + * The mime type associated with this object. Defaults to 'application/octet-stream' if the empty string is supplied + */ + public String mimeType; + } + + /** + * Get a record containing the current state of the given blob. + * + * @return all fields from the object + */ + public Blob.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBlobRecord(result); + } + + /** + * Get a reference to the blob instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Blob getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBlob(result); + } + + /** + * Get all the blob instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfBlob(result); + } + + /** + * Get the uuid field of the given blob. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given blob. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given blob. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the size field of the given blob. + * + * @return value of the field + */ + public Long getSize(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_size"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the public field of the given blob. + * + * @return value of the field + */ + public Boolean getPublic(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_public"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the last_updated field of the given blob. + * + * @return value of the field + */ + public Date getLastUpdated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_last_updated"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the mime_type field of the given blob. + * + * @return value of the field + */ + public String getMimeType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_mime_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Set the name/label field of the given blob. + * + * @param label New value to set + */ + public void setNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name/description field of the given blob. + * + * @param description New value to set + */ + public void setNameDescription(Connection c, String description) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the public field of the given blob. + * + * @param _public New value to set + */ + public void setPublic(Connection c, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.set_public"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a placeholder for a binary blob + * + * @param mimeType The mime-type of the blob. Defaults to 'application/octet-stream' if the empty string is supplied + * @param _public True if the blob should be publicly available + * @return The reference to the created blob + */ + public static Blob create(Connection c, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBlob(result); + } + + /** + * + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the blobs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfBlob(result); + } + + /** + * Return a map of blob references to blob records for all blobs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "blob.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfBlobBlobRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Bond.java b/deps/XenServerJava/src/com/xensource/xenapi/Bond.java new file mode 100644 index 00000000000..d9d30459e6e --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Bond.java @@ -0,0 +1,564 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * + * + * @author Citrix Systems, Inc. + */ +public class Bond extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Bond(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Bond, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Bond) + { + Bond other = (Bond) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Bond + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "master", this.master); + print.printf("%1$20s: %2$s\n", "slaves", this.slaves); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "primarySlave", this.primarySlave); + print.printf("%1$20s: %2$s\n", "mode", this.mode); + print.printf("%1$20s: %2$s\n", "properties", this.properties); + print.printf("%1$20s: %2$s\n", "linksUp", this.linksUp); + return writer.toString(); + } + + /** + * Convert a Bond.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("master", this.master == null ? new PIF("OpaqueRef:NULL") : this.master); + map.put("slaves", this.slaves == null ? new LinkedHashSet() : this.slaves); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("primary_slave", this.primarySlave == null ? new PIF("OpaqueRef:NULL") : this.primarySlave); + map.put("mode", this.mode == null ? Types.BondMode.UNRECOGNIZED : this.mode); + map.put("properties", this.properties == null ? new HashMap() : this.properties); + map.put("links_up", this.linksUp == null ? 0 : this.linksUp); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * The bonded interface + */ + public PIF master; + /** + * The interfaces which are part of this bond + */ + public Set slaves; + /** + * additional configuration + */ + public Map otherConfig; + /** + * The PIF of which the IP configuration and MAC were copied to the bond, and which will receive all configuration/VLANs/VIFs on the bond if the bond is destroyed + */ + public PIF primarySlave; + /** + * The algorithm used to distribute traffic among the bonded NICs + */ + public Types.BondMode mode; + /** + * Additional configuration properties specific to the bond mode. + */ + public Map properties; + /** + * Number of links up in this bond + */ + public Long linksUp; + } + + /** + * Get a record containing the current state of the given Bond. + * + * @return all fields from the object + */ + public Bond.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBondRecord(result); + } + + /** + * Get a reference to the Bond instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Bond getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBond(result); + } + + /** + * Get the uuid field of the given Bond. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the master field of the given Bond. + * + * @return value of the field + */ + public PIF getMaster(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_master"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Get the slaves field of the given Bond. + * + * @return value of the field + */ + public Set getSlaves(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_slaves"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPIF(result); + } + + /** + * Get the other_config field of the given Bond. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the primary_slave field of the given Bond. + * + * @return value of the field + */ + public PIF getPrimarySlave(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_primary_slave"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Get the mode field of the given Bond. + * + * @return value of the field + */ + public Types.BondMode getMode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBondMode(result); + } + + /** + * Get the properties field of the given Bond. + * + * @return value of the field + */ + public Map getProperties(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_properties"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the links_up field of the given Bond. + * + * @return value of the field + */ + public Long getLinksUp(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_links_up"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Set the other_config field of the given Bond. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given Bond. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given Bond. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create an interface bond + * + * @param network Network to add the bonded PIF to + * @param members PIFs to add to this bond + * @param MAC The MAC address to use on the bond itself. If this parameter is the empty string then the bond will inherit its MAC address from the primary slave. + * @param mode Bonding mode to use for the new bond + * @param properties Additional configuration parameters specific to the bond mode + * @return Task + */ + public static Task createAsync(Connection c, Network network, Set members, String MAC, Types.BondMode mode, Map properties) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.Bond.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(members), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(properties)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create an interface bond + * + * @param network Network to add the bonded PIF to + * @param members PIFs to add to this bond + * @param MAC The MAC address to use on the bond itself. If this parameter is the empty string then the bond will inherit its MAC address from the primary slave. + * @param mode Bonding mode to use for the new bond + * @param properties Additional configuration parameters specific to the bond mode + * @return The reference of the created Bond object + */ + public static Bond create(Connection c, Network network, Set members, String MAC, Types.BondMode mode, Map properties) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(members), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(properties)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBond(result); + } + + /** + * Destroy an interface bond + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.Bond.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy an interface bond + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Change the bond mode + * + * @param value The new bond mode + * @return Task + */ + public Task setModeAsync(Connection c, Types.BondMode value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.Bond.set_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Change the bond mode + * + * @param value The new bond mode + */ + public void setMode(Connection c, Types.BondMode value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.set_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of a property of the bond + * + * @param name The property name + * @param value The property value + * @return Task + */ + public Task setPropertyAsync(Connection c, String name, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.Bond.set_property"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the value of a property of the bond + * + * @param name The property name + * @param value The property value + */ + public void setProperty(Connection c, String name, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.set_property"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the Bonds known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfBond(result); + } + + /** + * Return a map of Bond references to Bond records for all Bonds known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Bond.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfBondBondRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Connection.java b/deps/XenServerJava/src/com/xensource/xenapi/Connection.java new file mode 100644 index 00000000000..805ddd01137 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Connection.java @@ -0,0 +1,380 @@ +/* Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.xensource.xenapi; + +import java.net.URL; +import java.util.Map; +import java.util.TimeZone; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfig; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.apache.xmlrpc.client.XmlRpcHttpClientConfig; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.SessionAuthenticationFailed; +import com.xensource.xenapi.Types.XenAPIException; + +/** + * Represents a connection to a XenServer. Creating a new instance of this class initialises a new XmlRpcClient that is + * then used by all method calls: each method call in xenapi takes a Connection as a parameter, composes an XMLRPC + * method call, and dispatches it on the Connection's client via the dispatch method. + */ +public class Connection +{ + /** + * The version of the bindings that this class belongs to. + */ + public static final String BINDINGS_VERSION = "6.1.0-1"; + + /** + * true if the connection is to the Rio edition of XenServer. Certain function calls are not allowed. + * + * @deprecated Use getAPIVersion() instead. + */ + @Deprecated + public Boolean rioConnection = false; + + private APIVersion apiVersion; + + /** + * Updated when Session.login_with_password() is called. + */ + public APIVersion getAPIVersion() + { + return apiVersion; + } + + /** + * The opaque reference to the session used by this connection + */ + private String sessionReference; + + /** + * As seen by the xmlrpc library. From our point of view it's a server. + */ + private final XmlRpcClient client; + + private final boolean deprecatedConstructorUsed; + + /** + * Creates a connection to a particular server using a given username and password. This object can then be passed + * in to any other API calls. + * + * This constructor calls Session.loginWithPassword, passing itself as the first parameter. + * + * When this constructor is used, a call to dispose() (also called in the Connection's finalizer) will attempt a + * Session.logout on this connection. + * + * @deprecated Use a constructor that takes a URL as the first parameter instead. + */ + @Deprecated + public Connection(String client, String username, String password) throws java.net.MalformedURLException, + XmlRpcException, BadServerResponse, SessionAuthenticationFailed, XenAPIException + { + deprecatedConstructorUsed = true; + + // To login normally we call login_with_password(username, password, "1.X"). On rio this call fails and we + // should use login_with_password(username,password) instead, and note that we are talking to a rio host so that we + // can refuse to make certain miami-specific calls + final String ApiVersion = APIVersion.latest().toString(); + this.client = getClientFromURL(new URL(client)); + try + { + //first try to login the modern way + this.sessionReference = loginWithPassword(this.client, username, password, ApiVersion); + } catch (BadServerResponse e) + { + //oops, something went wrong + String[] errDesc = e.errorDescription; + //was the problem that the host was running rio? If so it will have complained that it got three parameters + //instead of two. Let us carefully verify the details of this complaint + if (0 == errDesc[0].compareTo("MESSAGE_PARAMETER_COUNT_MISMATCH") + && 0 == errDesc[1].compareTo("session.login_with_password") + && 0 == errDesc[2].compareTo("2") + && 0 == errDesc[3].compareTo("3")) + { + //and if so, we can have another go, using the older login method, and see how that goes. + this.sessionReference = loginWithPassword(this.client, username, password); + //success!. Note that we are talking to an old host on this connection + this.rioConnection = true; + } else + { + //Hmm... Can't solve this here. Let upstairs know about the problem. + throw e; + } + } + + try + { + setAPIVersion(new Session(sessionReference)); + } + catch (XenAPIException exn) + { + dispose(); + throw exn; + } + catch (XmlRpcException exn) + { + dispose(); + throw exn; + } + } + + /** + * Creates a connection to a particular server using a given username and password. This object can then be passed + * in to any other API calls. + * + * Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it, + * passing the Connection as a parameter. No attempt to connect to the server is made until login is called. + * + * When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually + * logging out the Session. + */ + public Connection(URL url) + { + deprecatedConstructorUsed = false; + + this.client = getClientFromURL(url); + } + + /** + * Creates a connection to a particular server using a given username and password. This object can then be passed + * in to any other API calls. + * + * The additional sessionReference parameter must be a reference to a logged-in Session. Any method calls on this + * Connection will use it. This constructor does not call Session.loginWithPassword, and dispose() on the resulting + * Connection object does not call Session.logout. The programmer is responsible for ensuring the Session is logged + * in and out correctly. + */ + public Connection(URL url, String sessionReference) + { + deprecatedConstructorUsed = false; + + this.client = getClientFromURL(url); + this.sessionReference = sessionReference; + } + + protected void finalize() throws Throwable + { + dispose(); + super.finalize(); + } + + /** + * Nothrow guarantee. + */ + public void dispose() + { + if (!deprecatedConstructorUsed) + { + // We only need to do the Session.logout if they used the old deprecated constructor. + return; + } + + try + { + if (sessionReference != null) + { + String method_call = "session.logout"; + Object[] method_params = { Marshalling.toXMLRPC(this.sessionReference) }; + client.execute(method_call, method_params); + sessionReference = null; + } + } + catch (XmlRpcException exn) + { + } + } + + /** + * @deprecated The programmer is now responsible for calling login/logout themselves. + */ + @Deprecated + private static String loginWithPassword(XmlRpcClient client, String username, String password) + throws BadServerResponse, XmlRpcException, SessionAuthenticationFailed + { + String method_call = "session.login_with_password"; + Object[] method_params = { Marshalling.toXMLRPC(username), Marshalling.toXMLRPC(password) }; + Map response = (Map) client.execute(method_call, method_params); + if (response.get("Status").equals("Success")) + { + return (String) response.get("Value"); + } else if (response.get("Status").equals("Failure")) + { + Object[] error = (Object[]) response.get("ErrorDescription"); + if (error[0].equals("SESSION_AUTHENTICATION_FAILED")) + { + throw new SessionAuthenticationFailed(); + } + } + throw new BadServerResponse(response); + } + + /** + * @deprecated The programmer is now responsible for calling login/logout themselves. + */ + @Deprecated + private static String loginWithPassword(XmlRpcClient client, String username, String password, String ApiVersion) + throws BadServerResponse, XmlRpcException, SessionAuthenticationFailed + { + String method_call = "session.login_with_password"; + Object[] method_params = { Marshalling.toXMLRPC(username), Marshalling.toXMLRPC(password), + Marshalling.toXMLRPC(ApiVersion) }; + Map response = (Map) client.execute(method_call, method_params); + if (response.get("Status").equals("Success")) + { + return (String) response.get("Value"); + } else if (response.get("Status").equals("Failure")) + { + Object[] error = (Object[]) response.get("ErrorDescription"); + if (error[0].equals("SESSION_AUTHENTICATION_FAILED")) + { + throw new SessionAuthenticationFailed(); + } + } + throw new BadServerResponse(response); + } + + private XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + + public XmlRpcClientConfigImpl getConfig() + { + return config; + } + private XmlRpcClient getClientFromURL(URL url) + { + config.setTimeZone(TimeZone.getTimeZone("UTC")); + config.setServerURL(url); + XmlRpcClient client = new XmlRpcClient(); + client.setConfig(config); + return client; + } + + /* + * Because the binding calls are constructing their own parameter lists, they need to be able to get to + * the session reference directly. This is all rather ugly and needs redone + * Changed to public to allow easier integration with HTTP-level streaming interface, + * see CA-15447 + */ + public String getSessionReference() + { + return this.sessionReference; + } + + /** + * The (auto-generated parts of) the bindings dispatch XMLRPC calls on this Connection's client through this method. + */ + Map dispatch(String method_call, Object[] method_params) throws XmlRpcException, XenAPIException + { + Map response = (Map) client.execute(method_call, method_params); + + if (!deprecatedConstructorUsed) + { + // We are using the new-style constructor which doesn't perform login. + // Set this Connection's Session reference from the value returned on the wire. + if (method_call.equals("session.login_with_password") && + response.get("Status").equals("Success")) + { + // Store the Session reference and ask the server what the + // API version it's using is. + Session session = Types.toSession(response.get("Value")); + sessionReference = session.ref; + setAPIVersion(session); + } + else if (method_call.equals("session.slave_local_login_with_password") && + response.get("Status").equals("Success")) + { + // Store the Session reference and assume the latest API version. + sessionReference = Types.toSession(response.get("Value")).ref; + apiVersion = APIVersion.latest(); + } + else if (method_call.equals("session.logout")) + { + // Work around a bug in XenServer 5.0 and below. + // session.login_with_password should have rejected us with + // HOST_IS_SLAVE, but instead we don't find out until later. + // We don't want to leak the session, so we need to log out + // this session from the master instead. + if (response.get("Status").equals("Failure")) + { + Object[] error = (Object[]) response.get("ErrorDescription"); + if (error.length == 2 && error[0].equals("HOST_IS_SLAVE")) + { + try + { + URL client_url = + ((XmlRpcHttpClientConfig)client.getClientConfig()).getServerURL(); + Connection tmp_conn = + new Connection(new URL(client_url.getProtocol(), + (String)error[1], + client_url.getPort(), + client_url.getFile())); + tmp_conn.sessionReference = sessionReference; + try + { + Session.logout(tmp_conn); + } + finally + { + tmp_conn.dispose(); + } + } + catch (Exception exn2) + { + // Ignore -- we're going to throw HostIsSlave anyway. + } + } + } + + // Clear the stored Session reference. + this.sessionReference = null; + } + } + + return Types.checkResponse(response); + } + + + private void setAPIVersion(Session session) throws XenAPIException, XmlRpcException + { + try + { + long major = session.getThisHost(this).getAPIVersionMajor(this); + long minor = session.getThisHost(this).getAPIVersionMinor(this); + apiVersion = APIVersion.fromMajorMinor(major, minor); + } + catch (BadServerResponse exn) + { + apiVersion = APIVersion.API_1_1; + } + } +} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Console.java b/deps/XenServerJava/src/com/xensource/xenapi/Console.java new file mode 100644 index 00000000000..c734a839629 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Console.java @@ -0,0 +1,419 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A console + * + * @author Citrix Systems, Inc. + */ +public class Console extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Console(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Console, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Console) + { + Console other = (Console) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Console + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "protocol", this.protocol); + print.printf("%1$20s: %2$s\n", "location", this.location); + print.printf("%1$20s: %2$s\n", "VM", this.VM); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a console.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("protocol", this.protocol == null ? Types.ConsoleProtocol.UNRECOGNIZED : this.protocol); + map.put("location", this.location == null ? "" : this.location); + map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * the protocol used by this console + */ + public Types.ConsoleProtocol protocol; + /** + * URI for the console service + */ + public String location; + /** + * VM to which this console is attached + */ + public VM VM; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given console. + * + * @return all fields from the object + */ + public Console.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toConsoleRecord(result); + } + + /** + * Get a reference to the console instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Console getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toConsole(result); + } + + /** + * Create a new console instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, Console.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.console.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new console instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static Console create(Connection c, Console.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toConsole(result); + } + + /** + * Destroy the specified console instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.console.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified console instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the uuid field of the given console. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the protocol field of the given console. + * + * @return value of the field + */ + public Types.ConsoleProtocol getProtocol(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_protocol"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toConsoleProtocol(result); + } + + /** + * Get the location field of the given console. + * + * @return value of the field + */ + public String getLocation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_location"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the VM field of the given console. + * + * @return value of the field + */ + public VM getVM(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_VM"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Get the other_config field of the given console. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given console. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given console. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given console. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the consoles known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfConsole(result); + } + + /** + * Return a map of console references to console records for all consoles known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "console.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfConsoleConsoleRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java b/deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java new file mode 100644 index 00000000000..d1187bb4a7a --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java @@ -0,0 +1,358 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A VM crashdump + * + * @author Citrix Systems, Inc. + */ +public class Crashdump extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Crashdump(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Crashdump, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Crashdump) + { + Crashdump other = (Crashdump) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Crashdump + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "VM", this.VM); + print.printf("%1$20s: %2$s\n", "VDI", this.VDI); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a crashdump.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); + map.put("VDI", this.VDI == null ? new VDI("OpaqueRef:NULL") : this.VDI); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * the virtual machine + */ + public VM VM; + /** + * the virtual disk + */ + public VDI VDI; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given crashdump. + * + * @return all fields from the object + */ + public Crashdump.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toCrashdumpRecord(result); + } + + /** + * Get a reference to the crashdump instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Crashdump getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toCrashdump(result); + } + + /** + * Get the uuid field of the given crashdump. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the VM field of the given crashdump. + * + * @return value of the field + */ + public VM getVM(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.get_VM"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Get the VDI field of the given crashdump. + * + * @return value of the field + */ + public VDI getVDI(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.get_VDI"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Get the other_config field of the given crashdump. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given crashdump. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given crashdump. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given crashdump. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Destroy the specified crashdump + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.crashdump.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified crashdump + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the crashdumps known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfCrashdump(result); + } + + /** + * Return a map of crashdump references to crashdump records for all crashdumps known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "crashdump.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfCrashdumpCrashdumpRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/DRTask.java b/deps/XenServerJava/src/com/xensource/xenapi/DRTask.java new file mode 100644 index 00000000000..9694faa3c3c --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/DRTask.java @@ -0,0 +1,303 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * DR task + * + * @author Citrix Systems, Inc. + */ +public class DRTask extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + DRTask(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a DRTask, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof DRTask) + { + DRTask other = (DRTask) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a DRTask + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "introducedSRs", this.introducedSRs); + return writer.toString(); + } + + /** + * Convert a DR_task.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("introduced_SRs", this.introducedSRs == null ? new LinkedHashSet() : this.introducedSRs); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * All SRs introduced by this appliance + */ + public Set introducedSRs; + } + + /** + * Get a record containing the current state of the given DR_task. + * + * @return all fields from the object + */ + public DRTask.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "DR_task.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDRTaskRecord(result); + } + + /** + * Get a reference to the DR_task instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static DRTask getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "DR_task.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDRTask(result); + } + + /** + * Get the uuid field of the given DR_task. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "DR_task.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the introduced_SRs field of the given DR_task. + * + * @return value of the field + */ + public Set getIntroducedSRs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "DR_task.get_introduced_SRs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfSR(result); + } + + /** + * Create a disaster recovery task which will query the supplied list of devices + * + * @param type The SR driver type of the SRs to introduce + * @param deviceConfig The device configuration of the SRs to introduce + * @param whitelist The devices to use for disaster recovery + * @return Task + */ + public static Task createAsync(Connection c, String type, Map deviceConfig, Set whitelist) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.DR_task.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(whitelist)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a disaster recovery task which will query the supplied list of devices + * + * @param type The SR driver type of the SRs to introduce + * @param deviceConfig The device configuration of the SRs to introduce + * @param whitelist The devices to use for disaster recovery + * @return The reference to the created task + */ + public static DRTask create(Connection c, String type, Map deviceConfig, Set whitelist) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "DR_task.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(whitelist)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDRTask(result); + } + + /** + * Destroy the disaster recovery task, detaching and forgetting any SRs introduced which are no longer required + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.DR_task.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the disaster recovery task, detaching and forgetting any SRs introduced which are no longer required + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "DR_task.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the DR_tasks known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "DR_task.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfDRTask(result); + } + + /** + * Return a map of DR_task references to DR_task records for all DR_tasks known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "DR_task.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfDRTaskDRTaskRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/DataSource.java b/deps/XenServerJava/src/com/xensource/xenapi/DataSource.java new file mode 100644 index 00000000000..a0f46fb4fe8 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/DataSource.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * Data sources for logging in RRDs + * + * @author Citrix Systems, Inc. + */ +public class DataSource extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + DataSource(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a DataSource, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof DataSource) + { + DataSource other = (DataSource) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a DataSource + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "enabled", this.enabled); + print.printf("%1$20s: %2$s\n", "standard", this.standard); + print.printf("%1$20s: %2$s\n", "units", this.units); + print.printf("%1$20s: %2$s\n", "min", this.min); + print.printf("%1$20s: %2$s\n", "max", this.max); + print.printf("%1$20s: %2$s\n", "value", this.value); + return writer.toString(); + } + + /** + * Convert a data_source.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("enabled", this.enabled == null ? false : this.enabled); + map.put("standard", this.standard == null ? false : this.standard); + map.put("units", this.units == null ? "" : this.units); + map.put("min", this.min == null ? 0.0 : this.min); + map.put("max", this.max == null ? 0.0 : this.max); + map.put("value", this.value == null ? 0.0 : this.value); + return map; + } + + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * true if the data source is being logged + */ + public Boolean enabled; + /** + * true if the data source is enabled by default. Non-default data sources cannot be disabled + */ + public Boolean standard; + /** + * the units of the value + */ + public String units; + /** + * the minimum value of the data source + */ + public Double min; + /** + * the maximum value of the data source + */ + public Double max; + /** + * current value of the data source + */ + public Double value; + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Event.java b/deps/XenServerJava/src/com/xensource/xenapi/Event.java new file mode 100644 index 00000000000..3574cd19b0f --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Event.java @@ -0,0 +1,304 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * Asynchronous event registration and handling + * + * @author Citrix Systems, Inc. + */ +public class Event extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Event(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Event, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Event) + { + Event other = (Event) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Event + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "id", this.id); + print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp); + print.printf("%1$20s: %2$s\n", "clazz", this.clazz); + print.printf("%1$20s: %2$s\n", "operation", this.operation); + print.printf("%1$20s: %2$s\n", "ref", this.ref); + print.printf("%1$20s: %2$s\n", "objUuid", this.objUuid); + print.printf("%1$20s: %2$s\n", "snapshot", this.snapshot); + return writer.toString(); + } + + /** + * Convert a event.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("id", this.id == null ? 0 : this.id); + map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp); + map.put("class", this.clazz == null ? "" : this.clazz); + map.put("operation", this.operation == null ? Types.EventOperation.UNRECOGNIZED : this.operation); + map.put("ref", this.ref == null ? "" : this.ref); + map.put("obj_uuid", this.objUuid == null ? "" : this.objUuid); + map.put("snapshot", this.snapshot); + return map; + } + + /** + * An ID, monotonically increasing, and local to the current session + */ + public Long id; + /** + * The time at which the event occurred + */ + public Date timestamp; + /** + * The name of the class of the object that changed + */ + public String clazz; + /** + * The operation that was performed + */ + public Types.EventOperation operation; + /** + * A reference to the object that changed + */ + public String ref; + /** + * The uuid of the object that changed + */ + public String objUuid; + /** + * The record of the database object that was added, changed or deleted + * (the actual type will be VM.Record, VBD.Record or similar) + */ + public Object snapshot; + } + + /** + * Registers this session with the event system. Specifying * as the desired class will register for all classes. + * + * @param classes register for events for the indicated classes + * @return Task + */ + public static Task registerAsync(Connection c, Set classes) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.event.register"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Registers this session with the event system. Specifying * as the desired class will register for all classes. + * + * @param classes register for events for the indicated classes + */ + public static void register(Connection c, Set classes) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "event.register"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Unregisters this session with the event system + * + * @param classes remove this session's registration for the indicated classes + * @return Task + */ + public static Task unregisterAsync(Connection c, Set classes) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.event.unregister"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Unregisters this session with the event system + * + * @param classes remove this session's registration for the indicated classes + */ + public static void unregister(Connection c, Set classes) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "event.unregister"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Blocking call which returns a (possibly empty) batch of events + * + * @return the batch of events + */ + public static Set next(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SessionNotRegistered, + Types.EventsLost { + String method_call = "event.next"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfEventRecord(result); + } + + /** + * Blocking call which returns a (possibly empty) batch of events + * + * @param classes register for events for the indicated classes + * @param token A token representing the point from which to generate database events. The empty string represents the beginning. + * @param timeout Return after this many seconds if no events match + * @return the batch of events + */ + public static Set from(Connection c, Set classes, String token, Double timeout) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SessionNotRegistered, + Types.EventsLost { + String method_call = "event.from"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes), Marshalling.toXMLRPC(token), Marshalling.toXMLRPC(timeout)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfEventRecord(result); + } + + /** + * Return the ID of the next event to be generated by the system + * + * @return the event ID + */ + public static Long getCurrentId(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "event.get_current_id"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Injects an artificial event on the given object and return the corresponding ID + * + * @param clazz class of the object + * @param ref A reference to the object that will be changed. + * @return the event ID + */ + public static String inject(Connection c, String clazz, String ref) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "event.inject"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(clazz), Marshalling.toXMLRPC(ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/GPUGroup.java b/deps/XenServerJava/src/com/xensource/xenapi/GPUGroup.java new file mode 100644 index 00000000000..fbd7d7d59dd --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/GPUGroup.java @@ -0,0 +1,445 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A group of compatible GPUs across the resource pool + * + * @author Citrix Systems, Inc. + */ +public class GPUGroup extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + GPUGroup(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a GPUGroup, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof GPUGroup) + { + GPUGroup other = (GPUGroup) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a GPUGroup + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "PGPUs", this.PGPUs); + print.printf("%1$20s: %2$s\n", "VGPUs", this.VGPUs); + print.printf("%1$20s: %2$s\n", "GPUTypes", this.GPUTypes); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a GPU_group.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("PGPUs", this.PGPUs == null ? new LinkedHashSet() : this.PGPUs); + map.put("VGPUs", this.VGPUs == null ? new LinkedHashSet() : this.VGPUs); + map.put("GPU_types", this.GPUTypes == null ? new LinkedHashSet() : this.GPUTypes); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * List of pGPUs in the group + */ + public Set PGPUs; + /** + * List of vGPUs using the group + */ + public Set VGPUs; + /** + * List of GPU types (vendor+device ID) that can be in this group + */ + public Set GPUTypes; + /** + * Additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given GPU_group. + * + * @return all fields from the object + */ + public GPUGroup.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toGPUGroupRecord(result); + } + + /** + * Get a reference to the GPU_group instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static GPUGroup getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toGPUGroup(result); + } + + /** + * Get all the GPU_group instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfGPUGroup(result); + } + + /** + * Get the uuid field of the given GPU_group. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given GPU_group. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given GPU_group. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the PGPUs field of the given GPU_group. + * + * @return value of the field + */ + public Set getPGPUs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_PGPUs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPGPU(result); + } + + /** + * Get the VGPUs field of the given GPU_group. + * + * @return value of the field + */ + public Set getVGPUs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_VGPUs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVGPU(result); + } + + /** + * Get the GPU_types field of the given GPU_group. + * + * @return value of the field + */ + public Set getGPUTypes(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_GPU_types"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the other_config field of the given GPU_group. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the name/label field of the given GPU_group. + * + * @param label New value to set + */ + public void setNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name/description field of the given GPU_group. + * + * @param description New value to set + */ + public void setNameDescription(Connection c, String description) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given GPU_group. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given GPU_group. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given GPU_group. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the GPU_groups known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfGPUGroup(result); + } + + /** + * Return a map of GPU_group references to GPU_group records for all GPU_groups known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "GPU_group.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfGPUGroupGPUGroupRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Host.java b/deps/XenServerJava/src/com/xensource/xenapi/Host.java new file mode 100644 index 00000000000..2368930b55b --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Host.java @@ -0,0 +1,2919 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A physical host + * + * @author Citrix Systems, Inc. + */ +public class Host extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Host(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Host, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Host) + { + Host other = (Host) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Host + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "memoryOverhead", this.memoryOverhead); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "APIVersionMajor", this.APIVersionMajor); + print.printf("%1$20s: %2$s\n", "APIVersionMinor", this.APIVersionMinor); + print.printf("%1$20s: %2$s\n", "APIVersionVendor", this.APIVersionVendor); + print.printf("%1$20s: %2$s\n", "APIVersionVendorImplementation", this.APIVersionVendorImplementation); + print.printf("%1$20s: %2$s\n", "enabled", this.enabled); + print.printf("%1$20s: %2$s\n", "softwareVersion", this.softwareVersion); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "capabilities", this.capabilities); + print.printf("%1$20s: %2$s\n", "cpuConfiguration", this.cpuConfiguration); + print.printf("%1$20s: %2$s\n", "schedPolicy", this.schedPolicy); + print.printf("%1$20s: %2$s\n", "supportedBootloaders", this.supportedBootloaders); + print.printf("%1$20s: %2$s\n", "residentVMs", this.residentVMs); + print.printf("%1$20s: %2$s\n", "logging", this.logging); + print.printf("%1$20s: %2$s\n", "PIFs", this.PIFs); + print.printf("%1$20s: %2$s\n", "suspendImageSr", this.suspendImageSr); + print.printf("%1$20s: %2$s\n", "crashDumpSr", this.crashDumpSr); + print.printf("%1$20s: %2$s\n", "crashdumps", this.crashdumps); + print.printf("%1$20s: %2$s\n", "patches", this.patches); + print.printf("%1$20s: %2$s\n", "PBDs", this.PBDs); + print.printf("%1$20s: %2$s\n", "hostCPUs", this.hostCPUs); + print.printf("%1$20s: %2$s\n", "cpuInfo", this.cpuInfo); + print.printf("%1$20s: %2$s\n", "hostname", this.hostname); + print.printf("%1$20s: %2$s\n", "address", this.address); + print.printf("%1$20s: %2$s\n", "metrics", this.metrics); + print.printf("%1$20s: %2$s\n", "licenseParams", this.licenseParams); + print.printf("%1$20s: %2$s\n", "haStatefiles", this.haStatefiles); + print.printf("%1$20s: %2$s\n", "haNetworkPeers", this.haNetworkPeers); + print.printf("%1$20s: %2$s\n", "blobs", this.blobs); + print.printf("%1$20s: %2$s\n", "tags", this.tags); + print.printf("%1$20s: %2$s\n", "externalAuthType", this.externalAuthType); + print.printf("%1$20s: %2$s\n", "externalAuthServiceName", this.externalAuthServiceName); + print.printf("%1$20s: %2$s\n", "externalAuthConfiguration", this.externalAuthConfiguration); + print.printf("%1$20s: %2$s\n", "edition", this.edition); + print.printf("%1$20s: %2$s\n", "licenseServer", this.licenseServer); + print.printf("%1$20s: %2$s\n", "biosStrings", this.biosStrings); + print.printf("%1$20s: %2$s\n", "powerOnMode", this.powerOnMode); + print.printf("%1$20s: %2$s\n", "powerOnConfig", this.powerOnConfig); + print.printf("%1$20s: %2$s\n", "localCacheSr", this.localCacheSr); + print.printf("%1$20s: %2$s\n", "chipsetInfo", this.chipsetInfo); + print.printf("%1$20s: %2$s\n", "PCIs", this.PCIs); + print.printf("%1$20s: %2$s\n", "PGPUs", this.PGPUs); + return writer.toString(); + } + + /** + * Convert a host.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("memory_overhead", this.memoryOverhead == null ? 0 : this.memoryOverhead); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("API_version_major", this.APIVersionMajor == null ? 0 : this.APIVersionMajor); + map.put("API_version_minor", this.APIVersionMinor == null ? 0 : this.APIVersionMinor); + map.put("API_version_vendor", this.APIVersionVendor == null ? "" : this.APIVersionVendor); + map.put("API_version_vendor_implementation", this.APIVersionVendorImplementation == null ? new HashMap() : this.APIVersionVendorImplementation); + map.put("enabled", this.enabled == null ? false : this.enabled); + map.put("software_version", this.softwareVersion == null ? new HashMap() : this.softwareVersion); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("capabilities", this.capabilities == null ? new LinkedHashSet() : this.capabilities); + map.put("cpu_configuration", this.cpuConfiguration == null ? new HashMap() : this.cpuConfiguration); + map.put("sched_policy", this.schedPolicy == null ? "" : this.schedPolicy); + map.put("supported_bootloaders", this.supportedBootloaders == null ? new LinkedHashSet() : this.supportedBootloaders); + map.put("resident_VMs", this.residentVMs == null ? new LinkedHashSet() : this.residentVMs); + map.put("logging", this.logging == null ? new HashMap() : this.logging); + map.put("PIFs", this.PIFs == null ? new LinkedHashSet() : this.PIFs); + map.put("suspend_image_sr", this.suspendImageSr == null ? new SR("OpaqueRef:NULL") : this.suspendImageSr); + map.put("crash_dump_sr", this.crashDumpSr == null ? new SR("OpaqueRef:NULL") : this.crashDumpSr); + map.put("crashdumps", this.crashdumps == null ? new LinkedHashSet() : this.crashdumps); + map.put("patches", this.patches == null ? new LinkedHashSet() : this.patches); + map.put("PBDs", this.PBDs == null ? new LinkedHashSet() : this.PBDs); + map.put("host_CPUs", this.hostCPUs == null ? new LinkedHashSet() : this.hostCPUs); + map.put("cpu_info", this.cpuInfo == null ? new HashMap() : this.cpuInfo); + map.put("hostname", this.hostname == null ? "" : this.hostname); + map.put("address", this.address == null ? "" : this.address); + map.put("metrics", this.metrics == null ? new HostMetrics("OpaqueRef:NULL") : this.metrics); + map.put("license_params", this.licenseParams == null ? new HashMap() : this.licenseParams); + map.put("ha_statefiles", this.haStatefiles == null ? new LinkedHashSet() : this.haStatefiles); + map.put("ha_network_peers", this.haNetworkPeers == null ? new LinkedHashSet() : this.haNetworkPeers); + map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); + map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); + map.put("external_auth_type", this.externalAuthType == null ? "" : this.externalAuthType); + map.put("external_auth_service_name", this.externalAuthServiceName == null ? "" : this.externalAuthServiceName); + map.put("external_auth_configuration", this.externalAuthConfiguration == null ? new HashMap() : this.externalAuthConfiguration); + map.put("edition", this.edition == null ? "" : this.edition); + map.put("license_server", this.licenseServer == null ? new HashMap() : this.licenseServer); + map.put("bios_strings", this.biosStrings == null ? new HashMap() : this.biosStrings); + map.put("power_on_mode", this.powerOnMode == null ? "" : this.powerOnMode); + map.put("power_on_config", this.powerOnConfig == null ? new HashMap() : this.powerOnConfig); + map.put("local_cache_sr", this.localCacheSr == null ? new SR("OpaqueRef:NULL") : this.localCacheSr); + map.put("chipset_info", this.chipsetInfo == null ? new HashMap() : this.chipsetInfo); + map.put("PCIs", this.PCIs == null ? new LinkedHashSet() : this.PCIs); + map.put("PGPUs", this.PGPUs == null ? new LinkedHashSet() : this.PGPUs); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * Virtualization memory overhead (bytes). + */ + public Long memoryOverhead; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * major version number + */ + public Long APIVersionMajor; + /** + * minor version number + */ + public Long APIVersionMinor; + /** + * identification of vendor + */ + public String APIVersionVendor; + /** + * details of vendor implementation + */ + public Map APIVersionVendorImplementation; + /** + * True if the host is currently enabled + */ + public Boolean enabled; + /** + * version strings + */ + public Map softwareVersion; + /** + * additional configuration + */ + public Map otherConfig; + /** + * Xen capabilities + */ + public Set capabilities; + /** + * The CPU configuration on this host. May contain keys such as "nr_nodes", "sockets_per_node", "cores_per_socket", or "threads_per_core" + */ + public Map cpuConfiguration; + /** + * Scheduler policy currently in force on this host + */ + public String schedPolicy; + /** + * a list of the bootloaders installed on the machine + */ + public Set supportedBootloaders; + /** + * list of VMs currently resident on host + */ + public Set residentVMs; + /** + * logging configuration + */ + public Map logging; + /** + * physical network interfaces + */ + public Set PIFs; + /** + * The SR in which VDIs for suspend images are created + */ + public SR suspendImageSr; + /** + * The SR in which VDIs for crash dumps are created + */ + public SR crashDumpSr; + /** + * Set of host crash dumps + */ + public Set crashdumps; + /** + * Set of host patches + */ + public Set patches; + /** + * physical blockdevices + */ + public Set PBDs; + /** + * The physical CPUs on this host + */ + public Set hostCPUs; + /** + * Details about the physical CPUs on this host + */ + public Map cpuInfo; + /** + * The hostname of this host + */ + public String hostname; + /** + * The address by which this host can be contacted from any other host in the pool + */ + public String address; + /** + * metrics associated with this host + */ + public HostMetrics metrics; + /** + * State of the current license + */ + public Map licenseParams; + /** + * The set of statefiles accessible from this host + */ + public Set haStatefiles; + /** + * The set of hosts visible via the network from this host + */ + public Set haNetworkPeers; + /** + * Binary blobs associated with this host + */ + public Map blobs; + /** + * user-specified tags for categorization purposes + */ + public Set tags; + /** + * type of external authentication service configured; empty if none configured. + */ + public String externalAuthType; + /** + * name of external authentication service configured; empty if none configured. + */ + public String externalAuthServiceName; + /** + * configuration specific to external authentication service + */ + public Map externalAuthConfiguration; + /** + * XenServer edition + */ + public String edition; + /** + * Contact information of the license server + */ + public Map licenseServer; + /** + * BIOS strings + */ + public Map biosStrings; + /** + * The power on mode + */ + public String powerOnMode; + /** + * The power on config + */ + public Map powerOnConfig; + /** + * The SR that is used as a local cache + */ + public SR localCacheSr; + /** + * Information about chipset features + */ + public Map chipsetInfo; + /** + * List of PCI devices in the host + */ + public Set PCIs; + /** + * List of physical GPUs in the host + */ + public Set PGPUs; + } + + /** + * Get a record containing the current state of the given host. + * + * @return all fields from the object + */ + public Host.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostRecord(result); + } + + /** + * Get a reference to the host instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Host getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get all the host instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHost(result); + } + + /** + * Get the uuid field of the given host. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given host. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given host. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the memory/overhead field of the given host. + * + * @return value of the field + */ + public Long getMemoryOverhead(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_memory_overhead"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the allowed_operations field of the given host. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostAllowedOperations(result); + } + + /** + * Get the current_operations field of the given host. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringHostAllowedOperations(result); + } + + /** + * Get the API_version/major field of the given host. + * + * @return value of the field + */ + public Long getAPIVersionMajor(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_API_version_major"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the API_version/minor field of the given host. + * + * @return value of the field + */ + public Long getAPIVersionMinor(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_API_version_minor"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the API_version/vendor field of the given host. + * + * @return value of the field + */ + public String getAPIVersionVendor(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_API_version_vendor"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the API_version/vendor_implementation field of the given host. + * + * @return value of the field + */ + public Map getAPIVersionVendorImplementation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_API_version_vendor_implementation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the enabled field of the given host. + * + * @return value of the field + */ + public Boolean getEnabled(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the software_version field of the given host. + * + * @return value of the field + */ + public Map getSoftwareVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_software_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the other_config field of the given host. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the capabilities field of the given host. + * + * @return value of the field + */ + public Set getCapabilities(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_capabilities"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the cpu_configuration field of the given host. + * + * @return value of the field + */ + public Map getCpuConfiguration(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_cpu_configuration"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the sched_policy field of the given host. + * + * @return value of the field + */ + public String getSchedPolicy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_sched_policy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the supported_bootloaders field of the given host. + * + * @return value of the field + */ + public Set getSupportedBootloaders(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_supported_bootloaders"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the resident_VMs field of the given host. + * + * @return value of the field + */ + public Set getResidentVMs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_resident_VMs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVM(result); + } + + /** + * Get the logging field of the given host. + * + * @return value of the field + */ + public Map getLogging(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_logging"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the PIFs field of the given host. + * + * @return value of the field + */ + public Set getPIFs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_PIFs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPIF(result); + } + + /** + * Get the suspend_image_sr field of the given host. + * + * @return value of the field + */ + public SR getSuspendImageSr(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_suspend_image_sr"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the crash_dump_sr field of the given host. + * + * @return value of the field + */ + public SR getCrashDumpSr(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_crash_dump_sr"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the crashdumps field of the given host. + * + * @return value of the field + */ + public Set getCrashdumps(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_crashdumps"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostCrashdump(result); + } + + /** + * Get the patches field of the given host. + * + * @return value of the field + */ + public Set getPatches(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_patches"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostPatch(result); + } + + /** + * Get the PBDs field of the given host. + * + * @return value of the field + */ + public Set getPBDs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_PBDs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPBD(result); + } + + /** + * Get the host_CPUs field of the given host. + * + * @return value of the field + */ + public Set getHostCPUs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_host_CPUs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostCpu(result); + } + + /** + * Get the cpu_info field of the given host. + * + * @return value of the field + */ + public Map getCpuInfo(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_cpu_info"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the hostname field of the given host. + * + * @return value of the field + */ + public String getHostname(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_hostname"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the address field of the given host. + * + * @return value of the field + */ + public String getAddress(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_address"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the metrics field of the given host. + * + * @return value of the field + */ + public HostMetrics getMetrics(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_metrics"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostMetrics(result); + } + + /** + * Get the license_params field of the given host. + * + * @return value of the field + */ + public Map getLicenseParams(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_license_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the ha_statefiles field of the given host. + * + * @return value of the field + */ + public Set getHaStatefiles(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_ha_statefiles"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the ha_network_peers field of the given host. + * + * @return value of the field + */ + public Set getHaNetworkPeers(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_ha_network_peers"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the blobs field of the given host. + * + * @return value of the field + */ + public Map getBlobs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_blobs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringBlob(result); + } + + /** + * Get the tags field of the given host. + * + * @return value of the field + */ + public Set getTags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the external_auth_type field of the given host. + * + * @return value of the field + */ + public String getExternalAuthType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_external_auth_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the external_auth_service_name field of the given host. + * + * @return value of the field + */ + public String getExternalAuthServiceName(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_external_auth_service_name"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the external_auth_configuration field of the given host. + * + * @return value of the field + */ + public Map getExternalAuthConfiguration(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_external_auth_configuration"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the edition field of the given host. + * + * @return value of the field + */ + public String getEdition(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_edition"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the license_server field of the given host. + * + * @return value of the field + */ + public Map getLicenseServer(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_license_server"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the bios_strings field of the given host. + * + * @return value of the field + */ + public Map getBiosStrings(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_bios_strings"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the power_on_mode field of the given host. + * + * @return value of the field + */ + public String getPowerOnMode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_power_on_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the power_on_config field of the given host. + * + * @return value of the field + */ + public Map getPowerOnConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_power_on_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the local_cache_sr field of the given host. + * + * @return value of the field + */ + public SR getLocalCacheSr(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_local_cache_sr"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the chipset_info field of the given host. + * + * @return value of the field + */ + public Map getChipsetInfo(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_chipset_info"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the PCIs field of the given host. + * + * @return value of the field + */ + public Set getPCIs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_PCIs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPCI(result); + } + + /** + * Get the PGPUs field of the given host. + * + * @return value of the field + */ + public Set getPGPUs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_PGPUs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPGPU(result); + } + + /** + * Set the name/label field of the given host. + * + * @param label New value to set + */ + public void setNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name/description field of the given host. + * + * @param description New value to set + */ + public void setNameDescription(Connection c, String description) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given host. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given host. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given host. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the logging field of the given host. + * + * @param logging New value to set + */ + public void setLogging(Connection c, Map logging) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_logging"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(logging)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the logging field of the given host. + * + * @param key Key to add + * @param value Value to add + */ + public void addToLogging(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.add_to_logging"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the logging field of the given host. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromLogging(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.remove_from_logging"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the suspend_image_sr field of the given host. + * + * @param suspendImageSr New value to set + */ + public void setSuspendImageSr(Connection c, SR suspendImageSr) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_suspend_image_sr"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(suspendImageSr)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the crash_dump_sr field of the given host. + * + * @param crashDumpSr New value to set + */ + public void setCrashDumpSr(Connection c, SR crashDumpSr) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_crash_dump_sr"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(crashDumpSr)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the hostname field of the given host. + * + * @param hostname New value to set + */ + public void setHostname(Connection c, String hostname) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_hostname"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(hostname)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the address field of the given host. + * + * @param address New value to set + */ + public void setAddress(Connection c, String address) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_address"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(address)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the tags field of the given host. + * + * @param tags New value to set + */ + public void setTags(Connection c, Set tags) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given value to the tags field of the given host. If the value is already in that Set, then do nothing. + * + * @param value New value to add + */ + public void addTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.add_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given value from the tags field of the given host. If the value is not in that Set, then do nothing. + * + * @param value Value to remove + */ + public void removeTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.remove_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the license_server field of the given host. + * + * @param licenseServer New value to set + */ + public void setLicenseServer(Connection c, Map licenseServer) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_license_server"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(licenseServer)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the license_server field of the given host. + * + * @param key Key to add + * @param value Value to add + */ + public void addToLicenseServer(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.add_to_license_server"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the license_server field of the given host. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromLicenseServer(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.remove_from_license_server"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Puts the host into a state in which no new VMs can be started. Currently active VMs on the host continue to execute. + * + * @return Task + */ + public Task disableAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.disable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Puts the host into a state in which no new VMs can be started. Currently active VMs on the host continue to execute. + * + */ + public void disable(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.disable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Puts the host into a state in which new VMs can be started. + * + * @return Task + */ + public Task enableAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.enable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Puts the host into a state in which new VMs can be started. + * + */ + public void enable(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.enable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Shutdown the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.) + * + * @return Task + */ + public Task shutdownAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Shutdown the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.) + * + */ + public void shutdown(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Reboot the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.) + * + * @return Task + */ + public Task rebootAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.reboot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Reboot the host. (This function can only be called if there are no currently running VMs on the host and it is disabled.) + * + */ + public void reboot(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.reboot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the host xen dmesg. + * + * @return Task + */ + public Task dmesgAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.dmesg"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Get the host xen dmesg. + * + * @return dmesg string + */ + public String dmesg(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.dmesg"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the host xen dmesg, and clear the buffer. + * + * @return Task + */ + public Task dmesgClearAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.dmesg_clear"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Get the host xen dmesg, and clear the buffer. + * + * @return dmesg string + */ + public String dmesgClear(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.dmesg_clear"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the host's log file + * + * @return Task + */ + public Task getLogAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.get_log"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Get the host's log file + * + * @return The contents of the host's primary log file + */ + public String getLog(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_log"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Inject the given string as debugging keys into Xen + * + * @param keys The keys to send + * @return Task + */ + public Task sendDebugKeysAsync(Connection c, String keys) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.send_debug_keys"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(keys)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Inject the given string as debugging keys into Xen + * + * @param keys The keys to send + */ + public void sendDebugKeys(Connection c, String keys) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.send_debug_keys"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(keys)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Run xen-bugtool --yestoall and upload the output to Citrix support + * + * @param url The URL to upload to + * @param options Extra configuration operations + * @return Task + */ + public Task bugreportUploadAsync(Connection c, String url, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.bugreport_upload"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Run xen-bugtool --yestoall and upload the output to Citrix support + * + * @param url The URL to upload to + * @param options Extra configuration operations + */ + public void bugreportUpload(Connection c, String url, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.bugreport_upload"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * List all supported methods + * + * @return The name of every supported method. + */ + public static Set listMethods(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.list_methods"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Apply a new license to a host + * + * @param contents The contents of the license file, base64 encoded + * @return Task + */ + public Task licenseApplyAsync(Connection c, String contents) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.LicenseProcessingError { + String method_call = "Async.host.license_apply"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(contents)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Apply a new license to a host + * + * @param contents The contents of the license file, base64 encoded + */ + public void licenseApply(Connection c, String contents) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.LicenseProcessingError { + String method_call = "host.license_apply"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(contents)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Destroy specified host record in database + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy specified host record in database + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Attempt to power-on the host (if the capability exists). + * + * @return Task + */ + public Task powerOnAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.power_on"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Attempt to power-on the host (if the capability exists). + * + */ + public void powerOn(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.power_on"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call disables HA on the local host. This should only be used with extreme care. + * + */ + public static void emergencyHaDisable(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.emergency_ha_disable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @return A set of data sources + */ + public Set getDataSources(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_data_sources"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfDataSourceRecord(result); + } + + /** + * Start recording the specified data source + * + * @param dataSource The data source to record + */ + public void recordDataSource(Connection c, String dataSource) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.record_data_source"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Query the latest value of the specified data source + * + * @param dataSource The data source to query + * @return The latest value, averaged over the last 5 seconds + */ + public Double queryDataSource(Connection c, String dataSource) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.query_data_source"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Forget the recorded statistics related to the specified data source + * + * @param dataSource The data source whose archives are to be forgotten + */ + public void forgetDataSourceArchives(Connection c, String dataSource) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.forget_data_source_archives"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Check this host can be evacuated. + * + * @return Task + */ + public Task assertCanEvacuateAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.assert_can_evacuate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Check this host can be evacuated. + * + */ + public void assertCanEvacuate(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.assert_can_evacuate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a set of VMs which prevent the host being evacuated, with per-VM error codes + * + * @return Task + */ + public Task getVmsWhichPreventEvacuationAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.get_vms_which_prevent_evacuation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Return a set of VMs which prevent the host being evacuated, with per-VM error codes + * + * @return VMs which block evacuation together with reasons + */ + public Map> getVmsWhichPreventEvacuation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_vms_which_prevent_evacuation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMSetOfString(result); + } + + /** + * Return a set of VMs which are not co-operating with the host's memory control system + * @deprecated + * + * @return Task + */ + @Deprecated public Task getUncooperativeResidentVMsAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.get_uncooperative_resident_VMs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Return a set of VMs which are not co-operating with the host's memory control system + * @deprecated + * + * @return VMs which are not co-operating + */ + @Deprecated public Set getUncooperativeResidentVMs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_uncooperative_resident_VMs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVM(result); + } + + /** + * Migrate all VMs off of this host, where possible. + * + * @return Task + */ + public Task evacuateAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.evacuate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Migrate all VMs off of this host, where possible. + * + */ + public void evacuate(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.evacuate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Re-configure syslog logging + * + * @return Task + */ + public Task syslogReconfigureAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.syslog_reconfigure"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Re-configure syslog logging + * + */ + public void syslogReconfigure(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.syslog_reconfigure"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Reconfigure the management network interface + * + * @param pif reference to a PIF object corresponding to the management interface + * @return Task + */ + public static Task managementReconfigureAsync(Connection c, PIF pif) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.management_reconfigure"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(pif)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Reconfigure the management network interface + * + * @param pif reference to a PIF object corresponding to the management interface + */ + public static void managementReconfigure(Connection c, PIF pif) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.management_reconfigure"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(pif)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Reconfigure the management network interface. Should only be used if Host.management_reconfigure is impossible because the network configuration is broken. + * + * @param iface name of the interface to use as a management interface + */ + public static void localManagementReconfigure(Connection c, String iface) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.local_management_reconfigure"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(iface)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Disable the management network interface + * + */ + public static void managementDisable(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.management_disable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Returns the management interface for the specified host + * + * @return Task + */ + public Task getManagementIfaceAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.get_management_interface"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Returns the management interface for the specified host + * + * @return The managment interface for the host + */ + public PIF getManagementIface(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_management_interface"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * + * + * @return An XML fragment containing the system status capabilities. + */ + public String getSystemStatusCapabilities(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_system_status_capabilities"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Restarts the agent after a 10 second pause. WARNING: this is a dangerous operation. Any operations in progress will be aborted, and unrecoverable data loss may occur. The caller is responsible for ensuring that there are no operations in progress when this method is called. + * + * @return Task + */ + public Task restartAgentAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.restart_agent"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Restarts the agent after a 10 second pause. WARNING: this is a dangerous operation. Any operations in progress will be aborted, and unrecoverable data loss may occur. The caller is responsible for ensuring that there are no operations in progress when this method is called. + * + */ + public void restartAgent(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.restart_agent"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Shuts the agent down after a 10 second pause. WARNING: this is a dangerous operation. Any operations in progress will be aborted, and unrecoverable data loss may occur. The caller is responsible for ensuring that there are no operations in progress when this method is called. + * + */ + public static void shutdownAgent(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.shutdown_agent"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the host name to the specified string. Both the API and lower-level system hostname are changed immediately. + * + * @param hostname The new host name + */ + public void setHostnameLive(Connection c, String hostname) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.HostNameInvalid { + String method_call = "host.set_hostname_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(hostname)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Computes the amount of free memory on the host. + * + * @return Task + */ + public Task computeFreeMemoryAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.compute_free_memory"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Computes the amount of free memory on the host. + * + * @return the amount of free memory on the host. + */ + public Long computeFreeMemory(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.compute_free_memory"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Computes the virtualization memory overhead of a host. + * + * @return Task + */ + public Task computeMemoryOverheadAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.compute_memory_overhead"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Computes the virtualization memory overhead of a host. + * + * @return the virtualization memory overhead of the host. + */ + public Long computeMemoryOverhead(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.compute_memory_overhead"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * This causes the synchronisation of the non-database data (messages, RRDs and so on) stored on the master to be synchronised with the host + * + */ + public void syncData(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.sync_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This causes the RRDs to be backed up to the master + * + * @param delay Delay in seconds from when the call is received to perform the backup + */ + public void backupRrds(Connection c, Double delay) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.backup_rrds"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(delay)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this host + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return Task + */ + public Task createNewBlobAsync(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this host + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return The reference of the blob, needed for populating its data + */ + public Blob createNewBlob(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBlob(result); + } + + /** + * Call a XenAPI plugin on this host + * + * @param plugin The name of the plugin + * @param fn The name of the function within the plugin + * @param args Arguments for the function + * @return Task + */ + public Task callPluginAsync(Connection c, String plugin, String fn, Map args) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.call_plugin"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(plugin), Marshalling.toXMLRPC(fn), Marshalling.toXMLRPC(args)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Call a XenAPI plugin on this host + * + * @param plugin The name of the plugin + * @param fn The name of the function within the plugin + * @param args Arguments for the function + * @return Result from the plugin + */ + public String callPlugin(Connection c, String plugin, String fn, Map args) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.call_plugin"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(plugin), Marshalling.toXMLRPC(fn), Marshalling.toXMLRPC(args)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * This call queries the host's clock for the current time + * + * @return The current time + */ + public Date getServertime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_servertime"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * This call queries the host's clock for the current time in the host's local timezone + * + * @return The current local time + */ + public Date getServerLocaltime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_server_localtime"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * This call enables external authentication on a host + * + * @param config A list of key-values containing the configuration data + * @param serviceName The name of the service + * @param authType The type of authentication (e.g. AD for Active Directory) + */ + public void enableExternalAuth(Connection c, Map config, String serviceName, String authType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.enable_external_auth"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config), Marshalling.toXMLRPC(serviceName), Marshalling.toXMLRPC(authType)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call disables external authentication on the local host + * + * @param config Optional parameters as a list of key-values containing the configuration data + */ + public void disableExternalAuth(Connection c, Map config) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.disable_external_auth"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Retrieves recommended host migrations to perform when evacuating the host from the wlb server. If a VM cannot be migrated from the host the reason is listed instead of a recommendation. + * + * @return Task + */ + public Task retrieveWlbEvacuateRecommendationsAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.retrieve_wlb_evacuate_recommendations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Retrieves recommended host migrations to perform when evacuating the host from the wlb server. If a VM cannot be migrated from the host the reason is listed instead of a recommendation. + * + * @return VMs and the reasons why they would block evacuation, or their target host recommended by the wlb server + */ + public Map> retrieveWlbEvacuateRecommendations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.retrieve_wlb_evacuate_recommendations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMSetOfString(result); + } + + /** + * Get the installed server SSL certificate. + * + * @return Task + */ + public Task getServerCertificateAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.get_server_certificate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Get the installed server SSL certificate. + * + * @return The installed server SSL certificate, in PEM form. + */ + public String getServerCertificate(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_server_certificate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Change to another edition, or reactivate the current edition after a license has expired. This may be subject to the successful checkout of an appropriate license. + * + * @param edition The requested edition + */ + public void applyEdition(Connection c, String edition) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.apply_edition"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(edition)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Refresh the list of installed Supplemental Packs. + * + * @return Task + */ + public Task refreshPackInfoAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.refresh_pack_info"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Refresh the list of installed Supplemental Packs. + * + */ + public void refreshPackInfo(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.refresh_pack_info"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the power-on-mode, host, user and password + * + * @param powerOnMode power-on-mode can be empty,iLO,wake-on-lan, DRAC or other + * @param powerOnConfig Power on config + * @return Task + */ + public Task setPowerOnModeAsync(Connection c, String powerOnMode, Map powerOnConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.set_power_on_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(powerOnMode), Marshalling.toXMLRPC(powerOnConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the power-on-mode, host, user and password + * + * @param powerOnMode power-on-mode can be empty,iLO,wake-on-lan, DRAC or other + * @param powerOnConfig Power on config + */ + public void setPowerOnMode(Connection c, String powerOnMode, Map powerOnConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_power_on_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(powerOnMode), Marshalling.toXMLRPC(powerOnConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the CPU features to be used after a reboot, if the given features string is valid. + * + * @param features The features string (32 hexadecimal digits) + */ + public void setCpuFeatures(Connection c, String features) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.set_cpu_features"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(features)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the feature mask, such that after a reboot all features of the CPU are enabled. + * + */ + public void resetCpuFeatures(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.reset_cpu_features"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Enable the use of a local SR for caching purposes + * + * @param sr The SR to use as a local cache + */ + public void enableLocalStorageCaching(Connection c, SR sr) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.enable_local_storage_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Disable the use of a local SR for caching purposes + * + */ + public void disableLocalStorageCaching(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.disable_local_storage_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Prepare to receive a VM, returning a token which can be passed to VM.migrate. + * + * @param network The network through which migration traffic should be received. + * @param options Extra configuration operations + * @return Task + */ + public Task migrateReceiveAsync(Connection c, Network network, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host.migrate_receive"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Prepare to receive a VM, returning a token which can be passed to VM.migrate. + * + * @param network The network through which migration traffic should be received. + * @param options Extra configuration operations + * @return A value which should be passed to VM.migrate + */ + public Map migrateReceive(Connection c, Network network, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.migrate_receive"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Return a list of all the hosts known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHost(result); + } + + /** + * Return a map of host references to host records for all hosts known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfHostHostRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java b/deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java new file mode 100644 index 00000000000..4f4cdbc7296 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java @@ -0,0 +1,536 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A physical CPU + * + * @author Citrix Systems, Inc. + */ +public class HostCpu extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + HostCpu(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a HostCpu, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof HostCpu) + { + HostCpu other = (HostCpu) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a HostCpu + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "host", this.host); + print.printf("%1$20s: %2$s\n", "number", this.number); + print.printf("%1$20s: %2$s\n", "vendor", this.vendor); + print.printf("%1$20s: %2$s\n", "speed", this.speed); + print.printf("%1$20s: %2$s\n", "modelname", this.modelname); + print.printf("%1$20s: %2$s\n", "family", this.family); + print.printf("%1$20s: %2$s\n", "model", this.model); + print.printf("%1$20s: %2$s\n", "stepping", this.stepping); + print.printf("%1$20s: %2$s\n", "flags", this.flags); + print.printf("%1$20s: %2$s\n", "features", this.features); + print.printf("%1$20s: %2$s\n", "utilisation", this.utilisation); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a host_cpu.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); + map.put("number", this.number == null ? 0 : this.number); + map.put("vendor", this.vendor == null ? "" : this.vendor); + map.put("speed", this.speed == null ? 0 : this.speed); + map.put("modelname", this.modelname == null ? "" : this.modelname); + map.put("family", this.family == null ? 0 : this.family); + map.put("model", this.model == null ? 0 : this.model); + map.put("stepping", this.stepping == null ? "" : this.stepping); + map.put("flags", this.flags == null ? "" : this.flags); + map.put("features", this.features == null ? "" : this.features); + map.put("utilisation", this.utilisation == null ? 0.0 : this.utilisation); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * the host the CPU is in + */ + public Host host; + /** + * the number of the physical CPU within the host + */ + public Long number; + /** + * the vendor of the physical CPU + */ + public String vendor; + /** + * the speed of the physical CPU + */ + public Long speed; + /** + * the model name of the physical CPU + */ + public String modelname; + /** + * the family (number) of the physical CPU + */ + public Long family; + /** + * the model number of the physical CPU + */ + public Long model; + /** + * the stepping of the physical CPU + */ + public String stepping; + /** + * the flags of the physical CPU (a decoded version of the features field) + */ + public String flags; + /** + * the physical CPU feature bitmap + */ + public String features; + /** + * the current CPU utilisation + */ + public Double utilisation; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given host_cpu. + * @deprecated + * + * @return all fields from the object + */ + @Deprecated public HostCpu.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostCpuRecord(result); + } + + /** + * Get a reference to the host_cpu instance with the specified UUID. + * @deprecated + * + * @param uuid UUID of object to return + * @return reference to the object + */ + @Deprecated public static HostCpu getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostCpu(result); + } + + /** + * Get the uuid field of the given host_cpu. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the host field of the given host_cpu. + * + * @return value of the field + */ + public Host getHost(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the number field of the given host_cpu. + * + * @return value of the field + */ + public Long getNumber(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_number"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the vendor field of the given host_cpu. + * + * @return value of the field + */ + public String getVendor(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_vendor"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the speed field of the given host_cpu. + * + * @return value of the field + */ + public Long getSpeed(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_speed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the modelname field of the given host_cpu. + * + * @return value of the field + */ + public String getModelname(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_modelname"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the family field of the given host_cpu. + * + * @return value of the field + */ + public Long getFamily(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_family"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the model field of the given host_cpu. + * + * @return value of the field + */ + public Long getModel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_model"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the stepping field of the given host_cpu. + * + * @return value of the field + */ + public String getStepping(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_stepping"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the flags field of the given host_cpu. + * + * @return value of the field + */ + public String getFlags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_flags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the features field of the given host_cpu. + * + * @return value of the field + */ + public String getFeatures(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_features"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the utilisation field of the given host_cpu. + * + * @return value of the field + */ + public Double getUtilisation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_utilisation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the other_config field of the given host_cpu. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given host_cpu. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given host_cpu. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given host_cpu. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the host_cpus known to the system. + * @deprecated + * + * @return references to all objects + */ + @Deprecated public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostCpu(result); + } + + /** + * Return a map of host_cpu references to host_cpu records for all host_cpus known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_cpu.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfHostCpuHostCpuRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java b/deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java new file mode 100644 index 00000000000..f63479054a3 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java @@ -0,0 +1,417 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * Represents a host crash dump + * + * @author Citrix Systems, Inc. + */ +public class HostCrashdump extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + HostCrashdump(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a HostCrashdump, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof HostCrashdump) + { + HostCrashdump other = (HostCrashdump) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a HostCrashdump + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "host", this.host); + print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp); + print.printf("%1$20s: %2$s\n", "size", this.size); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a host_crashdump.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); + map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp); + map.put("size", this.size == null ? 0 : this.size); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Host the crashdump relates to + */ + public Host host; + /** + * Time the crash happened + */ + public Date timestamp; + /** + * Size of the crashdump + */ + public Long size; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given host_crashdump. + * + * @return all fields from the object + */ + public HostCrashdump.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostCrashdumpRecord(result); + } + + /** + * Get a reference to the host_crashdump instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static HostCrashdump getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostCrashdump(result); + } + + /** + * Get the uuid field of the given host_crashdump. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the host field of the given host_crashdump. + * + * @return value of the field + */ + public Host getHost(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the timestamp field of the given host_crashdump. + * + * @return value of the field + */ + public Date getTimestamp(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_timestamp"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the size field of the given host_crashdump. + * + * @return value of the field + */ + public Long getSize(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_size"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the other_config field of the given host_crashdump. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given host_crashdump. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given host_crashdump. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given host_crashdump. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Destroy specified host crash dump, removing it from the disk. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host_crashdump.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy specified host crash dump, removing it from the disk. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Upload the specified host crash dump to a specified URL + * + * @param url The URL to upload to + * @param options Extra configuration operations + * @return Task + */ + public Task uploadAsync(Connection c, String url, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host_crashdump.upload"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Upload the specified host crash dump to a specified URL + * + * @param url The URL to upload to + * @param options Extra configuration operations + */ + public void upload(Connection c, String url, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.upload"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the host_crashdumps known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostCrashdump(result); + } + + /** + * Return a map of host_crashdump references to host_crashdump records for all host_crashdumps known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_crashdump.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfHostCrashdumpHostCrashdumpRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java new file mode 100644 index 00000000000..5c7c7805902 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java @@ -0,0 +1,373 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * The metrics associated with a host + * + * @author Citrix Systems, Inc. + */ +public class HostMetrics extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + HostMetrics(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a HostMetrics, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof HostMetrics) + { + HostMetrics other = (HostMetrics) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a HostMetrics + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "memoryTotal", this.memoryTotal); + print.printf("%1$20s: %2$s\n", "memoryFree", this.memoryFree); + print.printf("%1$20s: %2$s\n", "live", this.live); + print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a host_metrics.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("memory_total", this.memoryTotal == null ? 0 : this.memoryTotal); + map.put("memory_free", this.memoryFree == null ? 0 : this.memoryFree); + map.put("live", this.live == null ? false : this.live); + map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Total host memory (bytes) + */ + public Long memoryTotal; + /** + * Free host memory (bytes) + */ + public Long memoryFree; + /** + * Pool master thinks this host is live + */ + public Boolean live; + /** + * Time at which this information was last updated + */ + public Date lastUpdated; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given host_metrics. + * + * @return all fields from the object + */ + public HostMetrics.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostMetricsRecord(result); + } + + /** + * Get a reference to the host_metrics instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static HostMetrics getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostMetrics(result); + } + + /** + * Get the uuid field of the given host_metrics. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the memory/total field of the given host_metrics. + * + * @return value of the field + */ + public Long getMemoryTotal(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_memory_total"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the memory/free field of the given host_metrics. + * @deprecated + * + * @return value of the field + */ + @Deprecated public Long getMemoryFree(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_memory_free"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the live field of the given host_metrics. + * + * @return value of the field + */ + public Boolean getLive(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the last_updated field of the given host_metrics. + * + * @return value of the field + */ + public Date getLastUpdated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_last_updated"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the other_config field of the given host_metrics. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given host_metrics. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given host_metrics. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given host_metrics. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the host_metrics instances known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostMetrics(result); + } + + /** + * Return a map of host_metrics references to host_metrics records for all host_metrics instances known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_metrics.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfHostMetricsHostMetricsRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java b/deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java new file mode 100644 index 00000000000..fafe4377f42 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java @@ -0,0 +1,552 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * Represents a patch stored on a server + * + * @author Citrix Systems, Inc. + */ +public class HostPatch extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + HostPatch(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a HostPatch, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof HostPatch) + { + HostPatch other = (HostPatch) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a HostPatch + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "version", this.version); + print.printf("%1$20s: %2$s\n", "host", this.host); + print.printf("%1$20s: %2$s\n", "applied", this.applied); + print.printf("%1$20s: %2$s\n", "timestampApplied", this.timestampApplied); + print.printf("%1$20s: %2$s\n", "size", this.size); + print.printf("%1$20s: %2$s\n", "poolPatch", this.poolPatch); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a host_patch.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("version", this.version == null ? "" : this.version); + map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); + map.put("applied", this.applied == null ? false : this.applied); + map.put("timestamp_applied", this.timestampApplied == null ? new Date(0) : this.timestampApplied); + map.put("size", this.size == null ? 0 : this.size); + map.put("pool_patch", this.poolPatch == null ? new PoolPatch("OpaqueRef:NULL") : this.poolPatch); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * Patch version number + */ + public String version; + /** + * Host the patch relates to + */ + public Host host; + /** + * True if the patch has been applied + */ + public Boolean applied; + /** + * Time the patch was applied + */ + public Date timestampApplied; + /** + * Size of the patch + */ + public Long size; + /** + * The patch applied + */ + public PoolPatch poolPatch; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given host_patch. + * + * @return all fields from the object + */ + public HostPatch.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostPatchRecord(result); + } + + /** + * Get a reference to the host_patch instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static HostPatch getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHostPatch(result); + } + + /** + * Get all the host_patch instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostPatch(result); + } + + /** + * Get the uuid field of the given host_patch. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given host_patch. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given host_patch. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the version field of the given host_patch. + * + * @return value of the field + */ + public String getVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the host field of the given host_patch. + * + * @return value of the field + */ + public Host getHost(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the applied field of the given host_patch. + * + * @return value of the field + */ + public Boolean getApplied(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_applied"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the timestamp_applied field of the given host_patch. + * + * @return value of the field + */ + public Date getTimestampApplied(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_timestamp_applied"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the size field of the given host_patch. + * + * @return value of the field + */ + public Long getSize(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_size"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the pool_patch field of the given host_patch. + * + * @return value of the field + */ + public PoolPatch getPoolPatch(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_pool_patch"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPoolPatch(result); + } + + /** + * Get the other_config field of the given host_patch. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given host_patch. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given host_patch. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given host_patch. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Destroy the specified host patch, removing it from the disk. This does NOT reverse the patch + * @deprecated + * + * @return Task + */ + @Deprecated public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host_patch.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified host patch, removing it from the disk. This does NOT reverse the patch + * @deprecated + * + */ + @Deprecated public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Apply the selected patch and return its output + * @deprecated + * + * @return Task + */ + @Deprecated public Task applyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.host_patch.apply"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Apply the selected patch and return its output + * @deprecated + * + * @return the output of the patch application process + */ + @Deprecated public String apply(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.apply"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Return a list of all the host_patchs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostPatch(result); + } + + /** + * Return a map of host_patch references to host_patch records for all host_patchs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "host_patch.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfHostPatchHostPatchRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java b/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java new file mode 100644 index 00000000000..416aad94b9e --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java @@ -0,0 +1,76 @@ +/* Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.xensource.xenapi; + +import java.util.*; + +/** + * Marshalls Java types onto the wire. + * Does not cope with records. Use individual record.toMap() + */ +public final class Marshalling { + /** + * Converts Integers to Strings + * and Sets to Lists recursively. + */ + public static Object toXMLRPC(Object o) { + if (o instanceof String || + o instanceof Boolean || + o instanceof Double || + o instanceof Date) { + return o; + } else if (o instanceof Long) { + return o.toString(); + } else if (o instanceof Map) { + Map result = new HashMap(); + Map m = (Map)o; + for (Object k : m.keySet()) + { + result.put(toXMLRPC(k), toXMLRPC(m.get(k))); + } + return result; + } else if (o instanceof Set) { + List result = new ArrayList(); + for (Object e : ((Set)o)) + { + result.add(toXMLRPC(e)); + } + return result; + } else if (o instanceof XenAPIObject) { + return ((XenAPIObject) o).toWireString(); + } else if (o instanceof Enum) { + return o.toString(); + }else if (o == null){ + return ""; + } else { + throw new RuntimeException ("=============don't know how to marshall:({[" + o + "]})"); + } + } +} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Message.java b/deps/XenServerJava/src/com/xensource/xenapi/Message.java new file mode 100644 index 00000000000..95bcc8fa107 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Message.java @@ -0,0 +1,320 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * An message for the attention of the administrator + * + * @author Citrix Systems, Inc. + */ +public class Message extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Message(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Message, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Message) + { + Message other = (Message) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Message + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "name", this.name); + print.printf("%1$20s: %2$s\n", "priority", this.priority); + print.printf("%1$20s: %2$s\n", "cls", this.cls); + print.printf("%1$20s: %2$s\n", "objUuid", this.objUuid); + print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp); + print.printf("%1$20s: %2$s\n", "body", this.body); + return writer.toString(); + } + + /** + * Convert a message.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name", this.name == null ? "" : this.name); + map.put("priority", this.priority == null ? 0 : this.priority); + map.put("cls", this.cls == null ? Types.Cls.UNRECOGNIZED : this.cls); + map.put("obj_uuid", this.objUuid == null ? "" : this.objUuid); + map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp); + map.put("body", this.body == null ? "" : this.body); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * The name of the message + */ + public String name; + /** + * The message priority, 0 being low priority + */ + public Long priority; + /** + * The class of the object this message is associated with + */ + public Types.Cls cls; + /** + * The uuid of the object this message is associated with + */ + public String objUuid; + /** + * The time at which the message was created + */ + public Date timestamp; + /** + * The body of the message + */ + public String body; + } + + /** + * + * + * @param name The name of the message + * @param priority The priority of the message + * @param cls The class of object this message is associated with + * @param objUuid The uuid of the object this message is associated with + * @param body The body of the message + * @return The reference of the created message + */ + public static Message create(Connection c, String name, Long priority, Types.Cls cls, String objUuid, String body) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(priority), Marshalling.toXMLRPC(cls), Marshalling.toXMLRPC(objUuid), Marshalling.toXMLRPC(body)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMessage(result); + } + + /** + * + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param cls The class of object + * @param objUuid The uuid of the object + * @param since The cutoff time + * @return The relevant messages + */ + public static Map get(Connection c, Types.Cls cls, String objUuid, Date since) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.get"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(cls), Marshalling.toXMLRPC(objUuid), Marshalling.toXMLRPC(since)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfMessageMessageRecord(result); + } + + /** + * + * + * @return The references to the messages + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfMessage(result); + } + + /** + * + * + * @param since The cutoff time + * @return The relevant messages + */ + public static Map getSince(Connection c, Date since) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.get_since"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(since)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfMessageMessageRecord(result); + } + + /** + * + * + * @return The message record + */ + public Message.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMessageRecord(result); + } + + /** + * + * + * @param uuid The uuid of the message + * @return The message reference + */ + public static Message getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMessage(result); + } + + /** + * + * + * @return The messages + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfMessageMessageRecord(result); + } + + /** + * + * + * @param expr The expression to match (not currently used) + * @return The messages + */ + public static Map getAllRecordsWhere(Connection c, String expr) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "message.get_all_records_where"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(expr)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfMessageMessageRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Network.java b/deps/XenServerJava/src/com/xensource/xenapi/Network.java new file mode 100644 index 00000000000..1b23afeee4d --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Network.java @@ -0,0 +1,791 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A virtual network + * + * @author Citrix Systems, Inc. + */ +public class Network extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Network(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Network, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Network) + { + Network other = (Network) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Network + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "VIFs", this.VIFs); + print.printf("%1$20s: %2$s\n", "PIFs", this.PIFs); + print.printf("%1$20s: %2$s\n", "MTU", this.MTU); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "bridge", this.bridge); + print.printf("%1$20s: %2$s\n", "blobs", this.blobs); + print.printf("%1$20s: %2$s\n", "tags", this.tags); + print.printf("%1$20s: %2$s\n", "defaultLockingMode", this.defaultLockingMode); + return writer.toString(); + } + + /** + * Convert a network.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("VIFs", this.VIFs == null ? new LinkedHashSet() : this.VIFs); + map.put("PIFs", this.PIFs == null ? new LinkedHashSet() : this.PIFs); + map.put("MTU", this.MTU == null ? 0 : this.MTU); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("bridge", this.bridge == null ? "" : this.bridge); + map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); + map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); + map.put("default_locking_mode", this.defaultLockingMode == null ? Types.NetworkDefaultLockingMode.UNRECOGNIZED : this.defaultLockingMode); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * list of connected vifs + */ + public Set VIFs; + /** + * list of connected pifs + */ + public Set PIFs; + /** + * MTU in octets + */ + public Long MTU; + /** + * additional configuration + */ + public Map otherConfig; + /** + * name of the bridge corresponding to this network on the local host + */ + public String bridge; + /** + * Binary blobs associated with this network + */ + public Map blobs; + /** + * user-specified tags for categorization purposes + */ + public Set tags; + /** + * The network will use this value to determine the behaviour of all VIFs where locking_mode = default + */ + public Types.NetworkDefaultLockingMode defaultLockingMode; + } + + /** + * Get a record containing the current state of the given network. + * + * @return all fields from the object + */ + public Network.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toNetworkRecord(result); + } + + /** + * Get a reference to the network instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Network getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toNetwork(result); + } + + /** + * Create a new network instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, Network.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.network.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new network instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static Network create(Connection c, Network.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toNetwork(result); + } + + /** + * Destroy the specified network instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.network.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified network instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get all the network instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfNetwork(result); + } + + /** + * Get the uuid field of the given network. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given network. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given network. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the allowed_operations field of the given network. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfNetworkOperations(result); + } + + /** + * Get the current_operations field of the given network. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringNetworkOperations(result); + } + + /** + * Get the VIFs field of the given network. + * + * @return value of the field + */ + public Set getVIFs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_VIFs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVIF(result); + } + + /** + * Get the PIFs field of the given network. + * + * @return value of the field + */ + public Set getPIFs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_PIFs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPIF(result); + } + + /** + * Get the MTU field of the given network. + * + * @return value of the field + */ + public Long getMTU(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_MTU"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the other_config field of the given network. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the bridge field of the given network. + * + * @return value of the field + */ + public String getBridge(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_bridge"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the blobs field of the given network. + * + * @return value of the field + */ + public Map getBlobs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_blobs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringBlob(result); + } + + /** + * Get the tags field of the given network. + * + * @return value of the field + */ + public Set getTags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the default_locking_mode field of the given network. + * + * @return value of the field + */ + public Types.NetworkDefaultLockingMode getDefaultLockingMode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_default_locking_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toNetworkDefaultLockingMode(result); + } + + /** + * Set the name/label field of the given network. + * + * @param label New value to set + */ + public void setNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name/description field of the given network. + * + * @param description New value to set + */ + public void setNameDescription(Connection c, String description) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the MTU field of the given network. + * + * @param MTU New value to set + */ + public void setMTU(Connection c, Long MTU) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.set_MTU"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(MTU)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given network. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given network. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given network. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the tags field of the given network. + * + * @param tags New value to set + */ + public void setTags(Connection c, Set tags) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.set_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given value to the tags field of the given network. If the value is already in that Set, then do nothing. + * + * @param value New value to add + */ + public void addTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.add_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given value from the tags field of the given network. If the value is not in that Set, then do nothing. + * + * @param value Value to remove + */ + public void removeTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.remove_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this pool + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return Task + */ + public Task createNewBlobAsync(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.network.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this pool + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return The reference of the blob, needed for populating its data + */ + public Blob createNewBlob(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBlob(result); + } + + /** + * Set the default locking mode for VIFs attached to this network + * + * @param value The default locking mode for VIFs attached to this network. + * @return Task + */ + public Task setDefaultLockingModeAsync(Connection c, Types.NetworkDefaultLockingMode value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.network.set_default_locking_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the default locking mode for VIFs attached to this network + * + * @param value The default locking mode for VIFs attached to this network. + */ + public void setDefaultLockingMode(Connection c, Types.NetworkDefaultLockingMode value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.set_default_locking_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the networks known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfNetwork(result); + } + + /** + * Return a map of network references to network records for all networks known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "network.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfNetworkNetworkRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PBD.java b/deps/XenServerJava/src/com/xensource/xenapi/PBD.java new file mode 100644 index 00000000000..6fddfa68542 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/PBD.java @@ -0,0 +1,542 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * The physical block devices through which hosts access SRs + * + * @author Citrix Systems, Inc. + */ +public class PBD extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + PBD(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a PBD, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof PBD) + { + PBD other = (PBD) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a PBD + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "host", this.host); + print.printf("%1$20s: %2$s\n", "SR", this.SR); + print.printf("%1$20s: %2$s\n", "deviceConfig", this.deviceConfig); + print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a PBD.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); + map.put("SR", this.SR == null ? new SR("OpaqueRef:NULL") : this.SR); + map.put("device_config", this.deviceConfig == null ? new HashMap() : this.deviceConfig); + map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * physical machine on which the pbd is available + */ + public Host host; + /** + * the storage repository that the pbd realises + */ + public SR SR; + /** + * a config string to string map that is provided to the host's SR-backend-driver + */ + public Map deviceConfig; + /** + * is the SR currently attached on this host? + */ + public Boolean currentlyAttached; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given PBD. + * + * @return all fields from the object + */ + public PBD.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPBDRecord(result); + } + + /** + * Get a reference to the PBD instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static PBD getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPBD(result); + } + + /** + * Create a new PBD instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, PBD.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PBD.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new PBD instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static PBD create(Connection c, PBD.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPBD(result); + } + + /** + * Destroy the specified PBD instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PBD.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified PBD instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the uuid field of the given PBD. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the host field of the given PBD. + * + * @return value of the field + */ + public Host getHost(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the SR field of the given PBD. + * + * @return value of the field + */ + public SR getSR(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the device_config field of the given PBD. + * + * @return value of the field + */ + public Map getDeviceConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_device_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the currently_attached field of the given PBD. + * + * @return value of the field + */ + public Boolean getCurrentlyAttached(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_currently_attached"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the other_config field of the given PBD. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given PBD. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given PBD. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given PBD. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Activate the specified PBD, causing the referenced SR to be attached and scanned + * + * @return Task + */ + public Task plugAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrUnknownDriver { + String method_call = "Async.PBD.plug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Activate the specified PBD, causing the referenced SR to be attached and scanned + * + */ + public void plug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrUnknownDriver { + String method_call = "PBD.plug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Deactivate the specified PBD, causing the referenced SR to be detached and nolonger scanned + * + * @return Task + */ + public Task unplugAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PBD.unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Deactivate the specified PBD, causing the referenced SR to be detached and nolonger scanned + * + */ + public void unplug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the PBD's device_config field + * + * @param value The new value of the PBD's device_config + * @return Task + */ + public Task setDeviceConfigAsync(Connection c, Map value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PBD.set_device_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Sets the PBD's device_config field + * + * @param value The new value of the PBD's device_config + */ + public void setDeviceConfig(Connection c, Map value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.set_device_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the PBDs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPBD(result); + } + + /** + * Return a map of PBD references to PBD records for all PBDs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PBD.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfPBDPBDRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PCI.java b/deps/XenServerJava/src/com/xensource/xenapi/PCI.java new file mode 100644 index 00000000000..9e2ec77d0be --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/PCI.java @@ -0,0 +1,418 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A PCI device + * + * @author Citrix Systems, Inc. + */ +public class PCI extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + PCI(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a PCI, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof PCI) + { + PCI other = (PCI) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a PCI + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "clazzName", this.clazzName); + print.printf("%1$20s: %2$s\n", "vendorName", this.vendorName); + print.printf("%1$20s: %2$s\n", "deviceName", this.deviceName); + print.printf("%1$20s: %2$s\n", "host", this.host); + print.printf("%1$20s: %2$s\n", "pciId", this.pciId); + print.printf("%1$20s: %2$s\n", "dependencies", this.dependencies); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a PCI.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("class_name", this.clazzName == null ? "" : this.clazzName); + map.put("vendor_name", this.vendorName == null ? "" : this.vendorName); + map.put("device_name", this.deviceName == null ? "" : this.deviceName); + map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); + map.put("pci_id", this.pciId == null ? "" : this.pciId); + map.put("dependencies", this.dependencies == null ? new LinkedHashSet() : this.dependencies); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * PCI class name + */ + public String clazzName; + /** + * Vendor name + */ + public String vendorName; + /** + * Device name + */ + public String deviceName; + /** + * Physical machine that owns the PCI device + */ + public Host host; + /** + * PCI ID of the physical device + */ + public String pciId; + /** + * List of dependent PCI devices + */ + public Set dependencies; + /** + * Additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given PCI. + * + * @return all fields from the object + */ + public PCI.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPCIRecord(result); + } + + /** + * Get a reference to the PCI instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static PCI getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPCI(result); + } + + /** + * Get the uuid field of the given PCI. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the class_name field of the given PCI. + * + * @return value of the field + */ + public String getClazzName(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_class_name"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the vendor_name field of the given PCI. + * + * @return value of the field + */ + public String getVendorName(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_vendor_name"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the device_name field of the given PCI. + * + * @return value of the field + */ + public String getDeviceName(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_device_name"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the host field of the given PCI. + * + * @return value of the field + */ + public Host getHost(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the pci_id field of the given PCI. + * + * @return value of the field + */ + public String getPciId(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_pci_id"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the dependencies field of the given PCI. + * + * @return value of the field + */ + public Set getDependencies(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_dependencies"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPCI(result); + } + + /** + * Get the other_config field of the given PCI. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given PCI. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given PCI. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given PCI. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the PCIs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPCI(result); + } + + /** + * Return a map of PCI references to PCI records for all PCIs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PCI.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfPCIPCIRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PGPU.java b/deps/XenServerJava/src/com/xensource/xenapi/PGPU.java new file mode 100644 index 00000000000..a9e1c432dad --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/PGPU.java @@ -0,0 +1,349 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A physical GPU (pGPU) + * + * @author Citrix Systems, Inc. + */ +public class PGPU extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + PGPU(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a PGPU, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof PGPU) + { + PGPU other = (PGPU) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a PGPU + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "PCI", this.PCI); + print.printf("%1$20s: %2$s\n", "GPUGroup", this.GPUGroup); + print.printf("%1$20s: %2$s\n", "host", this.host); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a PGPU.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("PCI", this.PCI == null ? new PCI("OpaqueRef:NULL") : this.PCI); + map.put("GPU_group", this.GPUGroup == null ? new GPUGroup("OpaqueRef:NULL") : this.GPUGroup); + map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Link to underlying PCI device + */ + public PCI PCI; + /** + * GPU group the pGPU is contained in + */ + public GPUGroup GPUGroup; + /** + * Host that own the GPU + */ + public Host host; + /** + * Additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given PGPU. + * + * @return all fields from the object + */ + public PGPU.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPGPURecord(result); + } + + /** + * Get a reference to the PGPU instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static PGPU getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPGPU(result); + } + + /** + * Get the uuid field of the given PGPU. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the PCI field of the given PGPU. + * + * @return value of the field + */ + public PCI getPCI(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_PCI"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPCI(result); + } + + /** + * Get the GPU_group field of the given PGPU. + * + * @return value of the field + */ + public GPUGroup getGPUGroup(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_GPU_group"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toGPUGroup(result); + } + + /** + * Get the host field of the given PGPU. + * + * @return value of the field + */ + public Host getHost(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the other_config field of the given PGPU. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given PGPU. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given PGPU. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given PGPU. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the PGPUs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPGPU(result); + } + + /** + * Return a map of PGPU references to PGPU records for all PGPUs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PGPU.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfPGPUPGPURecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PIF.java b/deps/XenServerJava/src/com/xensource/xenapi/PIF.java new file mode 100644 index 00000000000..950afebce14 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/PIF.java @@ -0,0 +1,1374 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A physical network interface (note separate VLANs are represented as several PIFs) + * + * @author Citrix Systems, Inc. + */ +public class PIF extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + PIF(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a PIF, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof PIF) + { + PIF other = (PIF) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a PIF + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "device", this.device); + print.printf("%1$20s: %2$s\n", "network", this.network); + print.printf("%1$20s: %2$s\n", "host", this.host); + print.printf("%1$20s: %2$s\n", "MAC", this.MAC); + print.printf("%1$20s: %2$s\n", "MTU", this.MTU); + print.printf("%1$20s: %2$s\n", "VLAN", this.VLAN); + print.printf("%1$20s: %2$s\n", "metrics", this.metrics); + print.printf("%1$20s: %2$s\n", "physical", this.physical); + print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); + print.printf("%1$20s: %2$s\n", "ipConfigurationMode", this.ipConfigurationMode); + print.printf("%1$20s: %2$s\n", "IP", this.IP); + print.printf("%1$20s: %2$s\n", "netmask", this.netmask); + print.printf("%1$20s: %2$s\n", "gateway", this.gateway); + print.printf("%1$20s: %2$s\n", "DNS", this.DNS); + print.printf("%1$20s: %2$s\n", "bondSlaveOf", this.bondSlaveOf); + print.printf("%1$20s: %2$s\n", "bondMasterOf", this.bondMasterOf); + print.printf("%1$20s: %2$s\n", "VLANMasterOf", this.VLANMasterOf); + print.printf("%1$20s: %2$s\n", "VLANSlaveOf", this.VLANSlaveOf); + print.printf("%1$20s: %2$s\n", "management", this.management); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "disallowUnplug", this.disallowUnplug); + print.printf("%1$20s: %2$s\n", "tunnelAccessPIFOf", this.tunnelAccessPIFOf); + print.printf("%1$20s: %2$s\n", "tunnelTransportPIFOf", this.tunnelTransportPIFOf); + print.printf("%1$20s: %2$s\n", "ipv6ConfigurationMode", this.ipv6ConfigurationMode); + print.printf("%1$20s: %2$s\n", "IPv6", this.IPv6); + print.printf("%1$20s: %2$s\n", "ipv6Gateway", this.ipv6Gateway); + print.printf("%1$20s: %2$s\n", "primaryAddressType", this.primaryAddressType); + return writer.toString(); + } + + /** + * Convert a PIF.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("device", this.device == null ? "" : this.device); + map.put("network", this.network == null ? new Network("OpaqueRef:NULL") : this.network); + map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host); + map.put("MAC", this.MAC == null ? "" : this.MAC); + map.put("MTU", this.MTU == null ? 0 : this.MTU); + map.put("VLAN", this.VLAN == null ? 0 : this.VLAN); + map.put("metrics", this.metrics == null ? new PIFMetrics("OpaqueRef:NULL") : this.metrics); + map.put("physical", this.physical == null ? false : this.physical); + map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); + map.put("ip_configuration_mode", this.ipConfigurationMode == null ? Types.IpConfigurationMode.UNRECOGNIZED : this.ipConfigurationMode); + map.put("IP", this.IP == null ? "" : this.IP); + map.put("netmask", this.netmask == null ? "" : this.netmask); + map.put("gateway", this.gateway == null ? "" : this.gateway); + map.put("DNS", this.DNS == null ? "" : this.DNS); + map.put("bond_slave_of", this.bondSlaveOf == null ? new Bond("OpaqueRef:NULL") : this.bondSlaveOf); + map.put("bond_master_of", this.bondMasterOf == null ? new LinkedHashSet() : this.bondMasterOf); + map.put("VLAN_master_of", this.VLANMasterOf == null ? new VLAN("OpaqueRef:NULL") : this.VLANMasterOf); + map.put("VLAN_slave_of", this.VLANSlaveOf == null ? new LinkedHashSet() : this.VLANSlaveOf); + map.put("management", this.management == null ? false : this.management); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("disallow_unplug", this.disallowUnplug == null ? false : this.disallowUnplug); + map.put("tunnel_access_PIF_of", this.tunnelAccessPIFOf == null ? new LinkedHashSet() : this.tunnelAccessPIFOf); + map.put("tunnel_transport_PIF_of", this.tunnelTransportPIFOf == null ? new LinkedHashSet() : this.tunnelTransportPIFOf); + map.put("ipv6_configuration_mode", this.ipv6ConfigurationMode == null ? Types.Ipv6ConfigurationMode.UNRECOGNIZED : this.ipv6ConfigurationMode); + map.put("IPv6", this.IPv6 == null ? new LinkedHashSet() : this.IPv6); + map.put("ipv6_gateway", this.ipv6Gateway == null ? "" : this.ipv6Gateway); + map.put("primary_address_type", this.primaryAddressType == null ? Types.PrimaryAddressType.UNRECOGNIZED : this.primaryAddressType); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * machine-readable name of the interface (e.g. eth0) + */ + public String device; + /** + * virtual network to which this pif is connected + */ + public Network network; + /** + * physical machine to which this pif is connected + */ + public Host host; + /** + * ethernet MAC address of physical interface + */ + public String MAC; + /** + * MTU in octets + */ + public Long MTU; + /** + * VLAN tag for all traffic passing through this interface + */ + public Long VLAN; + /** + * metrics associated with this PIF + */ + public PIFMetrics metrics; + /** + * true if this represents a physical network interface + */ + public Boolean physical; + /** + * true if this interface is online + */ + public Boolean currentlyAttached; + /** + * Sets if and how this interface gets an IP address + */ + public Types.IpConfigurationMode ipConfigurationMode; + /** + * IP address + */ + public String IP; + /** + * IP netmask + */ + public String netmask; + /** + * IP gateway + */ + public String gateway; + /** + * IP address of DNS servers to use + */ + public String DNS; + /** + * Indicates which bond this interface is part of + */ + public Bond bondSlaveOf; + /** + * Indicates this PIF represents the results of a bond + */ + public Set bondMasterOf; + /** + * Indicates wich VLAN this interface receives untagged traffic from + */ + public VLAN VLANMasterOf; + /** + * Indicates which VLANs this interface transmits tagged traffic to + */ + public Set VLANSlaveOf; + /** + * Indicates whether the control software is listening for connections on this interface + */ + public Boolean management; + /** + * Additional configuration + */ + public Map otherConfig; + /** + * Prevent this PIF from being unplugged; set this to notify the management tool-stack that the PIF has a special use and should not be unplugged under any circumstances (e.g. because you're running storage traffic over it) + */ + public Boolean disallowUnplug; + /** + * Indicates to which tunnel this PIF gives access + */ + public Set tunnelAccessPIFOf; + /** + * Indicates to which tunnel this PIF provides transport + */ + public Set tunnelTransportPIFOf; + /** + * Sets if and how this interface gets an IPv6 address + */ + public Types.Ipv6ConfigurationMode ipv6ConfigurationMode; + /** + * IPv6 address + */ + public Set IPv6; + /** + * IPv6 gateway + */ + public String ipv6Gateway; + /** + * Which protocol should define the primary address of this interface + */ + public Types.PrimaryAddressType primaryAddressType; + } + + /** + * Get a record containing the current state of the given PIF. + * + * @return all fields from the object + */ + public PIF.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIFRecord(result); + } + + /** + * Get a reference to the PIF instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static PIF getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Get the uuid field of the given PIF. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the device field of the given PIF. + * + * @return value of the field + */ + public String getDevice(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_device"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the network field of the given PIF. + * + * @return value of the field + */ + public Network getNetwork(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_network"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toNetwork(result); + } + + /** + * Get the host field of the given PIF. + * + * @return value of the field + */ + public Host getHost(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the MAC field of the given PIF. + * + * @return value of the field + */ + public String getMAC(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_MAC"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the MTU field of the given PIF. + * + * @return value of the field + */ + public Long getMTU(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_MTU"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the VLAN field of the given PIF. + * + * @return value of the field + */ + public Long getVLAN(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_VLAN"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the metrics field of the given PIF. + * + * @return value of the field + */ + public PIFMetrics getMetrics(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_metrics"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIFMetrics(result); + } + + /** + * Get the physical field of the given PIF. + * + * @return value of the field + */ + public Boolean getPhysical(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_physical"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the currently_attached field of the given PIF. + * + * @return value of the field + */ + public Boolean getCurrentlyAttached(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_currently_attached"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the ip_configuration_mode field of the given PIF. + * + * @return value of the field + */ + public Types.IpConfigurationMode getIpConfigurationMode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_ip_configuration_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toIpConfigurationMode(result); + } + + /** + * Get the IP field of the given PIF. + * + * @return value of the field + */ + public String getIP(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_IP"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the netmask field of the given PIF. + * + * @return value of the field + */ + public String getNetmask(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_netmask"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the gateway field of the given PIF. + * + * @return value of the field + */ + public String getGateway(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_gateway"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the DNS field of the given PIF. + * + * @return value of the field + */ + public String getDNS(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_DNS"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the bond_slave_of field of the given PIF. + * + * @return value of the field + */ + public Bond getBondSlaveOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_bond_slave_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBond(result); + } + + /** + * Get the bond_master_of field of the given PIF. + * + * @return value of the field + */ + public Set getBondMasterOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_bond_master_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfBond(result); + } + + /** + * Get the VLAN_master_of field of the given PIF. + * + * @return value of the field + */ + public VLAN getVLANMasterOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_VLAN_master_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVLAN(result); + } + + /** + * Get the VLAN_slave_of field of the given PIF. + * + * @return value of the field + */ + public Set getVLANSlaveOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_VLAN_slave_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVLAN(result); + } + + /** + * Get the management field of the given PIF. + * + * @return value of the field + */ + public Boolean getManagement(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_management"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the other_config field of the given PIF. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the disallow_unplug field of the given PIF. + * + * @return value of the field + */ + public Boolean getDisallowUnplug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_disallow_unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the tunnel_access_PIF_of field of the given PIF. + * + * @return value of the field + */ + public Set getTunnelAccessPIFOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_tunnel_access_PIF_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfTunnel(result); + } + + /** + * Get the tunnel_transport_PIF_of field of the given PIF. + * + * @return value of the field + */ + public Set getTunnelTransportPIFOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_tunnel_transport_PIF_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfTunnel(result); + } + + /** + * Get the ipv6_configuration_mode field of the given PIF. + * + * @return value of the field + */ + public Types.Ipv6ConfigurationMode getIpv6ConfigurationMode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_ipv6_configuration_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toIpv6ConfigurationMode(result); + } + + /** + * Get the IPv6 field of the given PIF. + * + * @return value of the field + */ + public Set getIPv6(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_IPv6"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the ipv6_gateway field of the given PIF. + * + * @return value of the field + */ + public String getIpv6Gateway(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_ipv6_gateway"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the primary_address_type field of the given PIF. + * + * @return value of the field + */ + public Types.PrimaryAddressType getPrimaryAddressType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_primary_address_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPrimaryAddressType(result); + } + + /** + * Set the other_config field of the given PIF. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given PIF. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given PIF. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the disallow_unplug field of the given PIF. + * + * @param disallowUnplug New value to set + */ + public void setDisallowUnplug(Connection c, Boolean disallowUnplug) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.set_disallow_unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(disallowUnplug)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a VLAN interface from an existing physical interface. This call is deprecated: use VLAN.create instead + * @deprecated + * + * @param device physical interface on which to create the VLAN interface + * @param network network to which this interface should be connected + * @param host physical machine to which this PIF is connected + * @param VLAN VLAN tag for the new interface + * @return Task + */ + @Deprecated public static Task createVLANAsync(Connection c, String device, Network network, Host host, Long VLAN) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VlanTagInvalid { + String method_call = "Async.PIF.create_VLAN"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(VLAN)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a VLAN interface from an existing physical interface. This call is deprecated: use VLAN.create instead + * @deprecated + * + * @param device physical interface on which to create the VLAN interface + * @param network network to which this interface should be connected + * @param host physical machine to which this PIF is connected + * @param VLAN VLAN tag for the new interface + * @return The reference of the created PIF object + */ + @Deprecated public static PIF createVLAN(Connection c, String device, Network network, Host host, Long VLAN) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VlanTagInvalid { + String method_call = "PIF.create_VLAN"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(VLAN)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Destroy the PIF object (provided it is a VLAN interface). This call is deprecated: use VLAN.destroy or Bond.destroy instead + * @deprecated + * + * @return Task + */ + @Deprecated public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.PifIsPhysical { + String method_call = "Async.PIF.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the PIF object (provided it is a VLAN interface). This call is deprecated: use VLAN.destroy or Bond.destroy instead + * @deprecated + * + */ + @Deprecated public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.PifIsPhysical { + String method_call = "PIF.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Reconfigure the IP address settings for this interface + * + * @param mode whether to use dynamic/static/no-assignment + * @param IP the new IP address + * @param netmask the new netmask + * @param gateway the new gateway + * @param DNS the new DNS settings + * @return Task + */ + public Task reconfigureIpAsync(Connection c, Types.IpConfigurationMode mode, String IP, String netmask, String gateway, String DNS) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PIF.reconfigure_ip"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(IP), Marshalling.toXMLRPC(netmask), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Reconfigure the IP address settings for this interface + * + * @param mode whether to use dynamic/static/no-assignment + * @param IP the new IP address + * @param netmask the new netmask + * @param gateway the new gateway + * @param DNS the new DNS settings + */ + public void reconfigureIp(Connection c, Types.IpConfigurationMode mode, String IP, String netmask, String gateway, String DNS) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.reconfigure_ip"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(IP), Marshalling.toXMLRPC(netmask), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Reconfigure the IPv6 address settings for this interface + * + * @param mode whether to use dynamic/static/no-assignment + * @param IPv6 the new IPv6 address (in / format) + * @param gateway the new gateway + * @param DNS the new DNS settings + * @return Task + */ + public Task reconfigureIpv6Async(Connection c, Types.Ipv6ConfigurationMode mode, String IPv6, String gateway, String DNS) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PIF.reconfigure_ipv6"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(IPv6), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Reconfigure the IPv6 address settings for this interface + * + * @param mode whether to use dynamic/static/no-assignment + * @param IPv6 the new IPv6 address (in / format) + * @param gateway the new gateway + * @param DNS the new DNS settings + */ + public void reconfigureIpv6(Connection c, Types.Ipv6ConfigurationMode mode, String IPv6, String gateway, String DNS) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.reconfigure_ipv6"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(IPv6), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Change the primary address type used by this PIF + * + * @param primaryAddressType Whether to prefer IPv4 or IPv6 connections + * @return Task + */ + public Task setPrimaryAddressTypeAsync(Connection c, Types.PrimaryAddressType primaryAddressType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PIF.set_primary_address_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(primaryAddressType)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Change the primary address type used by this PIF + * + * @param primaryAddressType Whether to prefer IPv4 or IPv6 connections + */ + public void setPrimaryAddressType(Connection c, Types.PrimaryAddressType primaryAddressType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.set_primary_address_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(primaryAddressType)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Scan for physical interfaces on a host and create PIF objects to represent them + * + * @param host The host on which to scan + * @return Task + */ + public static Task scanAsync(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PIF.scan"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Scan for physical interfaces on a host and create PIF objects to represent them + * + * @param host The host on which to scan + */ + public static void scan(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.scan"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a PIF object matching a particular network interface + * + * @param host The host on which the interface exists + * @param MAC The MAC address of the interface + * @param device The device name to use for the interface + * @return Task + */ + public static Task introduceAsync(Connection c, Host host, String MAC, String device) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PIF.introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(device)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a PIF object matching a particular network interface + * + * @param host The host on which the interface exists + * @param MAC The MAC address of the interface + * @param device The device name to use for the interface + * @return The reference of the created PIF object + */ + public static PIF introduce(Connection c, Host host, String MAC, String device) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(device)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Destroy the PIF object matching a particular network interface + * + * @return Task + */ + public Task forgetAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.PifTunnelStillExists { + String method_call = "Async.PIF.forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the PIF object matching a particular network interface + * + */ + public void forget(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.PifTunnelStillExists { + String method_call = "PIF.forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Attempt to bring down a physical interface + * + * @return Task + */ + public Task unplugAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PIF.unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Attempt to bring down a physical interface + * + */ + public void unplug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Attempt to bring up a physical interface + * + * @return Task + */ + public Task plugAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.TransportPifNotConfigured { + String method_call = "Async.PIF.plug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Attempt to bring up a physical interface + * + */ + public void plug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.TransportPifNotConfigured { + String method_call = "PIF.plug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a new PIF record in the database only + * + * @param device + * @param network + * @param host + * @param MAC + * @param MTU + * @param VLAN + * @param physical + * @param ipConfigurationMode + * @param IP + * @param netmask + * @param gateway + * @param DNS + * @param bondSlaveOf + * @param VLANMasterOf + * @param management + * @param otherConfig + * @param disallowUnplug + * @param ipv6ConfigurationMode + * @param IPv6 + * @param ipv6Gateway + * @param primaryAddressType + * @return Task + */ + public static Task dbIntroduceAsync(Connection c, String device, Network network, Host host, String MAC, Long MTU, Long VLAN, Boolean physical, Types.IpConfigurationMode ipConfigurationMode, String IP, String netmask, String gateway, String DNS, Bond bondSlaveOf, VLAN VLANMasterOf, Boolean management, Map otherConfig, Boolean disallowUnplug, Types.Ipv6ConfigurationMode ipv6ConfigurationMode, Set IPv6, String ipv6Gateway, Types.PrimaryAddressType primaryAddressType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PIF.db_introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(MTU), Marshalling.toXMLRPC(VLAN), Marshalling.toXMLRPC(physical), Marshalling.toXMLRPC(ipConfigurationMode), Marshalling.toXMLRPC(IP), Marshalling.toXMLRPC(netmask), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS), Marshalling.toXMLRPC(bondSlaveOf), Marshalling.toXMLRPC(VLANMasterOf), Marshalling.toXMLRPC(management), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(disallowUnplug), Marshalling.toXMLRPC(ipv6ConfigurationMode), Marshalling.toXMLRPC(IPv6), Marshalling.toXMLRPC(ipv6Gateway), Marshalling.toXMLRPC(primaryAddressType)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new PIF record in the database only + * + * @param device + * @param network + * @param host + * @param MAC + * @param MTU + * @param VLAN + * @param physical + * @param ipConfigurationMode + * @param IP + * @param netmask + * @param gateway + * @param DNS + * @param bondSlaveOf + * @param VLANMasterOf + * @param management + * @param otherConfig + * @param disallowUnplug + * @param ipv6ConfigurationMode + * @param IPv6 + * @param ipv6Gateway + * @param primaryAddressType + * @return The ref of the newly created PIF record. + */ + public static PIF dbIntroduce(Connection c, String device, Network network, Host host, String MAC, Long MTU, Long VLAN, Boolean physical, Types.IpConfigurationMode ipConfigurationMode, String IP, String netmask, String gateway, String DNS, Bond bondSlaveOf, VLAN VLANMasterOf, Boolean management, Map otherConfig, Boolean disallowUnplug, Types.Ipv6ConfigurationMode ipv6ConfigurationMode, Set IPv6, String ipv6Gateway, Types.PrimaryAddressType primaryAddressType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.db_introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(MTU), Marshalling.toXMLRPC(VLAN), Marshalling.toXMLRPC(physical), Marshalling.toXMLRPC(ipConfigurationMode), Marshalling.toXMLRPC(IP), Marshalling.toXMLRPC(netmask), Marshalling.toXMLRPC(gateway), Marshalling.toXMLRPC(DNS), Marshalling.toXMLRPC(bondSlaveOf), Marshalling.toXMLRPC(VLANMasterOf), Marshalling.toXMLRPC(management), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(disallowUnplug), Marshalling.toXMLRPC(ipv6ConfigurationMode), Marshalling.toXMLRPC(IPv6), Marshalling.toXMLRPC(ipv6Gateway), Marshalling.toXMLRPC(primaryAddressType)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Destroy a PIF database record. + * + * @return Task + */ + public Task dbForgetAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.PIF.db_forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy a PIF database record. + * + */ + public void dbForget(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.db_forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the PIFs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPIF(result); + } + + /** + * Return a map of PIF references to PIF records for all PIFs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfPIFPIFRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java new file mode 100644 index 00000000000..d0a3911d327 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java @@ -0,0 +1,533 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * The metrics associated with a physical network interface + * + * @author Citrix Systems, Inc. + */ +public class PIFMetrics extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + PIFMetrics(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a PIFMetrics, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof PIFMetrics) + { + PIFMetrics other = (PIFMetrics) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a PIFMetrics + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs); + print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs); + print.printf("%1$20s: %2$s\n", "carrier", this.carrier); + print.printf("%1$20s: %2$s\n", "vendorId", this.vendorId); + print.printf("%1$20s: %2$s\n", "vendorName", this.vendorName); + print.printf("%1$20s: %2$s\n", "deviceId", this.deviceId); + print.printf("%1$20s: %2$s\n", "deviceName", this.deviceName); + print.printf("%1$20s: %2$s\n", "speed", this.speed); + print.printf("%1$20s: %2$s\n", "duplex", this.duplex); + print.printf("%1$20s: %2$s\n", "pciBusPath", this.pciBusPath); + print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a PIF_metrics.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs); + map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs); + map.put("carrier", this.carrier == null ? false : this.carrier); + map.put("vendor_id", this.vendorId == null ? "" : this.vendorId); + map.put("vendor_name", this.vendorName == null ? "" : this.vendorName); + map.put("device_id", this.deviceId == null ? "" : this.deviceId); + map.put("device_name", this.deviceName == null ? "" : this.deviceName); + map.put("speed", this.speed == null ? 0 : this.speed); + map.put("duplex", this.duplex == null ? false : this.duplex); + map.put("pci_bus_path", this.pciBusPath == null ? "" : this.pciBusPath); + map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Read bandwidth (KiB/s) + */ + public Double ioReadKbs; + /** + * Write bandwidth (KiB/s) + */ + public Double ioWriteKbs; + /** + * Report if the PIF got a carrier or not + */ + public Boolean carrier; + /** + * Report vendor ID + */ + public String vendorId; + /** + * Report vendor name + */ + public String vendorName; + /** + * Report device ID + */ + public String deviceId; + /** + * Report device name + */ + public String deviceName; + /** + * Speed of the link (if available) + */ + public Long speed; + /** + * Full duplex capability of the link (if available) + */ + public Boolean duplex; + /** + * PCI bus path of the pif (if available) + */ + public String pciBusPath; + /** + * Time at which this information was last updated + */ + public Date lastUpdated; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given PIF_metrics. + * + * @return all fields from the object + */ + public PIFMetrics.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIFMetricsRecord(result); + } + + /** + * Get a reference to the PIF_metrics instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static PIFMetrics getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIFMetrics(result); + } + + /** + * Get the uuid field of the given PIF_metrics. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the io/read_kbs field of the given PIF_metrics. + * + * @return value of the field + */ + public Double getIoReadKbs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_io_read_kbs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the io/write_kbs field of the given PIF_metrics. + * + * @return value of the field + */ + public Double getIoWriteKbs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_io_write_kbs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the carrier field of the given PIF_metrics. + * + * @return value of the field + */ + public Boolean getCarrier(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_carrier"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the vendor_id field of the given PIF_metrics. + * + * @return value of the field + */ + public String getVendorId(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_vendor_id"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the vendor_name field of the given PIF_metrics. + * + * @return value of the field + */ + public String getVendorName(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_vendor_name"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the device_id field of the given PIF_metrics. + * + * @return value of the field + */ + public String getDeviceId(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_device_id"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the device_name field of the given PIF_metrics. + * + * @return value of the field + */ + public String getDeviceName(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_device_name"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the speed field of the given PIF_metrics. + * + * @return value of the field + */ + public Long getSpeed(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_speed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the duplex field of the given PIF_metrics. + * + * @return value of the field + */ + public Boolean getDuplex(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_duplex"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the pci_bus_path field of the given PIF_metrics. + * + * @return value of the field + */ + public String getPciBusPath(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_pci_bus_path"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the last_updated field of the given PIF_metrics. + * + * @return value of the field + */ + public Date getLastUpdated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_last_updated"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the other_config field of the given PIF_metrics. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given PIF_metrics. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given PIF_metrics. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given PIF_metrics. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the PIF_metrics instances known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPIFMetrics(result); + } + + /** + * Return a map of PIF_metrics references to PIF_metrics records for all PIF_metrics instances known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "PIF_metrics.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfPIFMetricsPIFMetricsRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Pool.java b/deps/XenServerJava/src/com/xensource/xenapi/Pool.java new file mode 100644 index 00000000000..2dc0fac9c78 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Pool.java @@ -0,0 +1,2324 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * Pool-wide information + * + * @author Citrix Systems, Inc. + */ +public class Pool extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Pool(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Pool, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Pool) + { + Pool other = (Pool) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Pool + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "master", this.master); + print.printf("%1$20s: %2$s\n", "defaultSR", this.defaultSR); + print.printf("%1$20s: %2$s\n", "suspendImageSR", this.suspendImageSR); + print.printf("%1$20s: %2$s\n", "crashDumpSR", this.crashDumpSR); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "haEnabled", this.haEnabled); + print.printf("%1$20s: %2$s\n", "haConfiguration", this.haConfiguration); + print.printf("%1$20s: %2$s\n", "haStatefiles", this.haStatefiles); + print.printf("%1$20s: %2$s\n", "haHostFailuresToTolerate", this.haHostFailuresToTolerate); + print.printf("%1$20s: %2$s\n", "haPlanExistsFor", this.haPlanExistsFor); + print.printf("%1$20s: %2$s\n", "haAllowOvercommit", this.haAllowOvercommit); + print.printf("%1$20s: %2$s\n", "haOvercommitted", this.haOvercommitted); + print.printf("%1$20s: %2$s\n", "blobs", this.blobs); + print.printf("%1$20s: %2$s\n", "tags", this.tags); + print.printf("%1$20s: %2$s\n", "guiConfig", this.guiConfig); + print.printf("%1$20s: %2$s\n", "wlbUrl", this.wlbUrl); + print.printf("%1$20s: %2$s\n", "wlbUsername", this.wlbUsername); + print.printf("%1$20s: %2$s\n", "wlbEnabled", this.wlbEnabled); + print.printf("%1$20s: %2$s\n", "wlbVerifyCert", this.wlbVerifyCert); + print.printf("%1$20s: %2$s\n", "redoLogEnabled", this.redoLogEnabled); + print.printf("%1$20s: %2$s\n", "redoLogVdi", this.redoLogVdi); + print.printf("%1$20s: %2$s\n", "vswitchController", this.vswitchController); + print.printf("%1$20s: %2$s\n", "restrictions", this.restrictions); + print.printf("%1$20s: %2$s\n", "metadataVDIs", this.metadataVDIs); + return writer.toString(); + } + + /** + * Convert a pool.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("master", this.master == null ? new Host("OpaqueRef:NULL") : this.master); + map.put("default_SR", this.defaultSR == null ? new SR("OpaqueRef:NULL") : this.defaultSR); + map.put("suspend_image_SR", this.suspendImageSR == null ? new SR("OpaqueRef:NULL") : this.suspendImageSR); + map.put("crash_dump_SR", this.crashDumpSR == null ? new SR("OpaqueRef:NULL") : this.crashDumpSR); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("ha_enabled", this.haEnabled == null ? false : this.haEnabled); + map.put("ha_configuration", this.haConfiguration == null ? new HashMap() : this.haConfiguration); + map.put("ha_statefiles", this.haStatefiles == null ? new LinkedHashSet() : this.haStatefiles); + map.put("ha_host_failures_to_tolerate", this.haHostFailuresToTolerate == null ? 0 : this.haHostFailuresToTolerate); + map.put("ha_plan_exists_for", this.haPlanExistsFor == null ? 0 : this.haPlanExistsFor); + map.put("ha_allow_overcommit", this.haAllowOvercommit == null ? false : this.haAllowOvercommit); + map.put("ha_overcommitted", this.haOvercommitted == null ? false : this.haOvercommitted); + map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); + map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); + map.put("gui_config", this.guiConfig == null ? new HashMap() : this.guiConfig); + map.put("wlb_url", this.wlbUrl == null ? "" : this.wlbUrl); + map.put("wlb_username", this.wlbUsername == null ? "" : this.wlbUsername); + map.put("wlb_enabled", this.wlbEnabled == null ? false : this.wlbEnabled); + map.put("wlb_verify_cert", this.wlbVerifyCert == null ? false : this.wlbVerifyCert); + map.put("redo_log_enabled", this.redoLogEnabled == null ? false : this.redoLogEnabled); + map.put("redo_log_vdi", this.redoLogVdi == null ? new VDI("OpaqueRef:NULL") : this.redoLogVdi); + map.put("vswitch_controller", this.vswitchController == null ? "" : this.vswitchController); + map.put("restrictions", this.restrictions == null ? new HashMap() : this.restrictions); + map.put("metadata_VDIs", this.metadataVDIs == null ? new LinkedHashSet() : this.metadataVDIs); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Short name + */ + public String nameLabel; + /** + * Description + */ + public String nameDescription; + /** + * The host that is pool master + */ + public Host master; + /** + * Default SR for VDIs + */ + public SR defaultSR; + /** + * The SR in which VDIs for suspend images are created + */ + public SR suspendImageSR; + /** + * The SR in which VDIs for crash dumps are created + */ + public SR crashDumpSR; + /** + * additional configuration + */ + public Map otherConfig; + /** + * true if HA is enabled on the pool, false otherwise + */ + public Boolean haEnabled; + /** + * The current HA configuration + */ + public Map haConfiguration; + /** + * HA statefile VDIs in use + */ + public Set haStatefiles; + /** + * Number of host failures to tolerate before the Pool is declared to be overcommitted + */ + public Long haHostFailuresToTolerate; + /** + * Number of future host failures we have managed to find a plan for. Once this reaches zero any future host failures will cause the failure of protected VMs. + */ + public Long haPlanExistsFor; + /** + * If set to false then operations which would cause the Pool to become overcommitted will be blocked. + */ + public Boolean haAllowOvercommit; + /** + * True if the Pool is considered to be overcommitted i.e. if there exist insufficient physical resources to tolerate the configured number of host failures + */ + public Boolean haOvercommitted; + /** + * Binary blobs associated with this pool + */ + public Map blobs; + /** + * user-specified tags for categorization purposes + */ + public Set tags; + /** + * gui-specific configuration for pool + */ + public Map guiConfig; + /** + * Url for the configured workload balancing host + */ + public String wlbUrl; + /** + * Username for accessing the workload balancing host + */ + public String wlbUsername; + /** + * true if workload balancing is enabled on the pool, false otherwise + */ + public Boolean wlbEnabled; + /** + * true if communication with the WLB server should enforce SSL certificate verification. + */ + public Boolean wlbVerifyCert; + /** + * true a redo-log is to be used other than when HA is enabled, false otherwise + */ + public Boolean redoLogEnabled; + /** + * indicates the VDI to use for the redo-log other than when HA is enabled + */ + public VDI redoLogVdi; + /** + * address of the vswitch controller + */ + public String vswitchController; + /** + * Pool-wide restrictions currently in effect + */ + public Map restrictions; + /** + * The set of currently known metadata VDIs for this pool + */ + public Set metadataVDIs; + } + + /** + * Get a record containing the current state of the given pool. + * + * @return all fields from the object + */ + public Pool.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPoolRecord(result); + } + + /** + * Get a reference to the pool instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Pool getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPool(result); + } + + /** + * Get the uuid field of the given pool. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name_label field of the given pool. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name_description field of the given pool. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the master field of the given pool. + * + * @return value of the field + */ + public Host getMaster(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_master"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the default_SR field of the given pool. + * + * @return value of the field + */ + public SR getDefaultSR(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_default_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the suspend_image_SR field of the given pool. + * + * @return value of the field + */ + public SR getSuspendImageSR(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_suspend_image_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the crash_dump_SR field of the given pool. + * + * @return value of the field + */ + public SR getCrashDumpSR(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_crash_dump_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the other_config field of the given pool. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the ha_enabled field of the given pool. + * + * @return value of the field + */ + public Boolean getHaEnabled(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_ha_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the ha_configuration field of the given pool. + * + * @return value of the field + */ + public Map getHaConfiguration(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_ha_configuration"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the ha_statefiles field of the given pool. + * + * @return value of the field + */ + public Set getHaStatefiles(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_ha_statefiles"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the ha_host_failures_to_tolerate field of the given pool. + * + * @return value of the field + */ + public Long getHaHostFailuresToTolerate(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_ha_host_failures_to_tolerate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the ha_plan_exists_for field of the given pool. + * + * @return value of the field + */ + public Long getHaPlanExistsFor(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_ha_plan_exists_for"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the ha_allow_overcommit field of the given pool. + * + * @return value of the field + */ + public Boolean getHaAllowOvercommit(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_ha_allow_overcommit"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the ha_overcommitted field of the given pool. + * + * @return value of the field + */ + public Boolean getHaOvercommitted(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_ha_overcommitted"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the blobs field of the given pool. + * + * @return value of the field + */ + public Map getBlobs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_blobs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringBlob(result); + } + + /** + * Get the tags field of the given pool. + * + * @return value of the field + */ + public Set getTags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the gui_config field of the given pool. + * + * @return value of the field + */ + public Map getGuiConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_gui_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the wlb_url field of the given pool. + * + * @return value of the field + */ + public String getWlbUrl(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_wlb_url"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the wlb_username field of the given pool. + * + * @return value of the field + */ + public String getWlbUsername(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_wlb_username"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the wlb_enabled field of the given pool. + * + * @return value of the field + */ + public Boolean getWlbEnabled(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_wlb_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the wlb_verify_cert field of the given pool. + * + * @return value of the field + */ + public Boolean getWlbVerifyCert(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_wlb_verify_cert"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the redo_log_enabled field of the given pool. + * + * @return value of the field + */ + public Boolean getRedoLogEnabled(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_redo_log_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the redo_log_vdi field of the given pool. + * + * @return value of the field + */ + public VDI getRedoLogVdi(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_redo_log_vdi"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Get the vswitch_controller field of the given pool. + * + * @return value of the field + */ + public String getVswitchController(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_vswitch_controller"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the restrictions field of the given pool. + * + * @return value of the field + */ + public Map getRestrictions(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_restrictions"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the metadata_VDIs field of the given pool. + * + * @return value of the field + */ + public Set getMetadataVDIs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_metadata_VDIs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVDI(result); + } + + /** + * Set the name_label field of the given pool. + * + * @param nameLabel New value to set + */ + public void setNameLabel(Connection c, String nameLabel) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(nameLabel)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name_description field of the given pool. + * + * @param nameDescription New value to set + */ + public void setNameDescription(Connection c, String nameDescription) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(nameDescription)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the default_SR field of the given pool. + * + * @param defaultSR New value to set + */ + public void setDefaultSR(Connection c, SR defaultSR) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_default_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(defaultSR)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the suspend_image_SR field of the given pool. + * + * @param suspendImageSR New value to set + */ + public void setSuspendImageSR(Connection c, SR suspendImageSR) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_suspend_image_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(suspendImageSR)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the crash_dump_SR field of the given pool. + * + * @param crashDumpSR New value to set + */ + public void setCrashDumpSR(Connection c, SR crashDumpSR) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_crash_dump_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(crashDumpSR)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given pool. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given pool. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given pool. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the ha_allow_overcommit field of the given pool. + * + * @param haAllowOvercommit New value to set + */ + public void setHaAllowOvercommit(Connection c, Boolean haAllowOvercommit) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_ha_allow_overcommit"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(haAllowOvercommit)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the tags field of the given pool. + * + * @param tags New value to set + */ + public void setTags(Connection c, Set tags) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given value to the tags field of the given pool. If the value is already in that Set, then do nothing. + * + * @param value New value to add + */ + public void addTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.add_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given value from the tags field of the given pool. If the value is not in that Set, then do nothing. + * + * @param value Value to remove + */ + public void removeTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.remove_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the gui_config field of the given pool. + * + * @param guiConfig New value to set + */ + public void setGuiConfig(Connection c, Map guiConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_gui_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(guiConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the gui_config field of the given pool. + * + * @param key Key to add + * @param value Value to add + */ + public void addToGuiConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.add_to_gui_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the gui_config field of the given pool. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromGuiConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.remove_from_gui_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the wlb_enabled field of the given pool. + * + * @param wlbEnabled New value to set + */ + public void setWlbEnabled(Connection c, Boolean wlbEnabled) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_wlb_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(wlbEnabled)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the wlb_verify_cert field of the given pool. + * + * @param wlbVerifyCert New value to set + */ + public void setWlbVerifyCert(Connection c, Boolean wlbVerifyCert) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_wlb_verify_cert"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(wlbVerifyCert)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Instruct host to join a new pool + * + * @param masterAddress The hostname of the master of the pool to join + * @param masterUsername The username of the master (for initial authentication) + * @param masterPassword The password for the master (for initial authentication) + * @return Task + */ + public static Task joinAsync(Connection c, String masterAddress, String masterUsername, String masterPassword) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.JoiningHostCannotContainSharedSrs { + String method_call = "Async.pool.join"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress), Marshalling.toXMLRPC(masterUsername), Marshalling.toXMLRPC(masterPassword)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Instruct host to join a new pool + * + * @param masterAddress The hostname of the master of the pool to join + * @param masterUsername The username of the master (for initial authentication) + * @param masterPassword The password for the master (for initial authentication) + */ + public static void join(Connection c, String masterAddress, String masterUsername, String masterPassword) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.JoiningHostCannotContainSharedSrs { + String method_call = "pool.join"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress), Marshalling.toXMLRPC(masterUsername), Marshalling.toXMLRPC(masterPassword)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Instruct host to join a new pool + * + * @param masterAddress The hostname of the master of the pool to join + * @param masterUsername The username of the master (for initial authentication) + * @param masterPassword The password for the master (for initial authentication) + * @return Task + */ + public static Task joinForceAsync(Connection c, String masterAddress, String masterUsername, String masterPassword) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.join_force"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress), Marshalling.toXMLRPC(masterUsername), Marshalling.toXMLRPC(masterPassword)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Instruct host to join a new pool + * + * @param masterAddress The hostname of the master of the pool to join + * @param masterUsername The username of the master (for initial authentication) + * @param masterPassword The password for the master (for initial authentication) + */ + public static void joinForce(Connection c, String masterAddress, String masterUsername, String masterPassword) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.join_force"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress), Marshalling.toXMLRPC(masterUsername), Marshalling.toXMLRPC(masterPassword)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Instruct a pool master to eject a host from the pool + * + * @param host The host to eject + * @return Task + */ + public static Task ejectAsync(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.eject"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Instruct a pool master to eject a host from the pool + * + * @param host The host to eject + */ + public static void eject(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.eject"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Instruct host that's currently a slave to transition to being master + * + */ + public static void emergencyTransitionToMaster(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.emergency_transition_to_master"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Instruct a slave already in a pool that the master has changed + * + * @param masterAddress The hostname of the master + */ + public static void emergencyResetMaster(Connection c, String masterAddress) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.emergency_reset_master"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(masterAddress)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Instruct a pool master, M, to try and contact its slaves and, if slaves are in emergency mode, reset their master address to M. + * + * @return Task + */ + public static Task recoverSlavesAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.recover_slaves"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Instruct a pool master, M, to try and contact its slaves and, if slaves are in emergency mode, reset their master address to M. + * + * @return list of hosts whose master address were succesfully reset + */ + public static Set recoverSlaves(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.recover_slaves"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHost(result); + } + + /** + * Create PIFs, mapping a network to the same physical interface/VLAN on each host. This call is deprecated: use Pool.create_VLAN_from_PIF instead. + * + * @param device physical interface on which to create the VLAN interface + * @param network network to which this interface should be connected + * @param VLAN VLAN tag for the new interface + * @return Task + */ + public static Task createVLANAsync(Connection c, String device, Network network, Long VLAN) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VlanTagInvalid { + String method_call = "Async.pool.create_VLAN"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(VLAN)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create PIFs, mapping a network to the same physical interface/VLAN on each host. This call is deprecated: use Pool.create_VLAN_from_PIF instead. + * + * @param device physical interface on which to create the VLAN interface + * @param network network to which this interface should be connected + * @param VLAN VLAN tag for the new interface + * @return The references of the created PIF objects + */ + public static Set createVLAN(Connection c, String device, Network network, Long VLAN) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VlanTagInvalid { + String method_call = "pool.create_VLAN"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(VLAN)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPIF(result); + } + + /** + * Create a pool-wide VLAN by taking the PIF. + * + * @param pif physical interface on any particular host, that identifies the PIF on which to create the (pool-wide) VLAN interface + * @param network network to which this interface should be connected + * @param VLAN VLAN tag for the new interface + * @return Task + */ + public static Task createVLANFromPIFAsync(Connection c, PIF pif, Network network, Long VLAN) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VlanTagInvalid { + String method_call = "Async.pool.create_VLAN_from_PIF"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(pif), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(VLAN)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a pool-wide VLAN by taking the PIF. + * + * @param pif physical interface on any particular host, that identifies the PIF on which to create the (pool-wide) VLAN interface + * @param network network to which this interface should be connected + * @param VLAN VLAN tag for the new interface + * @return The references of the created PIF objects + */ + public static Set createVLANFromPIF(Connection c, PIF pif, Network network, Long VLAN) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VlanTagInvalid { + String method_call = "pool.create_VLAN_from_PIF"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(pif), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(VLAN)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPIF(result); + } + + /** + * Turn on High Availability mode + * + * @param heartbeatSrs Set of SRs to use for storage heartbeating. + * @param configuration Detailed HA configuration to apply + * @return Task + */ + public static Task enableHaAsync(Connection c, Set heartbeatSrs, Map configuration) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.enable_ha"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(heartbeatSrs), Marshalling.toXMLRPC(configuration)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Turn on High Availability mode + * + * @param heartbeatSrs Set of SRs to use for storage heartbeating. + * @param configuration Detailed HA configuration to apply + */ + public static void enableHa(Connection c, Set heartbeatSrs, Map configuration) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.enable_ha"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(heartbeatSrs), Marshalling.toXMLRPC(configuration)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Turn off High Availability mode + * + * @return Task + */ + public static Task disableHaAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.disable_ha"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Turn off High Availability mode + * + */ + public static void disableHa(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.disable_ha"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Forcibly synchronise the database now + * + * @return Task + */ + public static Task syncDatabaseAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.sync_database"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Forcibly synchronise the database now + * + */ + public static void syncDatabase(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.sync_database"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Perform an orderly handover of the role of master to the referenced host. + * + * @param host The host who should become the new master + * @return Task + */ + public static Task designateNewMasterAsync(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.designate_new_master"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Perform an orderly handover of the role of master to the referenced host. + * + * @param host The host who should become the new master + */ + public static void designateNewMaster(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.designate_new_master"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * When this call returns the VM restart logic will not run for the requested number of seconds. If the argument is zero then the restart thread is immediately unblocked + * + * @param seconds The number of seconds to block the restart thread for + */ + public static void haPreventRestartsFor(Connection c, Long seconds) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.ha_prevent_restarts_for"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(seconds)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Returns true if a VM failover plan exists for up to 'n' host failures + * + * @param n The number of host failures to plan for + * @return true if a failover plan exists for the supplied number of host failures + */ + public static Boolean haFailoverPlanExists(Connection c, Long n) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.ha_failover_plan_exists"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(n)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Returns the maximum number of host failures we could tolerate before we would be unable to restart configured VMs + * + * @return maximum value for ha_host_failures_to_tolerate given current configuration + */ + public static Long haComputeMaxHostFailuresToTolerate(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.ha_compute_max_host_failures_to_tolerate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Returns the maximum number of host failures we could tolerate before we would be unable to restart the provided VMs + * + * @param configuration Map of protected VM reference to restart priority + * @return maximum value for ha_host_failures_to_tolerate given provided configuration + */ + public static Long haComputeHypotheticalMaxHostFailuresToTolerate(Connection c, Map configuration) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.ha_compute_hypothetical_max_host_failures_to_tolerate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(configuration)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Return a VM failover plan assuming a given subset of hosts fail + * + * @param failedHosts The set of hosts to assume have failed + * @param failedVms The set of VMs to restart + * @return VM failover plan: a map of VM to host to restart the host on + */ + public static Map> haComputeVmFailoverPlan(Connection c, Set failedHosts, Set failedVms) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.ha_compute_vm_failover_plan"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(failedHosts), Marshalling.toXMLRPC(failedVms)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMMapOfStringString(result); + } + + /** + * Set the maximum number of host failures to consider in the HA VM restart planner + * + * @param value New number of host failures to consider + * @return Task + */ + public Task setHaHostFailuresToTolerateAsync(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.set_ha_host_failures_to_tolerate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the maximum number of host failures to consider in the HA VM restart planner + * + * @param value New number of host failures to consider + */ + public void setHaHostFailuresToTolerate(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_ha_host_failures_to_tolerate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this pool + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return Task + */ + public Task createNewBlobAsync(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this pool + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return The reference of the blob, needed for populating its data + */ + public Blob createNewBlob(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBlob(result); + } + + /** + * This call enables external authentication on all the hosts of the pool + * + * @param config A list of key-values containing the configuration data + * @param serviceName The name of the service + * @param authType The type of authentication (e.g. AD for Active Directory) + */ + public void enableExternalAuth(Connection c, Map config, String serviceName, String authType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.enable_external_auth"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config), Marshalling.toXMLRPC(serviceName), Marshalling.toXMLRPC(authType)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call disables external authentication on all the hosts of the pool + * + * @param config Optional parameters as a list of key-values containing the configuration data + */ + public void disableExternalAuth(Connection c, Map config) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.disable_external_auth"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call asynchronously detects if the external authentication configuration in any slave is different from that in the master and raises appropriate alerts + * + */ + public void detectNonhomogeneousExternalAuth(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.detect_nonhomogeneous_external_auth"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Initializes workload balancing monitoring on this pool with the specified wlb server + * + * @param wlbUrl The ip address and port to use when accessing the wlb server + * @param wlbUsername The username used to authenticate with the wlb server + * @param wlbPassword The password used to authenticate with the wlb server + * @param xenserverUsername The usernamed used by the wlb server to authenticate with the xenserver + * @param xenserverPassword The password used by the wlb server to authenticate with the xenserver + * @return Task + */ + public static Task initializeWlbAsync(Connection c, String wlbUrl, String wlbUsername, String wlbPassword, String xenserverUsername, String xenserverPassword) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.initialize_wlb"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(wlbUrl), Marshalling.toXMLRPC(wlbUsername), Marshalling.toXMLRPC(wlbPassword), Marshalling.toXMLRPC(xenserverUsername), Marshalling.toXMLRPC(xenserverPassword)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Initializes workload balancing monitoring on this pool with the specified wlb server + * + * @param wlbUrl The ip address and port to use when accessing the wlb server + * @param wlbUsername The username used to authenticate with the wlb server + * @param wlbPassword The password used to authenticate with the wlb server + * @param xenserverUsername The usernamed used by the wlb server to authenticate with the xenserver + * @param xenserverPassword The password used by the wlb server to authenticate with the xenserver + */ + public static void initializeWlb(Connection c, String wlbUrl, String wlbUsername, String wlbPassword, String xenserverUsername, String xenserverPassword) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.initialize_wlb"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(wlbUrl), Marshalling.toXMLRPC(wlbUsername), Marshalling.toXMLRPC(wlbPassword), Marshalling.toXMLRPC(xenserverUsername), Marshalling.toXMLRPC(xenserverPassword)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Permanently deconfigures workload balancing monitoring on this pool + * + * @return Task + */ + public static Task deconfigureWlbAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.deconfigure_wlb"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Permanently deconfigures workload balancing monitoring on this pool + * + */ + public static void deconfigureWlb(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.deconfigure_wlb"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the pool optimization criteria for the workload balancing server + * + * @param config The configuration to use in optimizing this pool + * @return Task + */ + public static Task sendWlbConfigurationAsync(Connection c, Map config) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.send_wlb_configuration"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(config)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Sets the pool optimization criteria for the workload balancing server + * + * @param config The configuration to use in optimizing this pool + */ + public static void sendWlbConfiguration(Connection c, Map config) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.send_wlb_configuration"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(config)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Retrieves the pool optimization criteria from the workload balancing server + * + * @return Task + */ + public static Task retrieveWlbConfigurationAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.retrieve_wlb_configuration"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Retrieves the pool optimization criteria from the workload balancing server + * + * @return The configuration used in optimizing this pool + */ + public static Map retrieveWlbConfiguration(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.retrieve_wlb_configuration"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Retrieves vm migrate recommendations for the pool from the workload balancing server + * + * @return Task + */ + public static Task retrieveWlbRecommendationsAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.retrieve_wlb_recommendations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Retrieves vm migrate recommendations for the pool from the workload balancing server + * + * @return The list of vm migration recommendations + */ + public static Map> retrieveWlbRecommendations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.retrieve_wlb_recommendations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMSetOfString(result); + } + + /** + * Send the given body to the given host and port, using HTTPS, and print the response. This is used for debugging the SSL layer. + * + * @param host + * @param port + * @param body + * @return Task + */ + public static Task sendTestPostAsync(Connection c, String host, Long port, String body) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.send_test_post"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(port), Marshalling.toXMLRPC(body)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Send the given body to the given host and port, using HTTPS, and print the response. This is used for debugging the SSL layer. + * + * @param host + * @param port + * @param body + * @return The response + */ + public static String sendTestPost(Connection c, String host, Long port, String body) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.send_test_post"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(port), Marshalling.toXMLRPC(body)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Install an SSL certificate pool-wide. + * + * @param name A name to give the certificate + * @param cert The certificate + * @return Task + */ + public static Task certificateInstallAsync(Connection c, String name, String cert) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.certificate_install"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(cert)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Install an SSL certificate pool-wide. + * + * @param name A name to give the certificate + * @param cert The certificate + */ + public static void certificateInstall(Connection c, String name, String cert) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.certificate_install"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(cert)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove an SSL certificate. + * + * @param name The certificate name + * @return Task + */ + public static Task certificateUninstallAsync(Connection c, String name) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.certificate_uninstall"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Remove an SSL certificate. + * + * @param name The certificate name + */ + public static void certificateUninstall(Connection c, String name) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.certificate_uninstall"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * List all installed SSL certificates. + * + * @return Task + */ + public static Task certificateListAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.certificate_list"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * List all installed SSL certificates. + * + * @return All installed certificates + */ + public static Set certificateList(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.certificate_list"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Install an SSL certificate revocation list, pool-wide. + * + * @param name A name to give the CRL + * @param cert The CRL + * @return Task + */ + public static Task crlInstallAsync(Connection c, String name, String cert) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.crl_install"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(cert)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Install an SSL certificate revocation list, pool-wide. + * + * @param name A name to give the CRL + * @param cert The CRL + */ + public static void crlInstall(Connection c, String name, String cert) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.crl_install"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(cert)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove an SSL certificate revocation list. + * + * @param name The CRL name + * @return Task + */ + public static Task crlUninstallAsync(Connection c, String name) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.crl_uninstall"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Remove an SSL certificate revocation list. + * + * @param name The CRL name + */ + public static void crlUninstall(Connection c, String name) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.crl_uninstall"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * List all installed SSL certificate revocation lists. + * + * @return Task + */ + public static Task crlListAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.crl_list"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * List all installed SSL certificate revocation lists. + * + * @return All installed CRLs + */ + public static Set crlList(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.crl_list"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Sync SSL certificates from master to slaves. + * + * @return Task + */ + public static Task certificateSyncAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.certificate_sync"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Sync SSL certificates from master to slaves. + * + */ + public static void certificateSync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.certificate_sync"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Enable the redo log on the given SR and start using it, unless HA is enabled. + * + * @param sr SR to hold the redo log. + * @return Task + */ + public static Task enableRedoLogAsync(Connection c, SR sr) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.enable_redo_log"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(sr)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Enable the redo log on the given SR and start using it, unless HA is enabled. + * + * @param sr SR to hold the redo log. + */ + public static void enableRedoLog(Connection c, SR sr) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.enable_redo_log"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(sr)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Disable the redo log if in use, unless HA is enabled. + * + * @return Task + */ + public static Task disableRedoLogAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.disable_redo_log"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Disable the redo log if in use, unless HA is enabled. + * + */ + public static void disableRedoLog(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.disable_redo_log"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the IP address of the vswitch controller. + * + * @param address IP address of the vswitch controller. + * @return Task + */ + public static Task setVswitchControllerAsync(Connection c, String address) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.set_vswitch_controller"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(address)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the IP address of the vswitch controller. + * + * @param address IP address of the vswitch controller. + */ + public static void setVswitchController(Connection c, String address) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.set_vswitch_controller"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(address)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call tests if a location is valid + * + * @param config Location config settings to test + * @return An XMLRPC result + */ + public String testArchiveTarget(Connection c, Map config) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.test_archive_target"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(config)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * This call attempts to enable pool-wide local storage caching + * + * @return Task + */ + public Task enableLocalStorageCachingAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.enable_local_storage_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * This call attempts to enable pool-wide local storage caching + * + */ + public void enableLocalStorageCaching(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.enable_local_storage_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call disables pool-wide local storage caching + * + * @return Task + */ + public Task disableLocalStorageCachingAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool.disable_local_storage_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * This call disables pool-wide local storage caching + * + */ + public void disableLocalStorageCaching(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.disable_local_storage_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the pools known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPool(result); + } + + /** + * Return a map of pool references to pool records for all pools known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfPoolPoolRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java b/deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java new file mode 100644 index 00000000000..750a9f3225c --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java @@ -0,0 +1,693 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * Pool-wide patches + * + * @author Citrix Systems, Inc. + */ +public class PoolPatch extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + PoolPatch(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a PoolPatch, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof PoolPatch) + { + PoolPatch other = (PoolPatch) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a PoolPatch + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "version", this.version); + print.printf("%1$20s: %2$s\n", "size", this.size); + print.printf("%1$20s: %2$s\n", "poolApplied", this.poolApplied); + print.printf("%1$20s: %2$s\n", "hostPatches", this.hostPatches); + print.printf("%1$20s: %2$s\n", "afterApplyGuidance", this.afterApplyGuidance); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a pool_patch.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("version", this.version == null ? "" : this.version); + map.put("size", this.size == null ? 0 : this.size); + map.put("pool_applied", this.poolApplied == null ? false : this.poolApplied); + map.put("host_patches", this.hostPatches == null ? new LinkedHashSet() : this.hostPatches); + map.put("after_apply_guidance", this.afterApplyGuidance == null ? new LinkedHashSet() : this.afterApplyGuidance); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * Patch version number + */ + public String version; + /** + * Size of the patch + */ + public Long size; + /** + * This patch should be applied across the entire pool + */ + public Boolean poolApplied; + /** + * This hosts this patch is applied to. + */ + public Set hostPatches; + /** + * What the client should do after this patch has been applied. + */ + public Set afterApplyGuidance; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given pool_patch. + * + * @return all fields from the object + */ + public PoolPatch.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPoolPatchRecord(result); + } + + /** + * Get a reference to the pool_patch instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static PoolPatch getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPoolPatch(result); + } + + /** + * Get all the pool_patch instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPoolPatch(result); + } + + /** + * Get the uuid field of the given pool_patch. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given pool_patch. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given pool_patch. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the version field of the given pool_patch. + * + * @return value of the field + */ + public String getVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the size field of the given pool_patch. + * + * @return value of the field + */ + public Long getSize(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_size"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the pool_applied field of the given pool_patch. + * + * @return value of the field + */ + public Boolean getPoolApplied(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_pool_applied"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the host_patches field of the given pool_patch. + * + * @return value of the field + */ + public Set getHostPatches(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_host_patches"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHostPatch(result); + } + + /** + * Get the after_apply_guidance field of the given pool_patch. + * + * @return value of the field + */ + public Set getAfterApplyGuidance(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_after_apply_guidance"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfAfterApplyGuidance(result); + } + + /** + * Get the other_config field of the given pool_patch. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given pool_patch. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given pool_patch. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given pool_patch. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Apply the selected patch to a host and return its output + * + * @param host The host to apply the patch too + * @return Task + */ + public Task applyAsync(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool_patch.apply"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Apply the selected patch to a host and return its output + * + * @param host The host to apply the patch too + * @return the output of the patch application process + */ + public String apply(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.apply"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Apply the selected patch to all hosts in the pool and return a map of host_ref -> patch output + * + * @return Task + */ + public Task poolApplyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool_patch.pool_apply"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Apply the selected patch to all hosts in the pool and return a map of host_ref -> patch output + * + */ + public void poolApply(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.pool_apply"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Execute the precheck stage of the selected patch on a host and return its output + * + * @param host The host to run the prechecks on + * @return Task + */ + public Task precheckAsync(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool_patch.precheck"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Execute the precheck stage of the selected patch on a host and return its output + * + * @param host The host to run the prechecks on + * @return the output of the patch prechecks + */ + public String precheck(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.precheck"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Removes the patch's files from the server + * + * @return Task + */ + public Task cleanAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool_patch.clean"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removes the patch's files from the server + * + */ + public void clean(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.clean"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Removes the patch's files from all hosts in the pool, but does not remove the database entries + * + * @return Task + */ + public Task poolCleanAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool_patch.pool_clean"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removes the patch's files from all hosts in the pool, but does not remove the database entries + * + */ + public void poolClean(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.pool_clean"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Removes the patch's files from all hosts in the pool, and removes the database entries. Only works on unapplied patches. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool_patch.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removes the patch's files from all hosts in the pool, and removes the database entries. Only works on unapplied patches. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Removes the patch's files from the specified host + * + * @param host The host on which to clean the patch + * @return Task + */ + public Task cleanOnHostAsync(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.pool_patch.clean_on_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removes the patch's files from the specified host + * + * @param host The host on which to clean the patch + */ + public void cleanOnHost(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.clean_on_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the pool_patchs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPoolPatch(result); + } + + /** + * Return a map of pool_patch references to pool_patch records for all pool_patchs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "pool_patch.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfPoolPatchPoolPatchRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Role.java b/deps/XenServerJava/src/com/xensource/xenapi/Role.java new file mode 100644 index 00000000000..f8dea77010b --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Role.java @@ -0,0 +1,364 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A set of permissions associated with a subject + * + * @author Citrix Systems, Inc. + */ +public class Role extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Role(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Role, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Role) + { + Role other = (Role) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Role + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "subroles", this.subroles); + return writer.toString(); + } + + /** + * Convert a role.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("subroles", this.subroles == null ? new LinkedHashSet() : this.subroles); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a short user-friendly name for the role + */ + public String nameLabel; + /** + * what this role is for + */ + public String nameDescription; + /** + * a list of pointers to other roles or permissions + */ + public Set subroles; + } + + /** + * Get a record containing the current state of the given role. + * + * @return all fields from the object + */ + public Role.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toRoleRecord(result); + } + + /** + * Get a reference to the role instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Role getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toRole(result); + } + + /** + * Get all the role instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfRole(result); + } + + /** + * Get the uuid field of the given role. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given role. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given role. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the subroles field of the given role. + * + * @return value of the field + */ + public Set getSubroles(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_subroles"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfRole(result); + } + + /** + * This call returns a list of permissions given a role + * + * @return a list of permissions + */ + public Set getPermissions(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_permissions"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfRole(result); + } + + /** + * This call returns a list of permission names given a role + * + * @return a list of permission names + */ + public Set getPermissionsNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_permissions_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * This call returns a list of roles given a permission + * + * @return a list of references to roles + */ + public Set getByPermission(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_by_permission"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfRole(result); + } + + /** + * This call returns a list of roles given a permission name + * + * @param label The short friendly name of the role + * @return a list of references to roles + */ + public static Set getByPermissionNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_by_permission_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfRole(result); + } + + /** + * Return a list of all the roles known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfRole(result); + } + + /** + * Return a map of role references to role records for all roles known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "role.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfRoleRoleRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/SM.java b/deps/XenServerJava/src/com/xensource/xenapi/SM.java new file mode 100644 index 00000000000..9c7341ceb10 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/SM.java @@ -0,0 +1,528 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A storage manager plugin + * + * @author Citrix Systems, Inc. + */ +public class SM extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + SM(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a SM, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof SM) + { + SM other = (SM) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a SM + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "type", this.type); + print.printf("%1$20s: %2$s\n", "vendor", this.vendor); + print.printf("%1$20s: %2$s\n", "copyright", this.copyright); + print.printf("%1$20s: %2$s\n", "version", this.version); + print.printf("%1$20s: %2$s\n", "requiredApiVersion", this.requiredApiVersion); + print.printf("%1$20s: %2$s\n", "configuration", this.configuration); + print.printf("%1$20s: %2$s\n", "capabilities", this.capabilities); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "driverFilename", this.driverFilename); + return writer.toString(); + } + + /** + * Convert a SM.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("type", this.type == null ? "" : this.type); + map.put("vendor", this.vendor == null ? "" : this.vendor); + map.put("copyright", this.copyright == null ? "" : this.copyright); + map.put("version", this.version == null ? "" : this.version); + map.put("required_api_version", this.requiredApiVersion == null ? "" : this.requiredApiVersion); + map.put("configuration", this.configuration == null ? new HashMap() : this.configuration); + map.put("capabilities", this.capabilities == null ? new LinkedHashSet() : this.capabilities); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("driver_filename", this.driverFilename == null ? "" : this.driverFilename); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * SR.type + */ + public String type; + /** + * Vendor who created this plugin + */ + public String vendor; + /** + * Entity which owns the copyright of this plugin + */ + public String copyright; + /** + * Version of the plugin + */ + public String version; + /** + * Minimum SM API version required on the server + */ + public String requiredApiVersion; + /** + * names and descriptions of device config keys + */ + public Map configuration; + /** + * capabilities of the SM plugin + */ + public Set capabilities; + /** + * additional configuration + */ + public Map otherConfig; + /** + * filename of the storage driver + */ + public String driverFilename; + } + + /** + * Get a record containing the current state of the given SM. + * + * @return all fields from the object + */ + public SM.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSMRecord(result); + } + + /** + * Get a reference to the SM instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static SM getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSM(result); + } + + /** + * Get all the SM instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfSM(result); + } + + /** + * Get the uuid field of the given SM. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given SM. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given SM. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the type field of the given SM. + * + * @return value of the field + */ + public String getType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the vendor field of the given SM. + * + * @return value of the field + */ + public String getVendor(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_vendor"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the copyright field of the given SM. + * + * @return value of the field + */ + public String getCopyright(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_copyright"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the version field of the given SM. + * + * @return value of the field + */ + public String getVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the required_api_version field of the given SM. + * + * @return value of the field + */ + public String getRequiredApiVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_required_api_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the configuration field of the given SM. + * + * @return value of the field + */ + public Map getConfiguration(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_configuration"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the capabilities field of the given SM. + * + * @return value of the field + */ + public Set getCapabilities(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_capabilities"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the other_config field of the given SM. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the driver_filename field of the given SM. + * + * @return value of the field + */ + public String getDriverFilename(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_driver_filename"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Set the other_config field of the given SM. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given SM. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given SM. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the SMs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfSM(result); + } + + /** + * Return a map of SM references to SM records for all SMs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SM.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfSMSMRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/SR.java b/deps/XenServerJava/src/com/xensource/xenapi/SR.java new file mode 100644 index 00000000000..72314032506 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/SR.java @@ -0,0 +1,1639 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A storage repository + * + * @author Citrix Systems, Inc. + */ +public class SR extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + SR(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a SR, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof SR) + { + SR other = (SR) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a SR + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "VDIs", this.VDIs); + print.printf("%1$20s: %2$s\n", "PBDs", this.PBDs); + print.printf("%1$20s: %2$s\n", "virtualAllocation", this.virtualAllocation); + print.printf("%1$20s: %2$s\n", "physicalUtilisation", this.physicalUtilisation); + print.printf("%1$20s: %2$s\n", "physicalSize", this.physicalSize); + print.printf("%1$20s: %2$s\n", "type", this.type); + print.printf("%1$20s: %2$s\n", "contentType", this.contentType); + print.printf("%1$20s: %2$s\n", "shared", this.shared); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "tags", this.tags); + print.printf("%1$20s: %2$s\n", "smConfig", this.smConfig); + print.printf("%1$20s: %2$s\n", "blobs", this.blobs); + print.printf("%1$20s: %2$s\n", "localCacheEnabled", this.localCacheEnabled); + print.printf("%1$20s: %2$s\n", "introducedBy", this.introducedBy); + return writer.toString(); + } + + /** + * Convert a SR.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("VDIs", this.VDIs == null ? new LinkedHashSet() : this.VDIs); + map.put("PBDs", this.PBDs == null ? new LinkedHashSet() : this.PBDs); + map.put("virtual_allocation", this.virtualAllocation == null ? 0 : this.virtualAllocation); + map.put("physical_utilisation", this.physicalUtilisation == null ? 0 : this.physicalUtilisation); + map.put("physical_size", this.physicalSize == null ? 0 : this.physicalSize); + map.put("type", this.type == null ? "" : this.type); + map.put("content_type", this.contentType == null ? "" : this.contentType); + map.put("shared", this.shared == null ? false : this.shared); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); + map.put("sm_config", this.smConfig == null ? new HashMap() : this.smConfig); + map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); + map.put("local_cache_enabled", this.localCacheEnabled == null ? false : this.localCacheEnabled); + map.put("introduced_by", this.introducedBy == null ? new DRTask("OpaqueRef:NULL") : this.introducedBy); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * all virtual disks known to this storage repository + */ + public Set VDIs; + /** + * describes how particular hosts can see this storage repository + */ + public Set PBDs; + /** + * sum of virtual_sizes of all VDIs in this storage repository (in bytes) + */ + public Long virtualAllocation; + /** + * physical space currently utilised on this storage repository (in bytes). Note that for sparse disk formats, physical_utilisation may be less than virtual_allocation + */ + public Long physicalUtilisation; + /** + * total physical size of the repository (in bytes) + */ + public Long physicalSize; + /** + * type of the storage repository + */ + public String type; + /** + * the type of the SR's content, if required (e.g. ISOs) + */ + public String contentType; + /** + * true if this SR is (capable of being) shared between multiple hosts + */ + public Boolean shared; + /** + * additional configuration + */ + public Map otherConfig; + /** + * user-specified tags for categorization purposes + */ + public Set tags; + /** + * SM dependent data + */ + public Map smConfig; + /** + * Binary blobs associated with this SR + */ + public Map blobs; + /** + * True if this SR is assigned to be the local cache for its host + */ + public Boolean localCacheEnabled; + /** + * The disaster recovery task which introduced this SR + */ + public DRTask introducedBy; + } + + /** + * Get a record containing the current state of the given SR. + * + * @return all fields from the object + */ + public SR.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSRRecord(result); + } + + /** + * Get a reference to the SR instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static SR getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get all the SR instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfSR(result); + } + + /** + * Get the uuid field of the given SR. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given SR. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given SR. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the allowed_operations field of the given SR. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfStorageOperations(result); + } + + /** + * Get the current_operations field of the given SR. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringStorageOperations(result); + } + + /** + * Get the VDIs field of the given SR. + * + * @return value of the field + */ + public Set getVDIs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_VDIs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVDI(result); + } + + /** + * Get the PBDs field of the given SR. + * + * @return value of the field + */ + public Set getPBDs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_PBDs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPBD(result); + } + + /** + * Get the virtual_allocation field of the given SR. + * + * @return value of the field + */ + public Long getVirtualAllocation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_virtual_allocation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the physical_utilisation field of the given SR. + * + * @return value of the field + */ + public Long getPhysicalUtilisation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_physical_utilisation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the physical_size field of the given SR. + * + * @return value of the field + */ + public Long getPhysicalSize(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_physical_size"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the type field of the given SR. + * + * @return value of the field + */ + public String getType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the content_type field of the given SR. + * + * @return value of the field + */ + public String getContentType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_content_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the shared field of the given SR. + * + * @return value of the field + */ + public Boolean getShared(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_shared"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the other_config field of the given SR. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the tags field of the given SR. + * + * @return value of the field + */ + public Set getTags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the sm_config field of the given SR. + * + * @return value of the field + */ + public Map getSmConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_sm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the blobs field of the given SR. + * + * @return value of the field + */ + public Map getBlobs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_blobs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringBlob(result); + } + + /** + * Get the local_cache_enabled field of the given SR. + * + * @return value of the field + */ + public Boolean getLocalCacheEnabled(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_local_cache_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the introduced_by field of the given SR. + * + * @return value of the field + */ + public DRTask getIntroducedBy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_introduced_by"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDRTask(result); + } + + /** + * Set the other_config field of the given SR. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given SR. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given SR. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the tags field of the given SR. + * + * @param tags New value to set + */ + public void setTags(Connection c, Set tags) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given value to the tags field of the given SR. If the value is already in that Set, then do nothing. + * + * @param value New value to add + */ + public void addTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.add_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given value from the tags field of the given SR. If the value is not in that Set, then do nothing. + * + * @param value Value to remove + */ + public void removeTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.remove_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the sm_config field of the given SR. + * + * @param smConfig New value to set + */ + public void setSmConfig(Connection c, Map smConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_sm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the sm_config field of the given SR. + * + * @param key Key to add + * @param value Value to add + */ + public void addToSmConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.add_to_sm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the sm_config field of the given SR. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromSmConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.remove_from_sm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a new Storage Repository and introduce it into the managed system, creating both SR record and PBD record to attach it to current host (with specified device_config parameters) + * + * @param host The host to create/make the SR on + * @param deviceConfig The device config string that will be passed to backend SR driver + * @param physicalSize The physical size of the new storage repository + * @param nameLabel The name of the new storage repository + * @param nameDescription The description of the new storage repository + * @param type The type of the SR; used to specify the SR backend driver to use + * @param contentType The type of the new SRs content, if required (e.g. ISOs) + * @param shared True if the SR (is capable of) being shared by multiple hosts + * @param smConfig Storage backend specific configuration options + * @return Task + */ + public static Task createAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException, + Types.SrUnknownDriver { + + if(c.rioConnection){ + if (smConfig.isEmpty()){ + return rioCreateAsync(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, shared); + } else { + throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiCreateAsync(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, shared, smConfig); + } + } + + + + private static Task rioCreateAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared) throws + BadServerResponse, + XmlRpcException, + XenAPIException, + Types.SrUnknownDriver { + String method_call = "Async.SR.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + private static Task miamiCreateAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws + BadServerResponse, + XmlRpcException, + XenAPIException, + Types.SrUnknownDriver { + String method_call = "Async.SR.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new Storage Repository and introduce it into the managed system, creating both SR record and PBD record to attach it to current host (with specified device_config parameters) + * + * @param host The host to create/make the SR on + * @param deviceConfig The device config string that will be passed to backend SR driver + * @param physicalSize The physical size of the new storage repository + * @param nameLabel The name of the new storage repository + * @param nameDescription The description of the new storage repository + * @param type The type of the SR; used to specify the SR backend driver to use + * @param contentType The type of the new SRs content, if required (e.g. ISOs) + * @param shared True if the SR (is capable of) being shared by multiple hosts + * @param smConfig Storage backend specific configuration options + * @return The reference of the newly created Storage Repository. + */ + public static SR create(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException, + Types.SrUnknownDriver { + + if(c.rioConnection){ + if (smConfig.isEmpty()){ + return rioCreate(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, shared); + } else { + throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiCreate(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, shared, smConfig); + } + } + + + + private static SR rioCreate(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared) throws + BadServerResponse, + XmlRpcException, + XenAPIException, + Types.SrUnknownDriver { + String method_call = "SR.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + private static SR miamiCreate(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws + BadServerResponse, + XmlRpcException, + XenAPIException, + Types.SrUnknownDriver { + String method_call = "SR.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Introduce a new Storage Repository into the managed system + * + * @param uuid The uuid assigned to the introduced SR + * @param nameLabel The name of the new storage repository + * @param nameDescription The description of the new storage repository + * @param type The type of the SR; used to specify the SR backend driver to use + * @param contentType The type of the new SRs content, if required (e.g. ISOs) + * @param shared True if the SR (is capable of) being shared by multiple hosts + * @param smConfig Storage backend specific configuration options + * @return Task + */ + public static Task introduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException { + + if(c.rioConnection){ + if (smConfig.isEmpty()){ + return rioIntroduceAsync(c, uuid, nameLabel, nameDescription, type, contentType, shared); + } else { + throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiIntroduceAsync(c, uuid, nameLabel, nameDescription, type, contentType, shared, smConfig); + } + } + + + + private static Task rioIntroduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "Async.SR.introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + private static Task miamiIntroduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "Async.SR.introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Introduce a new Storage Repository into the managed system + * + * @param uuid The uuid assigned to the introduced SR + * @param nameLabel The name of the new storage repository + * @param nameDescription The description of the new storage repository + * @param type The type of the SR; used to specify the SR backend driver to use + * @param contentType The type of the new SRs content, if required (e.g. ISOs) + * @param shared True if the SR (is capable of) being shared by multiple hosts + * @param smConfig Storage backend specific configuration options + * @return The reference of the newly introduced Storage Repository. + */ + public static SR introduce(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException { + + if(c.rioConnection){ + if (smConfig.isEmpty()){ + return rioIntroduce(c, uuid, nameLabel, nameDescription, type, contentType, shared); + } else { + throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiIntroduce(c, uuid, nameLabel, nameDescription, type, contentType, shared, smConfig); + } + } + + + + private static SR rioIntroduce(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "SR.introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + private static SR miamiIntroduce(Connection c, String uuid, String nameLabel, String nameDescription, String type, String contentType, Boolean shared, Map smConfig) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "SR.introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(shared), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Create a new Storage Repository on disk. This call is deprecated: use SR.create instead. + * @deprecated + * + * @param host The host to create/make the SR on + * @param deviceConfig The device config string that will be passed to backend SR driver + * @param physicalSize The physical size of the new storage repository + * @param nameLabel The name of the new storage repository + * @param nameDescription The description of the new storage repository + * @param type The type of the SR; used to specify the SR backend driver to use + * @param contentType The type of the new SRs content, if required (e.g. ISOs) + * @param smConfig Storage backend specific configuration options + * @return Task + */ + @Deprecated public static Task makeAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Map smConfig) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException { + + if(c.rioConnection){ + if (smConfig.isEmpty()){ + return rioMakeAsync(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType); + } else { + throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiMakeAsync(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, smConfig); + } + } + + + + @Deprecated private static Task rioMakeAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "Async.SR.make"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + @Deprecated private static Task miamiMakeAsync(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Map smConfig) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "Async.SR.make"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new Storage Repository on disk. This call is deprecated: use SR.create instead. + * @deprecated + * + * @param host The host to create/make the SR on + * @param deviceConfig The device config string that will be passed to backend SR driver + * @param physicalSize The physical size of the new storage repository + * @param nameLabel The name of the new storage repository + * @param nameDescription The description of the new storage repository + * @param type The type of the SR; used to specify the SR backend driver to use + * @param contentType The type of the new SRs content, if required (e.g. ISOs) + * @param smConfig Storage backend specific configuration options + * @return The uuid of the newly created Storage Repository. + */ + @Deprecated public static String make(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Map smConfig) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException { + + if(c.rioConnection){ + if (smConfig.isEmpty()){ + return rioMake(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType); + } else { + throw new Types.VersionException("smConfig parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiMake(c, host, deviceConfig, physicalSize, nameLabel, nameDescription, type, contentType, smConfig); + } + } + + + + @Deprecated private static String rioMake(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "SR.make"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + @Deprecated private static String miamiMake(Connection c, Host host, Map deviceConfig, Long physicalSize, String nameLabel, String nameDescription, String type, String contentType, Map smConfig) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "SR.make"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(physicalSize), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(contentType), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Destroy specified SR, removing SR-record from database and remove SR from disk. (In order to affect this operation the appropriate device_config is read from the specified SR's PBD on current host) + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrHasPbd { + String method_call = "Async.SR.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy specified SR, removing SR-record from database and remove SR from disk. (In order to affect this operation the appropriate device_config is read from the specified SR's PBD on current host) + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrHasPbd { + String method_call = "SR.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Removing specified SR-record from database, without attempting to remove SR from disk + * + * @return Task + */ + public Task forgetAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrHasPbd { + String method_call = "Async.SR.forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removing specified SR-record from database, without attempting to remove SR from disk + * + */ + public void forget(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrHasPbd { + String method_call = "SR.forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Refresh the fields on the SR object + * + * @return Task + */ + public Task updateAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.update"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Refresh the fields on the SR object + * + */ + public void update(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.update"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a set of all the SR types supported by the system + * + * @return the supported SR types + */ + public static Set getSupportedTypes(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_supported_types"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Refreshes the list of VDIs associated with an SR + * + * @return Task + */ + public Task scanAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.scan"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Refreshes the list of VDIs associated with an SR + * + */ + public void scan(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.scan"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Perform a backend-specific scan, using the given device_config. If the device_config is complete, then this will return a list of the SRs present of this type on the device, if any. If the device_config is partial, then a backend-specific scan will be performed, returning results that will guide the user in improving the device_config. + * + * @param host The host to create/make the SR on + * @param deviceConfig The device config string that will be passed to backend SR driver + * @param type The type of the SR; used to specify the SR backend driver to use + * @param smConfig Storage backend specific configuration options + * @return Task + */ + public static Task probeAsync(Connection c, Host host, Map deviceConfig, String type, Map smConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.probe"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Perform a backend-specific scan, using the given device_config. If the device_config is complete, then this will return a list of the SRs present of this type on the device, if any. If the device_config is partial, then a backend-specific scan will be performed, returning results that will guide the user in improving the device_config. + * + * @param host The host to create/make the SR on + * @param deviceConfig The device config string that will be passed to backend SR driver + * @param type The type of the SR; used to specify the SR backend driver to use + * @param smConfig Storage backend specific configuration options + * @return An XML fragment containing the scan results. These are specific to the scan being performed, and the backend. + */ + public static String probe(Connection c, Host host, Map deviceConfig, String type, Map smConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.probe"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Sets the shared flag on the SR + * + * @param value True if the SR is shared + * @return Task + */ + public Task setSharedAsync(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.set_shared"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Sets the shared flag on the SR + * + * @param value True if the SR is shared + */ + public void setShared(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_shared"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name label of the SR + * + * @param value The name label for the SR + * @return Task + */ + public Task setNameLabelAsync(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the name label of the SR + * + * @param value The name label for the SR + */ + public void setNameLabel(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name description of the SR + * + * @param value The name description for the SR + * @return Task + */ + public Task setNameDescriptionAsync(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the name description of the SR + * + * @param value The name description for the SR + */ + public void setNameDescription(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this SR + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return Task + */ + public Task createNewBlobAsync(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this SR + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return The reference of the blob, needed for populating its data + */ + public Blob createNewBlob(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBlob(result); + } + + /** + * Sets the SR's physical_size field + * + * @param value The new value of the SR's physical_size + */ + public void setPhysicalSize(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_physical_size"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the SR's virtual_allocation field + * + * @param value The new value of the SR's virtual_allocation + */ + public void setVirtualAllocation(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_virtual_allocation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the SR's physical_utilisation field + * + * @param value The new value of the SR's physical utilisation + */ + public void setPhysicalUtilisation(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.set_physical_utilisation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Returns successfully if the given SR can host an HA statefile. Otherwise returns an error to explain why not + * + * @return Task + */ + public Task assertCanHostHaStatefileAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.assert_can_host_ha_statefile"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Returns successfully if the given SR can host an HA statefile. Otherwise returns an error to explain why not + * + */ + public void assertCanHostHaStatefile(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.assert_can_host_ha_statefile"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Returns successfully if the given SR supports database replication. Otherwise returns an error to explain why not. + * + * @return Task + */ + public Task assertSupportsDatabaseReplicationAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.assert_supports_database_replication"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Returns successfully if the given SR supports database replication. Otherwise returns an error to explain why not. + * + */ + public void assertSupportsDatabaseReplication(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.assert_supports_database_replication"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @return Task + */ + public Task enableDatabaseReplicationAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.enable_database_replication"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * + * + */ + public void enableDatabaseReplication(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.enable_database_replication"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @return Task + */ + public Task disableDatabaseReplicationAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.SR.disable_database_replication"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * + * + */ + public void disableDatabaseReplication(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.disable_database_replication"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the SRs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfSR(result); + } + + /** + * Return a map of SR references to SR records for all SRs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "SR.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfSRSRRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Secret.java b/deps/XenServerJava/src/com/xensource/xenapi/Secret.java new file mode 100644 index 00000000000..a9f8eddc847 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Secret.java @@ -0,0 +1,389 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A secret + * + * @author Citrix Systems, Inc. + */ +public class Secret extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Secret(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Secret, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Secret) + { + Secret other = (Secret) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Secret + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "value", this.value); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a secret.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("value", this.value == null ? "" : this.value); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * the secret + */ + public String value; + /** + * other_config + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given secret. + * + * @return all fields from the object + */ + public Secret.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSecretRecord(result); + } + + /** + * Get a reference to the secret instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Secret getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSecret(result); + } + + /** + * Create a new secret instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, Secret.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.secret.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new secret instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static Secret create(Connection c, Secret.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSecret(result); + } + + /** + * Destroy the specified secret instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.secret.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified secret instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the uuid field of the given secret. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the value field of the given secret. + * + * @return value of the field + */ + public String getValue(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.get_value"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the other_config field of the given secret. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the value field of the given secret. + * + * @param value New value to set + */ + public void setValue(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.set_value"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given secret. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given secret. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given secret. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the secrets known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfSecret(result); + } + + /** + * Return a map of secret references to secret records for all secrets known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "secret.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfSecretSecretRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Session.java b/deps/XenServerJava/src/com/xensource/xenapi/Session.java new file mode 100644 index 00000000000..f34476b162a --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Session.java @@ -0,0 +1,675 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A session + * + * @author Citrix Systems, Inc. + */ +public class Session extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Session(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Session, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Session) + { + Session other = (Session) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Session + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "thisHost", this.thisHost); + print.printf("%1$20s: %2$s\n", "thisUser", this.thisUser); + print.printf("%1$20s: %2$s\n", "lastActive", this.lastActive); + print.printf("%1$20s: %2$s\n", "pool", this.pool); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "isLocalSuperuser", this.isLocalSuperuser); + print.printf("%1$20s: %2$s\n", "subject", this.subject); + print.printf("%1$20s: %2$s\n", "validationTime", this.validationTime); + print.printf("%1$20s: %2$s\n", "authUserSid", this.authUserSid); + print.printf("%1$20s: %2$s\n", "authUserName", this.authUserName); + print.printf("%1$20s: %2$s\n", "rbacPermissions", this.rbacPermissions); + print.printf("%1$20s: %2$s\n", "tasks", this.tasks); + print.printf("%1$20s: %2$s\n", "parent", this.parent); + return writer.toString(); + } + + /** + * Convert a session.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("this_host", this.thisHost == null ? new Host("OpaqueRef:NULL") : this.thisHost); + map.put("this_user", this.thisUser == null ? new User("OpaqueRef:NULL") : this.thisUser); + map.put("last_active", this.lastActive == null ? new Date(0) : this.lastActive); + map.put("pool", this.pool == null ? false : this.pool); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("is_local_superuser", this.isLocalSuperuser == null ? false : this.isLocalSuperuser); + map.put("subject", this.subject == null ? new Subject("OpaqueRef:NULL") : this.subject); + map.put("validation_time", this.validationTime == null ? new Date(0) : this.validationTime); + map.put("auth_user_sid", this.authUserSid == null ? "" : this.authUserSid); + map.put("auth_user_name", this.authUserName == null ? "" : this.authUserName); + map.put("rbac_permissions", this.rbacPermissions == null ? new LinkedHashSet() : this.rbacPermissions); + map.put("tasks", this.tasks == null ? new LinkedHashSet() : this.tasks); + map.put("parent", this.parent == null ? new Session("OpaqueRef:NULL") : this.parent); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Currently connected host + */ + public Host thisHost; + /** + * Currently connected user + */ + public User thisUser; + /** + * Timestamp for last time session was active + */ + public Date lastActive; + /** + * True if this session relates to a intra-pool login, false otherwise + */ + public Boolean pool; + /** + * additional configuration + */ + public Map otherConfig; + /** + * true iff this session was created using local superuser credentials + */ + public Boolean isLocalSuperuser; + /** + * references the subject instance that created the session. If a session instance has is_local_superuser set, then the value of this field is undefined. + */ + public Subject subject; + /** + * time when session was last validated + */ + public Date validationTime; + /** + * the subject identifier of the user that was externally authenticated. If a session instance has is_local_superuser set, then the value of this field is undefined. + */ + public String authUserSid; + /** + * the subject name of the user that was externally authenticated. If a session instance has is_local_superuser set, then the value of this field is undefined. + */ + public String authUserName; + /** + * list with all RBAC permissions for this session + */ + public Set rbacPermissions; + /** + * list of tasks created using the current session + */ + public Set tasks; + /** + * references the parent session that created this session + */ + public Session parent; + } + + /** + * Get a record containing the current state of the given session. + * + * @return all fields from the object + */ + public Session.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSessionRecord(result); + } + + /** + * Get a reference to the session instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Session getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSession(result); + } + + /** + * Get the uuid field of the given session. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the this_host field of the given session. + * + * @return value of the field + */ + public Host getThisHost(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_this_host"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the this_user field of the given session. + * + * @return value of the field + */ + public User getThisUser(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_this_user"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toUser(result); + } + + /** + * Get the last_active field of the given session. + * + * @return value of the field + */ + public Date getLastActive(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_last_active"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the pool field of the given session. + * + * @return value of the field + */ + public Boolean getPool(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_pool"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the other_config field of the given session. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the is_local_superuser field of the given session. + * + * @return value of the field + */ + public Boolean getIsLocalSuperuser(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_is_local_superuser"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the subject field of the given session. + * + * @return value of the field + */ + public Subject getSubject(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_subject"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSubject(result); + } + + /** + * Get the validation_time field of the given session. + * + * @return value of the field + */ + public Date getValidationTime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_validation_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the auth_user_sid field of the given session. + * + * @return value of the field + */ + public String getAuthUserSid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_auth_user_sid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the auth_user_name field of the given session. + * + * @return value of the field + */ + public String getAuthUserName(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_auth_user_name"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the rbac_permissions field of the given session. + * + * @return value of the field + */ + public Set getRbacPermissions(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_rbac_permissions"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the tasks field of the given session. + * + * @return value of the field + */ + public Set getTasks(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_tasks"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfTask(result); + } + + /** + * Get the parent field of the given session. + * + * @return value of the field + */ + public Session getParent(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_parent"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSession(result); + } + + /** + * Set the other_config field of the given session. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given session. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given session. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Attempt to authenticate the user, returning a session reference if successful + * + * @param uname Username for login. + * @param pwd Password for login. + * @param version Client API version. + * @return reference of newly created session + */ + public static Session loginWithPassword(Connection c, String uname, String pwd, String version) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SessionAuthenticationFailed { + String method_call = "session.login_with_password"; + Object[] method_params = {Marshalling.toXMLRPC(uname), Marshalling.toXMLRPC(pwd), Marshalling.toXMLRPC(version)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSession(result); + } + + /** + * Log out of a session + * + */ + public static void logout(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.logout"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Change the account password; if your session is authenticated with root priviledges then the old_pwd is validated and the new_pwd is set regardless + * + * @param oldPwd Old password for account + * @param newPwd New password for account + */ + public static void changePassword(Connection c, String oldPwd, String newPwd) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.change_password"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(oldPwd), Marshalling.toXMLRPC(newPwd)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Authenticate locally against a slave in emergency mode. Note the resulting sessions are only good for use on this host. + * + * @param uname Username for login. + * @param pwd Password for login. + * @return ID of newly created session + */ + public static Session slaveLocalLoginWithPassword(Connection c, String uname, String pwd) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.slave_local_login_with_password"; + Object[] method_params = {Marshalling.toXMLRPC(uname), Marshalling.toXMLRPC(pwd)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSession(result); + } + + /** + * Log out of local session. + * + */ + public static void localLogout(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.local_logout"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the user subject-identifiers of all existing sessions + * + * @return Task + */ + public static Task getAllSubjectIdentifiersAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.session.get_all_subject_identifiers"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Return a list of all the user subject-identifiers of all existing sessions + * + * @return The list of user subject-identifiers of all existing sessions + */ + public static Set getAllSubjectIdentifiers(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.get_all_subject_identifiers"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Log out all sessions associated to a user subject-identifier, except the session associated with the context calling this function + * + * @param subjectIdentifier User subject-identifier of the sessions to be destroyed + * @return Task + */ + public static Task logoutSubjectIdentifierAsync(Connection c, String subjectIdentifier) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.session.logout_subject_identifier"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Log out all sessions associated to a user subject-identifier, except the session associated with the context calling this function + * + * @param subjectIdentifier User subject-identifier of the sessions to be destroyed + */ + public static void logoutSubjectIdentifier(Connection c, String subjectIdentifier) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "session.logout_subject_identifier"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)}; + Map response = c.dispatch(method_call, method_params); + return; + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Subject.java b/deps/XenServerJava/src/com/xensource/xenapi/Subject.java new file mode 100644 index 00000000000..a181b58fda5 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Subject.java @@ -0,0 +1,396 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A user or group that can log in xapi + * + * @author Citrix Systems, Inc. + */ +public class Subject extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Subject(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Subject, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Subject) + { + Subject other = (Subject) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Subject + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "subjectIdentifier", this.subjectIdentifier); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "roles", this.roles); + return writer.toString(); + } + + /** + * Convert a subject.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("subject_identifier", this.subjectIdentifier == null ? "" : this.subjectIdentifier); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("roles", this.roles == null ? new LinkedHashSet() : this.roles); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * the subject identifier, unique in the external directory service + */ + public String subjectIdentifier; + /** + * additional configuration + */ + public Map otherConfig; + /** + * the roles associated with this subject + */ + public Set roles; + } + + /** + * Get a record containing the current state of the given subject. + * + * @return all fields from the object + */ + public Subject.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSubjectRecord(result); + } + + /** + * Get a reference to the subject instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Subject getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSubject(result); + } + + /** + * Create a new subject instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, Subject.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.subject.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new subject instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static Subject create(Connection c, Subject.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSubject(result); + } + + /** + * Destroy the specified subject instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.subject.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified subject instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the uuid field of the given subject. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the subject_identifier field of the given subject. + * + * @return value of the field + */ + public String getSubjectIdentifier(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_subject_identifier"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the other_config field of the given subject. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the roles field of the given subject. + * + * @return value of the field + */ + public Set getRoles(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_roles"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfRole(result); + } + + /** + * This call adds a new role to a subject + * + * @param role The unique role reference + */ + public void addToRoles(Connection c, Role role) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.add_to_roles"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(role)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call removes a role from a subject + * + * @param role The unique role reference in the subject's roles field + */ + public void removeFromRoles(Connection c, Role role) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.remove_from_roles"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(role)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call returns a list of permission names given a subject + * + * @return a list of permission names + */ + public Set getPermissionsNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_permissions_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Return a list of all the subjects known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfSubject(result); + } + + /** + * Return a map of subject references to subject records for all subjects known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "subject.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfSubjectSubjectRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Task.java b/deps/XenServerJava/src/com/xensource/xenapi/Task.java new file mode 100644 index 00000000000..beb9686332e --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Task.java @@ -0,0 +1,688 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A long-running asynchronous task + * + * @author Citrix Systems, Inc. + */ +public class Task extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Task(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Task, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Task) + { + Task other = (Task) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Task + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "created", this.created); + print.printf("%1$20s: %2$s\n", "finished", this.finished); + print.printf("%1$20s: %2$s\n", "status", this.status); + print.printf("%1$20s: %2$s\n", "residentOn", this.residentOn); + print.printf("%1$20s: %2$s\n", "progress", this.progress); + print.printf("%1$20s: %2$s\n", "type", this.type); + print.printf("%1$20s: %2$s\n", "result", this.result); + print.printf("%1$20s: %2$s\n", "errorInfo", this.errorInfo); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "subtaskOf", this.subtaskOf); + print.printf("%1$20s: %2$s\n", "subtasks", this.subtasks); + return writer.toString(); + } + + /** + * Convert a task.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("created", this.created == null ? new Date(0) : this.created); + map.put("finished", this.finished == null ? new Date(0) : this.finished); + map.put("status", this.status == null ? Types.TaskStatusType.UNRECOGNIZED : this.status); + map.put("resident_on", this.residentOn == null ? new Host("OpaqueRef:NULL") : this.residentOn); + map.put("progress", this.progress == null ? 0.0 : this.progress); + map.put("type", this.type == null ? "" : this.type); + map.put("result", this.result == null ? "" : this.result); + map.put("error_info", this.errorInfo == null ? new LinkedHashSet() : this.errorInfo); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("subtask_of", this.subtaskOf == null ? new Task("OpaqueRef:NULL") : this.subtaskOf); + map.put("subtasks", this.subtasks == null ? new LinkedHashSet() : this.subtasks); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * Time task was created + */ + public Date created; + /** + * Time task finished (i.e. succeeded or failed). If task-status is pending, then the value of this field has no meaning + */ + public Date finished; + /** + * current status of the task + */ + public Types.TaskStatusType status; + /** + * the host on which the task is running + */ + public Host residentOn; + /** + * This field contains the estimated fraction of the task which is complete. This field should not be used to determine whether the task is complete - for this the status field of the task should be used. + */ + public Double progress; + /** + * if the task has completed successfully, this field contains the type of the encoded result (i.e. name of the class whose reference is in the result field). Undefined otherwise. + */ + public String type; + /** + * if the task has completed successfully, this field contains the result value (either Void or an object reference). Undefined otherwise. + */ + public String result; + /** + * if the task has failed, this field contains the set of associated error strings. Undefined otherwise. + */ + public Set errorInfo; + /** + * additional configuration + */ + public Map otherConfig; + /** + * Ref pointing to the task this is a substask of. + */ + public Task subtaskOf; + /** + * List pointing to all the substasks. + */ + public Set subtasks; + } + + /** + * Get a record containing the current state of the given task. + * + * @return all fields from the object + */ + public Task.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTaskRecord(result); + } + + /** + * Get a reference to the task instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Task getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Get all the task instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfTask(result); + } + + /** + * Get the uuid field of the given task. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given task. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given task. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the allowed_operations field of the given task. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfTaskAllowedOperations(result); + } + + /** + * Get the current_operations field of the given task. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringTaskAllowedOperations(result); + } + + /** + * Get the created field of the given task. + * + * @return value of the field + */ + public Date getCreated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_created"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the finished field of the given task. + * + * @return value of the field + */ + public Date getFinished(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_finished"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the status field of the given task. + * + * @return value of the field + */ + public Types.TaskStatusType getStatus(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_status"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTaskStatusType(result); + } + + /** + * Get the resident_on field of the given task. + * + * @return value of the field + */ + public Host getResidentOn(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_resident_on"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the progress field of the given task. + * + * @return value of the field + */ + public Double getProgress(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_progress"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the type field of the given task. + * + * @return value of the field + */ + public String getType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the result field of the given task. + * + * @return value of the field + */ + public String getResult(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_result"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the error_info field of the given task. + * + * @return value of the field + */ + public Set getErrorInfo(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_error_info"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the other_config field of the given task. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the subtask_of field of the given task. + * + * @return value of the field + */ + public Task getSubtaskOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_subtask_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Get the subtasks field of the given task. + * + * @return value of the field + */ + public Set getSubtasks(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_subtasks"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfTask(result); + } + + /** + * Set the other_config field of the given task. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given task. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given task. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a new task object which must be manually destroyed. + * + * @param label short label for the new task + * @param description longer description for the new task + * @return The reference of the created task object + */ + public static Task create(Connection c, String label, String description) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label), Marshalling.toXMLRPC(description)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the task object + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Request that a task be cancelled. Note that a task may fail to be cancelled and may complete or fail normally and note that, even when a task does cancel, it might take an arbitrary amount of time. + * + * @return Task + */ + public Task cancelAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationNotAllowed { + String method_call = "Async.task.cancel"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Request that a task be cancelled. Note that a task may fail to be cancelled and may complete or fail normally and note that, even when a task does cancel, it might take an arbitrary amount of time. + * + */ + public void cancel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationNotAllowed { + String method_call = "task.cancel"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the tasks known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfTask(result); + } + + /** + * Return a map of task references to task records for all tasks known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "task.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfTaskTaskRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java b/deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java new file mode 100644 index 00000000000..8289e8f35d2 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java @@ -0,0 +1,474 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A tunnel for network traffic + * + * @author Citrix Systems, Inc. + */ +public class Tunnel extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + Tunnel(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a Tunnel, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof Tunnel) + { + Tunnel other = (Tunnel) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a Tunnel + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "accessPIF", this.accessPIF); + print.printf("%1$20s: %2$s\n", "transportPIF", this.transportPIF); + print.printf("%1$20s: %2$s\n", "status", this.status); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a tunnel.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("access_PIF", this.accessPIF == null ? new PIF("OpaqueRef:NULL") : this.accessPIF); + map.put("transport_PIF", this.transportPIF == null ? new PIF("OpaqueRef:NULL") : this.transportPIF); + map.put("status", this.status == null ? new HashMap() : this.status); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * The interface through which the tunnel is accessed + */ + public PIF accessPIF; + /** + * The interface used by the tunnel + */ + public PIF transportPIF; + /** + * Status information about the tunnel + */ + public Map status; + /** + * Additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given tunnel. + * + * @return all fields from the object + */ + public Tunnel.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTunnelRecord(result); + } + + /** + * Get a reference to the tunnel instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static Tunnel getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTunnel(result); + } + + /** + * Get the uuid field of the given tunnel. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the access_PIF field of the given tunnel. + * + * @return value of the field + */ + public PIF getAccessPIF(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_access_PIF"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Get the transport_PIF field of the given tunnel. + * + * @return value of the field + */ + public PIF getTransportPIF(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_transport_PIF"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Get the status field of the given tunnel. + * + * @return value of the field + */ + public Map getStatus(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_status"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the other_config field of the given tunnel. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the status field of the given tunnel. + * + * @param status New value to set + */ + public void setStatus(Connection c, Map status) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.set_status"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(status)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the status field of the given tunnel. + * + * @param key Key to add + * @param value Value to add + */ + public void addToStatus(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.add_to_status"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the status field of the given tunnel. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromStatus(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.remove_from_status"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given tunnel. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given tunnel. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given tunnel. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a tunnel + * + * @param transportPIF PIF which receives the tagged traffic + * @param network Network to receive the tunnelled traffic + * @return Task + */ + public static Task createAsync(Connection c, PIF transportPIF, Network network) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OpenvswitchNotActive, + Types.TransportPifNotConfigured, + Types.IsTunnelAccessPif { + String method_call = "Async.tunnel.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(transportPIF), Marshalling.toXMLRPC(network)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a tunnel + * + * @param transportPIF PIF which receives the tagged traffic + * @param network Network to receive the tunnelled traffic + * @return The reference of the created tunnel object + */ + public static Tunnel create(Connection c, PIF transportPIF, Network network) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OpenvswitchNotActive, + Types.TransportPifNotConfigured, + Types.IsTunnelAccessPif { + String method_call = "tunnel.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(transportPIF), Marshalling.toXMLRPC(network)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTunnel(result); + } + + /** + * Destroy a tunnel + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.tunnel.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy a tunnel + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the tunnels known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfTunnel(result); + } + + /** + * Return a map of tunnel references to tunnel records for all tunnels known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "tunnel.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfTunnelTunnelRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Types.java b/deps/XenServerJava/src/com/xensource/xenapi/Types.java new file mode 100644 index 00000000000..bde887a4ec3 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/Types.java @@ -0,0 +1,13057 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import java.util.Date; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; +import java.util.LinkedHashSet; +import java.io.IOException; + +import java.util.regex.Pattern; +import java.util.regex.Matcher; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * This class holds vital marshalling functions, enum types and exceptions. + * + * @author Citrix Systems, Inc. + */ +public class Types +{ + /** + * Interface for all Record classes + */ + public static interface Record + { + /** + * Convert a Record to a Map + */ + Map toMap(); + } + + /** + * Helper method. + */ + private static String[] ObjectArrayToStringArray(Object[] objArray) + { + String[] result = new String[objArray.length]; + for (int i = 0; i < objArray.length; i++) + { + result[i] = (String) objArray[i]; + } + return result; + } + + /** + * Base class for all XenAPI Exceptions + */ + public static class XenAPIException extends IOException { + public final String shortDescription; + public final String[] errorDescription; + + XenAPIException(String shortDescription) + { + this.shortDescription = shortDescription; + this.errorDescription = null; + } + + XenAPIException(String[] errorDescription) + { + this.errorDescription = errorDescription; + + if (errorDescription.length > 0) + { + shortDescription = errorDescription[0]; + } else + { + shortDescription = ""; + } + } + + public String toString() + { + if (errorDescription == null) + { + return shortDescription; + } else if (errorDescription.length == 0) + { + return ""; + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < errorDescription.length - 1; i++) + { + sb.append(errorDescription[i]); + } + sb.append(errorDescription[errorDescription.length - 1]); + + return sb.toString(); + } + } + /** + * Thrown if the response from the server contains an invalid status. + */ + public static class BadServerResponse extends XenAPIException + { + public BadServerResponse(Map response) + { + super(ObjectArrayToStringArray((Object[]) response.get("ErrorDescription"))); + } + } + + public static class BadAsyncResult extends XenAPIException + { + public final String result; + + public BadAsyncResult(String result) + { + super(result); + this.result = result; + } + } + + /* + * A call has been made which should not be made against this version of host. + * Probably the host is out of date and cannot handle this call, or is + * unable to comply with the details of the call. For instance SR.create + * on Miami (4.1) hosts takes an smConfig parameter, which must be an empty map + * when making this call on Rio (4.0) hosts. + */ + public static class VersionException extends XenAPIException + { + public final String result; + + public VersionException(String result) + { + super(result); + this.result = result; + } + } + + private static String parseResult(String result) throws BadAsyncResult + { + Pattern pattern = Pattern.compile("(.*)"); + Matcher matcher = pattern.matcher(result); + matcher.find(); + + if (matcher.groupCount() != 1) + { + throw new Types.BadAsyncResult("Can't interpret: " + result); + } + + return matcher.group(1); + } + /** + * Checks the provided server response was successful. If the call failed, throws a XenAPIException. If the server + * returned an invalid response, throws a BadServerResponse. Otherwise, returns the server response as passed in. + */ + static Map checkResponse(Map response) throws XenAPIException, BadServerResponse + { + if (response.get("Status").equals("Success")) + { + return response; + } + + if (response.get("Status").equals("Failure")) + { + String[] ErrorDescription = ObjectArrayToStringArray((Object[]) response.get("ErrorDescription")); + + if (ErrorDescription[0].equals("RESTORE_TARGET_MISSING_DEVICE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.RestoreTargetMissingDevice(p1); + } + if (ErrorDescription[0].equals("WLB_TIMEOUT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.WlbTimeout(p1); + } + if (ErrorDescription[0].equals("MAC_DOES_NOT_EXIST")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.MacDoesNotExist(p1); + } + if (ErrorDescription[0].equals("HANDLE_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.HandleInvalid(p1, p2); + } + if (ErrorDescription[0].equals("DEVICE_ALREADY_ATTACHED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.DeviceAlreadyAttached(p1); + } + if (ErrorDescription[0].equals("INVALID_IP_ADDRESS_SPECIFIED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.InvalidIpAddressSpecified(p1); + } + if (ErrorDescription[0].equals("SR_NOT_EMPTY")) + { + throw new Types.SrNotEmpty(); + } + if (ErrorDescription[0].equals("VM_HVM_REQUIRED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmHvmRequired(p1); + } + if (ErrorDescription[0].equals("GPU_GROUP_CONTAINS_PGPU")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.GpuGroupContainsPgpu(p1); + } + if (ErrorDescription[0].equals("PIF_TUNNEL_STILL_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PifTunnelStillExists(p1); + } + if (ErrorDescription[0].equals("PIF_BOND_NEEDS_MORE_MEMBERS")) + { + throw new Types.PifBondNeedsMoreMembers(); + } + if (ErrorDescription[0].equals("PIF_ALREADY_BONDED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PifAlreadyBonded(p1); + } + if (ErrorDescription[0].equals("CANNOT_DESTROY_DISASTER_RECOVERY_TASK")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotDestroyDisasterRecoveryTask(p1); + } + if (ErrorDescription[0].equals("VLAN_TAG_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VlanTagInvalid(p1); + } + if (ErrorDescription[0].equals("HOST_IS_SLAVE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostIsSlave(p1); + } + if (ErrorDescription[0].equals("SR_HAS_MULTIPLE_PBDS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrHasMultiplePbds(p1); + } + if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_INVALID_OU")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthEnableFailedInvalidOu(p1, p2); + } + if (ErrorDescription[0].equals("IMPORT_ERROR_SOME_CHECKSUMS_FAILED")) + { + throw new Types.ImportErrorSomeChecksumsFailed(); + } + if (ErrorDescription[0].equals("OPENVSWITCH_NOT_ACTIVE")) + { + throw new Types.OpenvswitchNotActive(); + } + if (ErrorDescription[0].equals("CANNOT_FIND_OEM_BACKUP_PARTITION")) + { + throw new Types.CannotFindOemBackupPartition(); + } + if (ErrorDescription[0].equals("PIF_DEVICE_NOT_FOUND")) + { + throw new Types.PifDeviceNotFound(); + } + if (ErrorDescription[0].equals("DOMAIN_BUILDER_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.DomainBuilderError(p1, p2, p3); + } + if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_VM_RUNNING")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PatchPrecheckFailedVmRunning(p1); + } + if (ErrorDescription[0].equals("VM_REQUIRES_IOMMU")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmRequiresIommu(p1); + } + if (ErrorDescription[0].equals("HA_HOST_CANNOT_SEE_PEERS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.HaHostCannotSeePeers(p1, p2, p3); + } + if (ErrorDescription[0].equals("POOL_AUTH_DISABLE_FAILED_PERMISSION_DENIED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthDisableFailedPermissionDenied(p1, p2); + } + if (ErrorDescription[0].equals("PERMISSION_DENIED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PermissionDenied(p1); + } + if (ErrorDescription[0].equals("SSL_VERIFY_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SslVerifyError(p1); + } + if (ErrorDescription[0].equals("SR_ATTACH_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrAttachFailed(p1); + } + if (ErrorDescription[0].equals("SUBJECT_ALREADY_EXISTS")) + { + throw new Types.SubjectAlreadyExists(); + } + if (ErrorDescription[0].equals("HA_LOST_STATEFILE")) + { + throw new Types.HaLostStatefile(); + } + if (ErrorDescription[0].equals("HA_NOT_ENABLED")) + { + throw new Types.HaNotEnabled(); + } + if (ErrorDescription[0].equals("HA_HEARTBEAT_DAEMON_STARTUP_FAILED")) + { + throw new Types.HaHeartbeatDaemonStartupFailed(); + } + if (ErrorDescription[0].equals("SESSION_NOT_REGISTERED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SessionNotRegistered(p1); + } + if (ErrorDescription[0].equals("VM_NO_SUSPEND_SR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmNoSuspendSr(p1); + } + if (ErrorDescription[0].equals("VM_HAS_TOO_MANY_SNAPSHOTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmHasTooManySnapshots(p1); + } + if (ErrorDescription[0].equals("PATCH_APPLY_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PatchApplyFailed(p1); + } + if (ErrorDescription[0].equals("VDI_READONLY")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VdiReadonly(p1); + } + if (ErrorDescription[0].equals("SR_FULL")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.SrFull(p1, p2); + } + if (ErrorDescription[0].equals("VM_REQUIRES_GPU")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmRequiresGpu(p1, p2); + } + if (ErrorDescription[0].equals("VDI_NOT_AVAILABLE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VdiNotAvailable(p1); + } + if (ErrorDescription[0].equals("XMLRPC_UNMARSHAL_FAILURE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XmlrpcUnmarshalFailure(p1, p2); + } + if (ErrorDescription[0].equals("CRL_ALREADY_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CrlAlreadyExists(p1); + } + if (ErrorDescription[0].equals("HOST_MASTER_CANNOT_TALK_BACK")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostMasterCannotTalkBack(p1); + } + if (ErrorDescription[0].equals("XAPI_HOOK_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + String p4 = ErrorDescription.length > 4 ? ErrorDescription[4] : ""; + throw new Types.XapiHookFailed(p1, p2, p3, p4); + } + if (ErrorDescription[0].equals("IMPORT_INCOMPATIBLE_VERSION")) + { + throw new Types.ImportIncompatibleVersion(); + } + if (ErrorDescription[0].equals("UNKNOWN_BOOTLOADER")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.UnknownBootloader(p1, p2); + } + if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_PROV_NOT_LOADED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XenVssReqErrorProvNotLoaded(p1, p2); + } + if (ErrorDescription[0].equals("FEATURE_REQUIRES_HVM")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.FeatureRequiresHvm(p1); + } + if (ErrorDescription[0].equals("SR_VDI_LOCKING_FAILED")) + { + throw new Types.SrVdiLockingFailed(); + } + if (ErrorDescription[0].equals("PIF_IS_PHYSICAL")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PifIsPhysical(p1); + } + if (ErrorDescription[0].equals("MAP_DUPLICATE_KEY")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + String p4 = ErrorDescription.length > 4 ? ErrorDescription[4] : ""; + throw new Types.MapDuplicateKey(p1, p2, p3, p4); + } + if (ErrorDescription[0].equals("MISSING_CONNECTION_DETAILS")) + { + throw new Types.MissingConnectionDetails(); + } + if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_CREATING_SNAPSHOT_XML_STRING")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XenVssReqErrorCreatingSnapshotXmlString(p1, p2); + } + if (ErrorDescription[0].equals("BOOTLOADER_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.BootloaderFailed(p1, p2); + } + if (ErrorDescription[0].equals("WLB_XENSERVER_MALFORMED_RESPONSE")) + { + throw new Types.WlbXenserverMalformedResponse(); + } + if (ErrorDescription[0].equals("GPU_GROUP_CONTAINS_VGPU")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.GpuGroupContainsVgpu(p1); + } + if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_DUPLICATE_HOSTNAME")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthEnableFailedDuplicateHostname(p1, p2); + } + if (ErrorDescription[0].equals("SYSTEM_STATUS_RETRIEVAL_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SystemStatusRetrievalFailed(p1); + } + if (ErrorDescription[0].equals("VDI_IN_USE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VdiInUse(p1, p2); + } + if (ErrorDescription[0].equals("HOST_NOT_LIVE")) + { + throw new Types.HostNotLive(); + } + if (ErrorDescription[0].equals("CERTIFICATE_ALREADY_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CertificateAlreadyExists(p1); + } + if (ErrorDescription[0].equals("SR_HAS_NO_PBDS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrHasNoPbds(p1); + } + if (ErrorDescription[0].equals("CANNOT_ADD_TUNNEL_TO_BOND_SLAVE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotAddTunnelToBondSlave(p1); + } + if (ErrorDescription[0].equals("INVALID_PATCH")) + { + throw new Types.InvalidPatch(); + } + if (ErrorDescription[0].equals("SR_INDESTRUCTIBLE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrIndestructible(p1); + } + if (ErrorDescription[0].equals("HA_ABORT_NEW_MASTER")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HaAbortNewMaster(p1); + } + if (ErrorDescription[0].equals("WLB_MALFORMED_RESPONSE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.WlbMalformedResponse(p1, p2, p3); + } + if (ErrorDescription[0].equals("POOL_JOINING_HOST_MUST_HAVE_PHYSICAL_MANAGEMENT_NIC")) + { + throw new Types.PoolJoiningHostMustHavePhysicalManagementNic(); + } + if (ErrorDescription[0].equals("PIF_HAS_NO_V6_NETWORK_CONFIGURATION")) + { + throw new Types.PifHasNoV6NetworkConfiguration(); + } + if (ErrorDescription[0].equals("VM_IS_PART_OF_AN_APPLIANCE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmIsPartOfAnAppliance(p1, p2); + } + if (ErrorDescription[0].equals("WLB_XENSERVER_AUTHENTICATION_FAILED")) + { + throw new Types.WlbXenserverAuthenticationFailed(); + } + if (ErrorDescription[0].equals("CANNOT_RESET_CONTROL_DOMAIN")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotResetControlDomain(p1); + } + if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_UNKNOWN_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PatchPrecheckFailedUnknownError(p1, p2); + } + if (ErrorDescription[0].equals("HOST_CANNOT_ATTACH_NETWORK")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.HostCannotAttachNetwork(p1, p2); + } + if (ErrorDescription[0].equals("WLB_URL_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.WlbUrlInvalid(p1); + } + if (ErrorDescription[0].equals("DUPLICATE_VM")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.DuplicateVm(p1); + } + if (ErrorDescription[0].equals("HOST_CANNOT_DESTROY_SELF")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostCannotDestroySelf(p1); + } + if (ErrorDescription[0].equals("HOST_BROKEN")) + { + throw new Types.HostBroken(); + } + if (ErrorDescription[0].equals("VM_CHECKPOINT_RESUME_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmCheckpointResumeFailed(p1); + } + if (ErrorDescription[0].equals("VM_TOO_MANY_VCPUS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmTooManyVcpus(p1); + } + if (ErrorDescription[0].equals("HOST_IS_LIVE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostIsLive(p1); + } + if (ErrorDescription[0].equals("IMPORT_ERROR_ATTACHED_DISKS_NOT_FOUND")) + { + throw new Types.ImportErrorAttachedDisksNotFound(); + } + if (ErrorDescription[0].equals("VBD_NOT_UNPLUGGABLE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VbdNotUnpluggable(p1); + } + if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_CREATING_SNAPSHOT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XenVssReqErrorCreatingSnapshot(p1, p2); + } + if (ErrorDescription[0].equals("CANNOT_ENABLE_REDO_LOG")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotEnableRedoLog(p1); + } + if (ErrorDescription[0].equals("CANNOT_EVACUATE_HOST")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotEvacuateHost(p1); + } + if (ErrorDescription[0].equals("NO_HOSTS_AVAILABLE")) + { + throw new Types.NoHostsAvailable(); + } + if (ErrorDescription[0].equals("DEVICE_ATTACH_TIMEOUT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.DeviceAttachTimeout(p1, p2); + } + if (ErrorDescription[0].equals("INVALID_DEVICE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.InvalidDevice(p1); + } + if (ErrorDescription[0].equals("PBD_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.PbdExists(p1, p2, p3); + } + if (ErrorDescription[0].equals("WLB_XENSERVER_CONNECTION_REFUSED")) + { + throw new Types.WlbXenserverConnectionRefused(); + } + if (ErrorDescription[0].equals("HOST_CANNOT_READ_METRICS")) + { + throw new Types.HostCannotReadMetrics(); + } + if (ErrorDescription[0].equals("VM_INCOMPATIBLE_WITH_THIS_HOST")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.VmIncompatibleWithThisHost(p1, p2, p3); + } + if (ErrorDescription[0].equals("NO_MORE_REDO_LOGS_ALLOWED")) + { + throw new Types.NoMoreRedoLogsAllowed(); + } + if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthEnableFailed(p1, p2); + } + if (ErrorDescription[0].equals("VM_SNAPSHOT_WITH_QUIESCE_NOT_SUPPORTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmSnapshotWithQuiesceNotSupported(p1, p2); + } + if (ErrorDescription[0].equals("LICENSE_DOES_NOT_SUPPORT_POOLING")) + { + throw new Types.LicenseDoesNotSupportPooling(); + } + if (ErrorDescription[0].equals("HOST_UNKNOWN_TO_MASTER")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostUnknownToMaster(p1); + } + if (ErrorDescription[0].equals("WLB_CONNECTION_REFUSED")) + { + throw new Types.WlbConnectionRefused(); + } + if (ErrorDescription[0].equals("VM_SNAPSHOT_WITH_QUIESCE_PLUGIN_DEOS_NOT_RESPOND")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmSnapshotWithQuiescePluginDeosNotRespond(p1); + } + if (ErrorDescription[0].equals("VM_REQUIRES_SR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmRequiresSr(p1, p2); + } + if (ErrorDescription[0].equals("VM_NO_CRASHDUMP_SR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmNoCrashdumpSr(p1); + } + if (ErrorDescription[0].equals("HA_NOT_INSTALLED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HaNotInstalled(p1); + } + if (ErrorDescription[0].equals("DUPLICATE_PIF_DEVICE_NAME")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.DuplicatePifDeviceName(p1); + } + if (ErrorDescription[0].equals("VM_BAD_POWER_STATE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.VmBadPowerState(p1, p2, p3); + } + if (ErrorDescription[0].equals("WLB_DISABLED")) + { + throw new Types.WlbDisabled(); + } + if (ErrorDescription[0].equals("VM_HOST_INCOMPATIBLE_VERSION")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmHostIncompatibleVersion(p1, p2); + } + if (ErrorDescription[0].equals("POOL_JOINING_EXTERNAL_AUTH_MISMATCH")) + { + throw new Types.PoolJoiningExternalAuthMismatch(); + } + if (ErrorDescription[0].equals("DISK_VBD_MUST_BE_READWRITE_FOR_HVM")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.DiskVbdMustBeReadwriteForHvm(p1); + } + if (ErrorDescription[0].equals("VM_BIOS_STRINGS_ALREADY_SET")) + { + throw new Types.VmBiosStringsAlreadySet(); + } + if (ErrorDescription[0].equals("WLB_XENSERVER_UNKNOWN_HOST")) + { + throw new Types.WlbXenserverUnknownHost(); + } + if (ErrorDescription[0].equals("HA_HOST_CANNOT_ACCESS_STATEFILE")) + { + throw new Types.HaHostCannotAccessStatefile(); + } + if (ErrorDescription[0].equals("VM_FAILED_SHUTDOWN_ACKNOWLEDGMENT")) + { + throw new Types.VmFailedShutdownAcknowledgment(); + } + if (ErrorDescription[0].equals("AUTH_SERVICE_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthServiceError(p1); + } + if (ErrorDescription[0].equals("HOST_IN_EMERGENCY_MODE")) + { + throw new Types.HostInEmergencyMode(); + } + if (ErrorDescription[0].equals("HOST_DISABLED_UNTIL_REBOOT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostDisabledUntilReboot(p1); + } + if (ErrorDescription[0].equals("DEFAULT_SR_NOT_FOUND")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.DefaultSrNotFound(p1); + } + if (ErrorDescription[0].equals("DEVICE_ALREADY_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.DeviceAlreadyExists(p1); + } + if (ErrorDescription[0].equals("SR_NOT_SHARABLE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.SrNotSharable(p1, p2); + } + if (ErrorDescription[0].equals("VM_HAS_CHECKPOINT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmHasCheckpoint(p1); + } + if (ErrorDescription[0].equals("SM_PLUGIN_COMMUNICATION_FAILURE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SmPluginCommunicationFailure(p1); + } + if (ErrorDescription[0].equals("VM_ASSIGNED_TO_PROTECTION_POLICY")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmAssignedToProtectionPolicy(p1, p2); + } + if (ErrorDescription[0].equals("RBAC_PERMISSION_DENIED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.RbacPermissionDenied(p1, p2); + } + if (ErrorDescription[0].equals("AUTH_DISABLE_FAILED_PERMISSION_DENIED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthDisableFailedPermissionDenied(p1); + } + if (ErrorDescription[0].equals("LICENSE_CANNOT_DOWNGRADE_WHILE_IN_POOL")) + { + throw new Types.LicenseCannotDowngradeWhileInPool(); + } + if (ErrorDescription[0].equals("TOO_MANY_PENDING_TASKS")) + { + throw new Types.TooManyPendingTasks(); + } + if (ErrorDescription[0].equals("VM_SNAPSHOT_WITH_QUIESCE_TIMEOUT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmSnapshotWithQuiesceTimeout(p1); + } + if (ErrorDescription[0].equals("HA_CANNOT_CHANGE_BOND_STATUS_OF_MGMT_IFACE")) + { + throw new Types.HaCannotChangeBondStatusOfMgmtIface(); + } + if (ErrorDescription[0].equals("PATCH_ALREADY_APPLIED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PatchAlreadyApplied(p1); + } + if (ErrorDescription[0].equals("SR_UUID_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrUuidExists(p1); + } + if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED_DOMAIN_LOOKUP_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthEnableFailedDomainLookupFailed(p1); + } + if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_WRONG_SERVER_BUILD")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.PatchPrecheckFailedWrongServerBuild(p1, p2, p3); + } + if (ErrorDescription[0].equals("INVALID_FEATURE_STRING")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.InvalidFeatureString(p1); + } + if (ErrorDescription[0].equals("WLB_NOT_INITIALIZED")) + { + throw new Types.WlbNotInitialized(); + } + if (ErrorDescription[0].equals("OPERATION_BLOCKED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.OperationBlocked(p1, p2); + } + if (ErrorDescription[0].equals("PROVISION_ONLY_ALLOWED_ON_TEMPLATE")) + { + throw new Types.ProvisionOnlyAllowedOnTemplate(); + } + if (ErrorDescription[0].equals("VM_SHUTDOWN_TIMEOUT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmShutdownTimeout(p1, p2); + } + if (ErrorDescription[0].equals("ROLE_ALREADY_EXISTS")) + { + throw new Types.RoleAlreadyExists(); + } + if (ErrorDescription[0].equals("NETWORK_CONTAINS_PIF")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.NetworkContainsPif(p1); + } + if (ErrorDescription[0].equals("COULD_NOT_FIND_NETWORK_INTERFACE_WITH_SPECIFIED_DEVICE_NAME_AND_MAC_ADDRESS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.CouldNotFindNetworkInterfaceWithSpecifiedDeviceNameAndMacAddress(p1, p2); + } + if (ErrorDescription[0].equals("JOINING_HOST_SERVICE_FAILED")) + { + throw new Types.JoiningHostServiceFailed(); + } + if (ErrorDescription[0].equals("VDI_MISSING")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VdiMissing(p1, p2); + } + if (ErrorDescription[0].equals("VBD_TRAY_LOCKED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VbdTrayLocked(p1); + } + if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_PERMISSION_DENIED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthEnableFailedPermissionDenied(p1, p2); + } + if (ErrorDescription[0].equals("UUID_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.UuidInvalid(p1, p2); + } + if (ErrorDescription[0].equals("LICENCE_RESTRICTION")) + { + throw new Types.LicenceRestriction(); + } + if (ErrorDescription[0].equals("VIF_IN_USE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VifInUse(p1, p2); + } + if (ErrorDescription[0].equals("ONLY_ALLOWED_ON_OEM_EDITION")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.OnlyAllowedOnOemEdition(p1); + } + if (ErrorDescription[0].equals("VDI_IS_A_PHYSICAL_DEVICE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VdiIsAPhysicalDevice(p1); + } + if (ErrorDescription[0].equals("LICENSE_PROCESSING_ERROR")) + { + throw new Types.LicenseProcessingError(); + } + if (ErrorDescription[0].equals("ILLEGAL_VBD_DEVICE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.IllegalVbdDevice(p1, p2); + } + if (ErrorDescription[0].equals("CRL_DOES_NOT_EXIST")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CrlDoesNotExist(p1); + } + if (ErrorDescription[0].equals("TASK_CANCELLED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.TaskCancelled(p1); + } + if (ErrorDescription[0].equals("VM_CRASHED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmCrashed(p1); + } + if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_DOMAIN_LOOKUP_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthEnableFailedDomainLookupFailed(p1, p2); + } + if (ErrorDescription[0].equals("HA_SHOULD_BE_FENCED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HaShouldBeFenced(p1); + } + if (ErrorDescription[0].equals("VM_UNSAFE_BOOT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmUnsafeBoot(p1); + } + if (ErrorDescription[0].equals("PIF_HAS_NO_NETWORK_CONFIGURATION")) + { + throw new Types.PifHasNoNetworkConfiguration(); + } + if (ErrorDescription[0].equals("TOO_BUSY")) + { + throw new Types.TooBusy(); + } + if (ErrorDescription[0].equals("VALUE_NOT_SUPPORTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.ValueNotSupported(p1, p2, p3); + } + if (ErrorDescription[0].equals("SESSION_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SessionInvalid(p1); + } + if (ErrorDescription[0].equals("HA_CONSTRAINT_VIOLATION_NETWORK_NOT_SHARED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HaConstraintViolationNetworkNotShared(p1); + } + if (ErrorDescription[0].equals("HA_FAILED_TO_FORM_LIVESET")) + { + throw new Types.HaFailedToFormLiveset(); + } + if (ErrorDescription[0].equals("PIF_CANNOT_BOND_CROSS_HOST")) + { + throw new Types.PifCannotBondCrossHost(); + } + if (ErrorDescription[0].equals("EVENT_FROM_TOKEN_PARSE_FAILURE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.EventFromTokenParseFailure(p1); + } + if (ErrorDescription[0].equals("SR_REQUIRES_UPGRADE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrRequiresUpgrade(p1); + } + if (ErrorDescription[0].equals("CERTIFICATE_DOES_NOT_EXIST")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CertificateDoesNotExist(p1); + } + if (ErrorDescription[0].equals("HA_OPERATION_WOULD_BREAK_FAILOVER_PLAN")) + { + throw new Types.HaOperationWouldBreakFailoverPlan(); + } + if (ErrorDescription[0].equals("CANNOT_FETCH_PATCH")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotFetchPatch(p1); + } + if (ErrorDescription[0].equals("CANNOT_FIND_PATCH")) + { + throw new Types.CannotFindPatch(); + } + if (ErrorDescription[0].equals("DB_UNIQUENESS_CONSTRAINT_VIOLATION")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.DbUniquenessConstraintViolation(p1, p2, p3); + } + if (ErrorDescription[0].equals("VM_REQUIRES_NETWORK")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmRequiresNetwork(p1, p2); + } + if (ErrorDescription[0].equals("VBD_NOT_EMPTY")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VbdNotEmpty(p1); + } + if (ErrorDescription[0].equals("HOST_NOT_ENOUGH_FREE_MEMORY")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.HostNotEnoughFreeMemory(p1, p2); + } + if (ErrorDescription[0].equals("VM_MIGRATE_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + String p4 = ErrorDescription.length > 4 ? ErrorDescription[4] : ""; + throw new Types.VmMigrateFailed(p1, p2, p3, p4); + } + if (ErrorDescription[0].equals("SR_OPERATION_NOT_SUPPORTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrOperationNotSupported(p1); + } + if (ErrorDescription[0].equals("DEVICE_NOT_ATTACHED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.DeviceNotAttached(p1); + } + if (ErrorDescription[0].equals("HOST_DISABLED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostDisabled(p1); + } + if (ErrorDescription[0].equals("SYSTEM_STATUS_MUST_USE_TAR_ON_OEM")) + { + throw new Types.SystemStatusMustUseTarOnOem(); + } + if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_PREPARING_WRITERS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XenVssReqErrorPreparingWriters(p1, p2); + } + if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthEnableFailed(p1); + } + if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_CONTAIN_SHARED_SRS")) + { + throw new Types.JoiningHostCannotContainSharedSrs(); + } + if (ErrorDescription[0].equals("VM_NO_VCPUS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmNoVcpus(p1); + } + if (ErrorDescription[0].equals("INVALID_PATCH_WITH_LOG")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.InvalidPatchWithLog(p1); + } + if (ErrorDescription[0].equals("SR_DEVICE_IN_USE")) + { + throw new Types.SrDeviceInUse(); + } + if (ErrorDescription[0].equals("HOST_CD_DRIVE_EMPTY")) + { + throw new Types.HostCdDriveEmpty(); + } + if (ErrorDescription[0].equals("HA_HOST_IS_ARMED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HaHostIsArmed(p1); + } + if (ErrorDescription[0].equals("EVENT_SUBSCRIPTION_PARSE_FAILURE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.EventSubscriptionParseFailure(p1); + } + if (ErrorDescription[0].equals("LICENSE_EXPIRED")) + { + throw new Types.LicenseExpired(); + } + if (ErrorDescription[0].equals("SESSION_AUTHENTICATION_FAILED")) + { + throw new Types.SessionAuthenticationFailed(); + } + if (ErrorDescription[0].equals("PIF_IS_VLAN")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PifIsVlan(p1); + } + if (ErrorDescription[0].equals("VMPP_ARCHIVE_MORE_FREQUENT_THAN_BACKUP")) + { + throw new Types.VmppArchiveMoreFrequentThanBackup(); + } + if (ErrorDescription[0].equals("V6D_FAILURE")) + { + throw new Types.V6dFailure(); + } + if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_BE_MASTER_OF_OTHER_HOSTS")) + { + throw new Types.JoiningHostCannotBeMasterOfOtherHosts(); + } + if (ErrorDescription[0].equals("HOST_HAS_RESIDENT_VMS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostHasResidentVms(p1); + } + if (ErrorDescription[0].equals("VM_CHECKPOINT_SUSPEND_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmCheckpointSuspendFailed(p1); + } + if (ErrorDescription[0].equals("PIF_IS_MANAGEMENT_INTERFACE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PifIsManagementInterface(p1); + } + if (ErrorDescription[0].equals("MAC_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.MacInvalid(p1); + } + if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_START_SNAPSHOT_SET_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XenVssReqErrorStartSnapshotSetFailed(p1, p2); + } + if (ErrorDescription[0].equals("VBD_IS_EMPTY")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VbdIsEmpty(p1); + } + if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.PatchPrecheckFailedWrongServerVersion(p1, p2, p3); + } + if (ErrorDescription[0].equals("CANNOT_FIND_STATE_PARTITION")) + { + throw new Types.CannotFindStatePartition(); + } + if (ErrorDescription[0].equals("WLB_AUTHENTICATION_FAILED")) + { + throw new Types.WlbAuthenticationFailed(); + } + if (ErrorDescription[0].equals("AUTH_UNKNOWN_TYPE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthUnknownType(p1); + } + if (ErrorDescription[0].equals("NOT_IN_EMERGENCY_MODE")) + { + throw new Types.NotInEmergencyMode(); + } + if (ErrorDescription[0].equals("AUTH_DISABLE_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthDisableFailed(p1); + } + if (ErrorDescription[0].equals("NETWORK_ALREADY_CONNECTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.NetworkAlreadyConnected(p1, p2); + } + if (ErrorDescription[0].equals("VDI_INCOMPATIBLE_TYPE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VdiIncompatibleType(p1, p2); + } + if (ErrorDescription[0].equals("WLB_UNKNOWN_HOST")) + { + throw new Types.WlbUnknownHost(); + } + if (ErrorDescription[0].equals("IMPORT_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.ImportError(p1); + } + if (ErrorDescription[0].equals("SR_UNKNOWN_DRIVER")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrUnknownDriver(p1); + } + if (ErrorDescription[0].equals("AUTH_DISABLE_FAILED_WRONG_CREDENTIALS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthDisableFailedWrongCredentials(p1); + } + if (ErrorDescription[0].equals("VM_HALTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmHalted(p1); + } + if (ErrorDescription[0].equals("FEATURE_RESTRICTED")) + { + throw new Types.FeatureRestricted(); + } + if (ErrorDescription[0].equals("VDI_CONTAINS_METADATA_OF_THIS_POOL")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VdiContainsMetadataOfThisPool(p1, p2); + } + if (ErrorDescription[0].equals("CRL_NAME_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CrlNameInvalid(p1); + } + if (ErrorDescription[0].equals("HOST_POWER_ON_MODE_DISABLED")) + { + throw new Types.HostPowerOnModeDisabled(); + } + if (ErrorDescription[0].equals("ACTIVATION_WHILE_NOT_FREE")) + { + throw new Types.ActivationWhileNotFree(); + } + if (ErrorDescription[0].equals("XENAPI_PLUGIN_FAILURE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.XenapiPluginFailure(p1, p2, p3); + } + if (ErrorDescription[0].equals("MAC_STILL_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.MacStillExists(p1); + } + if (ErrorDescription[0].equals("HOST_IN_USE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.HostInUse(p1, p2, p3); + } + if (ErrorDescription[0].equals("HA_TOO_FEW_HOSTS")) + { + throw new Types.HaTooFewHosts(); + } + if (ErrorDescription[0].equals("WLB_CONNECTION_RESET")) + { + throw new Types.WlbConnectionReset(); + } + if (ErrorDescription[0].equals("POOL_AUTH_ENABLE_FAILED_WRONG_CREDENTIALS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthEnableFailedWrongCredentials(p1, p2); + } + if (ErrorDescription[0].equals("PATCH_IS_APPLIED")) + { + throw new Types.PatchIsApplied(); + } + if (ErrorDescription[0].equals("SR_HAS_PBD")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.SrHasPbd(p1); + } + if (ErrorDescription[0].equals("OPERATION_PARTIALLY_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.OperationPartiallyFailed(p1); + } + if (ErrorDescription[0].equals("WLB_MALFORMED_REQUEST")) + { + throw new Types.WlbMalformedRequest(); + } + if (ErrorDescription[0].equals("HOST_STILL_BOOTING")) + { + throw new Types.HostStillBooting(); + } + if (ErrorDescription[0].equals("CANNOT_DESTROY_SYSTEM_NETWORK")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotDestroySystemNetwork(p1); + } + if (ErrorDescription[0].equals("OBJECT_NOLONGER_EXISTS")) + { + throw new Types.ObjectNolongerExists(); + } + if (ErrorDescription[0].equals("VDI_NOT_IN_MAP")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VdiNotInMap(p1); + } + if (ErrorDescription[0].equals("HOSTS_NOT_HOMOGENEOUS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostsNotHomogeneous(p1); + } + if (ErrorDescription[0].equals("POOL_JOINING_HOST_MUST_HAVE_SAME_PRODUCT_VERSION")) + { + throw new Types.PoolJoiningHostMustHaveSameProductVersion(); + } + if (ErrorDescription[0].equals("PIF_VLAN_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PifVlanExists(p1); + } + if (ErrorDescription[0].equals("LICENSE_CHECKOUT_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.LicenseCheckoutError(p1); + } + if (ErrorDescription[0].equals("CERTIFICATE_LIBRARY_CORRUPT")) + { + throw new Types.CertificateLibraryCorrupt(); + } + if (ErrorDescription[0].equals("VDI_NOT_MANAGED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VdiNotManaged(p1); + } + if (ErrorDescription[0].equals("INVALID_EDITION")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.InvalidEdition(p1); + } + if (ErrorDescription[0].equals("PATCH_ALREADY_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PatchAlreadyExists(p1); + } + if (ErrorDescription[0].equals("OUT_OF_SPACE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.OutOfSpace(p1); + } + if (ErrorDescription[0].equals("IMPORT_ERROR_PREMATURE_EOF")) + { + throw new Types.ImportErrorPrematureEof(); + } + if (ErrorDescription[0].equals("NOT_SYSTEM_DOMAIN")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.NotSystemDomain(p1); + } + if (ErrorDescription[0].equals("VM_MEMORY_SIZE_TOO_LOW")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmMemorySizeTooLow(p1); + } + if (ErrorDescription[0].equals("VMPP_HAS_VM")) + { + throw new Types.VmppHasVm(); + } + if (ErrorDescription[0].equals("HOST_NOT_DISABLED")) + { + throw new Types.HostNotDisabled(); + } + if (ErrorDescription[0].equals("FIELD_TYPE_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.FieldTypeError(p1); + } + if (ErrorDescription[0].equals("SLAVE_REQUIRES_MANAGEMENT_INTERFACE")) + { + throw new Types.SlaveRequiresManagementInterface(); + } + if (ErrorDescription[0].equals("VM_IS_TEMPLATE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmIsTemplate(p1); + } + if (ErrorDescription[0].equals("VM_IS_PROTECTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmIsProtected(p1); + } + if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_HAVE_RUNNING_VMS")) + { + throw new Types.JoiningHostCannotHaveRunningVms(); + } + if (ErrorDescription[0].equals("VM_REQUIRES_VDI")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmRequiresVdi(p1, p2); + } + if (ErrorDescription[0].equals("VBD_CDS_MUST_BE_READONLY")) + { + throw new Types.VbdCdsMustBeReadonly(); + } + if (ErrorDescription[0].equals("LICENSE_FILE_DEPRECATED")) + { + throw new Types.LicenseFileDeprecated(); + } + if (ErrorDescription[0].equals("CANNOT_CREATE_STATE_FILE")) + { + throw new Types.CannotCreateStateFile(); + } + if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_HAVE_VMS_WITH_CURRENT_OPERATIONS")) + { + throw new Types.JoiningHostCannotHaveVmsWithCurrentOperations(); + } + if (ErrorDescription[0].equals("MESSAGE_PARAMETER_COUNT_MISMATCH")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.MessageParameterCountMismatch(p1, p2, p3); + } + if (ErrorDescription[0].equals("POOL_AUTH_ALREADY_ENABLED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PoolAuthAlreadyEnabled(p1); + } + if (ErrorDescription[0].equals("RESTORE_INCOMPATIBLE_VERSION")) + { + throw new Types.RestoreIncompatibleVersion(); + } + if (ErrorDescription[0].equals("DEVICE_DETACH_REJECTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.DeviceDetachRejected(p1, p2, p3); + } + if (ErrorDescription[0].equals("AUTH_IS_DISABLED")) + { + throw new Types.AuthIsDisabled(); + } + if (ErrorDescription[0].equals("JOINING_HOST_CANNOT_HAVE_RUNNING_OR_SUSPENDED_VMS")) + { + throw new Types.JoiningHostCannotHaveRunningOrSuspendedVms(); + } + if (ErrorDescription[0].equals("PATCH_PRECHECK_FAILED_PREREQUISITE_MISSING")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PatchPrecheckFailedPrerequisiteMissing(p1, p2); + } + if (ErrorDescription[0].equals("VM_HAS_PCI_ATTACHED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmHasPciAttached(p1); + } + if (ErrorDescription[0].equals("MIRROR_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.MirrorFailed(p1); + } + if (ErrorDescription[0].equals("WLB_XENSERVER_TIMEOUT")) + { + throw new Types.WlbXenserverTimeout(); + } + if (ErrorDescription[0].equals("POOL_AUTH_DISABLE_FAILED_WRONG_CREDENTIALS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthDisableFailedWrongCredentials(p1, p2); + } + if (ErrorDescription[0].equals("VM_SNAPSHOT_WITH_QUIESCE_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmSnapshotWithQuiesceFailed(p1); + } + if (ErrorDescription[0].equals("CERTIFICATE_CORRUPT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CertificateCorrupt(p1); + } + if (ErrorDescription[0].equals("WLB_INTERNAL_ERROR")) + { + throw new Types.WlbInternalError(); + } + if (ErrorDescription[0].equals("VM_REBOOTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmRebooted(p1); + } + if (ErrorDescription[0].equals("CANNOT_CONTACT_HOST")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotContactHost(p1); + } + if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_NO_VOLUMES_SUPPORTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XenVssReqErrorNoVolumesSupported(p1, p2); + } + if (ErrorDescription[0].equals("HOST_ITS_OWN_SLAVE")) + { + throw new Types.HostItsOwnSlave(); + } + if (ErrorDescription[0].equals("CANNOT_ADD_VLAN_TO_BOND_SLAVE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotAddVlanToBondSlave(p1); + } + if (ErrorDescription[0].equals("REDO_LOG_IS_ENABLED")) + { + throw new Types.RedoLogIsEnabled(); + } + if (ErrorDescription[0].equals("VM_MISSING_PV_DRIVERS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmMissingPvDrivers(p1); + } + if (ErrorDescription[0].equals("CERTIFICATE_NAME_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CertificateNameInvalid(p1); + } + if (ErrorDescription[0].equals("IMPORT_ERROR_FAILED_TO_FIND_OBJECT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.ImportErrorFailedToFindObject(p1); + } + if (ErrorDescription[0].equals("VDI_LOCATION_MISSING")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VdiLocationMissing(p1, p2); + } + if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED_PERMISSION_DENIED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthEnableFailedPermissionDenied(p1); + } + if (ErrorDescription[0].equals("PIF_VLAN_STILL_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PifVlanStillExists(p1); + } + if (ErrorDescription[0].equals("VMS_FAILED_TO_COOPERATE")) + { + throw new Types.VmsFailedToCooperate(); + } + if (ErrorDescription[0].equals("TOO_MANY_STORAGE_MIGRATES")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.TooManyStorageMigrates(p1); + } + if (ErrorDescription[0].equals("NETWORK_CONTAINS_VIF")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.NetworkContainsVif(p1); + } + if (ErrorDescription[0].equals("INVALID_VALUE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.InvalidValue(p1, p2); + } + if (ErrorDescription[0].equals("XENAPI_MISSING_PLUGIN")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.XenapiMissingPlugin(p1); + } + if (ErrorDescription[0].equals("RESTORE_TARGET_MGMT_IF_NOT_IN_BACKUP")) + { + throw new Types.RestoreTargetMgmtIfNotInBackup(); + } + if (ErrorDescription[0].equals("IS_TUNNEL_ACCESS_PIF")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.IsTunnelAccessPif(p1); + } + if (ErrorDescription[0].equals("JOINING_HOST_CONNECTION_FAILED")) + { + throw new Types.JoiningHostConnectionFailed(); + } + if (ErrorDescription[0].equals("SUBJECT_CANNOT_BE_RESOLVED")) + { + throw new Types.SubjectCannotBeResolved(); + } + if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_ADDING_VOLUME_TO_SNAPSET_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XenVssReqErrorAddingVolumeToSnapsetFailed(p1, p2); + } + if (ErrorDescription[0].equals("PROVISION_FAILED_OUT_OF_SPACE")) + { + throw new Types.ProvisionFailedOutOfSpace(); + } + if (ErrorDescription[0].equals("VDI_NEEDS_VM_FOR_MIGRATE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VdiNeedsVmForMigrate(p1); + } + if (ErrorDescription[0].equals("COULD_NOT_IMPORT_DATABASE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CouldNotImportDatabase(p1); + } + if (ErrorDescription[0].equals("VDI_IS_NOT_ISO")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VdiIsNotIso(p1, p2); + } + if (ErrorDescription[0].equals("MESSAGE_METHOD_UNKNOWN")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.MessageMethodUnknown(p1); + } + if (ErrorDescription[0].equals("VM_CANNOT_DELETE_DEFAULT_TEMPLATE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmCannotDeleteDefaultTemplate(p1); + } + if (ErrorDescription[0].equals("ROLE_NOT_FOUND")) + { + throw new Types.RoleNotFound(); + } + if (ErrorDescription[0].equals("NOT_ALLOWED_ON_OEM_EDITION")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.NotAllowedOnOemEdition(p1); + } + if (ErrorDescription[0].equals("RESTORE_SCRIPT_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.RestoreScriptFailed(p1); + } + if (ErrorDescription[0].equals("INTERNAL_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.InternalError(p1); + } + if (ErrorDescription[0].equals("LICENSE_DOES_NOT_SUPPORT_XHA")) + { + throw new Types.LicenseDoesNotSupportXha(); + } + if (ErrorDescription[0].equals("PIF_INCOMPATIBLE_PRIMARY_ADDRESS_TYPE")) + { + throw new Types.PifIncompatiblePrimaryAddressType(); + } + if (ErrorDescription[0].equals("DEVICE_ALREADY_DETACHED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.DeviceAlreadyDetached(p1); + } + if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED_UNAVAILABLE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthEnableFailedUnavailable(p1); + } + if (ErrorDescription[0].equals("VBD_NOT_REMOVABLE_MEDIA")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VbdNotRemovableMedia(p1); + } + if (ErrorDescription[0].equals("LOCATION_NOT_UNIQUE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.LocationNotUnique(p1, p2); + } + if (ErrorDescription[0].equals("NOT_IMPLEMENTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.NotImplemented(p1); + } + if (ErrorDescription[0].equals("CANNOT_PLUG_VIF")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotPlugVif(p1); + } + if (ErrorDescription[0].equals("USER_IS_NOT_LOCAL_SUPERUSER")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.UserIsNotLocalSuperuser(p1); + } + if (ErrorDescription[0].equals("BACKUP_SCRIPT_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.BackupScriptFailed(p1); + } + if (ErrorDescription[0].equals("IMPORT_ERROR_UNEXPECTED_FILE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.ImportErrorUnexpectedFile(p1, p2); + } + if (ErrorDescription[0].equals("AUTH_ALREADY_ENABLED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.AuthAlreadyEnabled(p1, p2); + } + if (ErrorDescription[0].equals("OPERATION_NOT_ALLOWED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.OperationNotAllowed(p1); + } + if (ErrorDescription[0].equals("HA_NO_PLAN")) + { + throw new Types.HaNoPlan(); + } + if (ErrorDescription[0].equals("EVENTS_LOST")) + { + throw new Types.EventsLost(); + } + if (ErrorDescription[0].equals("SR_BACKEND_FAILURE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.SrBackendFailure(p1, p2, p3); + } + if (ErrorDescription[0].equals("DEVICE_DETACH_TIMEOUT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.DeviceDetachTimeout(p1, p2); + } + if (ErrorDescription[0].equals("VM_DUPLICATE_VBD_DEVICE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.VmDuplicateVbdDevice(p1, p2, p3); + } + if (ErrorDescription[0].equals("CANNOT_PLUG_BOND_SLAVE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CannotPlugBondSlave(p1); + } + if (ErrorDescription[0].equals("VM_TO_IMPORT_IS_NOT_NEWER_VERSION")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.VmToImportIsNotNewerVersion(p1, p2, p3); + } + if (ErrorDescription[0].equals("CRL_CORRUPT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CrlCorrupt(p1); + } + if (ErrorDescription[0].equals("VM_OLD_PV_DRIVERS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + String p3 = ErrorDescription.length > 3 ? ErrorDescription[3] : ""; + throw new Types.VmOldPvDrivers(p1, p2, p3); + } + if (ErrorDescription[0].equals("PIF_DOES_NOT_ALLOW_UNPLUG")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.PifDoesNotAllowUnplug(p1); + } + if (ErrorDescription[0].equals("CHANGE_PASSWORD_REJECTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.ChangePasswordRejected(p1); + } + if (ErrorDescription[0].equals("OTHER_OPERATION_IN_PROGRESS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.OtherOperationInProgress(p1, p2); + } + if (ErrorDescription[0].equals("XEN_VSS_REQ_ERROR_INIT_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.XenVssReqErrorInitFailed(p1, p2); + } + if (ErrorDescription[0].equals("CPU_FEATURE_MASKING_NOT_SUPPORTED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.CpuFeatureMaskingNotSupported(p1); + } + if (ErrorDescription[0].equals("VM_NOT_RESIDENT_HERE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmNotResidentHere(p1, p2); + } + if (ErrorDescription[0].equals("HOST_OFFLINE")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostOffline(p1); + } + if (ErrorDescription[0].equals("POOL_AUTH_DISABLE_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PoolAuthDisableFailed(p1, p2); + } + if (ErrorDescription[0].equals("HOST_HAS_NO_MANAGEMENT_IP")) + { + throw new Types.HostHasNoManagementIp(); + } + if (ErrorDescription[0].equals("TRANSPORT_PIF_NOT_CONFIGURED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.TransportPifNotConfigured(p1); + } + if (ErrorDescription[0].equals("HA_IS_ENABLED")) + { + throw new Types.HaIsEnabled(); + } + if (ErrorDescription[0].equals("VM_REVERT_FAILED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.VmRevertFailed(p1, p2); + } + if (ErrorDescription[0].equals("HOST_NAME_INVALID")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HostNameInvalid(p1); + } + if (ErrorDescription[0].equals("DOMAIN_EXISTS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.DomainExists(p1, p2); + } + if (ErrorDescription[0].equals("HA_POOL_IS_ENABLED_BUT_HOST_IS_DISABLED")) + { + throw new Types.HaPoolIsEnabledButHostIsDisabled(); + } + if (ErrorDescription[0].equals("MESSAGE_DEPRECATED")) + { + throw new Types.MessageDeprecated(); + } + if (ErrorDescription[0].equals("HA_CONSTRAINT_VIOLATION_SR_NOT_SHARED")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.HaConstraintViolationSrNotShared(p1); + } + if (ErrorDescription[0].equals("IMPORT_ERROR_CANNOT_HANDLE_CHUNKED")) + { + throw new Types.ImportErrorCannotHandleChunked(); + } + if (ErrorDescription[0].equals("VM_ATTACHED_TO_MORE_THAN_ONE_VDI_WITH_TIMEOFFSET_MARKED_AS_RESET_ON_BOOT")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.VmAttachedToMoreThanOneVdiWithTimeoffsetMarkedAsResetOnBoot(p1); + } + if (ErrorDescription[0].equals("NOT_SUPPORTED_DURING_UPGRADE")) + { + throw new Types.NotSupportedDuringUpgrade(); + } + if (ErrorDescription[0].equals("PIF_CONFIGURATION_ERROR")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; + throw new Types.PifConfigurationError(p1, p2); + } + if (ErrorDescription[0].equals("INTERFACE_HAS_NO_IP")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.InterfaceHasNoIp(p1); + } + if (ErrorDescription[0].equals("HOSTS_NOT_COMPATIBLE")) + { + throw new Types.HostsNotCompatible(); + } + if (ErrorDescription[0].equals("AUTH_ENABLE_FAILED_WRONG_CREDENTIALS")) + { + String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; + throw new Types.AuthEnableFailedWrongCredentials(p1); + } + + // An unknown error occurred + throw new Types.XenAPIException(ErrorDescription); + } + + throw new BadServerResponse(response); + } + + public enum VdiOperations { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Scanning backends for new or deleted VDIs + */ + SCAN, + /** + * Cloning the VDI + */ + CLONE, + /** + * Copying the VDI + */ + COPY, + /** + * Resizing the VDI + */ + RESIZE, + /** + * Resizing the VDI which may or may not be online + */ + RESIZE_ONLINE, + /** + * Snapshotting the VDI + */ + SNAPSHOT, + /** + * Destroying the VDI + */ + DESTROY, + /** + * Forget about the VDI + */ + FORGET, + /** + * Refreshing the fields of the VDI + */ + UPDATE, + /** + * Forcibly unlocking the VDI + */ + FORCE_UNLOCK, + /** + * Generating static configuration + */ + GENERATE_CONFIG, + /** + * Operations on this VDI are temporarily blocked + */ + BLOCKED; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == SCAN) return "scan"; + if (this == CLONE) return "clone"; + if (this == COPY) return "copy"; + if (this == RESIZE) return "resize"; + if (this == RESIZE_ONLINE) return "resize_online"; + if (this == SNAPSHOT) return "snapshot"; + if (this == DESTROY) return "destroy"; + if (this == FORGET) return "forget"; + if (this == UPDATE) return "update"; + if (this == FORCE_UNLOCK) return "force_unlock"; + if (this == GENERATE_CONFIG) return "generate_config"; + if (this == BLOCKED) return "blocked"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum Cls { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * VM + */ + VM, + /** + * Host + */ + HOST, + /** + * SR + */ + SR, + /** + * Pool + */ + POOL, + /** + * VMPP + */ + VMPP; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == VM) return "VM"; + if (this == HOST) return "Host"; + if (this == SR) return "SR"; + if (this == POOL) return "Pool"; + if (this == VMPP) return "VMPP"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VdiType { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * a disk that may be replaced on upgrade + */ + SYSTEM, + /** + * a disk that is always preserved on upgrade + */ + USER, + /** + * a disk that may be reformatted on upgrade + */ + EPHEMERAL, + /** + * a disk that stores a suspend image + */ + SUSPEND, + /** + * a disk that stores VM crashdump information + */ + CRASHDUMP, + /** + * a disk used for HA storage heartbeating + */ + HA_STATEFILE, + /** + * a disk used for HA Pool metadata + */ + METADATA, + /** + * a disk used for a general metadata redo-log + */ + REDO_LOG; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == SYSTEM) return "system"; + if (this == USER) return "user"; + if (this == EPHEMERAL) return "ephemeral"; + if (this == SUSPEND) return "suspend"; + if (this == CRASHDUMP) return "crashdump"; + if (this == HA_STATEFILE) return "ha_statefile"; + if (this == METADATA) return "metadata"; + if (this == REDO_LOG) return "redo_log"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum AfterApplyGuidance { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * This patch requires HVM guests to be restarted once applied. + */ + RESTARTHVM, + /** + * This patch requires PV guests to be restarted once applied. + */ + RESTARTPV, + /** + * This patch requires the host to be restarted once applied. + */ + RESTARTHOST, + /** + * This patch requires XAPI to be restarted once applied. + */ + RESTARTXAPI; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == RESTARTHVM) return "restartHVM"; + if (this == RESTARTPV) return "restartPV"; + if (this == RESTARTHOST) return "restartHost"; + if (this == RESTARTXAPI) return "restartXAPI"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum EventOperation { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * An object has been created + */ + ADD, + /** + * An object has been deleted + */ + DEL, + /** + * An object has been modified + */ + MOD; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == ADD) return "add"; + if (this == DEL) return "del"; + if (this == MOD) return "mod"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum PrimaryAddressType { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Primary address is the IPv4 address + */ + IPV4, + /** + * Primary address is the IPv6 address + */ + IPV6; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == IPV4) return "IPv4"; + if (this == IPV6) return "IPv6"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum TaskAllowedOperations { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * refers to the operation "cancel" + */ + CANCEL; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == CANCEL) return "cancel"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum TaskStatusType { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * task is in progress + */ + PENDING, + /** + * task was completed successfully + */ + SUCCESS, + /** + * task has failed + */ + FAILURE, + /** + * task is being cancelled + */ + CANCELLING, + /** + * task has been cancelled + */ + CANCELLED; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == PENDING) return "pending"; + if (this == SUCCESS) return "success"; + if (this == FAILURE) return "failure"; + if (this == CANCELLING) return "cancelling"; + if (this == CANCELLED) return "cancelled"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum NetworkOperations { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Indicates this network is attaching to a VIF or PIF + */ + ATTACHING; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == ATTACHING) return "attaching"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum ConsoleProtocol { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * VT100 terminal + */ + VT100, + /** + * Remote FrameBuffer protocol (as used in VNC) + */ + RFB, + /** + * Remote Desktop Protocol + */ + RDP; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == VT100) return "vt100"; + if (this == RFB) return "rfb"; + if (this == RDP) return "rdp"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum OnCrashBehaviour { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * destroy the VM state + */ + DESTROY, + /** + * record a coredump and then destroy the VM state + */ + COREDUMP_AND_DESTROY, + /** + * restart the VM + */ + RESTART, + /** + * record a coredump and then restart the VM + */ + COREDUMP_AND_RESTART, + /** + * leave the crashed VM paused + */ + PRESERVE, + /** + * rename the crashed VM and start a new copy + */ + RENAME_RESTART; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == DESTROY) return "destroy"; + if (this == COREDUMP_AND_DESTROY) return "coredump_and_destroy"; + if (this == RESTART) return "restart"; + if (this == COREDUMP_AND_RESTART) return "coredump_and_restart"; + if (this == PRESERVE) return "preserve"; + if (this == RENAME_RESTART) return "rename_restart"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VmppBackupType { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * The backup is a snapshot + */ + SNAPSHOT, + /** + * The backup is a checkpoint + */ + CHECKPOINT; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == SNAPSHOT) return "snapshot"; + if (this == CHECKPOINT) return "checkpoint"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum OnNormalExit { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * destroy the VM state + */ + DESTROY, + /** + * restart the VM + */ + RESTART; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == DESTROY) return "destroy"; + if (this == RESTART) return "restart"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VifOperations { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Attempting to attach this VIF to a VM + */ + ATTACH, + /** + * Attempting to hotplug this VIF + */ + PLUG, + /** + * Attempting to hot unplug this VIF + */ + UNPLUG; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == ATTACH) return "attach"; + if (this == PLUG) return "plug"; + if (this == UNPLUG) return "unplug"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum XenAPIObjects { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * A session + */ + SESSION, + /** + * Management of remote authentication services + */ + AUTH, + /** + * A user or group that can log in xapi + */ + SUBJECT, + /** + * A set of permissions associated with a subject + */ + ROLE, + /** + * A long-running asynchronous task + */ + TASK, + /** + * Asynchronous event registration and handling + */ + EVENT, + /** + * Pool-wide information + */ + POOL, + /** + * Pool-wide patches + */ + POOL_PATCH, + /** + * A virtual machine (or 'guest'). + */ + VM, + /** + * The metrics associated with a VM + */ + VM_METRICS, + /** + * The metrics reported by the guest (as opposed to inferred from outside) + */ + VM_GUEST_METRICS, + /** + * VM Protection Policy + */ + VMPP, + /** + * VM appliance + */ + VM_APPLIANCE, + /** + * DR task + */ + DR_TASK, + /** + * A physical host + */ + HOST, + /** + * Represents a host crash dump + */ + HOST_CRASHDUMP, + /** + * Represents a patch stored on a server + */ + HOST_PATCH, + /** + * The metrics associated with a host + */ + HOST_METRICS, + /** + * A physical CPU + */ + HOST_CPU, + /** + * A virtual network + */ + NETWORK, + /** + * A virtual network interface + */ + VIF, + /** + * The metrics associated with a virtual network device + */ + VIF_METRICS, + /** + * A physical network interface (note separate VLANs are represented as several PIFs) + */ + PIF, + /** + * The metrics associated with a physical network interface + */ + PIF_METRICS, + /** + * + */ + BOND, + /** + * A VLAN mux/demux + */ + VLAN, + /** + * A storage manager plugin + */ + SM, + /** + * A storage repository + */ + SR, + /** + * A virtual disk image + */ + VDI, + /** + * A virtual block device + */ + VBD, + /** + * The metrics associated with a virtual block device + */ + VBD_METRICS, + /** + * The physical block devices through which hosts access SRs + */ + PBD, + /** + * A VM crashdump + */ + CRASHDUMP, + /** + * A virtual TPM device + */ + VTPM, + /** + * A console + */ + CONSOLE, + /** + * A user of the system + */ + USER, + /** + * Data sources for logging in RRDs + */ + DATA_SOURCE, + /** + * A placeholder for a binary blob + */ + BLOB, + /** + * An message for the attention of the administrator + */ + MESSAGE, + /** + * A secret + */ + SECRET, + /** + * A tunnel for network traffic + */ + TUNNEL, + /** + * A PCI device + */ + PCI, + /** + * A physical GPU (pGPU) + */ + PGPU, + /** + * A group of compatible GPUs across the resource pool + */ + GPU_GROUP, + /** + * A virtual GPU (vGPU) + */ + VGPU; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == SESSION) return "session"; + if (this == AUTH) return "auth"; + if (this == SUBJECT) return "subject"; + if (this == ROLE) return "role"; + if (this == TASK) return "task"; + if (this == EVENT) return "event"; + if (this == POOL) return "pool"; + if (this == POOL_PATCH) return "pool_patch"; + if (this == VM) return "VM"; + if (this == VM_METRICS) return "VM_metrics"; + if (this == VM_GUEST_METRICS) return "VM_guest_metrics"; + if (this == VMPP) return "VMPP"; + if (this == VM_APPLIANCE) return "VM_appliance"; + if (this == DR_TASK) return "DR_task"; + if (this == HOST) return "host"; + if (this == HOST_CRASHDUMP) return "host_crashdump"; + if (this == HOST_PATCH) return "host_patch"; + if (this == HOST_METRICS) return "host_metrics"; + if (this == HOST_CPU) return "host_cpu"; + if (this == NETWORK) return "network"; + if (this == VIF) return "VIF"; + if (this == VIF_METRICS) return "VIF_metrics"; + if (this == PIF) return "PIF"; + if (this == PIF_METRICS) return "PIF_metrics"; + if (this == BOND) return "Bond"; + if (this == VLAN) return "VLAN"; + if (this == SM) return "SM"; + if (this == SR) return "SR"; + if (this == VDI) return "VDI"; + if (this == VBD) return "VBD"; + if (this == VBD_METRICS) return "VBD_metrics"; + if (this == PBD) return "PBD"; + if (this == CRASHDUMP) return "crashdump"; + if (this == VTPM) return "VTPM"; + if (this == CONSOLE) return "console"; + if (this == USER) return "user"; + if (this == DATA_SOURCE) return "data_source"; + if (this == BLOB) return "blob"; + if (this == MESSAGE) return "message"; + if (this == SECRET) return "secret"; + if (this == TUNNEL) return "tunnel"; + if (this == PCI) return "PCI"; + if (this == PGPU) return "PGPU"; + if (this == GPU_GROUP) return "GPU_group"; + if (this == VGPU) return "VGPU"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum HostAllowedOperations { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Indicates this host is able to provision another VM + */ + PROVISION, + /** + * Indicates this host is evacuating + */ + EVACUATE, + /** + * Indicates this host is in the process of shutting itself down + */ + SHUTDOWN, + /** + * Indicates this host is in the process of rebooting + */ + REBOOT, + /** + * Indicates this host is in the process of being powered on + */ + POWER_ON, + /** + * This host is starting a VM + */ + VM_START, + /** + * This host is resuming a VM + */ + VM_RESUME, + /** + * This host is the migration target of a VM + */ + VM_MIGRATE; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == PROVISION) return "provision"; + if (this == EVACUATE) return "evacuate"; + if (this == SHUTDOWN) return "shutdown"; + if (this == REBOOT) return "reboot"; + if (this == POWER_ON) return "power_on"; + if (this == VM_START) return "vm_start"; + if (this == VM_RESUME) return "vm_resume"; + if (this == VM_MIGRATE) return "vm_migrate"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VmppArchiveFrequency { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Never archive + */ + NEVER, + /** + * Archive after backup + */ + ALWAYS_AFTER_BACKUP, + /** + * Daily archives + */ + DAILY, + /** + * Weekly backups + */ + WEEKLY; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == NEVER) return "never"; + if (this == ALWAYS_AFTER_BACKUP) return "always_after_backup"; + if (this == DAILY) return "daily"; + if (this == WEEKLY) return "weekly"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VmppArchiveTargetType { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * No target config + */ + NONE, + /** + * CIFS target config + */ + CIFS, + /** + * NFS target config + */ + NFS; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == NONE) return "none"; + if (this == CIFS) return "cifs"; + if (this == NFS) return "nfs"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VbdMode { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * only read-only access will be allowed + */ + RO, + /** + * read-write access will be allowed + */ + RW; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == RO) return "RO"; + if (this == RW) return "RW"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum Ipv6ConfigurationMode { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Do not acquire an IPv6 address + */ + NONE, + /** + * Acquire an IPv6 address by DHCP + */ + DHCP, + /** + * Static IPv6 address configuration + */ + STATIC, + /** + * Router assigned prefix delegation IPv6 allocation + */ + AUTOCONF; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == NONE) return "None"; + if (this == DHCP) return "DHCP"; + if (this == STATIC) return "Static"; + if (this == AUTOCONF) return "Autoconf"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VbdType { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * VBD will appear to guest as CD + */ + CD, + /** + * VBD will appear to guest as disk + */ + DISK; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == CD) return "CD"; + if (this == DISK) return "Disk"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum OnBoot { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * When a VM containing this VDI is started, the contents of the VDI are reset to the state they were in when this flag was last set. + */ + RESET, + /** + * Standard behaviour. + */ + PERSIST; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == RESET) return "reset"; + if (this == PERSIST) return "persist"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VmApplianceOperation { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Start + */ + START, + /** + * Clean shutdown + */ + CLEAN_SHUTDOWN, + /** + * Hard shutdown + */ + HARD_SHUTDOWN, + /** + * Shutdown + */ + SHUTDOWN; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == START) return "start"; + if (this == CLEAN_SHUTDOWN) return "clean_shutdown"; + if (this == HARD_SHUTDOWN) return "hard_shutdown"; + if (this == SHUTDOWN) return "shutdown"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VbdOperations { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Attempting to attach this VBD to a VM + */ + ATTACH, + /** + * Attempting to eject the media from this VBD + */ + EJECT, + /** + * Attempting to insert new media into this VBD + */ + INSERT, + /** + * Attempting to hotplug this VBD + */ + PLUG, + /** + * Attempting to hot unplug this VBD + */ + UNPLUG, + /** + * Attempting to forcibly unplug this VBD + */ + UNPLUG_FORCE, + /** + * Attempting to pause a block device backend + */ + PAUSE, + /** + * Attempting to unpause a block device backend + */ + UNPAUSE; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == ATTACH) return "attach"; + if (this == EJECT) return "eject"; + if (this == INSERT) return "insert"; + if (this == PLUG) return "plug"; + if (this == UNPLUG) return "unplug"; + if (this == UNPLUG_FORCE) return "unplug_force"; + if (this == PAUSE) return "pause"; + if (this == UNPAUSE) return "unpause"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VmppBackupFrequency { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Hourly backups + */ + HOURLY, + /** + * Daily backups + */ + DAILY, + /** + * Weekly backups + */ + WEEKLY; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == HOURLY) return "hourly"; + if (this == DAILY) return "daily"; + if (this == WEEKLY) return "weekly"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum NetworkDefaultLockingMode { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Treat all VIFs on this network with locking_mode = 'default' as if they have locking_mode = 'unlocked' + */ + UNLOCKED, + /** + * Treat all VIFs on this network with locking_mode = 'default' as if they have locking_mode = 'disabled' + */ + DISABLED; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == UNLOCKED) return "unlocked"; + if (this == DISABLED) return "disabled"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VmPowerState { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * VM is offline and not using any resources + */ + HALTED, + /** + * All resources have been allocated but the VM itself is paused and its vCPUs are not running + */ + PAUSED, + /** + * Running + */ + RUNNING, + /** + * VM state has been saved to disk and it is nolonger running. Note that disks remain in-use while the VM is suspended. + */ + SUSPENDED; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == HALTED) return "Halted"; + if (this == PAUSED) return "Paused"; + if (this == RUNNING) return "Running"; + if (this == SUSPENDED) return "Suspended"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VmOperations { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * refers to the operation "snapshot" + */ + SNAPSHOT, + /** + * refers to the operation "clone" + */ + CLONE, + /** + * refers to the operation "copy" + */ + COPY, + /** + * refers to the operation "create_template" + */ + CREATE_TEMPLATE, + /** + * refers to the operation "revert" + */ + REVERT, + /** + * refers to the operation "checkpoint" + */ + CHECKPOINT, + /** + * refers to the operation "snapshot_with_quiesce" + */ + SNAPSHOT_WITH_QUIESCE, + /** + * refers to the operation "provision" + */ + PROVISION, + /** + * refers to the operation "start" + */ + START, + /** + * refers to the operation "start_on" + */ + START_ON, + /** + * refers to the operation "pause" + */ + PAUSE, + /** + * refers to the operation "unpause" + */ + UNPAUSE, + /** + * refers to the operation "clean_shutdown" + */ + CLEAN_SHUTDOWN, + /** + * refers to the operation "clean_reboot" + */ + CLEAN_REBOOT, + /** + * refers to the operation "hard_shutdown" + */ + HARD_SHUTDOWN, + /** + * refers to the operation "power_state_reset" + */ + POWER_STATE_RESET, + /** + * refers to the operation "hard_reboot" + */ + HARD_REBOOT, + /** + * refers to the operation "suspend" + */ + SUSPEND, + /** + * refers to the operation "csvm" + */ + CSVM, + /** + * refers to the operation "resume" + */ + RESUME, + /** + * refers to the operation "resume_on" + */ + RESUME_ON, + /** + * refers to the operation "pool_migrate" + */ + POOL_MIGRATE, + /** + * refers to the operation "migrate_send" + */ + MIGRATE_SEND, + /** + * refers to the operation "get_boot_record" + */ + GET_BOOT_RECORD, + /** + * refers to the operation "send_sysrq" + */ + SEND_SYSRQ, + /** + * refers to the operation "send_trigger" + */ + SEND_TRIGGER, + /** + * refers to the operation "query_services" + */ + QUERY_SERVICES, + /** + * Changing the memory settings + */ + CHANGING_MEMORY_LIVE, + /** + * Waiting for the memory settings to change + */ + AWAITING_MEMORY_LIVE, + /** + * Changing the memory dynamic range + */ + CHANGING_DYNAMIC_RANGE, + /** + * Changing the memory static range + */ + CHANGING_STATIC_RANGE, + /** + * Changing the memory limits + */ + CHANGING_MEMORY_LIMITS, + /** + * Changing the shadow memory for a halted VM. + */ + CHANGING_SHADOW_MEMORY, + /** + * Changing the shadow memory for a running VM. + */ + CHANGING_SHADOW_MEMORY_LIVE, + /** + * Changing VCPU settings for a halted VM. + */ + CHANGING_VCPUS, + /** + * Changing VCPU settings for a running VM. + */ + CHANGING_VCPUS_LIVE, + /** + * + */ + ASSERT_OPERATION_VALID, + /** + * Add, remove, query or list data sources + */ + DATA_SOURCE_OP, + /** + * + */ + UPDATE_ALLOWED_OPERATIONS, + /** + * Turning this VM into a template + */ + MAKE_INTO_TEMPLATE, + /** + * importing a VM from a network stream + */ + IMPORT, + /** + * exporting a VM to a network stream + */ + EXPORT, + /** + * exporting VM metadata to a network stream + */ + METADATA_EXPORT, + /** + * Reverting the VM to a previous snapshotted state + */ + REVERTING, + /** + * refers to the act of uninstalling the VM + */ + DESTROY; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == SNAPSHOT) return "snapshot"; + if (this == CLONE) return "clone"; + if (this == COPY) return "copy"; + if (this == CREATE_TEMPLATE) return "create_template"; + if (this == REVERT) return "revert"; + if (this == CHECKPOINT) return "checkpoint"; + if (this == SNAPSHOT_WITH_QUIESCE) return "snapshot_with_quiesce"; + if (this == PROVISION) return "provision"; + if (this == START) return "start"; + if (this == START_ON) return "start_on"; + if (this == PAUSE) return "pause"; + if (this == UNPAUSE) return "unpause"; + if (this == CLEAN_SHUTDOWN) return "clean_shutdown"; + if (this == CLEAN_REBOOT) return "clean_reboot"; + if (this == HARD_SHUTDOWN) return "hard_shutdown"; + if (this == POWER_STATE_RESET) return "power_state_reset"; + if (this == HARD_REBOOT) return "hard_reboot"; + if (this == SUSPEND) return "suspend"; + if (this == CSVM) return "csvm"; + if (this == RESUME) return "resume"; + if (this == RESUME_ON) return "resume_on"; + if (this == POOL_MIGRATE) return "pool_migrate"; + if (this == MIGRATE_SEND) return "migrate_send"; + if (this == GET_BOOT_RECORD) return "get_boot_record"; + if (this == SEND_SYSRQ) return "send_sysrq"; + if (this == SEND_TRIGGER) return "send_trigger"; + if (this == QUERY_SERVICES) return "query_services"; + if (this == CHANGING_MEMORY_LIVE) return "changing_memory_live"; + if (this == AWAITING_MEMORY_LIVE) return "awaiting_memory_live"; + if (this == CHANGING_DYNAMIC_RANGE) return "changing_dynamic_range"; + if (this == CHANGING_STATIC_RANGE) return "changing_static_range"; + if (this == CHANGING_MEMORY_LIMITS) return "changing_memory_limits"; + if (this == CHANGING_SHADOW_MEMORY) return "changing_shadow_memory"; + if (this == CHANGING_SHADOW_MEMORY_LIVE) return "changing_shadow_memory_live"; + if (this == CHANGING_VCPUS) return "changing_VCPUs"; + if (this == CHANGING_VCPUS_LIVE) return "changing_VCPUs_live"; + if (this == ASSERT_OPERATION_VALID) return "assert_operation_valid"; + if (this == DATA_SOURCE_OP) return "data_source_op"; + if (this == UPDATE_ALLOWED_OPERATIONS) return "update_allowed_operations"; + if (this == MAKE_INTO_TEMPLATE) return "make_into_template"; + if (this == IMPORT) return "import"; + if (this == EXPORT) return "export"; + if (this == METADATA_EXPORT) return "metadata_export"; + if (this == REVERTING) return "reverting"; + if (this == DESTROY) return "destroy"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum BondMode { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Source-level balancing + */ + BALANCE_SLB, + /** + * Active/passive bonding: only one NIC is carrying traffic + */ + ACTIVE_BACKUP, + /** + * Link aggregation control protocol + */ + LACP; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == BALANCE_SLB) return "balance-slb"; + if (this == ACTIVE_BACKUP) return "active-backup"; + if (this == LACP) return "lacp"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum IpConfigurationMode { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Do not acquire an IP address + */ + NONE, + /** + * Acquire an IP address by DHCP + */ + DHCP, + /** + * Static IP address configuration + */ + STATIC; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == NONE) return "None"; + if (this == DHCP) return "DHCP"; + if (this == STATIC) return "Static"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum StorageOperations { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * Scanning backends for new or deleted VDIs + */ + SCAN, + /** + * Destroying the SR + */ + DESTROY, + /** + * Forgetting about SR + */ + FORGET, + /** + * Plugging a PBD into this SR + */ + PLUG, + /** + * Unplugging a PBD from this SR + */ + UNPLUG, + /** + * Refresh the fields on the SR + */ + UPDATE, + /** + * Creating a new VDI + */ + VDI_CREATE, + /** + * Introducing a new VDI + */ + VDI_INTRODUCE, + /** + * Destroying a VDI + */ + VDI_DESTROY, + /** + * Resizing a VDI + */ + VDI_RESIZE, + /** + * Cloneing a VDI + */ + VDI_CLONE, + /** + * Snapshotting a VDI + */ + VDI_SNAPSHOT, + /** + * Creating a PBD for this SR + */ + PBD_CREATE, + /** + * Destroying one of this SR's PBDs + */ + PBD_DESTROY; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == SCAN) return "scan"; + if (this == DESTROY) return "destroy"; + if (this == FORGET) return "forget"; + if (this == PLUG) return "plug"; + if (this == UNPLUG) return "unplug"; + if (this == UPDATE) return "update"; + if (this == VDI_CREATE) return "vdi_create"; + if (this == VDI_INTRODUCE) return "vdi_introduce"; + if (this == VDI_DESTROY) return "vdi_destroy"; + if (this == VDI_RESIZE) return "vdi_resize"; + if (this == VDI_CLONE) return "vdi_clone"; + if (this == VDI_SNAPSHOT) return "vdi_snapshot"; + if (this == PBD_CREATE) return "pbd_create"; + if (this == PBD_DESTROY) return "pbd_destroy"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + public enum VifLockingMode { + /** + * The value does not belong to this enumeration + */ + UNRECOGNIZED, + /** + * No specific configuration set - default network policy applies + */ + NETWORK_DEFAULT, + /** + * Only traffic to a specific MAC and a list of IPv4 or IPv6 addresses is permitted + */ + LOCKED, + /** + * All traffic is permitted + */ + UNLOCKED, + /** + * No traffic is permitted + */ + DISABLED; + public String toString() { + if (this == UNRECOGNIZED) return "UNRECOGNIZED"; + if (this == NETWORK_DEFAULT) return "network_default"; + if (this == LOCKED) return "locked"; + if (this == UNLOCKED) return "unlocked"; + if (this == DISABLED) return "disabled"; + /* This can never be reached */ + return "illegal enum"; + } + + }; + + + /** + * The restore could not be performed because a network interface is missing + */ + public static class RestoreTargetMissingDevice extends XenAPIException { + public final String device; + + /** + * Create a new RestoreTargetMissingDevice + * + * @param device + */ + public RestoreTargetMissingDevice(String device) { + super("The restore could not be performed because a network interface is missing"); + this.device = device; + } + + } + + /** + * The communication with the WLB server timed out. + */ + public static class WlbTimeout extends XenAPIException { + public final String configuredTimeout; + + /** + * Create a new WlbTimeout + * + * @param configuredTimeout + */ + public WlbTimeout(String configuredTimeout) { + super("The communication with the WLB server timed out."); + this.configuredTimeout = configuredTimeout; + } + + } + + /** + * The MAC address specified doesn't exist on this host. + */ + public static class MacDoesNotExist extends XenAPIException { + public final String MAC; + + /** + * Create a new MacDoesNotExist + * + * @param MAC + */ + public MacDoesNotExist(String MAC) { + super("The MAC address specified doesn't exist on this host."); + this.MAC = MAC; + } + + } + + /** + * You gave an invalid object reference. The object may have recently been deleted. The class parameter gives the type of reference given, and the handle parameter echoes the bad value given. + */ + public static class HandleInvalid extends XenAPIException { + public final String clazz; + public final String handle; + + /** + * Create a new HandleInvalid + * + * @param clazz + * @param handle + */ + public HandleInvalid(String clazz, String handle) { + super("You gave an invalid object reference. The object may have recently been deleted. The class parameter gives the type of reference given, and the handle parameter echoes the bad value given."); + this.clazz = clazz; + this.handle = handle; + } + + } + + /** + * The device is already attached to a VM + */ + public static class DeviceAlreadyAttached extends XenAPIException { + public final String device; + + /** + * Create a new DeviceAlreadyAttached + * + * @param device + */ + public DeviceAlreadyAttached(String device) { + super("The device is already attached to a VM"); + this.device = device; + } + + } + + /** + * A required parameter contained an invalid IP address + */ + public static class InvalidIpAddressSpecified extends XenAPIException { + public final String parameter; + + /** + * Create a new InvalidIpAddressSpecified + * + * @param parameter + */ + public InvalidIpAddressSpecified(String parameter) { + super("A required parameter contained an invalid IP address"); + this.parameter = parameter; + } + + } + + /** + * The SR operation cannot be performed because the SR is not empty. + */ + public static class SrNotEmpty extends XenAPIException { + + /** + * Create a new SrNotEmpty + */ + public SrNotEmpty() { + super("The SR operation cannot be performed because the SR is not empty."); + } + + } + + /** + * HVM is required for this operation + */ + public static class VmHvmRequired extends XenAPIException { + public final String vm; + + /** + * Create a new VmHvmRequired + * + * @param vm + */ + public VmHvmRequired(String vm) { + super("HVM is required for this operation"); + this.vm = vm; + } + + } + + /** + * The GPU group contains active PGPUs and cannot be deleted. + */ + public static class GpuGroupContainsPgpu extends XenAPIException { + public final String pgpus; + + /** + * Create a new GpuGroupContainsPgpu + * + * @param pgpus + */ + public GpuGroupContainsPgpu(String pgpus) { + super("The GPU group contains active PGPUs and cannot be deleted."); + this.pgpus = pgpus; + } + + } + + /** + * Operation cannot proceed while a tunnel exists on this interface. + */ + public static class PifTunnelStillExists extends XenAPIException { + public final String PIF; + + /** + * Create a new PifTunnelStillExists + * + * @param PIF + */ + public PifTunnelStillExists(String PIF) { + super("Operation cannot proceed while a tunnel exists on this interface."); + this.PIF = PIF; + } + + } + + /** + * A bond must consist of at least two member interfaces + */ + public static class PifBondNeedsMoreMembers extends XenAPIException { + + /** + * Create a new PifBondNeedsMoreMembers + */ + public PifBondNeedsMoreMembers() { + super("A bond must consist of at least two member interfaces"); + } + + } + + /** + * This operation cannot be performed because the pif is bonded. + */ + public static class PifAlreadyBonded extends XenAPIException { + public final String PIF; + + /** + * Create a new PifAlreadyBonded + * + * @param PIF + */ + public PifAlreadyBonded(String PIF) { + super("This operation cannot be performed because the pif is bonded."); + this.PIF = PIF; + } + + } + + /** + * The disaster recovery task could not be cleanly destroyed. + */ + public static class CannotDestroyDisasterRecoveryTask extends XenAPIException { + public final String reason; + + /** + * Create a new CannotDestroyDisasterRecoveryTask + * + * @param reason + */ + public CannotDestroyDisasterRecoveryTask(String reason) { + super("The disaster recovery task could not be cleanly destroyed."); + this.reason = reason; + } + + } + + /** + * You tried to create a VLAN, but the tag you gave was invalid -- it must be between 0 and 4094. The parameter echoes the VLAN tag you gave. + */ + public static class VlanTagInvalid extends XenAPIException { + public final String VLAN; + + /** + * Create a new VlanTagInvalid + * + * @param VLAN + */ + public VlanTagInvalid(String VLAN) { + super("You tried to create a VLAN, but the tag you gave was invalid -- it must be between 0 and 4094. The parameter echoes the VLAN tag you gave."); + this.VLAN = VLAN; + } + + } + + /** + * You cannot make regular API calls directly on a slave. Please pass API calls via the master host. + */ + public static class HostIsSlave extends XenAPIException { + public final String masterIPAddress; + + /** + * Create a new HostIsSlave + * + * @param masterIPAddress + */ + public HostIsSlave(String masterIPAddress) { + super("You cannot make regular API calls directly on a slave. Please pass API calls via the master host."); + this.masterIPAddress = masterIPAddress; + } + + } + + /** + * The SR.shared flag cannot be set to false while the SR remains connected to multiple hosts + */ + public static class SrHasMultiplePbds extends XenAPIException { + public final String PBD; + + /** + * Create a new SrHasMultiplePbds + * + * @param PBD + */ + public SrHasMultiplePbds(String PBD) { + super("The SR.shared flag cannot be set to false while the SR remains connected to multiple hosts"); + this.PBD = PBD; + } + + } + + /** + * The pool failed to enable external authentication. + */ + public static class PoolAuthEnableFailedInvalidOu extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthEnableFailedInvalidOu + * + * @param host + * @param message + */ + public PoolAuthEnableFailedInvalidOu(String host, String message) { + super("The pool failed to enable external authentication."); + this.host = host; + this.message = message; + } + + } + + /** + * Some data checksums were incorrect; the VM may be corrupt. + */ + public static class ImportErrorSomeChecksumsFailed extends XenAPIException { + + /** + * Create a new ImportErrorSomeChecksumsFailed + */ + public ImportErrorSomeChecksumsFailed() { + super("Some data checksums were incorrect; the VM may be corrupt."); + } + + } + + /** + * This operation needs the OpenVSwitch networking backend to be enabled on all hosts in the pool. + */ + public static class OpenvswitchNotActive extends XenAPIException { + + /** + * Create a new OpenvswitchNotActive + */ + public OpenvswitchNotActive() { + super("This operation needs the OpenVSwitch networking backend to be enabled on all hosts in the pool."); + } + + } + + /** + * The backup partition to stream the updat to cannot be found + */ + public static class CannotFindOemBackupPartition extends XenAPIException { + + /** + * Create a new CannotFindOemBackupPartition + */ + public CannotFindOemBackupPartition() { + super("The backup partition to stream the updat to cannot be found"); + } + + } + + /** + * The specified device was not found. + */ + public static class PifDeviceNotFound extends XenAPIException { + + /** + * Create a new PifDeviceNotFound + */ + public PifDeviceNotFound() { + super("The specified device was not found."); + } + + } + + /** + * An internal error generated by the domain builder. + */ + public static class DomainBuilderError extends XenAPIException { + public final String function; + public final String code; + public final String message; + + /** + * Create a new DomainBuilderError + * + * @param function + * @param code + * @param message + */ + public DomainBuilderError(String function, String code, String message) { + super("An internal error generated by the domain builder."); + this.function = function; + this.code = code; + this.message = message; + } + + } + + /** + * The patch precheck stage failed: there are one or more VMs still running on the server. All VMs must be suspended before the patch can be applied. + */ + public static class PatchPrecheckFailedVmRunning extends XenAPIException { + public final String patch; + + /** + * Create a new PatchPrecheckFailedVmRunning + * + * @param patch + */ + public PatchPrecheckFailedVmRunning(String patch) { + super("The patch precheck stage failed: there are one or more VMs still running on the server. All VMs must be suspended before the patch can be applied."); + this.patch = patch; + } + + } + + /** + * You attempted to run a VM on a host which doesn't have I/O virtualisation (IOMMU/VT-d) enabled, which is needed by the VM. + */ + public static class VmRequiresIommu extends XenAPIException { + public final String host; + + /** + * Create a new VmRequiresIommu + * + * @param host + */ + public VmRequiresIommu(String host) { + super("You attempted to run a VM on a host which doesn't have I/O virtualisation (IOMMU/VT-d) enabled, which is needed by the VM."); + this.host = host; + } + + } + + /** + * The operation failed because the HA software on the specified host could not see a subset of other hosts. Check your network connectivity. + */ + public static class HaHostCannotSeePeers extends XenAPIException { + public final String host; + public final String all; + public final String subset; + + /** + * Create a new HaHostCannotSeePeers + * + * @param host + * @param all + * @param subset + */ + public HaHostCannotSeePeers(String host, String all, String subset) { + super("The operation failed because the HA software on the specified host could not see a subset of other hosts. Check your network connectivity."); + this.host = host; + this.all = all; + this.subset = subset; + } + + } + + /** + * The pool failed to disable the external authentication of at least one host. + */ + public static class PoolAuthDisableFailedPermissionDenied extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthDisableFailedPermissionDenied + * + * @param host + * @param message + */ + public PoolAuthDisableFailedPermissionDenied(String host, String message) { + super("The pool failed to disable the external authentication of at least one host."); + this.host = host; + this.message = message; + } + + } + + /** + * Caller not allowed to perform this operation. + */ + public static class PermissionDenied extends XenAPIException { + public final String message; + + /** + * Create a new PermissionDenied + * + * @param message + */ + public PermissionDenied(String message) { + super("Caller not allowed to perform this operation."); + this.message = message; + } + + } + + /** + * The remote system's SSL certificate failed to verify against our certificate library. + */ + public static class SslVerifyError extends XenAPIException { + public final String reason; + + /** + * Create a new SslVerifyError + * + * @param reason + */ + public SslVerifyError(String reason) { + super("The remote system's SSL certificate failed to verify against our certificate library."); + this.reason = reason; + } + + } + + /** + * Attaching this SR failed. + */ + public static class SrAttachFailed extends XenAPIException { + public final String sr; + + /** + * Create a new SrAttachFailed + * + * @param sr + */ + public SrAttachFailed(String sr) { + super("Attaching this SR failed."); + this.sr = sr; + } + + } + + /** + * Subject already exists. + */ + public static class SubjectAlreadyExists extends XenAPIException { + + /** + * Create a new SubjectAlreadyExists + */ + public SubjectAlreadyExists() { + super("Subject already exists."); + } + + } + + /** + * This host lost access to the HA statefile. + */ + public static class HaLostStatefile extends XenAPIException { + + /** + * Create a new HaLostStatefile + */ + public HaLostStatefile() { + super("This host lost access to the HA statefile."); + } + + } + + /** + * The operation could not be performed because HA is not enabled on the Pool + */ + public static class HaNotEnabled extends XenAPIException { + + /** + * Create a new HaNotEnabled + */ + public HaNotEnabled() { + super("The operation could not be performed because HA is not enabled on the Pool"); + } + + } + + /** + * The host could not join the liveset because the HA daemon failed to start. + */ + public static class HaHeartbeatDaemonStartupFailed extends XenAPIException { + + /** + * Create a new HaHeartbeatDaemonStartupFailed + */ + public HaHeartbeatDaemonStartupFailed() { + super("The host could not join the liveset because the HA daemon failed to start."); + } + + } + + /** + * This session is not registered to receive events. You must call event.register before event.next. The session handle you are using is echoed. + */ + public static class SessionNotRegistered extends XenAPIException { + public final String handle; + + /** + * Create a new SessionNotRegistered + * + * @param handle + */ + public SessionNotRegistered(String handle) { + super("This session is not registered to receive events. You must call event.register before event.next. The session handle you are using is echoed."); + this.handle = handle; + } + + } + + /** + * This VM does not have a suspend SR specified. + */ + public static class VmNoSuspendSr extends XenAPIException { + public final String vm; + + /** + * Create a new VmNoSuspendSr + * + * @param vm + */ + public VmNoSuspendSr(String vm) { + super("This VM does not have a suspend SR specified."); + this.vm = vm; + } + + } + + /** + * You attempted to migrate a VM with more than one snapshot. + */ + public static class VmHasTooManySnapshots extends XenAPIException { + public final String vm; + + /** + * Create a new VmHasTooManySnapshots + * + * @param vm + */ + public VmHasTooManySnapshots(String vm) { + super("You attempted to migrate a VM with more than one snapshot."); + this.vm = vm; + } + + } + + /** + * The patch apply failed. Please see attached output. + */ + public static class PatchApplyFailed extends XenAPIException { + public final String output; + + /** + * Create a new PatchApplyFailed + * + * @param output + */ + public PatchApplyFailed(String output) { + super("The patch apply failed. Please see attached output."); + this.output = output; + } + + } + + /** + * The operation required write access but this VDI is read-only + */ + public static class VdiReadonly extends XenAPIException { + public final String vdi; + + /** + * Create a new VdiReadonly + * + * @param vdi + */ + public VdiReadonly(String vdi) { + super("The operation required write access but this VDI is read-only"); + this.vdi = vdi; + } + + } + + /** + * The SR is full. Requested new size exceeds the maximum size + */ + public static class SrFull extends XenAPIException { + public final String requested; + public final String maximum; + + /** + * Create a new SrFull + * + * @param requested + * @param maximum + */ + public SrFull(String requested, String maximum) { + super("The SR is full. Requested new size exceeds the maximum size"); + this.requested = requested; + this.maximum = maximum; + } + + } + + /** + * You attempted to run a VM on a host which doesn't have a pGPU available in the GPU group needed by the VM. The VM has a vGPU attached to this GPU group. + */ + public static class VmRequiresGpu extends XenAPIException { + public final String vm; + public final String GPUGroup; + + /** + * Create a new VmRequiresGpu + * + * @param vm + * @param GPUGroup + */ + public VmRequiresGpu(String vm, String GPUGroup) { + super("You attempted to run a VM on a host which doesn't have a pGPU available in the GPU group needed by the VM. The VM has a vGPU attached to this GPU group."); + this.vm = vm; + this.GPUGroup = GPUGroup; + } + + } + + /** + * This operation cannot be performed because this VDI could not be properly attached to the VM. + */ + public static class VdiNotAvailable extends XenAPIException { + public final String vdi; + + /** + * Create a new VdiNotAvailable + * + * @param vdi + */ + public VdiNotAvailable(String vdi) { + super("This operation cannot be performed because this VDI could not be properly attached to the VM."); + this.vdi = vdi; + } + + } + + /** + * The server failed to unmarshal the XMLRPC message; it was expecting one element and received something else. + */ + public static class XmlrpcUnmarshalFailure extends XenAPIException { + public final String expected; + public final String received; + + /** + * Create a new XmlrpcUnmarshalFailure + * + * @param expected + * @param received + */ + public XmlrpcUnmarshalFailure(String expected, String received) { + super("The server failed to unmarshal the XMLRPC message; it was expecting one element and received something else."); + this.expected = expected; + this.received = received; + } + + } + + /** + * A CRL already exists with the specified name. + */ + public static class CrlAlreadyExists extends XenAPIException { + public final String name; + + /** + * Create a new CrlAlreadyExists + * + * @param name + */ + public CrlAlreadyExists(String name) { + super("A CRL already exists with the specified name."); + this.name = name; + } + + } + + /** + * The master reports that it cannot talk back to the slave on the supplied management IP address. + */ + public static class HostMasterCannotTalkBack extends XenAPIException { + public final String ip; + + /** + * Create a new HostMasterCannotTalkBack + * + * @param ip + */ + public HostMasterCannotTalkBack(String ip) { + super("The master reports that it cannot talk back to the slave on the supplied management IP address."); + this.ip = ip; + } + + } + + /** + * 3rd party xapi hook failed + */ + public static class XapiHookFailed extends XenAPIException { + public final String hookName; + public final String reason; + public final String stdout; + public final String exitCode; + + /** + * Create a new XapiHookFailed + * + * @param hookName + * @param reason + * @param stdout + * @param exitCode + */ + public XapiHookFailed(String hookName, String reason, String stdout, String exitCode) { + super("3rd party xapi hook failed"); + this.hookName = hookName; + this.reason = reason; + this.stdout = stdout; + this.exitCode = exitCode; + } + + } + + /** + * The import failed because this export has been created by a different (incompatible) product version + */ + public static class ImportIncompatibleVersion extends XenAPIException { + + /** + * Create a new ImportIncompatibleVersion + */ + public ImportIncompatibleVersion() { + super("The import failed because this export has been created by a different (incompatible) product version"); + } + + } + + /** + * The requested bootloader is unknown + */ + public static class UnknownBootloader extends XenAPIException { + public final String vm; + public final String bootloader; + + /** + * Create a new UnknownBootloader + * + * @param vm + * @param bootloader + */ + public UnknownBootloader(String vm, String bootloader) { + super("The requested bootloader is unknown"); + this.vm = vm; + this.bootloader = bootloader; + } + + } + + /** + * The Citrix XenServer Vss Provider is not loaded + */ + public static class XenVssReqErrorProvNotLoaded extends XenAPIException { + public final String vm; + public final String errorCode; + + /** + * Create a new XenVssReqErrorProvNotLoaded + * + * @param vm + * @param errorCode + */ + public XenVssReqErrorProvNotLoaded(String vm, String errorCode) { + super("The Citrix XenServer Vss Provider is not loaded"); + this.vm = vm; + this.errorCode = errorCode; + } + + } + + /** + * The VM is set up to use a feature that requires it to boot as HVM. + */ + public static class FeatureRequiresHvm extends XenAPIException { + public final String details; + + /** + * Create a new FeatureRequiresHvm + * + * @param details + */ + public FeatureRequiresHvm(String details) { + super("The VM is set up to use a feature that requires it to boot as HVM."); + this.details = details; + } + + } + + /** + * The operation could not proceed because necessary VDIs were already locked at the storage level. + */ + public static class SrVdiLockingFailed extends XenAPIException { + + /** + * Create a new SrVdiLockingFailed + */ + public SrVdiLockingFailed() { + super("The operation could not proceed because necessary VDIs were already locked at the storage level."); + } + + } + + /** + * You tried to destroy a PIF, but it represents an aspect of the physical host configuration, and so cannot be destroyed. The parameter echoes the PIF handle you gave. + */ + public static class PifIsPhysical extends XenAPIException { + public final String PIF; + + /** + * Create a new PifIsPhysical + * + * @param PIF + */ + public PifIsPhysical(String PIF) { + super("You tried to destroy a PIF, but it represents an aspect of the physical host configuration, and so cannot be destroyed. The parameter echoes the PIF handle you gave."); + this.PIF = PIF; + } + + } + + /** + * You tried to add a key-value pair to a map, but that key is already there. + */ + public static class MapDuplicateKey extends XenAPIException { + public final String type; + public final String paramName; + public final String uuid; + public final String key; + + /** + * Create a new MapDuplicateKey + * + * @param type + * @param paramName + * @param uuid + * @param key + */ + public MapDuplicateKey(String type, String paramName, String uuid, String key) { + super("You tried to add a key-value pair to a map, but that key is already there."); + this.type = type; + this.paramName = paramName; + this.uuid = uuid; + this.key = key; + } + + } + + /** + * The license-server connection details (address or port) were missing or incomplete. + */ + public static class MissingConnectionDetails extends XenAPIException { + + /** + * Create a new MissingConnectionDetails + */ + public MissingConnectionDetails() { + super("The license-server connection details (address or port) were missing or incomplete."); + } + + } + + /** + * Could not create the XML string generated by the transportable snapshot + */ + public static class XenVssReqErrorCreatingSnapshotXmlString extends XenAPIException { + public final String vm; + public final String errorCode; + + /** + * Create a new XenVssReqErrorCreatingSnapshotXmlString + * + * @param vm + * @param errorCode + */ + public XenVssReqErrorCreatingSnapshotXmlString(String vm, String errorCode) { + super("Could not create the XML string generated by the transportable snapshot"); + this.vm = vm; + this.errorCode = errorCode; + } + + } + + /** + * The bootloader returned an error + */ + public static class BootloaderFailed extends XenAPIException { + public final String vm; + public final String msg; + + /** + * Create a new BootloaderFailed + * + * @param vm + * @param msg + */ + public BootloaderFailed(String vm, String msg) { + super("The bootloader returned an error"); + this.vm = vm; + this.msg = msg; + } + + } + + /** + * The WLB server reported that XenServer said something to it that WLB wasn't expecting or didn't understand. + */ + public static class WlbXenserverMalformedResponse extends XenAPIException { + + /** + * Create a new WlbXenserverMalformedResponse + */ + public WlbXenserverMalformedResponse() { + super("The WLB server reported that XenServer said something to it that WLB wasn't expecting or didn't understand."); + } + + } + + /** + * The GPU group contains active VGPUs and cannot be deleted. + */ + public static class GpuGroupContainsVgpu extends XenAPIException { + public final String vgpus; + + /** + * Create a new GpuGroupContainsVgpu + * + * @param vgpus + */ + public GpuGroupContainsVgpu(String vgpus) { + super("The GPU group contains active VGPUs and cannot be deleted."); + this.vgpus = vgpus; + } + + } + + /** + * The pool failed to enable external authentication. + */ + public static class PoolAuthEnableFailedDuplicateHostname extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthEnableFailedDuplicateHostname + * + * @param host + * @param message + */ + public PoolAuthEnableFailedDuplicateHostname(String host, String message) { + super("The pool failed to enable external authentication."); + this.host = host; + this.message = message; + } + + } + + /** + * Retrieving system status from the host failed. A diagnostic reason suitable for support organisations is also returned. + */ + public static class SystemStatusRetrievalFailed extends XenAPIException { + public final String reason; + + /** + * Create a new SystemStatusRetrievalFailed + * + * @param reason + */ + public SystemStatusRetrievalFailed(String reason) { + super("Retrieving system status from the host failed. A diagnostic reason suitable for support organisations is also returned."); + this.reason = reason; + } + + } + + /** + * This operation cannot be performed because this VDI is in use by some other operation + */ + public static class VdiInUse extends XenAPIException { + public final String vdi; + public final String operation; + + /** + * Create a new VdiInUse + * + * @param vdi + * @param operation + */ + public VdiInUse(String vdi, String operation) { + super("This operation cannot be performed because this VDI is in use by some other operation"); + this.vdi = vdi; + this.operation = operation; + } + + } + + /** + * This operation cannot be completed as the host is not live. + */ + public static class HostNotLive extends XenAPIException { + + /** + * Create a new HostNotLive + */ + public HostNotLive() { + super("This operation cannot be completed as the host is not live."); + } + + } + + /** + * A certificate already exists with the specified name. + */ + public static class CertificateAlreadyExists extends XenAPIException { + public final String name; + + /** + * Create a new CertificateAlreadyExists + * + * @param name + */ + public CertificateAlreadyExists(String name) { + super("A certificate already exists with the specified name."); + this.name = name; + } + + } + + /** + * The SR has no attached PBDs + */ + public static class SrHasNoPbds extends XenAPIException { + public final String sr; + + /** + * Create a new SrHasNoPbds + * + * @param sr + */ + public SrHasNoPbds(String sr) { + super("The SR has no attached PBDs"); + this.sr = sr; + } + + } + + /** + * This PIF is a bond slave and cannot have a tunnel on it. + */ + public static class CannotAddTunnelToBondSlave extends XenAPIException { + public final String PIF; + + /** + * Create a new CannotAddTunnelToBondSlave + * + * @param PIF + */ + public CannotAddTunnelToBondSlave(String PIF) { + super("This PIF is a bond slave and cannot have a tunnel on it."); + this.PIF = PIF; + } + + } + + /** + * The uploaded patch file is invalid + */ + public static class InvalidPatch extends XenAPIException { + + /** + * Create a new InvalidPatch + */ + public InvalidPatch() { + super("The uploaded patch file is invalid"); + } + + } + + /** + * The SR could not be destroyed, as the 'indestructible' flag was set on it. + */ + public static class SrIndestructible extends XenAPIException { + public final String sr; + + /** + * Create a new SrIndestructible + * + * @param sr + */ + public SrIndestructible(String sr) { + super("The SR could not be destroyed, as the 'indestructible' flag was set on it."); + this.sr = sr; + } + + } + + /** + * This host cannot accept the proposed new master setting at this time. + */ + public static class HaAbortNewMaster extends XenAPIException { + public final String reason; + + /** + * Create a new HaAbortNewMaster + * + * @param reason + */ + public HaAbortNewMaster(String reason) { + super("This host cannot accept the proposed new master setting at this time."); + this.reason = reason; + } + + } + + /** + * The WLB server said something that XenServer wasn't expecting or didn't understand. The method called on the WLB server, a diagnostic reason, and the response from WLB are returned. + */ + public static class WlbMalformedResponse extends XenAPIException { + public final String method; + public final String reason; + public final String response; + + /** + * Create a new WlbMalformedResponse + * + * @param method + * @param reason + * @param response + */ + public WlbMalformedResponse(String method, String reason, String response) { + super("The WLB server said something that XenServer wasn't expecting or didn't understand. The method called on the WLB server, a diagnostic reason, and the response from WLB are returned."); + this.method = method; + this.reason = reason; + this.response = response; + } + + } + + /** + * The host joining the pool must have a physical management NIC (i.e. the management NIC must not be on a VLAN or bonded PIF). + */ + public static class PoolJoiningHostMustHavePhysicalManagementNic extends XenAPIException { + + /** + * Create a new PoolJoiningHostMustHavePhysicalManagementNic + */ + public PoolJoiningHostMustHavePhysicalManagementNic() { + super("The host joining the pool must have a physical management NIC (i.e. the management NIC must not be on a VLAN or bonded PIF)."); + } + + } + + /** + * PIF has no IPv6 configuration (mode curently set to 'none') + */ + public static class PifHasNoV6NetworkConfiguration extends XenAPIException { + + /** + * Create a new PifHasNoV6NetworkConfiguration + */ + public PifHasNoV6NetworkConfiguration() { + super("PIF has no IPv6 configuration (mode curently set to 'none')"); + } + + } + + /** + * This operation is not allowed as the VM is part of an appliance. + */ + public static class VmIsPartOfAnAppliance extends XenAPIException { + public final String vm; + public final String appliance; + + /** + * Create a new VmIsPartOfAnAppliance + * + * @param vm + * @param appliance + */ + public VmIsPartOfAnAppliance(String vm, String appliance) { + super("This operation is not allowed as the VM is part of an appliance."); + this.vm = vm; + this.appliance = appliance; + } + + } + + /** + * The WLB server reported that XenServer rejected its configured authentication details. + */ + public static class WlbXenserverAuthenticationFailed extends XenAPIException { + + /** + * Create a new WlbXenserverAuthenticationFailed + */ + public WlbXenserverAuthenticationFailed() { + super("The WLB server reported that XenServer rejected its configured authentication details."); + } + + } + + /** + * The power-state of a control domain cannot be reset. + */ + public static class CannotResetControlDomain extends XenAPIException { + public final String vm; + + /** + * Create a new CannotResetControlDomain + * + * @param vm + */ + public CannotResetControlDomain(String vm) { + super("The power-state of a control domain cannot be reset."); + this.vm = vm; + } + + } + + /** + * The patch precheck stage failed with an unknown error. See attached info for more details. + */ + public static class PatchPrecheckFailedUnknownError extends XenAPIException { + public final String patch; + public final String info; + + /** + * Create a new PatchPrecheckFailedUnknownError + * + * @param patch + * @param info + */ + public PatchPrecheckFailedUnknownError(String patch, String info) { + super("The patch precheck stage failed with an unknown error. See attached info for more details."); + this.patch = patch; + this.info = info; + } + + } + + /** + * Host cannot attach network (in the case of NIC bonding, this may be because attaching the network on this host would require other networks [that are currently active] to be taken down). + */ + public static class HostCannotAttachNetwork extends XenAPIException { + public final String host; + public final String network; + + /** + * Create a new HostCannotAttachNetwork + * + * @param host + * @param network + */ + public HostCannotAttachNetwork(String host, String network) { + super("Host cannot attach network (in the case of NIC bonding, this may be because attaching the network on this host would require other networks [that are currently active] to be taken down)."); + this.host = host; + this.network = network; + } + + } + + /** + * The WLB URL is invalid. Ensure it is in format: :. The configured/given URL is returned. + */ + public static class WlbUrlInvalid extends XenAPIException { + public final String url; + + /** + * Create a new WlbUrlInvalid + * + * @param url + */ + public WlbUrlInvalid(String url) { + super("The WLB URL is invalid. Ensure it is in format: :. The configured/given URL is returned."); + this.url = url; + } + + } + + /** + * Cannot restore this VM because it would create a duplicate + */ + public static class DuplicateVm extends XenAPIException { + public final String vm; + + /** + * Create a new DuplicateVm + * + * @param vm + */ + public DuplicateVm(String vm) { + super("Cannot restore this VM because it would create a duplicate"); + this.vm = vm; + } + + } + + /** + * The pool master host cannot be removed. + */ + public static class HostCannotDestroySelf extends XenAPIException { + public final String host; + + /** + * Create a new HostCannotDestroySelf + * + * @param host + */ + public HostCannotDestroySelf(String host) { + super("The pool master host cannot be removed."); + this.host = host; + } + + } + + /** + * This host failed in the middle of an automatic failover operation and needs to retry the failover action + */ + public static class HostBroken extends XenAPIException { + + /** + * Create a new HostBroken + */ + public HostBroken() { + super("This host failed in the middle of an automatic failover operation and needs to retry the failover action"); + } + + } + + /** + * An error occured while restoring the memory image of the specified virtual machine + */ + public static class VmCheckpointResumeFailed extends XenAPIException { + public final String vm; + + /** + * Create a new VmCheckpointResumeFailed + * + * @param vm + */ + public VmCheckpointResumeFailed(String vm) { + super("An error occured while restoring the memory image of the specified virtual machine"); + this.vm = vm; + } + + } + + /** + * Too many VCPUs to start this VM + */ + public static class VmTooManyVcpus extends XenAPIException { + public final String vm; + + /** + * Create a new VmTooManyVcpus + * + * @param vm + */ + public VmTooManyVcpus(String vm) { + super("Too many VCPUs to start this VM"); + this.vm = vm; + } + + } + + /** + * This operation cannot be completed as the host is still live. + */ + public static class HostIsLive extends XenAPIException { + public final String host; + + /** + * Create a new HostIsLive + * + * @param host + */ + public HostIsLive(String host) { + super("This operation cannot be completed as the host is still live."); + this.host = host; + } + + } + + /** + * The VM could not be imported because attached disks could not be found. + */ + public static class ImportErrorAttachedDisksNotFound extends XenAPIException { + + /** + * Create a new ImportErrorAttachedDisksNotFound + */ + public ImportErrorAttachedDisksNotFound() { + super("The VM could not be imported because attached disks could not be found."); + } + + } + + /** + * Drive could not be hot-unplugged because it is not marked as unpluggable + */ + public static class VbdNotUnpluggable extends XenAPIException { + public final String vbd; + + /** + * Create a new VbdNotUnpluggable + * + * @param vbd + */ + public VbdNotUnpluggable(String vbd) { + super("Drive could not be hot-unplugged because it is not marked as unpluggable"); + this.vbd = vbd; + } + + } + + /** + * An attempt to create the snapshots failed + */ + public static class XenVssReqErrorCreatingSnapshot extends XenAPIException { + public final String vm; + public final String errorCode; + + /** + * Create a new XenVssReqErrorCreatingSnapshot + * + * @param vm + * @param errorCode + */ + public XenVssReqErrorCreatingSnapshot(String vm, String errorCode) { + super("An attempt to create the snapshots failed"); + this.vm = vm; + this.errorCode = errorCode; + } + + } + + /** + * Could not enable redo log. + */ + public static class CannotEnableRedoLog extends XenAPIException { + public final String reason; + + /** + * Create a new CannotEnableRedoLog + * + * @param reason + */ + public CannotEnableRedoLog(String reason) { + super("Could not enable redo log."); + this.reason = reason; + } + + } + + /** + * This host cannot be evacuated. + */ + public static class CannotEvacuateHost extends XenAPIException { + public final String errors; + + /** + * Create a new CannotEvacuateHost + * + * @param errors + */ + public CannotEvacuateHost(String errors) { + super("This host cannot be evacuated."); + this.errors = errors; + } + + } + + /** + * There were no hosts available to complete the specified operation. + */ + public static class NoHostsAvailable extends XenAPIException { + + /** + * Create a new NoHostsAvailable + */ + public NoHostsAvailable() { + super("There were no hosts available to complete the specified operation."); + } + + } + + /** + * A timeout happened while attempting to attach a device to a VM. + */ + public static class DeviceAttachTimeout extends XenAPIException { + public final String type; + public final String ref; + + /** + * Create a new DeviceAttachTimeout + * + * @param type + * @param ref + */ + public DeviceAttachTimeout(String type, String ref) { + super("A timeout happened while attempting to attach a device to a VM."); + this.type = type; + this.ref = ref; + } + + } + + /** + * The device name is invalid + */ + public static class InvalidDevice extends XenAPIException { + public final String device; + + /** + * Create a new InvalidDevice + * + * @param device + */ + public InvalidDevice(String device) { + super("The device name is invalid"); + this.device = device; + } + + } + + /** + * A PBD already exists connecting the SR to the host + */ + public static class PbdExists extends XenAPIException { + public final String sr; + public final String host; + public final String pbd; + + /** + * Create a new PbdExists + * + * @param sr + * @param host + * @param pbd + */ + public PbdExists(String sr, String host, String pbd) { + super("A PBD already exists connecting the SR to the host"); + this.sr = sr; + this.host = host; + this.pbd = pbd; + } + + } + + /** + * The WLB server reported that XenServer refused it a connection (even though we're connecting perfectly fine in the other direction). + */ + public static class WlbXenserverConnectionRefused extends XenAPIException { + + /** + * Create a new WlbXenserverConnectionRefused + */ + public WlbXenserverConnectionRefused() { + super("The WLB server reported that XenServer refused it a connection (even though we're connecting perfectly fine in the other direction)."); + } + + } + + /** + * The metrics of this host could not be read. + */ + public static class HostCannotReadMetrics extends XenAPIException { + + /** + * Create a new HostCannotReadMetrics + */ + public HostCannotReadMetrics() { + super("The metrics of this host could not be read."); + } + + } + + /** + * The VM is incompatible with the CPU features of this host. + */ + public static class VmIncompatibleWithThisHost extends XenAPIException { + public final String vm; + public final String host; + public final String reason; + + /** + * Create a new VmIncompatibleWithThisHost + * + * @param vm + * @param host + * @param reason + */ + public VmIncompatibleWithThisHost(String vm, String host, String reason) { + super("The VM is incompatible with the CPU features of this host."); + this.vm = vm; + this.host = host; + this.reason = reason; + } + + } + + /** + * The upper limit of active redo log instances was reached. + */ + public static class NoMoreRedoLogsAllowed extends XenAPIException { + + /** + * Create a new NoMoreRedoLogsAllowed + */ + public NoMoreRedoLogsAllowed() { + super("The upper limit of active redo log instances was reached."); + } + + } + + /** + * The pool failed to enable external authentication. + */ + public static class PoolAuthEnableFailed extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthEnableFailed + * + * @param host + * @param message + */ + public PoolAuthEnableFailed(String host, String message) { + super("The pool failed to enable external authentication."); + this.host = host; + this.message = message; + } + + } + + /** + * The VSS plug-in is not installed on this virtual machine + */ + public static class VmSnapshotWithQuiesceNotSupported extends XenAPIException { + public final String vm; + public final String error; + + /** + * Create a new VmSnapshotWithQuiesceNotSupported + * + * @param vm + * @param error + */ + public VmSnapshotWithQuiesceNotSupported(String vm, String error) { + super("The VSS plug-in is not installed on this virtual machine"); + this.vm = vm; + this.error = error; + } + + } + + /** + * This host cannot join a pool because it's license does not support pooling + */ + public static class LicenseDoesNotSupportPooling extends XenAPIException { + + /** + * Create a new LicenseDoesNotSupportPooling + */ + public LicenseDoesNotSupportPooling() { + super("This host cannot join a pool because it's license does not support pooling"); + } + + } + + /** + * The master says the host is not known to it. Perhaps the Host was deleted from the master's database? Perhaps the slave is pointing to the wrong master? + */ + public static class HostUnknownToMaster extends XenAPIException { + public final String host; + + /** + * Create a new HostUnknownToMaster + * + * @param host + */ + public HostUnknownToMaster(String host) { + super("The master says the host is not known to it. Perhaps the Host was deleted from the master's database? Perhaps the slave is pointing to the wrong master?"); + this.host = host; + } + + } + + /** + * The WLB server refused a connection to XenServer. + */ + public static class WlbConnectionRefused extends XenAPIException { + + /** + * Create a new WlbConnectionRefused + */ + public WlbConnectionRefused() { + super("The WLB server refused a connection to XenServer."); + } + + } + + /** + * The VSS plug-in cannot be contacted + */ + public static class VmSnapshotWithQuiescePluginDeosNotRespond extends XenAPIException { + public final String vm; + + /** + * Create a new VmSnapshotWithQuiescePluginDeosNotRespond + * + * @param vm + */ + public VmSnapshotWithQuiescePluginDeosNotRespond(String vm) { + super("The VSS plug-in cannot be contacted"); + this.vm = vm; + } + + } + + /** + * You attempted to run a VM on a host which doesn't have access to an SR needed by the VM. The VM has at least one VBD attached to a VDI in the SR. + */ + public static class VmRequiresSr extends XenAPIException { + public final String vm; + public final String sr; + + /** + * Create a new VmRequiresSr + * + * @param vm + * @param sr + */ + public VmRequiresSr(String vm, String sr) { + super("You attempted to run a VM on a host which doesn't have access to an SR needed by the VM. The VM has at least one VBD attached to a VDI in the SR."); + this.vm = vm; + this.sr = sr; + } + + } + + /** + * This VM does not have a crashdump SR specified. + */ + public static class VmNoCrashdumpSr extends XenAPIException { + public final String vm; + + /** + * Create a new VmNoCrashdumpSr + * + * @param vm + */ + public VmNoCrashdumpSr(String vm) { + super("This VM does not have a crashdump SR specified."); + this.vm = vm; + } + + } + + /** + * The operation could not be performed because the HA software is not installed on this host. + */ + public static class HaNotInstalled extends XenAPIException { + public final String host; + + /** + * Create a new HaNotInstalled + * + * @param host + */ + public HaNotInstalled(String host) { + super("The operation could not be performed because the HA software is not installed on this host."); + this.host = host; + } + + } + + /** + * A PIF with this specified device name already exists. + */ + public static class DuplicatePifDeviceName extends XenAPIException { + public final String device; + + /** + * Create a new DuplicatePifDeviceName + * + * @param device + */ + public DuplicatePifDeviceName(String device) { + super("A PIF with this specified device name already exists."); + this.device = device; + } + + } + + /** + * You attempted an operation on a VM that was not in an appropriate power state at the time; for example, you attempted to start a VM that was already running. The parameters returned are the VM's handle, and the expected and actual VM state at the time of the call. + */ + public static class VmBadPowerState extends XenAPIException { + public final String vm; + public final String expected; + public final String actual; + + /** + * Create a new VmBadPowerState + * + * @param vm + * @param expected + * @param actual + */ + public VmBadPowerState(String vm, String expected, String actual) { + super("You attempted an operation on a VM that was not in an appropriate power state at the time; for example, you attempted to start a VM that was already running. The parameters returned are the VM's handle, and the expected and actual VM state at the time of the call."); + this.vm = vm; + this.expected = expected; + this.actual = actual; + } + + } + + /** + * This pool has wlb-enabled set to false. + */ + public static class WlbDisabled extends XenAPIException { + + /** + * Create a new WlbDisabled + */ + public WlbDisabled() { + super("This pool has wlb-enabled set to false."); + } + + } + + /** + * This VM operation cannot be performed on an older-versioned host during an upgrade. + */ + public static class VmHostIncompatibleVersion extends XenAPIException { + public final String host; + public final String vm; + + /** + * Create a new VmHostIncompatibleVersion + * + * @param host + * @param vm + */ + public VmHostIncompatibleVersion(String host, String vm) { + super("This VM operation cannot be performed on an older-versioned host during an upgrade."); + this.host = host; + this.vm = vm; + } + + } + + /** + * Cannot join pool whose external authentication configuration is different. + */ + public static class PoolJoiningExternalAuthMismatch extends XenAPIException { + + /** + * Create a new PoolJoiningExternalAuthMismatch + */ + public PoolJoiningExternalAuthMismatch() { + super("Cannot join pool whose external authentication configuration is different."); + } + + } + + /** + * All VBDs of type 'disk' must be read/write for HVM guests + */ + public static class DiskVbdMustBeReadwriteForHvm extends XenAPIException { + public final String vbd; + + /** + * Create a new DiskVbdMustBeReadwriteForHvm + * + * @param vbd + */ + public DiskVbdMustBeReadwriteForHvm(String vbd) { + super("All VBDs of type 'disk' must be read/write for HVM guests"); + this.vbd = vbd; + } + + } + + /** + * The BIOS strings for this VM have already been set and cannot be changed anymore. + */ + public static class VmBiosStringsAlreadySet extends XenAPIException { + + /** + * Create a new VmBiosStringsAlreadySet + */ + public VmBiosStringsAlreadySet() { + super("The BIOS strings for this VM have already been set and cannot be changed anymore."); + } + + } + + /** + * The WLB server reported that its configured server name for this XenServer instance failed to resolve in DNS. + */ + public static class WlbXenserverUnknownHost extends XenAPIException { + + /** + * Create a new WlbXenserverUnknownHost + */ + public WlbXenserverUnknownHost() { + super("The WLB server reported that its configured server name for this XenServer instance failed to resolve in DNS."); + } + + } + + /** + * The host could not join the liveset because the HA daemon could not access the heartbeat disk. + */ + public static class HaHostCannotAccessStatefile extends XenAPIException { + + /** + * Create a new HaHostCannotAccessStatefile + */ + public HaHostCannotAccessStatefile() { + super("The host could not join the liveset because the HA daemon could not access the heartbeat disk."); + } + + } + + /** + * VM didn't acknowledge the need to shutdown. + */ + public static class VmFailedShutdownAcknowledgment extends XenAPIException { + + /** + * Create a new VmFailedShutdownAcknowledgment + */ + public VmFailedShutdownAcknowledgment() { + super("VM didn't acknowledge the need to shutdown."); + } + + } + + /** + * Error querying the external directory service. + */ + public static class AuthServiceError extends XenAPIException { + public final String message; + + /** + * Create a new AuthServiceError + * + * @param message + */ + public AuthServiceError(String message) { + super("Error querying the external directory service."); + this.message = message; + } + + } + + /** + * Cannot perform operation as the host is running in emergency mode. + */ + public static class HostInEmergencyMode extends XenAPIException { + + /** + * Create a new HostInEmergencyMode + */ + public HostInEmergencyMode() { + super("Cannot perform operation as the host is running in emergency mode."); + } + + } + + /** + * The specified host is disabled and cannot be re-enabled until after it has rebooted. + */ + public static class HostDisabledUntilReboot extends XenAPIException { + public final String host; + + /** + * Create a new HostDisabledUntilReboot + * + * @param host + */ + public HostDisabledUntilReboot(String host) { + super("The specified host is disabled and cannot be re-enabled until after it has rebooted."); + this.host = host; + } + + } + + /** + * The default SR reference does not point to a valid SR + */ + public static class DefaultSrNotFound extends XenAPIException { + public final String sr; + + /** + * Create a new DefaultSrNotFound + * + * @param sr + */ + public DefaultSrNotFound(String sr) { + super("The default SR reference does not point to a valid SR"); + this.sr = sr; + } + + } + + /** + * A device with the name given already exists on the selected VM + */ + public static class DeviceAlreadyExists extends XenAPIException { + public final String device; + + /** + * Create a new DeviceAlreadyExists + * + * @param device + */ + public DeviceAlreadyExists(String device) { + super("A device with the name given already exists on the selected VM"); + this.device = device; + } + + } + + /** + * The PBD could not be plugged because the SR is in use by another host and is not marked as sharable. + */ + public static class SrNotSharable extends XenAPIException { + public final String sr; + public final String host; + + /** + * Create a new SrNotSharable + * + * @param sr + * @param host + */ + public SrNotSharable(String sr, String host) { + super("The PBD could not be plugged because the SR is in use by another host and is not marked as sharable."); + this.sr = sr; + this.host = host; + } + + } + + /** + * You attempted to migrate a VM which has a checkpoint. + */ + public static class VmHasCheckpoint extends XenAPIException { + public final String vm; + + /** + * Create a new VmHasCheckpoint + * + * @param vm + */ + public VmHasCheckpoint(String vm) { + super("You attempted to migrate a VM which has a checkpoint."); + this.vm = vm; + } + + } + + /** + * The SM plugin did not respond to a query. + */ + public static class SmPluginCommunicationFailure extends XenAPIException { + public final String sm; + + /** + * Create a new SmPluginCommunicationFailure + * + * @param sm + */ + public SmPluginCommunicationFailure(String sm) { + super("The SM plugin did not respond to a query."); + this.sm = sm; + } + + } + + /** + * This VM is assigned to a protection policy. + */ + public static class VmAssignedToProtectionPolicy extends XenAPIException { + public final String vm; + public final String vmpp; + + /** + * Create a new VmAssignedToProtectionPolicy + * + * @param vm + * @param vmpp + */ + public VmAssignedToProtectionPolicy(String vm, String vmpp) { + super("This VM is assigned to a protection policy."); + this.vm = vm; + this.vmpp = vmpp; + } + + } + + /** + * RBAC permission denied. + */ + public static class RbacPermissionDenied extends XenAPIException { + public final String permission; + public final String message; + + /** + * Create a new RbacPermissionDenied + * + * @param permission + * @param message + */ + public RbacPermissionDenied(String permission, String message) { + super("RBAC permission denied."); + this.permission = permission; + this.message = message; + } + + } + + /** + * The host failed to disable external authentication. + */ + public static class AuthDisableFailedPermissionDenied extends XenAPIException { + public final String message; + + /** + * Create a new AuthDisableFailedPermissionDenied + * + * @param message + */ + public AuthDisableFailedPermissionDenied(String message) { + super("The host failed to disable external authentication."); + this.message = message; + } + + } + + /** + * Cannot downgrade license while in pool. Please disband the pool first, then downgrade licenses on hosts separately. + */ + public static class LicenseCannotDowngradeWhileInPool extends XenAPIException { + + /** + * Create a new LicenseCannotDowngradeWhileInPool + */ + public LicenseCannotDowngradeWhileInPool() { + super("Cannot downgrade license while in pool. Please disband the pool first, then downgrade licenses on hosts separately."); + } + + } + + /** + * The request was rejected because there are too many pending tasks on the server. + */ + public static class TooManyPendingTasks extends XenAPIException { + + /** + * Create a new TooManyPendingTasks + */ + public TooManyPendingTasks() { + super("The request was rejected because there are too many pending tasks on the server."); + } + + } + + /** + * The VSS plug-in has timed out + */ + public static class VmSnapshotWithQuiesceTimeout extends XenAPIException { + public final String vm; + + /** + * Create a new VmSnapshotWithQuiesceTimeout + * + * @param vm + */ + public VmSnapshotWithQuiesceTimeout(String vm) { + super("The VSS plug-in has timed out"); + this.vm = vm; + } + + } + + /** + * This operation cannot be performed because creating or deleting a bond involving the management interface is not allowed while HA is on. In order to do that, disable HA, create or delete the bond then re-enable HA. + */ + public static class HaCannotChangeBondStatusOfMgmtIface extends XenAPIException { + + /** + * Create a new HaCannotChangeBondStatusOfMgmtIface + */ + public HaCannotChangeBondStatusOfMgmtIface() { + super("This operation cannot be performed because creating or deleting a bond involving the management interface is not allowed while HA is on. In order to do that, disable HA, create or delete the bond then re-enable HA."); + } + + } + + /** + * This patch has already been applied + */ + public static class PatchAlreadyApplied extends XenAPIException { + public final String patch; + + /** + * Create a new PatchAlreadyApplied + * + * @param patch + */ + public PatchAlreadyApplied(String patch) { + super("This patch has already been applied"); + this.patch = patch; + } + + } + + /** + * An SR with that uuid already exists. + */ + public static class SrUuidExists extends XenAPIException { + public final String uuid; + + /** + * Create a new SrUuidExists + * + * @param uuid + */ + public SrUuidExists(String uuid) { + super("An SR with that uuid already exists."); + this.uuid = uuid; + } + + } + + /** + * The host failed to enable external authentication. + */ + public static class AuthEnableFailedDomainLookupFailed extends XenAPIException { + public final String message; + + /** + * Create a new AuthEnableFailedDomainLookupFailed + * + * @param message + */ + public AuthEnableFailedDomainLookupFailed(String message) { + super("The host failed to enable external authentication."); + this.message = message; + } + + } + + /** + * The patch precheck stage failed: the server is of an incorrect build. + */ + public static class PatchPrecheckFailedWrongServerBuild extends XenAPIException { + public final String patch; + public final String foundBuild; + public final String requiredBuild; + + /** + * Create a new PatchPrecheckFailedWrongServerBuild + * + * @param patch + * @param foundBuild + * @param requiredBuild + */ + public PatchPrecheckFailedWrongServerBuild(String patch, String foundBuild, String requiredBuild) { + super("The patch precheck stage failed: the server is of an incorrect build."); + this.patch = patch; + this.foundBuild = foundBuild; + this.requiredBuild = requiredBuild; + } + + } + + /** + * The given feature string is not valid. + */ + public static class InvalidFeatureString extends XenAPIException { + public final String details; + + /** + * Create a new InvalidFeatureString + * + * @param details + */ + public InvalidFeatureString(String details) { + super("The given feature string is not valid."); + this.details = details; + } + + } + + /** + * No WLB connection is configured. + */ + public static class WlbNotInitialized extends XenAPIException { + + /** + * Create a new WlbNotInitialized + */ + public WlbNotInitialized() { + super("No WLB connection is configured."); + } + + } + + /** + * You attempted an operation that was explicitly blocked (see the blocked_operations field of the given object). + */ + public static class OperationBlocked extends XenAPIException { + public final String ref; + public final String code; + + /** + * Create a new OperationBlocked + * + * @param ref + * @param code + */ + public OperationBlocked(String ref, String code) { + super("You attempted an operation that was explicitly blocked (see the blocked_operations field of the given object)."); + this.ref = ref; + this.code = code; + } + + } + + /** + * The provision call can only be invoked on templates, not regular VMs. + */ + public static class ProvisionOnlyAllowedOnTemplate extends XenAPIException { + + /** + * Create a new ProvisionOnlyAllowedOnTemplate + */ + public ProvisionOnlyAllowedOnTemplate() { + super("The provision call can only be invoked on templates, not regular VMs."); + } + + } + + /** + * VM failed to shutdown before the timeout expired + */ + public static class VmShutdownTimeout extends XenAPIException { + public final String vm; + public final String timeout; + + /** + * Create a new VmShutdownTimeout + * + * @param vm + * @param timeout + */ + public VmShutdownTimeout(String vm, String timeout) { + super("VM failed to shutdown before the timeout expired"); + this.vm = vm; + this.timeout = timeout; + } + + } + + /** + * Role already exists. + */ + public static class RoleAlreadyExists extends XenAPIException { + + /** + * Create a new RoleAlreadyExists + */ + public RoleAlreadyExists() { + super("Role already exists."); + } + + } + + /** + * The network contains active PIFs and cannot be deleted. + */ + public static class NetworkContainsPif extends XenAPIException { + public final String pifs; + + /** + * Create a new NetworkContainsPif + * + * @param pifs + */ + public NetworkContainsPif(String pifs) { + super("The network contains active PIFs and cannot be deleted."); + this.pifs = pifs; + } + + } + + /** + * Could not find a network interface with the specified device name and MAC address. + */ + public static class CouldNotFindNetworkInterfaceWithSpecifiedDeviceNameAndMacAddress extends XenAPIException { + public final String device; + public final String mac; + + /** + * Create a new CouldNotFindNetworkInterfaceWithSpecifiedDeviceNameAndMacAddress + * + * @param device + * @param mac + */ + public CouldNotFindNetworkInterfaceWithSpecifiedDeviceNameAndMacAddress(String device, String mac) { + super("Could not find a network interface with the specified device name and MAC address."); + this.device = device; + this.mac = mac; + } + + } + + /** + * There was an error connecting to the host. the service contacted didn't reply properly. + */ + public static class JoiningHostServiceFailed extends XenAPIException { + + /** + * Create a new JoiningHostServiceFailed + */ + public JoiningHostServiceFailed() { + super("There was an error connecting to the host. the service contacted didn't reply properly."); + } + + } + + /** + * This operation cannot be performed because the specified VDI could not be found on the storage substrate + */ + public static class VdiMissing extends XenAPIException { + public final String sr; + public final String vdi; + + /** + * Create a new VdiMissing + * + * @param sr + * @param vdi + */ + public VdiMissing(String sr, String vdi) { + super("This operation cannot be performed because the specified VDI could not be found on the storage substrate"); + this.sr = sr; + this.vdi = vdi; + } + + } + + /** + * This VM has locked the DVD drive tray, so the disk cannot be ejected + */ + public static class VbdTrayLocked extends XenAPIException { + public final String vbd; + + /** + * Create a new VbdTrayLocked + * + * @param vbd + */ + public VbdTrayLocked(String vbd) { + super("This VM has locked the DVD drive tray, so the disk cannot be ejected"); + this.vbd = vbd; + } + + } + + /** + * The pool failed to enable external authentication. + */ + public static class PoolAuthEnableFailedPermissionDenied extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthEnableFailedPermissionDenied + * + * @param host + * @param message + */ + public PoolAuthEnableFailedPermissionDenied(String host, String message) { + super("The pool failed to enable external authentication."); + this.host = host; + this.message = message; + } + + } + + /** + * The uuid you supplied was invalid. + */ + public static class UuidInvalid extends XenAPIException { + public final String type; + public final String uuid; + + /** + * Create a new UuidInvalid + * + * @param type + * @param uuid + */ + public UuidInvalid(String type, String uuid) { + super("The uuid you supplied was invalid."); + this.type = type; + this.uuid = uuid; + } + + } + + /** + * This operation is not allowed under your license. Please contact your support representative. + */ + public static class LicenceRestriction extends XenAPIException { + + /** + * Create a new LicenceRestriction + */ + public LicenceRestriction() { + super("This operation is not allowed under your license. Please contact your support representative."); + } + + } + + /** + * Network has active VIFs + */ + public static class VifInUse extends XenAPIException { + public final String network; + public final String VIF; + + /** + * Create a new VifInUse + * + * @param network + * @param VIF + */ + public VifInUse(String network, String VIF) { + super("Network has active VIFs"); + this.network = network; + this.VIF = VIF; + } + + } + + /** + * This command is only allowed on the OEM edition. + */ + public static class OnlyAllowedOnOemEdition extends XenAPIException { + public final String command; + + /** + * Create a new OnlyAllowedOnOemEdition + * + * @param command + */ + public OnlyAllowedOnOemEdition(String command) { + super("This command is only allowed on the OEM edition."); + this.command = command; + } + + } + + /** + * The operation cannot be performed on physical device + */ + public static class VdiIsAPhysicalDevice extends XenAPIException { + public final String vdi; + + /** + * Create a new VdiIsAPhysicalDevice + * + * @param vdi + */ + public VdiIsAPhysicalDevice(String vdi) { + super("The operation cannot be performed on physical device"); + this.vdi = vdi; + } + + } + + /** + * There was an error processing your license. Please contact your support representative. + */ + public static class LicenseProcessingError extends XenAPIException { + + /** + * Create a new LicenseProcessingError + */ + public LicenseProcessingError() { + super("There was an error processing your license. Please contact your support representative."); + } + + } + + /** + * The specified VBD device is not recognised: please use a non-negative integer + */ + public static class IllegalVbdDevice extends XenAPIException { + public final String vbd; + public final String device; + + /** + * Create a new IllegalVbdDevice + * + * @param vbd + * @param device + */ + public IllegalVbdDevice(String vbd, String device) { + super("The specified VBD device is not recognised: please use a non-negative integer"); + this.vbd = vbd; + this.device = device; + } + + } + + /** + * The specified CRL does not exist. + */ + public static class CrlDoesNotExist extends XenAPIException { + public final String name; + + /** + * Create a new CrlDoesNotExist + * + * @param name + */ + public CrlDoesNotExist(String name) { + super("The specified CRL does not exist."); + this.name = name; + } + + } + + /** + * The request was asynchronously cancelled. + */ + public static class TaskCancelled extends XenAPIException { + public final String task; + + /** + * Create a new TaskCancelled + * + * @param task + */ + public TaskCancelled(String task) { + super("The request was asynchronously cancelled."); + this.task = task; + } + + } + + /** + * The VM crashed + */ + public static class VmCrashed extends XenAPIException { + public final String vm; + + /** + * Create a new VmCrashed + * + * @param vm + */ + public VmCrashed(String vm) { + super("The VM crashed"); + this.vm = vm; + } + + } + + /** + * The pool failed to enable external authentication. + */ + public static class PoolAuthEnableFailedDomainLookupFailed extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthEnableFailedDomainLookupFailed + * + * @param host + * @param message + */ + public PoolAuthEnableFailedDomainLookupFailed(String host, String message) { + super("The pool failed to enable external authentication."); + this.host = host; + this.message = message; + } + + } + + /** + * Host cannot rejoin pool because it should have fenced (it is not in the master's partition) + */ + public static class HaShouldBeFenced extends XenAPIException { + public final String host; + + /** + * Create a new HaShouldBeFenced + * + * @param host + */ + public HaShouldBeFenced(String host) { + super("Host cannot rejoin pool because it should have fenced (it is not in the master's partition)"); + this.host = host; + } + + } + + /** + * You attempted an operation on a VM that was judged to be unsafe by the server. This can happen if the VM would run on a CPU that has a potentially incompatible set of feature flags to those the VM requires. If you want to override this warning then use the 'force' option. + */ + public static class VmUnsafeBoot extends XenAPIException { + public final String vm; + + /** + * Create a new VmUnsafeBoot + * + * @param vm + */ + public VmUnsafeBoot(String vm) { + super("You attempted an operation on a VM that was judged to be unsafe by the server. This can happen if the VM would run on a CPU that has a potentially incompatible set of feature flags to those the VM requires. If you want to override this warning then use the 'force' option."); + this.vm = vm; + } + + } + + /** + * PIF has no IP configuration (mode curently set to 'none') + */ + public static class PifHasNoNetworkConfiguration extends XenAPIException { + + /** + * Create a new PifHasNoNetworkConfiguration + */ + public PifHasNoNetworkConfiguration() { + super("PIF has no IP configuration (mode curently set to 'none')"); + } + + } + + /** + * The request was rejected because the server is too busy. + */ + public static class TooBusy extends XenAPIException { + + /** + * Create a new TooBusy + */ + public TooBusy() { + super("The request was rejected because the server is too busy."); + } + + } + + /** + * You attempted to set a value that is not supported by this implementation. The fully-qualified field name and the value that you tried to set are returned. Also returned is a developer-only diagnostic reason. + */ + public static class ValueNotSupported extends XenAPIException { + public final String field; + public final String value; + public final String reason; + + /** + * Create a new ValueNotSupported + * + * @param field + * @param value + * @param reason + */ + public ValueNotSupported(String field, String value, String reason) { + super("You attempted to set a value that is not supported by this implementation. The fully-qualified field name and the value that you tried to set are returned. Also returned is a developer-only diagnostic reason."); + this.field = field; + this.value = value; + this.reason = reason; + } + + } + + /** + * You gave an invalid session reference. It may have been invalidated by a server restart, or timed out. You should get a new session handle, using one of the session.login_ calls. This error does not invalidate the current connection. The handle parameter echoes the bad value given. + */ + public static class SessionInvalid extends XenAPIException { + public final String handle; + + /** + * Create a new SessionInvalid + * + * @param handle + */ + public SessionInvalid(String handle) { + super("You gave an invalid session reference. It may have been invalidated by a server restart, or timed out. You should get a new session handle, using one of the session.login_ calls. This error does not invalidate the current connection. The handle parameter echoes the bad value given."); + this.handle = handle; + } + + } + + /** + * This operation cannot be performed because the referenced network is not properly shared. The network must either be entirely virtual or must be physically present via a currently_attached PIF on every host. + */ + public static class HaConstraintViolationNetworkNotShared extends XenAPIException { + public final String network; + + /** + * Create a new HaConstraintViolationNetworkNotShared + * + * @param network + */ + public HaConstraintViolationNetworkNotShared(String network) { + super("This operation cannot be performed because the referenced network is not properly shared. The network must either be entirely virtual or must be physically present via a currently_attached PIF on every host."); + this.network = network; + } + + } + + /** + * HA could not be enabled on the Pool because a liveset could not be formed: check storage and network heartbeat paths. + */ + public static class HaFailedToFormLiveset extends XenAPIException { + + /** + * Create a new HaFailedToFormLiveset + */ + public HaFailedToFormLiveset() { + super("HA could not be enabled on the Pool because a liveset could not be formed: check storage and network heartbeat paths."); + } + + } + + /** + * You cannot bond interfaces across different hosts. + */ + public static class PifCannotBondCrossHost extends XenAPIException { + + /** + * Create a new PifCannotBondCrossHost + */ + public PifCannotBondCrossHost() { + super("You cannot bond interfaces across different hosts."); + } + + } + + /** + * The event.from token could not be parsed. Valid values include: '', and a value returned from a previous event.from call. + */ + public static class EventFromTokenParseFailure extends XenAPIException { + public final String token; + + /** + * Create a new EventFromTokenParseFailure + * + * @param token + */ + public EventFromTokenParseFailure(String token) { + super("The event.from token could not be parsed. Valid values include: '', and a value returned from a previous event.from call."); + this.token = token; + } + + } + + /** + * The operation cannot be performed until the SR has been upgraded + */ + public static class SrRequiresUpgrade extends XenAPIException { + public final String SR; + + /** + * Create a new SrRequiresUpgrade + * + * @param SR + */ + public SrRequiresUpgrade(String SR) { + super("The operation cannot be performed until the SR has been upgraded"); + this.SR = SR; + } + + } + + /** + * The specified certificate does not exist. + */ + public static class CertificateDoesNotExist extends XenAPIException { + public final String name; + + /** + * Create a new CertificateDoesNotExist + * + * @param name + */ + public CertificateDoesNotExist(String name) { + super("The specified certificate does not exist."); + this.name = name; + } + + } + + /** + * This operation cannot be performed because it would invalidate VM failover planning such that the system would be unable to guarantee to restart protected VMs after a Host failure. + */ + public static class HaOperationWouldBreakFailoverPlan extends XenAPIException { + + /** + * Create a new HaOperationWouldBreakFailoverPlan + */ + public HaOperationWouldBreakFailoverPlan() { + super("This operation cannot be performed because it would invalidate VM failover planning such that the system would be unable to guarantee to restart protected VMs after a Host failure."); + } + + } + + /** + * The requested update could to be obtained from the master. + */ + public static class CannotFetchPatch extends XenAPIException { + public final String uuid; + + /** + * Create a new CannotFetchPatch + * + * @param uuid + */ + public CannotFetchPatch(String uuid) { + super("The requested update could to be obtained from the master."); + this.uuid = uuid; + } + + } + + /** + * The requested update could not be found. This can occur when you designate a new master or xe patch-clean. Please upload the update again + */ + public static class CannotFindPatch extends XenAPIException { + + /** + * Create a new CannotFindPatch + */ + public CannotFindPatch() { + super("The requested update could not be found. This can occur when you designate a new master or xe patch-clean. Please upload the update again"); + } + + } + + /** + * You attempted an operation which would have resulted in duplicate keys in the database. + */ + public static class DbUniquenessConstraintViolation extends XenAPIException { + public final String table; + public final String field; + public final String value; + + /** + * Create a new DbUniquenessConstraintViolation + * + * @param table + * @param field + * @param value + */ + public DbUniquenessConstraintViolation(String table, String field, String value) { + super("You attempted an operation which would have resulted in duplicate keys in the database."); + this.table = table; + this.field = field; + this.value = value; + } + + } + + /** + * You attempted to run a VM on a host which doesn't have a PIF on a Network needed by the VM. The VM has at least one VIF attached to the Network. + */ + public static class VmRequiresNetwork extends XenAPIException { + public final String vm; + public final String network; + + /** + * Create a new VmRequiresNetwork + * + * @param vm + * @param network + */ + public VmRequiresNetwork(String vm, String network) { + super("You attempted to run a VM on a host which doesn't have a PIF on a Network needed by the VM. The VM has at least one VIF attached to the Network."); + this.vm = vm; + this.network = network; + } + + } + + /** + * Operation could not be performed because the drive is not empty + */ + public static class VbdNotEmpty extends XenAPIException { + public final String vbd; + + /** + * Create a new VbdNotEmpty + * + * @param vbd + */ + public VbdNotEmpty(String vbd) { + super("Operation could not be performed because the drive is not empty"); + this.vbd = vbd; + } + + } + + /** + * Not enough host memory is available to perform this operation + */ + public static class HostNotEnoughFreeMemory extends XenAPIException { + public final String needed; + public final String available; + + /** + * Create a new HostNotEnoughFreeMemory + * + * @param needed + * @param available + */ + public HostNotEnoughFreeMemory(String needed, String available) { + super("Not enough host memory is available to perform this operation"); + this.needed = needed; + this.available = available; + } + + } + + /** + * An error occurred during the migration process. + */ + public static class VmMigrateFailed extends XenAPIException { + public final String vm; + public final String source; + public final String destination; + public final String msg; + + /** + * Create a new VmMigrateFailed + * + * @param vm + * @param source + * @param destination + * @param msg + */ + public VmMigrateFailed(String vm, String source, String destination, String msg) { + super("An error occurred during the migration process."); + this.vm = vm; + this.source = source; + this.destination = destination; + this.msg = msg; + } + + } + + /** + * The SR backend does not support the operation (check the SR's allowed operations) + */ + public static class SrOperationNotSupported extends XenAPIException { + public final String sr; + + /** + * Create a new SrOperationNotSupported + * + * @param sr + */ + public SrOperationNotSupported(String sr) { + super("The SR backend does not support the operation (check the SR's allowed operations)"); + this.sr = sr; + } + + } + + /** + * The operation could not be performed because the VBD was not connected to the VM. + */ + public static class DeviceNotAttached extends XenAPIException { + public final String VBD; + + /** + * Create a new DeviceNotAttached + * + * @param VBD + */ + public DeviceNotAttached(String VBD) { + super("The operation could not be performed because the VBD was not connected to the VM."); + this.VBD = VBD; + } + + } + + /** + * The specified host is disabled. + */ + public static class HostDisabled extends XenAPIException { + public final String host; + + /** + * Create a new HostDisabled + * + * @param host + */ + public HostDisabled(String host) { + super("The specified host is disabled."); + this.host = host; + } + + } + + /** + * You must use tar output to retrieve system status from an OEM host. + */ + public static class SystemStatusMustUseTarOnOem extends XenAPIException { + + /** + * Create a new SystemStatusMustUseTarOnOem + */ + public SystemStatusMustUseTarOnOem() { + super("You must use tar output to retrieve system status from an OEM host."); + } + + } + + /** + * An attempt to prepare VSS writers for the snapshot failed + */ + public static class XenVssReqErrorPreparingWriters extends XenAPIException { + public final String vm; + public final String errorCode; + + /** + * Create a new XenVssReqErrorPreparingWriters + * + * @param vm + * @param errorCode + */ + public XenVssReqErrorPreparingWriters(String vm, String errorCode) { + super("An attempt to prepare VSS writers for the snapshot failed"); + this.vm = vm; + this.errorCode = errorCode; + } + + } + + /** + * The host failed to enable external authentication. + */ + public static class AuthEnableFailed extends XenAPIException { + public final String message; + + /** + * Create a new AuthEnableFailed + * + * @param message + */ + public AuthEnableFailed(String message) { + super("The host failed to enable external authentication."); + this.message = message; + } + + } + + /** + * The host joining the pool cannot contain any shared storage. + */ + public static class JoiningHostCannotContainSharedSrs extends XenAPIException { + + /** + * Create a new JoiningHostCannotContainSharedSrs + */ + public JoiningHostCannotContainSharedSrs() { + super("The host joining the pool cannot contain any shared storage."); + } + + } + + /** + * You need at least 1 VCPU to start a VM + */ + public static class VmNoVcpus extends XenAPIException { + public final String vm; + + /** + * Create a new VmNoVcpus + * + * @param vm + */ + public VmNoVcpus(String vm) { + super("You need at least 1 VCPU to start a VM"); + this.vm = vm; + } + + } + + /** + * The uploaded patch file is invalid. See attached log for more details. + */ + public static class InvalidPatchWithLog extends XenAPIException { + public final String log; + + /** + * Create a new InvalidPatchWithLog + * + * @param log + */ + public InvalidPatchWithLog(String log) { + super("The uploaded patch file is invalid. See attached log for more details."); + this.log = log; + } + + } + + /** + * The SR operation cannot be performed because a device underlying the SR is in use by the host. + */ + public static class SrDeviceInUse extends XenAPIException { + + /** + * Create a new SrDeviceInUse + */ + public SrDeviceInUse() { + super("The SR operation cannot be performed because a device underlying the SR is in use by the host."); + } + + } + + /** + * The host CDROM drive does not contain a valid CD + */ + public static class HostCdDriveEmpty extends XenAPIException { + + /** + * Create a new HostCdDriveEmpty + */ + public HostCdDriveEmpty() { + super("The host CDROM drive does not contain a valid CD"); + } + + } + + /** + * The operation could not be performed while the host is still armed; it must be disarmed first + */ + public static class HaHostIsArmed extends XenAPIException { + public final String host; + + /** + * Create a new HaHostIsArmed + * + * @param host + */ + public HaHostIsArmed(String host) { + super("The operation could not be performed while the host is still armed; it must be disarmed first"); + this.host = host; + } + + } + + /** + * The server failed to parse your event subscription. Valid values include: *, class-name, class-name/object-reference. + */ + public static class EventSubscriptionParseFailure extends XenAPIException { + public final String subscription; + + /** + * Create a new EventSubscriptionParseFailure + * + * @param subscription + */ + public EventSubscriptionParseFailure(String subscription) { + super("The server failed to parse your event subscription. Valid values include: *, class-name, class-name/object-reference."); + this.subscription = subscription; + } + + } + + /** + * Your license has expired. Please contact your support representative. + */ + public static class LicenseExpired extends XenAPIException { + + /** + * Create a new LicenseExpired + */ + public LicenseExpired() { + super("Your license has expired. Please contact your support representative."); + } + + } + + /** + * The credentials given by the user are incorrect, so access has been denied, and you have not been issued a session handle. + */ + public static class SessionAuthenticationFailed extends XenAPIException { + + /** + * Create a new SessionAuthenticationFailed + */ + public SessionAuthenticationFailed() { + super("The credentials given by the user are incorrect, so access has been denied, and you have not been issued a session handle."); + } + + } + + /** + * You tried to create a VLAN on top of another VLAN - use the underlying physical PIF/bond instead + */ + public static class PifIsVlan extends XenAPIException { + public final String PIF; + + /** + * Create a new PifIsVlan + * + * @param PIF + */ + public PifIsVlan(String PIF) { + super("You tried to create a VLAN on top of another VLAN - use the underlying physical PIF/bond instead"); + this.PIF = PIF; + } + + } + + /** + * Archive more frequent than backup. + */ + public static class VmppArchiveMoreFrequentThanBackup extends XenAPIException { + + /** + * Create a new VmppArchiveMoreFrequentThanBackup + */ + public VmppArchiveMoreFrequentThanBackup() { + super("Archive more frequent than backup."); + } + + } + + /** + * There was a problem with the license daemon (v6d). Is it running? + */ + public static class V6dFailure extends XenAPIException { + + /** + * Create a new V6dFailure + */ + public V6dFailure() { + super("There was a problem with the license daemon (v6d). Is it running?"); + } + + } + + /** + * The host joining the pool cannot already be a master of another pool. + */ + public static class JoiningHostCannotBeMasterOfOtherHosts extends XenAPIException { + + /** + * Create a new JoiningHostCannotBeMasterOfOtherHosts + */ + public JoiningHostCannotBeMasterOfOtherHosts() { + super("The host joining the pool cannot already be a master of another pool."); + } + + } + + /** + * This host can not be forgotten because there are some user VMs still running + */ + public static class HostHasResidentVms extends XenAPIException { + public final String host; + + /** + * Create a new HostHasResidentVms + * + * @param host + */ + public HostHasResidentVms(String host) { + super("This host can not be forgotten because there are some user VMs still running"); + this.host = host; + } + + } + + /** + * An error occured while saving the memory image of the specified virtual machine + */ + public static class VmCheckpointSuspendFailed extends XenAPIException { + public final String vm; + + /** + * Create a new VmCheckpointSuspendFailed + * + * @param vm + */ + public VmCheckpointSuspendFailed(String vm) { + super("An error occured while saving the memory image of the specified virtual machine"); + this.vm = vm; + } + + } + + /** + * The operation you requested cannot be performed because the specified PIF is the management interface. + */ + public static class PifIsManagementInterface extends XenAPIException { + public final String PIF; + + /** + * Create a new PifIsManagementInterface + * + * @param PIF + */ + public PifIsManagementInterface(String PIF) { + super("The operation you requested cannot be performed because the specified PIF is the management interface."); + this.PIF = PIF; + } + + } + + /** + * The MAC address specified is not valid. + */ + public static class MacInvalid extends XenAPIException { + public final String MAC; + + /** + * Create a new MacInvalid + * + * @param MAC + */ + public MacInvalid(String MAC) { + super("The MAC address specified is not valid."); + this.MAC = MAC; + } + + } + + /** + * An attempt to start a new VSS snapshot failed + */ + public static class XenVssReqErrorStartSnapshotSetFailed extends XenAPIException { + public final String vm; + public final String errorCode; + + /** + * Create a new XenVssReqErrorStartSnapshotSetFailed + * + * @param vm + * @param errorCode + */ + public XenVssReqErrorStartSnapshotSetFailed(String vm, String errorCode) { + super("An attempt to start a new VSS snapshot failed"); + this.vm = vm; + this.errorCode = errorCode; + } + + } + + /** + * Operation could not be performed because the drive is empty + */ + public static class VbdIsEmpty extends XenAPIException { + public final String vbd; + + /** + * Create a new VbdIsEmpty + * + * @param vbd + */ + public VbdIsEmpty(String vbd) { + super("Operation could not be performed because the drive is empty"); + this.vbd = vbd; + } + + } + + /** + * The patch precheck stage failed: the server is of an incorrect version. + */ + public static class PatchPrecheckFailedWrongServerVersion extends XenAPIException { + public final String patch; + public final String foundVersion; + public final String requiredVersion; + + /** + * Create a new PatchPrecheckFailedWrongServerVersion + * + * @param patch + * @param foundVersion + * @param requiredVersion + */ + public PatchPrecheckFailedWrongServerVersion(String patch, String foundVersion, String requiredVersion) { + super("The patch precheck stage failed: the server is of an incorrect version."); + this.patch = patch; + this.foundVersion = foundVersion; + this.requiredVersion = requiredVersion; + } + + } + + /** + * This operation could not be performed because the state partition could not be found + */ + public static class CannotFindStatePartition extends XenAPIException { + + /** + * Create a new CannotFindStatePartition + */ + public CannotFindStatePartition() { + super("This operation could not be performed because the state partition could not be found"); + } + + } + + /** + * The WLB server rejected our configured authentication details. + */ + public static class WlbAuthenticationFailed extends XenAPIException { + + /** + * Create a new WlbAuthenticationFailed + */ + public WlbAuthenticationFailed() { + super("The WLB server rejected our configured authentication details."); + } + + } + + /** + * Unknown type of external authentication. + */ + public static class AuthUnknownType extends XenAPIException { + public final String type; + + /** + * Create a new AuthUnknownType + * + * @param type + */ + public AuthUnknownType(String type) { + super("Unknown type of external authentication."); + this.type = type; + } + + } + + /** + * This pool is not in emergency mode. + */ + public static class NotInEmergencyMode extends XenAPIException { + + /** + * Create a new NotInEmergencyMode + */ + public NotInEmergencyMode() { + super("This pool is not in emergency mode."); + } + + } + + /** + * The host failed to disable external authentication. + */ + public static class AuthDisableFailed extends XenAPIException { + public final String message; + + /** + * Create a new AuthDisableFailed + * + * @param message + */ + public AuthDisableFailed(String message) { + super("The host failed to disable external authentication."); + this.message = message; + } + + } + + /** + * You tried to create a PIF, but the network you tried to attach it to is already attached to some other PIF, and so the creation failed. + */ + public static class NetworkAlreadyConnected extends XenAPIException { + public final String network; + public final String connectedPIF; + + /** + * Create a new NetworkAlreadyConnected + * + * @param network + * @param connectedPIF + */ + public NetworkAlreadyConnected(String network, String connectedPIF) { + super("You tried to create a PIF, but the network you tried to attach it to is already attached to some other PIF, and so the creation failed."); + this.network = network; + this.connectedPIF = connectedPIF; + } + + } + + /** + * This operation cannot be performed because the specified VDI is of an incompatible type (eg: an HA statefile cannot be attached to a guest) + */ + public static class VdiIncompatibleType extends XenAPIException { + public final String vdi; + public final String type; + + /** + * Create a new VdiIncompatibleType + * + * @param vdi + * @param type + */ + public VdiIncompatibleType(String vdi, String type) { + super("This operation cannot be performed because the specified VDI is of an incompatible type (eg: an HA statefile cannot be attached to a guest)"); + this.vdi = vdi; + this.type = type; + } + + } + + /** + * The configured WLB server name failed to resolve in DNS. + */ + public static class WlbUnknownHost extends XenAPIException { + + /** + * Create a new WlbUnknownHost + */ + public WlbUnknownHost() { + super("The configured WLB server name failed to resolve in DNS."); + } + + } + + /** + * The VM could not be imported. + */ + public static class ImportError extends XenAPIException { + public final String msg; + + /** + * Create a new ImportError + * + * @param msg + */ + public ImportError(String msg) { + super("The VM could not be imported."); + this.msg = msg; + } + + } + + /** + * The SR could not be connected because the driver was not recognised. + */ + public static class SrUnknownDriver extends XenAPIException { + public final String driver; + + /** + * Create a new SrUnknownDriver + * + * @param driver + */ + public SrUnknownDriver(String driver) { + super("The SR could not be connected because the driver was not recognised."); + this.driver = driver; + } + + } + + /** + * The host failed to disable external authentication. + */ + public static class AuthDisableFailedWrongCredentials extends XenAPIException { + public final String message; + + /** + * Create a new AuthDisableFailedWrongCredentials + * + * @param message + */ + public AuthDisableFailedWrongCredentials(String message) { + super("The host failed to disable external authentication."); + this.message = message; + } + + } + + /** + * The VM unexpectedly halted + */ + public static class VmHalted extends XenAPIException { + public final String vm; + + /** + * Create a new VmHalted + * + * @param vm + */ + public VmHalted(String vm) { + super("The VM unexpectedly halted"); + this.vm = vm; + } + + } + + /** + * The use of this feature is restricted. + */ + public static class FeatureRestricted extends XenAPIException { + + /** + * Create a new FeatureRestricted + */ + public FeatureRestricted() { + super("The use of this feature is restricted."); + } + + } + + /** + * The VDI could not be opened for metadata recovery as it contains the current pool's metadata. + */ + public static class VdiContainsMetadataOfThisPool extends XenAPIException { + public final String vdi; + public final String pool; + + /** + * Create a new VdiContainsMetadataOfThisPool + * + * @param vdi + * @param pool + */ + public VdiContainsMetadataOfThisPool(String vdi, String pool) { + super("The VDI could not be opened for metadata recovery as it contains the current pool's metadata."); + this.vdi = vdi; + this.pool = pool; + } + + } + + /** + * The specified CRL name is invalid. + */ + public static class CrlNameInvalid extends XenAPIException { + public final String name; + + /** + * Create a new CrlNameInvalid + * + * @param name + */ + public CrlNameInvalid(String name) { + super("The specified CRL name is invalid."); + this.name = name; + } + + } + + /** + * This operation cannot be completed as the host power on mode is disabled. + */ + public static class HostPowerOnModeDisabled extends XenAPIException { + + /** + * Create a new HostPowerOnModeDisabled + */ + public HostPowerOnModeDisabled() { + super("This operation cannot be completed as the host power on mode is disabled."); + } + + } + + /** + * An activation key can only be applied when the edition is set to 'free'. + */ + public static class ActivationWhileNotFree extends XenAPIException { + + /** + * Create a new ActivationWhileNotFree + */ + public ActivationWhileNotFree() { + super("An activation key can only be applied when the edition is set to 'free'."); + } + + } + + /** + * There was a failure communicating with the plugin. + */ + public static class XenapiPluginFailure extends XenAPIException { + public final String status; + public final String stdout; + public final String stderr; + + /** + * Create a new XenapiPluginFailure + * + * @param status + * @param stdout + * @param stderr + */ + public XenapiPluginFailure(String status, String stdout, String stderr) { + super("There was a failure communicating with the plugin."); + this.status = status; + this.stdout = stdout; + this.stderr = stderr; + } + + } + + /** + * The MAC address specified still exists on this host. + */ + public static class MacStillExists extends XenAPIException { + public final String MAC; + + /** + * Create a new MacStillExists + * + * @param MAC + */ + public MacStillExists(String MAC) { + super("The MAC address specified still exists on this host."); + this.MAC = MAC; + } + + } + + /** + * This operation cannot be completed as the host is in use by (at least) the object of type and ref echoed below. + */ + public static class HostInUse extends XenAPIException { + public final String host; + public final String type; + public final String ref; + + /** + * Create a new HostInUse + * + * @param host + * @param type + * @param ref + */ + public HostInUse(String host, String type, String ref) { + super("This operation cannot be completed as the host is in use by (at least) the object of type and ref echoed below."); + this.host = host; + this.type = type; + this.ref = ref; + } + + } + + /** + * HA can only be enabled for 2 hosts or more. Note that 2 hosts requires a pre-configured quorum tiebreak script. + */ + public static class HaTooFewHosts extends XenAPIException { + + /** + * Create a new HaTooFewHosts + */ + public HaTooFewHosts() { + super("HA can only be enabled for 2 hosts or more. Note that 2 hosts requires a pre-configured quorum tiebreak script."); + } + + } + + /** + * The connection to the WLB server was reset. + */ + public static class WlbConnectionReset extends XenAPIException { + + /** + * Create a new WlbConnectionReset + */ + public WlbConnectionReset() { + super("The connection to the WLB server was reset."); + } + + } + + /** + * The pool failed to enable external authentication. + */ + public static class PoolAuthEnableFailedWrongCredentials extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthEnableFailedWrongCredentials + * + * @param host + * @param message + */ + public PoolAuthEnableFailedWrongCredentials(String host, String message) { + super("The pool failed to enable external authentication."); + this.host = host; + this.message = message; + } + + } + + /** + * The specified patch is applied and cannot be destroyed. + */ + public static class PatchIsApplied extends XenAPIException { + + /** + * Create a new PatchIsApplied + */ + public PatchIsApplied() { + super("The specified patch is applied and cannot be destroyed."); + } + + } + + /** + * The SR is still connected to a host via a PBD. It cannot be destroyed or forgotten. + */ + public static class SrHasPbd extends XenAPIException { + public final String sr; + + /** + * Create a new SrHasPbd + * + * @param sr + */ + public SrHasPbd(String sr) { + super("The SR is still connected to a host via a PBD. It cannot be destroyed or forgotten."); + this.sr = sr; + } + + } + + /** + * Some VMs belonging to the appliance threw an exception while carrying out the specified operation + */ + public static class OperationPartiallyFailed extends XenAPIException { + public final String operation; + + /** + * Create a new OperationPartiallyFailed + * + * @param operation + */ + public OperationPartiallyFailed(String operation) { + super("Some VMs belonging to the appliance threw an exception while carrying out the specified operation"); + this.operation = operation; + } + + } + + /** + * The WLB server rejected XenServer's request as malformed. + */ + public static class WlbMalformedRequest extends XenAPIException { + + /** + * Create a new WlbMalformedRequest + */ + public WlbMalformedRequest() { + super("The WLB server rejected XenServer's request as malformed."); + } + + } + + /** + * The host toolstack is still initialising. Please wait. + */ + public static class HostStillBooting extends XenAPIException { + + /** + * Create a new HostStillBooting + */ + public HostStillBooting() { + super("The host toolstack is still initialising. Please wait."); + } + + } + + /** + * You tried to destroy a system network: these cannot be destroyed. + */ + public static class CannotDestroySystemNetwork extends XenAPIException { + public final String network; + + /** + * Create a new CannotDestroySystemNetwork + * + * @param network + */ + public CannotDestroySystemNetwork(String network) { + super("You tried to destroy a system network: these cannot be destroyed."); + this.network = network; + } + + } + + /** + * The specified object no longer exists. + */ + public static class ObjectNolongerExists extends XenAPIException { + + /** + * Create a new ObjectNolongerExists + */ + public ObjectNolongerExists() { + super("The specified object no longer exists."); + } + + } + + /** + * This VDI was not mapped to a destination SR in VM.migrate_send operation + */ + public static class VdiNotInMap extends XenAPIException { + public final String vdi; + + /** + * Create a new VdiNotInMap + * + * @param vdi + */ + public VdiNotInMap(String vdi) { + super("This VDI was not mapped to a destination SR in VM.migrate_send operation"); + this.vdi = vdi; + } + + } + + /** + * The hosts in this pool are not homogeneous. + */ + public static class HostsNotHomogeneous extends XenAPIException { + public final String reason; + + /** + * Create a new HostsNotHomogeneous + * + * @param reason + */ + public HostsNotHomogeneous(String reason) { + super("The hosts in this pool are not homogeneous."); + this.reason = reason; + } + + } + + /** + * The host joining the pool must have the same product version as the pool master. + */ + public static class PoolJoiningHostMustHaveSameProductVersion extends XenAPIException { + + /** + * Create a new PoolJoiningHostMustHaveSameProductVersion + */ + public PoolJoiningHostMustHaveSameProductVersion() { + super("The host joining the pool must have the same product version as the pool master."); + } + + } + + /** + * You tried to create a PIF, but it already exists. + */ + public static class PifVlanExists extends XenAPIException { + public final String PIF; + + /** + * Create a new PifVlanExists + * + * @param PIF + */ + public PifVlanExists(String PIF) { + super("You tried to create a PIF, but it already exists."); + this.PIF = PIF; + } + + } + + /** + * The license for the edition you requested is not available. + */ + public static class LicenseCheckoutError extends XenAPIException { + public final String reason; + + /** + * Create a new LicenseCheckoutError + * + * @param reason + */ + public LicenseCheckoutError(String reason) { + super("The license for the edition you requested is not available."); + this.reason = reason; + } + + } + + /** + * The certificate library is corrupt or unreadable. + */ + public static class CertificateLibraryCorrupt extends XenAPIException { + + /** + * Create a new CertificateLibraryCorrupt + */ + public CertificateLibraryCorrupt() { + super("The certificate library is corrupt or unreadable."); + } + + } + + /** + * This operation cannot be performed because the system does not manage this VDI + */ + public static class VdiNotManaged extends XenAPIException { + public final String vdi; + + /** + * Create a new VdiNotManaged + * + * @param vdi + */ + public VdiNotManaged(String vdi) { + super("This operation cannot be performed because the system does not manage this VDI"); + this.vdi = vdi; + } + + } + + /** + * The edition you supplied is invalid. + */ + public static class InvalidEdition extends XenAPIException { + public final String edition; + + /** + * Create a new InvalidEdition + * + * @param edition + */ + public InvalidEdition(String edition) { + super("The edition you supplied is invalid."); + this.edition = edition; + } + + } + + /** + * The uploaded patch file already exists + */ + public static class PatchAlreadyExists extends XenAPIException { + public final String uuid; + + /** + * Create a new PatchAlreadyExists + * + * @param uuid + */ + public PatchAlreadyExists(String uuid) { + super("The uploaded patch file already exists"); + this.uuid = uuid; + } + + } + + /** + * There is not enough space to upload the update + */ + public static class OutOfSpace extends XenAPIException { + public final String location; + + /** + * Create a new OutOfSpace + * + * @param location + */ + public OutOfSpace(String location) { + super("There is not enough space to upload the update"); + this.location = location; + } + + } + + /** + * The VM could not be imported; the end of the file was reached prematurely. + */ + public static class ImportErrorPrematureEof extends XenAPIException { + + /** + * Create a new ImportErrorPrematureEof + */ + public ImportErrorPrematureEof() { + super("The VM could not be imported; the end of the file was reached prematurely."); + } + + } + + /** + * The given VM is not registered as a system domain. This operation can only be performed on a registered system domain. + */ + public static class NotSystemDomain extends XenAPIException { + public final String vm; + + /** + * Create a new NotSystemDomain + * + * @param vm + */ + public NotSystemDomain(String vm) { + super("The given VM is not registered as a system domain. This operation can only be performed on a registered system domain."); + this.vm = vm; + } + + } + + /** + * The specified VM has too little memory to be started. + */ + public static class VmMemorySizeTooLow extends XenAPIException { + public final String vm; + + /** + * Create a new VmMemorySizeTooLow + * + * @param vm + */ + public VmMemorySizeTooLow(String vm) { + super("The specified VM has too little memory to be started."); + this.vm = vm; + } + + } + + /** + * There is at least one VM assigned to this protection policy. + */ + public static class VmppHasVm extends XenAPIException { + + /** + * Create a new VmppHasVm + */ + public VmppHasVm() { + super("There is at least one VM assigned to this protection policy."); + } + + } + + /** + * This operation cannot be performed because the host is not disabled. Please disable the host and then try again. + */ + public static class HostNotDisabled extends XenAPIException { + + /** + * Create a new HostNotDisabled + */ + public HostNotDisabled() { + super("This operation cannot be performed because the host is not disabled. Please disable the host and then try again."); + } + + } + + /** + * The value specified is of the wrong type + */ + public static class FieldTypeError extends XenAPIException { + public final String field; + + /** + * Create a new FieldTypeError + * + * @param field + */ + public FieldTypeError(String field) { + super("The value specified is of the wrong type"); + this.field = field; + } + + } + + /** + * The management interface on a slave cannot be disabled because the slave would enter emergency mode. + */ + public static class SlaveRequiresManagementInterface extends XenAPIException { + + /** + * Create a new SlaveRequiresManagementInterface + */ + public SlaveRequiresManagementInterface() { + super("The management interface on a slave cannot be disabled because the slave would enter emergency mode."); + } + + } + + /** + * The operation attempted is not valid for a template VM + */ + public static class VmIsTemplate extends XenAPIException { + public final String vm; + + /** + * Create a new VmIsTemplate + * + * @param vm + */ + public VmIsTemplate(String vm) { + super("The operation attempted is not valid for a template VM"); + this.vm = vm; + } + + } + + /** + * This operation cannot be performed because the specified VM is protected by xHA + */ + public static class VmIsProtected extends XenAPIException { + public final String vm; + + /** + * Create a new VmIsProtected + * + * @param vm + */ + public VmIsProtected(String vm) { + super("This operation cannot be performed because the specified VM is protected by xHA"); + this.vm = vm; + } + + } + + /** + * The host joining the pool cannot have any running VMs. + */ + public static class JoiningHostCannotHaveRunningVms extends XenAPIException { + + /** + * Create a new JoiningHostCannotHaveRunningVms + */ + public JoiningHostCannotHaveRunningVms() { + super("The host joining the pool cannot have any running VMs."); + } + + } + + /** + * VM cannot be started because it requires a VDI which cannot be attached + */ + public static class VmRequiresVdi extends XenAPIException { + public final String vm; + public final String vdi; + + /** + * Create a new VmRequiresVdi + * + * @param vm + * @param vdi + */ + public VmRequiresVdi(String vm, String vdi) { + super("VM cannot be started because it requires a VDI which cannot be attached"); + this.vm = vm; + this.vdi = vdi; + } + + } + + /** + * Read/write CDs are not supported + */ + public static class VbdCdsMustBeReadonly extends XenAPIException { + + /** + * Create a new VbdCdsMustBeReadonly + */ + public VbdCdsMustBeReadonly() { + super("Read/write CDs are not supported"); + } + + } + + /** + * This license file is no longer accepted. Please upgrade to the new licensing system. + */ + public static class LicenseFileDeprecated extends XenAPIException { + + /** + * Create a new LicenseFileDeprecated + */ + public LicenseFileDeprecated() { + super("This license file is no longer accepted. Please upgrade to the new licensing system."); + } + + } + + /** + * An HA statefile could not be created, perhaps because no SR with the appropriate capability was found. + */ + public static class CannotCreateStateFile extends XenAPIException { + + /** + * Create a new CannotCreateStateFile + */ + public CannotCreateStateFile() { + super("An HA statefile could not be created, perhaps because no SR with the appropriate capability was found."); + } + + } + + /** + * The host joining the pool cannot have any VMs with active tasks. + */ + public static class JoiningHostCannotHaveVmsWithCurrentOperations extends XenAPIException { + + /** + * Create a new JoiningHostCannotHaveVmsWithCurrentOperations + */ + public JoiningHostCannotHaveVmsWithCurrentOperations() { + super("The host joining the pool cannot have any VMs with active tasks."); + } + + } + + /** + * You tried to call a method with the incorrect number of parameters. The fully-qualified method name that you used, and the number of received and expected parameters are returned. + */ + public static class MessageParameterCountMismatch extends XenAPIException { + public final String method; + public final String expected; + public final String received; + + /** + * Create a new MessageParameterCountMismatch + * + * @param method + * @param expected + * @param received + */ + public MessageParameterCountMismatch(String method, String expected, String received) { + super("You tried to call a method with the incorrect number of parameters. The fully-qualified method name that you used, and the number of received and expected parameters are returned."); + this.method = method; + this.expected = expected; + this.received = received; + } + + } + + /** + * External authentication in this pool is already enabled for at least one host. + */ + public static class PoolAuthAlreadyEnabled extends XenAPIException { + public final String host; + + /** + * Create a new PoolAuthAlreadyEnabled + * + * @param host + */ + public PoolAuthAlreadyEnabled(String host) { + super("External authentication in this pool is already enabled for at least one host."); + this.host = host; + } + + } + + /** + * The restore could not be performed because this backup has been created by a different (incompatible) product version + */ + public static class RestoreIncompatibleVersion extends XenAPIException { + + /** + * Create a new RestoreIncompatibleVersion + */ + public RestoreIncompatibleVersion() { + super("The restore could not be performed because this backup has been created by a different (incompatible) product version"); + } + + } + + /** + * The VM rejected the attempt to detach the device. + */ + public static class DeviceDetachRejected extends XenAPIException { + public final String type; + public final String ref; + public final String msg; + + /** + * Create a new DeviceDetachRejected + * + * @param type + * @param ref + * @param msg + */ + public DeviceDetachRejected(String type, String ref, String msg) { + super("The VM rejected the attempt to detach the device."); + this.type = type; + this.ref = ref; + this.msg = msg; + } + + } + + /** + * External authentication is disabled, unable to resolve subject name. + */ + public static class AuthIsDisabled extends XenAPIException { + + /** + * Create a new AuthIsDisabled + */ + public AuthIsDisabled() { + super("External authentication is disabled, unable to resolve subject name."); + } + + } + + /** + * The host joining the pool cannot have any running or suspended VMs. + */ + public static class JoiningHostCannotHaveRunningOrSuspendedVms extends XenAPIException { + + /** + * Create a new JoiningHostCannotHaveRunningOrSuspendedVms + */ + public JoiningHostCannotHaveRunningOrSuspendedVms() { + super("The host joining the pool cannot have any running or suspended VMs."); + } + + } + + /** + * The patch precheck stage failed: prerequisite patches are missing. + */ + public static class PatchPrecheckFailedPrerequisiteMissing extends XenAPIException { + public final String patch; + public final String prerequisitePatchUuidList; + + /** + * Create a new PatchPrecheckFailedPrerequisiteMissing + * + * @param patch + * @param prerequisitePatchUuidList + */ + public PatchPrecheckFailedPrerequisiteMissing(String patch, String prerequisitePatchUuidList) { + super("The patch precheck stage failed: prerequisite patches are missing."); + this.patch = patch; + this.prerequisitePatchUuidList = prerequisitePatchUuidList; + } + + } + + /** + * This operation could not be performed, because the VM has one or more PCI devices passed through. + */ + public static class VmHasPciAttached extends XenAPIException { + public final String vm; + + /** + * Create a new VmHasPciAttached + * + * @param vm + */ + public VmHasPciAttached(String vm) { + super("This operation could not be performed, because the VM has one or more PCI devices passed through."); + this.vm = vm; + } + + } + + /** + * The VDI mirroring cannot be performed + */ + public static class MirrorFailed extends XenAPIException { + public final String vdi; + + /** + * Create a new MirrorFailed + * + * @param vdi + */ + public MirrorFailed(String vdi) { + super("The VDI mirroring cannot be performed"); + this.vdi = vdi; + } + + } + + /** + * The WLB server reported that communication with XenServer timed out. + */ + public static class WlbXenserverTimeout extends XenAPIException { + + /** + * Create a new WlbXenserverTimeout + */ + public WlbXenserverTimeout() { + super("The WLB server reported that communication with XenServer timed out."); + } + + } + + /** + * The pool failed to disable the external authentication of at least one host. + */ + public static class PoolAuthDisableFailedWrongCredentials extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthDisableFailedWrongCredentials + * + * @param host + * @param message + */ + public PoolAuthDisableFailedWrongCredentials(String host, String message) { + super("The pool failed to disable the external authentication of at least one host."); + this.host = host; + this.message = message; + } + + } + + /** + * The quiesced-snapshot operation failed for an unexpected reason + */ + public static class VmSnapshotWithQuiesceFailed extends XenAPIException { + public final String vm; + + /** + * Create a new VmSnapshotWithQuiesceFailed + * + * @param vm + */ + public VmSnapshotWithQuiesceFailed(String vm) { + super("The quiesced-snapshot operation failed for an unexpected reason"); + this.vm = vm; + } + + } + + /** + * The specified certificate is corrupt or unreadable. + */ + public static class CertificateCorrupt extends XenAPIException { + public final String name; + + /** + * Create a new CertificateCorrupt + * + * @param name + */ + public CertificateCorrupt(String name) { + super("The specified certificate is corrupt or unreadable."); + this.name = name; + } + + } + + /** + * The WLB server reported an internal error. + */ + public static class WlbInternalError extends XenAPIException { + + /** + * Create a new WlbInternalError + */ + public WlbInternalError() { + super("The WLB server reported an internal error."); + } + + } + + /** + * The VM unexpectedly rebooted + */ + public static class VmRebooted extends XenAPIException { + public final String vm; + + /** + * Create a new VmRebooted + * + * @param vm + */ + public VmRebooted(String vm) { + super("The VM unexpectedly rebooted"); + this.vm = vm; + } + + } + + /** + * Cannot forward messages because the host cannot be contacted. The host may be switched off or there may be network connectivity problems. + */ + public static class CannotContactHost extends XenAPIException { + public final String host; + + /** + * Create a new CannotContactHost + * + * @param host + */ + public CannotContactHost(String host) { + super("Cannot forward messages because the host cannot be contacted. The host may be switched off or there may be network connectivity problems."); + this.host = host; + } + + } + + /** + * Could not find any volumes supported by the Citrix XenServer Vss Provider + */ + public static class XenVssReqErrorNoVolumesSupported extends XenAPIException { + public final String vm; + public final String errorCode; + + /** + * Create a new XenVssReqErrorNoVolumesSupported + * + * @param vm + * @param errorCode + */ + public XenVssReqErrorNoVolumesSupported(String vm, String errorCode) { + super("Could not find any volumes supported by the Citrix XenServer Vss Provider"); + this.vm = vm; + this.errorCode = errorCode; + } + + } + + /** + * The host is its own slave. Please use pool-emergency-transition-to-master or pool-emergency-reset-master. + */ + public static class HostItsOwnSlave extends XenAPIException { + + /** + * Create a new HostItsOwnSlave + */ + public HostItsOwnSlave() { + super("The host is its own slave. Please use pool-emergency-transition-to-master or pool-emergency-reset-master."); + } + + } + + /** + * This PIF is a bond slave and cannot have a VLAN on it. + */ + public static class CannotAddVlanToBondSlave extends XenAPIException { + public final String PIF; + + /** + * Create a new CannotAddVlanToBondSlave + * + * @param PIF + */ + public CannotAddVlanToBondSlave(String PIF) { + super("This PIF is a bond slave and cannot have a VLAN on it."); + this.PIF = PIF; + } + + } + + /** + * The operation could not be performed because a redo log is enabled on the Pool. + */ + public static class RedoLogIsEnabled extends XenAPIException { + + /** + * Create a new RedoLogIsEnabled + */ + public RedoLogIsEnabled() { + super("The operation could not be performed because a redo log is enabled on the Pool."); + } + + } + + /** + * You attempted an operation on a VM which requires PV drivers to be installed but the drivers were not detected. + */ + public static class VmMissingPvDrivers extends XenAPIException { + public final String vm; + + /** + * Create a new VmMissingPvDrivers + * + * @param vm + */ + public VmMissingPvDrivers(String vm) { + super("You attempted an operation on a VM which requires PV drivers to be installed but the drivers were not detected."); + this.vm = vm; + } + + } + + /** + * The specified certificate name is invalid. + */ + public static class CertificateNameInvalid extends XenAPIException { + public final String name; + + /** + * Create a new CertificateNameInvalid + * + * @param name + */ + public CertificateNameInvalid(String name) { + super("The specified certificate name is invalid."); + this.name = name; + } + + } + + /** + * The VM could not be imported because a required object could not be found. + */ + public static class ImportErrorFailedToFindObject extends XenAPIException { + public final String id; + + /** + * Create a new ImportErrorFailedToFindObject + * + * @param id + */ + public ImportErrorFailedToFindObject(String id) { + super("The VM could not be imported because a required object could not be found."); + this.id = id; + } + + } + + /** + * This operation cannot be performed because the specified VDI could not be found in the specified SR + */ + public static class VdiLocationMissing extends XenAPIException { + public final String sr; + public final String location; + + /** + * Create a new VdiLocationMissing + * + * @param sr + * @param location + */ + public VdiLocationMissing(String sr, String location) { + super("This operation cannot be performed because the specified VDI could not be found in the specified SR"); + this.sr = sr; + this.location = location; + } + + } + + /** + * The host failed to enable external authentication. + */ + public static class AuthEnableFailedPermissionDenied extends XenAPIException { + public final String message; + + /** + * Create a new AuthEnableFailedPermissionDenied + * + * @param message + */ + public AuthEnableFailedPermissionDenied(String message) { + super("The host failed to enable external authentication."); + this.message = message; + } + + } + + /** + * Operation cannot proceed while a VLAN exists on this interface. + */ + public static class PifVlanStillExists extends XenAPIException { + public final String PIF; + + /** + * Create a new PifVlanStillExists + * + * @param PIF + */ + public PifVlanStillExists(String PIF) { + super("Operation cannot proceed while a VLAN exists on this interface."); + this.PIF = PIF; + } + + } + + /** + * The given VMs failed to release memory when instructed to do so + */ + public static class VmsFailedToCooperate extends XenAPIException { + + /** + * Create a new VmsFailedToCooperate + */ + public VmsFailedToCooperate() { + super("The given VMs failed to release memory when instructed to do so"); + } + + } + + /** + * You reached the maximal number of concurrently migrating VMs. + */ + public static class TooManyStorageMigrates extends XenAPIException { + public final String number; + + /** + * Create a new TooManyStorageMigrates + * + * @param number + */ + public TooManyStorageMigrates(String number) { + super("You reached the maximal number of concurrently migrating VMs."); + this.number = number; + } + + } + + /** + * The network contains active VIFs and cannot be deleted. + */ + public static class NetworkContainsVif extends XenAPIException { + public final String vifs; + + /** + * Create a new NetworkContainsVif + * + * @param vifs + */ + public NetworkContainsVif(String vifs) { + super("The network contains active VIFs and cannot be deleted."); + this.vifs = vifs; + } + + } + + /** + * The value given is invalid + */ + public static class InvalidValue extends XenAPIException { + public final String field; + public final String value; + + /** + * Create a new InvalidValue + * + * @param field + * @param value + */ + public InvalidValue(String field, String value) { + super("The value given is invalid"); + this.field = field; + this.value = value; + } + + } + + /** + * The requested plugin could not be found. + */ + public static class XenapiMissingPlugin extends XenAPIException { + public final String name; + + /** + * Create a new XenapiMissingPlugin + * + * @param name + */ + public XenapiMissingPlugin(String name) { + super("The requested plugin could not be found."); + this.name = name; + } + + } + + /** + * The restore could not be performed because the host's current management interface is not in the backup. The interfaces mentioned in the backup are: + */ + public static class RestoreTargetMgmtIfNotInBackup extends XenAPIException { + + /** + * Create a new RestoreTargetMgmtIfNotInBackup + */ + public RestoreTargetMgmtIfNotInBackup() { + super("The restore could not be performed because the host's current management interface is not in the backup. The interfaces mentioned in the backup are:"); + } + + } + + /** + * You tried to create a VLAN or tunnel on top of a tunnel access PIF - use the underlying transport PIF instead. + */ + public static class IsTunnelAccessPif extends XenAPIException { + public final String PIF; + + /** + * Create a new IsTunnelAccessPif + * + * @param PIF + */ + public IsTunnelAccessPif(String PIF) { + super("You tried to create a VLAN or tunnel on top of a tunnel access PIF - use the underlying transport PIF instead."); + this.PIF = PIF; + } + + } + + /** + * There was an error connecting to the host while joining it in the pool. + */ + public static class JoiningHostConnectionFailed extends XenAPIException { + + /** + * Create a new JoiningHostConnectionFailed + */ + public JoiningHostConnectionFailed() { + super("There was an error connecting to the host while joining it in the pool."); + } + + } + + /** + * Subject cannot be resolved by the external directory service. + */ + public static class SubjectCannotBeResolved extends XenAPIException { + + /** + * Create a new SubjectCannotBeResolved + */ + public SubjectCannotBeResolved() { + super("Subject cannot be resolved by the external directory service."); + } + + } + + /** + * Some volumes to be snapshot could not be added to the VSS snapshot set + */ + public static class XenVssReqErrorAddingVolumeToSnapsetFailed extends XenAPIException { + public final String vm; + public final String errorCode; + + /** + * Create a new XenVssReqErrorAddingVolumeToSnapsetFailed + * + * @param vm + * @param errorCode + */ + public XenVssReqErrorAddingVolumeToSnapsetFailed(String vm, String errorCode) { + super("Some volumes to be snapshot could not be added to the VSS snapshot set"); + this.vm = vm; + this.errorCode = errorCode; + } + + } + + /** + * The provision call failed because it ran out of space. + */ + public static class ProvisionFailedOutOfSpace extends XenAPIException { + + /** + * Create a new ProvisionFailedOutOfSpace + */ + public ProvisionFailedOutOfSpace() { + super("The provision call failed because it ran out of space."); + } + + } + + /** + * You attempted to migrate a VDI which is not attached to a runnning VM. + */ + public static class VdiNeedsVmForMigrate extends XenAPIException { + public final String vdi; + + /** + * Create a new VdiNeedsVmForMigrate + * + * @param vdi + */ + public VdiNeedsVmForMigrate(String vdi) { + super("You attempted to migrate a VDI which is not attached to a runnning VM."); + this.vdi = vdi; + } + + } + + /** + * An error occurred while attempting to import a database from a metadata VDI + */ + public static class CouldNotImportDatabase extends XenAPIException { + public final String reason; + + /** + * Create a new CouldNotImportDatabase + * + * @param reason + */ + public CouldNotImportDatabase(String reason) { + super("An error occurred while attempting to import a database from a metadata VDI"); + this.reason = reason; + } + + } + + /** + * This operation can only be performed on CD VDIs (iso files or CDROM drives) + */ + public static class VdiIsNotIso extends XenAPIException { + public final String vdi; + public final String type; + + /** + * Create a new VdiIsNotIso + * + * @param vdi + * @param type + */ + public VdiIsNotIso(String vdi, String type) { + super("This operation can only be performed on CD VDIs (iso files or CDROM drives)"); + this.vdi = vdi; + this.type = type; + } + + } + + /** + * You tried to call a method that does not exist. The method name that you used is echoed. + */ + public static class MessageMethodUnknown extends XenAPIException { + public final String method; + + /** + * Create a new MessageMethodUnknown + * + * @param method + */ + public MessageMethodUnknown(String method) { + super("You tried to call a method that does not exist. The method name that you used is echoed."); + this.method = method; + } + + } + + /** + * You cannot delete the specified default template. + */ + public static class VmCannotDeleteDefaultTemplate extends XenAPIException { + public final String vm; + + /** + * Create a new VmCannotDeleteDefaultTemplate + * + * @param vm + */ + public VmCannotDeleteDefaultTemplate(String vm) { + super("You cannot delete the specified default template."); + this.vm = vm; + } + + } + + /** + * Role cannot be found. + */ + public static class RoleNotFound extends XenAPIException { + + /** + * Create a new RoleNotFound + */ + public RoleNotFound() { + super("Role cannot be found."); + } + + } + + /** + * This command is not allowed on the OEM edition. + */ + public static class NotAllowedOnOemEdition extends XenAPIException { + public final String command; + + /** + * Create a new NotAllowedOnOemEdition + * + * @param command + */ + public NotAllowedOnOemEdition(String command) { + super("This command is not allowed on the OEM edition."); + this.command = command; + } + + } + + /** + * The restore could not be performed because the restore script failed. Is the file corrupt? + */ + public static class RestoreScriptFailed extends XenAPIException { + public final String log; + + /** + * Create a new RestoreScriptFailed + * + * @param log + */ + public RestoreScriptFailed(String log) { + super("The restore could not be performed because the restore script failed. Is the file corrupt?"); + this.log = log; + } + + } + + /** + * The server failed to handle your request, due to an internal error. The given message may give details useful for debugging the problem. + */ + public static class InternalError extends XenAPIException { + public final String message; + + /** + * Create a new InternalError + * + * @param message + */ + public InternalError(String message) { + super("The server failed to handle your request, due to an internal error. The given message may give details useful for debugging the problem."); + this.message = message; + } + + } + + /** + * XHA cannot be enabled because this host's license does not allow it + */ + public static class LicenseDoesNotSupportXha extends XenAPIException { + + /** + * Create a new LicenseDoesNotSupportXha + */ + public LicenseDoesNotSupportXha() { + super("XHA cannot be enabled because this host's license does not allow it"); + } + + } + + /** + * The primary address types are not compatible + */ + public static class PifIncompatiblePrimaryAddressType extends XenAPIException { + + /** + * Create a new PifIncompatiblePrimaryAddressType + */ + public PifIncompatiblePrimaryAddressType() { + super("The primary address types are not compatible"); + } + + } + + /** + * The device is not currently attached + */ + public static class DeviceAlreadyDetached extends XenAPIException { + public final String device; + + /** + * Create a new DeviceAlreadyDetached + * + * @param device + */ + public DeviceAlreadyDetached(String device) { + super("The device is not currently attached"); + this.device = device; + } + + } + + /** + * The host failed to enable external authentication. + */ + public static class AuthEnableFailedUnavailable extends XenAPIException { + public final String message; + + /** + * Create a new AuthEnableFailedUnavailable + * + * @param message + */ + public AuthEnableFailedUnavailable(String message) { + super("The host failed to enable external authentication."); + this.message = message; + } + + } + + /** + * Media could not be ejected because it is not removable + */ + public static class VbdNotRemovableMedia extends XenAPIException { + public final String vbd; + + /** + * Create a new VbdNotRemovableMedia + * + * @param vbd + */ + public VbdNotRemovableMedia(String vbd) { + super("Media could not be ejected because it is not removable"); + this.vbd = vbd; + } + + } + + /** + * A VDI with the specified location already exists within the SR + */ + public static class LocationNotUnique extends XenAPIException { + public final String SR; + public final String location; + + /** + * Create a new LocationNotUnique + * + * @param SR + * @param location + */ + public LocationNotUnique(String SR, String location) { + super("A VDI with the specified location already exists within the SR"); + this.SR = SR; + this.location = location; + } + + } + + /** + * The function is not implemented + */ + public static class NotImplemented extends XenAPIException { + public final String function; + + /** + * Create a new NotImplemented + * + * @param function + */ + public NotImplemented(String function) { + super("The function is not implemented"); + this.function = function; + } + + } + + /** + * Cannot plug VIF + */ + public static class CannotPlugVif extends XenAPIException { + public final String VIF; + + /** + * Create a new CannotPlugVif + * + * @param VIF + */ + public CannotPlugVif(String VIF) { + super("Cannot plug VIF"); + this.VIF = VIF; + } + + } + + /** + * Only the local superuser can execute this operation + */ + public static class UserIsNotLocalSuperuser extends XenAPIException { + public final String msg; + + /** + * Create a new UserIsNotLocalSuperuser + * + * @param msg + */ + public UserIsNotLocalSuperuser(String msg) { + super("Only the local superuser can execute this operation"); + this.msg = msg; + } + + } + + /** + * The backup could not be performed because the backup script failed. + */ + public static class BackupScriptFailed extends XenAPIException { + public final String log; + + /** + * Create a new BackupScriptFailed + * + * @param log + */ + public BackupScriptFailed(String log) { + super("The backup could not be performed because the backup script failed."); + this.log = log; + } + + } + + /** + * The VM could not be imported because the XVA file is invalid: an unexpected file was encountered. + */ + public static class ImportErrorUnexpectedFile extends XenAPIException { + public final String filenameExpected; + public final String filenameFound; + + /** + * Create a new ImportErrorUnexpectedFile + * + * @param filenameExpected + * @param filenameFound + */ + public ImportErrorUnexpectedFile(String filenameExpected, String filenameFound) { + super("The VM could not be imported because the XVA file is invalid: an unexpected file was encountered."); + this.filenameExpected = filenameExpected; + this.filenameFound = filenameFound; + } + + } + + /** + * External authentication for this host is already enabled. + */ + public static class AuthAlreadyEnabled extends XenAPIException { + public final String currentAuthType; + public final String currentServiceName; + + /** + * Create a new AuthAlreadyEnabled + * + * @param currentAuthType + * @param currentServiceName + */ + public AuthAlreadyEnabled(String currentAuthType, String currentServiceName) { + super("External authentication for this host is already enabled."); + this.currentAuthType = currentAuthType; + this.currentServiceName = currentServiceName; + } + + } + + /** + * You attempted an operation that was not allowed. + */ + public static class OperationNotAllowed extends XenAPIException { + public final String reason; + + /** + * Create a new OperationNotAllowed + * + * @param reason + */ + public OperationNotAllowed(String reason) { + super("You attempted an operation that was not allowed."); + this.reason = reason; + } + + } + + /** + * Cannot find a plan for placement of VMs as there are no other hosts available. + */ + public static class HaNoPlan extends XenAPIException { + + /** + * Create a new HaNoPlan + */ + public HaNoPlan() { + super("Cannot find a plan for placement of VMs as there are no other hosts available."); + } + + } + + /** + * Some events have been lost from the queue and cannot be retrieved. + */ + public static class EventsLost extends XenAPIException { + + /** + * Create a new EventsLost + */ + public EventsLost() { + super("Some events have been lost from the queue and cannot be retrieved."); + } + + } + + /** + * There was an SR backend failure. + */ + public static class SrBackendFailure extends XenAPIException { + public final String status; + public final String stdout; + public final String stderr; + + /** + * Create a new SrBackendFailure + * + * @param status + * @param stdout + * @param stderr + */ + public SrBackendFailure(String status, String stdout, String stderr) { + super("There was an SR backend failure."); + this.status = status; + this.stdout = stdout; + this.stderr = stderr; + } + + } + + /** + * A timeout happened while attempting to detach a device from a VM. + */ + public static class DeviceDetachTimeout extends XenAPIException { + public final String type; + public final String ref; + + /** + * Create a new DeviceDetachTimeout + * + * @param type + * @param ref + */ + public DeviceDetachTimeout(String type, String ref) { + super("A timeout happened while attempting to detach a device from a VM."); + this.type = type; + this.ref = ref; + } + + } + + /** + * The specified VM has a duplicate VBD device and cannot be started. + */ + public static class VmDuplicateVbdDevice extends XenAPIException { + public final String vm; + public final String vbd; + public final String device; + + /** + * Create a new VmDuplicateVbdDevice + * + * @param vm + * @param vbd + * @param device + */ + public VmDuplicateVbdDevice(String vm, String vbd, String device) { + super("The specified VM has a duplicate VBD device and cannot be started."); + this.vm = vm; + this.vbd = vbd; + this.device = device; + } + + } + + /** + * This PIF is a bond slave and cannot be plugged. + */ + public static class CannotPlugBondSlave extends XenAPIException { + public final String PIF; + + /** + * Create a new CannotPlugBondSlave + * + * @param PIF + */ + public CannotPlugBondSlave(String PIF) { + super("This PIF is a bond slave and cannot be plugged."); + this.PIF = PIF; + } + + } + + /** + * The VM cannot be imported unforced because it is either the same version or an older version of an existing VM. + */ + public static class VmToImportIsNotNewerVersion extends XenAPIException { + public final String vm; + public final String existingVersion; + public final String versionToImport; + + /** + * Create a new VmToImportIsNotNewerVersion + * + * @param vm + * @param existingVersion + * @param versionToImport + */ + public VmToImportIsNotNewerVersion(String vm, String existingVersion, String versionToImport) { + super("The VM cannot be imported unforced because it is either the same version or an older version of an existing VM."); + this.vm = vm; + this.existingVersion = existingVersion; + this.versionToImport = versionToImport; + } + + } + + /** + * The specified CRL is corrupt or unreadable. + */ + public static class CrlCorrupt extends XenAPIException { + public final String name; + + /** + * Create a new CrlCorrupt + * + * @param name + */ + public CrlCorrupt(String name) { + super("The specified CRL is corrupt or unreadable."); + this.name = name; + } + + } + + /** + * You attempted an operation on a VM which requires a more recent version of the PV drivers. Please upgrade your PV drivers. + */ + public static class VmOldPvDrivers extends XenAPIException { + public final String vm; + public final String major; + public final String minor; + + /** + * Create a new VmOldPvDrivers + * + * @param vm + * @param major + * @param minor + */ + public VmOldPvDrivers(String vm, String major, String minor) { + super("You attempted an operation on a VM which requires a more recent version of the PV drivers. Please upgrade your PV drivers."); + this.vm = vm; + this.major = major; + this.minor = minor; + } + + } + + /** + * The operation you requested cannot be performed because the specified PIF does not allow unplug. + */ + public static class PifDoesNotAllowUnplug extends XenAPIException { + public final String PIF; + + /** + * Create a new PifDoesNotAllowUnplug + * + * @param PIF + */ + public PifDoesNotAllowUnplug(String PIF) { + super("The operation you requested cannot be performed because the specified PIF does not allow unplug."); + this.PIF = PIF; + } + + } + + /** + * The system rejected the password change request; perhaps the new password was too short? + */ + public static class ChangePasswordRejected extends XenAPIException { + public final String msg; + + /** + * Create a new ChangePasswordRejected + * + * @param msg + */ + public ChangePasswordRejected(String msg) { + super("The system rejected the password change request; perhaps the new password was too short?"); + this.msg = msg; + } + + } + + /** + * Another operation involving the object is currently in progress + */ + public static class OtherOperationInProgress extends XenAPIException { + public final String clazz; + public final String object; + + /** + * Create a new OtherOperationInProgress + * + * @param clazz + * @param object + */ + public OtherOperationInProgress(String clazz, String object) { + super("Another operation involving the object is currently in progress"); + this.clazz = clazz; + this.object = object; + } + + } + + /** + * Initialization of the VSS requestor failed + */ + public static class XenVssReqErrorInitFailed extends XenAPIException { + public final String vm; + public final String errorCode; + + /** + * Create a new XenVssReqErrorInitFailed + * + * @param vm + * @param errorCode + */ + public XenVssReqErrorInitFailed(String vm, String errorCode) { + super("Initialization of the VSS requestor failed"); + this.vm = vm; + this.errorCode = errorCode; + } + + } + + /** + * The CPU does not support masking of features. + */ + public static class CpuFeatureMaskingNotSupported extends XenAPIException { + public final String details; + + /** + * Create a new CpuFeatureMaskingNotSupported + * + * @param details + */ + public CpuFeatureMaskingNotSupported(String details) { + super("The CPU does not support masking of features."); + this.details = details; + } + + } + + /** + * The specified VM is not currently resident on the specified host. + */ + public static class VmNotResidentHere extends XenAPIException { + public final String vm; + public final String host; + + /** + * Create a new VmNotResidentHere + * + * @param vm + * @param host + */ + public VmNotResidentHere(String vm, String host) { + super("The specified VM is not currently resident on the specified host."); + this.vm = vm; + this.host = host; + } + + } + + /** + * You attempted an operation which involves a host which could not be contacted. + */ + public static class HostOffline extends XenAPIException { + public final String host; + + /** + * Create a new HostOffline + * + * @param host + */ + public HostOffline(String host) { + super("You attempted an operation which involves a host which could not be contacted."); + this.host = host; + } + + } + + /** + * The pool failed to disable the external authentication of at least one host. + */ + public static class PoolAuthDisableFailed extends XenAPIException { + public final String host; + public final String message; + + /** + * Create a new PoolAuthDisableFailed + * + * @param host + * @param message + */ + public PoolAuthDisableFailed(String host, String message) { + super("The pool failed to disable the external authentication of at least one host."); + this.host = host; + this.message = message; + } + + } + + /** + * The host failed to acquire an IP address on its management interface and therefore cannot contact the master. + */ + public static class HostHasNoManagementIp extends XenAPIException { + + /** + * Create a new HostHasNoManagementIp + */ + public HostHasNoManagementIp() { + super("The host failed to acquire an IP address on its management interface and therefore cannot contact the master."); + } + + } + + /** + * The tunnel transport PIF has no IP configuration set. + */ + public static class TransportPifNotConfigured extends XenAPIException { + public final String PIF; + + /** + * Create a new TransportPifNotConfigured + * + * @param PIF + */ + public TransportPifNotConfigured(String PIF) { + super("The tunnel transport PIF has no IP configuration set."); + this.PIF = PIF; + } + + } + + /** + * The operation could not be performed because HA is enabled on the Pool + */ + public static class HaIsEnabled extends XenAPIException { + + /** + * Create a new HaIsEnabled + */ + public HaIsEnabled() { + super("The operation could not be performed because HA is enabled on the Pool"); + } + + } + + /** + * An error occured while reverting the specified virtual machine to the specified snapshot + */ + public static class VmRevertFailed extends XenAPIException { + public final String vm; + public final String snapshot; + + /** + * Create a new VmRevertFailed + * + * @param vm + * @param snapshot + */ + public VmRevertFailed(String vm, String snapshot) { + super("An error occured while reverting the specified virtual machine to the specified snapshot"); + this.vm = vm; + this.snapshot = snapshot; + } + + } + + /** + * The host name is invalid. + */ + public static class HostNameInvalid extends XenAPIException { + public final String reason; + + /** + * Create a new HostNameInvalid + * + * @param reason + */ + public HostNameInvalid(String reason) { + super("The host name is invalid."); + this.reason = reason; + } + + } + + /** + * The operation could not be performed because a domain still exists for the specified VM. + */ + public static class DomainExists extends XenAPIException { + public final String vm; + public final String domid; + + /** + * Create a new DomainExists + * + * @param vm + * @param domid + */ + public DomainExists(String vm, String domid) { + super("The operation could not be performed because a domain still exists for the specified VM."); + this.vm = vm; + this.domid = domid; + } + + } + + /** + * This host cannot join the pool because the pool has HA enabled but this host has HA disabled. + */ + public static class HaPoolIsEnabledButHostIsDisabled extends XenAPIException { + + /** + * Create a new HaPoolIsEnabledButHostIsDisabled + */ + public HaPoolIsEnabledButHostIsDisabled() { + super("This host cannot join the pool because the pool has HA enabled but this host has HA disabled."); + } + + } + + /** + * This message has been deprecated. + */ + public static class MessageDeprecated extends XenAPIException { + + /** + * Create a new MessageDeprecated + */ + public MessageDeprecated() { + super("This message has been deprecated."); + } + + } + + /** + * This operation cannot be performed because the referenced SR is not properly shared. The SR must both be marked as shared and a currently_attached PBD must exist for each host. + */ + public static class HaConstraintViolationSrNotShared extends XenAPIException { + public final String SR; + + /** + * Create a new HaConstraintViolationSrNotShared + * + * @param SR + */ + public HaConstraintViolationSrNotShared(String SR) { + super("This operation cannot be performed because the referenced SR is not properly shared. The SR must both be marked as shared and a currently_attached PBD must exist for each host."); + this.SR = SR; + } + + } + + /** + * Cannot import VM using chunked encoding. + */ + public static class ImportErrorCannotHandleChunked extends XenAPIException { + + /** + * Create a new ImportErrorCannotHandleChunked + */ + public ImportErrorCannotHandleChunked() { + super("Cannot import VM using chunked encoding."); + } + + } + + /** + * You attempted to start a VM that's attached to more than one VDI with a timeoffset marked as reset-on-boot. + */ + public static class VmAttachedToMoreThanOneVdiWithTimeoffsetMarkedAsResetOnBoot extends XenAPIException { + public final String vm; + + /** + * Create a new VmAttachedToMoreThanOneVdiWithTimeoffsetMarkedAsResetOnBoot + * + * @param vm + */ + public VmAttachedToMoreThanOneVdiWithTimeoffsetMarkedAsResetOnBoot(String vm) { + super("You attempted to start a VM that's attached to more than one VDI with a timeoffset marked as reset-on-boot."); + this.vm = vm; + } + + } + + /** + * This operation is not supported during an upgrade. + */ + public static class NotSupportedDuringUpgrade extends XenAPIException { + + /** + * Create a new NotSupportedDuringUpgrade + */ + public NotSupportedDuringUpgrade() { + super("This operation is not supported during an upgrade."); + } + + } + + /** + * An unknown error occurred while attempting to configure an interface. + */ + public static class PifConfigurationError extends XenAPIException { + public final String PIF; + public final String msg; + + /** + * Create a new PifConfigurationError + * + * @param PIF + * @param msg + */ + public PifConfigurationError(String PIF, String msg) { + super("An unknown error occurred while attempting to configure an interface."); + this.PIF = PIF; + this.msg = msg; + } + + } + + /** + * The specified interface cannot be used because it has no IP address + */ + public static class InterfaceHasNoIp extends XenAPIException { + public final String iface; + + /** + * Create a new InterfaceHasNoIp + * + * @param iface + */ + public InterfaceHasNoIp(String iface) { + super("The specified interface cannot be used because it has no IP address"); + this.iface = iface; + } + + } + + /** + * The hosts in this pool are not compatible. + */ + public static class HostsNotCompatible extends XenAPIException { + + /** + * Create a new HostsNotCompatible + */ + public HostsNotCompatible() { + super("The hosts in this pool are not compatible."); + } + + } + + /** + * The host failed to enable external authentication. + */ + public static class AuthEnableFailedWrongCredentials extends XenAPIException { + public final String message; + + /** + * Create a new AuthEnableFailedWrongCredentials + * + * @param message + */ + public AuthEnableFailedWrongCredentials(String message) { + super("The host failed to enable external authentication."); + this.message = message; + } + + } + + + public static String toString(Object object) { + if (object == null) { + return null; + } + return (String) object; + } + + public static Long toLong(Object object) { + if (object == null) { + return null; + } + return Long.valueOf((String) object); + } + + public static Double toDouble(Object object) { + if (object == null) { + return null; + } + return (Double) object; + } + + public static Boolean toBoolean(Object object) { + if (object == null) { + return null; + } + return (Boolean) object; + } + + public static Date toDate(Object object) { + if (object == null) { + return null; + } + try { + return (Date) object; + } catch (ClassCastException e){ + //Occasionally the date comes back as an ocaml float rather than + //in the xmlrpc format! Catch this and convert. + return (new Date((long) (1000*Double.parseDouble((String) object)))); + } + } + + public static Types.XenAPIObjects toXenAPIObjects(Object object) { + if (object == null) { + return null; + } + try { + return XenAPIObjects.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return XenAPIObjects.UNRECOGNIZED; + } + } + + public static Types.AfterApplyGuidance toAfterApplyGuidance(Object object) { + if (object == null) { + return null; + } + try { + return AfterApplyGuidance.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return AfterApplyGuidance.UNRECOGNIZED; + } + } + + public static Types.BondMode toBondMode(Object object) { + if (object == null) { + return null; + } + try { + return BondMode.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return BondMode.UNRECOGNIZED; + } + } + + public static Types.Cls toCls(Object object) { + if (object == null) { + return null; + } + try { + return Cls.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return Cls.UNRECOGNIZED; + } + } + + public static Types.ConsoleProtocol toConsoleProtocol(Object object) { + if (object == null) { + return null; + } + try { + return ConsoleProtocol.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return ConsoleProtocol.UNRECOGNIZED; + } + } + + public static Types.EventOperation toEventOperation(Object object) { + if (object == null) { + return null; + } + try { + return EventOperation.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return EventOperation.UNRECOGNIZED; + } + } + + public static Types.HostAllowedOperations toHostAllowedOperations(Object object) { + if (object == null) { + return null; + } + try { + return HostAllowedOperations.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return HostAllowedOperations.UNRECOGNIZED; + } + } + + public static Types.IpConfigurationMode toIpConfigurationMode(Object object) { + if (object == null) { + return null; + } + try { + return IpConfigurationMode.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return IpConfigurationMode.UNRECOGNIZED; + } + } + + public static Types.Ipv6ConfigurationMode toIpv6ConfigurationMode(Object object) { + if (object == null) { + return null; + } + try { + return Ipv6ConfigurationMode.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return Ipv6ConfigurationMode.UNRECOGNIZED; + } + } + + public static Types.NetworkDefaultLockingMode toNetworkDefaultLockingMode(Object object) { + if (object == null) { + return null; + } + try { + return NetworkDefaultLockingMode.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return NetworkDefaultLockingMode.UNRECOGNIZED; + } + } + + public static Types.NetworkOperations toNetworkOperations(Object object) { + if (object == null) { + return null; + } + try { + return NetworkOperations.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return NetworkOperations.UNRECOGNIZED; + } + } + + public static Types.OnBoot toOnBoot(Object object) { + if (object == null) { + return null; + } + try { + return OnBoot.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return OnBoot.UNRECOGNIZED; + } + } + + public static Types.OnCrashBehaviour toOnCrashBehaviour(Object object) { + if (object == null) { + return null; + } + try { + return OnCrashBehaviour.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return OnCrashBehaviour.UNRECOGNIZED; + } + } + + public static Types.OnNormalExit toOnNormalExit(Object object) { + if (object == null) { + return null; + } + try { + return OnNormalExit.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return OnNormalExit.UNRECOGNIZED; + } + } + + public static Types.PrimaryAddressType toPrimaryAddressType(Object object) { + if (object == null) { + return null; + } + try { + return PrimaryAddressType.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return PrimaryAddressType.UNRECOGNIZED; + } + } + + public static Types.StorageOperations toStorageOperations(Object object) { + if (object == null) { + return null; + } + try { + return StorageOperations.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return StorageOperations.UNRECOGNIZED; + } + } + + public static Types.TaskAllowedOperations toTaskAllowedOperations(Object object) { + if (object == null) { + return null; + } + try { + return TaskAllowedOperations.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return TaskAllowedOperations.UNRECOGNIZED; + } + } + + public static Types.TaskStatusType toTaskStatusType(Object object) { + if (object == null) { + return null; + } + try { + return TaskStatusType.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return TaskStatusType.UNRECOGNIZED; + } + } + + public static Types.VbdMode toVbdMode(Object object) { + if (object == null) { + return null; + } + try { + return VbdMode.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VbdMode.UNRECOGNIZED; + } + } + + public static Types.VbdOperations toVbdOperations(Object object) { + if (object == null) { + return null; + } + try { + return VbdOperations.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VbdOperations.UNRECOGNIZED; + } + } + + public static Types.VbdType toVbdType(Object object) { + if (object == null) { + return null; + } + try { + return VbdType.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VbdType.UNRECOGNIZED; + } + } + + public static Types.VdiOperations toVdiOperations(Object object) { + if (object == null) { + return null; + } + try { + return VdiOperations.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VdiOperations.UNRECOGNIZED; + } + } + + public static Types.VdiType toVdiType(Object object) { + if (object == null) { + return null; + } + try { + return VdiType.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VdiType.UNRECOGNIZED; + } + } + + public static Types.VifLockingMode toVifLockingMode(Object object) { + if (object == null) { + return null; + } + try { + return VifLockingMode.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VifLockingMode.UNRECOGNIZED; + } + } + + public static Types.VifOperations toVifOperations(Object object) { + if (object == null) { + return null; + } + try { + return VifOperations.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VifOperations.UNRECOGNIZED; + } + } + + public static Types.VmApplianceOperation toVmApplianceOperation(Object object) { + if (object == null) { + return null; + } + try { + return VmApplianceOperation.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VmApplianceOperation.UNRECOGNIZED; + } + } + + public static Types.VmOperations toVmOperations(Object object) { + if (object == null) { + return null; + } + try { + return VmOperations.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VmOperations.UNRECOGNIZED; + } + } + + public static Types.VmPowerState toVmPowerState(Object object) { + if (object == null) { + return null; + } + try { + return VmPowerState.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VmPowerState.UNRECOGNIZED; + } + } + + public static Types.VmppArchiveFrequency toVmppArchiveFrequency(Object object) { + if (object == null) { + return null; + } + try { + return VmppArchiveFrequency.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VmppArchiveFrequency.UNRECOGNIZED; + } + } + + public static Types.VmppArchiveTargetType toVmppArchiveTargetType(Object object) { + if (object == null) { + return null; + } + try { + return VmppArchiveTargetType.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VmppArchiveTargetType.UNRECOGNIZED; + } + } + + public static Types.VmppBackupFrequency toVmppBackupFrequency(Object object) { + if (object == null) { + return null; + } + try { + return VmppBackupFrequency.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VmppBackupFrequency.UNRECOGNIZED; + } + } + + public static Types.VmppBackupType toVmppBackupType(Object object) { + if (object == null) { + return null; + } + try { + return VmppBackupType.valueOf(((String) object).toUpperCase().replace('-','_')); + } catch (IllegalArgumentException ex) { + return VmppBackupType.UNRECOGNIZED; + } + } + + public static Set toSetOfString(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + String typed = toString(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfAfterApplyGuidance(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.AfterApplyGuidance typed = toAfterApplyGuidance(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfHostAllowedOperations(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.HostAllowedOperations typed = toHostAllowedOperations(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfNetworkOperations(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.NetworkOperations typed = toNetworkOperations(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfStorageOperations(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.StorageOperations typed = toStorageOperations(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfTaskAllowedOperations(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.TaskAllowedOperations typed = toTaskAllowedOperations(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVbdOperations(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.VbdOperations typed = toVbdOperations(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVdiOperations(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.VdiOperations typed = toVdiOperations(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVifOperations(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.VifOperations typed = toVifOperations(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVmApplianceOperation(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.VmApplianceOperation typed = toVmApplianceOperation(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVmOperations(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Types.VmOperations typed = toVmOperations(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfBond(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Bond typed = toBond(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfDRTask(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + DRTask typed = toDRTask(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfGPUGroup(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + GPUGroup typed = toGPUGroup(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfPBD(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + PBD typed = toPBD(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfPCI(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + PCI typed = toPCI(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfPGPU(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + PGPU typed = toPGPU(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfPIF(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + PIF typed = toPIF(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfPIFMetrics(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + PIFMetrics typed = toPIFMetrics(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfSM(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + SM typed = toSM(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfSR(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + SR typed = toSR(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVBD(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VBD typed = toVBD(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVBDMetrics(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VBDMetrics typed = toVBDMetrics(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVDI(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VDI typed = toVDI(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVGPU(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VGPU typed = toVGPU(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVIF(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VIF typed = toVIF(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVIFMetrics(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VIFMetrics typed = toVIFMetrics(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVLAN(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VLAN typed = toVLAN(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVM(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VM typed = toVM(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVMPP(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VMPP typed = toVMPP(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVMAppliance(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VMAppliance typed = toVMAppliance(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVMGuestMetrics(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VMGuestMetrics typed = toVMGuestMetrics(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVMMetrics(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VMMetrics typed = toVMMetrics(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfVTPM(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + VTPM typed = toVTPM(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfBlob(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Blob typed = toBlob(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfConsole(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Console typed = toConsole(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfCrashdump(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Crashdump typed = toCrashdump(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfHost(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Host typed = toHost(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfHostCpu(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + HostCpu typed = toHostCpu(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfHostCrashdump(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + HostCrashdump typed = toHostCrashdump(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfHostMetrics(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + HostMetrics typed = toHostMetrics(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfHostPatch(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + HostPatch typed = toHostPatch(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfMessage(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Message typed = toMessage(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfNetwork(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Network typed = toNetwork(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfPool(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Pool typed = toPool(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfPoolPatch(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + PoolPatch typed = toPoolPatch(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfRole(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Role typed = toRole(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfSecret(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Secret typed = toSecret(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfSubject(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Subject typed = toSubject(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfTask(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Task typed = toTask(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfTunnel(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Tunnel typed = toTunnel(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfDataSourceRecord(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + DataSource.Record typed = toDataSourceRecord(item); + result.add(typed); + } + return result; + } + + public static Set toSetOfEventRecord(Object object) { + if (object == null) { + return null; + } + Object[] items = (Object[]) object; + Set result = new LinkedHashSet(); + for(Object item: items) { + Event.Record typed = toEventRecord(item); + result.add(typed); + } + return result; + } + + public static Map toMapOfStringString(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + String value = toString(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringHostAllowedOperations(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.HostAllowedOperations value = toHostAllowedOperations(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringNetworkOperations(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.NetworkOperations value = toNetworkOperations(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringStorageOperations(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.StorageOperations value = toStorageOperations(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringTaskAllowedOperations(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.TaskAllowedOperations value = toTaskAllowedOperations(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringVbdOperations(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.VbdOperations value = toVbdOperations(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringVdiOperations(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.VdiOperations value = toVdiOperations(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringVifOperations(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.VifOperations value = toVifOperations(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringVmApplianceOperation(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.VmApplianceOperation value = toVmApplianceOperation(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringVmOperations(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Types.VmOperations value = toVmOperations(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfStringBlob(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + String key = toString(entry.getKey()); + Blob value = toBlob(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfLongLong(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Long key = toLong(entry.getKey()); + Long value = toLong(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfLongDouble(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Long key = toLong(entry.getKey()); + Double value = toDouble(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map> toMapOfLongSetOfString(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map> result = new HashMap>(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Long key = toLong(entry.getKey()); + Set value = toSetOfString(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVmOperationsString(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Types.VmOperations key = toVmOperations(entry.getKey()); + String value = toString(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfBondBondRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Bond key = toBond(entry.getKey()); + Bond.Record value = toBondRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfDRTaskDRTaskRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + DRTask key = toDRTask(entry.getKey()); + DRTask.Record value = toDRTaskRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfGPUGroupGPUGroupRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + GPUGroup key = toGPUGroup(entry.getKey()); + GPUGroup.Record value = toGPUGroupRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfPBDPBDRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + PBD key = toPBD(entry.getKey()); + PBD.Record value = toPBDRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfPCIPCIRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + PCI key = toPCI(entry.getKey()); + PCI.Record value = toPCIRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfPGPUPGPURecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + PGPU key = toPGPU(entry.getKey()); + PGPU.Record value = toPGPURecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfPIFPIFRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + PIF key = toPIF(entry.getKey()); + PIF.Record value = toPIFRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfPIFMetricsPIFMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + PIFMetrics key = toPIFMetrics(entry.getKey()); + PIFMetrics.Record value = toPIFMetricsRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfSMSMRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + SM key = toSM(entry.getKey()); + SM.Record value = toSMRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfSRSRRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + SR key = toSR(entry.getKey()); + SR.Record value = toSRRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVBDVBDRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VBD key = toVBD(entry.getKey()); + VBD.Record value = toVBDRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVBDMetricsVBDMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VBDMetrics key = toVBDMetrics(entry.getKey()); + VBDMetrics.Record value = toVBDMetricsRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVDISR(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VDI key = toVDI(entry.getKey()); + SR value = toSR(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVDIVDIRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VDI key = toVDI(entry.getKey()); + VDI.Record value = toVDIRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVGPUVGPURecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VGPU key = toVGPU(entry.getKey()); + VGPU.Record value = toVGPURecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVIFNetwork(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VIF key = toVIF(entry.getKey()); + Network value = toNetwork(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVIFVIFRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VIF key = toVIF(entry.getKey()); + VIF.Record value = toVIFRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVIFMetricsVIFMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VIFMetrics key = toVIFMetrics(entry.getKey()); + VIFMetrics.Record value = toVIFMetricsRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVLANVLANRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VLAN key = toVLAN(entry.getKey()); + VLAN.Record value = toVLANRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVMString(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VM key = toVM(entry.getKey()); + String value = toString(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map> toMapOfVMSetOfString(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map> result = new HashMap>(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VM key = toVM(entry.getKey()); + Set value = toSetOfString(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map> toMapOfVMMapOfStringString(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map> result = new HashMap>(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VM key = toVM(entry.getKey()); + Map value = toMapOfStringString(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVMVMRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VM key = toVM(entry.getKey()); + VM.Record value = toVMRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVMPPVMPPRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VMPP key = toVMPP(entry.getKey()); + VMPP.Record value = toVMPPRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVMApplianceVMApplianceRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VMAppliance key = toVMAppliance(entry.getKey()); + VMAppliance.Record value = toVMApplianceRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVMGuestMetricsVMGuestMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VMGuestMetrics key = toVMGuestMetrics(entry.getKey()); + VMGuestMetrics.Record value = toVMGuestMetricsRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfVMMetricsVMMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + VMMetrics key = toVMMetrics(entry.getKey()); + VMMetrics.Record value = toVMMetricsRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfBlobBlobRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Blob key = toBlob(entry.getKey()); + Blob.Record value = toBlobRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfConsoleConsoleRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Console key = toConsole(entry.getKey()); + Console.Record value = toConsoleRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfCrashdumpCrashdumpRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Crashdump key = toCrashdump(entry.getKey()); + Crashdump.Record value = toCrashdumpRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map> toMapOfHostSetOfString(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map> result = new HashMap>(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Host key = toHost(entry.getKey()); + Set value = toSetOfString(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfHostHostRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Host key = toHost(entry.getKey()); + Host.Record value = toHostRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfHostCpuHostCpuRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + HostCpu key = toHostCpu(entry.getKey()); + HostCpu.Record value = toHostCpuRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfHostCrashdumpHostCrashdumpRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + HostCrashdump key = toHostCrashdump(entry.getKey()); + HostCrashdump.Record value = toHostCrashdumpRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfHostMetricsHostMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + HostMetrics key = toHostMetrics(entry.getKey()); + HostMetrics.Record value = toHostMetricsRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfHostPatchHostPatchRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + HostPatch key = toHostPatch(entry.getKey()); + HostPatch.Record value = toHostPatchRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfMessageMessageRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Message key = toMessage(entry.getKey()); + Message.Record value = toMessageRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfNetworkNetworkRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Network key = toNetwork(entry.getKey()); + Network.Record value = toNetworkRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfPoolPoolRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Pool key = toPool(entry.getKey()); + Pool.Record value = toPoolRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfPoolPatchPoolPatchRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + PoolPatch key = toPoolPatch(entry.getKey()); + PoolPatch.Record value = toPoolPatchRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfRoleRoleRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Role key = toRole(entry.getKey()); + Role.Record value = toRoleRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfSecretSecretRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Secret key = toSecret(entry.getKey()); + Secret.Record value = toSecretRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfSubjectSubjectRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Subject key = toSubject(entry.getKey()); + Subject.Record value = toSubjectRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfTaskTaskRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Task key = toTask(entry.getKey()); + Task.Record value = toTaskRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Map toMapOfTunnelTunnelRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Map result = new HashMap(); + Set entries = map.entrySet(); + for(Map.Entry entry: entries) { + Tunnel key = toTunnel(entry.getKey()); + Tunnel.Record value = toTunnelRecord(entry.getValue()); + result.put(key, value); + } + return result; + } + + public static Bond toBond(Object object) { + if (object == null) { + return null; + } + return new Bond((String) object); + } + + public static DRTask toDRTask(Object object) { + if (object == null) { + return null; + } + return new DRTask((String) object); + } + + public static GPUGroup toGPUGroup(Object object) { + if (object == null) { + return null; + } + return new GPUGroup((String) object); + } + + public static PBD toPBD(Object object) { + if (object == null) { + return null; + } + return new PBD((String) object); + } + + public static PCI toPCI(Object object) { + if (object == null) { + return null; + } + return new PCI((String) object); + } + + public static PGPU toPGPU(Object object) { + if (object == null) { + return null; + } + return new PGPU((String) object); + } + + public static PIF toPIF(Object object) { + if (object == null) { + return null; + } + return new PIF((String) object); + } + + public static PIFMetrics toPIFMetrics(Object object) { + if (object == null) { + return null; + } + return new PIFMetrics((String) object); + } + + public static SM toSM(Object object) { + if (object == null) { + return null; + } + return new SM((String) object); + } + + public static SR toSR(Object object) { + if (object == null) { + return null; + } + return new SR((String) object); + } + + public static VBD toVBD(Object object) { + if (object == null) { + return null; + } + return new VBD((String) object); + } + + public static VBDMetrics toVBDMetrics(Object object) { + if (object == null) { + return null; + } + return new VBDMetrics((String) object); + } + + public static VDI toVDI(Object object) { + if (object == null) { + return null; + } + return new VDI((String) object); + } + + public static VGPU toVGPU(Object object) { + if (object == null) { + return null; + } + return new VGPU((String) object); + } + + public static VIF toVIF(Object object) { + if (object == null) { + return null; + } + return new VIF((String) object); + } + + public static VIFMetrics toVIFMetrics(Object object) { + if (object == null) { + return null; + } + return new VIFMetrics((String) object); + } + + public static VLAN toVLAN(Object object) { + if (object == null) { + return null; + } + return new VLAN((String) object); + } + + public static VM toVM(Object object) { + if (object == null) { + return null; + } + return new VM((String) object); + } + + public static VMPP toVMPP(Object object) { + if (object == null) { + return null; + } + return new VMPP((String) object); + } + + public static VMAppliance toVMAppliance(Object object) { + if (object == null) { + return null; + } + return new VMAppliance((String) object); + } + + public static VMGuestMetrics toVMGuestMetrics(Object object) { + if (object == null) { + return null; + } + return new VMGuestMetrics((String) object); + } + + public static VMMetrics toVMMetrics(Object object) { + if (object == null) { + return null; + } + return new VMMetrics((String) object); + } + + public static VTPM toVTPM(Object object) { + if (object == null) { + return null; + } + return new VTPM((String) object); + } + + public static Blob toBlob(Object object) { + if (object == null) { + return null; + } + return new Blob((String) object); + } + + public static Console toConsole(Object object) { + if (object == null) { + return null; + } + return new Console((String) object); + } + + public static Crashdump toCrashdump(Object object) { + if (object == null) { + return null; + } + return new Crashdump((String) object); + } + + public static Host toHost(Object object) { + if (object == null) { + return null; + } + return new Host((String) object); + } + + public static HostCpu toHostCpu(Object object) { + if (object == null) { + return null; + } + return new HostCpu((String) object); + } + + public static HostCrashdump toHostCrashdump(Object object) { + if (object == null) { + return null; + } + return new HostCrashdump((String) object); + } + + public static HostMetrics toHostMetrics(Object object) { + if (object == null) { + return null; + } + return new HostMetrics((String) object); + } + + public static HostPatch toHostPatch(Object object) { + if (object == null) { + return null; + } + return new HostPatch((String) object); + } + + public static Message toMessage(Object object) { + if (object == null) { + return null; + } + return new Message((String) object); + } + + public static Network toNetwork(Object object) { + if (object == null) { + return null; + } + return new Network((String) object); + } + + public static Pool toPool(Object object) { + if (object == null) { + return null; + } + return new Pool((String) object); + } + + public static PoolPatch toPoolPatch(Object object) { + if (object == null) { + return null; + } + return new PoolPatch((String) object); + } + + public static Role toRole(Object object) { + if (object == null) { + return null; + } + return new Role((String) object); + } + + public static Secret toSecret(Object object) { + if (object == null) { + return null; + } + return new Secret((String) object); + } + + public static Session toSession(Object object) { + if (object == null) { + return null; + } + return new Session((String) object); + } + + public static Subject toSubject(Object object) { + if (object == null) { + return null; + } + return new Subject((String) object); + } + + public static Task toTask(Object object) { + if (object == null) { + return null; + } + return new Task((String) object); + } + + public static Tunnel toTunnel(Object object) { + if (object == null) { + return null; + } + return new Tunnel((String) object); + } + + public static User toUser(Object object) { + if (object == null) { + return null; + } + return new User((String) object); + } + + public static Bond.Record toBondRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Bond.Record record = new Bond.Record(); + record.uuid = toString(map.get("uuid")); + record.master = toPIF(map.get("master")); + record.slaves = toSetOfPIF(map.get("slaves")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.primarySlave = toPIF(map.get("primary_slave")); + record.mode = toBondMode(map.get("mode")); + record.properties = toMapOfStringString(map.get("properties")); + record.linksUp = toLong(map.get("links_up")); + return record; + } + + public static DRTask.Record toDRTaskRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + DRTask.Record record = new DRTask.Record(); + record.uuid = toString(map.get("uuid")); + record.introducedSRs = toSetOfSR(map.get("introduced_SRs")); + return record; + } + + public static GPUGroup.Record toGPUGroupRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + GPUGroup.Record record = new GPUGroup.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.PGPUs = toSetOfPGPU(map.get("PGPUs")); + record.VGPUs = toSetOfVGPU(map.get("VGPUs")); + record.GPUTypes = toSetOfString(map.get("GPU_types")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static PBD.Record toPBDRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + PBD.Record record = new PBD.Record(); + record.uuid = toString(map.get("uuid")); + record.host = toHost(map.get("host")); + record.SR = toSR(map.get("SR")); + record.deviceConfig = toMapOfStringString(map.get("device_config")); + record.currentlyAttached = toBoolean(map.get("currently_attached")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static PCI.Record toPCIRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + PCI.Record record = new PCI.Record(); + record.uuid = toString(map.get("uuid")); + record.clazzName = toString(map.get("class_name")); + record.vendorName = toString(map.get("vendor_name")); + record.deviceName = toString(map.get("device_name")); + record.host = toHost(map.get("host")); + record.pciId = toString(map.get("pci_id")); + record.dependencies = toSetOfPCI(map.get("dependencies")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static PGPU.Record toPGPURecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + PGPU.Record record = new PGPU.Record(); + record.uuid = toString(map.get("uuid")); + record.PCI = toPCI(map.get("PCI")); + record.GPUGroup = toGPUGroup(map.get("GPU_group")); + record.host = toHost(map.get("host")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static PIF.Record toPIFRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + PIF.Record record = new PIF.Record(); + record.uuid = toString(map.get("uuid")); + record.device = toString(map.get("device")); + record.network = toNetwork(map.get("network")); + record.host = toHost(map.get("host")); + record.MAC = toString(map.get("MAC")); + record.MTU = toLong(map.get("MTU")); + record.VLAN = toLong(map.get("VLAN")); + record.metrics = toPIFMetrics(map.get("metrics")); + record.physical = toBoolean(map.get("physical")); + record.currentlyAttached = toBoolean(map.get("currently_attached")); + record.ipConfigurationMode = toIpConfigurationMode(map.get("ip_configuration_mode")); + record.IP = toString(map.get("IP")); + record.netmask = toString(map.get("netmask")); + record.gateway = toString(map.get("gateway")); + record.DNS = toString(map.get("DNS")); + record.bondSlaveOf = toBond(map.get("bond_slave_of")); + record.bondMasterOf = toSetOfBond(map.get("bond_master_of")); + record.VLANMasterOf = toVLAN(map.get("VLAN_master_of")); + record.VLANSlaveOf = toSetOfVLAN(map.get("VLAN_slave_of")); + record.management = toBoolean(map.get("management")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.disallowUnplug = toBoolean(map.get("disallow_unplug")); + record.tunnelAccessPIFOf = toSetOfTunnel(map.get("tunnel_access_PIF_of")); + record.tunnelTransportPIFOf = toSetOfTunnel(map.get("tunnel_transport_PIF_of")); + record.ipv6ConfigurationMode = toIpv6ConfigurationMode(map.get("ipv6_configuration_mode")); + record.IPv6 = toSetOfString(map.get("IPv6")); + record.ipv6Gateway = toString(map.get("ipv6_gateway")); + record.primaryAddressType = toPrimaryAddressType(map.get("primary_address_type")); + return record; + } + + public static PIFMetrics.Record toPIFMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + PIFMetrics.Record record = new PIFMetrics.Record(); + record.uuid = toString(map.get("uuid")); + record.ioReadKbs = toDouble(map.get("io_read_kbs")); + record.ioWriteKbs = toDouble(map.get("io_write_kbs")); + record.carrier = toBoolean(map.get("carrier")); + record.vendorId = toString(map.get("vendor_id")); + record.vendorName = toString(map.get("vendor_name")); + record.deviceId = toString(map.get("device_id")); + record.deviceName = toString(map.get("device_name")); + record.speed = toLong(map.get("speed")); + record.duplex = toBoolean(map.get("duplex")); + record.pciBusPath = toString(map.get("pci_bus_path")); + record.lastUpdated = toDate(map.get("last_updated")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static SM.Record toSMRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + SM.Record record = new SM.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.type = toString(map.get("type")); + record.vendor = toString(map.get("vendor")); + record.copyright = toString(map.get("copyright")); + record.version = toString(map.get("version")); + record.requiredApiVersion = toString(map.get("required_api_version")); + record.configuration = toMapOfStringString(map.get("configuration")); + record.capabilities = toSetOfString(map.get("capabilities")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.driverFilename = toString(map.get("driver_filename")); + return record; + } + + public static SR.Record toSRRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + SR.Record record = new SR.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.allowedOperations = toSetOfStorageOperations(map.get("allowed_operations")); + record.currentOperations = toMapOfStringStorageOperations(map.get("current_operations")); + record.VDIs = toSetOfVDI(map.get("VDIs")); + record.PBDs = toSetOfPBD(map.get("PBDs")); + record.virtualAllocation = toLong(map.get("virtual_allocation")); + record.physicalUtilisation = toLong(map.get("physical_utilisation")); + record.physicalSize = toLong(map.get("physical_size")); + record.type = toString(map.get("type")); + record.contentType = toString(map.get("content_type")); + record.shared = toBoolean(map.get("shared")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.tags = toSetOfString(map.get("tags")); + record.smConfig = toMapOfStringString(map.get("sm_config")); + record.blobs = toMapOfStringBlob(map.get("blobs")); + record.localCacheEnabled = toBoolean(map.get("local_cache_enabled")); + record.introducedBy = toDRTask(map.get("introduced_by")); + return record; + } + + public static VBD.Record toVBDRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VBD.Record record = new VBD.Record(); + record.uuid = toString(map.get("uuid")); + record.allowedOperations = toSetOfVbdOperations(map.get("allowed_operations")); + record.currentOperations = toMapOfStringVbdOperations(map.get("current_operations")); + record.VM = toVM(map.get("VM")); + record.VDI = toVDI(map.get("VDI")); + record.device = toString(map.get("device")); + record.userdevice = toString(map.get("userdevice")); + record.bootable = toBoolean(map.get("bootable")); + record.mode = toVbdMode(map.get("mode")); + record.type = toVbdType(map.get("type")); + record.unpluggable = toBoolean(map.get("unpluggable")); + record.storageLock = toBoolean(map.get("storage_lock")); + record.empty = toBoolean(map.get("empty")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.currentlyAttached = toBoolean(map.get("currently_attached")); + record.statusCode = toLong(map.get("status_code")); + record.statusDetail = toString(map.get("status_detail")); + record.runtimeProperties = toMapOfStringString(map.get("runtime_properties")); + record.qosAlgorithmType = toString(map.get("qos_algorithm_type")); + record.qosAlgorithmParams = toMapOfStringString(map.get("qos_algorithm_params")); + record.qosSupportedAlgorithms = toSetOfString(map.get("qos_supported_algorithms")); + record.metrics = toVBDMetrics(map.get("metrics")); + return record; + } + + public static VBDMetrics.Record toVBDMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VBDMetrics.Record record = new VBDMetrics.Record(); + record.uuid = toString(map.get("uuid")); + record.ioReadKbs = toDouble(map.get("io_read_kbs")); + record.ioWriteKbs = toDouble(map.get("io_write_kbs")); + record.lastUpdated = toDate(map.get("last_updated")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static VDI.Record toVDIRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VDI.Record record = new VDI.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.allowedOperations = toSetOfVdiOperations(map.get("allowed_operations")); + record.currentOperations = toMapOfStringVdiOperations(map.get("current_operations")); + record.SR = toSR(map.get("SR")); + record.VBDs = toSetOfVBD(map.get("VBDs")); + record.crashDumps = toSetOfCrashdump(map.get("crash_dumps")); + record.virtualSize = toLong(map.get("virtual_size")); + record.physicalUtilisation = toLong(map.get("physical_utilisation")); + record.type = toVdiType(map.get("type")); + record.sharable = toBoolean(map.get("sharable")); + record.readOnly = toBoolean(map.get("read_only")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.storageLock = toBoolean(map.get("storage_lock")); + record.location = toString(map.get("location")); + record.managed = toBoolean(map.get("managed")); + record.missing = toBoolean(map.get("missing")); + record.parent = toVDI(map.get("parent")); + record.xenstoreData = toMapOfStringString(map.get("xenstore_data")); + record.smConfig = toMapOfStringString(map.get("sm_config")); + record.isASnapshot = toBoolean(map.get("is_a_snapshot")); + record.snapshotOf = toVDI(map.get("snapshot_of")); + record.snapshots = toSetOfVDI(map.get("snapshots")); + record.snapshotTime = toDate(map.get("snapshot_time")); + record.tags = toSetOfString(map.get("tags")); + record.allowCaching = toBoolean(map.get("allow_caching")); + record.onBoot = toOnBoot(map.get("on_boot")); + record.metadataOfPool = toPool(map.get("metadata_of_pool")); + record.metadataLatest = toBoolean(map.get("metadata_latest")); + return record; + } + + public static VGPU.Record toVGPURecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VGPU.Record record = new VGPU.Record(); + record.uuid = toString(map.get("uuid")); + record.VM = toVM(map.get("VM")); + record.GPUGroup = toGPUGroup(map.get("GPU_group")); + record.device = toString(map.get("device")); + record.currentlyAttached = toBoolean(map.get("currently_attached")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static VIF.Record toVIFRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VIF.Record record = new VIF.Record(); + record.uuid = toString(map.get("uuid")); + record.allowedOperations = toSetOfVifOperations(map.get("allowed_operations")); + record.currentOperations = toMapOfStringVifOperations(map.get("current_operations")); + record.device = toString(map.get("device")); + record.network = toNetwork(map.get("network")); + record.VM = toVM(map.get("VM")); + record.MAC = toString(map.get("MAC")); + record.MTU = toLong(map.get("MTU")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.currentlyAttached = toBoolean(map.get("currently_attached")); + record.statusCode = toLong(map.get("status_code")); + record.statusDetail = toString(map.get("status_detail")); + record.runtimeProperties = toMapOfStringString(map.get("runtime_properties")); + record.qosAlgorithmType = toString(map.get("qos_algorithm_type")); + record.qosAlgorithmParams = toMapOfStringString(map.get("qos_algorithm_params")); + record.qosSupportedAlgorithms = toSetOfString(map.get("qos_supported_algorithms")); + record.metrics = toVIFMetrics(map.get("metrics")); + record.MACAutogenerated = toBoolean(map.get("MAC_autogenerated")); + record.lockingMode = toVifLockingMode(map.get("locking_mode")); + record.ipv4Allowed = toSetOfString(map.get("ipv4_allowed")); + record.ipv6Allowed = toSetOfString(map.get("ipv6_allowed")); + return record; + } + + public static VIFMetrics.Record toVIFMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VIFMetrics.Record record = new VIFMetrics.Record(); + record.uuid = toString(map.get("uuid")); + record.ioReadKbs = toDouble(map.get("io_read_kbs")); + record.ioWriteKbs = toDouble(map.get("io_write_kbs")); + record.lastUpdated = toDate(map.get("last_updated")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static VLAN.Record toVLANRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VLAN.Record record = new VLAN.Record(); + record.uuid = toString(map.get("uuid")); + record.taggedPIF = toPIF(map.get("tagged_PIF")); + record.untaggedPIF = toPIF(map.get("untagged_PIF")); + record.tag = toLong(map.get("tag")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static VM.Record toVMRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VM.Record record = new VM.Record(); + record.uuid = toString(map.get("uuid")); + record.allowedOperations = toSetOfVmOperations(map.get("allowed_operations")); + record.currentOperations = toMapOfStringVmOperations(map.get("current_operations")); + record.powerState = toVmPowerState(map.get("power_state")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.userVersion = toLong(map.get("user_version")); + record.isATemplate = toBoolean(map.get("is_a_template")); + record.suspendVDI = toVDI(map.get("suspend_VDI")); + record.residentOn = toHost(map.get("resident_on")); + record.affinity = toHost(map.get("affinity")); + record.memoryOverhead = toLong(map.get("memory_overhead")); + record.memoryTarget = toLong(map.get("memory_target")); + record.memoryStaticMax = toLong(map.get("memory_static_max")); + record.memoryDynamicMax = toLong(map.get("memory_dynamic_max")); + record.memoryDynamicMin = toLong(map.get("memory_dynamic_min")); + record.memoryStaticMin = toLong(map.get("memory_static_min")); + record.VCPUsParams = toMapOfStringString(map.get("VCPUs_params")); + record.VCPUsMax = toLong(map.get("VCPUs_max")); + record.VCPUsAtStartup = toLong(map.get("VCPUs_at_startup")); + record.actionsAfterShutdown = toOnNormalExit(map.get("actions_after_shutdown")); + record.actionsAfterReboot = toOnNormalExit(map.get("actions_after_reboot")); + record.actionsAfterCrash = toOnCrashBehaviour(map.get("actions_after_crash")); + record.consoles = toSetOfConsole(map.get("consoles")); + record.VIFs = toSetOfVIF(map.get("VIFs")); + record.VBDs = toSetOfVBD(map.get("VBDs")); + record.crashDumps = toSetOfCrashdump(map.get("crash_dumps")); + record.VTPMs = toSetOfVTPM(map.get("VTPMs")); + record.PVBootloader = toString(map.get("PV_bootloader")); + record.PVKernel = toString(map.get("PV_kernel")); + record.PVRamdisk = toString(map.get("PV_ramdisk")); + record.PVArgs = toString(map.get("PV_args")); + record.PVBootloaderArgs = toString(map.get("PV_bootloader_args")); + record.PVLegacyArgs = toString(map.get("PV_legacy_args")); + record.HVMBootPolicy = toString(map.get("HVM_boot_policy")); + record.HVMBootParams = toMapOfStringString(map.get("HVM_boot_params")); + record.HVMShadowMultiplier = toDouble(map.get("HVM_shadow_multiplier")); + record.platform = toMapOfStringString(map.get("platform")); + record.PCIBus = toString(map.get("PCI_bus")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.domid = toLong(map.get("domid")); + record.domarch = toString(map.get("domarch")); + record.lastBootCPUFlags = toMapOfStringString(map.get("last_boot_CPU_flags")); + record.isControlDomain = toBoolean(map.get("is_control_domain")); + record.metrics = toVMMetrics(map.get("metrics")); + record.guestMetrics = toVMGuestMetrics(map.get("guest_metrics")); + record.lastBootedRecord = toString(map.get("last_booted_record")); + record.recommendations = toString(map.get("recommendations")); + record.xenstoreData = toMapOfStringString(map.get("xenstore_data")); + record.haAlwaysRun = toBoolean(map.get("ha_always_run")); + record.haRestartPriority = toString(map.get("ha_restart_priority")); + record.isASnapshot = toBoolean(map.get("is_a_snapshot")); + record.snapshotOf = toVM(map.get("snapshot_of")); + record.snapshots = toSetOfVM(map.get("snapshots")); + record.snapshotTime = toDate(map.get("snapshot_time")); + record.transportableSnapshotId = toString(map.get("transportable_snapshot_id")); + record.blobs = toMapOfStringBlob(map.get("blobs")); + record.tags = toSetOfString(map.get("tags")); + record.blockedOperations = toMapOfVmOperationsString(map.get("blocked_operations")); + record.snapshotInfo = toMapOfStringString(map.get("snapshot_info")); + record.snapshotMetadata = toString(map.get("snapshot_metadata")); + record.parent = toVM(map.get("parent")); + record.children = toSetOfVM(map.get("children")); + record.biosStrings = toMapOfStringString(map.get("bios_strings")); + record.protectionPolicy = toVMPP(map.get("protection_policy")); + record.isSnapshotFromVmpp = toBoolean(map.get("is_snapshot_from_vmpp")); + record.appliance = toVMAppliance(map.get("appliance")); + record.startDelay = toLong(map.get("start_delay")); + record.shutdownDelay = toLong(map.get("shutdown_delay")); + record.order = toLong(map.get("order")); + record.VGPUs = toSetOfVGPU(map.get("VGPUs")); + record.attachedPCIs = toSetOfPCI(map.get("attached_PCIs")); + record.suspendSR = toSR(map.get("suspend_SR")); + record.version = toLong(map.get("version")); + return record; + } + + public static VMPP.Record toVMPPRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VMPP.Record record = new VMPP.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.isPolicyEnabled = toBoolean(map.get("is_policy_enabled")); + record.backupType = toVmppBackupType(map.get("backup_type")); + record.backupRetentionValue = toLong(map.get("backup_retention_value")); + record.backupFrequency = toVmppBackupFrequency(map.get("backup_frequency")); + record.backupSchedule = toMapOfStringString(map.get("backup_schedule")); + record.isBackupRunning = toBoolean(map.get("is_backup_running")); + record.backupLastRunTime = toDate(map.get("backup_last_run_time")); + record.archiveTargetType = toVmppArchiveTargetType(map.get("archive_target_type")); + record.archiveTargetConfig = toMapOfStringString(map.get("archive_target_config")); + record.archiveFrequency = toVmppArchiveFrequency(map.get("archive_frequency")); + record.archiveSchedule = toMapOfStringString(map.get("archive_schedule")); + record.isArchiveRunning = toBoolean(map.get("is_archive_running")); + record.archiveLastRunTime = toDate(map.get("archive_last_run_time")); + record.VMs = toSetOfVM(map.get("VMs")); + record.isAlarmEnabled = toBoolean(map.get("is_alarm_enabled")); + record.alarmConfig = toMapOfStringString(map.get("alarm_config")); + record.recentAlerts = toSetOfString(map.get("recent_alerts")); + return record; + } + + public static VMAppliance.Record toVMApplianceRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VMAppliance.Record record = new VMAppliance.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.allowedOperations = toSetOfVmApplianceOperation(map.get("allowed_operations")); + record.currentOperations = toMapOfStringVmApplianceOperation(map.get("current_operations")); + record.VMs = toSetOfVM(map.get("VMs")); + return record; + } + + public static VMGuestMetrics.Record toVMGuestMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VMGuestMetrics.Record record = new VMGuestMetrics.Record(); + record.uuid = toString(map.get("uuid")); + record.osVersion = toMapOfStringString(map.get("os_version")); + record.PVDriversVersion = toMapOfStringString(map.get("PV_drivers_version")); + record.PVDriversUpToDate = toBoolean(map.get("PV_drivers_up_to_date")); + record.memory = toMapOfStringString(map.get("memory")); + record.disks = toMapOfStringString(map.get("disks")); + record.networks = toMapOfStringString(map.get("networks")); + record.other = toMapOfStringString(map.get("other")); + record.lastUpdated = toDate(map.get("last_updated")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.live = toBoolean(map.get("live")); + return record; + } + + public static VMMetrics.Record toVMMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VMMetrics.Record record = new VMMetrics.Record(); + record.uuid = toString(map.get("uuid")); + record.memoryActual = toLong(map.get("memory_actual")); + record.VCPUsNumber = toLong(map.get("VCPUs_number")); + record.VCPUsUtilisation = toMapOfLongDouble(map.get("VCPUs_utilisation")); + record.VCPUsCPU = toMapOfLongLong(map.get("VCPUs_CPU")); + record.VCPUsParams = toMapOfStringString(map.get("VCPUs_params")); + record.VCPUsFlags = toMapOfLongSetOfString(map.get("VCPUs_flags")); + record.state = toSetOfString(map.get("state")); + record.startTime = toDate(map.get("start_time")); + record.installTime = toDate(map.get("install_time")); + record.lastUpdated = toDate(map.get("last_updated")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static VTPM.Record toVTPMRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + VTPM.Record record = new VTPM.Record(); + record.uuid = toString(map.get("uuid")); + record.VM = toVM(map.get("VM")); + record.backend = toVM(map.get("backend")); + return record; + } + + public static Blob.Record toBlobRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Blob.Record record = new Blob.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.size = toLong(map.get("size")); + record._public = toBoolean(map.get("public")); + record.lastUpdated = toDate(map.get("last_updated")); + record.mimeType = toString(map.get("mime_type")); + return record; + } + + public static Console.Record toConsoleRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Console.Record record = new Console.Record(); + record.uuid = toString(map.get("uuid")); + record.protocol = toConsoleProtocol(map.get("protocol")); + record.location = toString(map.get("location")); + record.VM = toVM(map.get("VM")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static Crashdump.Record toCrashdumpRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Crashdump.Record record = new Crashdump.Record(); + record.uuid = toString(map.get("uuid")); + record.VM = toVM(map.get("VM")); + record.VDI = toVDI(map.get("VDI")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static DataSource.Record toDataSourceRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + DataSource.Record record = new DataSource.Record(); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.enabled = toBoolean(map.get("enabled")); + record.standard = toBoolean(map.get("standard")); + record.units = toString(map.get("units")); + record.min = toDouble(map.get("min")); + record.max = toDouble(map.get("max")); + record.value = toDouble(map.get("value")); + return record; + } + + public static Event.Record toEventRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Event.Record record = new Event.Record(); + record.id = toLong(map.get("id")); + record.timestamp = toDate(map.get("timestamp")); + record.clazz = toString(map.get("class")); + record.operation = toEventOperation(map.get("operation")); + record.ref = toString(map.get("ref")); + record.objUuid = toString(map.get("obj_uuid")); + + + Object a,b; + a=map.get("snapshot"); + switch(toXenAPIObjects(record.clazz)) + { + case SESSION: b = toSessionRecord(a); break; + case SUBJECT: b = toSubjectRecord(a); break; + case ROLE: b = toRoleRecord(a); break; + case TASK: b = toTaskRecord(a); break; + case EVENT: b = toEventRecord(a); break; + case POOL: b = toPoolRecord(a); break; + case POOL_PATCH: b = toPoolPatchRecord(a); break; + case VM: b = toVMRecord(a); break; + case VM_METRICS: b = toVMMetricsRecord(a); break; + case VM_GUEST_METRICS: b = toVMGuestMetricsRecord(a); break; + case VMPP: b = toVMPPRecord(a); break; + case VM_APPLIANCE: b = toVMApplianceRecord(a); break; + case DR_TASK: b = toDRTaskRecord(a); break; + case HOST: b = toHostRecord(a); break; + case HOST_CRASHDUMP: b = toHostCrashdumpRecord(a); break; + case HOST_PATCH: b = toHostPatchRecord(a); break; + case HOST_METRICS: b = toHostMetricsRecord(a); break; + case HOST_CPU: b = toHostCpuRecord(a); break; + case NETWORK: b = toNetworkRecord(a); break; + case VIF: b = toVIFRecord(a); break; + case VIF_METRICS: b = toVIFMetricsRecord(a); break; + case PIF: b = toPIFRecord(a); break; + case PIF_METRICS: b = toPIFMetricsRecord(a); break; + case BOND: b = toBondRecord(a); break; + case VLAN: b = toVLANRecord(a); break; + case SM: b = toSMRecord(a); break; + case SR: b = toSRRecord(a); break; + case VDI: b = toVDIRecord(a); break; + case VBD: b = toVBDRecord(a); break; + case VBD_METRICS: b = toVBDMetricsRecord(a); break; + case PBD: b = toPBDRecord(a); break; + case CRASHDUMP: b = toCrashdumpRecord(a); break; + case VTPM: b = toVTPMRecord(a); break; + case CONSOLE: b = toConsoleRecord(a); break; + case USER: b = toUserRecord(a); break; + case DATA_SOURCE: b = toDataSourceRecord(a); break; + case BLOB: b = toBlobRecord(a); break; + case MESSAGE: b = toMessageRecord(a); break; + case SECRET: b = toSecretRecord(a); break; + case TUNNEL: b = toTunnelRecord(a); break; + case PCI: b = toPCIRecord(a); break; + case PGPU: b = toPGPURecord(a); break; + case GPU_GROUP: b = toGPUGroupRecord(a); break; + case VGPU: b = toVGPURecord(a); break; + default: throw new RuntimeException("Internal error in auto-generated code whilst unmarshalling event snapshot"); + } + record.snapshot = b; + return record; + } + + public static Host.Record toHostRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Host.Record record = new Host.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.memoryOverhead = toLong(map.get("memory_overhead")); + record.allowedOperations = toSetOfHostAllowedOperations(map.get("allowed_operations")); + record.currentOperations = toMapOfStringHostAllowedOperations(map.get("current_operations")); + record.APIVersionMajor = toLong(map.get("API_version_major")); + record.APIVersionMinor = toLong(map.get("API_version_minor")); + record.APIVersionVendor = toString(map.get("API_version_vendor")); + record.APIVersionVendorImplementation = toMapOfStringString(map.get("API_version_vendor_implementation")); + record.enabled = toBoolean(map.get("enabled")); + record.softwareVersion = toMapOfStringString(map.get("software_version")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.capabilities = toSetOfString(map.get("capabilities")); + record.cpuConfiguration = toMapOfStringString(map.get("cpu_configuration")); + record.schedPolicy = toString(map.get("sched_policy")); + record.supportedBootloaders = toSetOfString(map.get("supported_bootloaders")); + record.residentVMs = toSetOfVM(map.get("resident_VMs")); + record.logging = toMapOfStringString(map.get("logging")); + record.PIFs = toSetOfPIF(map.get("PIFs")); + record.suspendImageSr = toSR(map.get("suspend_image_sr")); + record.crashDumpSr = toSR(map.get("crash_dump_sr")); + record.crashdumps = toSetOfHostCrashdump(map.get("crashdumps")); + record.patches = toSetOfHostPatch(map.get("patches")); + record.PBDs = toSetOfPBD(map.get("PBDs")); + record.hostCPUs = toSetOfHostCpu(map.get("host_CPUs")); + record.cpuInfo = toMapOfStringString(map.get("cpu_info")); + record.hostname = toString(map.get("hostname")); + record.address = toString(map.get("address")); + record.metrics = toHostMetrics(map.get("metrics")); + record.licenseParams = toMapOfStringString(map.get("license_params")); + record.haStatefiles = toSetOfString(map.get("ha_statefiles")); + record.haNetworkPeers = toSetOfString(map.get("ha_network_peers")); + record.blobs = toMapOfStringBlob(map.get("blobs")); + record.tags = toSetOfString(map.get("tags")); + record.externalAuthType = toString(map.get("external_auth_type")); + record.externalAuthServiceName = toString(map.get("external_auth_service_name")); + record.externalAuthConfiguration = toMapOfStringString(map.get("external_auth_configuration")); + record.edition = toString(map.get("edition")); + record.licenseServer = toMapOfStringString(map.get("license_server")); + record.biosStrings = toMapOfStringString(map.get("bios_strings")); + record.powerOnMode = toString(map.get("power_on_mode")); + record.powerOnConfig = toMapOfStringString(map.get("power_on_config")); + record.localCacheSr = toSR(map.get("local_cache_sr")); + record.chipsetInfo = toMapOfStringString(map.get("chipset_info")); + record.PCIs = toSetOfPCI(map.get("PCIs")); + record.PGPUs = toSetOfPGPU(map.get("PGPUs")); + return record; + } + + public static HostCpu.Record toHostCpuRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + HostCpu.Record record = new HostCpu.Record(); + record.uuid = toString(map.get("uuid")); + record.host = toHost(map.get("host")); + record.number = toLong(map.get("number")); + record.vendor = toString(map.get("vendor")); + record.speed = toLong(map.get("speed")); + record.modelname = toString(map.get("modelname")); + record.family = toLong(map.get("family")); + record.model = toLong(map.get("model")); + record.stepping = toString(map.get("stepping")); + record.flags = toString(map.get("flags")); + record.features = toString(map.get("features")); + record.utilisation = toDouble(map.get("utilisation")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static HostCrashdump.Record toHostCrashdumpRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + HostCrashdump.Record record = new HostCrashdump.Record(); + record.uuid = toString(map.get("uuid")); + record.host = toHost(map.get("host")); + record.timestamp = toDate(map.get("timestamp")); + record.size = toLong(map.get("size")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static HostMetrics.Record toHostMetricsRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + HostMetrics.Record record = new HostMetrics.Record(); + record.uuid = toString(map.get("uuid")); + record.memoryTotal = toLong(map.get("memory_total")); + record.memoryFree = toLong(map.get("memory_free")); + record.live = toBoolean(map.get("live")); + record.lastUpdated = toDate(map.get("last_updated")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static HostPatch.Record toHostPatchRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + HostPatch.Record record = new HostPatch.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.version = toString(map.get("version")); + record.host = toHost(map.get("host")); + record.applied = toBoolean(map.get("applied")); + record.timestampApplied = toDate(map.get("timestamp_applied")); + record.size = toLong(map.get("size")); + record.poolPatch = toPoolPatch(map.get("pool_patch")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static Message.Record toMessageRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Message.Record record = new Message.Record(); + record.uuid = toString(map.get("uuid")); + record.name = toString(map.get("name")); + record.priority = toLong(map.get("priority")); + record.cls = toCls(map.get("cls")); + record.objUuid = toString(map.get("obj_uuid")); + record.timestamp = toDate(map.get("timestamp")); + record.body = toString(map.get("body")); + return record; + } + + public static Network.Record toNetworkRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Network.Record record = new Network.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.allowedOperations = toSetOfNetworkOperations(map.get("allowed_operations")); + record.currentOperations = toMapOfStringNetworkOperations(map.get("current_operations")); + record.VIFs = toSetOfVIF(map.get("VIFs")); + record.PIFs = toSetOfPIF(map.get("PIFs")); + record.MTU = toLong(map.get("MTU")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.bridge = toString(map.get("bridge")); + record.blobs = toMapOfStringBlob(map.get("blobs")); + record.tags = toSetOfString(map.get("tags")); + record.defaultLockingMode = toNetworkDefaultLockingMode(map.get("default_locking_mode")); + return record; + } + + public static Pool.Record toPoolRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Pool.Record record = new Pool.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.master = toHost(map.get("master")); + record.defaultSR = toSR(map.get("default_SR")); + record.suspendImageSR = toSR(map.get("suspend_image_SR")); + record.crashDumpSR = toSR(map.get("crash_dump_SR")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.haEnabled = toBoolean(map.get("ha_enabled")); + record.haConfiguration = toMapOfStringString(map.get("ha_configuration")); + record.haStatefiles = toSetOfString(map.get("ha_statefiles")); + record.haHostFailuresToTolerate = toLong(map.get("ha_host_failures_to_tolerate")); + record.haPlanExistsFor = toLong(map.get("ha_plan_exists_for")); + record.haAllowOvercommit = toBoolean(map.get("ha_allow_overcommit")); + record.haOvercommitted = toBoolean(map.get("ha_overcommitted")); + record.blobs = toMapOfStringBlob(map.get("blobs")); + record.tags = toSetOfString(map.get("tags")); + record.guiConfig = toMapOfStringString(map.get("gui_config")); + record.wlbUrl = toString(map.get("wlb_url")); + record.wlbUsername = toString(map.get("wlb_username")); + record.wlbEnabled = toBoolean(map.get("wlb_enabled")); + record.wlbVerifyCert = toBoolean(map.get("wlb_verify_cert")); + record.redoLogEnabled = toBoolean(map.get("redo_log_enabled")); + record.redoLogVdi = toVDI(map.get("redo_log_vdi")); + record.vswitchController = toString(map.get("vswitch_controller")); + record.restrictions = toMapOfStringString(map.get("restrictions")); + record.metadataVDIs = toSetOfVDI(map.get("metadata_VDIs")); + return record; + } + + public static PoolPatch.Record toPoolPatchRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + PoolPatch.Record record = new PoolPatch.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.version = toString(map.get("version")); + record.size = toLong(map.get("size")); + record.poolApplied = toBoolean(map.get("pool_applied")); + record.hostPatches = toSetOfHostPatch(map.get("host_patches")); + record.afterApplyGuidance = toSetOfAfterApplyGuidance(map.get("after_apply_guidance")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static Role.Record toRoleRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Role.Record record = new Role.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.subroles = toSetOfRole(map.get("subroles")); + return record; + } + + public static Secret.Record toSecretRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Secret.Record record = new Secret.Record(); + record.uuid = toString(map.get("uuid")); + record.value = toString(map.get("value")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static Session.Record toSessionRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Session.Record record = new Session.Record(); + record.uuid = toString(map.get("uuid")); + record.thisHost = toHost(map.get("this_host")); + record.thisUser = toUser(map.get("this_user")); + record.lastActive = toDate(map.get("last_active")); + record.pool = toBoolean(map.get("pool")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.isLocalSuperuser = toBoolean(map.get("is_local_superuser")); + record.subject = toSubject(map.get("subject")); + record.validationTime = toDate(map.get("validation_time")); + record.authUserSid = toString(map.get("auth_user_sid")); + record.authUserName = toString(map.get("auth_user_name")); + record.rbacPermissions = toSetOfString(map.get("rbac_permissions")); + record.tasks = toSetOfTask(map.get("tasks")); + record.parent = toSession(map.get("parent")); + return record; + } + + public static Subject.Record toSubjectRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Subject.Record record = new Subject.Record(); + record.uuid = toString(map.get("uuid")); + record.subjectIdentifier = toString(map.get("subject_identifier")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.roles = toSetOfRole(map.get("roles")); + return record; + } + + public static Task.Record toTaskRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Task.Record record = new Task.Record(); + record.uuid = toString(map.get("uuid")); + record.nameLabel = toString(map.get("name_label")); + record.nameDescription = toString(map.get("name_description")); + record.allowedOperations = toSetOfTaskAllowedOperations(map.get("allowed_operations")); + record.currentOperations = toMapOfStringTaskAllowedOperations(map.get("current_operations")); + record.created = toDate(map.get("created")); + record.finished = toDate(map.get("finished")); + record.status = toTaskStatusType(map.get("status")); + record.residentOn = toHost(map.get("resident_on")); + record.progress = toDouble(map.get("progress")); + record.type = toString(map.get("type")); + record.result = toString(map.get("result")); + record.errorInfo = toSetOfString(map.get("error_info")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + record.subtaskOf = toTask(map.get("subtask_of")); + record.subtasks = toSetOfTask(map.get("subtasks")); + return record; + } + + public static Tunnel.Record toTunnelRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + Tunnel.Record record = new Tunnel.Record(); + record.uuid = toString(map.get("uuid")); + record.accessPIF = toPIF(map.get("access_PIF")); + record.transportPIF = toPIF(map.get("transport_PIF")); + record.status = toMapOfStringString(map.get("status")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + public static User.Record toUserRecord(Object object) { + if (object == null) { + return null; + } + Map map = (Map) object; + User.Record record = new User.Record(); + record.uuid = toString(map.get("uuid")); + record.shortName = toString(map.get("short_name")); + record.fullname = toString(map.get("fullname")); + record.otherConfig = toMapOfStringString(map.get("other_config")); + return record; + } + + + public static Bond toBond(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toBond(parseResult(task.getResult(connection))); + } + + public static DRTask toDRTask(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toDRTask(parseResult(task.getResult(connection))); + } + + public static GPUGroup toGPUGroup(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toGPUGroup(parseResult(task.getResult(connection))); + } + + public static PBD toPBD(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toPBD(parseResult(task.getResult(connection))); + } + + public static PCI toPCI(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toPCI(parseResult(task.getResult(connection))); + } + + public static PGPU toPGPU(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toPGPU(parseResult(task.getResult(connection))); + } + + public static PIF toPIF(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toPIF(parseResult(task.getResult(connection))); + } + + public static PIFMetrics toPIFMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toPIFMetrics(parseResult(task.getResult(connection))); + } + + public static SM toSM(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toSM(parseResult(task.getResult(connection))); + } + + public static SR toSR(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toSR(parseResult(task.getResult(connection))); + } + + public static VBD toVBD(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVBD(parseResult(task.getResult(connection))); + } + + public static VBDMetrics toVBDMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVBDMetrics(parseResult(task.getResult(connection))); + } + + public static VDI toVDI(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVDI(parseResult(task.getResult(connection))); + } + + public static VGPU toVGPU(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVGPU(parseResult(task.getResult(connection))); + } + + public static VIF toVIF(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVIF(parseResult(task.getResult(connection))); + } + + public static VIFMetrics toVIFMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVIFMetrics(parseResult(task.getResult(connection))); + } + + public static VLAN toVLAN(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVLAN(parseResult(task.getResult(connection))); + } + + public static VM toVM(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVM(parseResult(task.getResult(connection))); + } + + public static VMPP toVMPP(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVMPP(parseResult(task.getResult(connection))); + } + + public static VMAppliance toVMAppliance(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVMAppliance(parseResult(task.getResult(connection))); + } + + public static VMGuestMetrics toVMGuestMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVMGuestMetrics(parseResult(task.getResult(connection))); + } + + public static VMMetrics toVMMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVMMetrics(parseResult(task.getResult(connection))); + } + + public static VTPM toVTPM(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toVTPM(parseResult(task.getResult(connection))); + } + + public static Blob toBlob(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toBlob(parseResult(task.getResult(connection))); + } + + public static Console toConsole(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toConsole(parseResult(task.getResult(connection))); + } + + public static Crashdump toCrashdump(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toCrashdump(parseResult(task.getResult(connection))); + } + + public static Host toHost(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toHost(parseResult(task.getResult(connection))); + } + + public static HostCpu toHostCpu(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toHostCpu(parseResult(task.getResult(connection))); + } + + public static HostCrashdump toHostCrashdump(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toHostCrashdump(parseResult(task.getResult(connection))); + } + + public static HostMetrics toHostMetrics(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toHostMetrics(parseResult(task.getResult(connection))); + } + + public static HostPatch toHostPatch(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toHostPatch(parseResult(task.getResult(connection))); + } + + public static Message toMessage(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toMessage(parseResult(task.getResult(connection))); + } + + public static Network toNetwork(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toNetwork(parseResult(task.getResult(connection))); + } + + public static Pool toPool(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toPool(parseResult(task.getResult(connection))); + } + + public static PoolPatch toPoolPatch(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toPoolPatch(parseResult(task.getResult(connection))); + } + + public static Role toRole(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toRole(parseResult(task.getResult(connection))); + } + + public static Secret toSecret(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toSecret(parseResult(task.getResult(connection))); + } + + public static Session toSession(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toSession(parseResult(task.getResult(connection))); + } + + public static Subject toSubject(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toSubject(parseResult(task.getResult(connection))); + } + + public static Task toTask(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toTask(parseResult(task.getResult(connection))); + } + + public static Tunnel toTunnel(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toTunnel(parseResult(task.getResult(connection))); + } + + public static User toUser(Task task, Connection connection) throws XenAPIException, BadServerResponse, XmlRpcException, BadAsyncResult{ + return Types.toUser(parseResult(task.getResult(connection))); + } + +} diff --git a/deps/XenServerJava/src/com/xensource/xenapi/User.java b/deps/XenServerJava/src/com/xensource/xenapi/User.java new file mode 100644 index 00000000000..0d2e4fd81d8 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/User.java @@ -0,0 +1,384 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A user of the system + * + * @author Citrix Systems, Inc. + */ +public class User extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + User(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a User, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof User) + { + User other = (User) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a User + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "shortName", this.shortName); + print.printf("%1$20s: %2$s\n", "fullname", this.fullname); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a user.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("short_name", this.shortName == null ? "" : this.shortName); + map.put("fullname", this.fullname == null ? "" : this.fullname); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * short name (e.g. userid) + */ + public String shortName; + /** + * full name + */ + public String fullname; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given user. + * @deprecated + * + * @return all fields from the object + */ + @Deprecated public User.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toUserRecord(result); + } + + /** + * Get a reference to the user instance with the specified UUID. + * @deprecated + * + * @param uuid UUID of object to return + * @return reference to the object + */ + @Deprecated public static User getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toUser(result); + } + + /** + * Create a new user instance, and return its handle. + * @deprecated + * + * @param record All constructor arguments + * @return Task + */ + @Deprecated public static Task createAsync(Connection c, User.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.user.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new user instance, and return its handle. + * @deprecated + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + @Deprecated public static User create(Connection c, User.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toUser(result); + } + + /** + * Destroy the specified user instance. + * @deprecated + * + * @return Task + */ + @Deprecated public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.user.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified user instance. + * @deprecated + * + */ + @Deprecated public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the uuid field of the given user. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the short_name field of the given user. + * + * @return value of the field + */ + public String getShortName(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.get_short_name"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the fullname field of the given user. + * + * @return value of the field + */ + public String getFullname(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.get_fullname"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the other_config field of the given user. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the fullname field of the given user. + * + * @param fullname New value to set + */ + public void setFullname(Connection c, String fullname) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.set_fullname"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(fullname)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given user. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given user. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given user. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "user.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VBD.java b/deps/XenServerJava/src/com/xensource/xenapi/VBD.java new file mode 100644 index 00000000000..18cbb7b488d --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VBD.java @@ -0,0 +1,1161 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A virtual block device + * + * @author Citrix Systems, Inc. + */ +public class VBD extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VBD(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VBD, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VBD) + { + VBD other = (VBD) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VBD + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "VM", this.VM); + print.printf("%1$20s: %2$s\n", "VDI", this.VDI); + print.printf("%1$20s: %2$s\n", "device", this.device); + print.printf("%1$20s: %2$s\n", "userdevice", this.userdevice); + print.printf("%1$20s: %2$s\n", "bootable", this.bootable); + print.printf("%1$20s: %2$s\n", "mode", this.mode); + print.printf("%1$20s: %2$s\n", "type", this.type); + print.printf("%1$20s: %2$s\n", "unpluggable", this.unpluggable); + print.printf("%1$20s: %2$s\n", "storageLock", this.storageLock); + print.printf("%1$20s: %2$s\n", "empty", this.empty); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); + print.printf("%1$20s: %2$s\n", "statusCode", this.statusCode); + print.printf("%1$20s: %2$s\n", "statusDetail", this.statusDetail); + print.printf("%1$20s: %2$s\n", "runtimeProperties", this.runtimeProperties); + print.printf("%1$20s: %2$s\n", "qosAlgorithmType", this.qosAlgorithmType); + print.printf("%1$20s: %2$s\n", "qosAlgorithmParams", this.qosAlgorithmParams); + print.printf("%1$20s: %2$s\n", "qosSupportedAlgorithms", this.qosSupportedAlgorithms); + print.printf("%1$20s: %2$s\n", "metrics", this.metrics); + return writer.toString(); + } + + /** + * Convert a VBD.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); + map.put("VDI", this.VDI == null ? new VDI("OpaqueRef:NULL") : this.VDI); + map.put("device", this.device == null ? "" : this.device); + map.put("userdevice", this.userdevice == null ? "" : this.userdevice); + map.put("bootable", this.bootable == null ? false : this.bootable); + map.put("mode", this.mode == null ? Types.VbdMode.UNRECOGNIZED : this.mode); + map.put("type", this.type == null ? Types.VbdType.UNRECOGNIZED : this.type); + map.put("unpluggable", this.unpluggable == null ? false : this.unpluggable); + map.put("storage_lock", this.storageLock == null ? false : this.storageLock); + map.put("empty", this.empty == null ? false : this.empty); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); + map.put("status_code", this.statusCode == null ? 0 : this.statusCode); + map.put("status_detail", this.statusDetail == null ? "" : this.statusDetail); + map.put("runtime_properties", this.runtimeProperties == null ? new HashMap() : this.runtimeProperties); + map.put("qos_algorithm_type", this.qosAlgorithmType == null ? "" : this.qosAlgorithmType); + map.put("qos_algorithm_params", this.qosAlgorithmParams == null ? new HashMap() : this.qosAlgorithmParams); + map.put("qos_supported_algorithms", this.qosSupportedAlgorithms == null ? new LinkedHashSet() : this.qosSupportedAlgorithms); + map.put("metrics", this.metrics == null ? new VBDMetrics("OpaqueRef:NULL") : this.metrics); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * the virtual machine + */ + public VM VM; + /** + * the virtual disk + */ + public VDI VDI; + /** + * device seen by the guest e.g. hda1 + */ + public String device; + /** + * user-friendly device name e.g. 0,1,2,etc. + */ + public String userdevice; + /** + * true if this VBD is bootable + */ + public Boolean bootable; + /** + * the mode the VBD should be mounted with + */ + public Types.VbdMode mode; + /** + * how the VBD will appear to the guest (e.g. disk or CD) + */ + public Types.VbdType type; + /** + * true if this VBD will support hot-unplug + */ + public Boolean unpluggable; + /** + * true if a storage level lock was acquired + */ + public Boolean storageLock; + /** + * if true this represents an empty drive + */ + public Boolean empty; + /** + * additional configuration + */ + public Map otherConfig; + /** + * is the device currently attached (erased on reboot) + */ + public Boolean currentlyAttached; + /** + * error/success code associated with last attach-operation (erased on reboot) + */ + public Long statusCode; + /** + * error/success information associated with last attach-operation status (erased on reboot) + */ + public String statusDetail; + /** + * Device runtime properties + */ + public Map runtimeProperties; + /** + * QoS algorithm to use + */ + public String qosAlgorithmType; + /** + * parameters for chosen QoS algorithm + */ + public Map qosAlgorithmParams; + /** + * supported QoS algorithms for this VBD + */ + public Set qosSupportedAlgorithms; + /** + * metrics associated with this VBD + */ + public VBDMetrics metrics; + } + + /** + * Get a record containing the current state of the given VBD. + * + * @return all fields from the object + */ + public VBD.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVBDRecord(result); + } + + /** + * Get a reference to the VBD instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VBD getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVBD(result); + } + + /** + * Create a new VBD instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, VBD.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VBD.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VBD instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static VBD create(Connection c, VBD.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVBD(result); + } + + /** + * Destroy the specified VBD instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VBD.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified VBD instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the uuid field of the given VBD. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the allowed_operations field of the given VBD. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVbdOperations(result); + } + + /** + * Get the current_operations field of the given VBD. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringVbdOperations(result); + } + + /** + * Get the VM field of the given VBD. + * + * @return value of the field + */ + public VM getVM(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_VM"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Get the VDI field of the given VBD. + * + * @return value of the field + */ + public VDI getVDI(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_VDI"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Get the device field of the given VBD. + * + * @return value of the field + */ + public String getDevice(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_device"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the userdevice field of the given VBD. + * + * @return value of the field + */ + public String getUserdevice(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_userdevice"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the bootable field of the given VBD. + * + * @return value of the field + */ + public Boolean getBootable(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_bootable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the mode field of the given VBD. + * + * @return value of the field + */ + public Types.VbdMode getMode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVbdMode(result); + } + + /** + * Get the type field of the given VBD. + * + * @return value of the field + */ + public Types.VbdType getType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVbdType(result); + } + + /** + * Get the unpluggable field of the given VBD. + * + * @return value of the field + */ + public Boolean getUnpluggable(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_unpluggable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the storage_lock field of the given VBD. + * + * @return value of the field + */ + public Boolean getStorageLock(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_storage_lock"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the empty field of the given VBD. + * + * @return value of the field + */ + public Boolean getEmpty(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_empty"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the other_config field of the given VBD. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the currently_attached field of the given VBD. + * + * @return value of the field + */ + public Boolean getCurrentlyAttached(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_currently_attached"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the status_code field of the given VBD. + * + * @return value of the field + */ + public Long getStatusCode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_status_code"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the status_detail field of the given VBD. + * + * @return value of the field + */ + public String getStatusDetail(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_status_detail"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the runtime_properties field of the given VBD. + * + * @return value of the field + */ + public Map getRuntimeProperties(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_runtime_properties"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the qos/algorithm_type field of the given VBD. + * + * @return value of the field + */ + public String getQosAlgorithmType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_qos_algorithm_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the qos/algorithm_params field of the given VBD. + * + * @return value of the field + */ + public Map getQosAlgorithmParams(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_qos_algorithm_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the qos/supported_algorithms field of the given VBD. + * + * @return value of the field + */ + public Set getQosSupportedAlgorithms(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_qos_supported_algorithms"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the metrics field of the given VBD. + * + * @return value of the field + */ + public VBDMetrics getMetrics(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_metrics"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVBDMetrics(result); + } + + /** + * Set the userdevice field of the given VBD. + * + * @param userdevice New value to set + */ + public void setUserdevice(Connection c, String userdevice) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.set_userdevice"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(userdevice)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the bootable field of the given VBD. + * + * @param bootable New value to set + */ + public void setBootable(Connection c, Boolean bootable) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.set_bootable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootable)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the mode field of the given VBD. + * + * @param mode New value to set + */ + public void setMode(Connection c, Types.VbdMode mode) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.set_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(mode)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the type field of the given VBD. + * + * @param type New value to set + */ + public void setType(Connection c, Types.VbdType type) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.set_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(type)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the unpluggable field of the given VBD. + * + * @param unpluggable New value to set + */ + public void setUnpluggable(Connection c, Boolean unpluggable) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.set_unpluggable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(unpluggable)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given VBD. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VBD. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VBD. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the qos/algorithm_type field of the given VBD. + * + * @param algorithmType New value to set + */ + public void setQosAlgorithmType(Connection c, String algorithmType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.set_qos_algorithm_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(algorithmType)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the qos/algorithm_params field of the given VBD. + * + * @param algorithmParams New value to set + */ + public void setQosAlgorithmParams(Connection c, Map algorithmParams) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.set_qos_algorithm_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(algorithmParams)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the qos/algorithm_params field of the given VBD. + * + * @param key Key to add + * @param value Value to add + */ + public void addToQosAlgorithmParams(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.add_to_qos_algorithm_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the qos/algorithm_params field of the given VBD. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromQosAlgorithmParams(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.remove_from_qos_algorithm_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the media from the device and leave it empty + * + * @return Task + */ + public Task ejectAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VbdNotRemovableMedia, + Types.VbdIsEmpty { + String method_call = "Async.VBD.eject"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Remove the media from the device and leave it empty + * + */ + public void eject(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VbdNotRemovableMedia, + Types.VbdIsEmpty { + String method_call = "VBD.eject"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Insert new media into the device + * + * @param vdi The new VDI to 'insert' + * @return Task + */ + public Task insertAsync(Connection c, VDI vdi) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VbdNotRemovableMedia, + Types.VbdNotEmpty { + String method_call = "Async.VBD.insert"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(vdi)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Insert new media into the device + * + * @param vdi The new VDI to 'insert' + */ + public void insert(Connection c, VDI vdi) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VbdNotRemovableMedia, + Types.VbdNotEmpty { + String method_call = "VBD.insert"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(vdi)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Hotplug the specified VBD, dynamically attaching it to the running VM + * + * @return Task + */ + public Task plugAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VBD.plug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Hotplug the specified VBD, dynamically attaching it to the running VM + * + */ + public void plug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.plug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Hot-unplug the specified VBD, dynamically unattaching it from the running VM + * + * @return Task + */ + public Task unplugAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.DeviceDetachRejected, + Types.DeviceAlreadyDetached { + String method_call = "Async.VBD.unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Hot-unplug the specified VBD, dynamically unattaching it from the running VM + * + */ + public void unplug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.DeviceDetachRejected, + Types.DeviceAlreadyDetached { + String method_call = "VBD.unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Forcibly unplug the specified VBD + * + * @return Task + */ + public Task unplugForceAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VBD.unplug_force"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Forcibly unplug the specified VBD + * + */ + public void unplugForce(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.unplug_force"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Throws an error if this VBD could not be attached to this VM if the VM were running. Intended for debugging. + * + * @return Task + */ + public Task assertAttachableAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VBD.assert_attachable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Throws an error if this VBD could not be attached to this VM if the VM were running. Intended for debugging. + * + */ + public void assertAttachable(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.assert_attachable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VBDs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVBD(result); + } + + /** + * Return a map of VBD references to VBD records for all VBDs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVBDVBDRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java new file mode 100644 index 00000000000..adb6bb513de --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java @@ -0,0 +1,349 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * The metrics associated with a virtual block device + * + * @author Citrix Systems, Inc. + */ +public class VBDMetrics extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VBDMetrics(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VBDMetrics, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VBDMetrics) + { + VBDMetrics other = (VBDMetrics) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VBDMetrics + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs); + print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs); + print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a VBD_metrics.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs); + map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs); + map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Read bandwidth (KiB/s) + */ + public Double ioReadKbs; + /** + * Write bandwidth (KiB/s) + */ + public Double ioWriteKbs; + /** + * Time at which this information was last updated + */ + public Date lastUpdated; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given VBD_metrics. + * + * @return all fields from the object + */ + public VBDMetrics.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVBDMetricsRecord(result); + } + + /** + * Get a reference to the VBD_metrics instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VBDMetrics getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVBDMetrics(result); + } + + /** + * Get the uuid field of the given VBD_metrics. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the io/read_kbs field of the given VBD_metrics. + * + * @return value of the field + */ + public Double getIoReadKbs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_io_read_kbs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the io/write_kbs field of the given VBD_metrics. + * + * @return value of the field + */ + public Double getIoWriteKbs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_io_write_kbs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the last_updated field of the given VBD_metrics. + * + * @return value of the field + */ + public Date getLastUpdated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_last_updated"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the other_config field of the given VBD_metrics. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given VBD_metrics. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VBD_metrics. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VBD_metrics. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VBD_metrics instances known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVBDMetrics(result); + } + + /** + * Return a map of VBD_metrics references to VBD_metrics records for all VBD_metrics instances known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VBD_metrics.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVBDMetricsVBDMetricsRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VDI.java b/deps/XenServerJava/src/com/xensource/xenapi/VDI.java new file mode 100644 index 00000000000..4ea9daff1fa --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VDI.java @@ -0,0 +1,2100 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A virtual disk image + * + * @author Citrix Systems, Inc. + */ +public class VDI extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VDI(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VDI, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VDI) + { + VDI other = (VDI) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VDI + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "SR", this.SR); + print.printf("%1$20s: %2$s\n", "VBDs", this.VBDs); + print.printf("%1$20s: %2$s\n", "crashDumps", this.crashDumps); + print.printf("%1$20s: %2$s\n", "virtualSize", this.virtualSize); + print.printf("%1$20s: %2$s\n", "physicalUtilisation", this.physicalUtilisation); + print.printf("%1$20s: %2$s\n", "type", this.type); + print.printf("%1$20s: %2$s\n", "sharable", this.sharable); + print.printf("%1$20s: %2$s\n", "readOnly", this.readOnly); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "storageLock", this.storageLock); + print.printf("%1$20s: %2$s\n", "location", this.location); + print.printf("%1$20s: %2$s\n", "managed", this.managed); + print.printf("%1$20s: %2$s\n", "missing", this.missing); + print.printf("%1$20s: %2$s\n", "parent", this.parent); + print.printf("%1$20s: %2$s\n", "xenstoreData", this.xenstoreData); + print.printf("%1$20s: %2$s\n", "smConfig", this.smConfig); + print.printf("%1$20s: %2$s\n", "isASnapshot", this.isASnapshot); + print.printf("%1$20s: %2$s\n", "snapshotOf", this.snapshotOf); + print.printf("%1$20s: %2$s\n", "snapshots", this.snapshots); + print.printf("%1$20s: %2$s\n", "snapshotTime", this.snapshotTime); + print.printf("%1$20s: %2$s\n", "tags", this.tags); + print.printf("%1$20s: %2$s\n", "allowCaching", this.allowCaching); + print.printf("%1$20s: %2$s\n", "onBoot", this.onBoot); + print.printf("%1$20s: %2$s\n", "metadataOfPool", this.metadataOfPool); + print.printf("%1$20s: %2$s\n", "metadataLatest", this.metadataLatest); + return writer.toString(); + } + + /** + * Convert a VDI.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("SR", this.SR == null ? new SR("OpaqueRef:NULL") : this.SR); + map.put("VBDs", this.VBDs == null ? new LinkedHashSet() : this.VBDs); + map.put("crash_dumps", this.crashDumps == null ? new LinkedHashSet() : this.crashDumps); + map.put("virtual_size", this.virtualSize == null ? 0 : this.virtualSize); + map.put("physical_utilisation", this.physicalUtilisation == null ? 0 : this.physicalUtilisation); + map.put("type", this.type == null ? Types.VdiType.UNRECOGNIZED : this.type); + map.put("sharable", this.sharable == null ? false : this.sharable); + map.put("read_only", this.readOnly == null ? false : this.readOnly); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("storage_lock", this.storageLock == null ? false : this.storageLock); + map.put("location", this.location == null ? "" : this.location); + map.put("managed", this.managed == null ? false : this.managed); + map.put("missing", this.missing == null ? false : this.missing); + map.put("parent", this.parent == null ? new VDI("OpaqueRef:NULL") : this.parent); + map.put("xenstore_data", this.xenstoreData == null ? new HashMap() : this.xenstoreData); + map.put("sm_config", this.smConfig == null ? new HashMap() : this.smConfig); + map.put("is_a_snapshot", this.isASnapshot == null ? false : this.isASnapshot); + map.put("snapshot_of", this.snapshotOf == null ? new VDI("OpaqueRef:NULL") : this.snapshotOf); + map.put("snapshots", this.snapshots == null ? new LinkedHashSet() : this.snapshots); + map.put("snapshot_time", this.snapshotTime == null ? new Date(0) : this.snapshotTime); + map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); + map.put("allow_caching", this.allowCaching == null ? false : this.allowCaching); + map.put("on_boot", this.onBoot == null ? Types.OnBoot.UNRECOGNIZED : this.onBoot); + map.put("metadata_of_pool", this.metadataOfPool == null ? new Pool("OpaqueRef:NULL") : this.metadataOfPool); + map.put("metadata_latest", this.metadataLatest == null ? false : this.metadataLatest); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * storage repository in which the VDI resides + */ + public SR SR; + /** + * list of vbds that refer to this disk + */ + public Set VBDs; + /** + * list of crash dumps that refer to this disk + */ + public Set crashDumps; + /** + * size of disk as presented to the guest (in bytes). Note that, depending on storage backend type, requested size may not be respected exactly + */ + public Long virtualSize; + /** + * amount of physical space that the disk image is currently taking up on the storage repository (in bytes) + */ + public Long physicalUtilisation; + /** + * type of the VDI + */ + public Types.VdiType type; + /** + * true if this disk may be shared + */ + public Boolean sharable; + /** + * true if this disk may ONLY be mounted read-only + */ + public Boolean readOnly; + /** + * additional configuration + */ + public Map otherConfig; + /** + * true if this disk is locked at the storage level + */ + public Boolean storageLock; + /** + * location information + */ + public String location; + /** + * + */ + public Boolean managed; + /** + * true if SR scan operation reported this VDI as not present on disk + */ + public Boolean missing; + /** + * References the parent disk, if this VDI is part of a chain + */ + public VDI parent; + /** + * data to be inserted into the xenstore tree (/local/domain/0/backend/vbd///sm-data) after the VDI is attached. This is generally set by the SM backends on vdi_attach. + */ + public Map xenstoreData; + /** + * SM dependent data + */ + public Map smConfig; + /** + * true if this is a snapshot. + */ + public Boolean isASnapshot; + /** + * Ref pointing to the VDI this snapshot is of. + */ + public VDI snapshotOf; + /** + * List pointing to all the VDIs snapshots. + */ + public Set snapshots; + /** + * Date/time when this snapshot was created. + */ + public Date snapshotTime; + /** + * user-specified tags for categorization purposes + */ + public Set tags; + /** + * true if this VDI is to be cached in the local cache SR + */ + public Boolean allowCaching; + /** + * The behaviour of this VDI on a VM boot + */ + public Types.OnBoot onBoot; + /** + * The pool whose metadata is contained in this VDI + */ + public Pool metadataOfPool; + /** + * Whether this VDI contains the latest known accessible metadata for the pool + */ + public Boolean metadataLatest; + } + + /** + * Get a record containing the current state of the given VDI. + * + * @return all fields from the object + */ + public VDI.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDIRecord(result); + } + + /** + * Get a reference to the VDI instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VDI getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Create a new VDI instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, VDI.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VDI instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static VDI create(Connection c, VDI.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Destroy the specified VDI instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified VDI instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get all the VDI instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVDI(result); + } + + /** + * Get the uuid field of the given VDI. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given VDI. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given VDI. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the allowed_operations field of the given VDI. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVdiOperations(result); + } + + /** + * Get the current_operations field of the given VDI. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringVdiOperations(result); + } + + /** + * Get the SR field of the given VDI. + * + * @return value of the field + */ + public SR getSR(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the VBDs field of the given VDI. + * + * @return value of the field + */ + public Set getVBDs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_VBDs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVBD(result); + } + + /** + * Get the crash_dumps field of the given VDI. + * + * @return value of the field + */ + public Set getCrashDumps(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_crash_dumps"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfCrashdump(result); + } + + /** + * Get the virtual_size field of the given VDI. + * + * @return value of the field + */ + public Long getVirtualSize(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_virtual_size"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the physical_utilisation field of the given VDI. + * + * @return value of the field + */ + public Long getPhysicalUtilisation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_physical_utilisation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the type field of the given VDI. + * + * @return value of the field + */ + public Types.VdiType getType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVdiType(result); + } + + /** + * Get the sharable field of the given VDI. + * + * @return value of the field + */ + public Boolean getSharable(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_sharable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the read_only field of the given VDI. + * + * @return value of the field + */ + public Boolean getReadOnly(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_read_only"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the other_config field of the given VDI. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the storage_lock field of the given VDI. + * + * @return value of the field + */ + public Boolean getStorageLock(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_storage_lock"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the location field of the given VDI. + * + * @return value of the field + */ + public String getLocation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_location"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the managed field of the given VDI. + * + * @return value of the field + */ + public Boolean getManaged(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_managed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the missing field of the given VDI. + * + * @return value of the field + */ + public Boolean getMissing(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_missing"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the parent field of the given VDI. + * + * @return value of the field + */ + public VDI getParent(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_parent"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Get the xenstore_data field of the given VDI. + * + * @return value of the field + */ + public Map getXenstoreData(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_xenstore_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the sm_config field of the given VDI. + * + * @return value of the field + */ + public Map getSmConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_sm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the is_a_snapshot field of the given VDI. + * + * @return value of the field + */ + public Boolean getIsASnapshot(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_is_a_snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the snapshot_of field of the given VDI. + * + * @return value of the field + */ + public VDI getSnapshotOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_snapshot_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Get the snapshots field of the given VDI. + * + * @return value of the field + */ + public Set getSnapshots(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_snapshots"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVDI(result); + } + + /** + * Get the snapshot_time field of the given VDI. + * + * @return value of the field + */ + public Date getSnapshotTime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_snapshot_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the tags field of the given VDI. + * + * @return value of the field + */ + public Set getTags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the allow_caching field of the given VDI. + * + * @return value of the field + */ + public Boolean getAllowCaching(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_allow_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the on_boot field of the given VDI. + * + * @return value of the field + */ + public Types.OnBoot getOnBoot(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_on_boot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toOnBoot(result); + } + + /** + * Get the metadata_of_pool field of the given VDI. + * + * @return value of the field + */ + public Pool getMetadataOfPool(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_metadata_of_pool"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPool(result); + } + + /** + * Get the metadata_latest field of the given VDI. + * + * @return value of the field + */ + public Boolean getMetadataLatest(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_metadata_latest"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Set the other_config field of the given VDI. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VDI. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VDI. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the xenstore_data field of the given VDI. + * + * @param xenstoreData New value to set + */ + public void setXenstoreData(Connection c, Map xenstoreData) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_xenstore_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(xenstoreData)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the xenstore_data field of the given VDI. + * + * @param key Key to add + * @param value Value to add + */ + public void addToXenstoreData(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.add_to_xenstore_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the xenstore_data field of the given VDI. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromXenstoreData(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.remove_from_xenstore_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the sm_config field of the given VDI. + * + * @param smConfig New value to set + */ + public void setSmConfig(Connection c, Map smConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_sm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(smConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the sm_config field of the given VDI. + * + * @param key Key to add + * @param value Value to add + */ + public void addToSmConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.add_to_sm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the sm_config field of the given VDI. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromSmConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.remove_from_sm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the tags field of the given VDI. + * + * @param tags New value to set + */ + public void setTags(Connection c, Set tags) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given value to the tags field of the given VDI. If the value is already in that Set, then do nothing. + * + * @param value New value to add + */ + public void addTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.add_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given value from the tags field of the given VDI. If the value is not in that Set, then do nothing. + * + * @param value Value to remove + */ + public void removeTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.remove_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Take a read-only snapshot of the VDI, returning a reference to the snapshot. If any driver_params are specified then these are passed through to the storage-specific substrate driver that takes the snapshot. NB the snapshot lives in the same Storage Repository as its parent. + * + * @param driverParams Optional parameters that can be passed through to backend driver in order to specify storage-type-specific snapshot options + * @return Task + */ + public Task snapshotAsync(Connection c, Map driverParams) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException { + + if(c.rioConnection){ + if (driverParams.isEmpty()){ + return rioSnapshotAsync(c); + } else { + throw new Types.VersionException("driverParams parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiSnapshotAsync(c, driverParams); + } + } + + + + private Task rioSnapshotAsync(Connection c) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "Async.VDI.snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + private Task miamiSnapshotAsync(Connection c, Map driverParams) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "Async.VDI.snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(driverParams)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Take a read-only snapshot of the VDI, returning a reference to the snapshot. If any driver_params are specified then these are passed through to the storage-specific substrate driver that takes the snapshot. NB the snapshot lives in the same Storage Repository as its parent. + * + * @param driverParams Optional parameters that can be passed through to backend driver in order to specify storage-type-specific snapshot options + * @return The ID of the newly created VDI. + */ + public VDI snapshot(Connection c, Map driverParams) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException { + + if(c.rioConnection){ + if (driverParams.isEmpty()){ + return rioSnapshot(c); + } else { + throw new Types.VersionException("driverParams parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiSnapshot(c, driverParams); + } + } + + + + private VDI rioSnapshot(Connection c) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "VDI.snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + private VDI miamiSnapshot(Connection c, Map driverParams) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "VDI.snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(driverParams)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Take an exact copy of the VDI and return a reference to the new disk. If any driver_params are specified then these are passed through to the storage-specific substrate driver that implements the clone operation. NB the clone lives in the same Storage Repository as its parent. + * + * @param driverParams Optional parameters that are passed through to the backend driver in order to specify storage-type-specific clone options + * @return Task + */ + public Task createCloneAsync(Connection c, Map driverParams) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException { + + if(c.rioConnection){ + if (driverParams.isEmpty()){ + return rioCreateCloneAsync(c); + } else { + throw new Types.VersionException("driverParams parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiCreateCloneAsync(c, driverParams); + } + } + + + + private Task rioCreateCloneAsync(Connection c) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "Async.VDI.clone"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + private Task miamiCreateCloneAsync(Connection c, Map driverParams) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "Async.VDI.clone"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(driverParams)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Take an exact copy of the VDI and return a reference to the new disk. If any driver_params are specified then these are passed through to the storage-specific substrate driver that implements the clone operation. NB the clone lives in the same Storage Repository as its parent. + * + * @param driverParams Optional parameters that are passed through to the backend driver in order to specify storage-type-specific clone options + * @return The ID of the newly created VDI. + */ + public VDI createClone(Connection c, Map driverParams) throws + BadServerResponse, + VersionException, + XenAPIException, + XmlRpcException { + + if(c.rioConnection){ + if (driverParams.isEmpty()){ + return rioCreateClone(c); + } else { + throw new Types.VersionException("driverParams parameter must be empty map for Rio (legacy XenServer) host"); + } + } else { + return miamiCreateClone(c, driverParams); + } + } + + + + private VDI rioCreateClone(Connection c) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "VDI.clone"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + private VDI miamiCreateClone(Connection c, Map driverParams) throws + BadServerResponse, + XmlRpcException, + XenAPIException { + String method_call = "VDI.clone"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(driverParams)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Resize the VDI. + * + * @param size The new size of the VDI + * @return Task + */ + public Task resizeAsync(Connection c, Long size) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.resize"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(size)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Resize the VDI. + * + * @param size The new size of the VDI + */ + public void resize(Connection c, Long size) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.resize"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(size)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Resize the VDI which may or may not be attached to running guests. + * + * @param size The new size of the VDI + * @return Task + */ + public Task resizeOnlineAsync(Connection c, Long size) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.resize_online"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(size)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Resize the VDI which may or may not be attached to running guests. + * + * @param size The new size of the VDI + */ + public void resizeOnline(Connection c, Long size) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.resize_online"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(size)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a new VDI record in the database only + * + * @param uuid The uuid of the disk to introduce + * @param nameLabel The name of the disk record + * @param nameDescription The description of the disk record + * @param SR The SR that the VDI is in + * @param type The type of the VDI + * @param sharable true if this disk may be shared + * @param readOnly true if this disk may ONLY be mounted read-only + * @param otherConfig additional configuration + * @param location location information + * @param xenstoreData Data to insert into xenstore + * @param smConfig Storage-specific config + * @param managed Storage-specific config + * @param virtualSize Storage-specific config + * @param physicalUtilisation Storage-specific config + * @param metadataOfPool Storage-specific config + * @param isASnapshot Storage-specific config + * @param snapshotTime Storage-specific config + * @param snapshotOf Storage-specific config + * @return Task + */ + public static Task introduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, SR SR, Types.VdiType type, Boolean sharable, Boolean readOnly, Map otherConfig, String location, Map xenstoreData, Map smConfig, Boolean managed, Long virtualSize, Long physicalUtilisation, Pool metadataOfPool, Boolean isASnapshot, Date snapshotTime, VDI snapshotOf) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrOperationNotSupported { + String method_call = "Async.VDI.introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(SR), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(sharable), Marshalling.toXMLRPC(readOnly), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(location), Marshalling.toXMLRPC(xenstoreData), Marshalling.toXMLRPC(smConfig), Marshalling.toXMLRPC(managed), Marshalling.toXMLRPC(virtualSize), Marshalling.toXMLRPC(physicalUtilisation), Marshalling.toXMLRPC(metadataOfPool), Marshalling.toXMLRPC(isASnapshot), Marshalling.toXMLRPC(snapshotTime), Marshalling.toXMLRPC(snapshotOf)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VDI record in the database only + * + * @param uuid The uuid of the disk to introduce + * @param nameLabel The name of the disk record + * @param nameDescription The description of the disk record + * @param SR The SR that the VDI is in + * @param type The type of the VDI + * @param sharable true if this disk may be shared + * @param readOnly true if this disk may ONLY be mounted read-only + * @param otherConfig additional configuration + * @param location location information + * @param xenstoreData Data to insert into xenstore + * @param smConfig Storage-specific config + * @param managed Storage-specific config + * @param virtualSize Storage-specific config + * @param physicalUtilisation Storage-specific config + * @param metadataOfPool Storage-specific config + * @param isASnapshot Storage-specific config + * @param snapshotTime Storage-specific config + * @param snapshotOf Storage-specific config + * @return The ref of the newly created VDI record. + */ + public static VDI introduce(Connection c, String uuid, String nameLabel, String nameDescription, SR SR, Types.VdiType type, Boolean sharable, Boolean readOnly, Map otherConfig, String location, Map xenstoreData, Map smConfig, Boolean managed, Long virtualSize, Long physicalUtilisation, Pool metadataOfPool, Boolean isASnapshot, Date snapshotTime, VDI snapshotOf) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrOperationNotSupported { + String method_call = "VDI.introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(SR), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(sharable), Marshalling.toXMLRPC(readOnly), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(location), Marshalling.toXMLRPC(xenstoreData), Marshalling.toXMLRPC(smConfig), Marshalling.toXMLRPC(managed), Marshalling.toXMLRPC(virtualSize), Marshalling.toXMLRPC(physicalUtilisation), Marshalling.toXMLRPC(metadataOfPool), Marshalling.toXMLRPC(isASnapshot), Marshalling.toXMLRPC(snapshotTime), Marshalling.toXMLRPC(snapshotOf)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Create a new VDI record in the database only + * + * @param uuid The uuid of the disk to introduce + * @param nameLabel The name of the disk record + * @param nameDescription The description of the disk record + * @param SR The SR that the VDI is in + * @param type The type of the VDI + * @param sharable true if this disk may be shared + * @param readOnly true if this disk may ONLY be mounted read-only + * @param otherConfig additional configuration + * @param location location information + * @param xenstoreData Data to insert into xenstore + * @param smConfig Storage-specific config + * @param managed Storage-specific config + * @param virtualSize Storage-specific config + * @param physicalUtilisation Storage-specific config + * @param metadataOfPool Storage-specific config + * @param isASnapshot Storage-specific config + * @param snapshotTime Storage-specific config + * @param snapshotOf Storage-specific config + * @return Task + */ + public static Task dbIntroduceAsync(Connection c, String uuid, String nameLabel, String nameDescription, SR SR, Types.VdiType type, Boolean sharable, Boolean readOnly, Map otherConfig, String location, Map xenstoreData, Map smConfig, Boolean managed, Long virtualSize, Long physicalUtilisation, Pool metadataOfPool, Boolean isASnapshot, Date snapshotTime, VDI snapshotOf) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.db_introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(SR), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(sharable), Marshalling.toXMLRPC(readOnly), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(location), Marshalling.toXMLRPC(xenstoreData), Marshalling.toXMLRPC(smConfig), Marshalling.toXMLRPC(managed), Marshalling.toXMLRPC(virtualSize), Marshalling.toXMLRPC(physicalUtilisation), Marshalling.toXMLRPC(metadataOfPool), Marshalling.toXMLRPC(isASnapshot), Marshalling.toXMLRPC(snapshotTime), Marshalling.toXMLRPC(snapshotOf)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VDI record in the database only + * + * @param uuid The uuid of the disk to introduce + * @param nameLabel The name of the disk record + * @param nameDescription The description of the disk record + * @param SR The SR that the VDI is in + * @param type The type of the VDI + * @param sharable true if this disk may be shared + * @param readOnly true if this disk may ONLY be mounted read-only + * @param otherConfig additional configuration + * @param location location information + * @param xenstoreData Data to insert into xenstore + * @param smConfig Storage-specific config + * @param managed Storage-specific config + * @param virtualSize Storage-specific config + * @param physicalUtilisation Storage-specific config + * @param metadataOfPool Storage-specific config + * @param isASnapshot Storage-specific config + * @param snapshotTime Storage-specific config + * @param snapshotOf Storage-specific config + * @return The ref of the newly created VDI record. + */ + public static VDI dbIntroduce(Connection c, String uuid, String nameLabel, String nameDescription, SR SR, Types.VdiType type, Boolean sharable, Boolean readOnly, Map otherConfig, String location, Map xenstoreData, Map smConfig, Boolean managed, Long virtualSize, Long physicalUtilisation, Pool metadataOfPool, Boolean isASnapshot, Date snapshotTime, VDI snapshotOf) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.db_introduce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid), Marshalling.toXMLRPC(nameLabel), Marshalling.toXMLRPC(nameDescription), Marshalling.toXMLRPC(SR), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(sharable), Marshalling.toXMLRPC(readOnly), Marshalling.toXMLRPC(otherConfig), Marshalling.toXMLRPC(location), Marshalling.toXMLRPC(xenstoreData), Marshalling.toXMLRPC(smConfig), Marshalling.toXMLRPC(managed), Marshalling.toXMLRPC(virtualSize), Marshalling.toXMLRPC(physicalUtilisation), Marshalling.toXMLRPC(metadataOfPool), Marshalling.toXMLRPC(isASnapshot), Marshalling.toXMLRPC(snapshotTime), Marshalling.toXMLRPC(snapshotOf)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Removes a VDI record from the database + * + * @return Task + */ + public Task dbForgetAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.db_forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removes a VDI record from the database + * + */ + public void dbForget(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.db_forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Ask the storage backend to refresh the fields in the VDI object + * + * @return Task + */ + public Task updateAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrOperationNotSupported { + String method_call = "Async.VDI.update"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Ask the storage backend to refresh the fields in the VDI object + * + */ + public void update(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.SrOperationNotSupported { + String method_call = "VDI.update"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Make a fresh VDI in the specified SR and copy the supplied VDI's data to the new disk + * + * @param sr The destination SR + * @return Task + */ + public Task copyAsync(Connection c, SR sr) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.copy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Make a fresh VDI in the specified SR and copy the supplied VDI's data to the new disk + * + * @param sr The destination SR + * @return The reference of the newly created VDI. + */ + public VDI copy(Connection c, SR sr) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.copy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Sets the VDI's managed field + * + * @param value The new value of the VDI's managed field + */ + public void setManaged(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_managed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Removes a VDI record from the database + * + * @return Task + */ + public Task forgetAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removes a VDI record from the database + * + */ + public void forget(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.forget"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the VDI's sharable field + * + * @param value The new value of the VDI's sharable field + */ + public void setSharable(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_sharable"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the VDI's read_only field + * + * @param value The new value of the VDI's read_only field + */ + public void setReadOnly(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_read_only"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the VDI's missing field + * + * @param value The new value of the VDI's missing field + */ + public void setMissing(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_missing"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the VDI's virtual_size field + * + * @param value The new value of the VDI's virtual size + */ + public void setVirtualSize(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_virtual_size"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the VDI's physical_utilisation field + * + * @param value The new value of the VDI's physical utilisation + */ + public void setPhysicalUtilisation(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_physical_utilisation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets whether this VDI is a snapshot + * + * @param value The new value indicating whether this VDI is a snapshot + */ + public void setIsASnapshot(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_is_a_snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the VDI of which this VDI is a snapshot + * + * @param value The VDI of which this VDI is a snapshot + */ + public void setSnapshotOf(Connection c, VDI value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_snapshot_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Sets the snapshot time of this VDI. + * + * @param value The snapshot time of this VDI. + */ + public void setSnapshotTime(Connection c, Date value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_snapshot_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Records the pool whose metadata is contained by this VDI. + * + * @param value The pool whose metadata is contained by this VDI + */ + public void setMetadataOfPool(Connection c, Pool value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_metadata_of_pool"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name label of the VDI. This can only happen when then its SR is currently attached. + * + * @param value The name lable for the VDI + * @return Task + */ + public Task setNameLabelAsync(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the name label of the VDI. This can only happen when then its SR is currently attached. + * + * @param value The name lable for the VDI + */ + public void setNameLabel(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name description of the VDI. This can only happen when its SR is currently attached. + * + * @param value The name description for the VDI + * @return Task + */ + public Task setNameDescriptionAsync(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the name description of the VDI. This can only happen when its SR is currently attached. + * + * @param value The name description for the VDI + */ + public void setNameDescription(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the on_boot parameter. This value can only be changed when the VDI is not attached to a running VM. + * + * @param value The value to set + * @return Task + */ + public Task setOnBootAsync(Connection c, Types.OnBoot value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.set_on_boot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the value of the on_boot parameter. This value can only be changed when the VDI is not attached to a running VM. + * + * @param value The value to set + */ + public void setOnBoot(Connection c, Types.OnBoot value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_on_boot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the allow_caching parameter. This value can only be changed when the VDI is not attached to a running VM. The caching behaviour is only affected by this flag for VHD-based VDIs that have one parent and no child VHDs. Moreover, caching only takes place when the host running the VM containing this VDI has a nominated SR for local caching. + * + * @param value The value to set + * @return Task + */ + public Task setAllowCachingAsync(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.set_allow_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the value of the allow_caching parameter. This value can only be changed when the VDI is not attached to a running VM. The caching behaviour is only affected by this flag for VHD-based VDIs that have one parent and no child VHDs. Moreover, caching only takes place when the host running the VM containing this VDI has a nominated SR for local caching. + * + * @param value The value to set + */ + public void setAllowCaching(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.set_allow_caching"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Load the metadata found on the supplied VDI and return a session reference which can be used in XenAPI calls to query its contents. + * + * @return Task + */ + public Task openDatabaseAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.open_database"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Load the metadata found on the supplied VDI and return a session reference which can be used in XenAPI calls to query its contents. + * + * @return A session which can be used to query the database + */ + public Session openDatabase(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.open_database"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSession(result); + } + + /** + * Check the VDI cache for the pool UUID of the database on this VDI. + * + * @return Task + */ + public Task readDatabasePoolUuidAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.read_database_pool_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Check the VDI cache for the pool UUID of the database on this VDI. + * + * @return The cached pool UUID of the database on the VDI. + */ + public String readDatabasePoolUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.read_database_pool_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Migrate a VDI, which may be attached to a running guest, to a different SR. The destination SR must be visible to the guest. + * + * @param sr The destination SR + * @param options Other parameters + * @return Task + */ + public Task poolMigrateAsync(Connection c, SR sr, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VDI.pool_migrate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Migrate a VDI, which may be attached to a running guest, to a different SR. The destination SR must be visible to the guest. + * + * @param sr The destination SR + * @param options Other parameters + * @return The new reference of the migrated VDI. + */ + public VDI poolMigrate(Connection c, SR sr, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.pool_migrate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Return a list of all the VDIs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVDI(result); + } + + /** + * Return a map of VDI references to VDI records for all VDIs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VDI.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVDIVDIRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VGPU.java b/deps/XenServerJava/src/com/xensource/xenapi/VGPU.java new file mode 100644 index 00000000000..075ab54757c --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VGPU.java @@ -0,0 +1,446 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A virtual GPU (vGPU) + * + * @author Citrix Systems, Inc. + */ +public class VGPU extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VGPU(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VGPU, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VGPU) + { + VGPU other = (VGPU) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VGPU + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "VM", this.VM); + print.printf("%1$20s: %2$s\n", "GPUGroup", this.GPUGroup); + print.printf("%1$20s: %2$s\n", "device", this.device); + print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a VGPU.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); + map.put("GPU_group", this.GPUGroup == null ? new GPUGroup("OpaqueRef:NULL") : this.GPUGroup); + map.put("device", this.device == null ? "" : this.device); + map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * VM that owns the vGPU + */ + public VM VM; + /** + * GPU group used by the vGPU + */ + public GPUGroup GPUGroup; + /** + * Order in which the devices are plugged into the VM + */ + public String device; + /** + * Reflects whether the virtual device is currently connected to a physical device + */ + public Boolean currentlyAttached; + /** + * Additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given VGPU. + * + * @return all fields from the object + */ + public VGPU.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVGPURecord(result); + } + + /** + * Get a reference to the VGPU instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VGPU getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVGPU(result); + } + + /** + * Get the uuid field of the given VGPU. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the VM field of the given VGPU. + * + * @return value of the field + */ + public VM getVM(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_VM"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Get the GPU_group field of the given VGPU. + * + * @return value of the field + */ + public GPUGroup getGPUGroup(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_GPU_group"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toGPUGroup(result); + } + + /** + * Get the device field of the given VGPU. + * + * @return value of the field + */ + public String getDevice(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_device"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the currently_attached field of the given VGPU. + * + * @return value of the field + */ + public Boolean getCurrentlyAttached(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_currently_attached"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the other_config field of the given VGPU. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given VGPU. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VGPU. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VGPU. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param VM + * @param GPUGroup + * @param device + * @param otherConfig + * @return Task + */ + public static Task createAsync(Connection c, VM VM, GPUGroup GPUGroup, String device, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VGPU.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(VM), Marshalling.toXMLRPC(GPUGroup), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * + * + * @param VM + * @param GPUGroup + * @param device + * @param otherConfig + * @return reference to the newly created object + */ + public static VGPU create(Connection c, VM VM, GPUGroup GPUGroup, String device, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(VM), Marshalling.toXMLRPC(GPUGroup), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVGPU(result); + } + + /** + * + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VGPU.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VGPUs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVGPU(result); + } + + /** + * Return a map of VGPU references to VGPU records for all VGPUs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VGPU.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVGPUVGPURecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VIF.java b/deps/XenServerJava/src/com/xensource/xenapi/VIF.java new file mode 100644 index 00000000000..c1d25b445ac --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VIF.java @@ -0,0 +1,1186 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A virtual network interface + * + * @author Citrix Systems, Inc. + */ +public class VIF extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VIF(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VIF, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VIF) + { + VIF other = (VIF) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VIF + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "device", this.device); + print.printf("%1$20s: %2$s\n", "network", this.network); + print.printf("%1$20s: %2$s\n", "VM", this.VM); + print.printf("%1$20s: %2$s\n", "MAC", this.MAC); + print.printf("%1$20s: %2$s\n", "MTU", this.MTU); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached); + print.printf("%1$20s: %2$s\n", "statusCode", this.statusCode); + print.printf("%1$20s: %2$s\n", "statusDetail", this.statusDetail); + print.printf("%1$20s: %2$s\n", "runtimeProperties", this.runtimeProperties); + print.printf("%1$20s: %2$s\n", "qosAlgorithmType", this.qosAlgorithmType); + print.printf("%1$20s: %2$s\n", "qosAlgorithmParams", this.qosAlgorithmParams); + print.printf("%1$20s: %2$s\n", "qosSupportedAlgorithms", this.qosSupportedAlgorithms); + print.printf("%1$20s: %2$s\n", "metrics", this.metrics); + print.printf("%1$20s: %2$s\n", "MACAutogenerated", this.MACAutogenerated); + print.printf("%1$20s: %2$s\n", "lockingMode", this.lockingMode); + print.printf("%1$20s: %2$s\n", "ipv4Allowed", this.ipv4Allowed); + print.printf("%1$20s: %2$s\n", "ipv6Allowed", this.ipv6Allowed); + return writer.toString(); + } + + /** + * Convert a VIF.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("device", this.device == null ? "" : this.device); + map.put("network", this.network == null ? new Network("OpaqueRef:NULL") : this.network); + map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); + map.put("MAC", this.MAC == null ? "" : this.MAC); + map.put("MTU", this.MTU == null ? 0 : this.MTU); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached); + map.put("status_code", this.statusCode == null ? 0 : this.statusCode); + map.put("status_detail", this.statusDetail == null ? "" : this.statusDetail); + map.put("runtime_properties", this.runtimeProperties == null ? new HashMap() : this.runtimeProperties); + map.put("qos_algorithm_type", this.qosAlgorithmType == null ? "" : this.qosAlgorithmType); + map.put("qos_algorithm_params", this.qosAlgorithmParams == null ? new HashMap() : this.qosAlgorithmParams); + map.put("qos_supported_algorithms", this.qosSupportedAlgorithms == null ? new LinkedHashSet() : this.qosSupportedAlgorithms); + map.put("metrics", this.metrics == null ? new VIFMetrics("OpaqueRef:NULL") : this.metrics); + map.put("MAC_autogenerated", this.MACAutogenerated == null ? false : this.MACAutogenerated); + map.put("locking_mode", this.lockingMode == null ? Types.VifLockingMode.UNRECOGNIZED : this.lockingMode); + map.put("ipv4_allowed", this.ipv4Allowed == null ? new LinkedHashSet() : this.ipv4Allowed); + map.put("ipv6_allowed", this.ipv6Allowed == null ? new LinkedHashSet() : this.ipv6Allowed); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * order in which VIF backends are created by xapi + */ + public String device; + /** + * virtual network to which this vif is connected + */ + public Network network; + /** + * virtual machine to which this vif is connected + */ + public VM VM; + /** + * ethernet MAC address of virtual interface, as exposed to guest + */ + public String MAC; + /** + * MTU in octets + */ + public Long MTU; + /** + * additional configuration + */ + public Map otherConfig; + /** + * is the device currently attached (erased on reboot) + */ + public Boolean currentlyAttached; + /** + * error/success code associated with last attach-operation (erased on reboot) + */ + public Long statusCode; + /** + * error/success information associated with last attach-operation status (erased on reboot) + */ + public String statusDetail; + /** + * Device runtime properties + */ + public Map runtimeProperties; + /** + * QoS algorithm to use + */ + public String qosAlgorithmType; + /** + * parameters for chosen QoS algorithm + */ + public Map qosAlgorithmParams; + /** + * supported QoS algorithms for this VIF + */ + public Set qosSupportedAlgorithms; + /** + * metrics associated with this VIF + */ + public VIFMetrics metrics; + /** + * true if the MAC was autogenerated; false indicates it was set manually + */ + public Boolean MACAutogenerated; + /** + * current locking mode of the VIF + */ + public Types.VifLockingMode lockingMode; + /** + * A list of IPv4 addresses which can be used to filter traffic passing through this VIF + */ + public Set ipv4Allowed; + /** + * A list of IPv6 addresses which can be used to filter traffic passing through this VIF + */ + public Set ipv6Allowed; + } + + /** + * Get a record containing the current state of the given VIF. + * + * @return all fields from the object + */ + public VIF.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVIFRecord(result); + } + + /** + * Get a reference to the VIF instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VIF getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVIF(result); + } + + /** + * Create a new VIF instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, VIF.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VIF instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static VIF create(Connection c, VIF.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVIF(result); + } + + /** + * Destroy the specified VIF instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified VIF instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the uuid field of the given VIF. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the allowed_operations field of the given VIF. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVifOperations(result); + } + + /** + * Get the current_operations field of the given VIF. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringVifOperations(result); + } + + /** + * Get the device field of the given VIF. + * + * @return value of the field + */ + public String getDevice(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_device"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the network field of the given VIF. + * + * @return value of the field + */ + public Network getNetwork(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_network"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toNetwork(result); + } + + /** + * Get the VM field of the given VIF. + * + * @return value of the field + */ + public VM getVM(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_VM"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Get the MAC field of the given VIF. + * + * @return value of the field + */ + public String getMAC(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_MAC"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the MTU field of the given VIF. + * + * @return value of the field + */ + public Long getMTU(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_MTU"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the other_config field of the given VIF. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the currently_attached field of the given VIF. + * + * @return value of the field + */ + public Boolean getCurrentlyAttached(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_currently_attached"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the status_code field of the given VIF. + * + * @return value of the field + */ + public Long getStatusCode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_status_code"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the status_detail field of the given VIF. + * + * @return value of the field + */ + public String getStatusDetail(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_status_detail"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the runtime_properties field of the given VIF. + * + * @return value of the field + */ + public Map getRuntimeProperties(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_runtime_properties"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the qos/algorithm_type field of the given VIF. + * + * @return value of the field + */ + public String getQosAlgorithmType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_qos_algorithm_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the qos/algorithm_params field of the given VIF. + * + * @return value of the field + */ + public Map getQosAlgorithmParams(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_qos_algorithm_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the qos/supported_algorithms field of the given VIF. + * + * @return value of the field + */ + public Set getQosSupportedAlgorithms(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_qos_supported_algorithms"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the metrics field of the given VIF. + * + * @return value of the field + */ + public VIFMetrics getMetrics(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_metrics"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVIFMetrics(result); + } + + /** + * Get the MAC_autogenerated field of the given VIF. + * + * @return value of the field + */ + public Boolean getMACAutogenerated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_MAC_autogenerated"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the locking_mode field of the given VIF. + * + * @return value of the field + */ + public Types.VifLockingMode getLockingMode(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_locking_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVifLockingMode(result); + } + + /** + * Get the ipv4_allowed field of the given VIF. + * + * @return value of the field + */ + public Set getIpv4Allowed(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_ipv4_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the ipv6_allowed field of the given VIF. + * + * @return value of the field + */ + public Set getIpv6Allowed(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_ipv6_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Set the other_config field of the given VIF. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VIF. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VIF. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the qos/algorithm_type field of the given VIF. + * + * @param algorithmType New value to set + */ + public void setQosAlgorithmType(Connection c, String algorithmType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.set_qos_algorithm_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(algorithmType)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the qos/algorithm_params field of the given VIF. + * + * @param algorithmParams New value to set + */ + public void setQosAlgorithmParams(Connection c, Map algorithmParams) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.set_qos_algorithm_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(algorithmParams)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the qos/algorithm_params field of the given VIF. + * + * @param key Key to add + * @param value Value to add + */ + public void addToQosAlgorithmParams(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.add_to_qos_algorithm_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the qos/algorithm_params field of the given VIF. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromQosAlgorithmParams(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.remove_from_qos_algorithm_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Hotplug the specified VIF, dynamically attaching it to the running VM + * + * @return Task + */ + public Task plugAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.plug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Hotplug the specified VIF, dynamically attaching it to the running VM + * + */ + public void plug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.plug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Hot-unplug the specified VIF, dynamically unattaching it from the running VM + * + * @return Task + */ + public Task unplugAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Hot-unplug the specified VIF, dynamically unattaching it from the running VM + * + */ + public void unplug(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.unplug"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Forcibly unplug the specified VIF + * + * @return Task + */ + public Task unplugForceAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.unplug_force"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Forcibly unplug the specified VIF + * + */ + public void unplugForce(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.unplug_force"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the locking mode for this VIF + * + * @param value The new locking mode for the VIF + * @return Task + */ + public Task setLockingModeAsync(Connection c, Types.VifLockingMode value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.set_locking_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the locking mode for this VIF + * + * @param value The new locking mode for the VIF + */ + public void setLockingMode(Connection c, Types.VifLockingMode value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.set_locking_mode"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the IPv4 addresses to which traffic on this VIF can be restricted + * + * @param value The IP addresses which will be associated with the VIF + * @return Task + */ + public Task setIpv4AllowedAsync(Connection c, Set value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.set_ipv4_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the IPv4 addresses to which traffic on this VIF can be restricted + * + * @param value The IP addresses which will be associated with the VIF + */ + public void setIpv4Allowed(Connection c, Set value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.set_ipv4_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Associates an IPv4 address with this VIF + * + * @param value The IP address which will be associated with the VIF + * @return Task + */ + public Task addIpv4AllowedAsync(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.add_ipv4_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Associates an IPv4 address with this VIF + * + * @param value The IP address which will be associated with the VIF + */ + public void addIpv4Allowed(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.add_ipv4_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Removes an IPv4 address from this VIF + * + * @param value The IP address which will be removed from the VIF + * @return Task + */ + public Task removeIpv4AllowedAsync(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.remove_ipv4_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removes an IPv4 address from this VIF + * + * @param value The IP address which will be removed from the VIF + */ + public void removeIpv4Allowed(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.remove_ipv4_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the IPv6 addresses to which traffic on this VIF can be restricted + * + * @param value The IP addresses which will be associated with the VIF + * @return Task + */ + public Task setIpv6AllowedAsync(Connection c, Set value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.set_ipv6_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the IPv6 addresses to which traffic on this VIF can be restricted + * + * @param value The IP addresses which will be associated with the VIF + */ + public void setIpv6Allowed(Connection c, Set value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.set_ipv6_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Associates an IPv6 address with this VIF + * + * @param value The IP address which will be associated with the VIF + * @return Task + */ + public Task addIpv6AllowedAsync(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.add_ipv6_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Associates an IPv6 address with this VIF + * + * @param value The IP address which will be associated with the VIF + */ + public void addIpv6Allowed(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.add_ipv6_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Removes an IPv6 address from this VIF + * + * @param value The IP address which will be removed from the VIF + * @return Task + */ + public Task removeIpv6AllowedAsync(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VIF.remove_ipv6_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Removes an IPv6 address from this VIF + * + * @param value The IP address which will be removed from the VIF + */ + public void removeIpv6Allowed(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.remove_ipv6_allowed"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VIFs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVIF(result); + } + + /** + * Return a map of VIF references to VIF records for all VIFs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVIFVIFRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java new file mode 100644 index 00000000000..ed7504c17b1 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java @@ -0,0 +1,349 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * The metrics associated with a virtual network device + * + * @author Citrix Systems, Inc. + */ +public class VIFMetrics extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VIFMetrics(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VIFMetrics, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VIFMetrics) + { + VIFMetrics other = (VIFMetrics) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VIFMetrics + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs); + print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs); + print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a VIF_metrics.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs); + map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs); + map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Read bandwidth (KiB/s) + */ + public Double ioReadKbs; + /** + * Write bandwidth (KiB/s) + */ + public Double ioWriteKbs; + /** + * Time at which this information was last updated + */ + public Date lastUpdated; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given VIF_metrics. + * + * @return all fields from the object + */ + public VIFMetrics.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVIFMetricsRecord(result); + } + + /** + * Get a reference to the VIF_metrics instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VIFMetrics getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVIFMetrics(result); + } + + /** + * Get the uuid field of the given VIF_metrics. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the io/read_kbs field of the given VIF_metrics. + * + * @return value of the field + */ + public Double getIoReadKbs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_io_read_kbs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the io/write_kbs field of the given VIF_metrics. + * + * @return value of the field + */ + public Double getIoWriteKbs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_io_write_kbs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the last_updated field of the given VIF_metrics. + * + * @return value of the field + */ + public Date getLastUpdated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_last_updated"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the other_config field of the given VIF_metrics. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given VIF_metrics. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VIF_metrics. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VIF_metrics. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VIF_metrics instances known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVIFMetrics(result); + } + + /** + * Return a map of VIF_metrics references to VIF_metrics records for all VIF_metrics instances known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VIF_metrics.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVIFMetricsVIFMetricsRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VLAN.java b/deps/XenServerJava/src/com/xensource/xenapi/VLAN.java new file mode 100644 index 00000000000..232640527ac --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VLAN.java @@ -0,0 +1,421 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A VLAN mux/demux + * + * @author Citrix Systems, Inc. + */ +public class VLAN extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VLAN(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VLAN, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VLAN) + { + VLAN other = (VLAN) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VLAN + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "taggedPIF", this.taggedPIF); + print.printf("%1$20s: %2$s\n", "untaggedPIF", this.untaggedPIF); + print.printf("%1$20s: %2$s\n", "tag", this.tag); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a VLAN.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("tagged_PIF", this.taggedPIF == null ? new PIF("OpaqueRef:NULL") : this.taggedPIF); + map.put("untagged_PIF", this.untaggedPIF == null ? new PIF("OpaqueRef:NULL") : this.untaggedPIF); + map.put("tag", this.tag == null ? 0 : this.tag); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * interface on which traffic is tagged + */ + public PIF taggedPIF; + /** + * interface on which traffic is untagged + */ + public PIF untaggedPIF; + /** + * VLAN tag in use + */ + public Long tag; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given VLAN. + * + * @return all fields from the object + */ + public VLAN.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVLANRecord(result); + } + + /** + * Get a reference to the VLAN instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VLAN getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVLAN(result); + } + + /** + * Get the uuid field of the given VLAN. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the tagged_PIF field of the given VLAN. + * + * @return value of the field + */ + public PIF getTaggedPIF(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_tagged_PIF"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Get the untagged_PIF field of the given VLAN. + * + * @return value of the field + */ + public PIF getUntaggedPIF(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_untagged_PIF"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toPIF(result); + } + + /** + * Get the tag field of the given VLAN. + * + * @return value of the field + */ + public Long getTag(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_tag"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the other_config field of the given VLAN. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given VLAN. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VLAN. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VLAN. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a VLAN mux/demuxer + * + * @param taggedPIF PIF which receives the tagged traffic + * @param tag VLAN tag to use + * @param network Network to receive the untagged traffic + * @return Task + */ + public static Task createAsync(Connection c, PIF taggedPIF, Long tag, Network network) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VLAN.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(taggedPIF), Marshalling.toXMLRPC(tag), Marshalling.toXMLRPC(network)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a VLAN mux/demuxer + * + * @param taggedPIF PIF which receives the tagged traffic + * @param tag VLAN tag to use + * @param network Network to receive the untagged traffic + * @return The reference of the created VLAN object + */ + public static VLAN create(Connection c, PIF taggedPIF, Long tag, Network network) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.create"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(taggedPIF), Marshalling.toXMLRPC(tag), Marshalling.toXMLRPC(network)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVLAN(result); + } + + /** + * Destroy a VLAN mux/demuxer + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VLAN.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy a VLAN mux/demuxer + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VLANs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVLAN(result); + } + + /** + * Return a map of VLAN references to VLAN records for all VLANs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VLAN.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVLANVLANRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VM.java b/deps/XenServerJava/src/com/xensource/xenapi/VM.java new file mode 100644 index 00000000000..736026654d7 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VM.java @@ -0,0 +1,4891 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A virtual machine (or 'guest'). + * + * @author Citrix Systems, Inc. + */ +public class VM extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VM(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VM, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VM) + { + VM other = (VM) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VM + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "powerState", this.powerState); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "userVersion", this.userVersion); + print.printf("%1$20s: %2$s\n", "isATemplate", this.isATemplate); + print.printf("%1$20s: %2$s\n", "suspendVDI", this.suspendVDI); + print.printf("%1$20s: %2$s\n", "residentOn", this.residentOn); + print.printf("%1$20s: %2$s\n", "affinity", this.affinity); + print.printf("%1$20s: %2$s\n", "memoryOverhead", this.memoryOverhead); + print.printf("%1$20s: %2$s\n", "memoryTarget", this.memoryTarget); + print.printf("%1$20s: %2$s\n", "memoryStaticMax", this.memoryStaticMax); + print.printf("%1$20s: %2$s\n", "memoryDynamicMax", this.memoryDynamicMax); + print.printf("%1$20s: %2$s\n", "memoryDynamicMin", this.memoryDynamicMin); + print.printf("%1$20s: %2$s\n", "memoryStaticMin", this.memoryStaticMin); + print.printf("%1$20s: %2$s\n", "VCPUsParams", this.VCPUsParams); + print.printf("%1$20s: %2$s\n", "VCPUsMax", this.VCPUsMax); + print.printf("%1$20s: %2$s\n", "VCPUsAtStartup", this.VCPUsAtStartup); + print.printf("%1$20s: %2$s\n", "actionsAfterShutdown", this.actionsAfterShutdown); + print.printf("%1$20s: %2$s\n", "actionsAfterReboot", this.actionsAfterReboot); + print.printf("%1$20s: %2$s\n", "actionsAfterCrash", this.actionsAfterCrash); + print.printf("%1$20s: %2$s\n", "consoles", this.consoles); + print.printf("%1$20s: %2$s\n", "VIFs", this.VIFs); + print.printf("%1$20s: %2$s\n", "VBDs", this.VBDs); + print.printf("%1$20s: %2$s\n", "crashDumps", this.crashDumps); + print.printf("%1$20s: %2$s\n", "VTPMs", this.VTPMs); + print.printf("%1$20s: %2$s\n", "PVBootloader", this.PVBootloader); + print.printf("%1$20s: %2$s\n", "PVKernel", this.PVKernel); + print.printf("%1$20s: %2$s\n", "PVRamdisk", this.PVRamdisk); + print.printf("%1$20s: %2$s\n", "PVArgs", this.PVArgs); + print.printf("%1$20s: %2$s\n", "PVBootloaderArgs", this.PVBootloaderArgs); + print.printf("%1$20s: %2$s\n", "PVLegacyArgs", this.PVLegacyArgs); + print.printf("%1$20s: %2$s\n", "HVMBootPolicy", this.HVMBootPolicy); + print.printf("%1$20s: %2$s\n", "HVMBootParams", this.HVMBootParams); + print.printf("%1$20s: %2$s\n", "HVMShadowMultiplier", this.HVMShadowMultiplier); + print.printf("%1$20s: %2$s\n", "platform", this.platform); + print.printf("%1$20s: %2$s\n", "PCIBus", this.PCIBus); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "domid", this.domid); + print.printf("%1$20s: %2$s\n", "domarch", this.domarch); + print.printf("%1$20s: %2$s\n", "lastBootCPUFlags", this.lastBootCPUFlags); + print.printf("%1$20s: %2$s\n", "isControlDomain", this.isControlDomain); + print.printf("%1$20s: %2$s\n", "metrics", this.metrics); + print.printf("%1$20s: %2$s\n", "guestMetrics", this.guestMetrics); + print.printf("%1$20s: %2$s\n", "lastBootedRecord", this.lastBootedRecord); + print.printf("%1$20s: %2$s\n", "recommendations", this.recommendations); + print.printf("%1$20s: %2$s\n", "xenstoreData", this.xenstoreData); + print.printf("%1$20s: %2$s\n", "haAlwaysRun", this.haAlwaysRun); + print.printf("%1$20s: %2$s\n", "haRestartPriority", this.haRestartPriority); + print.printf("%1$20s: %2$s\n", "isASnapshot", this.isASnapshot); + print.printf("%1$20s: %2$s\n", "snapshotOf", this.snapshotOf); + print.printf("%1$20s: %2$s\n", "snapshots", this.snapshots); + print.printf("%1$20s: %2$s\n", "snapshotTime", this.snapshotTime); + print.printf("%1$20s: %2$s\n", "transportableSnapshotId", this.transportableSnapshotId); + print.printf("%1$20s: %2$s\n", "blobs", this.blobs); + print.printf("%1$20s: %2$s\n", "tags", this.tags); + print.printf("%1$20s: %2$s\n", "blockedOperations", this.blockedOperations); + print.printf("%1$20s: %2$s\n", "snapshotInfo", this.snapshotInfo); + print.printf("%1$20s: %2$s\n", "snapshotMetadata", this.snapshotMetadata); + print.printf("%1$20s: %2$s\n", "parent", this.parent); + print.printf("%1$20s: %2$s\n", "children", this.children); + print.printf("%1$20s: %2$s\n", "biosStrings", this.biosStrings); + print.printf("%1$20s: %2$s\n", "protectionPolicy", this.protectionPolicy); + print.printf("%1$20s: %2$s\n", "isSnapshotFromVmpp", this.isSnapshotFromVmpp); + print.printf("%1$20s: %2$s\n", "appliance", this.appliance); + print.printf("%1$20s: %2$s\n", "startDelay", this.startDelay); + print.printf("%1$20s: %2$s\n", "shutdownDelay", this.shutdownDelay); + print.printf("%1$20s: %2$s\n", "order", this.order); + print.printf("%1$20s: %2$s\n", "VGPUs", this.VGPUs); + print.printf("%1$20s: %2$s\n", "attachedPCIs", this.attachedPCIs); + print.printf("%1$20s: %2$s\n", "suspendSR", this.suspendSR); + print.printf("%1$20s: %2$s\n", "version", this.version); + return writer.toString(); + } + + /** + * Convert a VM.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("power_state", this.powerState == null ? Types.VmPowerState.UNRECOGNIZED : this.powerState); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("user_version", this.userVersion == null ? 0 : this.userVersion); + map.put("is_a_template", this.isATemplate == null ? false : this.isATemplate); + map.put("suspend_VDI", this.suspendVDI == null ? new VDI("OpaqueRef:NULL") : this.suspendVDI); + map.put("resident_on", this.residentOn == null ? new Host("OpaqueRef:NULL") : this.residentOn); + map.put("affinity", this.affinity == null ? new Host("OpaqueRef:NULL") : this.affinity); + map.put("memory_overhead", this.memoryOverhead == null ? 0 : this.memoryOverhead); + map.put("memory_target", this.memoryTarget == null ? 0 : this.memoryTarget); + map.put("memory_static_max", this.memoryStaticMax == null ? 0 : this.memoryStaticMax); + map.put("memory_dynamic_max", this.memoryDynamicMax == null ? 0 : this.memoryDynamicMax); + map.put("memory_dynamic_min", this.memoryDynamicMin == null ? 0 : this.memoryDynamicMin); + map.put("memory_static_min", this.memoryStaticMin == null ? 0 : this.memoryStaticMin); + map.put("VCPUs_params", this.VCPUsParams == null ? new HashMap() : this.VCPUsParams); + map.put("VCPUs_max", this.VCPUsMax == null ? 0 : this.VCPUsMax); + map.put("VCPUs_at_startup", this.VCPUsAtStartup == null ? 0 : this.VCPUsAtStartup); + map.put("actions_after_shutdown", this.actionsAfterShutdown == null ? Types.OnNormalExit.UNRECOGNIZED : this.actionsAfterShutdown); + map.put("actions_after_reboot", this.actionsAfterReboot == null ? Types.OnNormalExit.UNRECOGNIZED : this.actionsAfterReboot); + map.put("actions_after_crash", this.actionsAfterCrash == null ? Types.OnCrashBehaviour.UNRECOGNIZED : this.actionsAfterCrash); + map.put("consoles", this.consoles == null ? new LinkedHashSet() : this.consoles); + map.put("VIFs", this.VIFs == null ? new LinkedHashSet() : this.VIFs); + map.put("VBDs", this.VBDs == null ? new LinkedHashSet() : this.VBDs); + map.put("crash_dumps", this.crashDumps == null ? new LinkedHashSet() : this.crashDumps); + map.put("VTPMs", this.VTPMs == null ? new LinkedHashSet() : this.VTPMs); + map.put("PV_bootloader", this.PVBootloader == null ? "" : this.PVBootloader); + map.put("PV_kernel", this.PVKernel == null ? "" : this.PVKernel); + map.put("PV_ramdisk", this.PVRamdisk == null ? "" : this.PVRamdisk); + map.put("PV_args", this.PVArgs == null ? "" : this.PVArgs); + map.put("PV_bootloader_args", this.PVBootloaderArgs == null ? "" : this.PVBootloaderArgs); + map.put("PV_legacy_args", this.PVLegacyArgs == null ? "" : this.PVLegacyArgs); + map.put("HVM_boot_policy", this.HVMBootPolicy == null ? "" : this.HVMBootPolicy); + map.put("HVM_boot_params", this.HVMBootParams == null ? new HashMap() : this.HVMBootParams); + map.put("HVM_shadow_multiplier", this.HVMShadowMultiplier == null ? 0.0 : this.HVMShadowMultiplier); + map.put("platform", this.platform == null ? new HashMap() : this.platform); + map.put("PCI_bus", this.PCIBus == null ? "" : this.PCIBus); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("domid", this.domid == null ? 0 : this.domid); + map.put("domarch", this.domarch == null ? "" : this.domarch); + map.put("last_boot_CPU_flags", this.lastBootCPUFlags == null ? new HashMap() : this.lastBootCPUFlags); + map.put("is_control_domain", this.isControlDomain == null ? false : this.isControlDomain); + map.put("metrics", this.metrics == null ? new VMMetrics("OpaqueRef:NULL") : this.metrics); + map.put("guest_metrics", this.guestMetrics == null ? new VMGuestMetrics("OpaqueRef:NULL") : this.guestMetrics); + map.put("last_booted_record", this.lastBootedRecord == null ? "" : this.lastBootedRecord); + map.put("recommendations", this.recommendations == null ? "" : this.recommendations); + map.put("xenstore_data", this.xenstoreData == null ? new HashMap() : this.xenstoreData); + map.put("ha_always_run", this.haAlwaysRun == null ? false : this.haAlwaysRun); + map.put("ha_restart_priority", this.haRestartPriority == null ? "" : this.haRestartPriority); + map.put("is_a_snapshot", this.isASnapshot == null ? false : this.isASnapshot); + map.put("snapshot_of", this.snapshotOf == null ? new VM("OpaqueRef:NULL") : this.snapshotOf); + map.put("snapshots", this.snapshots == null ? new LinkedHashSet() : this.snapshots); + map.put("snapshot_time", this.snapshotTime == null ? new Date(0) : this.snapshotTime); + map.put("transportable_snapshot_id", this.transportableSnapshotId == null ? "" : this.transportableSnapshotId); + map.put("blobs", this.blobs == null ? new HashMap() : this.blobs); + map.put("tags", this.tags == null ? new LinkedHashSet() : this.tags); + map.put("blocked_operations", this.blockedOperations == null ? new HashMap() : this.blockedOperations); + map.put("snapshot_info", this.snapshotInfo == null ? new HashMap() : this.snapshotInfo); + map.put("snapshot_metadata", this.snapshotMetadata == null ? "" : this.snapshotMetadata); + map.put("parent", this.parent == null ? new VM("OpaqueRef:NULL") : this.parent); + map.put("children", this.children == null ? new LinkedHashSet() : this.children); + map.put("bios_strings", this.biosStrings == null ? new HashMap() : this.biosStrings); + map.put("protection_policy", this.protectionPolicy == null ? new VMPP("OpaqueRef:NULL") : this.protectionPolicy); + map.put("is_snapshot_from_vmpp", this.isSnapshotFromVmpp == null ? false : this.isSnapshotFromVmpp); + map.put("appliance", this.appliance == null ? new VMAppliance("OpaqueRef:NULL") : this.appliance); + map.put("start_delay", this.startDelay == null ? 0 : this.startDelay); + map.put("shutdown_delay", this.shutdownDelay == null ? 0 : this.shutdownDelay); + map.put("order", this.order == null ? 0 : this.order); + map.put("VGPUs", this.VGPUs == null ? new LinkedHashSet() : this.VGPUs); + map.put("attached_PCIs", this.attachedPCIs == null ? new LinkedHashSet() : this.attachedPCIs); + map.put("suspend_SR", this.suspendSR == null ? new SR("OpaqueRef:NULL") : this.suspendSR); + map.put("version", this.version == null ? 0 : this.version); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * Current power state of the machine + */ + public Types.VmPowerState powerState; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * a user version number for this machine + */ + public Long userVersion; + /** + * true if this is a template. Template VMs can never be started, they are used only for cloning other VMs + */ + public Boolean isATemplate; + /** + * The VDI that a suspend image is stored on. (Only has meaning if VM is currently suspended) + */ + public VDI suspendVDI; + /** + * the host the VM is currently resident on + */ + public Host residentOn; + /** + * a host which the VM has some affinity for (or NULL). This is used as a hint to the start call when it decides where to run the VM. Implementations are free to ignore this field. + */ + public Host affinity; + /** + * Virtualization memory overhead (bytes). + */ + public Long memoryOverhead; + /** + * Dynamically-set memory target (bytes). The value of this field indicates the current target for memory available to this VM. + */ + public Long memoryTarget; + /** + * Statically-set (i.e. absolute) maximum (bytes). The value of this field at VM start time acts as a hard limit of the amount of memory a guest can use. New values only take effect on reboot. + */ + public Long memoryStaticMax; + /** + * Dynamic maximum (bytes) + */ + public Long memoryDynamicMax; + /** + * Dynamic minimum (bytes) + */ + public Long memoryDynamicMin; + /** + * Statically-set (i.e. absolute) mininum (bytes). The value of this field indicates the least amount of memory this VM can boot with without crashing. + */ + public Long memoryStaticMin; + /** + * configuration parameters for the selected VCPU policy + */ + public Map VCPUsParams; + /** + * Max number of VCPUs + */ + public Long VCPUsMax; + /** + * Boot number of VCPUs + */ + public Long VCPUsAtStartup; + /** + * action to take after the guest has shutdown itself + */ + public Types.OnNormalExit actionsAfterShutdown; + /** + * action to take after the guest has rebooted itself + */ + public Types.OnNormalExit actionsAfterReboot; + /** + * action to take if the guest crashes + */ + public Types.OnCrashBehaviour actionsAfterCrash; + /** + * virtual console devices + */ + public Set consoles; + /** + * virtual network interfaces + */ + public Set VIFs; + /** + * virtual block devices + */ + public Set VBDs; + /** + * crash dumps associated with this VM + */ + public Set crashDumps; + /** + * virtual TPMs + */ + public Set VTPMs; + /** + * name of or path to bootloader + */ + public String PVBootloader; + /** + * path to the kernel + */ + public String PVKernel; + /** + * path to the initrd + */ + public String PVRamdisk; + /** + * kernel command-line arguments + */ + public String PVArgs; + /** + * miscellaneous arguments for the bootloader + */ + public String PVBootloaderArgs; + /** + * to make Zurich guests boot + */ + public String PVLegacyArgs; + /** + * HVM boot policy + */ + public String HVMBootPolicy; + /** + * HVM boot params + */ + public Map HVMBootParams; + /** + * multiplier applied to the amount of shadow that will be made available to the guest + */ + public Double HVMShadowMultiplier; + /** + * platform-specific configuration + */ + public Map platform; + /** + * PCI bus path for pass-through devices + */ + public String PCIBus; + /** + * additional configuration + */ + public Map otherConfig; + /** + * domain ID (if available, -1 otherwise) + */ + public Long domid; + /** + * Domain architecture (if available, null string otherwise) + */ + public String domarch; + /** + * describes the CPU flags on which the VM was last booted + */ + public Map lastBootCPUFlags; + /** + * true if this is a control domain (domain 0 or a driver domain) + */ + public Boolean isControlDomain; + /** + * metrics associated with this VM + */ + public VMMetrics metrics; + /** + * metrics associated with the running guest + */ + public VMGuestMetrics guestMetrics; + /** + * marshalled value containing VM record at time of last boot, updated dynamically to reflect the runtime state of the domain + */ + public String lastBootedRecord; + /** + * An XML specification of recommended values and ranges for properties of this VM + */ + public String recommendations; + /** + * data to be inserted into the xenstore tree (/local/domain//vm-data) after the VM is created. + */ + public Map xenstoreData; + /** + * if true then the system will attempt to keep the VM running as much as possible. + */ + public Boolean haAlwaysRun; + /** + * has possible values: "best-effort" meaning "try to restart this VM if possible but don't consider the Pool to be overcommitted if this is not possible"; "restart" meaning "this VM should be restarted"; "" meaning "do not try to restart this VM" + */ + public String haRestartPriority; + /** + * true if this is a snapshot. Snapshotted VMs can never be started, they are used only for cloning other VMs + */ + public Boolean isASnapshot; + /** + * Ref pointing to the VM this snapshot is of. + */ + public VM snapshotOf; + /** + * List pointing to all the VM snapshots. + */ + public Set snapshots; + /** + * Date/time when this snapshot was created. + */ + public Date snapshotTime; + /** + * Transportable ID of the snapshot VM + */ + public String transportableSnapshotId; + /** + * Binary blobs associated with this VM + */ + public Map blobs; + /** + * user-specified tags for categorization purposes + */ + public Set tags; + /** + * List of operations which have been explicitly blocked and an error code + */ + public Map blockedOperations; + /** + * Human-readable information concerning this snapshot + */ + public Map snapshotInfo; + /** + * Encoded information about the VM's metadata this is a snapshot of + */ + public String snapshotMetadata; + /** + * Ref pointing to the parent of this VM + */ + public VM parent; + /** + * List pointing to all the children of this VM + */ + public Set children; + /** + * BIOS strings + */ + public Map biosStrings; + /** + * Ref pointing to a protection policy for this VM + */ + public VMPP protectionPolicy; + /** + * true if this snapshot was created by the protection policy + */ + public Boolean isSnapshotFromVmpp; + /** + * the appliance to which this VM belongs + */ + public VMAppliance appliance; + /** + * The delay to wait before proceeding to the next order in the startup sequence (seconds) + */ + public Long startDelay; + /** + * The delay to wait before proceeding to the next order in the shutdown sequence (seconds) + */ + public Long shutdownDelay; + /** + * The point in the startup or shutdown sequence at which this VM will be started + */ + public Long order; + /** + * Virtual GPUs + */ + public Set VGPUs; + /** + * Currently passed-through PCI devices + */ + public Set attachedPCIs; + /** + * The SR on which a suspend image is stored + */ + public SR suspendSR; + /** + * The number of times this VM has been recovered + */ + public Long version; + } + + /** + * Get a record containing the current state of the given VM. + * + * @return all fields from the object + */ + public VM.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMRecord(result); + } + + /** + * Get a reference to the VM instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VM getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Create a new VM instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, VM.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VM instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static VM create(Connection c, VM.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Destroy the specified VM. The VM is completely removed from the system. This function can only be called when the VM is in the Halted State. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified VM. The VM is completely removed from the system. This function can only be called when the VM is in the Halted State. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get all the VM instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVM(result); + } + + /** + * Get the uuid field of the given VM. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the allowed_operations field of the given VM. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVmOperations(result); + } + + /** + * Get the current_operations field of the given VM. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringVmOperations(result); + } + + /** + * Get the power_state field of the given VM. + * + * @return value of the field + */ + public Types.VmPowerState getPowerState(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_power_state"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVmPowerState(result); + } + + /** + * Get the name/label field of the given VM. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given VM. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the user_version field of the given VM. + * + * @return value of the field + */ + public Long getUserVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_user_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the is_a_template field of the given VM. + * + * @return value of the field + */ + public Boolean getIsATemplate(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_is_a_template"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the suspend_VDI field of the given VM. + * + * @return value of the field + */ + public VDI getSuspendVDI(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_suspend_VDI"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVDI(result); + } + + /** + * Get the resident_on field of the given VM. + * + * @return value of the field + */ + public Host getResidentOn(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_resident_on"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the affinity field of the given VM. + * + * @return value of the field + */ + public Host getAffinity(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_affinity"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toHost(result); + } + + /** + * Get the memory/overhead field of the given VM. + * + * @return value of the field + */ + public Long getMemoryOverhead(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_memory_overhead"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the memory/target field of the given VM. + * @deprecated + * + * @return value of the field + */ + @Deprecated public Long getMemoryTarget(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_memory_target"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the memory/static_max field of the given VM. + * + * @return value of the field + */ + public Long getMemoryStaticMax(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_memory_static_max"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the memory/dynamic_max field of the given VM. + * + * @return value of the field + */ + public Long getMemoryDynamicMax(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_memory_dynamic_max"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the memory/dynamic_min field of the given VM. + * + * @return value of the field + */ + public Long getMemoryDynamicMin(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_memory_dynamic_min"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the memory/static_min field of the given VM. + * + * @return value of the field + */ + public Long getMemoryStaticMin(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_memory_static_min"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the VCPUs/params field of the given VM. + * + * @return value of the field + */ + public Map getVCPUsParams(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_VCPUs_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the VCPUs/max field of the given VM. + * + * @return value of the field + */ + public Long getVCPUsMax(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_VCPUs_max"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the VCPUs/at_startup field of the given VM. + * + * @return value of the field + */ + public Long getVCPUsAtStartup(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_VCPUs_at_startup"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the actions/after_shutdown field of the given VM. + * + * @return value of the field + */ + public Types.OnNormalExit getActionsAfterShutdown(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_actions_after_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toOnNormalExit(result); + } + + /** + * Get the actions/after_reboot field of the given VM. + * + * @return value of the field + */ + public Types.OnNormalExit getActionsAfterReboot(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_actions_after_reboot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toOnNormalExit(result); + } + + /** + * Get the actions/after_crash field of the given VM. + * + * @return value of the field + */ + public Types.OnCrashBehaviour getActionsAfterCrash(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_actions_after_crash"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toOnCrashBehaviour(result); + } + + /** + * Get the consoles field of the given VM. + * + * @return value of the field + */ + public Set getConsoles(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_consoles"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfConsole(result); + } + + /** + * Get the VIFs field of the given VM. + * + * @return value of the field + */ + public Set getVIFs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_VIFs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVIF(result); + } + + /** + * Get the VBDs field of the given VM. + * + * @return value of the field + */ + public Set getVBDs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_VBDs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVBD(result); + } + + /** + * Get the crash_dumps field of the given VM. + * + * @return value of the field + */ + public Set getCrashDumps(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_crash_dumps"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfCrashdump(result); + } + + /** + * Get the VTPMs field of the given VM. + * + * @return value of the field + */ + public Set getVTPMs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_VTPMs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVTPM(result); + } + + /** + * Get the PV/bootloader field of the given VM. + * + * @return value of the field + */ + public String getPVBootloader(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_PV_bootloader"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the PV/kernel field of the given VM. + * + * @return value of the field + */ + public String getPVKernel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_PV_kernel"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the PV/ramdisk field of the given VM. + * + * @return value of the field + */ + public String getPVRamdisk(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_PV_ramdisk"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the PV/args field of the given VM. + * + * @return value of the field + */ + public String getPVArgs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_PV_args"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the PV/bootloader_args field of the given VM. + * + * @return value of the field + */ + public String getPVBootloaderArgs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_PV_bootloader_args"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the PV/legacy_args field of the given VM. + * + * @return value of the field + */ + public String getPVLegacyArgs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_PV_legacy_args"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the HVM/boot_policy field of the given VM. + * + * @return value of the field + */ + public String getHVMBootPolicy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_HVM_boot_policy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the HVM/boot_params field of the given VM. + * + * @return value of the field + */ + public Map getHVMBootParams(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_HVM_boot_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the HVM/shadow_multiplier field of the given VM. + * + * @return value of the field + */ + public Double getHVMShadowMultiplier(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_HVM_shadow_multiplier"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Get the platform field of the given VM. + * + * @return value of the field + */ + public Map getPlatform(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_platform"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the PCI_bus field of the given VM. + * @deprecated + * + * @return value of the field + */ + @Deprecated public String getPCIBus(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_PCI_bus"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the other_config field of the given VM. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the domid field of the given VM. + * + * @return value of the field + */ + public Long getDomid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_domid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the domarch field of the given VM. + * + * @return value of the field + */ + public String getDomarch(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_domarch"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the last_boot_CPU_flags field of the given VM. + * + * @return value of the field + */ + public Map getLastBootCPUFlags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_last_boot_CPU_flags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the is_control_domain field of the given VM. + * + * @return value of the field + */ + public Boolean getIsControlDomain(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_is_control_domain"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the metrics field of the given VM. + * + * @return value of the field + */ + public VMMetrics getMetrics(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_metrics"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMMetrics(result); + } + + /** + * Get the guest_metrics field of the given VM. + * + * @return value of the field + */ + public VMGuestMetrics getGuestMetrics(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_guest_metrics"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMGuestMetrics(result); + } + + /** + * Get the last_booted_record field of the given VM. + * + * @return value of the field + */ + public String getLastBootedRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_last_booted_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the recommendations field of the given VM. + * + * @return value of the field + */ + public String getRecommendations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_recommendations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the xenstore_data field of the given VM. + * + * @return value of the field + */ + public Map getXenstoreData(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_xenstore_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the ha_always_run field of the given VM. + * @deprecated + * + * @return value of the field + */ + @Deprecated public Boolean getHaAlwaysRun(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_ha_always_run"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the ha_restart_priority field of the given VM. + * + * @return value of the field + */ + public String getHaRestartPriority(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_ha_restart_priority"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the is_a_snapshot field of the given VM. + * + * @return value of the field + */ + public Boolean getIsASnapshot(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_is_a_snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the snapshot_of field of the given VM. + * + * @return value of the field + */ + public VM getSnapshotOf(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_snapshot_of"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Get the snapshots field of the given VM. + * + * @return value of the field + */ + public Set getSnapshots(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_snapshots"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVM(result); + } + + /** + * Get the snapshot_time field of the given VM. + * + * @return value of the field + */ + public Date getSnapshotTime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_snapshot_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the transportable_snapshot_id field of the given VM. + * + * @return value of the field + */ + public String getTransportableSnapshotId(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_transportable_snapshot_id"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the blobs field of the given VM. + * + * @return value of the field + */ + public Map getBlobs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_blobs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringBlob(result); + } + + /** + * Get the tags field of the given VM. + * + * @return value of the field + */ + public Set getTags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the blocked_operations field of the given VM. + * + * @return value of the field + */ + public Map getBlockedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_blocked_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVmOperationsString(result); + } + + /** + * Get the snapshot_info field of the given VM. + * + * @return value of the field + */ + public Map getSnapshotInfo(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_snapshot_info"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the snapshot_metadata field of the given VM. + * + * @return value of the field + */ + public String getSnapshotMetadata(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_snapshot_metadata"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the parent field of the given VM. + * + * @return value of the field + */ + public VM getParent(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_parent"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Get the children field of the given VM. + * + * @return value of the field + */ + public Set getChildren(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_children"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVM(result); + } + + /** + * Get the bios_strings field of the given VM. + * + * @return value of the field + */ + public Map getBiosStrings(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_bios_strings"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the protection_policy field of the given VM. + * + * @return value of the field + */ + public VMPP getProtectionPolicy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_protection_policy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMPP(result); + } + + /** + * Get the is_snapshot_from_vmpp field of the given VM. + * + * @return value of the field + */ + public Boolean getIsSnapshotFromVmpp(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_is_snapshot_from_vmpp"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the appliance field of the given VM. + * + * @return value of the field + */ + public VMAppliance getAppliance(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_appliance"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMAppliance(result); + } + + /** + * Get the start_delay field of the given VM. + * + * @return value of the field + */ + public Long getStartDelay(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_start_delay"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the shutdown_delay field of the given VM. + * + * @return value of the field + */ + public Long getShutdownDelay(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_shutdown_delay"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the order field of the given VM. + * + * @return value of the field + */ + public Long getOrder(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_order"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the VGPUs field of the given VM. + * + * @return value of the field + */ + public Set getVGPUs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_VGPUs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVGPU(result); + } + + /** + * Get the attached_PCIs field of the given VM. + * + * @return value of the field + */ + public Set getAttachedPCIs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_attached_PCIs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfPCI(result); + } + + /** + * Get the suspend_SR field of the given VM. + * + * @return value of the field + */ + public SR getSuspendSR(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_suspend_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSR(result); + } + + /** + * Get the version field of the given VM. + * + * @return value of the field + */ + public Long getVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Set the name/label field of the given VM. + * + * @param label New value to set + */ + public void setNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name/description field of the given VM. + * + * @param description New value to set + */ + public void setNameDescription(Connection c, String description) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the user_version field of the given VM. + * + * @param userVersion New value to set + */ + public void setUserVersion(Connection c, Long userVersion) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_user_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(userVersion)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the is_a_template field of the given VM. + * + * @param isATemplate New value to set + */ + public void setIsATemplate(Connection c, Boolean isATemplate) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_is_a_template"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(isATemplate)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the affinity field of the given VM. + * + * @param affinity New value to set + */ + public void setAffinity(Connection c, Host affinity) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_affinity"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(affinity)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the VCPUs/params field of the given VM. + * + * @param params New value to set + */ + public void setVCPUsParams(Connection c, Map params) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_VCPUs_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(params)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the VCPUs/params field of the given VM. + * + * @param key Key to add + * @param value Value to add + */ + public void addToVCPUsParams(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.add_to_VCPUs_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the VCPUs/params field of the given VM. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromVCPUsParams(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.remove_from_VCPUs_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the actions/after_shutdown field of the given VM. + * + * @param afterShutdown New value to set + */ + public void setActionsAfterShutdown(Connection c, Types.OnNormalExit afterShutdown) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_actions_after_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(afterShutdown)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the actions/after_reboot field of the given VM. + * + * @param afterReboot New value to set + */ + public void setActionsAfterReboot(Connection c, Types.OnNormalExit afterReboot) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_actions_after_reboot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(afterReboot)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the actions/after_crash field of the given VM. + * + * @param afterCrash New value to set + */ + public void setActionsAfterCrash(Connection c, Types.OnCrashBehaviour afterCrash) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_actions_after_crash"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(afterCrash)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the PV/bootloader field of the given VM. + * + * @param bootloader New value to set + */ + public void setPVBootloader(Connection c, String bootloader) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_PV_bootloader"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootloader)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the PV/kernel field of the given VM. + * + * @param kernel New value to set + */ + public void setPVKernel(Connection c, String kernel) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_PV_kernel"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(kernel)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the PV/ramdisk field of the given VM. + * + * @param ramdisk New value to set + */ + public void setPVRamdisk(Connection c, String ramdisk) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_PV_ramdisk"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(ramdisk)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the PV/args field of the given VM. + * + * @param args New value to set + */ + public void setPVArgs(Connection c, String args) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_PV_args"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(args)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the PV/bootloader_args field of the given VM. + * + * @param bootloaderArgs New value to set + */ + public void setPVBootloaderArgs(Connection c, String bootloaderArgs) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_PV_bootloader_args"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootloaderArgs)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the PV/legacy_args field of the given VM. + * + * @param legacyArgs New value to set + */ + public void setPVLegacyArgs(Connection c, String legacyArgs) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_PV_legacy_args"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(legacyArgs)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the HVM/boot_policy field of the given VM. + * + * @param bootPolicy New value to set + */ + public void setHVMBootPolicy(Connection c, String bootPolicy) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_HVM_boot_policy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootPolicy)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the HVM/boot_params field of the given VM. + * + * @param bootParams New value to set + */ + public void setHVMBootParams(Connection c, Map bootParams) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_HVM_boot_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(bootParams)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the HVM/boot_params field of the given VM. + * + * @param key Key to add + * @param value Value to add + */ + public void addToHVMBootParams(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.add_to_HVM_boot_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the HVM/boot_params field of the given VM. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromHVMBootParams(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.remove_from_HVM_boot_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the platform field of the given VM. + * + * @param platform New value to set + */ + public void setPlatform(Connection c, Map platform) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_platform"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(platform)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the platform field of the given VM. + * + * @param key Key to add + * @param value Value to add + */ + public void addToPlatform(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.add_to_platform"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the platform field of the given VM. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromPlatform(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.remove_from_platform"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the PCI_bus field of the given VM. + * @deprecated + * + * @param PCIBus New value to set + */ + @Deprecated public void setPCIBus(Connection c, String PCIBus) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_PCI_bus"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(PCIBus)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the other_config field of the given VM. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VM. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VM. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the recommendations field of the given VM. + * + * @param recommendations New value to set + */ + public void setRecommendations(Connection c, String recommendations) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_recommendations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(recommendations)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the xenstore_data field of the given VM. + * + * @param xenstoreData New value to set + */ + public void setXenstoreData(Connection c, Map xenstoreData) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_xenstore_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(xenstoreData)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the xenstore_data field of the given VM. + * + * @param key Key to add + * @param value Value to add + */ + public void addToXenstoreData(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.add_to_xenstore_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the xenstore_data field of the given VM. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromXenstoreData(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.remove_from_xenstore_data"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the tags field of the given VM. + * + * @param tags New value to set + */ + public void setTags(Connection c, Set tags) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given value to the tags field of the given VM. If the value is already in that Set, then do nothing. + * + * @param value New value to add + */ + public void addTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.add_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given value from the tags field of the given VM. If the value is not in that Set, then do nothing. + * + * @param value Value to remove + */ + public void removeTags(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.remove_tags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the blocked_operations field of the given VM. + * + * @param blockedOperations New value to set + */ + public void setBlockedOperations(Connection c, Map blockedOperations) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_blocked_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(blockedOperations)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the blocked_operations field of the given VM. + * + * @param key Key to add + * @param value Value to add + */ + public void addToBlockedOperations(Connection c, Types.VmOperations key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.add_to_blocked_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the blocked_operations field of the given VM. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromBlockedOperations(Connection c, Types.VmOperations key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.remove_from_blocked_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the suspend_SR field of the given VM. + * + * @param suspendSR New value to set + */ + public void setSuspendSR(Connection c, SR suspendSR) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_suspend_SR"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(suspendSR)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Snapshots the specified VM, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). + * + * @param newName The name of the snapshotted VM + * @return Task + */ + public Task snapshotAsync(Connection c, String newName) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed { + String method_call = "Async.VM.snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Snapshots the specified VM, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). + * + * @param newName The name of the snapshotted VM + * @return The reference of the newly created VM. + */ + public VM snapshot(Connection c, String newName) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed { + String method_call = "VM.snapshot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Snapshots the specified VM with quiesce, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). + * + * @param newName The name of the snapshotted VM + * @return Task + */ + public Task snapshotWithQuiesceAsync(Connection c, String newName) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed, + Types.VmSnapshotWithQuiesceFailed, + Types.VmSnapshotWithQuiesceTimeout, + Types.VmSnapshotWithQuiescePluginDeosNotRespond, + Types.VmSnapshotWithQuiesceNotSupported { + String method_call = "Async.VM.snapshot_with_quiesce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Snapshots the specified VM with quiesce, making a new VM. Snapshot automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). + * + * @param newName The name of the snapshotted VM + * @return The reference of the newly created VM. + */ + public VM snapshotWithQuiesce(Connection c, String newName) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed, + Types.VmSnapshotWithQuiesceFailed, + Types.VmSnapshotWithQuiesceTimeout, + Types.VmSnapshotWithQuiescePluginDeosNotRespond, + Types.VmSnapshotWithQuiesceNotSupported { + String method_call = "VM.snapshot_with_quiesce"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Clones the specified VM, making a new VM. Clone automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). This function can only be called when the VM is in the Halted State. + * + * @param newName The name of the cloned VM + * @return Task + */ + public Task createCloneAsync(Connection c, String newName) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed { + String method_call = "Async.VM.clone"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Clones the specified VM, making a new VM. Clone automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write). This function can only be called when the VM is in the Halted State. + * + * @param newName The name of the cloned VM + * @return The reference of the newly created VM. + */ + public VM createClone(Connection c, String newName) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed { + String method_call = "VM.clone"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Copied the specified VM, making a new VM. Unlike clone, copy does not exploits the capabilities of the underlying storage repository in which the VM's disk images are stored. Instead, copy guarantees that the disk images of the newly created VM will be 'full disks' - i.e. not part of a CoW chain. This function can only be called when the VM is in the Halted State. + * + * @param newName The name of the copied VM + * @param sr An SR to copy all the VM's disks into (if an invalid reference then it uses the existing SRs) + * @return Task + */ + public Task copyAsync(Connection c, String newName, SR sr) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed { + String method_call = "Async.VM.copy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName), Marshalling.toXMLRPC(sr)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Copied the specified VM, making a new VM. Unlike clone, copy does not exploits the capabilities of the underlying storage repository in which the VM's disk images are stored. Instead, copy guarantees that the disk images of the newly created VM will be 'full disks' - i.e. not part of a CoW chain. This function can only be called when the VM is in the Halted State. + * + * @param newName The name of the copied VM + * @param sr An SR to copy all the VM's disks into (if an invalid reference then it uses the existing SRs) + * @return The reference of the newly created VM. + */ + public VM copy(Connection c, String newName, SR sr) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed { + String method_call = "VM.copy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName), Marshalling.toXMLRPC(sr)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Reverts the specified VM to a previous state. + * + * @return Task + */ + public Task revertAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OperationNotAllowed, + Types.SrFull, + Types.VmRevertFailed { + String method_call = "Async.VM.revert"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Reverts the specified VM to a previous state. + * + */ + public void revert(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OperationNotAllowed, + Types.SrFull, + Types.VmRevertFailed { + String method_call = "VM.revert"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Checkpoints the specified VM, making a new VM. Checkpoint automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write) and saves the memory image as well. + * + * @param newName The name of the checkpointed VM + * @return Task + */ + public Task checkpointAsync(Connection c, String newName) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed, + Types.VmCheckpointSuspendFailed, + Types.VmCheckpointResumeFailed { + String method_call = "Async.VM.checkpoint"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Checkpoints the specified VM, making a new VM. Checkpoint automatically exploits the capabilities of the underlying storage repository in which the VM's disk images are stored (e.g. Copy on Write) and saves the memory image as well. + * + * @param newName The name of the checkpointed VM + * @return The reference of the newly created VM. + */ + public VM checkpoint(Connection c, String newName) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed, + Types.VmCheckpointSuspendFailed, + Types.VmCheckpointResumeFailed { + String method_call = "VM.checkpoint"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(newName)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Inspects the disk configuration contained within the VM's other_config, creates VDIs and VBDs and then executes any applicable post-install script. + * + * @return Task + */ + public Task provisionAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed { + String method_call = "Async.VM.provision"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Inspects the disk configuration contained within the VM's other_config, creates VDIs and VBDs and then executes any applicable post-install script. + * + */ + public void provision(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.SrFull, + Types.OperationNotAllowed { + String method_call = "VM.provision"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Start the specified VM. This function can only be called with the VM is in the Halted State. + * + * @param startPaused Instantiate VM in paused state if set to true. + * @param force Attempt to force the VM to start. If this flag is false then the VM may fail pre-boot safety checks (e.g. if the CPU the VM last booted on looks substantially different to the current one) + * @return Task + */ + public Task startAsync(Connection c, Boolean startPaused, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.VmHvmRequired, + Types.VmIsTemplate, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.BootloaderFailed, + Types.UnknownBootloader, + Types.NoHostsAvailable, + Types.LicenceRestriction { + String method_call = "Async.VM.start"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Start the specified VM. This function can only be called with the VM is in the Halted State. + * + * @param startPaused Instantiate VM in paused state if set to true. + * @param force Attempt to force the VM to start. If this flag is false then the VM may fail pre-boot safety checks (e.g. if the CPU the VM last booted on looks substantially different to the current one) + */ + public void start(Connection c, Boolean startPaused, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.VmHvmRequired, + Types.VmIsTemplate, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.BootloaderFailed, + Types.UnknownBootloader, + Types.NoHostsAvailable, + Types.LicenceRestriction { + String method_call = "VM.start"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Start the specified VM on a particular host. This function can only be called with the VM is in the Halted State. + * + * @param host The Host on which to start the VM + * @param startPaused Instantiate VM in paused state if set to true. + * @param force Attempt to force the VM to start. If this flag is false then the VM may fail pre-boot safety checks (e.g. if the CPU the VM last booted on looks substantially different to the current one) + * @return Task + */ + public Task startOnAsync(Connection c, Host host, Boolean startPaused, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.VmIsTemplate, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.BootloaderFailed, + Types.UnknownBootloader { + String method_call = "Async.VM.start_on"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Start the specified VM on a particular host. This function can only be called with the VM is in the Halted State. + * + * @param host The Host on which to start the VM + * @param startPaused Instantiate VM in paused state if set to true. + * @param force Attempt to force the VM to start. If this flag is false then the VM may fail pre-boot safety checks (e.g. if the CPU the VM last booted on looks substantially different to the current one) + */ + public void startOn(Connection c, Host host, Boolean startPaused, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.VmIsTemplate, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.BootloaderFailed, + Types.UnknownBootloader { + String method_call = "VM.start_on"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Pause the specified VM. This can only be called when the specified VM is in the Running state. + * + * @return Task + */ + public Task pauseAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.pause"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Pause the specified VM. This can only be called when the specified VM is in the Running state. + * + */ + public void pause(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.pause"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Resume the specified VM. This can only be called when the specified VM is in the Paused state. + * + * @return Task + */ + public Task unpauseAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.unpause"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Resume the specified VM. This can only be called when the specified VM is in the Paused state. + * + */ + public void unpause(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.unpause"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Attempt to cleanly shutdown the specified VM. (Note: this may not be supported---e.g. if a guest agent is not installed). This can only be called when the specified VM is in the Running state. + * + * @return Task + */ + public Task cleanShutdownAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.clean_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Attempt to cleanly shutdown the specified VM. (Note: this may not be supported---e.g. if a guest agent is not installed). This can only be called when the specified VM is in the Running state. + * + */ + public void cleanShutdown(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.clean_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Attempt to cleanly shutdown the specified VM (Note: this may not be supported---e.g. if a guest agent is not installed). This can only be called when the specified VM is in the Running state. + * + * @return Task + */ + public Task cleanRebootAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.clean_reboot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Attempt to cleanly shutdown the specified VM (Note: this may not be supported---e.g. if a guest agent is not installed). This can only be called when the specified VM is in the Running state. + * + */ + public void cleanReboot(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.clean_reboot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Stop executing the specified VM without attempting a clean shutdown. + * + * @return Task + */ + public Task hardShutdownAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.hard_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Stop executing the specified VM without attempting a clean shutdown. + * + */ + public void hardShutdown(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.hard_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Reset the power-state of the VM to halted in the database only. (Used to recover from slave failures in pooling scenarios by resetting the power-states of VMs running on dead slaves to halted.) This is a potentially dangerous operation; use with care. + * + * @return Task + */ + public Task powerStateResetAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.power_state_reset"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Reset the power-state of the VM to halted in the database only. (Used to recover from slave failures in pooling scenarios by resetting the power-states of VMs running on dead slaves to halted.) This is a potentially dangerous operation; use with care. + * + */ + public void powerStateReset(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.power_state_reset"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Stop executing the specified VM without attempting a clean shutdown and immediately restart the VM. + * + * @return Task + */ + public Task hardRebootAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.hard_reboot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Stop executing the specified VM without attempting a clean shutdown and immediately restart the VM. + * + */ + public void hardReboot(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.hard_reboot"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Suspend the specified VM to disk. This can only be called when the specified VM is in the Running state. + * + * @return Task + */ + public Task suspendAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.suspend"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Suspend the specified VM to disk. This can only be called when the specified VM is in the Running state. + * + */ + public void suspend(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.suspend"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Awaken the specified VM and resume it. This can only be called when the specified VM is in the Suspended state. + * + * @param startPaused Resume VM in paused state if set to true. + * @param force Attempt to force the VM to resume. If this flag is false then the VM may fail pre-resume safety checks (e.g. if the CPU the VM was running on looks substantially different to the current one) + * @return Task + */ + public Task resumeAsync(Connection c, Boolean startPaused, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.resume"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Awaken the specified VM and resume it. This can only be called when the specified VM is in the Suspended state. + * + * @param startPaused Resume VM in paused state if set to true. + * @param force Attempt to force the VM to resume. If this flag is false then the VM may fail pre-resume safety checks (e.g. if the CPU the VM was running on looks substantially different to the current one) + */ + public void resume(Connection c, Boolean startPaused, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.resume"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Awaken the specified VM and resume it on a particular Host. This can only be called when the specified VM is in the Suspended state. + * + * @param host The Host on which to resume the VM + * @param startPaused Resume VM in paused state if set to true. + * @param force Attempt to force the VM to resume. If this flag is false then the VM may fail pre-resume safety checks (e.g. if the CPU the VM was running on looks substantially different to the current one) + * @return Task + */ + public Task resumeOnAsync(Connection c, Host host, Boolean startPaused, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "Async.VM.resume_on"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Awaken the specified VM and resume it on a particular Host. This can only be called when the specified VM is in the Suspended state. + * + * @param host The Host on which to resume the VM + * @param startPaused Resume VM in paused state if set to true. + * @param force Attempt to force the VM to resume. If this flag is false then the VM may fail pre-resume safety checks (e.g. if the CPU the VM was running on looks substantially different to the current one) + */ + public void resumeOn(Connection c, Host host, Boolean startPaused, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OperationNotAllowed, + Types.VmIsTemplate { + String method_call = "VM.resume_on"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(startPaused), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Migrate a VM to another Host. This can only be called when the specified VM is in the Running state. + * + * @param host The target host + * @param options Extra configuration operations + * @return Task + */ + public Task poolMigrateAsync(Connection c, Host host, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.VmIsTemplate, + Types.OperationNotAllowed, + Types.VmMigrateFailed, + Types.VmMissingPvDrivers { + String method_call = "Async.VM.pool_migrate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Migrate a VM to another Host. This can only be called when the specified VM is in the Running state. + * + * @param host The target host + * @param options Extra configuration operations + */ + public void poolMigrate(Connection c, Host host, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState, + Types.OtherOperationInProgress, + Types.VmIsTemplate, + Types.OperationNotAllowed, + Types.VmMigrateFailed, + Types.VmMissingPvDrivers { + String method_call = "VM.pool_migrate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the number of VCPUs for a running VM + * + * @param nvcpu The number of VCPUs + * @return Task + */ + public Task setVCPUsNumberLiveAsync(Connection c, Long nvcpu) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_VCPUs_number_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(nvcpu)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the number of VCPUs for a running VM + * + * @param nvcpu The number of VCPUs + */ + public void setVCPUsNumberLive(Connection c, Long nvcpu) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_VCPUs_number_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(nvcpu)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to VM.VCPUs_params, and apply that value on the running VM + * + * @param key The key + * @param value The value + * @return Task + */ + public Task addToVCPUsParamsLiveAsync(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.add_to_VCPUs_params_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Add the given key-value pair to VM.VCPUs_params, and apply that value on the running VM + * + * @param key The key + * @param value The value + */ + public void addToVCPUsParamsLive(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.add_to_VCPUs_params_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the ha_restart_priority field + * + * @param value The value + */ + public void setHaRestartPriority(Connection c, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_ha_restart_priority"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the ha_always_run + * @deprecated + * + * @param value The value + */ + @Deprecated public void setHaAlwaysRun(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_ha_always_run"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Computes the virtualization memory overhead of a VM. + * + * @return Task + */ + public Task computeMemoryOverheadAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.compute_memory_overhead"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Computes the virtualization memory overhead of a VM. + * + * @return the virtualization memory overhead of the VM. + */ + public Long computeMemoryOverhead(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.compute_memory_overhead"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Set the value of the memory_dynamic_max field + * + * @param value The new value of memory_dynamic_max + */ + public void setMemoryDynamicMax(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_memory_dynamic_max"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the memory_dynamic_min field + * + * @param value The new value of memory_dynamic_min + */ + public void setMemoryDynamicMin(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_memory_dynamic_min"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the minimum and maximum amounts of physical memory the VM is allowed to use. + * + * @param min The new minimum value + * @param max The new maximum value + * @return Task + */ + public Task setMemoryDynamicRangeAsync(Connection c, Long min, Long max) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_memory_dynamic_range"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(min), Marshalling.toXMLRPC(max)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the minimum and maximum amounts of physical memory the VM is allowed to use. + * + * @param min The new minimum value + * @param max The new maximum value + */ + public void setMemoryDynamicRange(Connection c, Long min, Long max) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_memory_dynamic_range"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(min), Marshalling.toXMLRPC(max)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the memory_static_max field + * + * @param value The new value of memory_static_max + */ + public void setMemoryStaticMax(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.HaOperationWouldBreakFailoverPlan { + String method_call = "VM.set_memory_static_max"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the memory_static_min field + * + * @param value The new value of memory_static_min + */ + public void setMemoryStaticMin(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_memory_static_min"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the static (ie boot-time) range of virtual memory that the VM is allowed to use. + * + * @param min The new minimum value + * @param max The new maximum value + * @return Task + */ + public Task setMemoryStaticRangeAsync(Connection c, Long min, Long max) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_memory_static_range"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(min), Marshalling.toXMLRPC(max)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the static (ie boot-time) range of virtual memory that the VM is allowed to use. + * + * @param min The new minimum value + * @param max The new maximum value + */ + public void setMemoryStaticRange(Connection c, Long min, Long max) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_memory_static_range"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(min), Marshalling.toXMLRPC(max)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the memory limits of this VM. + * + * @param staticMin The new value of memory_static_min. + * @param staticMax The new value of memory_static_max. + * @param dynamicMin The new value of memory_dynamic_min. + * @param dynamicMax The new value of memory_dynamic_max. + * @return Task + */ + public Task setMemoryLimitsAsync(Connection c, Long staticMin, Long staticMax, Long dynamicMin, Long dynamicMax) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_memory_limits"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(staticMin), Marshalling.toXMLRPC(staticMax), Marshalling.toXMLRPC(dynamicMin), Marshalling.toXMLRPC(dynamicMax)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the memory limits of this VM. + * + * @param staticMin The new value of memory_static_min. + * @param staticMax The new value of memory_static_max. + * @param dynamicMin The new value of memory_dynamic_min. + * @param dynamicMax The new value of memory_dynamic_max. + */ + public void setMemoryLimits(Connection c, Long staticMin, Long staticMax, Long dynamicMin, Long dynamicMax) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_memory_limits"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(staticMin), Marshalling.toXMLRPC(staticMax), Marshalling.toXMLRPC(dynamicMin), Marshalling.toXMLRPC(dynamicMax)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the memory target for a running VM + * @deprecated + * + * @param target The target in bytes + * @return Task + */ + @Deprecated public Task setMemoryTargetLiveAsync(Connection c, Long target) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_memory_target_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(target)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the memory target for a running VM + * @deprecated + * + * @param target The target in bytes + */ + @Deprecated public void setMemoryTargetLive(Connection c, Long target) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_memory_target_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(target)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Wait for a running VM to reach its current memory target + * @deprecated + * + * @return Task + */ + @Deprecated public Task waitMemoryTargetLiveAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.wait_memory_target_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Wait for a running VM to reach its current memory target + * @deprecated + * + */ + @Deprecated public void waitMemoryTargetLive(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.wait_memory_target_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return true if the VM is currently 'co-operative' i.e. is expected to reach a balloon target and actually has done + * @deprecated + * + * @return Task + */ + @Deprecated public Task getCooperativeAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.get_cooperative"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Return true if the VM is currently 'co-operative' i.e. is expected to reach a balloon target and actually has done + * @deprecated + * + * @return true if the VM is currently 'co-operative'; false otherwise + */ + @Deprecated public Boolean getCooperative(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_cooperative"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Set the shadow memory multiplier on a halted VM + * + * @param value The new shadow memory multiplier to set + */ + public void setHVMShadowMultiplier(Connection c, Double value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_HVM_shadow_multiplier"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the shadow memory multiplier on a running VM + * + * @param multiplier The new shadow memory multiplier to set + * @return Task + */ + public Task setShadowMultiplierLiveAsync(Connection c, Double multiplier) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_shadow_multiplier_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(multiplier)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set the shadow memory multiplier on a running VM + * + * @param multiplier The new shadow memory multiplier to set + */ + public void setShadowMultiplierLive(Connection c, Double multiplier) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_shadow_multiplier_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(multiplier)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the maximum number of VCPUs for a halted VM + * + * @param value The new maximum number of VCPUs + */ + public void setVCPUsMax(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_VCPUs_max"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the number of startup VCPUs for a halted VM + * + * @param value The new maximum number of VCPUs + */ + public void setVCPUsAtStartup(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_VCPUs_at_startup"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Send the given key as a sysrq to this VM. The key is specified as a single character (a String of length 1). This can only be called when the specified VM is in the Running state. + * + * @param key The key to send + * @return Task + */ + public Task sendSysrqAsync(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState { + String method_call = "Async.VM.send_sysrq"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Send the given key as a sysrq to this VM. The key is specified as a single character (a String of length 1). This can only be called when the specified VM is in the Running state. + * + * @param key The key to send + */ + public void sendSysrq(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState { + String method_call = "VM.send_sysrq"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Send the named trigger to this VM. This can only be called when the specified VM is in the Running state. + * + * @param trigger The trigger to send + * @return Task + */ + public Task sendTriggerAsync(Connection c, String trigger) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState { + String method_call = "Async.VM.send_trigger"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(trigger)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Send the named trigger to this VM. This can only be called when the specified VM is in the Running state. + * + * @param trigger The trigger to send + */ + public void sendTrigger(Connection c, String trigger) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState { + String method_call = "VM.send_trigger"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(trigger)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Returns the maximum amount of guest memory which will fit, together with overheads, in the supplied amount of physical memory. If 'exact' is true then an exact calculation is performed using the VM's current settings. If 'exact' is false then a more conservative approximation is used + * + * @param total Total amount of physical RAM to fit within + * @param approximate If false the limit is calculated with the guest's current exact configuration. Otherwise a more approximate calculation is performed + * @return Task + */ + public Task maximiseMemoryAsync(Connection c, Long total, Boolean approximate) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.maximise_memory"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(total), Marshalling.toXMLRPC(approximate)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Returns the maximum amount of guest memory which will fit, together with overheads, in the supplied amount of physical memory. If 'exact' is true then an exact calculation is performed using the VM's current settings. If 'exact' is false then a more conservative approximation is used + * + * @param total Total amount of physical RAM to fit within + * @param approximate If false the limit is calculated with the guest's current exact configuration. Otherwise a more approximate calculation is performed + * @return The maximum possible static-max + */ + public Long maximiseMemory(Connection c, Long total, Boolean approximate) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.maximise_memory"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(total), Marshalling.toXMLRPC(approximate)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Migrate the VM to another host. This can only be called when the specified VM is in the Running state. + * + * @param dest The result of a Host.migrate_receive call. + * @param live Live migration + * @param vdiMap Map of source VDI to destination SR + * @param vifMap Map of source VIF to destination network + * @param options Other parameters + * @return Task + */ + public Task migrateSendAsync(Connection c, Map dest, Boolean live, Map vdiMap, Map vifMap, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState { + String method_call = "Async.VM.migrate_send"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dest), Marshalling.toXMLRPC(live), Marshalling.toXMLRPC(vdiMap), Marshalling.toXMLRPC(vifMap), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Migrate the VM to another host. This can only be called when the specified VM is in the Running state. + * + * @param dest The result of a Host.migrate_receive call. + * @param live Live migration + * @param vdiMap Map of source VDI to destination SR + * @param vifMap Map of source VIF to destination network + * @param options Other parameters + */ + public void migrateSend(Connection c, Map dest, Boolean live, Map vdiMap, Map vifMap, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmBadPowerState { + String method_call = "VM.migrate_send"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dest), Marshalling.toXMLRPC(live), Marshalling.toXMLRPC(vdiMap), Marshalling.toXMLRPC(vifMap), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Assert whether a VM can be migrated to the specified destination. + * + * @param dest The result of a VM.migrate_receive call. + * @param live Live migration + * @param vdiMap Map of source VDI to destination SR + * @param vifMap Map of source VIF to destination network + * @param options Other parameters + * @return Task + */ + public Task assertCanMigrateAsync(Connection c, Map dest, Boolean live, Map vdiMap, Map vifMap, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.assert_can_migrate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dest), Marshalling.toXMLRPC(live), Marshalling.toXMLRPC(vdiMap), Marshalling.toXMLRPC(vifMap), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Assert whether a VM can be migrated to the specified destination. + * + * @param dest The result of a VM.migrate_receive call. + * @param live Live migration + * @param vdiMap Map of source VDI to destination SR + * @param vifMap Map of source VIF to destination network + * @param options Other parameters + */ + public void assertCanMigrate(Connection c, Map dest, Boolean live, Map vdiMap, Map vifMap, Map options) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.assert_can_migrate"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dest), Marshalling.toXMLRPC(live), Marshalling.toXMLRPC(vdiMap), Marshalling.toXMLRPC(vifMap), Marshalling.toXMLRPC(options)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Returns a record describing the VM's dynamic state, initialised when the VM boots and updated to reflect runtime configuration changes e.g. CPU hotplug + * + * @return A record describing the VM + */ + public VM.Record getBootRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_boot_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMRecord(result); + } + + /** + * + * + * @return A set of data sources + */ + public Set getDataSources(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_data_sources"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfDataSourceRecord(result); + } + + /** + * Start recording the specified data source + * + * @param dataSource The data source to record + */ + public void recordDataSource(Connection c, String dataSource) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.record_data_source"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Query the latest value of the specified data source + * + * @param dataSource The data source to query + * @return The latest value, averaged over the last 5 seconds + */ + public Double queryDataSource(Connection c, String dataSource) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.query_data_source"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDouble(result); + } + + /** + * Forget the recorded statistics related to the specified data source + * + * @param dataSource The data source whose archives are to be forgotten + */ + public void forgetDataSourceArchives(Connection c, String dataSource) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.forget_data_source_archives"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(dataSource)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Check to see whether this operation is acceptable in the current state of the system, raising an error if the operation is invalid for some reason + * + * @param op proposed operation + * @return Task + */ + public Task assertOperationValidAsync(Connection c, Types.VmOperations op) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.assert_operation_valid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(op)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Check to see whether this operation is acceptable in the current state of the system, raising an error if the operation is invalid for some reason + * + * @param op proposed operation + */ + public void assertOperationValid(Connection c, Types.VmOperations op) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.assert_operation_valid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(op)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Recomputes the list of acceptable operations + * + * @return Task + */ + public Task updateAllowedOperationsAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.update_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Recomputes the list of acceptable operations + * + */ + public void updateAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.update_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Returns a list of the allowed values that a VBD device field can take + * + * @return The allowed values + */ + public Set getAllowedVBDDevices(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_allowed_VBD_devices"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Returns a list of the allowed values that a VIF device field can take + * + * @return The allowed values + */ + public Set getAllowedVIFDevices(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_allowed_VIF_devices"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Return the list of hosts on which this VM may run. + * + * @return Task + */ + public Task getPossibleHostsAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.get_possible_hosts"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Return the list of hosts on which this VM may run. + * + * @return The possible hosts + */ + public Set getPossibleHosts(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_possible_hosts"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfHost(result); + } + + /** + * Returns an error if the VM could not boot on this host for some reason + * + * @param host The host + * @return Task + */ + public Task assertCanBootHereAsync(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.HostNotEnoughFreeMemory, + Types.VmRequiresSr, + Types.VmHostIncompatibleVersion { + String method_call = "Async.VM.assert_can_boot_here"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Returns an error if the VM could not boot on this host for some reason + * + * @param host The host + */ + public void assertCanBootHere(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.HostNotEnoughFreeMemory, + Types.VmRequiresSr, + Types.VmHostIncompatibleVersion { + String method_call = "VM.assert_can_boot_here"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this VM + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return Task + */ + public Task createNewBlobAsync(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a placeholder for a named binary blob of data that is associated with this VM + * + * @param name The name associated with the blob + * @param mimeType The mime type for the data. Empty string translates to application/octet-stream + * @param _public True if the blob should be publicly available + * @return The reference of the blob, needed for populating its data + */ + public Blob createNewBlob(Connection c, String name, String mimeType, Boolean _public) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.create_new_blob"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBlob(result); + } + + /** + * Returns an error if the VM is not considered agile e.g. because it is tied to a resource local to a host + * + * @return Task + */ + public Task assertAgileAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.assert_agile"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Returns an error if the VM is not considered agile e.g. because it is tied to a resource local to a host + * + */ + public void assertAgile(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.assert_agile"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Returns mapping of hosts to ratings, indicating the suitability of starting the VM at that location according to wlb. Rating is replaced with an error if the VM cannot boot there. + * + * @return Task + */ + public Task retrieveWlbRecommendationsAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.retrieve_wlb_recommendations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Returns mapping of hosts to ratings, indicating the suitability of starting the VM at that location according to wlb. Rating is replaced with an error if the VM cannot boot there. + * + * @return The potential hosts and their corresponding recommendations or errors + */ + public Map> retrieveWlbRecommendations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.retrieve_wlb_recommendations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfHostSetOfString(result); + } + + /** + * Copy the BIOS strings from the given host to this VM + * + * @param host The host to copy the BIOS strings from + * @return Task + */ + public Task copyBiosStringsAsync(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.copy_bios_strings"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Copy the BIOS strings from the given host to this VM + * + * @param host The host to copy the BIOS strings from + */ + public void copyBiosStrings(Connection c, Host host) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.copy_bios_strings"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the protection_policy field + * + * @param value The value + */ + public void setProtectionPolicy(Connection c, VMPP value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_protection_policy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set this VM's start delay in seconds + * + * @param value This VM's start delay in seconds + * @return Task + */ + public Task setStartDelayAsync(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_start_delay"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set this VM's start delay in seconds + * + * @param value This VM's start delay in seconds + */ + public void setStartDelay(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_start_delay"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set this VM's shutdown delay in seconds + * + * @param value This VM's shutdown delay in seconds + * @return Task + */ + public Task setShutdownDelayAsync(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_shutdown_delay"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set this VM's shutdown delay in seconds + * + * @param value This VM's shutdown delay in seconds + */ + public void setShutdownDelay(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_shutdown_delay"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set this VM's boot order + * + * @param value This VM's boot order + * @return Task + */ + public Task setOrderAsync(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_order"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set this VM's boot order + * + * @param value This VM's boot order + */ + public void setOrder(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_order"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set this VM's suspend VDI, which must be indentical to its current one + * + * @param value The suspend VDI uuid + * @return Task + */ + public Task setSuspendVDIAsync(Connection c, VDI value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_suspend_VDI"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Set this VM's suspend VDI, which must be indentical to its current one + * + * @param value The suspend VDI uuid + */ + public void setSuspendVDI(Connection c, VDI value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_suspend_VDI"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Assert whether all SRs required to recover this VM are available. + * + * @param sessionTo The session to which the VM is to be recovered. + * @return Task + */ + public Task assertCanBeRecoveredAsync(Connection c, Session sessionTo) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmIsPartOfAnAppliance, + Types.VmRequiresSr { + String method_call = "Async.VM.assert_can_be_recovered"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Assert whether all SRs required to recover this VM are available. + * + * @param sessionTo The session to which the VM is to be recovered. + */ + public void assertCanBeRecovered(Connection c, Session sessionTo) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmIsPartOfAnAppliance, + Types.VmRequiresSr { + String method_call = "VM.assert_can_be_recovered"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Recover the VM + * + * @param sessionTo The session to which the VM is to be recovered. + * @param force Whether the VM should replace newer versions of itself. + * @return Task + */ + public Task recoverAsync(Connection c, Session sessionTo, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.recover"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Recover the VM + * + * @param sessionTo The session to which the VM is to be recovered. + * @param force Whether the VM should replace newer versions of itself. + */ + public void recover(Connection c, Session sessionTo, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.recover"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Import using a conversion service. + * + * @param type Type of the conversion + * @param username Admin username on the host + * @param password Password on the host + * @param sr The destination SR + * @param remoteConfig Remote configuration options + * @return Task + */ + public static Task importConvertAsync(Connection c, String type, String username, String password, SR sr, Map remoteConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.import_convert"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(username), Marshalling.toXMLRPC(password), Marshalling.toXMLRPC(sr), Marshalling.toXMLRPC(remoteConfig)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Import using a conversion service. + * + * @param type Type of the conversion + * @param username Admin username on the host + * @param password Password on the host + * @param sr The destination SR + * @param remoteConfig Remote configuration options + */ + public static void importConvert(Connection c, String type, String username, String password, SR sr, Map remoteConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.import_convert"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(username), Marshalling.toXMLRPC(password), Marshalling.toXMLRPC(sr), Marshalling.toXMLRPC(remoteConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Assign this VM to an appliance. + * + * @param value The appliance to which this VM should be assigned. + * @return Task + */ + public Task setApplianceAsync(Connection c, VMAppliance value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.set_appliance"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Assign this VM to an appliance. + * + * @param value The appliance to which this VM should be assigned. + */ + public void setAppliance(Connection c, VMAppliance value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.set_appliance"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Query the system services advertised by this VM and register them. This can only be applied to a system domain. + * + * @return Task + */ + public Task queryServicesAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM.query_services"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Query the system services advertised by this VM and register them. This can only be applied to a system domain. + * + * @return map of service type to name + */ + public Map queryServices(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.query_services"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Return a list of all the VMs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVM(result); + } + + /** + * Return a map of VM references to VM records for all VMs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMVMRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VMAppliance.java b/deps/XenServerJava/src/com/xensource/xenapi/VMAppliance.java new file mode 100644 index 00000000000..a04026314b9 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VMAppliance.java @@ -0,0 +1,655 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * VM appliance + * + * @author Citrix Systems, Inc. + */ +public class VMAppliance extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VMAppliance(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VMAppliance, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VMAppliance) + { + VMAppliance other = (VMAppliance) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VMAppliance + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations); + print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations); + print.printf("%1$20s: %2$s\n", "VMs", this.VMs); + return writer.toString(); + } + + /** + * Convert a VM_appliance.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet() : this.allowedOperations); + map.put("current_operations", this.currentOperations == null ? new HashMap() : this.currentOperations); + map.put("VMs", this.VMs == null ? new LinkedHashSet() : this.VMs); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client. + */ + public Set allowedOperations; + /** + * links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task. + */ + public Map currentOperations; + /** + * all VMs in this appliance + */ + public Set VMs; + } + + /** + * Get a record containing the current state of the given VM_appliance. + * + * @return all fields from the object + */ + public VMAppliance.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMApplianceRecord(result); + } + + /** + * Get a reference to the VM_appliance instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VMAppliance getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMAppliance(result); + } + + /** + * Create a new VM_appliance instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, VMAppliance.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM_appliance.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VM_appliance instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static VMAppliance create(Connection c, VMAppliance.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMAppliance(result); + } + + /** + * Destroy the specified VM_appliance instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VM_appliance.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified VM_appliance instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get all the VM_appliance instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVMAppliance(result); + } + + /** + * Get the uuid field of the given VM_appliance. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given VM_appliance. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given VM_appliance. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the allowed_operations field of the given VM_appliance. + * + * @return value of the field + */ + public Set getAllowedOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_allowed_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVmApplianceOperation(result); + } + + /** + * Get the current_operations field of the given VM_appliance. + * + * @return value of the field + */ + public Map getCurrentOperations(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_current_operations"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringVmApplianceOperation(result); + } + + /** + * Get the VMs field of the given VM_appliance. + * + * @return value of the field + */ + public Set getVMs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_VMs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVM(result); + } + + /** + * Set the name/label field of the given VM_appliance. + * + * @param label New value to set + */ + public void setNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name/description field of the given VM_appliance. + * + * @param description New value to set + */ + public void setNameDescription(Connection c, String description) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Start all VMs in the appliance + * + * @param paused Instantiate all VMs belonging to this appliance in paused state if set to true. + * @return Task + */ + public Task startAsync(Connection c, Boolean paused) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationPartiallyFailed { + String method_call = "Async.VM_appliance.start"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(paused)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Start all VMs in the appliance + * + * @param paused Instantiate all VMs belonging to this appliance in paused state if set to true. + */ + public void start(Connection c, Boolean paused) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationPartiallyFailed { + String method_call = "VM_appliance.start"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(paused)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Perform a clean shutdown of all the VMs in the appliance + * + * @return Task + */ + public Task cleanShutdownAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationPartiallyFailed { + String method_call = "Async.VM_appliance.clean_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Perform a clean shutdown of all the VMs in the appliance + * + */ + public void cleanShutdown(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationPartiallyFailed { + String method_call = "VM_appliance.clean_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Perform a hard shutdown of all the VMs in the appliance + * + * @return Task + */ + public Task hardShutdownAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationPartiallyFailed { + String method_call = "Async.VM_appliance.hard_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Perform a hard shutdown of all the VMs in the appliance + * + */ + public void hardShutdown(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationPartiallyFailed { + String method_call = "VM_appliance.hard_shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * For each VM in the appliance, try to shut it down cleanly. If this fails, perform a hard shutdown of the VM. + * + * @return Task + */ + public Task shutdownAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationPartiallyFailed { + String method_call = "Async.VM_appliance.shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * For each VM in the appliance, try to shut it down cleanly. If this fails, perform a hard shutdown of the VM. + * + */ + public void shutdown(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.OperationPartiallyFailed { + String method_call = "VM_appliance.shutdown"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Assert whether all SRs required to recover this VM appliance are available. + * + * @param sessionTo The session to which the VM appliance is to be recovered. + * @return Task + */ + public Task assertCanBeRecoveredAsync(Connection c, Session sessionTo) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmRequiresSr { + String method_call = "Async.VM_appliance.assert_can_be_recovered"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Assert whether all SRs required to recover this VM appliance are available. + * + * @param sessionTo The session to which the VM appliance is to be recovered. + */ + public void assertCanBeRecovered(Connection c, Session sessionTo) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmRequiresSr { + String method_call = "VM_appliance.assert_can_be_recovered"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Recover the VM appliance + * + * @param sessionTo The session to which the VM appliance is to be recovered. + * @param force Whether the VMs should replace newer versions of themselves. + * @return Task + */ + public Task recoverAsync(Connection c, Session sessionTo, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmRequiresSr { + String method_call = "Async.VM_appliance.recover"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Recover the VM appliance + * + * @param sessionTo The session to which the VM appliance is to be recovered. + * @param force Whether the VMs should replace newer versions of themselves. + */ + public void recover(Connection c, Session sessionTo, Boolean force) throws + BadServerResponse, + XenAPIException, + XmlRpcException, + Types.VmRequiresSr { + String method_call = "VM_appliance.recover"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo), Marshalling.toXMLRPC(force)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VM_appliances known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVMAppliance(result); + } + + /** + * Return a map of VM_appliance references to VM_appliance records for all VM_appliances known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_appliance.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMApplianceVMApplianceRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java new file mode 100644 index 00000000000..9a6caf052bd --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java @@ -0,0 +1,487 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * The metrics reported by the guest (as opposed to inferred from outside) + * + * @author Citrix Systems, Inc. + */ +public class VMGuestMetrics extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VMGuestMetrics(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VMGuestMetrics, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VMGuestMetrics) + { + VMGuestMetrics other = (VMGuestMetrics) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VMGuestMetrics + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "osVersion", this.osVersion); + print.printf("%1$20s: %2$s\n", "PVDriversVersion", this.PVDriversVersion); + print.printf("%1$20s: %2$s\n", "PVDriversUpToDate", this.PVDriversUpToDate); + print.printf("%1$20s: %2$s\n", "memory", this.memory); + print.printf("%1$20s: %2$s\n", "disks", this.disks); + print.printf("%1$20s: %2$s\n", "networks", this.networks); + print.printf("%1$20s: %2$s\n", "other", this.other); + print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + print.printf("%1$20s: %2$s\n", "live", this.live); + return writer.toString(); + } + + /** + * Convert a VM_guest_metrics.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("os_version", this.osVersion == null ? new HashMap() : this.osVersion); + map.put("PV_drivers_version", this.PVDriversVersion == null ? new HashMap() : this.PVDriversVersion); + map.put("PV_drivers_up_to_date", this.PVDriversUpToDate == null ? false : this.PVDriversUpToDate); + map.put("memory", this.memory == null ? new HashMap() : this.memory); + map.put("disks", this.disks == null ? new HashMap() : this.disks); + map.put("networks", this.networks == null ? new HashMap() : this.networks); + map.put("other", this.other == null ? new HashMap() : this.other); + map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + map.put("live", this.live == null ? false : this.live); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * version of the OS + */ + public Map osVersion; + /** + * version of the PV drivers + */ + public Map PVDriversVersion; + /** + * true if the PV drivers appear to be up to date + */ + public Boolean PVDriversUpToDate; + /** + * free/used/total memory + */ + public Map memory; + /** + * disk configuration/free space + */ + public Map disks; + /** + * network configuration + */ + public Map networks; + /** + * anything else + */ + public Map other; + /** + * Time at which this information was last updated + */ + public Date lastUpdated; + /** + * additional configuration + */ + public Map otherConfig; + /** + * True if the guest is sending heartbeat messages via the guest agent + */ + public Boolean live; + } + + /** + * Get a record containing the current state of the given VM_guest_metrics. + * + * @return all fields from the object + */ + public VMGuestMetrics.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMGuestMetricsRecord(result); + } + + /** + * Get a reference to the VM_guest_metrics instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VMGuestMetrics getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMGuestMetrics(result); + } + + /** + * Get the uuid field of the given VM_guest_metrics. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the os_version field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Map getOsVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_os_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the PV_drivers_version field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Map getPVDriversVersion(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_PV_drivers_version"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the PV_drivers_up_to_date field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Boolean getPVDriversUpToDate(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_PV_drivers_up_to_date"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the memory field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Map getMemory(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_memory"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the disks field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Map getDisks(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_disks"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the networks field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Map getNetworks(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_networks"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the other field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Map getOther(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_other"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the last_updated field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Date getLastUpdated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_last_updated"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the other_config field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the live field of the given VM_guest_metrics. + * + * @return value of the field + */ + public Boolean getLive(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_live"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Set the other_config field of the given VM_guest_metrics. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VM_guest_metrics. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VM_guest_metrics. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VM_guest_metrics instances known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVMGuestMetrics(result); + } + + /** + * Return a map of VM_guest_metrics references to VM_guest_metrics records for all VM_guest_metrics instances known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_guest_metrics.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMGuestMetricsVMGuestMetricsRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java b/deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java new file mode 100644 index 00000000000..8544e42e143 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java @@ -0,0 +1,510 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * The metrics associated with a VM + * + * @author Citrix Systems, Inc. + */ +public class VMMetrics extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VMMetrics(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VMMetrics, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VMMetrics) + { + VMMetrics other = (VMMetrics) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VMMetrics + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "memoryActual", this.memoryActual); + print.printf("%1$20s: %2$s\n", "VCPUsNumber", this.VCPUsNumber); + print.printf("%1$20s: %2$s\n", "VCPUsUtilisation", this.VCPUsUtilisation); + print.printf("%1$20s: %2$s\n", "VCPUsCPU", this.VCPUsCPU); + print.printf("%1$20s: %2$s\n", "VCPUsParams", this.VCPUsParams); + print.printf("%1$20s: %2$s\n", "VCPUsFlags", this.VCPUsFlags); + print.printf("%1$20s: %2$s\n", "state", this.state); + print.printf("%1$20s: %2$s\n", "startTime", this.startTime); + print.printf("%1$20s: %2$s\n", "installTime", this.installTime); + print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated); + print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig); + return writer.toString(); + } + + /** + * Convert a VM_metrics.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("memory_actual", this.memoryActual == null ? 0 : this.memoryActual); + map.put("VCPUs_number", this.VCPUsNumber == null ? 0 : this.VCPUsNumber); + map.put("VCPUs_utilisation", this.VCPUsUtilisation == null ? new HashMap() : this.VCPUsUtilisation); + map.put("VCPUs_CPU", this.VCPUsCPU == null ? new HashMap() : this.VCPUsCPU); + map.put("VCPUs_params", this.VCPUsParams == null ? new HashMap() : this.VCPUsParams); + map.put("VCPUs_flags", this.VCPUsFlags == null ? new HashMap>() : this.VCPUsFlags); + map.put("state", this.state == null ? new LinkedHashSet() : this.state); + map.put("start_time", this.startTime == null ? new Date(0) : this.startTime); + map.put("install_time", this.installTime == null ? new Date(0) : this.installTime); + map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated); + map.put("other_config", this.otherConfig == null ? new HashMap() : this.otherConfig); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * Guest's actual memory (bytes) + */ + public Long memoryActual; + /** + * Current number of VCPUs + */ + public Long VCPUsNumber; + /** + * Utilisation for all of guest's current VCPUs + */ + public Map VCPUsUtilisation; + /** + * VCPU to PCPU map + */ + public Map VCPUsCPU; + /** + * The live equivalent to VM.VCPUs_params + */ + public Map VCPUsParams; + /** + * CPU flags (blocked,online,running) + */ + public Map> VCPUsFlags; + /** + * The state of the guest, eg blocked, dying etc + */ + public Set state; + /** + * Time at which this VM was last booted + */ + public Date startTime; + /** + * Time at which the VM was installed + */ + public Date installTime; + /** + * Time at which this information was last updated + */ + public Date lastUpdated; + /** + * additional configuration + */ + public Map otherConfig; + } + + /** + * Get a record containing the current state of the given VM_metrics. + * + * @return all fields from the object + */ + public VMMetrics.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMMetricsRecord(result); + } + + /** + * Get a reference to the VM_metrics instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VMMetrics getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMMetrics(result); + } + + /** + * Get the uuid field of the given VM_metrics. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the memory/actual field of the given VM_metrics. + * + * @return value of the field + */ + public Long getMemoryActual(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_memory_actual"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the VCPUs/number field of the given VM_metrics. + * + * @return value of the field + */ + public Long getVCPUsNumber(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_VCPUs_number"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the VCPUs/utilisation field of the given VM_metrics. + * + * @return value of the field + */ + public Map getVCPUsUtilisation(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_VCPUs_utilisation"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfLongDouble(result); + } + + /** + * Get the VCPUs/CPU field of the given VM_metrics. + * + * @return value of the field + */ + public Map getVCPUsCPU(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_VCPUs_CPU"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfLongLong(result); + } + + /** + * Get the VCPUs/params field of the given VM_metrics. + * + * @return value of the field + */ + public Map getVCPUsParams(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_VCPUs_params"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the VCPUs/flags field of the given VM_metrics. + * + * @return value of the field + */ + public Map> getVCPUsFlags(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_VCPUs_flags"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfLongSetOfString(result); + } + + /** + * Get the state field of the given VM_metrics. + * + * @return value of the field + */ + public Set getState(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_state"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Get the start_time field of the given VM_metrics. + * + * @return value of the field + */ + public Date getStartTime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_start_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the install_time field of the given VM_metrics. + * + * @return value of the field + */ + public Date getInstallTime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_install_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the last_updated field of the given VM_metrics. + * + * @return value of the field + */ + public Date getLastUpdated(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_last_updated"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the other_config field of the given VM_metrics. + * + * @return value of the field + */ + public Map getOtherConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Set the other_config field of the given VM_metrics. + * + * @param otherConfig New value to set + */ + public void setOtherConfig(Connection c, Map otherConfig) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.set_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Add the given key-value pair to the other_config field of the given VM_metrics. + * + * @param key Key to add + * @param value Value to add + */ + public void addToOtherConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.add_to_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Remove the given key and its corresponding value from the other_config field of the given VM_metrics. If the key is not in that Map, then do nothing. + * + * @param key Key to remove + */ + public void removeFromOtherConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.remove_from_other_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VM_metrics instances known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVMMetrics(result); + } + + /** + * Return a map of VM_metrics references to VM_metrics records for all VM_metrics instances known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VM_metrics.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMMetricsVMMetricsRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VMPP.java b/deps/XenServerJava/src/com/xensource/xenapi/VMPP.java new file mode 100644 index 00000000000..3e8d2fbdd42 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VMPP.java @@ -0,0 +1,1158 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * VM Protection Policy + * + * @author Citrix Systems, Inc. + */ +public class VMPP extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VMPP(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VMPP, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VMPP) + { + VMPP other = (VMPP) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VMPP + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel); + print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription); + print.printf("%1$20s: %2$s\n", "isPolicyEnabled", this.isPolicyEnabled); + print.printf("%1$20s: %2$s\n", "backupType", this.backupType); + print.printf("%1$20s: %2$s\n", "backupRetentionValue", this.backupRetentionValue); + print.printf("%1$20s: %2$s\n", "backupFrequency", this.backupFrequency); + print.printf("%1$20s: %2$s\n", "backupSchedule", this.backupSchedule); + print.printf("%1$20s: %2$s\n", "isBackupRunning", this.isBackupRunning); + print.printf("%1$20s: %2$s\n", "backupLastRunTime", this.backupLastRunTime); + print.printf("%1$20s: %2$s\n", "archiveTargetType", this.archiveTargetType); + print.printf("%1$20s: %2$s\n", "archiveTargetConfig", this.archiveTargetConfig); + print.printf("%1$20s: %2$s\n", "archiveFrequency", this.archiveFrequency); + print.printf("%1$20s: %2$s\n", "archiveSchedule", this.archiveSchedule); + print.printf("%1$20s: %2$s\n", "isArchiveRunning", this.isArchiveRunning); + print.printf("%1$20s: %2$s\n", "archiveLastRunTime", this.archiveLastRunTime); + print.printf("%1$20s: %2$s\n", "VMs", this.VMs); + print.printf("%1$20s: %2$s\n", "isAlarmEnabled", this.isAlarmEnabled); + print.printf("%1$20s: %2$s\n", "alarmConfig", this.alarmConfig); + print.printf("%1$20s: %2$s\n", "recentAlerts", this.recentAlerts); + return writer.toString(); + } + + /** + * Convert a VMPP.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("name_label", this.nameLabel == null ? "" : this.nameLabel); + map.put("name_description", this.nameDescription == null ? "" : this.nameDescription); + map.put("is_policy_enabled", this.isPolicyEnabled == null ? false : this.isPolicyEnabled); + map.put("backup_type", this.backupType == null ? Types.VmppBackupType.UNRECOGNIZED : this.backupType); + map.put("backup_retention_value", this.backupRetentionValue == null ? 0 : this.backupRetentionValue); + map.put("backup_frequency", this.backupFrequency == null ? Types.VmppBackupFrequency.UNRECOGNIZED : this.backupFrequency); + map.put("backup_schedule", this.backupSchedule == null ? new HashMap() : this.backupSchedule); + map.put("is_backup_running", this.isBackupRunning == null ? false : this.isBackupRunning); + map.put("backup_last_run_time", this.backupLastRunTime == null ? new Date(0) : this.backupLastRunTime); + map.put("archive_target_type", this.archiveTargetType == null ? Types.VmppArchiveTargetType.UNRECOGNIZED : this.archiveTargetType); + map.put("archive_target_config", this.archiveTargetConfig == null ? new HashMap() : this.archiveTargetConfig); + map.put("archive_frequency", this.archiveFrequency == null ? Types.VmppArchiveFrequency.UNRECOGNIZED : this.archiveFrequency); + map.put("archive_schedule", this.archiveSchedule == null ? new HashMap() : this.archiveSchedule); + map.put("is_archive_running", this.isArchiveRunning == null ? false : this.isArchiveRunning); + map.put("archive_last_run_time", this.archiveLastRunTime == null ? new Date(0) : this.archiveLastRunTime); + map.put("VMs", this.VMs == null ? new LinkedHashSet() : this.VMs); + map.put("is_alarm_enabled", this.isAlarmEnabled == null ? false : this.isAlarmEnabled); + map.put("alarm_config", this.alarmConfig == null ? new HashMap() : this.alarmConfig); + map.put("recent_alerts", this.recentAlerts == null ? new LinkedHashSet() : this.recentAlerts); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * a human-readable name + */ + public String nameLabel; + /** + * a notes field containing human-readable description + */ + public String nameDescription; + /** + * enable or disable this policy + */ + public Boolean isPolicyEnabled; + /** + * type of the backup sub-policy + */ + public Types.VmppBackupType backupType; + /** + * maximum number of backups that should be stored at any time + */ + public Long backupRetentionValue; + /** + * frequency of the backup schedule + */ + public Types.VmppBackupFrequency backupFrequency; + /** + * schedule of the backup containing 'hour', 'min', 'days'. Date/time-related information is in XenServer Local Timezone + */ + public Map backupSchedule; + /** + * true if this protection policy's backup is running + */ + public Boolean isBackupRunning; + /** + * time of the last backup + */ + public Date backupLastRunTime; + /** + * type of the archive target config + */ + public Types.VmppArchiveTargetType archiveTargetType; + /** + * configuration for the archive, including its 'location', 'username', 'password' + */ + public Map archiveTargetConfig; + /** + * frequency of the archive schedule + */ + public Types.VmppArchiveFrequency archiveFrequency; + /** + * schedule of the archive containing 'hour', 'min', 'days'. Date/time-related information is in XenServer Local Timezone + */ + public Map archiveSchedule; + /** + * true if this protection policy's archive is running + */ + public Boolean isArchiveRunning; + /** + * time of the last archive + */ + public Date archiveLastRunTime; + /** + * all VMs attached to this protection policy + */ + public Set VMs; + /** + * true if alarm is enabled for this policy + */ + public Boolean isAlarmEnabled; + /** + * configuration for the alarm + */ + public Map alarmConfig; + /** + * recent alerts + */ + public Set recentAlerts; + } + + /** + * Get a record containing the current state of the given VMPP. + * + * @return all fields from the object + */ + public VMPP.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMPPRecord(result); + } + + /** + * Get a reference to the VMPP instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VMPP getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMPP(result); + } + + /** + * Create a new VMPP instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, VMPP.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VMPP.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VMPP instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static VMPP create(Connection c, VMPP.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVMPP(result); + } + + /** + * Destroy the specified VMPP instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VMPP.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified VMPP instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get all the VMPP instances with the given label. + * + * @param label label of object to return + * @return references to objects with matching names + */ + public static Set getByNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_by_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVMPP(result); + } + + /** + * Get the uuid field of the given VMPP. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/label field of the given VMPP. + * + * @return value of the field + */ + public String getNameLabel(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the name/description field of the given VMPP. + * + * @return value of the field + */ + public String getNameDescription(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the is_policy_enabled field of the given VMPP. + * + * @return value of the field + */ + public Boolean getIsPolicyEnabled(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_is_policy_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the backup_type field of the given VMPP. + * + * @return value of the field + */ + public Types.VmppBackupType getBackupType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_backup_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVmppBackupType(result); + } + + /** + * Get the backup_retention_value field of the given VMPP. + * + * @return value of the field + */ + public Long getBackupRetentionValue(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_backup_retention_value"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toLong(result); + } + + /** + * Get the backup_frequency field of the given VMPP. + * + * @return value of the field + */ + public Types.VmppBackupFrequency getBackupFrequency(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_backup_frequency"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVmppBackupFrequency(result); + } + + /** + * Get the backup_schedule field of the given VMPP. + * + * @return value of the field + */ + public Map getBackupSchedule(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_backup_schedule"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the is_backup_running field of the given VMPP. + * + * @return value of the field + */ + public Boolean getIsBackupRunning(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_is_backup_running"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the backup_last_run_time field of the given VMPP. + * + * @return value of the field + */ + public Date getBackupLastRunTime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_backup_last_run_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the archive_target_type field of the given VMPP. + * + * @return value of the field + */ + public Types.VmppArchiveTargetType getArchiveTargetType(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_archive_target_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVmppArchiveTargetType(result); + } + + /** + * Get the archive_target_config field of the given VMPP. + * + * @return value of the field + */ + public Map getArchiveTargetConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_archive_target_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the archive_frequency field of the given VMPP. + * + * @return value of the field + */ + public Types.VmppArchiveFrequency getArchiveFrequency(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_archive_frequency"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVmppArchiveFrequency(result); + } + + /** + * Get the archive_schedule field of the given VMPP. + * + * @return value of the field + */ + public Map getArchiveSchedule(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_archive_schedule"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the is_archive_running field of the given VMPP. + * + * @return value of the field + */ + public Boolean getIsArchiveRunning(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_is_archive_running"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the archive_last_run_time field of the given VMPP. + * + * @return value of the field + */ + public Date getArchiveLastRunTime(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_archive_last_run_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toDate(result); + } + + /** + * Get the VMs field of the given VMPP. + * + * @return value of the field + */ + public Set getVMs(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_VMs"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVM(result); + } + + /** + * Get the is_alarm_enabled field of the given VMPP. + * + * @return value of the field + */ + public Boolean getIsAlarmEnabled(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_is_alarm_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toBoolean(result); + } + + /** + * Get the alarm_config field of the given VMPP. + * + * @return value of the field + */ + public Map getAlarmConfig(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_alarm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfStringString(result); + } + + /** + * Get the recent_alerts field of the given VMPP. + * + * @return value of the field + */ + public Set getRecentAlerts(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_recent_alerts"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * Set the name/label field of the given VMPP. + * + * @param label New value to set + */ + public void setNameLabel(Connection c, String label) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_name_label"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the name/description field of the given VMPP. + * + * @param description New value to set + */ + public void setNameDescription(Connection c, String description) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_name_description"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the is_policy_enabled field of the given VMPP. + * + * @param isPolicyEnabled New value to set + */ + public void setIsPolicyEnabled(Connection c, Boolean isPolicyEnabled) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_is_policy_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(isPolicyEnabled)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the backup_type field of the given VMPP. + * + * @param backupType New value to set + */ + public void setBackupType(Connection c, Types.VmppBackupType backupType) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_backup_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(backupType)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * This call executes the protection policy immediately + * + * @return An XMLRPC result + */ + public String protectNow(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.protect_now"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * This call archives the snapshot provided as a parameter + * + * @param snapshot The snapshot to archive + * @return An XMLRPC result + */ + public static String archiveNow(Connection c, VM snapshot) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.archive_now"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(snapshot)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * This call fetches a history of alerts for a given protection policy + * + * @param hoursFromNow how many hours in the past the oldest record to fetch is + * @return A list of alerts encoded in xml + */ + public Set getAlerts(Connection c, Long hoursFromNow) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_alerts"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(hoursFromNow)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfString(result); + } + + /** + * + * + * @param value the value to set + */ + public void setBackupRetentionValue(Connection c, Long value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_backup_retention_value"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the backup_frequency field + * + * @param value the backup frequency + */ + public void setBackupFrequency(Connection c, Types.VmppBackupFrequency value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_backup_frequency"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param value the value to set + */ + public void setBackupSchedule(Connection c, Map value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_backup_schedule"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the archive_frequency field + * + * @param value the archive frequency + */ + public void setArchiveFrequency(Connection c, Types.VmppArchiveFrequency value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_archive_frequency"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param value the value to set + */ + public void setArchiveSchedule(Connection c, Map value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_archive_schedule"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the archive_target_config_type field + * + * @param value the archive target config type + */ + public void setArchiveTargetType(Connection c, Types.VmppArchiveTargetType value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_archive_target_type"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param value the value to set + */ + public void setArchiveTargetConfig(Connection c, Map value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_archive_target_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Set the value of the is_alarm_enabled field + * + * @param value true if alarm is enabled for this policy + */ + public void setIsAlarmEnabled(Connection c, Boolean value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_is_alarm_enabled"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param value the value to set + */ + public void setAlarmConfig(Connection c, Map value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_alarm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param key the key to add + * @param value the value to add + */ + public void addToBackupSchedule(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.add_to_backup_schedule"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param key the key to add + * @param value the value to add + */ + public void addToArchiveTargetConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.add_to_archive_target_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param key the key to add + * @param value the value to add + */ + public void addToArchiveSchedule(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.add_to_archive_schedule"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param key the key to add + * @param value the value to add + */ + public void addToAlarmConfig(Connection c, String key, String value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.add_to_alarm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param key the key to remove + */ + public void removeFromBackupSchedule(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.remove_from_backup_schedule"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param key the key to remove + */ + public void removeFromArchiveTargetConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.remove_from_archive_target_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param key the key to remove + */ + public void removeFromArchiveSchedule(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.remove_from_archive_schedule"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param key the key to remove + */ + public void removeFromAlarmConfig(Connection c, String key) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.remove_from_alarm_config"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param value the value to set + */ + public void setBackupLastRunTime(Connection c, Date value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_backup_last_run_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * + * + * @param value the value to set + */ + public void setArchiveLastRunTime(Connection c, Date value) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.set_archive_last_run_time"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Return a list of all the VMPPs known to the system. + * + * @return references to all objects + */ + public static Set getAll(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_all"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toSetOfVMPP(result); + } + + /** + * Return a map of VMPP references to VMPP records for all VMPPs known to the system. + * + * @return records of all objects + */ + public static Map getAllRecords(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VMPP.get_all_records"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toMapOfVMPPVMPPRecord(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/VTPM.java b/deps/XenServerJava/src/com/xensource/xenapi/VTPM.java new file mode 100644 index 00000000000..71736a01664 --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/VTPM.java @@ -0,0 +1,290 @@ +/* + * Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +package com.xensource.xenapi; + +import com.xensource.xenapi.Types.BadServerResponse; +import com.xensource.xenapi.Types.VersionException; +import com.xensource.xenapi.Types.XenAPIException; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.xmlrpc.XmlRpcException; + +/** + * A virtual TPM device + * + * @author Citrix Systems, Inc. + */ +public class VTPM extends XenAPIObject { + + /** + * The XenAPI reference (OpaqueRef) to this object. + */ + protected final String ref; + + /** + * For internal use only. + */ + VTPM(String ref) { + this.ref = ref; + } + + /** + * @return The XenAPI reference (OpaqueRef) to this object. + */ + public String toWireString() { + return this.ref; + } + + /** + * If obj is a VTPM, compares XenAPI references for equality. + */ + @Override + public boolean equals(Object obj) + { + if (obj != null && obj instanceof VTPM) + { + VTPM other = (VTPM) obj; + return other.ref.equals(this.ref); + } else + { + return false; + } + } + + @Override + public int hashCode() + { + return ref.hashCode(); + } + + /** + * Represents all the fields in a VTPM + */ + public static class Record implements Types.Record { + public String toString() { + StringWriter writer = new StringWriter(); + PrintWriter print = new PrintWriter(writer); + print.printf("%1$20s: %2$s\n", "uuid", this.uuid); + print.printf("%1$20s: %2$s\n", "VM", this.VM); + print.printf("%1$20s: %2$s\n", "backend", this.backend); + return writer.toString(); + } + + /** + * Convert a VTPM.Record to a Map + */ + public Map toMap() { + Map map = new HashMap(); + map.put("uuid", this.uuid == null ? "" : this.uuid); + map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM); + map.put("backend", this.backend == null ? new VM("OpaqueRef:NULL") : this.backend); + return map; + } + + /** + * Unique identifier/object reference + */ + public String uuid; + /** + * the virtual machine + */ + public VM VM; + /** + * the domain where the backend is located + */ + public VM backend; + } + + /** + * Get a record containing the current state of the given VTPM. + * + * @return all fields from the object + */ + public VTPM.Record getRecord(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VTPM.get_record"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVTPMRecord(result); + } + + /** + * Get a reference to the VTPM instance with the specified UUID. + * + * @param uuid UUID of object to return + * @return reference to the object + */ + public static VTPM getByUuid(Connection c, String uuid) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VTPM.get_by_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVTPM(result); + } + + /** + * Create a new VTPM instance, and return its handle. + * + * @param record All constructor arguments + * @return Task + */ + public static Task createAsync(Connection c, VTPM.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VTPM.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Create a new VTPM instance, and return its handle. + * + * @param record All constructor arguments + * @return reference to the newly created object + */ + public static VTPM create(Connection c, VTPM.Record record) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VTPM.create"; + String session = c.getSessionReference(); + Map record_map = record.toMap(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVTPM(result); + } + + /** + * Destroy the specified VTPM instance. + * + * @return Task + */ + public Task destroyAsync(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "Async.VTPM.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toTask(result); + } + + /** + * Destroy the specified VTPM instance. + * + */ + public void destroy(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VTPM.destroy"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + return; + } + + /** + * Get the uuid field of the given VTPM. + * + * @return value of the field + */ + public String getUuid(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VTPM.get_uuid"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toString(result); + } + + /** + * Get the VM field of the given VTPM. + * + * @return value of the field + */ + public VM getVM(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VTPM.get_VM"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + + /** + * Get the backend field of the given VTPM. + * + * @return value of the field + */ + public VM getBackend(Connection c) throws + BadServerResponse, + XenAPIException, + XmlRpcException { + String method_call = "VTPM.get_backend"; + String session = c.getSessionReference(); + Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)}; + Map response = c.dispatch(method_call, method_params); + Object result = response.get("Value"); + return Types.toVM(result); + } + +} \ No newline at end of file diff --git a/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java b/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java new file mode 100644 index 00000000000..b678a7fa1ec --- /dev/null +++ b/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java @@ -0,0 +1,35 @@ +/* Copyright (c) Citrix Systems, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1) Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.xensource.xenapi; + +public abstract class XenAPIObject +{ + public abstract String toWireString(); +} From 2cc09c813a419ab7f81796b79abde849eb456698 Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Thu, 13 Dec 2012 09:42:43 -0500 Subject: [PATCH 079/145] CLOUDSTACK-594: Updating the XenServer java bindings used in cloudstack - part 3. Updating the xenserver java bindings used in cloudstack. This is part 3 of the change and it adds the customization's that have been made to them for cloudstack. 1. https://reviews.apache.org/r/8566/ - removes the old bindings. 2. https://reviews.apache.org/r/8567/ - introduces the latest bindings. 3. https://reviews.apache.org/r/8568/ - adds the customization's made to them for cloudstack. Signed-off-by: Chip Childers --- .../src/com/xensource/xenapi/Connection.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/deps/XenServerJava/src/com/xensource/xenapi/Connection.java b/deps/XenServerJava/src/com/xensource/xenapi/Connection.java index 805ddd01137..22f64d34fd3 100644 --- a/deps/XenServerJava/src/com/xensource/xenapi/Connection.java +++ b/deps/XenServerJava/src/com/xensource/xenapi/Connection.java @@ -38,6 +38,7 @@ import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfig; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcHttpClientConfig; +import org.apache.xmlrpc.client.XmlRpcSun15HttpTransportFactory; import com.xensource.xenapi.Types.BadServerResponse; import com.xensource.xenapi.Types.SessionAuthenticationFailed; @@ -65,6 +66,8 @@ public class Connection private APIVersion apiVersion; + protected int _wait = 600; + /** * Updated when Session.login_with_password() is called. */ @@ -159,10 +162,10 @@ public class Connection * When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually * logging out the Session. */ - public Connection(URL url) + public Connection(URL url, int wait) { deprecatedConstructorUsed = false; - + _wait = wait; this.client = getClientFromURL(url); } @@ -274,6 +277,8 @@ public class Connection { config.setTimeZone(TimeZone.getTimeZone("UTC")); config.setServerURL(url); + config.setReplyTimeout(_wait * 1000); + config.setConnectionTimeout(5000); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); return client; @@ -293,7 +298,7 @@ public class Connection /** * The (auto-generated parts of) the bindings dispatch XMLRPC calls on this Connection's client through this method. */ - Map dispatch(String method_call, Object[] method_params) throws XmlRpcException, XenAPIException + protected Map dispatch(String method_call, Object[] method_params) throws XmlRpcException, XenAPIException { Map response = (Map) client.execute(method_call, method_params); @@ -337,7 +342,7 @@ public class Connection new Connection(new URL(client_url.getProtocol(), (String)error[1], client_url.getPort(), - client_url.getFile())); + client_url.getFile()), _wait); tmp_conn.sessionReference = sessionReference; try { From 82a17a413b109002a9b42f04ba49515ea4fe4e0b Mon Sep 17 00:00:00 2001 From: Chip Childers Date: Thu, 13 Dec 2012 16:00:30 -0500 Subject: [PATCH 080/145] CLOUDSTACK-505: Removed logging of deployVirtualMachine and resetPasswordForVirtualMachine commands. Signed-off-by: Chip Childers --- server/src/com/cloud/api/ApiServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index 7365b36622f..019931cea2a 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -586,7 +586,7 @@ public class ApiServer implements HttpRequestHandler { return; } auditTrailSb.append(" " + HttpServletResponse.SC_OK + " "); - if (command.equals("createSSHKeyPair")){ + if (command.equals("createSSHKeyPair") || command.equals("deployVirtualMachine") || command.equals("resetPasswordForVirtualMachine")){ auditTrailSb.append("This result was not logged because it contains sensitive data."); } else { auditTrailSb.append(result); From fd6be7a37b892e1a4f10abbb435ba76a03f74fe8 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 13 Dec 2012 14:08:39 -0800 Subject: [PATCH 081/145] marvin: establishing some defaults when logging in just use defaults if no service dict values are provided --- tools/marvin/marvin/integration/lib/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py index e8c3b25bd89..0daea5dd579 100644 --- a/tools/marvin/marvin/integration/lib/base.py +++ b/tools/marvin/marvin/integration/lib/base.py @@ -205,10 +205,16 @@ class VirtualMachine: self.__dict__.update(items) if "username" in services: self.username = services["username"] + else: + self.username = 'root' if "password" in services: self.password = services["password"] + else: + self.password = 'password' if "ssh_port" in services: self.ssh_port = services["ssh_port"] + else: + self.ssh_port = 22 self.ssh_client = None #extract out the ipaddress self.ipaddress = self.nic[0].ipaddress From f05cd36634c17ad970797e813d8dcfe9a97e8465 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 13 Dec 2012 15:25:39 -0800 Subject: [PATCH 082/145] marvin: assertions with messages for common.py --- tools/marvin/marvin/integration/lib/common.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py index 5f90110c367..69aa733420e 100644 --- a/tools/marvin/marvin/integration/lib/common.py +++ b/tools/marvin/marvin/integration/lib/common.py @@ -81,7 +81,7 @@ def get_zone(apiclient, services=None): zones = apiclient.listZones(cmd) if isinstance(zones, list): - assert len(zones) > 0 + assert len(zones) > 0, "There are no available zones in the deployment" return zones[0] else: raise Exception("Failed to find specified zone.") @@ -100,7 +100,7 @@ def get_pod(apiclient, zoneid, services=None): pods = apiclient.listPods(cmd) if isinstance(pods, list): - assert len(pods) > 0 + assert len(pods) > 0, "No pods found for zone %s"%zoneid return pods[0] else: raise Exception("Exception: Failed to find specified pod.") @@ -129,10 +129,11 @@ def get_template(apiclient, zoneid, ostype, services=None): list_templates = apiclient.listTemplates(cmd) - assert len(list_templates) > 0 - for template in list_templates: - if template.ostypeid == ostypeid: - return template + if isinstance(list_templates, list): + assert len(list_templates) > 0, "received empty response on template of type %s"%ostype + for template in list_templates: + if template.ostypeid == ostypeid: + return template raise Exception("Exception: Failed to find template with OSTypeID: %s" % ostypeid) From 1ae2d720a3ca3bde2baacb0d06610e7466f95bfe Mon Sep 17 00:00:00 2001 From: Bill Rich Date: Fri, 7 Dec 2012 08:39:13 -0800 Subject: [PATCH 083/145] CLOUDSTACK-591: Changed bridge name parsing in security_group.py to support bridges named with dashes --- scripts/vm/network/security_group.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py index b0798907c8a..534f384f3d3 100755 --- a/scripts/vm/network/security_group.py +++ b/scripts/vm/network/security_group.py @@ -24,6 +24,7 @@ import sys import os import xml.dom.minidom from optparse import OptionParser, OptionGroup, OptParseError, BadOptionError, OptionError, OptionConflictError, OptionValueError +import re iptables = Command("iptables") bash = Command("/bin/bash") virsh = Command("virsh") @@ -425,7 +426,7 @@ def network_rules_for_rebooted_vm(vmName): brName = "cloudbr0" else: brName.pop() - brName = brName[0].split("-")[1] + brName = re.sub("^BF-", "", brName[0]) if 1 in [ vm_name.startswith(c) for c in ['r-', 's-', 'v-'] ]: From 6f29317a8492008d37c7eb0770f0cee650c14c40 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 13 Dec 2012 15:26:05 -0800 Subject: [PATCH 084/145] CLOUDSTACK-591: Fix execute and string processing logic for reboot_vm in security_group - Since we're always getting the first from the list, use head -1 to get the first of the results instead of processing again - Remove unecessay pop (why was it even there) Signed-off-by: Rohit Yadav --- scripts/vm/network/security_group.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py index 534f384f3d3..dcb01a7604b 100755 --- a/scripts/vm/network/security_group.py +++ b/scripts/vm/network/security_group.py @@ -421,12 +421,11 @@ def network_rules_for_rebooted_vm(vmName): delete_rules_for_vm_in_bridge_firewall_chain(vm_name) - brName = execute("iptables-save |grep physdev-is-bridged |grep FORWARD |grep BF |grep '\-o' |awk '{print $9}'").split("\n") - if brName is None: + brName = execute("iptables-save |grep physdev-is-bridged |grep FORWARD |grep BF |grep '\-o' |awk '{print $9}' | head -1").strip() + if brName is None or brName is "": brName = "cloudbr0" else: - brName.pop() - brName = re.sub("^BF-", "", brName[0]) + brName = re.sub("^BF-", "", brName) if 1 in [ vm_name.startswith(c) for c in ['r-', 's-', 'v-'] ]: From fb5ea25a4d50f4530fcf535d66d7b38e53612e00 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 13 Dec 2012 15:57:59 -0800 Subject: [PATCH 085/145] marvin: remoteSSHclient logs Adding logging for commands sent, and executed with results returned frmo the remote host. --- tools/marvin/marvin/remoteSSHClient.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py index 036e1c381e1..24ba0fe185f 100644 --- a/tools/marvin/marvin/remoteSSHClient.py +++ b/tools/marvin/marvin/remoteSSHClient.py @@ -19,6 +19,7 @@ import paramiko import time import cloudstackException import contextlib +import logging from contextlib import closing class remoteSSHClient(object): @@ -34,6 +35,7 @@ class remoteSSHClient(object): while True: try: self.ssh.connect(str(host),int(port), user, passwd) + logging.debug("[SSHClient] connecting to server %s @ port % with user:passwd %s:%s"%(str(host), port, user, passwd)) except paramiko.SSHException, sshex: if retry_count == 0: raise cloudstackException.InvalidParameterException(repr(sshex)) @@ -46,6 +48,7 @@ class remoteSSHClient(object): def execute(self, command): stdin, stdout, stderr = self.ssh.exec_command(command) + logging.debug("[SSHClient] sending command %s to host"%(command, str(self.host))) output = stdout.readlines() errors = stderr.readlines() results = [] @@ -57,7 +60,7 @@ class remoteSSHClient(object): else: for strOut in output: results.append(strOut.rstrip()) - + logging.debug("[SSHClient] command %s returned %s"%(command, results)) return results def scp(self, srcFile, destPath): From ceea53cd8ffb0b69043acfd1a3ef2cd220cf667c Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 13 Dec 2012 19:22:49 -0800 Subject: [PATCH 086/145] marvin: remoteSSHClient logger handler send the logs to the console stream --- tools/marvin/marvin/remoteSSHClient.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/marvin/marvin/remoteSSHClient.py b/tools/marvin/marvin/remoteSSHClient.py index 24ba0fe185f..95a9adab53f 100644 --- a/tools/marvin/marvin/remoteSSHClient.py +++ b/tools/marvin/marvin/remoteSSHClient.py @@ -30,12 +30,16 @@ class remoteSSHClient(object): self.passwd = passwd self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + self.logger = logging.getLogger('sshClient') + ch = logging.StreamHandler() + ch.setLevel(logging.DEBUG) + self.logger.addHandler(ch) retry_count = retries while True: try: self.ssh.connect(str(host),int(port), user, passwd) - logging.debug("[SSHClient] connecting to server %s @ port % with user:passwd %s:%s"%(str(host), port, user, passwd)) + self.logger.debug("connecting to server %s with user %s passwd %s"%(str(host), user, passwd)) except paramiko.SSHException, sshex: if retry_count == 0: raise cloudstackException.InvalidParameterException(repr(sshex)) @@ -48,7 +52,7 @@ class remoteSSHClient(object): def execute(self, command): stdin, stdout, stderr = self.ssh.exec_command(command) - logging.debug("[SSHClient] sending command %s to host"%(command, str(self.host))) + self.logger.debug("sending command %s to host %s"%(command, str(self.host))) output = stdout.readlines() errors = stderr.readlines() results = [] @@ -60,7 +64,7 @@ class remoteSSHClient(object): else: for strOut in output: results.append(strOut.rstrip()) - logging.debug("[SSHClient] command %s returned %s"%(command, results)) + self.logger.debug("command %s returned %s"%(command, results)) return results def scp(self, srcFile, destPath): From 2a8b9e513045bb1d5be93c192e3663f6db5cef4c Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Mon, 10 Dec 2012 13:42:13 +0530 Subject: [PATCH 087/145] CLOUDSTACK-292: AWSAPI calls fail with 'com.cloud.utils.exception.CloudRuntimeException: DB Exception on: null' --- utils/conf/db.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/conf/db.properties b/utils/conf/db.properties index 8d981191b0e..3f0cc8e76e8 100644 --- a/utils/conf/db.properties +++ b/utils/conf/db.properties @@ -57,3 +57,6 @@ db.usage.maxActive=100 db.usage.maxIdle=30 db.usage.maxWait=10000 db.usage.autoReconnect=true + +# awsapi database settings +db.awsapi.name=cloudbridge From 8ced7da733f8f3e9402495a239f037804ebea2a3 Mon Sep 17 00:00:00 2001 From: Vijayendra Bhamidipati Date: Fri, 12 Oct 2012 17:33:36 -0400 Subject: [PATCH 088/145] CLOUDSTACK-333: When Datacenter name in VCenter has spaces Primary Storage (VMFS) discovery will fail Description: Missed encoding of URI when discovering ESX cluster in vCenter. Signed-off-by: Vijayendra Bhamidipati --- server/src/com/cloud/storage/StorageManagerImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index e252633f8e3..a768610b750 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -1281,7 +1281,7 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag } URI uri = null; try { - uri = new URI(cmd.getUrl()); + uri = new URI(UriUtils.encodeURIComponent(cmd.getUrl())); if (uri.getScheme() == null) { throw new InvalidParameterValueException("scheme is null " + cmd.getUrl() + ", add nfs:// as a prefix"); } else if (uri.getScheme().equalsIgnoreCase("nfs")) { From 988ccfc45d8a4f7b689a75adc76c06f0ec1a06db Mon Sep 17 00:00:00 2001 From: Laszlo Hornyak Date: Sun, 11 Nov 2012 22:06:08 +0100 Subject: [PATCH 089/145] removed some unused database connection properties Signed-off-by: Laszlo Hornyak Signed-off-by: Prasanna Santhanam --- client/tomcatconf/db-enc.properties.in | 3 --- client/tomcatconf/db.properties.in | 3 --- utils/conf/db.properties | 3 --- utils/src/com/cloud/utils/db/Transaction.java | 3 --- 4 files changed, 12 deletions(-) diff --git a/client/tomcatconf/db-enc.properties.in b/client/tomcatconf/db-enc.properties.in index 6136f37511f..a9404fa4932 100644 --- a/client/tomcatconf/db-enc.properties.in +++ b/client/tomcatconf/db-enc.properties.in @@ -37,9 +37,6 @@ db.cloud.testOnBorrow=true db.cloud.testWhileIdle=true db.cloud.timeBetweenEvictionRunsMillis=40000 db.cloud.minEvictableIdleTimeMillis=240000 -db.cloud.removeAbandoned=false -db.cloud.removeAbandonedTimeout=300 -db.cloud.logAbandoned=true db.cloud.poolPreparedStatements=false db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true diff --git a/client/tomcatconf/db.properties.in b/client/tomcatconf/db.properties.in index f39d8fe4097..e38366706d4 100644 --- a/client/tomcatconf/db.properties.in +++ b/client/tomcatconf/db.properties.in @@ -37,9 +37,6 @@ db.cloud.testOnBorrow=true db.cloud.testWhileIdle=true db.cloud.timeBetweenEvictionRunsMillis=40000 db.cloud.minEvictableIdleTimeMillis=240000 -db.cloud.removeAbandoned=false -db.cloud.removeAbandonedTimeout=300 -db.cloud.logAbandoned=true db.cloud.poolPreparedStatements=false db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true diff --git a/utils/conf/db.properties b/utils/conf/db.properties index 3f0cc8e76e8..8c8833f7e94 100644 --- a/utils/conf/db.properties +++ b/utils/conf/db.properties @@ -39,9 +39,6 @@ db.cloud.testOnBorrow=true db.cloud.testWhileIdle=true db.cloud.timeBetweenEvictionRunsMillis=40000 db.cloud.minEvictableIdleTimeMillis=240000 -db.cloud.removeAbandoned=false -db.cloud.removeAbandonedTimeout=300 -db.cloud.logAbandoned=true db.cloud.poolPreparedStatements=false db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&prepStmtCacheSqlLimit=4096 diff --git a/utils/src/com/cloud/utils/db/Transaction.java b/utils/src/com/cloud/utils/db/Transaction.java index 0fa3e0a0138..eaa31f6e2f5 100755 --- a/utils/src/com/cloud/utils/db/Transaction.java +++ b/utils/src/com/cloud/utils/db/Transaction.java @@ -1039,9 +1039,6 @@ public class Transaction { final boolean cloudTestWhileIdle = Boolean.parseBoolean(dbProps.getProperty("db.cloud.testWhileIdle")); final long cloudTimeBtwEvictionRunsMillis = Long.parseLong(dbProps.getProperty("db.cloud.timeBetweenEvictionRunsMillis")); final long cloudMinEvcitableIdleTimeMillis = Long.parseLong(dbProps.getProperty("db.cloud.minEvictableIdleTimeMillis")); - final boolean cloudRemoveAbandoned = Boolean.parseBoolean(dbProps.getProperty("db.cloud.removeAbandoned")); - final int cloudRemoveAbandonedTimeout = Integer.parseInt(dbProps.getProperty("db.cloud.removeAbandonedTimeout")); - final boolean cloudLogAbandoned = Boolean.parseBoolean(dbProps.getProperty("db.cloud.logAbandoned")); final boolean cloudPoolPreparedStatements = Boolean.parseBoolean(dbProps.getProperty("db.cloud.poolPreparedStatements")); final String url = dbProps.getProperty("db.cloud.url.params"); final boolean useSSL = Boolean.parseBoolean(dbProps.getProperty("db.cloud.useSSL")); From 15704cfa6cb26737342cb6293194da129147b976 Mon Sep 17 00:00:00 2001 From: Atsushi Midorikawa Date: Thu, 13 Dec 2012 22:59:35 -0800 Subject: [PATCH 090/145] virtual router: edithosts.sh cleanup fails on existing hosts The already deleted same hostname is not deleted from /etc/hosts of vRouter. vRouter's /etc/hosts format: $ip $host This patch fixes deletion logic below. sed -i /"$host "/d $HOSTS Signed-off-by: Prasanna Santhanam --- patches/systemvm/debian/config/root/edithosts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/systemvm/debian/config/root/edithosts.sh b/patches/systemvm/debian/config/root/edithosts.sh index 3c6102d61d5..37c75a53022 100755 --- a/patches/systemvm/debian/config/root/edithosts.sh +++ b/patches/systemvm/debian/config/root/edithosts.sh @@ -88,7 +88,7 @@ echo "0 $mac $ip $host *" >> $DHCP_LEASES #edit hosts file as well sed -i /"$ip "/d $HOSTS -sed -i /"$host "/d $HOSTS +sed -i /" $host$"/d $HOSTS echo "$ip $host" >> $HOSTS if [ "$dflt" != "" ] From 0ba355fbc20411890b74f7b6f33edc057c493259 Mon Sep 17 00:00:00 2001 From: Simon Waterhouse Date: Tue, 13 Nov 2012 11:59:08 +0000 Subject: [PATCH 091/145] CLOUDSTACK-284: listVirtualMachines when zoneid passed When zoneid is passed an no state is specified listVIrtualMachines does not return the destroyed vms. This patch fixes the issue. Signed-off-by: Prasanna Santhanam --- server/src/com/cloud/vm/UserVmManagerImpl.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 02d630f31fd..cb0531cbb1d 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -3161,10 +3161,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (zone != null) { sc.setParameters("dataCenterId", zone); - - if (state == null) { - sc.setParameters("stateNEQ", "Destroyed"); - } } if (pod != null) { sc.setParameters("podId", pod); From b70c1a5a84ee014d980c07555d341f16ed515cb8 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Thu, 13 Dec 2012 23:11:30 -0800 Subject: [PATCH 092/145] Backs NFS-based secondary storage with an S3-compatible object store. Periodically, a reaper thread synchronizes templates and ISOs stored on a NFS secondary storage mount with a configured S3 object store. It also pushes snapshots to the object store when they are created and downloads them in other zones on-demand. In addition to permitting the use of commodity or IaaS storage solutions for static assets, it provides a means of automatically synchronizing template and ISO assets across multiple zones. --- .gitignore | 1 + .../agent/api/BackupSnapshotCommand.java | 12 +- .../api/DeleteSnapshotBackupCommand.java | 8 + .../api/DeleteTemplateFromS3Command.java | 106 +++ .../api/DownloadSnapshotFromS3Command.java | 61 ++ ...mplateFromS3ToSecondaryStorageCommand.java | 66 ++ ...mplateToS3FromSecondaryStorageCommand.java | 121 ++++ api/src/com/cloud/agent/api/to/S3TO.java | 252 +++++++ api/src/com/cloud/api/ApiConstants.java | 10 + api/src/com/cloud/api/ResponseGenerator.java | 5 + api/src/com/cloud/api/commands/AddS3Cmd.java | 218 ++++++ .../com/cloud/api/commands/ListS3sCmd.java | 112 +++ .../com/cloud/api/response/S3Response.java | 209 ++++++ .../com/cloud/resource/ResourceService.java | 8 + api/src/com/cloud/storage/S3.java | 51 ++ .../classes/resources/messages.properties | 11 + client/tomcatconf/commands.properties.in | 3 + core/pom.xml | 5 + core/src/com/cloud/storage/S3VO.java | 208 ++++++ core/src/com/cloud/storage/SnapshotVO.java | 12 + .../src/com/cloud/storage/VMTemplateS3VO.java | 203 ++++++ .../resource/NfsSecondaryStorageResource.java | 437 +++++++++++- .../systemvm/debian/config/etc/sysctl.conf | 2 +- .../xen/resource/CitrixResourceBase.java | 102 ++- pom.xml | 6 +- scripts/vm/hypervisor/xenserver/s3xen | 297 ++++++++ .../vm/hypervisor/xenserver/xenserver56/patch | 2 + .../hypervisor/xenserver/xenserver56fp1/patch | 2 + .../vm/hypervisor/xenserver/xenserver60/patch | 2 + server/pom.xml | 6 +- server/src/com/cloud/api/ApiDBUtils.java | 8 + server/src/com/cloud/api/ApiDispatcher.java | 17 +- .../src/com/cloud/api/ApiResponseHelper.java | 97 ++- .../com/cloud/api/doc/ApiXmlDocWriter.java | 5 + .../src/com/cloud/configuration/Config.java | 4 +- .../ConfigurationManagerImpl.java | 15 + .../DefaultComponentLibrary.java | 6 + .../cloud/resource/ResourceManagerImpl.java | 17 + .../com/cloud/storage/StorageManagerImpl.java | 16 + server/src/com/cloud/storage/dao/S3Dao.java | 29 + .../src/com/cloud/storage/dao/S3DaoImpl.java | 47 ++ .../com/cloud/storage/dao/VMTemplateDao.java | 2 + .../cloud/storage/dao/VMTemplateDaoImpl.java | 15 +- .../cloud/storage/dao/VMTemplateS3Dao.java | 36 + .../storage/dao/VMTemplateS3DaoImpl.java | 101 +++ .../src/com/cloud/storage/s3/S3Manager.java | 63 ++ .../com/cloud/storage/s3/S3ManagerImpl.java | 669 ++++++++++++++++++ .../storage/snapshot/SnapshotManager.java | 2 + .../storage/snapshot/SnapshotManagerImpl.java | 107 ++- server/src/com/cloud/template/S3SyncTask.java | 94 +++ .../cloud/template/TemplateManagerImpl.java | 88 ++- setup/db/create-schema.sql | 36 +- setup/db/db/schema-40to410.sql | 58 ++ tools/apidoc/gen_toc.py | 1 + tools/marvin/marvin/cloudstackConnection.py | 2 +- tools/marvin/marvin/deployDataCenter.py | 6 +- ui/dictionary.jsp | 11 + ui/scripts/cloudStack.js | 28 + ui/scripts/sharedFunctions.js | 1 + ui/scripts/system.js | 78 ++ ui/scripts/templates.js | 2 +- utils/pom.xml | 13 +- utils/src/com/cloud/utils/DateUtil.java | 4 + utils/src/com/cloud/utils/S3Utils.java | 495 +++++++++++++ utils/src/com/cloud/utils/StringUtils.java | 11 +- utils/src/com/cloud/utils/db/GlobalLock.java | 40 ++ 66 files changed, 4708 insertions(+), 54 deletions(-) create mode 100644 api/src/com/cloud/agent/api/DeleteTemplateFromS3Command.java create mode 100644 api/src/com/cloud/agent/api/DownloadSnapshotFromS3Command.java create mode 100644 api/src/com/cloud/agent/api/DownloadTemplateFromS3ToSecondaryStorageCommand.java create mode 100644 api/src/com/cloud/agent/api/UploadTemplateToS3FromSecondaryStorageCommand.java create mode 100644 api/src/com/cloud/agent/api/to/S3TO.java create mode 100644 api/src/com/cloud/api/commands/AddS3Cmd.java create mode 100644 api/src/com/cloud/api/commands/ListS3sCmd.java create mode 100644 api/src/com/cloud/api/response/S3Response.java create mode 100644 api/src/com/cloud/storage/S3.java create mode 100644 core/src/com/cloud/storage/S3VO.java create mode 100644 core/src/com/cloud/storage/VMTemplateS3VO.java create mode 100644 scripts/vm/hypervisor/xenserver/s3xen create mode 100644 server/src/com/cloud/storage/dao/S3Dao.java create mode 100644 server/src/com/cloud/storage/dao/S3DaoImpl.java create mode 100644 server/src/com/cloud/storage/dao/VMTemplateS3Dao.java create mode 100644 server/src/com/cloud/storage/dao/VMTemplateS3DaoImpl.java create mode 100644 server/src/com/cloud/storage/s3/S3Manager.java create mode 100644 server/src/com/cloud/storage/s3/S3ManagerImpl.java create mode 100644 server/src/com/cloud/template/S3SyncTask.java create mode 100644 setup/db/db/schema-40to410.sql create mode 100644 utils/src/com/cloud/utils/S3Utils.java diff --git a/.gitignore b/.gitignore index 33f95c7902c..aa503c4d337 100644 --- a/.gitignore +++ b/.gitignore @@ -67,6 +67,7 @@ awsapi/modules/* .settings/ db.properties.override awsapi/overlays/ +tools/marvin/marvin/cloudstackAPI/* *.egg-info/ docs/tmp docs/publish diff --git a/api/src/com/cloud/agent/api/BackupSnapshotCommand.java b/api/src/com/cloud/agent/api/BackupSnapshotCommand.java index 9476d7d7065..04a0bb4a44d 100644 --- a/api/src/com/cloud/agent/api/BackupSnapshotCommand.java +++ b/api/src/com/cloud/agent/api/BackupSnapshotCommand.java @@ -17,6 +17,7 @@ package com.cloud.agent.api; import com.cloud.agent.api.LogLevel.Log4jLevel; +import com.cloud.agent.api.to.S3TO; import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.agent.api.to.SwiftTO; import com.cloud.storage.StoragePool; @@ -32,6 +33,7 @@ public class BackupSnapshotCommand extends SnapshotCommand { private Long snapshotId; @LogLevel(Log4jLevel.Off) private SwiftTO swift; + private S3TO s3; StorageFilerTO pool; protected BackupSnapshotCommand() { @@ -88,7 +90,7 @@ public class BackupSnapshotCommand extends SnapshotCommand { } public String getVmName() { - return vmName; + return vmName; } public SwiftTO getSwift() { @@ -99,6 +101,14 @@ public class BackupSnapshotCommand extends SnapshotCommand { this.swift = swift; } + public S3TO getS3() { + return s3; + } + + public void setS3(S3TO s3) { + this.s3 = s3; + } + public Long getSnapshotId() { return snapshotId; } diff --git a/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java b/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java index 3fa8c2b7eb4..5e5557002e6 100644 --- a/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java +++ b/api/src/com/cloud/agent/api/DeleteSnapshotBackupCommand.java @@ -17,6 +17,7 @@ package com.cloud.agent.api; import com.cloud.agent.api.LogLevel.Log4jLevel; +import com.cloud.agent.api.to.S3TO; import com.cloud.agent.api.to.SwiftTO; /** @@ -26,6 +27,7 @@ import com.cloud.agent.api.to.SwiftTO; public class DeleteSnapshotBackupCommand extends SnapshotCommand { @LogLevel(Log4jLevel.Off) private SwiftTO swift; + private S3TO s3; private Boolean all; public SwiftTO getSwift() { @@ -44,6 +46,10 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand { this.swift = swift; } + public S3TO getS3() { + return s3; + } + protected DeleteSnapshotBackupCommand() { } @@ -73,6 +79,7 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand { * @param childUUID The child VHD file of the backup whose parent is reset to its grandparent. */ public DeleteSnapshotBackupCommand(SwiftTO swift, + S3TO s3, String secondaryStoragePoolURL, Long dcId, Long accountId, @@ -81,6 +88,7 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand { { super(null, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId); setSwift(swift); + this.s3 = s3; setAll(all); } } \ No newline at end of file diff --git a/api/src/com/cloud/agent/api/DeleteTemplateFromS3Command.java b/api/src/com/cloud/agent/api/DeleteTemplateFromS3Command.java new file mode 100644 index 00000000000..278669b2c97 --- /dev/null +++ b/api/src/com/cloud/agent/api/DeleteTemplateFromS3Command.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.agent.api; + +import com.cloud.agent.api.to.S3TO; + +public class DeleteTemplateFromS3Command extends Command { + + private S3TO s3; + private Long templateId; + private Long accountId; + + protected DeleteTemplateFromS3Command() { + super(); + } + + public DeleteTemplateFromS3Command(final S3TO s3, final Long accountId, + final Long templateId) { + + super(); + + this.s3 = s3; + this.accountId = accountId; + this.templateId = templateId; + + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((accountId == null) ? 0 : accountId.hashCode()); + result = prime * result + ((s3 == null) ? 0 : s3.hashCode()); + result = prime * result + + ((templateId == null) ? 0 : templateId.hashCode()); + return result; + } + + @Override + public boolean equals(Object thatObject) { + + if (this == thatObject) { + return true; + } + + if (thatObject == null) { + return false; + } + + if (getClass() != thatObject.getClass()) { + return false; + } + + final DeleteTemplateFromS3Command thatCommand = (DeleteTemplateFromS3Command) thatObject; + + if (!(accountId == thatCommand.accountId) + || (this.accountId != null && this.accountId + .equals(thatCommand.accountId))) { + return false; + } + + if (!(templateId == thatCommand.templateId) + || (this.templateId != null && this.templateId + .equals(thatCommand.templateId))) { + return false; + } + + return true; + + } + + public S3TO getS3() { + return s3; + } + + public Long getTemplateId() { + return templateId; + } + + public Long getAccountId() { + return accountId; + } + + @Override + public boolean executeInSequence() { + return true; + } + +} diff --git a/api/src/com/cloud/agent/api/DownloadSnapshotFromS3Command.java b/api/src/com/cloud/agent/api/DownloadSnapshotFromS3Command.java new file mode 100644 index 00000000000..1c44dcd6846 --- /dev/null +++ b/api/src/com/cloud/agent/api/DownloadSnapshotFromS3Command.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.agent.api; + +import com.cloud.agent.api.to.S3TO; + +public class DownloadSnapshotFromS3Command extends SnapshotCommand { + + private S3TO s3; + private String parent; + + protected DownloadSnapshotFromS3Command() { + super(); + } + + public DownloadSnapshotFromS3Command(S3TO s3, String parent, + String secondaryStorageUrl, Long dcId, Long accountId, + Long volumeId, String backupUuid, int wait) { + + super("", secondaryStorageUrl, backupUuid, "", dcId, accountId, + volumeId); + + this.s3 = s3; + this.parent = parent; + setWait(wait); + + } + + public S3TO getS3() { + return s3; + } + + public void setS3(S3TO s3) { + this.s3 = s3; + } + + public String getParent() { + return parent; + } + + public void setParent(String parent) { + this.parent = parent; + } + +} diff --git a/api/src/com/cloud/agent/api/DownloadTemplateFromS3ToSecondaryStorageCommand.java b/api/src/com/cloud/agent/api/DownloadTemplateFromS3ToSecondaryStorageCommand.java new file mode 100644 index 00000000000..af61228c020 --- /dev/null +++ b/api/src/com/cloud/agent/api/DownloadTemplateFromS3ToSecondaryStorageCommand.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.agent.api; + +import com.cloud.agent.api.to.S3TO; + +public final class DownloadTemplateFromS3ToSecondaryStorageCommand extends Command { + + private final S3TO s3; + private final Long accountId; + private final Long templateId; + private final String storagePath; + + public DownloadTemplateFromS3ToSecondaryStorageCommand(final S3TO s3, + final Long accountId, final Long templateId, + final String storagePath, final int wait) { + + super(); + + this.s3 = s3; + this.accountId = accountId; + this.templateId = templateId; + this.storagePath = storagePath; + + setWait(wait); + + } + + public S3TO getS3() { + return this.s3; + } + + public Long getAccountId() { + return this.accountId; + } + + public Long getTemplateId() { + return this.templateId; + } + + public String getStoragePath() { + return this.storagePath; + } + + @Override + public boolean executeInSequence() { + return true; + } + +} diff --git a/api/src/com/cloud/agent/api/UploadTemplateToS3FromSecondaryStorageCommand.java b/api/src/com/cloud/agent/api/UploadTemplateToS3FromSecondaryStorageCommand.java new file mode 100644 index 00000000000..1807cd56315 --- /dev/null +++ b/api/src/com/cloud/agent/api/UploadTemplateToS3FromSecondaryStorageCommand.java @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.agent.api; + +import com.cloud.agent.api.to.S3TO; + +public class UploadTemplateToS3FromSecondaryStorageCommand extends Command { + + private final S3TO s3; + private final String storagePath; + private final Long dataCenterId; + private final Long accountId; + private final Long templateId; + + public UploadTemplateToS3FromSecondaryStorageCommand(final S3TO s3, + final String storagePath, final Long dataCenterId, final Long accountId, + final Long templateId) { + + super(); + + this.s3 = s3; + this.storagePath = storagePath; + this.dataCenterId = dataCenterId; + this.accountId = accountId; + this.templateId = templateId; + + } + + @Override + public boolean executeInSequence() { + return false; + } + + @Override + public boolean equals(final Object thatObject) { + + if (this == thatObject) { + return true; + } + + if (thatObject == null || getClass() != thatObject.getClass()) { + return false; + } + + final UploadTemplateToS3FromSecondaryStorageCommand thatCommand = + (UploadTemplateToS3FromSecondaryStorageCommand) thatObject; + + if (this.accountId != null ? !this.accountId.equals(thatCommand + .accountId) : thatCommand.accountId != null) { + return false; + } + + if (this.dataCenterId != null ? !this.dataCenterId.equals(thatCommand + .dataCenterId) : thatCommand.dataCenterId != null) { + return false; + } + + if (this.s3 != null ? !this.s3.equals(thatCommand.s3) : thatCommand.s3 != null) { + return false; + } + + if (this.storagePath != null ? !this.storagePath.equals(thatCommand + .storagePath) : thatCommand.storagePath != null) { + return false; + } + + if (this.templateId != null ? !this.templateId.equals(thatCommand.templateId) : + thatCommand.templateId != null) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = this.s3 != null ? this.s3.hashCode() : 0; + result = 31 * result + (this.storagePath != null ? this.storagePath.hashCode() : 0); + result = 31 * result + (this.dataCenterId != null ? this.dataCenterId.hashCode() : 0); + result = 31 * result + (this.accountId != null ? this.accountId.hashCode() : 0); + result = 31 * result + (this.templateId != null ? this.templateId.hashCode() : 0); + return result; + } + + public S3TO getS3() { + return this.s3; + } + + public String getStoragePath() { + return this.storagePath; + } + + public Long getDataCenterId() { + return this.dataCenterId; + } + + public Long getAccountId() { + return this.accountId; + } + + public Long getTemplateId() { + return this.templateId; + } + +} diff --git a/api/src/com/cloud/agent/api/to/S3TO.java b/api/src/com/cloud/agent/api/to/S3TO.java new file mode 100644 index 00000000000..879df229c31 --- /dev/null +++ b/api/src/com/cloud/agent/api/to/S3TO.java @@ -0,0 +1,252 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 com.cloud.agent.api.to; + +import com.cloud.utils.S3Utils; + +import java.util.Date; + +public final class S3TO implements S3Utils.ClientOptions { + + private Long id; + private String uuid; + private String accessKey; + private String secretKey; + private String endPoint; + private String bucketName; + private Boolean httpsFlag; + private Integer connectionTimeout; + private Integer maxErrorRetry; + private Integer socketTimeout; + private Date created; + + public S3TO() { + + super(); + + } + + public S3TO(final Long id, final String uuid, final String accessKey, + final String secretKey, final String endPoint, + final String bucketName, final Boolean httpsFlag, + final Integer connectionTimeout, final Integer maxErrorRetry, + final Integer socketTimeout, final Date created) { + + super(); + + this.id = id; + this.uuid = uuid; + this.accessKey = accessKey; + this.secretKey = secretKey; + this.endPoint = endPoint; + this.bucketName = bucketName; + this.httpsFlag = httpsFlag; + this.connectionTimeout = connectionTimeout; + this.maxErrorRetry = maxErrorRetry; + this.socketTimeout = socketTimeout; + this.created = created; + + } + + @Override + public boolean equals(final Object thatObject) { + + if (this == thatObject) + return true; + if (thatObject == null || getClass() != thatObject.getClass()) + return false; + + final S3TO thatS3TO = (S3TO) thatObject; + + if (httpsFlag != null ? !httpsFlag.equals(thatS3TO.httpsFlag) + : thatS3TO.httpsFlag != null) { + return false; + } + + if (accessKey != null ? !accessKey.equals(thatS3TO.accessKey) + : thatS3TO.accessKey != null) { + return false; + } + + if (connectionTimeout != null ? !connectionTimeout + .equals(thatS3TO.connectionTimeout) + : thatS3TO.connectionTimeout != null) { + return false; + } + + if (endPoint != null ? !endPoint.equals(thatS3TO.endPoint) + : thatS3TO.endPoint != null) { + return false; + } + + if (id != null ? !id.equals(thatS3TO.id) : thatS3TO.id != null) { + return false; + } + + if (uuid != null ? !uuid.equals(thatS3TO.uuid) : thatS3TO.uuid != null) { + return false; + } + + if (maxErrorRetry != null ? !maxErrorRetry + .equals(thatS3TO.maxErrorRetry) + : thatS3TO.maxErrorRetry != null) { + return false; + } + + if (secretKey != null ? !secretKey.equals(thatS3TO.secretKey) + : thatS3TO.secretKey != null) { + return false; + } + + if (socketTimeout != null ? !socketTimeout + .equals(thatS3TO.socketTimeout) + : thatS3TO.socketTimeout != null) { + return false; + } + + if (bucketName != null ? !bucketName.equals(thatS3TO.bucketName) + : thatS3TO.bucketName != null) { + return false; + } + + if (created != null ? !created.equals(thatS3TO.created) + : thatS3TO.created != null) { + return false; + } + + return true; + + } + + @Override + public int hashCode() { + + int result = id != null ? id.hashCode() : 0; + + result = 31 * result + (accessKey != null ? accessKey.hashCode() : 0); + result = 31 * result + (secretKey != null ? secretKey.hashCode() : 0); + result = 31 * result + (endPoint != null ? endPoint.hashCode() : 0); + result = 31 * result + (bucketName != null ? bucketName.hashCode() : 0); + result = 31 * result + (httpsFlag ? 1 : 0); + result = 31 + * result + + (connectionTimeout != null ? connectionTimeout.hashCode() : 0); + result = 31 * result + + (maxErrorRetry != null ? maxErrorRetry.hashCode() : 0); + result = 31 * result + + (socketTimeout != null ? socketTimeout.hashCode() : 0); + + return result; + + } + + public Long getId() { + return this.id; + } + + public void setId(final Long id) { + this.id = id; + } + + public String getUuid() { + return this.uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + @Override + public String getAccessKey() { + return this.accessKey; + } + + public void setAccessKey(final String accessKey) { + this.accessKey = accessKey; + } + + @Override + public String getSecretKey() { + return this.secretKey; + } + + public void setSecretKey(final String secretKey) { + this.secretKey = secretKey; + } + + @Override + public String getEndPoint() { + return this.endPoint; + } + + public void setEndPoint(final String endPoint) { + this.endPoint = endPoint; + } + + public String getBucketName() { + return this.bucketName; + } + + public void setBucketName(final String bucketName) { + this.bucketName = bucketName; + } + + @Override + public Boolean isHttps() { + return this.httpsFlag; + } + + public void setHttps(final Boolean httpsFlag) { + this.httpsFlag = httpsFlag; + } + + @Override + public Integer getConnectionTimeout() { + return connectionTimeout; + } + + public void setConnectionTimeout(final Integer connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + @Override + public Integer getMaxErrorRetry() { + return maxErrorRetry; + } + + public void setMaxErrorRetry(final Integer maxErrorRetry) { + this.maxErrorRetry = maxErrorRetry; + } + + @Override + public Integer getSocketTimeout() { + return socketTimeout; + } + + public void setSocketTimeout(final Integer socketTimeout) { + this.socketTimeout = socketTimeout; + } + + public Date getCreated() { + return this.created; + } + + public void setCreated(final Date created) { + this.created = created; + } + +} diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index 78a3deda578..9f1c5eaa33a 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -16,6 +16,8 @@ // under the License. package com.cloud.api; +import org.omg.CORBA.PUBLIC_MEMBER; + public class ApiConstants { public static final String ACCOUNT = "account"; public static final String ACCOUNTS = "accounts"; @@ -383,6 +385,14 @@ public class ApiConstants { public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid"; public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename"; public static final String NICIRA_NVP_GATEWAYSERVICE_UUID = "l3gatewayserviceuuid"; + public static final String S3_ACCESS_KEY = "accesskey"; + public static final String S3_SECRET_KEY = "secretkey"; + public static final String S3_END_POINT = "endpoint"; + public static final String S3_BUCKET_NAME = "bucket"; + public static final String S3_HTTPS_FLAG = "usehttps"; + public static final String S3_CONNECTION_TIMEOUT = "connectiontimeout"; + public static final String S3_MAX_ERROR_RETRY = "maxerrorretry"; + public static final String S3_SOCKET_TIMEOUT = "sockettimeout"; public static final String SOURCE = "source"; public static final String COUNTER_ID = "counterid"; diff --git a/api/src/com/cloud/api/ResponseGenerator.java b/api/src/com/cloud/api/ResponseGenerator.java index 4e8fbd824a9..ec6c00ba8d4 100755 --- a/api/src/com/cloud/api/ResponseGenerator.java +++ b/api/src/com/cloud/api/ResponseGenerator.java @@ -64,6 +64,7 @@ import com.cloud.api.response.RemoteAccessVpnResponse; import com.cloud.api.response.ResourceCountResponse; import com.cloud.api.response.ResourceLimitResponse; import com.cloud.api.response.ResourceTagResponse; +import com.cloud.api.response.S3Response; import com.cloud.api.response.SecurityGroupResponse; import com.cloud.api.response.ServiceOfferingResponse; import com.cloud.api.response.ServiceResponse; @@ -141,6 +142,7 @@ import com.cloud.projects.Project; import com.cloud.projects.ProjectAccount; import com.cloud.projects.ProjectInvitation; import com.cloud.server.ResourceTag; +import com.cloud.storage.S3; import com.cloud.storage.Snapshot; import com.cloud.storage.StoragePool; import com.cloud.storage.Swift; @@ -287,6 +289,8 @@ public interface ResponseGenerator { SwiftResponse createSwiftResponse(Swift swift); + S3Response createS3Response(S3 result); + PhysicalNetworkResponse createPhysicalNetworkResponse(PhysicalNetwork result); ServiceResponse createNetworkServiceResponse(Service service); @@ -361,4 +365,5 @@ public interface ResponseGenerator { AutoScaleVmProfileResponse createAutoScaleVmProfileResponse(AutoScaleVmProfile profile); AutoScaleVmGroupResponse createAutoScaleVmGroupResponse(AutoScaleVmGroup vmGroup); + } diff --git a/api/src/com/cloud/api/commands/AddS3Cmd.java b/api/src/com/cloud/api/commands/AddS3Cmd.java new file mode 100644 index 00000000000..e046ccc0160 --- /dev/null +++ b/api/src/com/cloud/api/commands/AddS3Cmd.java @@ -0,0 +1,218 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.api.commands; + +import static com.cloud.api.ApiConstants.S3_ACCESS_KEY; +import static com.cloud.api.ApiConstants.S3_CONNECTION_TIMEOUT; +import static com.cloud.api.ApiConstants.S3_END_POINT; +import static com.cloud.api.ApiConstants.S3_HTTPS_FLAG; +import static com.cloud.api.ApiConstants.S3_MAX_ERROR_RETRY; +import static com.cloud.api.ApiConstants.S3_SECRET_KEY; +import static com.cloud.api.ApiConstants.S3_SOCKET_TIMEOUT; +import static com.cloud.api.ApiConstants.S3_BUCKET_NAME; +import static com.cloud.api.BaseCmd.CommandType.INTEGER; +import static com.cloud.api.BaseCmd.CommandType.STRING; +import static com.cloud.api.BaseCmd.CommandType.BOOLEAN; +import static com.cloud.user.Account.ACCOUNT_ID_SYSTEM; + +import com.cloud.api.BaseCmd; +import com.cloud.api.Implementation; +import com.cloud.api.Parameter; +import com.cloud.api.ServerApiException; +import com.cloud.api.response.S3Response; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.DiscoveryException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.NetworkRuleConflictException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.storage.S3; + +@Implementation(description = "Adds S3", responseObject = S3Response.class, since = "4.0.0") +public final class AddS3Cmd extends BaseCmd { + + private static String COMMAND_NAME = "adds3response"; + + @Parameter(name = S3_ACCESS_KEY, type = STRING, required = true, + description = "S3 access key") + private String accessKey; + + @Parameter(name = S3_SECRET_KEY, type = STRING, required = true, + description = "S3 secret key") + private String secretKey; + + @Parameter(name = S3_END_POINT, type = STRING, required = false, + description = "S3 host name") + private String endPoint = null; + + @Parameter(name = S3_BUCKET_NAME, type = STRING, required = true, + description = "name of the template storage bucket") + private String bucketName; + + @Parameter(name = S3_HTTPS_FLAG, type = BOOLEAN, required = false, + description = "connect to the S3 endpoint via HTTPS?") + private Boolean httpsFlag = null; + + @Parameter(name = S3_CONNECTION_TIMEOUT, type = INTEGER, required = false, + description = "connection timeout (milliseconds)") + private Integer connectionTimeout = null; + + @Parameter(name = S3_MAX_ERROR_RETRY, type = INTEGER, required = false, + description = "maximum number of times to retry on error") + private Integer maxErrorRetry = null; + + @Parameter(name = S3_SOCKET_TIMEOUT, type = INTEGER, required = false, + description = "socket timeout (milliseconds)") + private Integer socketTimeout = null; + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, + ServerApiException, ConcurrentOperationException, ResourceAllocationException, + NetworkRuleConflictException { + + final S3 result; + + try { + + result = _resourceService.discoverS3(this); + + if (result == null) { + throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3."); + } + + } catch (DiscoveryException e) { + + throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3 due to " + e.getMessage()); + + } + + final S3Response response = _responseGenerator.createS3Response(result); + response.setResponseName(this.getCommandName()); + this.setResponseObject(response); + + } + + @Override + public boolean equals(final Object thatObject) { + + if (this == thatObject) { + return true; + } + + if (thatObject == null || this.getClass() != thatObject.getClass()) { + return false; + } + + final AddS3Cmd thatAddS3Cmd = (AddS3Cmd) thatObject; + + if (this.httpsFlag != null ? !this.httpsFlag.equals(thatAddS3Cmd.httpsFlag) : thatAddS3Cmd.httpsFlag != null) { + return false; + } + + if (this.accessKey != null ? !this.accessKey.equals(thatAddS3Cmd.accessKey) : thatAddS3Cmd.accessKey != null) { + return false; + } + + if (this.connectionTimeout != null ? !this.connectionTimeout.equals(thatAddS3Cmd.connectionTimeout) : thatAddS3Cmd.connectionTimeout != null) { + return false; + } + + if (this.endPoint != null ? !this.endPoint.equals(thatAddS3Cmd.endPoint) : thatAddS3Cmd.endPoint != null) { + return false; + } + + if (this.maxErrorRetry != null ? !this.maxErrorRetry.equals(thatAddS3Cmd.maxErrorRetry) : thatAddS3Cmd.maxErrorRetry != null) { + return false; + } + + if (this.secretKey != null ? !this.secretKey.equals(thatAddS3Cmd.secretKey) : thatAddS3Cmd.secretKey != null) { + return false; + } + + if (this.socketTimeout != null ? !this.socketTimeout.equals(thatAddS3Cmd.socketTimeout) : thatAddS3Cmd.socketTimeout != null) { + return false; + } + + if (this.bucketName != null ? !this.bucketName.equals(thatAddS3Cmd.bucketName) : thatAddS3Cmd.bucketName != null) { + return false; + } + + return true; + + } + + @Override + public int hashCode() { + + int result = this.accessKey != null ? this.accessKey.hashCode() : 0; + result = 31 * result + (this.secretKey != null ? this.secretKey.hashCode() : 0); + result = 31 * result + (this.endPoint != null ? this.endPoint.hashCode() : 0); + result = 31 * result + (this.bucketName != null ? this.bucketName.hashCode() : 0); + result = 31 * result + (this.httpsFlag != null && this.httpsFlag == true ? 1 : 0); + result = 31 * result + (this.connectionTimeout != null ? this.connectionTimeout.hashCode() : 0); + result = 31 * result + (this.maxErrorRetry != null ? this.maxErrorRetry.hashCode() : 0); + result = 31 * result + (this.socketTimeout != null ? this.socketTimeout.hashCode() : 0); + + return result; + + } + + @Override + public String getCommandName() { + return COMMAND_NAME; + } + + @Override + public long getEntityOwnerId() { + return ACCOUNT_ID_SYSTEM; + } + + public String getAccessKey() { + return this.accessKey; + } + + public String getSecretKey() { + return this.secretKey; + } + + public String getEndPoint() { + return this.endPoint; + } + + public String getBucketName() { + return this.bucketName; + } + + public Boolean getHttpsFlag() { + return this.httpsFlag; + } + + public Integer getConnectionTimeout() { + return this.connectionTimeout; + } + + public Integer getMaxErrorRetry() { + return this.maxErrorRetry; + } + + public Integer getSocketTimeout() { + return this.socketTimeout; + } + +} diff --git a/api/src/com/cloud/api/commands/ListS3sCmd.java b/api/src/com/cloud/api/commands/ListS3sCmd.java new file mode 100644 index 00000000000..507053dd89f --- /dev/null +++ b/api/src/com/cloud/api/commands/ListS3sCmd.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.api.commands; + +import static com.cloud.api.ApiConstants.ID; +import static com.cloud.api.BaseCmd.CommandType.LONG; + +import java.util.ArrayList; +import java.util.List; + +import com.cloud.api.BaseListCmd; +import com.cloud.api.Implementation; +import com.cloud.api.Parameter; +import com.cloud.api.ServerApiException; +import com.cloud.api.response.ListResponse; +import com.cloud.api.response.S3Response; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.NetworkRuleConflictException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.storage.S3; + +@Implementation(description = "Lists S3s", responseObject = S3Response.class, since = "4.0.0") +public final class ListS3sCmd extends BaseListCmd { + + private static final String COMMAND_NAME = "lists3sresponse"; + + @Parameter(name = ID, type = LONG, required = true, description = "The ID of the S3") + private Long id; + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, + ServerApiException, ConcurrentOperationException, ResourceAllocationException, + NetworkRuleConflictException { + + final List result = _resourceService.listS3s(this); + final ListResponse response = new ListResponse(); + final List s3Responses = new ArrayList(); + + if (result != null) { + + for (S3 s3 : result) { + + S3Response s3Response = _responseGenerator.createS3Response(s3); + s3Response.setResponseName(this.getCommandName()); + s3Response.setObjectName("s3"); + s3Responses.add(s3Response); + + } + + } + + response.setResponses(s3Responses); + response.setResponseName(this.getCommandName()); + + this.setResponseObject(response); + + } + + @Override + public boolean equals(final Object thatObject) { + + if (this == thatObject) { + return true; + } + + if (thatObject == null || getClass() != thatObject.getClass()) { + return false; + } + + final ListS3sCmd thatListS3sCmd = (ListS3sCmd) thatObject; + + if (this.id != null ? !this.id.equals(thatListS3sCmd.id) : thatListS3sCmd.id != null) { + return false; + } + + return true; + + } + + @Override + public int hashCode() { + return this.id != null ? this.id.hashCode() : 0; + } + + @Override + public String getCommandName() { + return COMMAND_NAME; + } + + public Long getId() { + return this.id; + } + +} diff --git a/api/src/com/cloud/api/response/S3Response.java b/api/src/com/cloud/api/response/S3Response.java new file mode 100644 index 00000000000..1efbe23b05e --- /dev/null +++ b/api/src/com/cloud/api/response/S3Response.java @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.api.response; + +import com.cloud.serializer.Param; +import com.cloud.utils.IdentityProxy; +import com.google.gson.annotations.SerializedName; + +import static com.cloud.api.ApiConstants.*; + +public class S3Response extends BaseResponse { + + @SerializedName(ID) + @Param(description = "The ID of the S3 configuration") + private IdentityProxy id = new IdentityProxy("s3"); + + @SerializedName(S3_ACCESS_KEY) + @Param(description = "The S3 access key") + private String accessKey; + + @SerializedName(S3_SECRET_KEY) + @Param(description = "The S3 secret key") + private String secretKey; + + @SerializedName(S3_END_POINT) + @Param(description = "The S3 end point") + private String endPoint; + + @SerializedName(S3_BUCKET_NAME) + @Param(description = "The name of the template storage bucket") + private String bucketName; + + @SerializedName(S3_HTTPS_FLAG) + @Param(description = "Connect to S3 using HTTPS?") + private Integer httpsFlag; + + @SerializedName(S3_CONNECTION_TIMEOUT) + @Param(description = "The connection timeout (milliseconds)") + private Integer connectionTimeout; + + @SerializedName(S3_MAX_ERROR_RETRY) + @Param(description = "The maximum number of time to retry a connection on error.") + private Integer maxErrorRetry; + + @SerializedName(S3_SOCKET_TIMEOUT) + @Param(description = "The connection socket (milliseconds)") + private Integer socketTimeout; + + @Override + public boolean equals(final Object thatObject) { + + if (this == thatObject) { + return true; + } + + if (thatObject == null || this.getClass() != thatObject.getClass()) { + return false; + } + + final S3Response thatS3Response = (S3Response) thatObject; + + if (this.httpsFlag != null ? !this.httpsFlag.equals(thatS3Response.httpsFlag) : thatS3Response.httpsFlag != null) { + return false; + } + + if (this.accessKey != null ? !this.accessKey.equals(thatS3Response.accessKey) : thatS3Response.accessKey != null) { + return false; + } + + if (this.connectionTimeout != null ? !this.connectionTimeout.equals(thatS3Response.connectionTimeout) : thatS3Response.connectionTimeout != null) { + return false; + } + + if (this.endPoint != null ? !this.endPoint.equals(thatS3Response.endPoint) : thatS3Response.endPoint != null) { + return false; + } + + if (this.id != null ? !this.id.equals(thatS3Response.id) : thatS3Response.id != null) { + return false; + } + + if (this.maxErrorRetry != null ? !this.maxErrorRetry.equals(thatS3Response.maxErrorRetry) : thatS3Response.maxErrorRetry != null) { + return false; + } + + if (this.secretKey != null ? !this.secretKey.equals(thatS3Response.secretKey) : thatS3Response.secretKey != null) { + return false; + } + + if (this.socketTimeout != null ? !this.socketTimeout.equals(thatS3Response.socketTimeout) : thatS3Response.socketTimeout != null) { + return false; + } + + if (this.bucketName != null ? !this.bucketName.equals(thatS3Response.bucketName) : thatS3Response.bucketName != null) { + return false; + } + + return true; + + } + + @Override + public int hashCode() { + + int result = this.id != null ? this.id.hashCode() : 0; + result = 31 * result + (this.accessKey != null ? this.accessKey.hashCode() : 0); + result = 31 * result + (this.secretKey != null ? this.secretKey.hashCode() : 0); + result = 31 * result + (this.endPoint != null ? this.endPoint.hashCode() : 0); + result = 31 * result + (this.bucketName != null ? this.bucketName.hashCode() : 0); + result = 31 * result + (this.httpsFlag != null ? this.httpsFlag : 0); + result = 31 * result + (this.connectionTimeout != null ? this.connectionTimeout.hashCode() : 0); + result = 31 * result + (this.maxErrorRetry != null ? this.maxErrorRetry.hashCode() : 0); + result = 31 * result + (this.socketTimeout != null ? this.socketTimeout.hashCode() : 0); + + return result; + + } + + @Override + public Long getObjectId() { + return this.id.getValue(); + } + + public void setObjectId(Long id) { + this.id.setValue(id); + } + + public String getAccessKey() { + return this.accessKey; + } + + public void setAccessKey(final String accessKey) { + this.accessKey = accessKey; + } + + public String getSecretKey() { + return this.secretKey; + } + + public void setSecretKey(final String secretKey) { + this.secretKey = secretKey; + } + + public String getEndPoint() { + return this.endPoint; + } + + public void setEndPoint(final String endPoint) { + this.endPoint = endPoint; + } + + + public String getTemplateBucketName() { + return this.bucketName; + } + + public void setTemplateBucketName(final String templateBucketName) { + this.bucketName = templateBucketName; + } + + public Integer getHttpsFlag() { + return this.httpsFlag; + } + + public void setHttpsFlag(final Integer httpsFlag) { + this.httpsFlag = httpsFlag; + } + + public Integer getConnectionTimeout() { + return this.connectionTimeout; + } + + public void setConnectionTimeout(final Integer connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + public Integer getMaxErrorRetry() { + return this.maxErrorRetry; + } + + public void setMaxErrorRetry(final Integer maxErrorRetry) { + this.maxErrorRetry = maxErrorRetry; + } + + public Integer getSocketTimeout() { + return this.socketTimeout; + } + + public void setSocketTimeout(final Integer socketTimeout) { + this.socketTimeout = socketTimeout; + } + +} diff --git a/api/src/com/cloud/resource/ResourceService.java b/api/src/com/cloud/resource/ResourceService.java index 10654539bb6..4cdb31a72ab 100755 --- a/api/src/com/cloud/resource/ResourceService.java +++ b/api/src/com/cloud/resource/ResourceService.java @@ -20,10 +20,12 @@ import java.util.List; import com.cloud.api.commands.AddClusterCmd; import com.cloud.api.commands.AddHostCmd; +import com.cloud.api.commands.AddS3Cmd; import com.cloud.api.commands.AddSecondaryStorageCmd; import com.cloud.api.commands.AddSwiftCmd; import com.cloud.api.commands.CancelMaintenanceCmd; import com.cloud.api.commands.DeleteClusterCmd; +import com.cloud.api.commands.ListS3sCmd; import com.cloud.api.commands.ListSwiftsCmd; import com.cloud.api.commands.PrepareForMaintenanceCmd; import com.cloud.api.commands.ReconnectHostCmd; @@ -35,6 +37,7 @@ import com.cloud.exception.ResourceInUseException; import com.cloud.host.Host; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.org.Cluster; +import com.cloud.storage.S3; import com.cloud.storage.Swift; import com.cloud.utils.fsm.NoTransitionException; @@ -93,8 +96,13 @@ public interface ResourceService { Cluster getCluster(Long clusterId); Swift discoverSwift(AddSwiftCmd addSwiftCmd) throws DiscoveryException; + + S3 discoverS3(AddS3Cmd cmd) throws DiscoveryException; List getSupportedHypervisorTypes(long zoneId, boolean forVirtualRouter, Long podId); List listSwifts(ListSwiftsCmd cmd); + + List listS3s(ListS3sCmd cmd); + } diff --git a/api/src/com/cloud/storage/S3.java b/api/src/com/cloud/storage/S3.java new file mode 100644 index 00000000000..7a679f2adc5 --- /dev/null +++ b/api/src/com/cloud/storage/S3.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage; + +import com.cloud.agent.api.to.S3TO; + +import java.util.Date; + +public interface S3 { + + long getId(); + + String getUuid(); + + String getAccessKey(); + + String getSecretKey(); + + String getEndPoint(); + + String getBucketName(); + + Integer getHttpsFlag(); + + Integer getConnectionTimeout(); + + Integer getMaxErrorRetry(); + + Integer getSocketTimeout(); + + Date getCreated(); + + S3TO toS3TO(); + +} diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 48514e8f29d..e0dce474fc5 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -32,6 +32,17 @@ label.destroy=Destroy label.restore=Restore label.isolation.uri=Isolation URI label.broadcast.uri=Broadcast URI +label.enable.s3=Enable S3-backed Secondary Storage +confirm.enable.s3=Please fill in the following information to enable support for S3-backed Secondary Storage +message.after.enable.s3=S3-backed Secondary Storage configured. Note: When you leave this page, you will not be able to re-configure S3 again. +label.s3.access_key=Access Key +label.s3.secret_key=Secret Key +label.s3.bucket=Bucket +label.s3.endpoint=Endpoint +label.s3.use_https=Use HTTPS +label.s3.connection_timeout=Connection Timeout +label.s3.max_error_retry=Max Error Retry +label.s3.socket_timeout=Socket Timeout #new labels (end) ************************************************************************************************ diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 149547ee575..437c8d458f5 100755 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -227,6 +227,9 @@ listCapacity=com.cloud.api.commands.ListCapacityCmd;3 addSwift=com.cloud.api.commands.AddSwiftCmd;1 listSwifts=com.cloud.api.commands.ListSwiftsCmd;1 +#### s3 commands +addS3=com.cloud.api.commands.AddS3Cmd;1 +listS3s=com.cloud.api.commands.ListS3sCmd;1 #### host commands addHost=com.cloud.api.commands.AddHostCmd;3 diff --git a/core/pom.xml b/core/pom.xml index 15f0f7b7302..3d6356e561e 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -43,6 +43,11 @@ + + commons-codec + commons-codec + ${cs.codec.version} + install diff --git a/core/src/com/cloud/storage/S3VO.java b/core/src/com/cloud/storage/S3VO.java new file mode 100644 index 00000000000..89f233b87fe --- /dev/null +++ b/core/src/com/cloud/storage/S3VO.java @@ -0,0 +1,208 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage; + +import com.cloud.agent.api.to.S3TO; +import com.cloud.api.Identity; +import com.cloud.utils.db.GenericDao; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Date; + +@Entity +@Table(name = "s3") +public class S3VO implements S3, Identity { + + public static final String ID_COLUMN_NAME = "id"; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = ID_COLUMN_NAME) + private long id; + + @Column(name = "uuid") + private String uuid; + + @Column(name = "access_key") + private String accessKey; + + @Column(name = "secret_key") + private String secretKey; + + @Column(name = "end_point") + private String endPoint; + + @Column(name = "bucket") + private String bucketName; + + @Column(name = "https") + private Integer httpsFlag; + + @Column(name = "connection_timeout") + private Integer connectionTimeout; + + @Column(name = "max_error_retry") + private Integer maxErrorRetry; + + @Column(name = "socket_timeout") + private Integer socketTimeout; + + @Column(name = GenericDao.CREATED_COLUMN) + private Date created; + + public S3VO() { + super(); + } + + public S3VO(final String uuid, final String accessKey, + final String secretKey, final String endPoint, + final String bucketName, final Boolean httpsFlag, + final Integer connectionTimeout, final Integer maxErrorRetry, + final Integer socketTimeout, final Date created) { + + super(); + + this.uuid = uuid; + this.accessKey = accessKey; + this.secretKey = secretKey; + this.endPoint = endPoint; + this.bucketName = bucketName; + + Integer value = null; + if (httpsFlag != null) { + value = httpsFlag == false ? 0 : 1; + } + this.httpsFlag = value; + + this.connectionTimeout = connectionTimeout; + this.maxErrorRetry = maxErrorRetry; + this.socketTimeout = socketTimeout; + this.created = created; + + } + + @Override + public S3TO toS3TO() { + + Boolean httpsFlag = null; + if (this.httpsFlag != null) { + httpsFlag = this.httpsFlag == 0 ? false : true; + } + + return new S3TO(this.id, this.uuid, this.accessKey, this.secretKey, + this.endPoint, this.bucketName, httpsFlag, + this.connectionTimeout, this.maxErrorRetry, this.socketTimeout, + this.created); + + } + + public long getId() { + return this.id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getUuid() { + return this.uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public String getAccessKey() { + return this.accessKey; + } + + public void setAccessKey(final String accessKey) { + this.accessKey = accessKey; + } + + public String getSecretKey() { + return this.secretKey; + } + + public void setSecretKey(final String secretKey) { + this.secretKey = secretKey; + } + + public String getEndPoint() { + return this.endPoint; + } + + public void setEndPoint(final String endPoint) { + this.endPoint = endPoint; + } + + public String getBucketName() { + return this.bucketName; + } + + public void setBucketName(final String bucketName) { + this.bucketName = bucketName; + } + + public Integer getHttpsFlag() { + return this.httpsFlag; + } + + public void setHttpsFlag(final Integer httpsFlag) { + this.httpsFlag = httpsFlag; + } + + public Integer getConnectionTimeout() { + return this.connectionTimeout; + } + + public void setConnectionTimeout(final int connectionTimeout) { + this.connectionTimeout = connectionTimeout; + } + + public Integer getMaxErrorRetry() { + return this.maxErrorRetry; + } + + public void setMaxErrorRetry(final int maxErrorRetry) { + this.maxErrorRetry = maxErrorRetry; + } + + public Integer getSocketTimeout() { + return this.socketTimeout; + } + + public void setSocketTimeout(final int socketTimeout) { + this.socketTimeout = socketTimeout; + } + + public Date getCreated() { + return this.created; + } + + public void setCreated(final Date created) { + this.created = created; + } + +} diff --git a/core/src/com/cloud/storage/SnapshotVO.java b/core/src/com/cloud/storage/SnapshotVO.java index 08dfafa6bac..ae4fd6aafef 100644 --- a/core/src/com/cloud/storage/SnapshotVO.java +++ b/core/src/com/cloud/storage/SnapshotVO.java @@ -91,6 +91,9 @@ public class SnapshotVO implements Snapshot, Identity { @Column(name="swift_id") Long swiftId; + @Column(name="s3_id") + Long s3Id; + @Column(name="sechost_id") Long secHostId; @@ -289,4 +292,13 @@ public class SnapshotVO implements Snapshot, Identity { public void setUuid(String uuid) { this.uuid = uuid; } + + public Long getS3Id() { + return s3Id; + } + + public void setS3Id(Long s3Id) { + this.s3Id = s3Id; + } + } diff --git a/core/src/com/cloud/storage/VMTemplateS3VO.java b/core/src/com/cloud/storage/VMTemplateS3VO.java new file mode 100644 index 00000000000..a75c37d192d --- /dev/null +++ b/core/src/com/cloud/storage/VMTemplateS3VO.java @@ -0,0 +1,203 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage; + +import com.cloud.utils.db.GenericDaoBase; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +import java.text.DateFormat; +import java.util.Date; + +@Entity +@Table(name = "template_s3_ref") +public class VMTemplateS3VO { + + public static final String S3_ID_COLUMN_NAME = "s3_id"; + + public static final String TEMPLATE_ID_COLUMN_NAME = "template_id"; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private long id; + + @Column(name = S3_ID_COLUMN_NAME) + private long s3Id; + + @Column(name = TEMPLATE_ID_COLUMN_NAME) + private long templateId; + + @Column(name = GenericDaoBase.CREATED_COLUMN) + private Date created; + + @Column(name = "size") + private Long size; + + @Column(name = "physical_size") + private Long physicalSize; + + public VMTemplateS3VO() { + super(); + } + + public VMTemplateS3VO(final long s3Id, final long templateId, + final Date created, final Long size, final Long physicalSize) { + + super(); + + this.s3Id = s3Id; + this.templateId = templateId; + this.created = created; + this.size = size; + this.physicalSize = physicalSize; + + } + + @Override + public boolean equals(final Object thatObject) { + + if (this == thatObject) { + return true; + } + + if (thatObject == null || getClass() != thatObject.getClass()) { + return false; + } + + final VMTemplateS3VO thatVMTemplateS3VO = (VMTemplateS3VO) thatObject; + + if (this.id != thatVMTemplateS3VO.id) { + return false; + } + + if (this.s3Id != thatVMTemplateS3VO.s3Id) { + return false; + } + + if (this.templateId != thatVMTemplateS3VO.templateId) { + return false; + } + + if (this.created != null ? !created.equals(thatVMTemplateS3VO.created) + : thatVMTemplateS3VO.created != null) { + return false; + } + + if (this.physicalSize != null ? !physicalSize + .equals(thatVMTemplateS3VO.physicalSize) + : thatVMTemplateS3VO.physicalSize != null) { + return false; + } + + if (this.size != null ? !size.equals(thatVMTemplateS3VO.size) + : thatVMTemplateS3VO.size != null) { + return false; + } + + return true; + } + + @Override + public int hashCode() { + + int result = (int) (this.id ^ (this.id >>> 32)); + + result = 31 * result + (int) (this.s3Id ^ (this.s3Id >>> 32)); + result = 31 * result + + (int) (this.templateId ^ (this.templateId >>> 32)); + result = 31 * result + + (this.created != null ? this.created.hashCode() : 0); + result = 31 * result + (this.size != null ? this.size.hashCode() : 0); + result = 31 + * result + + (this.physicalSize != null ? this.physicalSize.hashCode() : 0); + + return result; + + } + + public long getId() { + return this.id; + } + + public void setId(final long id) { + this.id = id; + } + + public long getS3Id() { + return this.s3Id; + } + + public void setS3Id(final long s3Id) { + this.s3Id = s3Id; + } + + public long getTemplateId() { + return this.templateId; + } + + public void setTemplateId(final long templateId) { + this.templateId = templateId; + } + + public Date getCreated() { + return this.created; + } + + public void setCreated(final Date created) { + this.created = created; + } + + public Long getSize() { + return this.size; + } + + public void setSize(final Long size) { + this.size = size; + } + + public Long getPhysicalSize() { + return this.physicalSize; + } + + public void setPhysicalSize(final Long physicalSize) { + this.physicalSize = physicalSize; + } + + @Override + public String toString() { + + final StringBuilder stringBuilder = new StringBuilder( + "VMTemplateS3VO [ id: ").append(id).append(", created: ") + .append(DateFormat.getDateTimeInstance().format(created)) + .append(", physicalSize: ").append(physicalSize) + .append(", size: ").append(size).append(", templateId: ") + .append(templateId).append(", s3Id: ").append(s3Id) + .append(" ]"); + + return stringBuilder.toString(); + + } + +} diff --git a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java index 155210df499..d8fdc3a71d6 100755 --- a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java +++ b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java @@ -16,10 +16,20 @@ // under the License. package com.cloud.storage.resource; +import static com.cloud.utils.S3Utils.deleteDirectory; +import static com.cloud.utils.S3Utils.getDirectory; +import static com.cloud.utils.S3Utils.putDirectory; +import static com.cloud.utils.StringUtils.join; +import static com.cloud.utils.db.GlobalLock.executeWithNoWaitLock; +import static java.lang.String.format; +import static java.util.Arrays.asList; +import static org.apache.commons.lang.StringUtils.substringAfterLast; + import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileWriter; +import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; @@ -32,6 +42,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import java.util.concurrent.Callable; import javax.naming.ConfigurationException; @@ -46,6 +57,9 @@ import com.cloud.agent.api.ComputeChecksumCommand; import com.cloud.agent.api.DeleteObjectFromSwiftCommand; import com.cloud.agent.api.DeleteSnapshotBackupCommand; import com.cloud.agent.api.DeleteSnapshotsDirCommand; +import com.cloud.agent.api.DeleteTemplateFromS3Command; +import com.cloud.agent.api.DownloadSnapshotFromS3Command; +import com.cloud.agent.api.DownloadTemplateFromS3ToSecondaryStorageCommand; import com.cloud.agent.api.GetStorageStatsAnswer; import com.cloud.agent.api.GetStorageStatsCommand; import com.cloud.agent.api.PingCommand; @@ -60,6 +74,8 @@ import com.cloud.agent.api.SecStorageSetupCommand.Certificates; import com.cloud.agent.api.StartupSecondaryStorageCommand; import com.cloud.agent.api.SecStorageVMSetupCommand; import com.cloud.agent.api.StartupCommand; +import com.cloud.agent.api.StartupSecondaryStorageCommand; +import com.cloud.agent.api.UploadTemplateToS3FromSecondaryStorageCommand; import com.cloud.agent.api.downloadSnapshotFromSwiftCommand; import com.cloud.agent.api.downloadTemplateFromSwiftToSecondaryStorageCommand; import com.cloud.agent.api.uploadTemplateToSwiftFromSecondaryStorageCommand; @@ -75,6 +91,7 @@ import com.cloud.agent.api.storage.ListVolumeAnswer; import com.cloud.agent.api.storage.ListVolumeCommand; import com.cloud.agent.api.storage.UploadCommand; import com.cloud.agent.api.storage.ssCommand; +import com.cloud.agent.api.to.S3TO; import com.cloud.agent.api.to.SwiftTO; import com.cloud.api.commands.DeleteVolumeCmd; import com.cloud.exception.InternalErrorException; @@ -90,6 +107,9 @@ import com.cloud.storage.template.TemplateLocation; import com.cloud.storage.template.UploadManager; import com.cloud.storage.template.UploadManagerImpl; import com.cloud.utils.NumbersUtil; +import com.cloud.utils.S3Utils; +import com.cloud.utils.S3Utils.FileNamingStrategy; +import com.cloud.utils.S3Utils.ObjectNamingStrategy; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; @@ -97,8 +117,15 @@ import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; import com.cloud.vm.SecondaryStorageVm; -public class NfsSecondaryStorageResource extends ServerResourceBase implements SecondaryStorageResource { - private static final Logger s_logger = Logger.getLogger(NfsSecondaryStorageResource.class); +public class NfsSecondaryStorageResource extends ServerResourceBase implements + SecondaryStorageResource { + + private static final Logger s_logger = Logger + .getLogger(NfsSecondaryStorageResource.class); + + private static final String TEMPLATE_ROOT_DIR = "template/tmpl"; + private static final String SNAPSHOT_ROOT_DIR = "snapshots"; + int _timeout; String _instance; @@ -168,16 +195,24 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S return execute((ListVolumeCommand)cmd); }else if (cmd instanceof downloadSnapshotFromSwiftCommand){ return execute((downloadSnapshotFromSwiftCommand)cmd); + } else if (cmd instanceof DownloadSnapshotFromS3Command) { + return execute((DownloadSnapshotFromS3Command) cmd); } else if (cmd instanceof DeleteSnapshotBackupCommand){ return execute((DeleteSnapshotBackupCommand)cmd); } else if (cmd instanceof DeleteSnapshotsDirCommand){ return execute((DeleteSnapshotsDirCommand)cmd); } else if (cmd instanceof downloadTemplateFromSwiftToSecondaryStorageCommand) { return execute((downloadTemplateFromSwiftToSecondaryStorageCommand) cmd); + } else if (cmd instanceof DownloadTemplateFromS3ToSecondaryStorageCommand) { + return execute((DownloadTemplateFromS3ToSecondaryStorageCommand) cmd); } else if (cmd instanceof uploadTemplateToSwiftFromSecondaryStorageCommand) { return execute((uploadTemplateToSwiftFromSecondaryStorageCommand) cmd); + } else if (cmd instanceof UploadTemplateToS3FromSecondaryStorageCommand) { + return execute((UploadTemplateToS3FromSecondaryStorageCommand) cmd); } else if (cmd instanceof DeleteObjectFromSwiftCommand) { return execute((DeleteObjectFromSwiftCommand) cmd); + } else if (cmd instanceof DeleteTemplateFromS3Command) { + return execute((DeleteTemplateFromS3Command) cmd); } else if (cmd instanceof CleanupSnapshotBackupCommand){ return execute((CleanupSnapshotBackupCommand)cmd); } else { @@ -185,6 +220,69 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } } + @SuppressWarnings("unchecked") + private String determineS3TemplateDirectory(final Long accountId, + final Long templateId) { + return join(asList(TEMPLATE_ROOT_DIR, accountId, templateId), + S3Utils.SEPARATOR); + } + + @SuppressWarnings("unchecked") + private String determineStorageTemplatePath(final String storagePath, + final Long accountId, final Long templateId) { + return join( + asList(getRootDir(storagePath), TEMPLATE_ROOT_DIR, accountId, + templateId), File.separator); + } + + private Answer execute( + final DownloadTemplateFromS3ToSecondaryStorageCommand cmd) { + + final S3TO s3 = cmd.getS3(); + final String storagePath = cmd.getStoragePath(); + final Long accountId = cmd.getAccountId(); + final Long templateId = cmd.getTemplateId(); + + try { + + final File downloadDirectory = _storage + .getFile(determineStorageTemplatePath(storagePath, + accountId, templateId)); + downloadDirectory.mkdirs(); + + if (!downloadDirectory.exists()) { + final String errMsg = format( + "Unable to create directory " + + "download directory %1$s for download of template id " + + "%2$s from S3.", downloadDirectory.getName(), + templateId); + s_logger.error(errMsg); + return new Answer(cmd, false, errMsg); + } + + getDirectory(s3, s3.getBucketName(), + determineS3TemplateDirectory(accountId, templateId), + downloadDirectory, new FileNamingStrategy() { + @Override + public String determineFileName(final String key) { + return substringAfterLast(key, S3Utils.SEPARATOR); + } + }); + + return new Answer(cmd, true, format("Successfully downloaded " + + "template id %1$s from S3 to directory %2$s", templateId, + downloadDirectory.getName())); + + } catch (Exception e) { + + final String errMsg = format("Failed to upload template id %1$s " + + "due to $2%s", templateId, e.getMessage()); + s_logger.error(errMsg, e); + return new Answer(cmd, false, errMsg); + + } + + } private Answer execute(downloadTemplateFromSwiftToSecondaryStorageCommand cmd) { SwiftTO swift = cmd.getSwift(); @@ -256,6 +354,83 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } } + private Answer execute(UploadTemplateToS3FromSecondaryStorageCommand cmd) { + + final S3TO s3 = cmd.getS3(); + final Long accountId = cmd.getAccountId(); + final Long templateId = cmd.getTemplateId(); + + try { + + final String templatePath = determineStorageTemplatePath( + cmd.getStoragePath(), accountId, templateId); + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found template id " + templateId + + " account id " + accountId + " from directory " + + templatePath + " to upload to S3."); + } + + if (!_storage.isDirectory(templatePath)) { + final String errMsg = format("S3 Sync Failure: Directory %1$s" + + "for template id %2$s does not exist.", templatePath, + templateId); + s_logger.error(errMsg); + return new Answer(cmd, false, errMsg); + } + + if (!_storage.isFile(templatePath + "/template.properties")) { + final String errMsg = format("S3 Sync Failure: Template id " + + "%1$s does not exist on the file system.", + templatePath); + s_logger.error(errMsg); + return new Answer(cmd, false, errMsg); + } + + if (s_logger.isDebugEnabled()) { + s_logger.debug(format( + "Pushing template id %1$s from %2$s to S3...", + templateId, templatePath)); + } + + final String bucket = s3.getBucketName(); + putDirectory(s3, bucket, _storage.getFile(templatePath), + new FilenameFilter() { + @Override + public boolean accept(final File directory, + final String fileName) { + return !fileName.startsWith("."); + } + }, new ObjectNamingStrategy() { + @Override + public String determineKey(final File file) { + s_logger.debug(String + .format("Determining key using account id %1$s and template id %2$s", + accountId, templateId)); + return join( + asList(determineS3TemplateDirectory( + accountId, templateId), file + .getName()), S3Utils.SEPARATOR); + } + }); + + return new Answer( + cmd, + true, + format("Uploaded the contents of directory %1$s for template id %2$s to S3 bucket %3$s", + templatePath, templateId, bucket)); + + } catch (Exception e) { + + final String errMsg = format("Failed to upload template id %1$s", + templateId); + s_logger.error(errMsg, e); + return new Answer(cmd, false, errMsg); + + } + + } + private Answer execute(DeleteObjectFromSwiftCommand cmd) { SwiftTO swift = cmd.getSwift(); String container = cmd.getContainer(); @@ -279,6 +454,47 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } + private Answer execute(final DeleteTemplateFromS3Command cmd) { + + final S3TO s3 = cmd.getS3(); + final Long accountId = cmd.getAccountId(); + final Long templateId = cmd.getTemplateId(); + + if (accountId == null || (accountId != null && accountId <= 0)) { + final String errorMessage = "No account id specified for S3 template deletion."; + s_logger.error(errorMessage); + return new Answer(cmd, false, errorMessage); + } + + if (templateId == null || (templateId != null && templateId <= 0)) { + final String errorMessage = "No template id specified for S3 template deletion."; + s_logger.error(errorMessage); + return new Answer(cmd, false, errorMessage); + } + + if (s3 == null) { + final String errorMessge = "No S3 client options provided"; + s_logger.error(errorMessge); + return new Answer(cmd, false, errorMessge); + } + + final String bucket = s3.getBucketName(); + try { + deleteDirectory(s3, bucket, + determineS3TemplateDirectory(templateId, accountId)); + return new Answer(cmd, true, String.format( + "Deleted template %1%s from bucket %2$s.", templateId, + bucket)); + } catch (Exception e) { + final String errorMessage = String + .format("Failed to delete templaet id %1$s from bucket %2$s due to the following error: %3$s", + templateId, bucket, e.getMessage()); + s_logger.error(errorMessage, e); + return new Answer(cmd, false, errorMessage); + } + + } + String swiftDownload(SwiftTO swift, String container, String rfilename, String lFullPath) { Script command = new Script("/bin/bash", s_logger); command.add("-c"); @@ -451,6 +667,110 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } } + public Answer execute(final DownloadSnapshotFromS3Command cmd) { + + final S3TO s3 = cmd.getS3(); + final String secondaryStorageUrl = cmd.getSecondaryStorageUrl(); + final Long accountId = cmd.getAccountId(); + final Long volumeId = cmd.getVolumeId(); + + try { + + executeWithNoWaitLock(determineSnapshotLockId(accountId, volumeId), + new Callable() { + + @Override + public Void call() throws Exception { + + final String directoryName = determineSnapshotLocalDirectory( + secondaryStorageUrl, accountId, volumeId); + + String result = createLocalDir(directoryName); + if (result != null) { + throw new InternalErrorException( + format("Failed to create directory %1$s during S3 snapshot download.", + directoryName)); + } + + final String snapshotFileName = determineSnapshotBackupFilename(cmd + .getSnapshotUuid()); + final String key = determineSnapshotS3Key( + accountId, volumeId, snapshotFileName); + final File targetFile = S3Utils.getFile(s3, + s3.getBucketName(), key, + _storage.getFile(directoryName), + new FileNamingStrategy() { + + @Override + public String determineFileName( + String key) { + return snapshotFileName; + } + + }); + + if (cmd.getParent() != null) { + + final String parentPath = join( + File.pathSeparator, directoryName, + determineSnapshotBackupFilename(cmd + .getParent())); + result = setVhdParent( + targetFile.getAbsolutePath(), + parentPath); + if (result != null) { + throw new InternalErrorException( + format("Failed to set the parent for backup %1$s to %2$s due to %3$s.", + targetFile + .getAbsolutePath(), + parentPath, result)); + } + + } + + return null; + + } + + }); + + return new Answer( + cmd, + true, + format("Succesfully retrieved volume id %1$s for account id %2$s to %3$s from S3.", + volumeId, accountId, secondaryStorageUrl)); + + } catch (Exception e) { + final String errMsg = format( + "Failed to retrieve volume id %1$s for account id %2$s to %3$s from S3 due to exception %4$s", + volumeId, accountId, secondaryStorageUrl, e.getMessage()); + s_logger.error(errMsg); + return new Answer(cmd, false, errMsg); + } + + } + + private String determineSnapshotS3Directory(final Long accountId, + final Long volumeId) { + return join(S3Utils.SEPARATOR, SNAPSHOT_ROOT_DIR, accountId, volumeId); + } + + private String determineSnapshotS3Key(final Long accountId, + final Long volumeId, final String snapshotFileName) { + + final String directoryName = determineSnapshotS3Directory(accountId, + volumeId); + return join(S3Utils.SEPARATOR, directoryName, snapshotFileName); + + } + + private String determineSnapshotLocalDirectory( + final String secondaryStorageUrl, final Long accountId, + final Long volumeId) { + return join(File.pathSeparator, getRootDir(secondaryStorageUrl), + SNAPSHOT_ROOT_DIR, accountId, volumeId); + } + public Answer execute(downloadSnapshotFromSwiftCommand cmd){ SwiftTO swift = cmd.getSwift(); String secondaryStorageUrl = cmd.getSecondaryStorageUrl(); @@ -622,6 +942,92 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S } } + private String deleteSnapshotBackupFromLocalFileSystem( + final String secondaryStorageUrl, final Long accountId, + final Long volumeId, final String name, final Boolean deleteAllFlag) { + + final String lPath = determineSnapshotLocalDirectory( + secondaryStorageUrl, accountId, volumeId) + + File.pathSeparator + + (deleteAllFlag ? "*" : "*" + name + "*"); + + final String result = deleteLocalFile(lPath); + + if (result != null) { + return "failed to delete snapshot " + lPath + " , err=" + result; + } + + return null; + + } + + private String deleteSnapshotBackupfromS3(final S3TO s3, + final String secondaryStorageUrl, final Long accountId, + final Long volumeId, final String name, final Boolean deleteAllFlag) { + + try { + + final String bucket = s3.getBucketName(); + + final String result = executeWithNoWaitLock( + determineSnapshotLockId(accountId, volumeId), + new Callable() { + + @Override + public String call() throws Exception { + + final String innerResult = deleteSnapshotBackupFromLocalFileSystem( + secondaryStorageUrl, accountId, volumeId, + name, deleteAllFlag); + if (innerResult != null) { + return innerResult; + } + + if (deleteAllFlag) { + S3Utils.deleteDirectory( + s3, + bucket, + determineSnapshotS3Directory(accountId, + volumeId)); + } else { + S3Utils.deleteObject( + s3, + bucket, + determineSnapshotS3Key( + accountId, + volumeId, + determineSnapshotBackupFilename(name))); + } + + return null; + + } + + }); + + return result; + + } catch (Exception e) { + + s_logger.error( + String.format( + "Failed to delete snapshot backup for account id %1$s volume id %2$sfrom S3.", + accountId, volumeId), e); + return e.getMessage(); + + } + + } + + private String determineSnapshotBackupFilename(final String snapshotUuid) { + return snapshotUuid + ".vhd"; + } + + private String determineSnapshotLockId(final Long accountId, + final Long volumeId) { + return join("_", "SNAPSHOT", accountId, volumeId); + } + protected Answer execute(final DeleteSnapshotBackupCommand cmd) { String secondaryStorageUrl = cmd.getSecondaryStorageUrl(); Long accountId = cmd.getAccountId(); @@ -629,21 +1035,22 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S String name = cmd.getSnapshotUuid(); try { SwiftTO swift = cmd.getSwift(); + S3TO s3 = cmd.getS3(); if (swift == null) { - String parent = getRootDir(secondaryStorageUrl); - String filename; - if (cmd.isAll()) { - filename = "*"; - - } else { - filename = "*" + name + "*"; - } - String lPath = parent + "/snapshots/" + String.valueOf(accountId) + "/" + String.valueOf(volumeId) + "/" + filename; - String result = deleteLocalFile(lPath); + final String result = deleteSnapshotBackupFromLocalFileSystem( + secondaryStorageUrl, accountId, volumeId, name, + cmd.isAll()); if (result != null) { - String errMsg = "failed to delete snapshot " + lPath + " , err=" + result; - s_logger.warn(errMsg); - return new Answer(cmd, false, errMsg); + s_logger.warn(result); + return new Answer(cmd, false, result); + } + } else if (s3 != null) { + final String result = deleteSnapshotBackupfromS3(s3, + secondaryStorageUrl, accountId, volumeId, name, + cmd.isAll()); + if (result != null) { + s_logger.warn(result); + return new Answer(cmd, false, result); } } else { String filename; diff --git a/patches/systemvm/debian/config/etc/sysctl.conf b/patches/systemvm/debian/config/etc/sysctl.conf index 7f945b0d4b1..961d471dfa9 100644 --- a/patches/systemvm/debian/config/etc/sysctl.conf +++ b/patches/systemvm/debian/config/etc/sysctl.conf @@ -8,7 +8,7 @@ net.ipv4.ip_forward = 1 # Controls source route verification -net.ipv4.conf.default.rp_filter = 1 +net.ipv4.conf.default.rp_filter = 0 # Do not accept source routing net.ipv4.conf.default.accept_source_route = 0 diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 967a2993f2e..313703c0a82 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -17,6 +17,10 @@ package com.cloud.hypervisor.xen.resource; +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -24,11 +28,13 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringReader; +import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -179,6 +185,7 @@ import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; import com.cloud.agent.api.to.IpAddressTO; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.PortForwardingRuleTO; +import com.cloud.agent.api.to.S3TO; import com.cloud.agent.api.to.StaticNatRuleTO; import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.agent.api.to.SwiftTO; @@ -217,6 +224,8 @@ import com.cloud.storage.template.TemplateInfo; import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; +import com.cloud.utils.S3Utils; +import com.cloud.utils.StringUtils; import com.cloud.utils.Ternary; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; @@ -6507,7 +6516,14 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } finally { deleteSnapshotBackup(conn, dcId, accountId, volumeId, secondaryStorageMountPath, snapshotBackupUuid); } - } + } else if (cmd.getS3() != null) { + try { + backupSnapshotToS3(conn, cmd.getS3(), snapshotSr.getUuid(conn), snapshotBackupUuid, isISCSI, wait); + snapshotBackupUuid = snapshotBackupUuid + ".vhd"; + } finally { + deleteSnapshotBackup(conn, dcId, accountId, volumeId, secondaryStorageMountPath, snapshotBackupUuid); + } + } success = true; } finally { if( snapshotSr != null) { @@ -6524,6 +6540,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe snapshotBackupUuid = snapshotPaUuid + ".vhd"; } success = true; + } else if (cmd.getS3() != null) { + backupSnapshotToS3(conn, cmd.getS3(), primaryStorageSRUuid, snapshotPaUuid, isISCSI, wait); } else { snapshotBackupUuid = backupSnapshot(conn, primaryStorageSRUuid, dcId, accountId, volumeId, secondaryStorageMountPath, snapshotUuid, prevBackupUuid, isISCSI, wait); success = (snapshotBackupUuid != null); @@ -6546,6 +6564,88 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe return new BackupSnapshotAnswer(cmd, success, details, snapshotBackupUuid, fullbackup); } + private static List serializeProperties(final Object object, + final Class propertySet) { + + assert object != null; + assert propertySet != null; + assert propertySet.isAssignableFrom(object.getClass()); + + try { + + final BeanInfo beanInfo = Introspector.getBeanInfo(propertySet); + final PropertyDescriptor[] descriptors = beanInfo + .getPropertyDescriptors(); + + final List serializedProperties = new ArrayList(); + for (final PropertyDescriptor descriptor : descriptors) { + + serializedProperties.add(descriptor.getName()); + final Object value = descriptor.getReadMethod().invoke(object); + serializedProperties.add(value != null ? value.toString() + : "null"); + + } + + return Collections.unmodifiableList(serializedProperties); + + } catch (IntrospectionException e) { + s_logger.warn( + "Ignored IntrospectionException when serializing class " + + object.getClass().getCanonicalName(), e); + } catch (IllegalArgumentException e) { + s_logger.warn( + "Ignored IllegalArgumentException when serializing class " + + object.getClass().getCanonicalName(), e); + } catch (IllegalAccessException e) { + s_logger.warn( + "Ignored IllegalAccessException when serializing class " + + object.getClass().getCanonicalName(), e); + } catch (InvocationTargetException e) { + s_logger.warn( + "Ignored InvocationTargetException when serializing class " + + object.getClass().getCanonicalName(), e); + } + + return Collections.emptyList(); + + } + + private boolean backupSnapshotToS3(final Connection connection, + final S3TO s3, final String srUuid, final String snapshotUuid, + final Boolean iSCSIFlag, final int wait) { + + final String filename = iSCSIFlag ? "VHD-" + snapshotUuid + : snapshotUuid + ".vhd"; + final String dir = (iSCSIFlag ? "/dev/VG_XenStorage-" + : "/var/run/sr-mount/") + srUuid; + final String key = StringUtils.join("/", "snapshots", snapshotUuid); + + try { + + final List parameters = new ArrayList( + serializeProperties(s3, S3Utils.ClientOptions.class)); + parameters.addAll(Arrays.asList("operation", "put", "directory", + dir, "filename", filename, "iSCSIFlag", + iSCSIFlag.toString(), "key", key)); + final String result = callHostPluginAsync(connection, "s3xen", + "s3", wait, + parameters.toArray(new String[parameters.size()])); + + if (result != null && result.equals("true")) { + return true; + } + + } catch (Exception e) { + s_logger.error(String.format( + "S3 upload failed of snapshot %1$s due to %2$s.", + snapshotUuid, e.toString()), e); + } + + return false; + + } + protected CreateVolumeFromSnapshotAnswer execute(final CreateVolumeFromSnapshotCommand cmd) { Connection conn = getConnection(); String primaryStorageNameLabel = cmd.getPrimaryStoragePoolNameLabel(); diff --git a/pom.xml b/pom.xml index 2c2600b552f..e5aa024b5ac 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 1.7.1 5.6.100-1-SNAPSHOT 3.1 - 4.0 + 4.1 5.1.21 1.3.1 3.1.3 @@ -82,7 +82,9 @@ 1.0-20081010.060147 4.1 1.9.5 - + 1.3.21.1 + 2.6 + 1.4 diff --git a/scripts/vm/hypervisor/xenserver/s3xen b/scripts/vm/hypervisor/xenserver/s3xen new file mode 100644 index 00000000000..4d9c12d6a5a --- /dev/null +++ b/scripts/vm/hypervisor/xenserver/s3xen @@ -0,0 +1,297 @@ +#!/usr/bin/python +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Version @VERSION@ +# +# A plugin for executing script needed by cloud stack +from __future__ import with_statement + +from copy import copy +from datetime import datetime +from httplib import * +from string import join + +import os +import sys +import time +import hashlib +import base64 +import hmac +import traceback +import urllib2 + +import XenAPIPlugin +sys.path.extend(["/opt/xensource/sm/"]) +import util + +NULL = 'null' + +# Value conversion utility functions ... + + +def to_none(value): + return value if value is not None and value.strip() != NULL else None + + +def to_bool(value): + return True if to_none(value) in ['true', 'True', None] else False + + +def to_integer(value, default): + return int(value) if to_none(value) is not None else default + + +def optional_str_value(value, default): + return value if is_not_blank(value) else default + + +def is_not_blank(value): + return True if to_none(value) is not None and value.strip != '' else False + + +def get_optional_key(map, key, default=''): + return map[key] if key in map else default + + +def log(message): + util.SMlog('#### VMOPS %s ####' % message) + + +def echo(fn): + def wrapped(*v, **k): + name = fn.__name__ + log("enter %s ####" % name) + res = fn(*v, **k) + log("exit %s with result %s" % name, res) + return res + return wrapped + + +def require_str_value(value, error_message): + + if is_not_blank(value): + return value + + raise ValueError(error_message) + + +def retry(max_attempts, fn): + + attempts = 1 + while attempts <= max_attempts: + log("Attempting execution {0}/{1} of {2}". + format(attempts, max_attempts, fn.__name__)) + try: + return fn() + except: + if (attempts >= max_attempts): + raise + attempts = attempts + 1 + + +def compute_md5(filename, buffer_size=8192): + + hasher = hashlib.md5() + + with open(filename, 'rb') as file: + data = file.read(buffer_size) + while data != "": + hasher.update(data) + data = file.read(buffer_size) + + return base64.encodestring(hasher.digest())[:-1] + + +class S3Client(object): + + DEFAULT_END_POINT = 's3.amazonaws.com' + DEFAULT_CONNECTION_TIMEOUT = 50000 + DEFAULT_SOCKET_TIMEOUT = 50000 + DEFAULT_MAX_ERROR_RETRY = 3 + + HEADER_CONTENT_MD5 = 'Content-MD5' + HEADER_CONTENT_TYPE = 'Content-Type' + HEADER_CONTENT_LENGTH = 'Content-Length' + + def __init__(self, access_key, secret_key, end_point=None, + https_flag=None, connection_timeout=None, socket_timeout=None, + max_error_retry=None): + + self.access_key = require_str_value( + access_key, 'An access key must be specified.') + self.secret_key = require_str_value( + secret_key, 'A secret key must be specified.') + self.end_point = optional_str_value(end_point, self.DEFAULT_END_POINT) + self.https_flag = to_bool(https_flag) + self.connection_timeout = to_integer( + connection_timeout, self.DEFAULT_CONNECTION_TIMEOUT) + self.socket_timeout = to_integer( + socket_timeout, self.DEFAULT_SOCKET_TIMEOUT) + self.max_error_retry = to_integer( + max_error_retry, self.DEFAULT_MAX_ERROR_RETRY) + + def build_canocialized_resource(self, bucket, key): + + return '/{bucket}/{key}'.format(bucket=bucket, key=key) + + def noop_send_body(): + pass + + def noop_read(response): + return response.read() + + def do_operation( + self, method, bucket, key, input_headers={}, + fn_send_body=noop_send_body, fn_read=noop_read): + + headers = copy(input_headers) + headers['Expect'] = '100-continue' + + uri = self.build_canocialized_resource(bucket, key) + signature, request_date = self.sign_request(method, uri, headers) + headers['Authorization'] = "AWS {0}:{1}".format( + self.access_key, signature) + headers['Date'] = request_date + + connection = HTTPSConnection(self.end_point) \ + if self.https_flag else HTTPConnection(self.end_point) + connection.timeout = self.socket_timeout + + def perform_request(): + + connection.request(method, uri, fn_send_body(), headers) + response = connection.getresponse() + log("Sent {0} request to {1} {2} with headers {3}. \ + Got response status {4}: {5}". + format(method, self.end_point, uri, headers, + response.status, response.reason)) + return fn_read(response) + + try: + return retry(self.max_error_retry, perform_request) + finally: + connection.close() + + ''' + See http://bit.ly/MMC5de for more information regarding the creation of + AWS authorization tokens and header signing + ''' + def sign_request(self, operation, canocialized_resource, headers): + + request_date = datetime.utcnow( + ).strftime('%a, %d %b %Y %H:%M:%S +0000') + + content_hash = get_optional_key(headers, self.HEADER_CONTENT_MD5) + content_type = get_optional_key(headers, self.HEADER_CONTENT_TYPE) + + string_to_sign = join( + [operation, content_hash, content_type, request_date, + canocialized_resource], '\n') + + signature = base64.encodestring( + hmac.new(self.secret_key, string_to_sign.encode('utf8'), + hashlib.sha1).digest())[:-1] + + return signature, request_date + + def put(self, bucket, key, src_filename): + + headers = { + self.HEADER_CONTENT_MD5: compute_md5(src_filename), + self.HEADER_CONTENT_TYPE: 'application/octet-stream', + self.HEADER_CONTENT_LENGTH: os.stat(src_filename).st_size, + } + + def send_body(): + return open(src_filename, 'rb') + + self.do_operation('PUT', bucket, key, headers, send_body) + + def get(self, bucket, key, target_filename): + + def read(response): + + with open(target_filename, 'wb') as file: + while True: + block = response.read(8192) + if not block: + break + file.write(block) + + return self.do_operation('GET', bucket, key, fn_read=read) + + def delete(self, bucket, key): + + return self.do_operation('DELETE', bucket, key) + + +def parseArguments(args): + + # The keys in the args map will correspond to the properties defined on + # the com.cloud.utils.S3Utils#ClientOptions interface + client = S3Client( + args['accessKey'], args['secretKey'], args['endPoint'], + args['isHttps'], args['connectionTimeout'], args['socketTimeout']) + + operation = args['operation'] + bucket = args['bucket'] + key = args['key'] + filename = args['filename'] + + if is_blank(operation): + raise ValueError('An operation must be specified.') + + if is_blank(bucket): + raise ValueError('A bucket must be specified.') + + if is_blank(key): + raise ValueError('A value must be specified.') + + if is_blank(filename): + raise ValueError('A filename must be specified.') + + return client, operation, bucket, key, filename + + +@echo +def s3(session, args): + + client, operation, bucket, key, filename = parseArguments(args) + + try: + + if operation == 'put': + client.put(bucket, key, filename) + elif operation == 'get': + client.get(bucket, key, filename) + elif operation == 'delete': + client.delete(bucket, key, filename) + else: + raise RuntimeError( + "S3 plugin does not support operation {0}.".format(operation)) + + return 'true' + + except: + log("Operation {0} on file {1} from/in bucket {2} key {3}.".format( + operation, filename, bucket, key)) + log(traceback.format_exc()) + return 'false' + +if __name__ == "__main__": + XenAPIPlugin.dispatch({"s3": s3}) diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch index d485414fdcb..36dba3dc06b 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch @@ -62,3 +62,5 @@ cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin swift=..,0755,/opt/xensource/bin swiftxen=..,0755,/etc/xapi.d/plugins +s3xen=..,0755,/etc/xapi.d/plugins + diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch index 9fe9740756c..d20e60f2e49 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch @@ -61,3 +61,5 @@ cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin swift=..,0755,/opt/xensource/bin swiftxen=..,0755,/etc/xapi.d/plugins +s3xen=..,0755,/etc/xapi.d/plugins + diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/patch b/scripts/vm/hypervisor/xenserver/xenserver60/patch index f0491092749..c9125f4c5b2 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver60/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver60/patch @@ -66,3 +66,5 @@ cloud-prepare-upgrade.sh=..,0755,/opt/xensource/bin bumpUpPriority.sh=../../../../network/domr/,0755,/opt/xensource/bin swift=..,0755,/opt/xensource/bin swiftxen=..,0755,/etc/xapi.d/plugins +s3xen=..,0755,/etc/xapi.d/plugins + diff --git a/server/pom.xml b/server/pom.xml index e3308d85ea2..5ae926f9111 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -62,6 +62,11 @@ jstl ${cs.jstl.version} + + commons-codec + commons-codec + ${cs.codec.version} + org.apache.cloudstack cloud-utils @@ -69,7 +74,6 @@ tests test - install diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index 3b5f634f216..cdd5339665c 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -115,6 +115,7 @@ import com.cloud.storage.StoragePoolVO; import com.cloud.storage.StorageStats; import com.cloud.storage.UploadVO; import com.cloud.storage.VMTemplateHostVO; +import com.cloud.storage.VMTemplateS3VO; import com.cloud.storage.VMTemplateSwiftVO; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.Volume.Type; @@ -129,6 +130,7 @@ import com.cloud.storage.dao.UploadDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateDetailsDao; import com.cloud.storage.dao.VMTemplateHostDao; +import com.cloud.storage.dao.VMTemplateS3Dao; import com.cloud.storage.dao.VMTemplateSwiftDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeHostDao; @@ -196,6 +198,7 @@ public class ApiDBUtils { private static VMTemplateDetailsDao _templateDetailsDao; private static VMTemplateHostDao _templateHostDao; private static VMTemplateSwiftDao _templateSwiftDao; + private static VMTemplateS3Dao _templateS3Dao; private static UploadDao _uploadDao; private static UserDao _userDao; private static UserStatisticsDao _userStatsDao; @@ -260,6 +263,7 @@ public class ApiDBUtils { _templateDetailsDao = locator.getDao(VMTemplateDetailsDao.class); _templateHostDao = locator.getDao(VMTemplateHostDao.class); _templateSwiftDao = locator.getDao(VMTemplateSwiftDao.class); + _templateS3Dao = locator.getDao(VMTemplateS3Dao.class); _uploadDao = locator.getDao(UploadDao.class); _userDao = locator.getDao(UserDao.class); _userStatsDao = locator.getDao(UserStatisticsDao.class); @@ -575,6 +579,10 @@ public class ApiDBUtils { return _templateSwiftDao.findOneByTemplateId(templateId); } + public static VMTemplateS3VO findTemplateS3Ref(long templateId) { + return _templateS3Dao.findOneByTemplateId(templateId); + } + public static UploadVO findUploadById(Long id) { return _uploadDao.findById(id); } diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index dfe4a1fc789..9fd0b2e9f06 100755 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -16,6 +16,8 @@ // under the License. package com.cloud.api; +import static org.apache.commons.lang.StringUtils.isNotBlank; + import java.lang.reflect.Field; import java.text.DateFormat; import java.text.ParseException; @@ -41,7 +43,6 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; -import com.cloud.utils.IdentityProxy; import com.cloud.server.ManagementServer; import com.cloud.user.Account; import com.cloud.user.UserContext; @@ -417,10 +418,20 @@ public class ApiDispatcher { } break; case FLOAT: - field.set(cmdObj, Float.valueOf(paramObj.toString())); + // Assuming that the parameters have been checked for required before now, + // we ignore blank or null values and defer to the command to set a default + // value for optional parameters ... + if (paramObj != null && isNotBlank(paramObj.toString())) { + field.set(cmdObj, Float.valueOf(paramObj.toString())); + } break; case INTEGER: - field.set(cmdObj, Integer.valueOf(paramObj.toString())); + // Assuming that the parameters have been checked for required before now, + // we ignore blank or null values and defer to the command to set a default + // value for optional parameters ... + if (paramObj != null && isNotBlank(paramObj.toString())) { + field.set(cmdObj, Integer.valueOf(paramObj.toString())); + } break; case LIST: List listParam = new ArrayList(); diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index ebe8415048b..a5747101215 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -16,6 +16,9 @@ // under the License. package com.cloud.api; +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; + import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Date; @@ -82,6 +85,7 @@ import com.cloud.api.response.RemoteAccessVpnResponse; import com.cloud.api.response.ResourceCountResponse; import com.cloud.api.response.ResourceLimitResponse; import com.cloud.api.response.ResourceTagResponse; +import com.cloud.api.response.S3Response; import com.cloud.api.response.SecurityGroupResponse; import com.cloud.api.response.SecurityGroupResultObject; import com.cloud.api.response.SecurityGroupRuleResponse; @@ -131,7 +135,6 @@ import com.cloud.dc.Vlan.VlanType; import com.cloud.dc.VlanVO; import com.cloud.domain.Domain; import com.cloud.event.Event; -import com.cloud.exception.InvalidParameterValueException; import com.cloud.host.Host; import com.cloud.host.HostStats; import com.cloud.host.HostVO; @@ -189,6 +192,7 @@ import com.cloud.server.ResourceTag.TaggedResourceType; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.GuestOS; import com.cloud.storage.GuestOSCategoryVO; +import com.cloud.storage.S3; import com.cloud.storage.Snapshot; import com.cloud.storage.Storage; import com.cloud.storage.Storage.ImageFormat; @@ -200,6 +204,7 @@ import com.cloud.storage.StorageStats; import com.cloud.storage.Swift; import com.cloud.storage.UploadVO; import com.cloud.storage.VMTemplateHostVO; +import com.cloud.storage.VMTemplateS3VO; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateSwiftVO; import com.cloud.storage.VMTemplateVO; @@ -743,6 +748,25 @@ public class ApiResponseHelper implements ResponseGenerator { return swiftResponse; } + @Override + public S3Response createS3Response(final S3 result) { + + final S3Response response = new S3Response(); + + response.setAccessKey(result.getAccessKey()); + response.setConnectionTimeout(result.getConnectionTimeout()); + response.setEndPoint(result.getEndPoint()); + response.setHttpsFlag(result.getHttpsFlag()); + response.setMaxErrorRetry(result.getMaxErrorRetry()); + response.setObjectId(result.getId()); + response.setSecretKey(result.getSecretKey()); + response.setSocketTimeout(result.getSocketTimeout()); + response.setTemplateBucketName(result.getBucketName()); + + return response; + + } + @Override public VlanIpRangeResponse createVlanIpRangeResponse(Vlan vlan) { Long podId = ApiDBUtils.getPodIdForVlan(vlan.getId()); @@ -2153,7 +2177,7 @@ public class ApiResponseHelper implements ResponseGenerator { @Override public List createIsoResponses(long isoId, Long zoneId, boolean readyOnly) { - List isoResponses = new ArrayList(); + final List isoResponses = new ArrayList(); VirtualMachineTemplate iso = findTemplateById(isoId); if (iso.getTemplateType() == TemplateType.PERHOST) { TemplateResponse isoResponse = new TemplateResponse(); @@ -2191,11 +2215,17 @@ public class ApiResponseHelper implements ResponseGenerator { return isoResponses; } else { if (zoneId == null || zoneId == -1) { - isoResponses = createSwiftIsoResponses(iso); + isoResponses.addAll(createSwiftIsoResponses(iso)); if (!isoResponses.isEmpty()) { return isoResponses; } - List dcs = new ArrayList(); + + isoResponses.addAll(createS3IsoResponses(iso)); + if (!isoResponses.isEmpty()) { + return isoResponses; + } + + final List dcs = new ArrayList(); dcs.addAll(ApiDBUtils.listZones()); for (DataCenterVO dc : dcs) { isoResponses.addAll(createIsoResponses(iso, dc.getId(), readyOnly)); @@ -2207,6 +2237,65 @@ public class ApiResponseHelper implements ResponseGenerator { } } + private List createS3IsoResponses(final VirtualMachineTemplate iso) { + + final VMTemplateS3VO s3Iso = ApiDBUtils.findTemplateS3Ref(iso.getId()); + + if (s3Iso == null) { + return emptyList(); + } + + final TemplateResponse templateResponse = new TemplateResponse(); + + templateResponse.setId(iso.getId()); + templateResponse.setName(iso.getName()); + templateResponse.setDisplayText(iso.getDisplayText()); + templateResponse.setPublic(iso.isPublicTemplate()); + templateResponse.setExtractable(iso.isExtractable()); + templateResponse.setCreated(s3Iso.getCreated()); + templateResponse.setReady(true); + templateResponse.setBootable(iso.isBootable()); + templateResponse.setFeatured(iso.isFeatured()); + templateResponse.setCrossZones(iso.isCrossZones()); + templateResponse.setChecksum(iso.getChecksum()); + templateResponse.setDetails(iso.getDetails()); + + final GuestOS os = ApiDBUtils.findGuestOSById(iso.getGuestOSId()); + + if (os != null) { + templateResponse.setOsTypeId(os.getId()); + templateResponse.setOsTypeName(os.getDisplayName()); + } else { + templateResponse.setOsTypeId(-1L); + templateResponse.setOsTypeName(""); + } + + final Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId()); + populateAccount(templateResponse, account.getId()); + populateDomain(templateResponse, account.getDomainId()); + + boolean isAdmin = false; + if ((account == null) || BaseCmd.isAdmin(account.getType())) { + isAdmin = true; + } + + // If the user is an admin, add the template download status + if (isAdmin || account.getId() == iso.getAccountId()) { + // add download status + templateResponse.setStatus("Successfully Installed"); + } + + final Long isoSize = s3Iso.getSize(); + if (isoSize > 0) { + templateResponse.setSize(isoSize); + } + + templateResponse.setObjectName("iso"); + + return singletonList(templateResponse); + + } + private List createSwiftIsoResponses(VirtualMachineTemplate iso) { long isoId = iso.getId(); List isoResponses = new ArrayList(); diff --git a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java index d31ef5a8a5f..ffdd5be237b 100644 --- a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java +++ b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java @@ -314,6 +314,11 @@ public class ApiXmlDocWriter { impl = clas.getSuperclass().getAnnotation(Implementation.class); } + if (impl == null) { + throw new IllegalStateException(String.format("An %1$s annotation is required for class %2$s.", + Implementation.class.getCanonicalName(), clas.getCanonicalName())); + } + if (impl.includeInApiDoc()) { String commandDescription = impl.description(); if (commandDescription != null && !commandDescription.isEmpty()) { diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 66ac2762de1..9b82fccfc2f 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -140,8 +140,8 @@ public enum Config { JobExpireMinutes("Advanced", ManagementServer.class, String.class, "job.expire.minutes", "1440", "Time (in minutes) for async-jobs to be kept in system", null), JobCancelThresholdMinutes("Advanced", ManagementServer.class, String.class, "job.cancel.threshold.minutes", "60", "Time (in minutes) for async-jobs to be forcely cancelled if it has been in process for long", null), SwiftEnable("Advanced", ManagementServer.class, Boolean.class, "swift.enable", "false", "enable swift ", null), - - EventPurgeInterval("Advanced", ManagementServer.class, Integer.class, "event.purge.interval", "86400", "The interval (in seconds) to wait before running the event purge thread", null), + S3Enable("Advanced", ManagementServer.class, Boolean.class, "s3.enable", "false", "enable s3 ", null), + EventPurgeInterval("Advanced", ManagementServer.class, Integer.class, "event.purge.interval", "86400", "The interval (in seconds) to wait before running the event purge thread", null), AccountCleanupInterval("Advanced", ManagementServer.class, Integer.class, "account.cleanup.interval", "86400", "The interval (in seconds) between cleanup for removed accounts", null), AllowPublicUserTemplates("Advanced", ManagementServer.class, Integer.class, "allow.public.user.templates", "true", "If false, users will not be able to create public templates.", null), InstanceName("Advanced", AgentManager.class, String.class, "instance.name", "VM", "Name of the deployment instance.", "instanceName"), diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 33baaf12ca4..2d7dfe290a6 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -63,7 +63,9 @@ import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.SwiftVO; import com.cloud.storage.dao.DiskOfferingDao; +import com.cloud.storage.dao.S3Dao; import com.cloud.storage.dao.SwiftDao; +import com.cloud.storage.s3.S3Manager; import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.swift.SwiftManager; import com.cloud.test.IPRangeConfig; @@ -118,6 +120,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura @Inject SwiftDao _swiftDao; @Inject + S3Dao _s3Dao; + @Inject ServiceOfferingDao _serviceOfferingDao; @Inject DiskOfferingDao _diskOfferingDao; @@ -158,6 +162,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura @Inject SwiftManager _swiftMgr; @Inject + S3Manager _s3Mgr; + @Inject PhysicalNetworkTrafficTypeDao _trafficTypeDao; @Inject NicDao _nicDao; @@ -419,6 +425,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura if (swift != null) { return " can not change " + Config.SwiftEnable.key() + " after you have added Swift"; } + if (this._s3Mgr.isS3Enabled()) { + return String.format("Swift is not supported when S3 is enabled."); + } + } + if (Config.S3Enable.key().equals(name)) { + if (this._swiftMgr.isSwiftEnabled()) { + return String.format("S3-backed Secondary Storage is not supported when Swift is enabled."); + } } return null; } @@ -1520,6 +1534,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura createDefaultSystemNetworks(zone.getId()); _swiftMgr.propagateSwiftTmplteOnZone(zone.getId()); + _s3Mgr.propagateTemplatesToZone(zone); txn.commit(); return zone; } catch (Exception ex) { diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java index ef61044d06b..226ca49a56b 100755 --- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java +++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java @@ -147,6 +147,7 @@ import com.cloud.storage.dao.DiskOfferingDaoImpl; import com.cloud.storage.dao.GuestOSCategoryDaoImpl; import com.cloud.storage.dao.GuestOSDaoImpl; import com.cloud.storage.dao.LaunchPermissionDaoImpl; +import com.cloud.storage.dao.S3DaoImpl; import com.cloud.storage.dao.SnapshotDaoImpl; import com.cloud.storage.dao.SnapshotPolicyDaoImpl; import com.cloud.storage.dao.SnapshotScheduleDaoImpl; @@ -159,11 +160,13 @@ import com.cloud.storage.dao.VMTemplateDaoImpl; import com.cloud.storage.dao.VMTemplateDetailsDaoImpl; import com.cloud.storage.dao.VMTemplateHostDaoImpl; import com.cloud.storage.dao.VMTemplatePoolDaoImpl; +import com.cloud.storage.dao.VMTemplateS3DaoImpl; import com.cloud.storage.dao.VMTemplateSwiftDaoImpl; import com.cloud.storage.dao.VMTemplateZoneDaoImpl; import com.cloud.storage.dao.VolumeDaoImpl; import com.cloud.storage.dao.VolumeHostDaoImpl; import com.cloud.storage.download.DownloadMonitorImpl; +import com.cloud.storage.s3.S3ManagerImpl; import com.cloud.storage.secondary.SecondaryStorageManagerImpl; import com.cloud.storage.snapshot.SnapshotManagerImpl; import com.cloud.storage.snapshot.SnapshotSchedulerImpl; @@ -270,6 +273,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com addDao("VMTemplateHostDao", VMTemplateHostDaoImpl.class); addDao("VolumeHostDao", VolumeHostDaoImpl.class); addDao("VMTemplateSwiftDao", VMTemplateSwiftDaoImpl.class); + addDao("VMTemplateS3Dao", VMTemplateS3DaoImpl.class); addDao("UploadDao", UploadDaoImpl.class); addDao("VMTemplatePoolDao", VMTemplatePoolDaoImpl.class); addDao("LaunchPermissionDao", LaunchPermissionDaoImpl.class); @@ -318,6 +322,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com addDao("KeystoreDao", KeystoreDaoImpl.class); addDao("DcDetailsDao", DcDetailsDaoImpl.class); addDao("SwiftDao", SwiftDaoImpl.class); + addDao("S3Dao", S3DaoImpl.class); addDao("AgentTransferMapDao", HostTransferMapDaoImpl.class); addDao("ProjectDao", ProjectDaoImpl.class); addDao("InlineLoadBalancerNicMapDao", InlineLoadBalancerNicMapDaoImpl.class); @@ -403,6 +408,7 @@ public class DefaultComponentLibrary extends ComponentLibraryBase implements Com info.addParameter("consoleproxy.sslEnabled", "true"); addManager("ProjectManager", ProjectManagerImpl.class); addManager("SwiftManager", SwiftManagerImpl.class); + addManager("S3Manager", S3ManagerImpl.class); addManager("StorageNetworkManager", StorageNetworkManagerImpl.class); addManager("ExternalLoadBalancerUsageManager", ExternalLoadBalancerUsageManagerImpl.class); addManager("HA Manager", HighAvailabilityManagerImpl.class); diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index ced601b179b..8d50886d13a 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -30,6 +30,11 @@ import java.util.Set; import javax.ejb.Local; import javax.naming.ConfigurationException; +import com.cloud.api.commands.AddS3Cmd; +import com.cloud.api.commands.ListS3sCmd; +import com.cloud.storage.S3; +import com.cloud.storage.S3VO; +import com.cloud.storage.s3.S3Manager; import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; @@ -181,6 +186,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma @Inject protected SwiftManager _swiftMgr; @Inject + protected S3Manager _s3Mgr; + @Inject protected HostDetailsDao _hostDetailsDao; @Inject protected ConfigurationDao _configDao; @@ -561,6 +568,16 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma return _swiftMgr.listSwifts(cmd); } + @Override + public S3 discoverS3(final AddS3Cmd cmd) throws DiscoveryException { + return this._s3Mgr.addS3(cmd); + } + + @Override + public List listS3s(final ListS3sCmd cmd) { + return this._s3Mgr.listS3s(cmd); + } + private List discoverHostsFull(Long dcId, Long podId, Long clusterId, String clusterName, String url, String username, String password, String hypervisorType, List hostTags, Map params) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException { URI uri = null; diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index a768610b750..7ecc3ec9611 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -151,11 +151,13 @@ import com.cloud.storage.dao.StoragePoolWorkDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.storage.dao.VMTemplatePoolDao; +import com.cloud.storage.dao.VMTemplateS3Dao; import com.cloud.storage.dao.VMTemplateSwiftDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeHostDao; import com.cloud.storage.download.DownloadMonitor; import com.cloud.storage.listener.StoragePoolMonitor; +import com.cloud.storage.s3.S3Manager; import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.storage.snapshot.SnapshotScheduler; @@ -262,6 +264,10 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag @Inject protected VMTemplateSwiftDao _vmTemplateSwiftDao = null; @Inject + protected VMTemplateS3Dao _vmTemplateS3Dao; + @Inject + protected S3Manager _s3Mgr; + @Inject protected VMTemplateDao _vmTemplateDao = null; @Inject protected StoragePoolHostDao _poolHostDao = null; @@ -707,6 +713,8 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag try { if (snapshot.getSwiftId() != null && snapshot.getSwiftId() != 0) { _snapshotMgr.downloadSnapshotsFromSwift(snapshot); + } else if (snapshot.getS3Id() != null && snapshot.getS3Id() != 0) { + _snapshotMgr.downloadSnapshotsFromS3(snapshot); } CreateVolumeFromSnapshotCommand createVolumeFromSnapshotCommand = new CreateVolumeFromSnapshotCommand(primaryStoragePoolNameLabel, secondaryStoragePoolUrl, dcId, accountId, volumeId, backedUpSnapshotUuid, snapshot.getName(), _createVolumeFromSnapshotWait); @@ -2983,6 +2991,14 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag if (tsvs != null && tsvs.size() > 0) { size = tsvs.get(0).getSize(); } + + if (size == null && _s3Mgr.isS3Enabled()) { + VMTemplateS3VO vmTemplateS3VO = _vmTemplateS3Dao.findOneByTemplateId(template.getId()); + if (vmTemplateS3VO != null) { + size = vmTemplateS3VO.getSize(); + } + } + if (size == null) { List sss = _vmTemplateHostDao.search(sc, null); if (sss == null || sss.size() == 0) { diff --git a/server/src/com/cloud/storage/dao/S3Dao.java b/server/src/com/cloud/storage/dao/S3Dao.java new file mode 100644 index 00000000000..ebea3531339 --- /dev/null +++ b/server/src/com/cloud/storage/dao/S3Dao.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage.dao; + +import com.cloud.agent.api.to.S3TO; +import com.cloud.storage.S3VO; +import com.cloud.utils.db.GenericDao; + +public interface S3Dao extends GenericDao { + + S3TO getS3TO(final Long id); + +} diff --git a/server/src/com/cloud/storage/dao/S3DaoImpl.java b/server/src/com/cloud/storage/dao/S3DaoImpl.java new file mode 100644 index 00000000000..6162e6ebf73 --- /dev/null +++ b/server/src/com/cloud/storage/dao/S3DaoImpl.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage.dao; + +import com.cloud.agent.api.to.S3TO; +import com.cloud.storage.S3VO; +import com.cloud.utils.db.GenericDaoBase; + +import javax.ejb.Local; + +@Local(S3Dao.class) +public class S3DaoImpl extends GenericDaoBase implements S3Dao { + + @Override + public S3TO getS3TO(final Long id) { + + if (id != null) { + + final S3VO s3VO = findById(id); + if (s3VO != null) { + return s3VO.toS3TO(); + } + + } + + // NOTE: Excluded listAll / shuffle operation implemented in SwiftDaoImpl ... + + return null; + + } +} diff --git a/server/src/com/cloud/storage/dao/VMTemplateDao.java b/server/src/com/cloud/storage/dao/VMTemplateDao.java index f5b6913df8a..1284ba103cf 100755 --- a/server/src/com/cloud/storage/dao/VMTemplateDao.java +++ b/server/src/com/cloud/storage/dao/VMTemplateDao.java @@ -71,4 +71,6 @@ public interface VMTemplateDao extends GenericDao { List listPrivateTemplatesByHost(Long hostId); public Long countTemplatesForAccount(long accountId); + List findTemplatesToSyncToS3(); + } diff --git a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java index 2a0dfc85559..5c71f1bdb0c 100755 --- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java +++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java @@ -92,6 +92,14 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem private final String SELECT_TEMPLATE_SWIFT_REF = "SELECT t.id, t.unique_name, t.name, t.public, t.featured, t.type, t.hvm, t.bits, t.url, t.format, t.created, t.account_id, " + "t.checksum, t.display_text, t.enable_password, t.guest_os_id, t.bootable, t.prepopulate, t.cross_zones, t.hypervisor_type FROM vm_template t"; + + private static final String SELECT_S3_CANDIDATE_TEMPLATES = "SELECT t.id, t.unique_name, t.name, t.public, t.featured, " + + "t.type, t.hvm, t.bits, t.url, t.format, t.created, t.account_id, t.checksum, t.display_text, " + + "t.enable_password, t.guest_os_id, t.bootable, t.prepopulate, t.cross_zones, t.hypervisor_type " + + "FROM vm_template t JOIN template_host_ref r ON t.id=r.template_id JOIN host h ON h.id=r.host_id " + + "WHERE t.hypervisor_type IN (SELECT hypervisor_type FROM host) AND r.download_state = 'DOWNLOADED' AND " + + "r.template_id NOT IN (SELECT template_id FROM template_s3_ref) AND r.destroyed = 0 AND t.type <> 'PERHOST'"; + protected SearchBuilder TemplateNameSearch; protected SearchBuilder UniqueNameSearch; protected SearchBuilder tmpltTypeSearch; @@ -917,5 +925,10 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); } - + + @Override + public List findTemplatesToSyncToS3() { + return executeList(SELECT_S3_CANDIDATE_TEMPLATES, new Object[] {}); + } + } diff --git a/server/src/com/cloud/storage/dao/VMTemplateS3Dao.java b/server/src/com/cloud/storage/dao/VMTemplateS3Dao.java new file mode 100644 index 00000000000..d36fb3a2257 --- /dev/null +++ b/server/src/com/cloud/storage/dao/VMTemplateS3Dao.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage.dao; + +import com.cloud.storage.VMTemplateS3VO; +import com.cloud.utils.db.GenericDao; + +import java.util.List; + +public interface VMTemplateS3Dao extends GenericDao { + + List listByS3Id(long id); + + VMTemplateS3VO findOneByTemplateId(long id); + + VMTemplateS3VO findOneByS3Template(long s3Id, long templateId); + + void expungeAllByTemplateId(long templateId); + +} diff --git a/server/src/com/cloud/storage/dao/VMTemplateS3DaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateS3DaoImpl.java new file mode 100644 index 00000000000..f23b803bf68 --- /dev/null +++ b/server/src/com/cloud/storage/dao/VMTemplateS3DaoImpl.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage.dao; + +import static com.cloud.utils.db.SearchCriteria.Op.*; +import static com.cloud.storage.VMTemplateS3VO.*; + +import com.cloud.storage.VMTemplateS3VO; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; + +import javax.ejb.Local; +import java.util.List; + +@Local(VMTemplateS3Dao.class) +public class VMTemplateS3DaoImpl extends GenericDaoBase + implements VMTemplateS3Dao { + + private final SearchBuilder searchBuilder; + + public VMTemplateS3DaoImpl() { + + super(); + + this.searchBuilder = createSearchBuilder(); + this.searchBuilder + .and(S3_ID_COLUMN_NAME, this.searchBuilder.entity().getS3Id(), + EQ) + .and(TEMPLATE_ID_COLUMN_NAME, + this.searchBuilder.entity().getTemplateId(), EQ).done(); + + } + + @Override + public List listByS3Id(final long s3id) { + + final SearchCriteria criteria = this.searchBuilder + .create(); + + criteria.setParameters(S3_ID_COLUMN_NAME, s3id); + + return this.listBy(criteria); + + } + + @Override + public VMTemplateS3VO findOneByTemplateId(final long templateId) { + + final SearchCriteria criteria = this.searchBuilder + .create(); + + criteria.setParameters(TEMPLATE_ID_COLUMN_NAME, templateId); + + return this.findOneBy(criteria); + + } + + @Override + public VMTemplateS3VO findOneByS3Template(final long s3Id, + final long templateId) { + + final SearchCriteria criteria = this.searchBuilder + .create(); + + criteria.setParameters(S3_ID_COLUMN_NAME, s3Id); + criteria.setParameters(TEMPLATE_ID_COLUMN_NAME, templateId); + + return this.findOneBy(criteria); + + } + + @Override + public void expungeAllByTemplateId(long templateId) { + + final SearchCriteria criteria = this.searchBuilder + .create(); + + criteria.setParameters(TEMPLATE_ID_COLUMN_NAME, templateId); + + this.expunge(criteria); + + } + +} diff --git a/server/src/com/cloud/storage/s3/S3Manager.java b/server/src/com/cloud/storage/s3/S3Manager.java new file mode 100644 index 00000000000..357f2aed463 --- /dev/null +++ b/server/src/com/cloud/storage/s3/S3Manager.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage.s3; + +import java.util.List; + +import com.cloud.agent.api.to.S3TO; +import com.cloud.api.commands.AddS3Cmd; +import com.cloud.api.commands.ListS3sCmd; +import com.cloud.dc.DataCenterVO; +import com.cloud.exception.DiscoveryException; +import com.cloud.storage.S3; +import com.cloud.storage.S3VO; +import com.cloud.storage.VMTemplateS3VO; +import com.cloud.storage.VMTemplateVO; +import com.cloud.utils.component.Manager; + +public interface S3Manager extends Manager { + + S3TO getS3TO(); + + S3TO getS3TO(Long s3Id); + + S3 addS3(AddS3Cmd addS3Cmd) throws DiscoveryException; + + Long chooseZoneForTemplateExtract(VMTemplateVO template); + + boolean isS3Enabled(); + + boolean isTemplateInstalled(Long templateId); + + void deleteTemplate(final Long accountId, final Long templateId); + + String downloadTemplateFromS3ToSecondaryStorage(final long dcId, + final long templateId, final int primaryStorageDownloadWait); + + List listS3s(ListS3sCmd listS3sCmd); + + VMTemplateS3VO findByTemplateId(Long templateId); + + void propagateTemplatesToZone(DataCenterVO zone); + + void propagateTemplateToAllZones(VMTemplateS3VO vmTemplateS3VO); + + void uploadTemplateToS3FromSecondaryStorage(final VMTemplateVO template); + +} diff --git a/server/src/com/cloud/storage/s3/S3ManagerImpl.java b/server/src/com/cloud/storage/s3/S3ManagerImpl.java new file mode 100644 index 00000000000..6b072540c66 --- /dev/null +++ b/server/src/com/cloud/storage/s3/S3ManagerImpl.java @@ -0,0 +1,669 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.storage.s3; + +import static com.cloud.storage.S3VO.ID_COLUMN_NAME; +import static com.cloud.utils.DateUtil.now; +import static com.cloud.utils.S3Utils.canConnect; +import static com.cloud.utils.S3Utils.canReadWriteBucket; +import static com.cloud.utils.S3Utils.checkBucketName; +import static com.cloud.utils.S3Utils.checkClientOptions; +import static com.cloud.utils.S3Utils.doesBucketExist; +import static com.cloud.utils.StringUtils.join; +import static com.cloud.utils.db.GlobalLock.executeWithNoWaitLock; +import static com.cloud.utils.db.SearchCriteria.Op.EQ; +import static java.lang.Boolean.TRUE; +import static java.lang.String.format; +import static java.util.Arrays.asList; +import static java.util.Collections.emptyList; +import static java.util.Collections.shuffle; +import static java.util.Collections.singletonList; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.Callable; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; + +import org.apache.log4j.Logger; + +import com.cloud.agent.AgentManager; +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.DeleteTemplateFromS3Command; +import com.cloud.agent.api.DownloadTemplateFromS3ToSecondaryStorageCommand; +import com.cloud.agent.api.UploadTemplateToS3FromSecondaryStorageCommand; +import com.cloud.agent.api.to.S3TO; +import com.cloud.api.commands.AddS3Cmd; +import com.cloud.api.commands.ListS3sCmd; +import com.cloud.configuration.Config; +import com.cloud.configuration.dao.ConfigurationDao; +import com.cloud.dc.DataCenterVO; +import com.cloud.dc.dao.DataCenterDao; +import com.cloud.exception.DiscoveryException; +import com.cloud.host.HostVO; +import com.cloud.host.dao.HostDao; +import com.cloud.storage.S3; +import com.cloud.storage.S3VO; +import com.cloud.storage.VMTemplateHostVO; +import com.cloud.storage.VMTemplateS3VO; +import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; +import com.cloud.storage.VMTemplateVO; +import com.cloud.storage.VMTemplateZoneVO; +import com.cloud.storage.dao.S3Dao; +import com.cloud.storage.dao.VMTemplateDao; +import com.cloud.storage.dao.VMTemplateHostDao; +import com.cloud.storage.dao.VMTemplateS3Dao; +import com.cloud.storage.dao.VMTemplateZoneDao; +import com.cloud.storage.secondary.SecondaryStorageVmManager; +import com.cloud.utils.S3Utils.ClientOptions; +import com.cloud.utils.component.Inject; +import com.cloud.utils.db.Filter; +import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.exception.CloudRuntimeException; + +@Local(value = { S3Manager.class }) +public class S3ManagerImpl implements S3Manager { + + private static final Logger LOGGER = Logger.getLogger(S3ManagerImpl.class); + + private String name; + + @Inject + private AgentManager agentManager; + + @Inject + private S3Dao s3Dao; + + @Inject + private VMTemplateZoneDao vmTemplateZoneDao; + + @Inject + private VMTemplateS3Dao vmTemplateS3Dao; + + @Inject + private VMTemplateHostDao vmTemplateHostDao; + + @Inject + private VMTemplateDao vmTemplateDao; + + @Inject + private ConfigurationDao configurationDao; + + @Inject + private DataCenterDao dataCenterDao; + + @Inject + private HostDao hostDao; + + @Inject + private SecondaryStorageVmManager secondaryStorageVMManager; + + protected S3ManagerImpl() { + super(); + } + + private void verifyConnection(final S3TO s3) throws DiscoveryException { + + if (!canConnect(s3)) { + throw new DiscoveryException(format("Unable to connect to S3 " + + "using access key %1$s, secret key %2$s, and endpoint, " + + "%3$S", s3.getAccessKey(), s3.getSecretKey(), + s3.getEndPoint() != null ? s3.getEndPoint() : "default")); + } + + } + + private void verifyBuckets(S3TO s3) throws DiscoveryException { + + final List errorMessages = new ArrayList(); + + errorMessages.addAll(verifyBucket(s3, s3.getBucketName())); + + throwDiscoveryExceptionFromErrorMessages(errorMessages); + + } + + private List verifyBucket(final ClientOptions clientOptions, + final String bucketName) { + + if (!doesBucketExist(clientOptions, bucketName)) { + return singletonList(format("Bucket %1$s does not exist.", + bucketName)); + } + + if (!canReadWriteBucket(clientOptions, bucketName)) { + return singletonList(format("Can read/write from bucket %1$s.", + bucketName)); + } + + return emptyList(); + } + + private void validateFields(final S3VO s3VO) { + + final List errorMessages = new ArrayList(); + + errorMessages.addAll(checkClientOptions(s3VO.toS3TO())); + + errorMessages.addAll(checkBucketName("template", s3VO.getBucketName())); + + throwDiscoveryExceptionFromErrorMessages(errorMessages); + + } + + private void enforceS3PreConditions() throws DiscoveryException { + + if (!this.isS3Enabled()) { + throw new DiscoveryException("S3 is not enabled."); + } + + if (this.getS3TO() != null) { + throw new DiscoveryException("Attempt to define multiple S3 " + + "instances. Only one instance definition is supported."); + } + + } + + private void throwDiscoveryExceptionFromErrorMessages( + final List errorMessages) { + + if (!errorMessages.isEmpty()) { + throw new CloudRuntimeException(join(errorMessages, " ")); + } + + } + + @SuppressWarnings("unchecked") + private String determineLockId(final long accountId, final long templateId) { + + // TBD The lock scope may be too coarse grained. Deletes need to lock + // the template across all zones where upload and download could + // probably safely scoped to the zone ... + return join(asList("S3_TEMPLATE", accountId, templateId), "_"); + + } + + @Override + public S3TO getS3TO(final Long s3Id) { + return this.s3Dao.getS3TO(s3Id); + } + + @Override + public S3TO getS3TO() { + + final List s3s = this.s3Dao.listAll(); + + if (s3s == null || (s3s != null && s3s.isEmpty())) { + return null; + } + + if (s3s.size() == 1) { + return s3s.get(0).toS3TO(); + } + + throw new CloudRuntimeException("Multiple S3 instances have been " + + "defined. Only one instance configuration is supported."); + + } + + @Override + public S3 addS3(final AddS3Cmd addS3Cmd) throws DiscoveryException { + + this.enforceS3PreConditions(); + + final S3VO s3VO = new S3VO(UUID.randomUUID().toString(), + addS3Cmd.getAccessKey(), addS3Cmd.getSecretKey(), + addS3Cmd.getEndPoint(), addS3Cmd.getBucketName(), + addS3Cmd.getHttpsFlag(), addS3Cmd.getConnectionTimeout(), + addS3Cmd.getMaxErrorRetry(), addS3Cmd.getSocketTimeout(), now()); + + this.validateFields(s3VO); + + final S3TO s3 = s3VO.toS3TO(); + this.verifyConnection(s3); + this.verifyBuckets(s3); + + return this.s3Dao.persist(s3VO); + + } + + @Override + public boolean isS3Enabled() { + return Boolean + .valueOf(configurationDao.getValue(Config.S3Enable.key())); + } + + @Override + public boolean isTemplateInstalled(final Long templateId) { + throw new UnsupportedOperationException( + "S3Manager#isTemplateInstalled (DeleteIsoCmd) has not yet " + + "been implemented"); + } + + @Override + public void deleteTemplate(final Long templateId, final Long accountId) { + + final S3TO s3 = getS3TO(); + + if (s3 == null) { + final String errorMessage = "Delete Template Failed: No S3 configuration defined."; + LOGGER.error(errorMessage); + throw new CloudRuntimeException(errorMessage); + } + + final VMTemplateS3VO vmTemplateS3VO = vmTemplateS3Dao + .findOneByS3Template(s3.getId(), templateId); + if (vmTemplateS3VO == null) { + final String errorMessage = format( + "Delete Template Failed: Unable to find Template %1$s in S3.", + templateId); + LOGGER.error(errorMessage); + throw new CloudRuntimeException(errorMessage); + } + + try { + + executeWithNoWaitLock(determineLockId(accountId, templateId), + new Callable() { + + @Override + public Void call() throws Exception { + + final Answer answer = agentManager.sendToSSVM(null, + new DeleteTemplateFromS3Command(s3, + accountId, templateId)); + if (answer == null || !answer.getResult()) { + final String errorMessage = format( + "Delete Template Failed: Unable to delete template id %1$s from S3 due to following error: %2$s", + templateId, + ((answer == null) ? "answer is null" + : answer.getDetails())); + LOGGER.error(errorMessage); + throw new CloudRuntimeException(errorMessage); + } + + vmTemplateS3Dao.remove(vmTemplateS3VO.getId()); + LOGGER.debug(format( + "Deleted template %1$s from S3.", + templateId)); + + return null; + + } + + }); + + } catch (Exception e) { + + final String errorMessage = format( + "Delete Template Failed: Unable to delete template id %1$s from S3 due to the following error: %2$s.", + templateId, e.getMessage()); + LOGGER.error(errorMessage); + throw new CloudRuntimeException(errorMessage, e); + + } + + } + + @SuppressWarnings("unchecked") + @Override + public String downloadTemplateFromS3ToSecondaryStorage( + final long dataCenterId, final long templateId, + final int primaryStorageDownloadWait) { + + if (!isS3Enabled()) { + return null; + } + + final VMTemplateVO template = vmTemplateDao.findById(templateId); + if (template == null) { + final String errorMessage = String + .format("Failed to download template id %1$s from S3 because the template definition was not found.", + templateId); + LOGGER.error(errorMessage); + return errorMessage; + } + + final VMTemplateS3VO templateS3VO = findByTemplateId(templateId); + if (templateS3VO == null) { + final String errorMessage = format( + "Failed to download template id %1$s from S3 because it does not exist in S3.", + templateId); + LOGGER.error(errorMessage); + return errorMessage; + } + + final S3TO s3 = getS3TO(templateS3VO.getS3Id()); + if (s3 == null) { + final String errorMessage = format( + "Failed to download template id %1$s from S3 because S3 id %2$s does not exist.", + templateId, templateS3VO); + LOGGER.error(errorMessage); + return errorMessage; + } + + final HostVO secondaryStorageHost = secondaryStorageVMManager + .findSecondaryStorageHost(dataCenterId); + if (secondaryStorageHost == null) { + final String errorMessage = format( + "Unable to find secondary storage host for zone id %1$s.", + dataCenterId); + LOGGER.error(errorMessage); + throw new CloudRuntimeException(errorMessage); + } + + final long accountId = template.getAccountId(); + final DownloadTemplateFromS3ToSecondaryStorageCommand cmd = new DownloadTemplateFromS3ToSecondaryStorageCommand( + s3, accountId, templateId, secondaryStorageHost.getName(), + primaryStorageDownloadWait); + + try { + + executeWithNoWaitLock(determineLockId(accountId, templateId), + new Callable() { + + @Override + public Void call() throws Exception { + + final Answer answer = agentManager.sendToSSVM( + dataCenterId, cmd); + + if (answer == null || !answer.getResult()) { + final String errMsg = String + .format("Failed to download template from S3 to secondary storage due to %1$s", + (answer == null ? "answer is null" + : answer.getDetails())); + LOGGER.error(errMsg); + throw new CloudRuntimeException(errMsg); + } + + final String installPath = join( + asList("template", "tmpl", accountId, + templateId), File.separator); + final VMTemplateHostVO tmpltHost = new VMTemplateHostVO( + secondaryStorageHost.getId(), templateId, + now(), 100, Status.DOWNLOADED, null, null, + null, installPath, template.getUrl()); + tmpltHost.setSize(templateS3VO.getSize()); + tmpltHost.setPhysicalSize(templateS3VO + .getPhysicalSize()); + vmTemplateHostDao.persist(tmpltHost); + + return null; + + } + + }); + + } catch (Exception e) { + final String errMsg = "Failed to download template from S3 to secondary storage due to " + + e.toString(); + LOGGER.error(errMsg); + throw new CloudRuntimeException(errMsg); + } + + return null; + + } + + @Override + public List listS3s(final ListS3sCmd cmd) { + + final Filter filter = new Filter(S3VO.class, ID_COLUMN_NAME, TRUE, + cmd.getStartIndex(), cmd.getPageSizeVal()); + final SearchCriteria criteria = this.s3Dao.createSearchCriteria(); + + if (cmd.getId() != null) { + criteria.addAnd(ID_COLUMN_NAME, EQ, cmd.getId()); + } + + return this.s3Dao.search(criteria, filter); + + } + + @Override + public VMTemplateS3VO findByTemplateId(final Long templateId) { + throw new UnsupportedOperationException( + "S3Manager#findByTemplateId(Long) has not yet " + + "been implemented"); + } + + @Override + public void propagateTemplatesToZone(final DataCenterVO zone) { + + if (!isS3Enabled()) { + return; + } + + final List s3VMTemplateRefs = this.vmTemplateS3Dao + .listAll(); + if (LOGGER.isInfoEnabled()) { + LOGGER.info(format("Propagating %1$s templates to zone %2$s.", + s3VMTemplateRefs.size(), zone.getName())); + } + + for (final VMTemplateS3VO templateS3VO : s3VMTemplateRefs) { + this.vmTemplateZoneDao.persist(new VMTemplateZoneVO(zone.getId(), + templateS3VO.getTemplateId(), now())); + } + + } + + @Override + public boolean configure(final String name, final Map params) + throws ConfigurationException { + + if (LOGGER.isInfoEnabled()) { + LOGGER.info(format("Configuring S3 Manager %1$s", name)); + } + + this.name = name; + + return true; + + } + + @Override + public boolean start() { + LOGGER.info("Starting S3 Manager"); + return true; + } + + @Override + public boolean stop() { + LOGGER.info("Stopping S3 Manager"); + return true; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public void propagateTemplateToAllZones(final VMTemplateS3VO vmTemplateS3VO) { + + final long templateId = vmTemplateS3VO.getId(); + + if (!isS3Enabled()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace(format( + "Attempt to propogate template id %1$s across all zones. However, S3 is not enabled.", + templateId)); + } + return; + + } + + final S3TO s3 = getS3TO(); + + if (s3 == null) { + LOGGER.warn(format( + "Unable to propagate template id %1$s across all zones because S3 is enabled, but not configured.", + templateId)); + return; + } + + if (vmTemplateS3VO != null) { + final List dataCenters = dataCenterDao.listAll(); + for (DataCenterVO dataCenter : dataCenters) { + final VMTemplateZoneVO tmpltZoneVO = new VMTemplateZoneVO( + dataCenter.getId(), templateId, now()); + vmTemplateZoneDao.persist(tmpltZoneVO); + } + } + + } + + @Override + public Long chooseZoneForTemplateExtract(VMTemplateVO template) { + + final S3TO s3 = getS3TO(); + + if (s3 == null) { + return null; + } + + final List templateHosts = vmTemplateHostDao + .listByOnlyTemplateId(template.getId()); + if (templateHosts != null) { + shuffle(templateHosts); + for (VMTemplateHostVO vmTemplateHostVO : templateHosts) { + final HostVO host = hostDao.findById(vmTemplateHostVO + .getHostId()); + if (host != null) { + return host.getDataCenterId(); + } + throw new CloudRuntimeException( + format("Unable to find secondary storage host for template id %1$s.", + template.getId())); + } + } + + final List dataCenters = dataCenterDao.listAll(); + shuffle(dataCenters); + return dataCenters.get(0).getId(); + + } + + @Override + public void uploadTemplateToS3FromSecondaryStorage( + final VMTemplateVO template) { + + final Long templateId = template.getId(); + + final List templateHostRefs = vmTemplateHostDao + .listByTemplateId(templateId); + + if (templateHostRefs == null + || (templateHostRefs != null && templateHostRefs.isEmpty())) { + throw new CloudRuntimeException( + format("Attempt to sync template id %1$s that is not attached to a host.", + templateId)); + } + + final VMTemplateHostVO templateHostRef = templateHostRefs.get(0); + + if (!isS3Enabled()) { + return; + } + + final S3TO s3 = getS3TO(); + if (s3 == null) { + LOGGER.warn("S3 Template Sync Failed: Attempt to sync templates with S3, but no S3 instance defined."); + return; + } + + final HostVO secondaryHost = this.hostDao.findById(templateHostRef + .getHostId()); + if (secondaryHost == null) { + throw new CloudRuntimeException(format( + "Unable to find secondary storage host id %1$s.", + templateHostRef.getHostId())); + } + + final Long dataCenterId = secondaryHost.getDataCenterId(); + final Long accountId = template.getAccountId(); + + try { + + executeWithNoWaitLock(determineLockId(accountId, templateId), + new Callable() { + + @Override + public Void call() throws Exception { + + final UploadTemplateToS3FromSecondaryStorageCommand cmd = new UploadTemplateToS3FromSecondaryStorageCommand( + s3, secondaryHost.getStorageUrl(), + dataCenterId, accountId, templateId); + + final Answer answer = agentManager.sendToSSVM( + dataCenterId, cmd); + if (answer == null || !answer.getResult()) { + + final String reason = answer != null ? answer + .getDetails() + : "S3 template sync failed due to an unspecified error."; + throw new CloudRuntimeException( + format("Failed to upload template id %1$s to S3 from secondary storage due to %2$s.", + templateId, reason)); + + } + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(format( + "Creating VMTemplateS3VO instance using template id %1s.", + templateId)); + } + + final VMTemplateS3VO vmTemplateS3VO = new VMTemplateS3VO( + s3.getId(), templateId, now(), + templateHostRef.getSize(), templateHostRef + .getPhysicalSize()); + + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(format("Persisting %1$s", + vmTemplateS3VO)); + } + + vmTemplateS3Dao.persist(vmTemplateS3VO); + propagateTemplateToAllZones(vmTemplateS3VO); + + return null; + + } + + }); + + } catch (Exception e) { + + final String errorMessage = format( + "Failed to upload template id %1$s for zone id %2$s to S3.", + templateId, dataCenterId); + LOGGER.error(errorMessage, e); + + } + + } + +} diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManager.java b/server/src/com/cloud/storage/snapshot/SnapshotManager.java index a10298efb90..a7692de7107 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManager.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManager.java @@ -128,6 +128,8 @@ public interface SnapshotManager { void downloadSnapshotsFromSwift(SnapshotVO ss); + void downloadSnapshotsFromS3(SnapshotVO snapshot); + HostVO getSecondaryStorageHost(SnapshotVO snapshot); String getSecondaryStorageURL(SnapshotVO snapshot); diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 32e37e63c0d..259feab3bcf 100755 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -17,6 +17,7 @@ package com.cloud.storage.snapshot; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; @@ -34,9 +35,11 @@ import com.cloud.agent.api.BackupSnapshotCommand; import com.cloud.agent.api.Command; import com.cloud.agent.api.DeleteSnapshotBackupCommand; import com.cloud.agent.api.DeleteSnapshotsDirCommand; +import com.cloud.agent.api.DownloadSnapshotFromS3Command; import com.cloud.agent.api.ManageSnapshotAnswer; import com.cloud.agent.api.ManageSnapshotCommand; import com.cloud.agent.api.downloadSnapshotFromSwiftCommand; +import com.cloud.agent.api.to.S3TO; import com.cloud.agent.api.to.SwiftTO; import com.cloud.alert.AlertManager; import com.cloud.api.commands.CreateSnapshotPolicyCmd; @@ -91,6 +94,7 @@ import com.cloud.storage.dao.SnapshotScheduleDao; import com.cloud.storage.dao.StoragePoolDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VolumeDao; +import com.cloud.storage.s3.S3Manager; import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.swift.SwiftManager; import com.cloud.tags.ResourceTagVO; @@ -171,6 +175,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma private ResourceLimitService _resourceLimitMgr; @Inject private SwiftManager _swiftMgr; + @Inject + private S3Manager _s3Mgr; @Inject private SecondaryStorageVmManager _ssvmMgr; @Inject @@ -477,11 +483,25 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma return createdSnapshot; } + private static void checkObjectStorageConfiguration(SwiftTO swift, S3TO s3) { + + if (swift != null && s3 != null) { + throw new CloudRuntimeException( + "Swift and S3 are not simultaneously supported for snapshot backup."); + } + + } @Override public void deleteSnapshotsForVolume (String secondaryStoragePoolUrl, Long dcId, Long accountId, Long volumeId ){ SwiftTO swift = _swiftMgr.getSwiftTO(); - DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(swift, secondaryStoragePoolUrl, dcId, accountId, volumeId, null, true); + S3TO s3 = _s3Mgr.getS3TO(); + + checkObjectStorageConfiguration(swift, s3); + + DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand( + swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId, + null, true); try { Answer ans = _agentMgr.sendToSSVM(dcId, cmd); if ( ans == null || !ans.getResult() ) { @@ -543,6 +563,54 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma } + private List determineBackupUuids(final SnapshotVO snapshot) { + + final List backupUuids = new ArrayList(); + backupUuids.add(0, snapshot.getBackupSnapshotId()); + + SnapshotVO tempSnapshot = snapshot; + while (tempSnapshot.getPrevSnapshotId() != 0) { + tempSnapshot = _snapshotDao.findById(tempSnapshot + .getPrevSnapshotId()); + backupUuids.add(0, tempSnapshot.getBackupSnapshotId()); + } + + return Collections.unmodifiableList(backupUuids); + } + + @Override + public void downloadSnapshotsFromS3(final SnapshotVO snapshot) { + + final VolumeVO volume = _volsDao.findById(snapshot.getVolumeId()); + final Long zoneId = volume.getDataCenterId(); + final HostVO secHost = _storageMgr.getSecondaryStorageHost(zoneId); + + final S3TO s3 = _s3Mgr.getS3TO(snapshot.getS3Id()); + final List backupUuids = determineBackupUuids(snapshot); + + try { + String parent = null; + for (final String backupUuid : backupUuids) { + final DownloadSnapshotFromS3Command cmd = new DownloadSnapshotFromS3Command( + s3, parent, secHost.getStorageUrl(), zoneId, + volume.getAccountId(), volume.getId(), backupUuid, + _backupsnapshotwait); + final Answer answer = _agentMgr.sendToSSVM(zoneId, cmd); + if ((answer == null) || !answer.getResult()) { + throw new CloudRuntimeException(String.format( + "S3 snapshot download failed due to %1$s.", + answer != null ? answer.getDetails() + : "unspecified error")); + } + parent = backupUuid; + } + } catch (Exception e) { + throw new CloudRuntimeException( + "Snapshot download from S3 failed due to " + e.toString(), + e); + } + + } @Override @DB @@ -577,6 +645,9 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma SwiftTO swift = _swiftMgr.getSwiftTO(); + S3TO s3 = _s3Mgr.getS3TO(); + + checkObjectStorageConfiguration(swift, s3); long prevSnapshotId = snapshot.getPrevSnapshotId(); if (prevSnapshotId > 0) { @@ -586,7 +657,8 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma prevBackupUuid = prevSnapshot.getBackupSnapshotId(); prevSnapshotUuid = prevSnapshot.getPath(); } - } else if ( prevSnapshot.getSwiftId() != null && swift != null ) { + } else if ((prevSnapshot.getSwiftId() != null && swift != null) + || (prevSnapshot.getS3Id() != null && s3 != null)) { prevBackupUuid = prevSnapshot.getBackupSnapshotId(); prevSnapshotUuid = prevSnapshot.getPath(); } @@ -599,8 +671,10 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma if ( swift != null ) { backupSnapshotCommand.setSwift(swift); + } else if (s3 != null) { + backupSnapshotCommand.setS3(s3); } - + String backedUpSnapshotUuid = null; // By default, assume failed. boolean backedUp = false; @@ -621,6 +695,9 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma if (backupSnapshotCommand.getSwift() != null ) { snapshot.setSwiftId(swift.getId()); snapshot.setBackupSnapshotId(backedUpSnapshotUuid); + } else if (backupSnapshotCommand.getS3() != null) { + snapshot.setS3Id(s3.getId()); + snapshot.setBackupSnapshotId(backedUpSnapshotUuid); } else { snapshot.setSecHostId(secHost.getId()); snapshot.setBackupSnapshotId(backedUpSnapshotUuid); @@ -832,7 +909,13 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma return true; } SwiftTO swift = _swiftMgr.getSwiftTO(snapshot.getSwiftId()); - DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(swift, secondaryStoragePoolUrl, dcId, accountId, volumeId, backupOfSnapshot, false); + S3TO s3 = _s3Mgr.getS3TO(); + + checkObjectStorageConfiguration(swift, s3); + + DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand( + swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId, + backupOfSnapshot, false); Answer answer = _agentMgr.sendToSSVM(dcId, cmd); if ((answer != null) && answer.getResult()) { @@ -979,9 +1062,15 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma } List ssHosts = _ssvmMgr.listSecondaryStorageHostsInOneZone(dcId); SwiftTO swift = _swiftMgr.getSwiftTO(); - if (swift == null) { + S3TO s3 = _s3Mgr.getS3TO(); + + checkObjectStorageConfiguration(swift, s3); + + if (swift == null && s3 == null) { for (HostVO ssHost : ssHosts) { - DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(null, ssHost.getStorageUrl(), dcId, accountId, volumeId, "", true); + DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand( + null, null, ssHost.getStorageUrl(), dcId, + accountId, volumeId, "", true); Answer answer = null; try { answer = _agentMgr.sendToSSVM(dcId, cmd); @@ -998,12 +1087,14 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma } } } else { - DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(swift, "", dcId, accountId, volumeId, "", true); + DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand( + swift, s3, "", dcId, accountId, volumeId, "", true); Answer answer = null; try { answer = _agentMgr.sendToSSVM(dcId, cmd); } catch (Exception e) { - s_logger.warn("Failed to delete all snapshot for volume " + volumeId + " on swift"); + final String storeType = s3 != null ? "S3" : "swift"; + s_logger.warn("Failed to delete all snapshot for volume " + volumeId + " on " + storeType); } if ((answer != null) && answer.getResult()) { s_logger.debug("Deleted all snapshots for volume: " + volumeId + " under account: " + accountId); diff --git a/server/src/com/cloud/template/S3SyncTask.java b/server/src/com/cloud/template/S3SyncTask.java new file mode 100644 index 00000000000..ed179dc8961 --- /dev/null +++ b/server/src/com/cloud/template/S3SyncTask.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 com.cloud.template; + +import static java.lang.String.*; + +import java.util.List; + +import org.apache.log4j.Logger; + +import com.cloud.agent.api.to.S3TO; +import com.cloud.storage.VMTemplateVO; +import com.cloud.storage.dao.VMTemplateDao; +import com.cloud.storage.s3.S3Manager; + +final class S3SyncTask implements Runnable { + + private static final Logger LOGGER = Logger.getLogger(S3SyncTask.class); + + private final VMTemplateDao vmTemplateDao; + private final S3Manager s3Mgr; + + S3SyncTask(final VMTemplateDao vmTemplateDao, final S3Manager s3Mgr) { + + super(); + + assert vmTemplateDao != null; + assert s3Mgr != null; + + this.vmTemplateDao = vmTemplateDao; + this.s3Mgr = s3Mgr; + + } + + @Override + public void run() { + + try { + + final S3TO s3 = s3Mgr.getS3TO(); + + if (s3 == null) { + LOGGER.warn("S3 sync skipped because no S3 instance is configured."); + return; + } + + final List candidateTemplates = vmTemplateDao + .findTemplatesToSyncToS3(); + + if (candidateTemplates.isEmpty()) { + LOGGER.debug("All templates are synced with S3."); + return; + } + + for (VMTemplateVO candidateTemplate : candidateTemplates) { + + if (LOGGER.isInfoEnabled()) { + LOGGER.info(format( + "Uploading template %1$s (id: %2$s) to S3.", + candidateTemplate.getName(), + candidateTemplate.getId())); + } + + s3Mgr.uploadTemplateToS3FromSecondaryStorage(candidateTemplate); + + } + + LOGGER.debug("Completed S3 template sync task."); + + } catch (Exception e) { + LOGGER.warn( + "S3 Sync Task ignored exception, and will continue to execute.", + e); + } + + } + +} diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 1e87de2fecb..82c31f14ffb 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -113,10 +113,12 @@ import com.cloud.storage.dao.UploadDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.storage.dao.VMTemplatePoolDao; +import com.cloud.storage.dao.VMTemplateS3Dao; import com.cloud.storage.dao.VMTemplateSwiftDao; import com.cloud.storage.dao.VMTemplateZoneDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.download.DownloadMonitor; +import com.cloud.storage.s3.S3Manager; import com.cloud.storage.secondary.SecondaryStorageVmManager; import com.cloud.storage.swift.SwiftManager; import com.cloud.storage.upload.UploadMonitor; @@ -179,8 +181,12 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe @Inject SwiftManager _swiftMgr; @Inject + S3Manager _s3Mgr; + @Inject VMTemplateSwiftDao _tmpltSwiftDao; @Inject + VMTemplateS3Dao _vmS3TemplateDao; + @Inject ConfigurationDao _configDao; @Inject ClusterDao _clusterDao; @@ -207,6 +213,7 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe ExecutorService _preloadExecutor; ScheduledExecutorService _swiftTemplateSyncExecutor; + private ScheduledExecutorService _s3TemplateSyncExecutor = null; @Inject (adapter=TemplateAdapter.class) protected Adapters _adapters; @@ -344,10 +351,14 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe } } - if (zoneId == null) { + if (zoneId == null && _swiftMgr.isSwiftEnabled()) { zoneId = _swiftMgr.chooseZoneForTmpltExtract(templateId); } + if (zoneId == null && _s3Mgr.isS3Enabled()) { + zoneId = _s3Mgr.chooseZoneForTemplateExtract(template); + } + if (_dcDao.findById(zoneId) == null) { throw new IllegalArgumentException("Please specify a valid zone."); } @@ -380,7 +391,13 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe if (swift != null && sservers != null) { downloadTemplateFromSwiftToSecondaryStorage(zoneId, templateId); } + } else if (tmpltHostRef == null && _s3Mgr.isS3Enabled()) { + if (sservers != null) { + _s3Mgr.downloadTemplateFromS3ToSecondaryStorage(zoneId, + templateId, _primaryStorageDownloadWait); + } } + if (tmpltHostRef == null) { throw new InvalidParameterValueException("The " + desc + " has not been downloaded "); } @@ -594,6 +611,12 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe s_logger.error("Unable to find a secondary storage host who has completely downloaded the template."); return null; } + result = _s3Mgr.downloadTemplateFromS3ToSecondaryStorage(dcId, + templateId, _primaryStorageDownloadWait); + if (result != null) { + s_logger.error("Unable to find a secondary storage host who has completely downloaded the template."); + return null; + } templateHostRef = _storageMgr.findVmTemplateHost(templateId, pool); if (templateHostRef == null || templateHostRef.getDownloadState() != Status.DOWNLOADED) { s_logger.error("Unable to find a secondary storage host who has completely downloaded the template."); @@ -708,6 +731,12 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe s_logger.error("Unable to find a secondary storage host who has completely downloaded the template."); return null; } + result = _s3Mgr.downloadTemplateFromS3ToSecondaryStorage(dcId, + templateId, _primaryStorageDownloadWait); + if (result != null) { + s_logger.error("Unable to find a secondary storage host who has completely downloaded the template."); + return null; + } templateHostRef = _storageMgr.findVmTemplateHost(templateId, pool); if (templateHostRef == null || templateHostRef.getDownloadState() != Status.DOWNLOADED) { s_logger.error("Unable to find a secondary storage host who has completely downloaded the template."); @@ -823,6 +852,12 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe if (_swiftMgr.isSwiftEnabled()) { throw new CloudRuntimeException("copytemplate API is disabled in Swift setup, templates in Swift can be accessed by all Zones"); } + + if (_s3Mgr.isS3Enabled()) { + throw new CloudRuntimeException( + "copytemplate API is disabled in S3 setup -- S3 templates are accessible in all zones."); + } + //Verify parameters if (sourceZoneId == destZoneId) { throw new InvalidParameterValueException("Please specify different source and destination zones."); @@ -1003,12 +1038,32 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe @Override public boolean start() { _swiftTemplateSyncExecutor.scheduleAtFixedRate(getSwiftTemplateSyncTask(), 60, 60, TimeUnit.SECONDS); + + if (_s3TemplateSyncExecutor != null) { + + final int initialDelay = 60; + final int period = 60; + + _s3TemplateSyncExecutor.scheduleAtFixedRate(new S3SyncTask( + this._tmpltDao, this._s3Mgr), initialDelay, period, + TimeUnit.SECONDS); + s_logger.info(String.format("Started S3 sync task to execute " + + "execute every %1$s after an initial delay of %2$s.", + period, initialDelay)); + + } + return true; } @Override public boolean stop() { _swiftTemplateSyncExecutor.shutdownNow(); + + if (_s3TemplateSyncExecutor != null) { + _s3TemplateSyncExecutor.shutdownNow(); + } + return true; } @@ -1041,7 +1096,16 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe _storagePoolMaxWaitSeconds = NumbersUtil.parseInt(_configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); _preloadExecutor = Executors.newFixedThreadPool(8, new NamedThreadFactory("Template-Preloader")); _swiftTemplateSyncExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("swift-template-sync-Executor")); - return false; + + if (_s3Mgr.isS3Enabled()) { + _s3TemplateSyncExecutor = Executors + .newSingleThreadScheduledExecutor(new NamedThreadFactory( + "s3-template-sync")); + } else { + s_logger.info("S3 secondary storage synchronization is disabled."); + } + + return false; } protected TemplateManagerImpl() { @@ -1195,13 +1259,19 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe if (cmd.getZoneId() == null && _swiftMgr.isSwiftEnabled()) { _swiftMgr.deleteTemplate(cmd); } + if (cmd.getZoneId() == null && _s3Mgr.isS3Enabled()) { + _s3Mgr.deleteTemplate(cmd.getId(), caller.getAccountId()); + } + TemplateAdapter adapter = getAdapter(template.getHypervisorType()); TemplateProfile profile = adapter.prepareDelete(cmd); boolean result = adapter.delete(profile); if (result){ - if (cmd.getZoneId() == null && _swiftMgr.isSwiftEnabled()) { - List templateZones = _tmpltZoneDao.listByZoneTemplate(null, templateId); + if (cmd.getZoneId() == null + && (_swiftMgr.isSwiftEnabled() || _s3Mgr.isS3Enabled())) { + List templateZones = _tmpltZoneDao + .listByZoneTemplate(null, templateId); if (templateZones != null) { for (VMTemplateZoneVO templateZone : templateZones) { _tmpltZoneDao.remove(templateZone.getId()); @@ -1234,6 +1304,10 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe if (cmd.getZoneId() == null && _swiftMgr.isSwiftEnabled()) { _swiftMgr.deleteIso(cmd); } + if (cmd.getZoneId() == null && _s3Mgr.isS3Enabled()) { + _s3Mgr.deleteTemplate(caller.getAccountId(), templateId); + } + if (zoneId != null && (_ssvmMgr.findSecondaryStorageHost(zoneId) == null)) { throw new InvalidParameterValueException("Failed to find a secondary storage host in the specified zone."); } @@ -1241,8 +1315,10 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe TemplateProfile profile = adapter.prepareDelete(cmd); boolean result = adapter.delete(profile); if (result) { - if (cmd.getZoneId() == null && _swiftMgr.isSwiftEnabled()) { - List templateZones = _tmpltZoneDao.listByZoneTemplate(null, templateId); + if (cmd.getZoneId() == null + && (_swiftMgr.isSwiftEnabled() || _s3Mgr.isS3Enabled())) { + List templateZones = _tmpltZoneDao + .listByZoneTemplate(null, templateId); if (templateZones != null) { for (VMTemplateZoneVO templateZone : templateZones) { _tmpltZoneDao.remove(templateZone.getId()); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index b0457d7ef3e..8010e3b88c5 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -146,6 +146,8 @@ DROP TABLE IF EXISTS `cloud`.`s2s_vpn_gateway`; DROP TABLE IF EXISTS `cloud`.`s2s_vpn_connection`; DROP TABLE IF EXISTS `cloud`,`external_nicira_nvp_devices`; DROP TABLE IF EXISTS `cloud`,`nicira_nvp_nic_map`; +DROP TABLE IF EXISTS `cloud`,`s3`; +DROP TABLE IF EXISTS `cloud`,`template_s3_ref`; DROP TABLE IF EXISTS `cloud`,`nicira_nvp_router_map`; DROP TABLE IF EXISTS `cloud`.`autoscale_vmgroup_policy_map`; DROP TABLE IF EXISTS `cloud`.`autoscale_policy_condition_map`; @@ -164,7 +166,7 @@ CREATE TABLE `cloud`.`version` ( INDEX `i_version__version`(`version`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -INSERT INTO `version` (`version`, `updated`, `step`) VALUES('@VERSION@', now(), 'Complete'); +INSERT INTO `version` (`version`, `updated`, `step`) VALUES('4.0.0.2012-09-12T14:47:37Z', now(), 'Complete'); CREATE TABLE `cloud`.`op_it_work` ( `id` char(40) COMMENT 'reservation id', @@ -480,12 +482,14 @@ CREATE TABLE `cloud`.`snapshots` ( `removed` datetime COMMENT 'Date removed. not null if removed', `backup_snap_id` varchar(255) COMMENT 'Back up uuid of the snapshot', `swift_id` bigint unsigned COMMENT 'which swift', + `s3_id` bigint unsigned COMMENT 'S3 to which this snapshot will be stored', `sechost_id` bigint unsigned COMMENT 'secondary storage host id', `prev_snap_id` bigint unsigned COMMENT 'Id of the most recent snapshot', `hypervisor_type` varchar(32) NOT NULL COMMENT 'hypervisor that the snapshot was taken under', `version` varchar(32) COMMENT 'snapshot version', PRIMARY KEY (`id`), CONSTRAINT `uc_snapshots__uuid` UNIQUE (`uuid`), + CONSTRAINT `fk_snapshots__s3_id` FOREIGN KEY `fk_snapshots__s3_id` (`s3_id`) REFERENCES `s3` (`id`), INDEX `i_snapshots__removed`(`removed`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -1850,6 +1854,36 @@ CREATE TABLE `cloud`.`swift` ( CONSTRAINT `uc_swift__uuid` UNIQUE (`uuid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE `cloud`.`s3` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `uuid` varchar(40), + `access_key` varchar(20) NOT NULL COMMENT ' The S3 access key', + `secret_key` varchar(40) NOT NULL COMMENT ' The S3 secret key', + `end_point` varchar(1024) COMMENT ' The S3 host', + `bucket` varchar(63) NOT NULL COMMENT ' The S3 host', + `https` tinyint unsigned DEFAULT NULL COMMENT ' Flag indicating whether or not to connect over HTTPS', + `connection_timeout` integer COMMENT ' The amount of time to wait (in milliseconds) when initially establishing a connection before giving up and timing out.', + `max_error_retry` integer COMMENT ' The maximum number of retry attempts for failed retryable requests (ex: 5xx error responses from services).', + `socket_timeout` integer COMMENT ' The amount of time to wait (in milliseconds) for data to be transfered over an established, open connection before the connection times out and is closed.', + `created` datetime COMMENT 'date the s3 first signed on', + PRIMARY KEY (`id`), + CONSTRAINT `uc_s3__uuid` UNIQUE (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `cloud`.`template_s3_ref` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `s3_id` bigint unsigned NOT NULL COMMENT ' Associated S3 instance id', + `template_id` bigint unsigned NOT NULL COMMENT ' Associated template id', + `created` DATETIME NOT NULL COMMENT ' The creation timestamp', + `size` bigint unsigned COMMENT ' The size of the object', + `physical_size` bigint unsigned DEFAULT 0 COMMENT ' The physical size of the object', + PRIMARY KEY (`id`), + CONSTRAINT `uc_template_s3_ref__template_id` UNIQUE (`template_id`), + CONSTRAINT `fk_template_s3_ref__s3_id` FOREIGN KEY `fk_template_s3_ref__s3_id` (`s3_id`) REFERENCES `s3` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_template_s3_ref__template_id` FOREIGN KEY `fk_template_s3_ref__template_id` (`template_id`) REFERENCES `vm_template` (`id`), + INDEX `i_template_s3_ref__s3_id`(`s3_id`), + INDEX `i_template_s3_ref__template_id`(`template_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`op_host_transfer` ( `id` bigint unsigned UNIQUE NOT NULL COMMENT 'Id of the host', diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql new file mode 100644 index 00000000000..b0301d72538 --- /dev/null +++ b/setup/db/db/schema-40to410.sql @@ -0,0 +1,58 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you 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. + +--; +-- Schema upgrade from 4.0.0 to 4.1.0; +--; + +CREATE TABLE `cloud`.`s3` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `uuid` varchar(40), + `access_key` varchar(20) NOT NULL COMMENT ' The S3 access key', + `secret_key` varchar(40) NOT NULL COMMENT ' The S3 secret key', + `end_point` varchar(1024) COMMENT ' The S3 host', + `bucket` varchar(63) NOT NULL COMMENT ' The S3 host', + `https` tinyint unsigned DEFAULT NULL COMMENT ' Flag indicating whether or not to connect over HTTPS', + `connection_timeout` integer COMMENT ' The amount of time to wait (in milliseconds) when initially establishing a connection before giving up and timing out.', + `max_error_retry` integer COMMENT ' The maximum number of retry attempts for failed retryable requests (ex: 5xx error responses from services).', + `socket_timeout` integer COMMENT ' The amount of time to wait (in milliseconds) for data to be transfered over an established, open connection before the connection times out and is closed.', + `created` datetime COMMENT 'date the s3 first signed on', + PRIMARY KEY (`id`), + CONSTRAINT `uc_s3__uuid` UNIQUE (`uuid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `cloud`.`template_s3_ref` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', + `s3_id` bigint unsigned NOT NULL COMMENT ' Associated S3 instance id', + `template_id` bigint unsigned NOT NULL COMMENT ' Associated template id', + `created` DATETIME NOT NULL COMMENT ' The creation timestamp', + `size` bigint unsigned COMMENT ' The size of the object', + `physical_size` bigint unsigned DEFAULT 0 COMMENT ' The physical size of the object', + PRIMARY KEY (`id`), + CONSTRAINT `uc_template_s3_ref__template_id` UNIQUE (`template_id`), + CONSTRAINT `fk_template_s3_ref__s3_id` FOREIGN KEY `fk_template_s3_ref__s3_id` (`s3_id`) REFERENCES `s3` (`id`) ON DELETE CASCADE, + CONSTRAINT `fk_template_s3_ref__template_id` FOREIGN KEY `fk_template_s3_ref__template_id` (`template_id`) REFERENCES `vm_template` (`id`), + INDEX `i_template_s3_ref__swift_id`(`s3_id`), + INDEX `i_template_s3_ref__template_id`(`template_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 's3.enable', 'false', 'enable s3'); + +ALTER TABLE `cloud`.`snapshots` ADD COLUMN `s3_id` bigint unsigned COMMENT 'S3 to which this snapshot will be stored'; + +ALTER TABLE `cloud`.`snapshots` ADD CONSTRAINT `fk_snapshots__s3_id` FOREIGN KEY `fk_snapshots__s3_id` (`s3_id`) REFERENCES `s3` (`id`); + diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py index eeaf2a29cc2..abff8d15980 100644 --- a/tools/apidoc/gen_toc.py +++ b/tools/apidoc/gen_toc.py @@ -116,6 +116,7 @@ known_categories = { 'LB': 'Load Balancer', 'ldap': 'LDAP', 'Swift': 'Swift', + 'S3' : 'S3', 'SecondaryStorage': 'Host', 'Project': 'Project', 'Lun': 'Storage', diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py index c8052130fe6..8c4e3251690 100644 --- a/tools/marvin/marvin/cloudstackConnection.py +++ b/tools/marvin/marvin/cloudstackConnection.py @@ -42,7 +42,7 @@ class cloudConnection(object): else: self.protocol=protocol self.path = path - if port == 8096: + if port == 8096 or (self.apiKey == None and self.securityKey == None): self.auth = False else: self.auth = True diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py index bdf08cc2d2d..01235fe4027 100644 --- a/tools/marvin/marvin/deployDataCenter.py +++ b/tools/marvin/marvin/deployDataCenter.py @@ -399,9 +399,9 @@ class deployDataCenters(): logging=self.testClientLogger) """config database""" - dbSvr = self.config.dbSvr - self.testClient.dbConfigure(dbSvr.dbSvr, dbSvr.port, dbSvr.user, \ - dbSvr.passwd, dbSvr.db) + #dbSvr = self.config.dbSvr + #self.testClient.dbConfigure(dbSvr.dbSvr, dbSvr.port, dbSvr.user, \ + # dbSvr.passwd, dbSvr.db) self.apiClient = self.testClient.getApiClient() def updateConfiguration(self, globalCfg): diff --git a/ui/dictionary.jsp b/ui/dictionary.jsp index e72481eeefc..20b35bded86 100644 --- a/ui/dictionary.jsp +++ b/ui/dictionary.jsp @@ -25,6 +25,17 @@ under the License. <% long now = System.currentTimeMillis(); %>