diff --git a/.gitignore b/.gitignore index d6f5d1c8feb..a0307a771de 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,7 @@ awsapi/modules/* .settings.xml .settings/ db.properties.override +replace.properties.override awsapi/overlays/ tools/marvin/marvin/cloudstackAPI/* *.egg-info/ diff --git a/LICENSE b/LICENSE index c970ff13924..497323bffce 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013 The Apache Software Foundation +Copyright (c) 2014 The Apache Software Foundation Apache License @@ -207,38 +207,6 @@ Within the console-proxy/js directory from John Resig jquery.js -Within the deps directory - licensed under the BSD (2-clause) for XenServerJava http://www.opensource.org/licenses/BSD-2-Clause (as follows) - - 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. - - from Citrix Systems, Inc http://www.citrix.com/ - XenServerJava from http://community.citrix.com/cdn/xs/sdks/ Within the patches/systemvm/debian/config/etc directory placed in the public domain diff --git a/NOTICE b/NOTICE index d36048aabda..a74c0dcb52b 100644 --- a/NOTICE +++ b/NOTICE @@ -1,4 +1,5 @@ - +Apache CloudStack +Copyright 2014 The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/). diff --git a/agent/conf/agent.properties b/agent/conf/agent.properties index a7376b68947..b8b7a7cdad0 100644 --- a/agent/conf/agent.properties +++ b/agent/conf/agent.properties @@ -70,6 +70,17 @@ domr.scripts.dir=scripts/network/domr/kvm # In MegaBytes per second #vm.migrate.speed=0 +# set target downtime at end of livemigration, the 'hiccup' for final copy. Higher numbers +# make livemigration easier, lower numbers may cause migration to never complete. Less than 1 +# means hypervisor default (20ms). +#vm.migrate.downtime=0 + +# Busy VMs may never finish migrating, depending on environment. When its available, we will +# want to add support for autoconvergence migration flag which should fix this. Set an upper +# limit in milliseconds for how long live migration should wait, at which point VM is paused and +# migration will finish quickly. Less than 1 means disabled. +#vm.migrate.pauseafter=0 + # set the type of bridge used on the hypervisor, this defines what commands the resource # will use to setup networking. Currently supported NATIVE, OPENVSWITCH #network.bridge.type=native diff --git a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in index fb82ebfab99..d1769ccdfb0 100755 --- a/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in +++ b/agent/distro/centos/SYSCONFDIR/rc.d/init.d/cloud-agent.in @@ -24,12 +24,10 @@ . /etc/rc.d/init.d/functions -whatami=cloud-agent - # set environment variables -SHORTNAME="$whatami" -PIDFILE=@PIDDIR@/"$whatami".pid +SHORTNAME=`basename $0` +PIDFILE=@PIDDIR@/"$SHORTNAME".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" @@ -114,7 +112,7 @@ case "$1" in fi ;; *) - echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}" + echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}" RETVAL=3 esac diff --git a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in index fb82ebfab99..d1769ccdfb0 100755 --- a/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in +++ b/agent/distro/fedora/SYSCONFDIR/rc.d/init.d/cloud-agent.in @@ -24,12 +24,10 @@ . /etc/rc.d/init.d/functions -whatami=cloud-agent - # set environment variables -SHORTNAME="$whatami" -PIDFILE=@PIDDIR@/"$whatami".pid +SHORTNAME=`basename $0` +PIDFILE=@PIDDIR@/"$SHORTNAME".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" @@ -114,7 +112,7 @@ case "$1" in fi ;; *) - echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}" + echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}" RETVAL=3 esac diff --git a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in index ea1c6059b60..741317bde43 100644 --- a/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in +++ b/agent/distro/opensuse/sles/SYSCONFDIR/init.d/cloud-agent.in @@ -31,12 +31,10 @@ . /lib/lsb/init-functions . /etc/rc.status -whatami=cloud-agent - # set environment variables -SHORTNAME="$whatami" -PIDFILE=@PIDDIR@/"$whatami".pid +SHORTNAME=`basename $0` +PIDFILE=@PIDDIR@/"$SHORTNAME".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" @@ -166,7 +164,7 @@ case "$1" in start ;; *) - echo $"Usage: $whatami {start|stop|restart|status|help}" + echo $"Usage: $SHORTNAME {start|stop|restart|status|help}" RETVAL=3 esac diff --git a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in b/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in index fb82ebfab99..d1769ccdfb0 100644 --- a/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in +++ b/agent/distro/rhel/SYSCONFDIR/rc.d/init.d/cloud-agent.in @@ -24,12 +24,10 @@ . /etc/rc.d/init.d/functions -whatami=cloud-agent - # set environment variables -SHORTNAME="$whatami" -PIDFILE=@PIDDIR@/"$whatami".pid +SHORTNAME=`basename $0` +PIDFILE=@PIDDIR@/"$SHORTNAME".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" @@ -114,7 +112,7 @@ case "$1" in fi ;; *) - echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}" + echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}" RETVAL=3 esac diff --git a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in b/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in index ea1c6059b60..741317bde43 100644 --- a/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in +++ b/agent/distro/sles/SYSCONFDIR/init.d/cloud-agent.in @@ -31,12 +31,10 @@ . /lib/lsb/init-functions . /etc/rc.status -whatami=cloud-agent - # set environment variables -SHORTNAME="$whatami" -PIDFILE=@PIDDIR@/"$whatami".pid +SHORTNAME=`basename $0` +PIDFILE=@PIDDIR@/"$SHORTNAME".pid LOCKFILE=@LOCKDIR@/"$SHORTNAME" LOGFILE=@AGENTLOG@ PROGNAME="Cloud Agent" @@ -166,7 +164,7 @@ case "$1" in start ;; *) - echo $"Usage: $whatami {start|stop|restart|status|help}" + echo $"Usage: $SHORTNAME {start|stop|restart|status|help}" RETVAL=3 esac diff --git a/agent/findbugsExcludeFilter.xml b/agent/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/agent/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/agent/pom.xml b/agent/pom.xml index 2036ae0ca39..347c0f0fbf0 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT diff --git a/api/findbugsExcludeFilter.xml b/api/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/api/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/api/pom.xml b/api/pom.xml index 7629e9fd07d..abfa2c59e02 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT diff --git a/api/src/com/cloud/agent/api/HostVmStateReportEntry.java b/api/src/com/cloud/agent/api/HostVmStateReportEntry.java index 4f0fb911225..08acfef6c86 100644 --- a/api/src/com/cloud/agent/api/HostVmStateReportEntry.java +++ b/api/src/com/cloud/agent/api/HostVmStateReportEntry.java @@ -32,16 +32,12 @@ public class HostVmStateReportEntry { // host name or host uuid String host; - // XS needs Xen Tools version info - String hostToolsVersion; - public HostVmStateReportEntry() { } - public HostVmStateReportEntry(PowerState state, String host, String hostToolsVersion) { + public HostVmStateReportEntry(PowerState state, String host) { this.state = state; this.host = host; - this.hostToolsVersion = hostToolsVersion; } public PowerState getState() { @@ -51,8 +47,4 @@ public class HostVmStateReportEntry { public String getHost() { return host; } - - public String getHostToolsVersion() { - return hostToolsVersion; - } } diff --git a/api/src/com/cloud/agent/api/to/GPUDeviceTO.java b/api/src/com/cloud/agent/api/to/GPUDeviceTO.java new file mode 100644 index 00000000000..8bc9e5229de --- /dev/null +++ b/api/src/com/cloud/agent/api/to/GPUDeviceTO.java @@ -0,0 +1,56 @@ +// 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 java.util.HashMap; + +public class GPUDeviceTO { + + private String gpuGroup; + private String vgpuType; + private HashMap> groupDetails = new HashMap>(); + + public GPUDeviceTO( String gpuGroup, String vgpuType, HashMap> groupDetails) { + this.gpuGroup = gpuGroup; + this.vgpuType = vgpuType; + this.groupDetails = groupDetails; + } + + public String getGpuGroup() { + return gpuGroup; + } + + public String getVgpuType() { + return vgpuType; + } + + public void setGpuGroup(String gpuGroup) { + this.gpuGroup = gpuGroup; + } + + public void setVgpuType(String vgpuType) { + this.vgpuType = vgpuType; + } + + public HashMap> getGroupDetails() { + return groupDetails; + } + + public void setGroupDetails(HashMap> groupDetails) { + this.groupDetails = groupDetails; + } +} diff --git a/api/src/com/cloud/agent/api/to/NicTO.java b/api/src/com/cloud/agent/api/to/NicTO.java index bd8f24ec563..67660c85307 100644 --- a/api/src/com/cloud/agent/api/to/NicTO.java +++ b/api/src/com/cloud/agent/api/to/NicTO.java @@ -80,4 +80,12 @@ public class NicTO extends NetworkTO { public List getNicSecIps() { return nicSecIps; } + + public String getNetworkUuid() { + return super.getUuid(); + } + + public void setNetworkUuid(String uuid) { + super.setUuid(uuid); + } } diff --git a/api/src/com/cloud/agent/api/to/VirtualMachineTO.java b/api/src/com/cloud/agent/api/to/VirtualMachineTO.java index bed3e1d6aaf..bbd83852abf 100644 --- a/api/src/com/cloud/agent/api/to/VirtualMachineTO.java +++ b/api/src/com/cloud/agent/api/to/VirtualMachineTO.java @@ -60,6 +60,7 @@ public class VirtualMachineTO { DiskTO[] disks; NicTO[] nics; + GPUDeviceTO gpuDevice; public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader, String os, boolean enableHA, boolean limitCpuUse, String vncPassword) { @@ -266,4 +267,12 @@ public class VirtualMachineTO { this.uuid = uuid; } + public GPUDeviceTO getGpuDevice() { + return gpuDevice; + } + + public void setGpuDevice(GPUDeviceTO gpuDevice) { + this.gpuDevice = gpuDevice; + } + } diff --git a/api/src/com/cloud/domain/Domain.java b/api/src/com/cloud/domain/Domain.java index c4755d79c96..365a705041c 100644 --- a/api/src/com/cloud/domain/Domain.java +++ b/api/src/com/cloud/domain/Domain.java @@ -60,7 +60,4 @@ public interface Domain extends OwnedBy, Identity, InternalIdentity { String getNetworkDomain(); - @Override - public String getUuid(); - } diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index e88f0104ea7..39ef710f8a9 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -50,6 +50,8 @@ import com.cloud.offering.DiskOffering; import com.cloud.offering.NetworkOffering; import com.cloud.offering.ServiceOffering; import com.cloud.projects.Project; +import com.cloud.storage.GuestOS; +import com.cloud.storage.GuestOSHypervisor; import com.cloud.storage.Snapshot; import com.cloud.storage.Volume; import com.cloud.template.VirtualMachineTemplate; @@ -102,6 +104,7 @@ public class EventTypes { // Network Events public static final String EVENT_NET_IP_ASSIGN = "NET.IPASSIGN"; public static final String EVENT_NET_IP_RELEASE = "NET.IPRELEASE"; + public static final String EVENT_NET_IP_UPDATE = "NET.IPUPDATE"; public static final String EVENT_PORTABLE_IP_ASSIGN = "PORTABLE.IPASSIGN"; public static final String EVENT_PORTABLE_IP_RELEASE = "PORTABLE.IPRELEASE"; public static final String EVENT_NET_RULE_ADD = "NET.RULEADD"; @@ -112,6 +115,7 @@ public class EventTypes { public static final String EVENT_NETWORK_UPDATE = "NETWORK.UPDATE"; public static final String EVENT_FIREWALL_OPEN = "FIREWALL.OPEN"; public static final String EVENT_FIREWALL_CLOSE = "FIREWALL.CLOSE"; + public static final String EVENT_FIREWALL_UPDATE = "FIREWALL.UPDATE"; //NIC Events public static final String EVENT_NIC_CREATE = "NIC.CREATE"; @@ -285,16 +289,19 @@ public class EventTypes { // VPN public static final String EVENT_REMOTE_ACCESS_VPN_CREATE = "VPN.REMOTE.ACCESS.CREATE"; public static final String EVENT_REMOTE_ACCESS_VPN_DESTROY = "VPN.REMOTE.ACCESS.DESTROY"; + public static final String EVENT_REMOTE_ACCESS_VPN_UPDATE = "VPN.REMOTE.ACCESS.UPDATE"; public static final String EVENT_VPN_USER_ADD = "VPN.USER.ADD"; public static final String EVENT_VPN_USER_REMOVE = "VPN.USER.REMOVE"; public static final String EVENT_S2S_VPN_GATEWAY_CREATE = "VPN.S2S.VPN.GATEWAY.CREATE"; public static final String EVENT_S2S_VPN_GATEWAY_DELETE = "VPN.S2S.VPN.GATEWAY.DELETE"; + public static final String EVENT_S2S_VPN_GATEWAY_UPDATE = "VPN.S2S.VPN.GATEWAY.UPDATE"; public static final String EVENT_S2S_VPN_CUSTOMER_GATEWAY_CREATE = "VPN.S2S.CUSTOMER.GATEWAY.CREATE"; public static final String EVENT_S2S_VPN_CUSTOMER_GATEWAY_DELETE = "VPN.S2S.CUSTOMER.GATEWAY.DELETE"; public static final String EVENT_S2S_VPN_CUSTOMER_GATEWAY_UPDATE = "VPN.S2S.CUSTOMER.GATEWAY.UPDATE"; public static final String EVENT_S2S_VPN_CONNECTION_CREATE = "VPN.S2S.CONNECTION.CREATE"; public static final String EVENT_S2S_VPN_CONNECTION_DELETE = "VPN.S2S.CONNECTION.DELETE"; public static final String EVENT_S2S_VPN_CONNECTION_RESET = "VPN.S2S.CONNECTION.RESET"; + public static final String EVENT_S2S_VPN_CONNECTION_UPDATE = "VPN.S2S.CONNECTION.UPDATE"; // Network public static final String EVENT_NETWORK_RESTART = "NETWORK.RESTART"; @@ -364,6 +371,7 @@ public class EventTypes { public static final String EVENT_NETWORK_ACL_CREATE = "NETWORK.ACL.CREATE"; public static final String EVENT_NETWORK_ACL_DELETE = "NETWORK.ACL.DELETE"; public static final String EVENT_NETWORK_ACL_REPLACE = "NETWORK.ACL.REPLACE"; + public static final String EVENT_NETWORK_ACL_UPDATE = "NETWORK.ACL.UPDATE"; public static final String EVENT_NETWORK_ACL_ITEM_CREATE = "NETWORK.ACL.ITEM.CREATE"; public static final String EVENT_NETWORK_ACL_ITEM_UPDATE = "NETWORK.ACL.ITEM.UPDATE"; public static final String EVENT_NETWORK_ACL_ITEM_DELETE = "NETWORK.ACL.ITEM.DELETE"; @@ -449,6 +457,19 @@ public class EventTypes { public static final String EVENT_UCS_ASSOCIATED_PROFILE = "UCS.ASSOCIATEPROFILE"; + // IAM events + public static final String EVENT_IAM_POLICY_CREATE = "IAMPOLICY.CREATE"; + public static final String EVENT_IAM_POLICY_DELETE = "IAMPOLICY.DELETE"; + public static final String EVENT_IAM_POLICY_GRANT = "IAMPOLICY.GRANT"; + public static final String EVENT_IAM_POLICY_REVOKE = "IAMPOLICY.REVOKE"; + + public static final String EVENT_IAM_GROUP_UPDATE = "IAMGROUP.UPDATE"; + public static final String EVENT_IAM_GROUP_CREATE = "IAMGROUP.CREATE"; + public static final String EVENT_IAM_GROUP_DELETE = "IAMGROUP.DELETE"; + public static final String EVENT_IAM_GROUP_GRANT = "IAMGROUP.GRANT"; + public static final String EVENT_IAM_GROUP_REVOKE = "IAMGROUP.REVOKE"; + public static final String EVENT_IAM_ACCOUNT_POLICY_UPDATE = "IAMACCOUNTPOLICY.UPDATE"; + // Object store migration public static final String EVENT_MIGRATE_PREPARE_SECONDARY_STORAGE = "MIGRATE.PREPARE.SS"; @@ -460,10 +481,19 @@ public class EventTypes { public static final String EVENT_EXTERNAL_OPENDAYLIGHT_DELETE_CONTROLLER = "PHYSICAL.ODLCONTROLLER.DELETE"; public static final String EVENT_EXTERNAL_OPENDAYLIGHT_CONFIGURE_CONTROLLER = "PHYSICAL.ODLCONTROLLER.CONFIGURE"; + //Guest OS related events + public static final String EVENT_GUEST_OS_ADD = "GUEST.OS.ADD"; + public static final String EVENT_GUEST_OS_REMOVE = "GUEST.OS.REMOVE"; + public static final String EVENT_GUEST_OS_UPDATE = "GUEST.OS.UPDATE"; + public static final String EVENT_GUEST_OS_MAPPING_ADD = "GUEST.OS.MAPPING.ADD"; + public static final String EVENT_GUEST_OS_MAPPING_REMOVE = "GUEST.OS.MAPPING.REMOVE"; + public static final String EVENT_GUEST_OS_MAPPING_UPDATE = "GUEST.OS.MAPPING.UPDATE"; + static { // TODO: need a way to force author adding event types to declare the entity details as well, with out braking // current ActionEvent annotation semantics + // TODO #2 - The map should be from event type to class. entityEventDetails = new HashMap(); @@ -474,10 +504,13 @@ public class EventTypes { entityEventDetails.put(EVENT_VM_REBOOT, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_UPDATE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_UPGRADE, VirtualMachine.class.getName()); + entityEventDetails.put(EVENT_VM_DYNAMIC_SCALE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_RESETPASSWORD, VirtualMachine.class.getName()); + entityEventDetails.put(EVENT_VM_RESETSSHKEY, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_MIGRATE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_MOVE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_RESTORE, VirtualMachine.class.getName()); + entityEventDetails.put(EVENT_VM_EXPUNGE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_ROUTER_CREATE, VirtualRouter.class.getName()); entityEventDetails.put(EVENT_ROUTER_DESTROY, VirtualRouter.class.getName()); @@ -525,9 +558,11 @@ public class EventTypes { entityEventDetails.put(EVENT_LB_CERT_REMOVE, LoadBalancer.class.getName()); // Account events + entityEventDetails.put(EVENT_ACCOUNT_ENABLE, Account.class.getName()); entityEventDetails.put(EVENT_ACCOUNT_DISABLE, Account.class.getName()); entityEventDetails.put(EVENT_ACCOUNT_CREATE, Account.class.getName()); entityEventDetails.put(EVENT_ACCOUNT_DELETE, Account.class.getName()); + entityEventDetails.put(EVENT_ACCOUNT_UPDATE, Account.class.getName()); entityEventDetails.put(EVENT_ACCOUNT_MARK_DEFAULT_ZONE, Account.class.getName()); // UserVO Events @@ -770,6 +805,14 @@ public class EventTypes { entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_ADD_CONTROLLER, "OpenDaylightController"); entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_DELETE_CONTROLLER, "OpenDaylightController"); entityEventDetails.put(EVENT_EXTERNAL_OPENDAYLIGHT_CONFIGURE_CONTROLLER, "OpenDaylightController"); + + //Guest OS + entityEventDetails.put(EVENT_GUEST_OS_ADD, GuestOS.class.getName()); + entityEventDetails.put(EVENT_GUEST_OS_REMOVE, GuestOS.class.getName()); + entityEventDetails.put(EVENT_GUEST_OS_UPDATE, GuestOS.class.getName()); + entityEventDetails.put(EVENT_GUEST_OS_MAPPING_ADD, GuestOSHypervisor.class.getName()); + entityEventDetails.put(EVENT_GUEST_OS_MAPPING_REMOVE, GuestOSHypervisor.class.getName()); + entityEventDetails.put(EVENT_GUEST_OS_MAPPING_UPDATE, GuestOSHypervisor.class.getName()); } public static String getEntityForEvent(String eventName) { diff --git a/api/src/com/cloud/gpu/GPU.java b/api/src/com/cloud/gpu/GPU.java new file mode 100644 index 00000000000..0eb466758fc --- /dev/null +++ b/api/src/com/cloud/gpu/GPU.java @@ -0,0 +1,49 @@ +// 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.gpu; + + +public class GPU { + + public enum Keys { + pciDevice, + vgpuType + } + public enum Type { + GPU_Passthrough, + VGPU + } + + public enum vGPUType { + GRID_K100("GRID K100"), + GRID_K140Q("GRID K140Q"), + GRID_K200("GRID K200"), + GRID_K240Q("GRID K240Q"), + GRID_K260("GRID K260Q"), + passthrough("passthrough"); + + private String type; + + vGPUType(String type) { + this.type = type; + } + + public String getType() { + return type; + } + } +} diff --git a/api/src/com/cloud/network/IpAddress.java b/api/src/com/cloud/network/IpAddress.java index a3816cb3ded..5aae7842798 100644 --- a/api/src/com/cloud/network/IpAddress.java +++ b/api/src/com/cloud/network/IpAddress.java @@ -85,4 +85,6 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity Long getNetworkId(); + boolean isDisplay(); + } diff --git a/api/src/com/cloud/network/MonitoringService.java b/api/src/com/cloud/network/MonitoringService.java index 63f2ec10425..b33e8ffe139 100644 --- a/api/src/com/cloud/network/MonitoringService.java +++ b/api/src/com/cloud/network/MonitoringService.java @@ -39,7 +39,7 @@ public interface MonitoringService extends ControlledEntity, Identity, InternalI String getServiceName(); - String getPidFile(); + String getServicePidFile(); String getServicePath(); } diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index 62151a4f0c0..ef3bcdf51c4 100644 --- a/api/src/com/cloud/network/Network.java +++ b/api/src/com/cloud/network/Network.java @@ -57,7 +57,7 @@ public interface Network extends ControlledEntity, StateObject, I public static final Service PortForwarding = new Service("PortForwarding"); public static final Service SecurityGroup = new Service("SecurityGroup"); public static final Service NetworkACL = new Service("NetworkACL", Capability.SupportedProtocols); - public static final Service Connectivity = new Service("Connectivity"); + public static final Service Connectivity = new Service("Connectivity", Capability.DistributedRouter, Capability.RegionLevelVpc, Capability.StretchedL2Subnet); private final String name; private final Capability[] caps; @@ -113,6 +113,7 @@ public interface Network extends ControlledEntity, StateObject, I public static final Provider VirtualRouter = new Provider("VirtualRouter", false); public static final Provider JuniperContrailRouter = new Provider("JuniperContrailRouter", false); + public static final Provider JuniperContrailVpcRouter = new Provider("JuniperContrailVpcRouter", false); public static final Provider JuniperSRX = new Provider("JuniperSRX", true); public static final Provider PaloAlto = new Provider("PaloAlto", true); public static final Provider F5BigIp = new Provider("F5BigIp", true); @@ -185,6 +186,9 @@ public interface Network extends ControlledEntity, StateObject, I public static final Capability SslTermination = new Capability("SslTermination"); public static final Capability LbSchemes = new Capability("LbSchemes"); public static final Capability DhcpAccrossMultipleSubnets = new Capability("DhcpAccrossMultipleSubnets"); + public static final Capability DistributedRouter = new Capability("DistributedRouter"); + public static final Capability StretchedL2Subnet = new Capability("StretchedL2Subnet"); + public static final Capability RegionLevelVpc = new Capability("RegionLevelVpc"); private final String name; @@ -335,4 +339,6 @@ public interface Network extends ControlledEntity, StateObject, I Long getNetworkACLId(); void setNetworkACLId(Long networkACLId); + + boolean isStrechedL2Network(); } diff --git a/api/src/com/cloud/network/NetworkModel.java b/api/src/com/cloud/network/NetworkModel.java index f6555db565e..f48bc9a7e5a 100644 --- a/api/src/com/cloud/network/NetworkModel.java +++ b/api/src/com/cloud/network/NetworkModel.java @@ -22,6 +22,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; + import com.cloud.dc.Vlan; import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InvalidParameterValueException; @@ -199,10 +201,10 @@ public interface NetworkModel { List getPhysicalNtwksSupportingTrafficType(long zoneId, TrafficType trafficType); /** - * @param guestNic + * @param ntwkId * @return */ - boolean isPrivateGateway(Nic guestNic); + boolean isPrivateGateway(long ntwkId); Map> getNetworkCapabilities(long networkId); @@ -273,4 +275,6 @@ public interface NetworkModel { boolean isNetworkReadyForGc(long networkId); boolean getNetworkEgressDefaultPolicy(Long networkId); + + void checkNetworkPermissions(Account owner, Network network, AccessType accessType); } \ No newline at end of file diff --git a/api/src/com/cloud/network/NetworkProfile.java b/api/src/com/cloud/network/NetworkProfile.java index 1b66c7c5f7c..db3cba56e1a 100644 --- a/api/src/com/cloud/network/NetworkProfile.java +++ b/api/src/com/cloud/network/NetworkProfile.java @@ -55,6 +55,7 @@ public class NetworkProfile implements Network { private final boolean displayNetwork; private Long networkAclId; private final String guruName; + private boolean strechedL2Subnet; public NetworkProfile(Network network) { id = network.getId(); @@ -87,6 +88,7 @@ public class NetworkProfile implements Network { displayNetwork = network.getDisplayNetwork(); networkAclId = network.getNetworkACLId(); guruName = network.getGuruName(); + strechedL2Subnet = network.isStrechedL2Network(); } public String getDns1() { @@ -275,4 +277,15 @@ public class NetworkProfile implements Network { public String getIp6Cidr() { return ip6Cidr; } + + @Override + public Class getEntityType() { + return Network.class; + } + + @Override + public boolean isStrechedL2Network() { + return false; + } + } diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java index 1731b119d5e..1e126f52aee 100755 --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -50,7 +50,7 @@ public interface NetworkService { List getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner); - IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException, + IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException; boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException; @@ -77,7 +77,7 @@ public interface NetworkService { IpAddress getIp(long id); Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser, String domainSuffix, Long networkOfferingId, - Boolean changeCidr, String guestVmCidr, Boolean displayNetwork); + Boolean changeCidr, String guestVmCidr, Boolean displayNetwork, String newUUID); PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List isolationMethods, String broadcastDomainRange, Long domainId, List tags, String name); @@ -176,4 +176,6 @@ public interface NetworkService { List listNics(ListNicsCmd listNicsCmd); Map getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service); + + IpAddress updateIP(Long id, String customId, Boolean displayIp); } diff --git a/api/src/com/cloud/network/RemoteAccessVpn.java b/api/src/com/cloud/network/RemoteAccessVpn.java index d3262b75e3e..4d7e4d49b12 100644 --- a/api/src/com/cloud/network/RemoteAccessVpn.java +++ b/api/src/com/cloud/network/RemoteAccessVpn.java @@ -38,4 +38,6 @@ public interface RemoteAccessVpn extends ControlledEntity, InternalIdentity, Ide Long getVpcId(); State getState(); + + boolean isDisplay(); } diff --git a/api/src/com/cloud/network/Site2SiteVpnConnection.java b/api/src/com/cloud/network/Site2SiteVpnConnection.java index ad1a9825c01..81e81801195 100644 --- a/api/src/com/cloud/network/Site2SiteVpnConnection.java +++ b/api/src/com/cloud/network/Site2SiteVpnConnection.java @@ -42,4 +42,6 @@ public interface Site2SiteVpnConnection extends ControlledEntity, InternalIdenti public Date getRemoved(); public boolean isPassive(); + + boolean isDisplay(); } diff --git a/api/src/com/cloud/network/Site2SiteVpnGateway.java b/api/src/com/cloud/network/Site2SiteVpnGateway.java index b60db3adf5c..bae12597f27 100644 --- a/api/src/com/cloud/network/Site2SiteVpnGateway.java +++ b/api/src/com/cloud/network/Site2SiteVpnGateway.java @@ -1,3 +1,4 @@ + // 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 @@ -15,17 +16,19 @@ // specific language governing permissions and limitations // under the License. package com.cloud.network; - import java.util.Date; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; + public interface Site2SiteVpnGateway extends ControlledEntity, Identity, InternalIdentity { public long getAddrId(); public long getVpcId(); public Date getRemoved(); + + boolean isDisplay(); } diff --git a/api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java b/api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java index eee62ceea76..382c460725d 100644 --- a/api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java +++ b/api/src/com/cloud/network/VpcVirtualNetworkApplianceService.java @@ -16,10 +16,13 @@ // under the License. package com.cloud.network; +import java.util.Map; + import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.router.VirtualRouter; +import com.cloud.vm.VirtualMachineProfile; public interface VpcVirtualNetworkApplianceService extends VirtualNetworkApplianceService { @@ -27,13 +30,14 @@ public interface VpcVirtualNetworkApplianceService extends VirtualNetworkApplian * @param router * @param network * @param isRedundant + * @param params TODO * @return * @throws ConcurrentOperationException * @throws ResourceUnavailableException * @throws InsufficientCapacityException */ - boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant) throws ConcurrentOperationException, ResourceUnavailableException, - InsufficientCapacityException; + boolean addVpcRouterToGuestNetwork(VirtualRouter router, Network network, boolean isRedundant, Map params) + throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException; /** * @param router diff --git a/api/src/com/cloud/network/as/AutoScaleVmGroup.java b/api/src/com/cloud/network/as/AutoScaleVmGroup.java index e8b328fc267..14c761593b1 100644 --- a/api/src/com/cloud/network/as/AutoScaleVmGroup.java +++ b/api/src/com/cloud/network/as/AutoScaleVmGroup.java @@ -53,4 +53,6 @@ public interface AutoScaleVmGroup extends ControlledEntity, InternalIdentity { String getUuid(); + boolean isDisplay(); + } diff --git a/api/src/com/cloud/network/as/AutoScaleVmProfile.java b/api/src/com/cloud/network/as/AutoScaleVmProfile.java index 0577080a316..6e0b5ffb91b 100644 --- a/api/src/com/cloud/network/as/AutoScaleVmProfile.java +++ b/api/src/com/cloud/network/as/AutoScaleVmProfile.java @@ -48,4 +48,6 @@ public interface AutoScaleVmProfile extends ControlledEntity, InternalIdentity { public long getAutoScaleUserId(); + boolean isDisplay(); + } diff --git a/api/src/com/cloud/network/element/AggregatedCommandExecutor.java b/api/src/com/cloud/network/element/AggregatedCommandExecutor.java new file mode 100644 index 00000000000..012908fc268 --- /dev/null +++ b/api/src/com/cloud/network/element/AggregatedCommandExecutor.java @@ -0,0 +1,28 @@ +// 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.element; + +import com.cloud.deploy.DeployDestination; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.Network; + +public interface AggregatedCommandExecutor { + public boolean prepareAggregatedExecution(Network network, DeployDestination dest) throws ResourceUnavailableException; + public boolean completeAggregatedExecution(Network network, DeployDestination dest) throws ResourceUnavailableException; + public boolean cleanupAggregatedExecution(Network network, DeployDestination dest) throws ResourceUnavailableException; +} diff --git a/api/src/com/cloud/network/firewall/FirewallService.java b/api/src/com/cloud/network/firewall/FirewallService.java index 917bda3de6d..5ab789121ad 100644 --- a/api/src/com/cloud/network/firewall/FirewallService.java +++ b/api/src/com/cloud/network/firewall/FirewallService.java @@ -50,4 +50,6 @@ public interface FirewallService { boolean revokeRelatedFirewallRule(long ruleId, boolean apply); + FirewallRule updateFirewallRule(long ruleId, String customId, Boolean forDisplay); + } diff --git a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java index cd0a276c73c..98d29c5718d 100644 --- a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java +++ b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java @@ -41,16 +41,17 @@ import com.cloud.utils.net.Ip; public interface LoadBalancingRulesService { /** * Create a load balancer rule from the given ipAddress/port to the given private port - * * @param openFirewall * TODO + * @param forDisplay TODO * @param cmd * the command specifying the ip address, public port, protocol, private port, and algorithm + * * @return the newly created LoadBalancerVO if successful, null otherwise * @throws InsufficientAddressCapacityException */ LoadBalancer createPublicLoadBalancerRule(String xId, String name, String description, int srcPortStart, int srcPortEnd, int defPortStart, int defPortEnd, - Long ipAddrId, String protocol, String algorithm, long networkId, long lbOwnerId, boolean openFirewall, String lbProtocol) throws NetworkRuleConflictException, + Long ipAddrId, String protocol, String algorithm, long networkId, long lbOwnerId, boolean openFirewall, String lbProtocol, Boolean forDisplay) throws NetworkRuleConflictException, InsufficientAddressCapacityException; LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd); @@ -91,13 +92,13 @@ public interface LoadBalancingRulesService { boolean deleteLBHealthCheckPolicy(long healthCheckPolicyId, boolean apply); /** - * Assign a virtual machine, or list of virtual machines, to a load balancer. + * Assign a virtual machine or list of virtual machines, or Map of to a load balancer. */ - boolean assignToLoadBalancer(long lbRuleId, List vmIds); + boolean assignToLoadBalancer(long lbRuleId, List vmIds, Map> vmIdIpMap); boolean assignSSLCertToLoadBalancerRule(Long lbRuleId, String certName, String publicCert, String privateKey); - boolean removeFromLoadBalancer(long lbRuleId, List vmIds); + boolean removeFromLoadBalancer(long lbRuleId, List vmIds, Map> vmIdIpMap); boolean applyLoadBalancerConfig(long lbRuleId) throws ResourceUnavailableException; @@ -150,4 +151,8 @@ public interface LoadBalancingRulesService { public void updateLBHealthChecks(Scheme scheme) throws ResourceUnavailableException; Map getLbInstances(long lbId); + + boolean isLbRuleMappedToVmGuestIp(String vmSecondaryIp); + + List listLbVmIpAddress(long id, long vmId); } diff --git a/api/src/com/cloud/network/rules/FirewallRule.java b/api/src/com/cloud/network/rules/FirewallRule.java index 274242ad394..b02257b7c89 100644 --- a/api/src/com/cloud/network/rules/FirewallRule.java +++ b/api/src/com/cloud/network/rules/FirewallRule.java @@ -87,4 +87,6 @@ public interface FirewallRule extends ControlledEntity, Identity, InternalIdenti */ TrafficType getTrafficType(); + boolean isDisplay(); + } diff --git a/api/src/com/cloud/network/rules/RulesService.java b/api/src/com/cloud/network/rules/RulesService.java index 39329d5e734..2dd0182dbc4 100644 --- a/api/src/com/cloud/network/rules/RulesService.java +++ b/api/src/com/cloud/network/rules/RulesService.java @@ -41,11 +41,12 @@ public interface RulesService { * vm to be linked to. If specified the destination ip address is ignored. * @param openFirewall * TODO + * @param forDisplay TODO * @return PortForwardingRule if created. * @throws NetworkRuleConflictException * if conflicts in the network rules are detected. */ - PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, Ip vmIp, boolean openFirewall) throws NetworkRuleConflictException; + PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, Ip vmIp, boolean openFirewall, Boolean forDisplay) throws NetworkRuleConflictException; /** * Revokes a port forwarding rule @@ -80,4 +81,6 @@ public interface RulesService { boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException; + PortForwardingRule updatePortForwardingRule(long id, String customId, Boolean forDisplay); + } diff --git a/api/src/com/cloud/network/vpc/NetworkACL.java b/api/src/com/cloud/network/vpc/NetworkACL.java index a97c57d6ff0..3ebee146ed8 100644 --- a/api/src/com/cloud/network/vpc/NetworkACL.java +++ b/api/src/com/cloud/network/vpc/NetworkACL.java @@ -33,4 +33,6 @@ public interface NetworkACL extends InternalIdentity { long getId(); String getName(); + + boolean isDisplay(); } diff --git a/api/src/com/cloud/network/vpc/NetworkACLItem.java b/api/src/com/cloud/network/vpc/NetworkACLItem.java index d8dd0fb79d1..faa4d273c9c 100644 --- a/api/src/com/cloud/network/vpc/NetworkACLItem.java +++ b/api/src/com/cloud/network/vpc/NetworkACLItem.java @@ -73,4 +73,6 @@ public interface NetworkACLItem extends InternalIdentity { */ TrafficType getTrafficType(); + boolean isDisplay(); + } diff --git a/api/src/com/cloud/network/vpc/NetworkACLService.java b/api/src/com/cloud/network/vpc/NetworkACLService.java index 4d1188018b5..7cd1d3b3141 100644 --- a/api/src/com/cloud/network/vpc/NetworkACLService.java +++ b/api/src/com/cloud/network/vpc/NetworkACLService.java @@ -31,9 +31,10 @@ public interface NetworkACLService { * @param name * @param description * @param vpcId + * @param forDisplay TODO * @return */ - NetworkACL createNetworkACL(String name, String description, long vpcId); + NetworkACL createNetworkACL(String name, String description, long vpcId, Boolean forDisplay); /** * Get Network ACL with specified Id @@ -114,11 +115,13 @@ public interface NetworkACLService { * @param sourcePortEnd * @param icmpCode * @param icmpType + * @param newUUID TODO + * @param forDisplay TODO * @return * @throws ResourceUnavailableException */ NetworkACLItem updateNetworkACLItem(Long id, String protocol, List sourceCidrList, NetworkACLItem.TrafficType trafficType, String action, Integer number, - Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType) throws ResourceUnavailableException; + Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType, String newUUID, Boolean forDisplay) throws ResourceUnavailableException; /** * Associates ACL with specified Network @@ -129,4 +132,6 @@ public interface NetworkACLService { */ boolean replaceNetworkACLonPrivateGw(long aclId, long privateGatewayId) throws ResourceUnavailableException; + NetworkACL updateNetworkACL(Long id, String customId, Boolean forDisplay); + } diff --git a/api/src/com/cloud/network/vpc/StaticRouteProfile.java b/api/src/com/cloud/network/vpc/StaticRouteProfile.java index 05cff4986a2..737541f0a40 100644 --- a/api/src/com/cloud/network/vpc/StaticRouteProfile.java +++ b/api/src/com/cloud/network/vpc/StaticRouteProfile.java @@ -16,6 +16,7 @@ // under the License. package com.cloud.network.vpc; + public class StaticRouteProfile implements StaticRoute { private long id; private String uuid; @@ -31,18 +32,18 @@ public class StaticRouteProfile implements StaticRoute { String ipAddress; public StaticRouteProfile(StaticRoute staticRoute, VpcGateway gateway) { - this.id = staticRoute.getId(); - this.uuid = staticRoute.getUuid(); - this.targetCidr = staticRoute.getCidr(); - this.accountId = staticRoute.getAccountId(); - this.domainId = staticRoute.getDomainId(); - this.gatewayId = staticRoute.getVpcGatewayId(); - this.state = staticRoute.getState(); - this.vpcId = staticRoute.getVpcId(); - this.vlanTag = gateway.getBroadcastUri(); + id = staticRoute.getId(); + uuid = staticRoute.getUuid(); + targetCidr = staticRoute.getCidr(); + accountId = staticRoute.getAccountId(); + domainId = staticRoute.getDomainId(); + gatewayId = staticRoute.getVpcGatewayId(); + state = staticRoute.getState(); + vpcId = staticRoute.getVpcId(); + vlanTag = gateway.getBroadcastUri(); this.gateway = gateway.getGateway(); - this.netmask = gateway.getNetmask(); - this.ipAddress = gateway.getIp4Address(); + netmask = gateway.getNetmask(); + ipAddress = gateway.getIp4Address(); } @Override @@ -72,7 +73,7 @@ public class StaticRouteProfile implements StaticRoute { @Override public Long getVpcId() { - return vpcId; + return vpcId; } @Override @@ -101,4 +102,8 @@ public class StaticRouteProfile implements StaticRoute { return netmask; } + @Override + public Class getEntityType() { + return StaticRoute.class; + } } diff --git a/api/src/com/cloud/network/vpc/Vpc.java b/api/src/com/cloud/network/vpc/Vpc.java index fb5f2cc8991..23388787d23 100644 --- a/api/src/com/cloud/network/vpc/Vpc.java +++ b/api/src/com/cloud/network/vpc/Vpc.java @@ -72,4 +72,17 @@ public interface Vpc extends ControlledEntity, Identity, InternalIdentity { */ boolean isRestartRequired(); + boolean isDisplay(); + + /** + * + * @return true if VPC is configured to use distributed router to provides one-hop forwarding and hypervisor based ACL + */ + boolean usesDistributedRouter(); + + /** + * + * @return true if VPC spans multiple zones in the region + */ + boolean isRegionLevelVpc(); } diff --git a/api/src/com/cloud/network/vpc/VpcOffering.java b/api/src/com/cloud/network/vpc/VpcOffering.java index 6e75a2f2500..660c79dc1e4 100644 --- a/api/src/com/cloud/network/vpc/VpcOffering.java +++ b/api/src/com/cloud/network/vpc/VpcOffering.java @@ -55,4 +55,13 @@ public interface VpcOffering extends InternalIdentity, Identity { */ Long getServiceOfferingId(); + /** + * @return true if the offering provides a distributed router capable of one-hop forwarding + */ + boolean supportsDistributedRouter(); + + /** + * @return true if VPC created with the offering can span multiple zones in the region + */ + boolean offersRegionLevelVPC(); } diff --git a/api/src/com/cloud/network/vpc/VpcProvisioningService.java b/api/src/com/cloud/network/vpc/VpcProvisioningService.java index 174b71f34a2..82a7baae959 100644 --- a/api/src/com/cloud/network/vpc/VpcProvisioningService.java +++ b/api/src/com/cloud/network/vpc/VpcProvisioningService.java @@ -16,6 +16,7 @@ // under the License. package com.cloud.network.vpc; + import java.util.List; import java.util.Map; @@ -23,8 +24,10 @@ public interface VpcProvisioningService { public VpcOffering getVpcOffering(long vpcOfferingId); - public VpcOffering createVpcOffering(String name, String displayText, List supportedServices, Map> serviceProviders, - Long serviceOfferingId); + public VpcOffering createVpcOffering(String name, String displayText, List supportedServices, + Map> serviceProviders, + Map serviceCapabilitystList, + Long serviceOfferingId); List listVpcOfferings(Long id, String name, String displayText, List supportedServicesStr, Boolean isDefault, String keyword, String state, Long startIndex, Long pageSizeVal); diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java index e28f3515271..d1166df4065 100644 --- a/api/src/com/cloud/network/vpc/VpcService.java +++ b/api/src/com/cloud/network/vpc/VpcService.java @@ -43,10 +43,11 @@ public interface VpcService { * @param displayText * @param cidr * @param networkDomain TODO + * @param displayVpc TODO * @return * @throws ResourceAllocationException TODO */ - public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain) + public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain, Boolean displayVpc) throws ResourceAllocationException; /** @@ -66,9 +67,11 @@ public interface VpcService { * @param vpcId * @param vpcName * @param displayText + * @param customId TODO + * @param displayVpc TODO * @return */ - public Vpc updateVpc(long vpcId, String vpcName, String displayText); + public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc); /** * Lists VPC(s) based on the parameters passed to the method call @@ -90,12 +93,13 @@ public interface VpcService { * @param restartRequired TODO * @param tags TODO * @param projectId TODO + * @param display TODO * @param vpc * @return */ public List listVpcs(Long id, String vpcName, String displayText, List supportedServicesStr, String cidr, Long vpcOffId, String state, String accountName, Long domainId, String keyword, Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired, - Map tags, Long projectId); + Map tags, Long projectId, Boolean display); /** * Starts VPC which includes starting VPC provider and applying all the neworking rules on the backend diff --git a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java index ac9649b171b..acf007bbb33 100644 --- a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java +++ b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java @@ -31,7 +31,7 @@ import com.cloud.utils.Pair; public interface RemoteAccessVpnService { static final String RemoteAccessVpnClientIpRangeCK = "remote.access.vpn.client.iprange"; - RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall) throws NetworkRuleConflictException; + RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall, Boolean forDisplay) throws NetworkRuleConflictException; void destroyRemoteAccessVpnForIp(long vpnServerAddressId, Account caller) throws ResourceUnavailableException; @@ -52,4 +52,9 @@ public interface RemoteAccessVpnService { List listRemoteAccessVpns(long networkId); RemoteAccessVpn getRemoteAccessVpn(long vpnAddrId); + + RemoteAccessVpn getRemoteAccessVpnById(long vpnId); + + RemoteAccessVpn updateRemoteAccessVpn(long id, String customId, Boolean forDisplay); + } diff --git a/api/src/com/cloud/network/vpn/Site2SiteVpnService.java b/api/src/com/cloud/network/vpn/Site2SiteVpnService.java index bfc5e2579bd..abdc7568766 100644 --- a/api/src/com/cloud/network/vpn/Site2SiteVpnService.java +++ b/api/src/com/cloud/network/vpn/Site2SiteVpnService.java @@ -63,4 +63,8 @@ public interface Site2SiteVpnService { Pair, Integer> searchForVpnConnections(ListVpnConnectionsCmd listVpnConnectionsCmd); Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCmd updateVpnCustomerGatewayCmd); + + Site2SiteVpnConnection updateVpnConnection(long id, String customId, Boolean forDisplay); + + Site2SiteVpnGateway updateVpnGateway(Long id, String customId, Boolean forDisplay); } diff --git a/api/src/com/cloud/offering/DiskOfferingInfo.java b/api/src/com/cloud/offering/DiskOfferingInfo.java new file mode 100644 index 00000000000..75a520e2d5a --- /dev/null +++ b/api/src/com/cloud/offering/DiskOfferingInfo.java @@ -0,0 +1,65 @@ +/* + * 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.offering; + +public class DiskOfferingInfo { + private DiskOffering _diskOffering; + private Long _size; + private Long _minIops; + private Long _maxIops; + + public DiskOfferingInfo() { + } + + public DiskOfferingInfo(DiskOffering diskOffering) { + _diskOffering = diskOffering; + } + + public void setDiskOffering(DiskOffering diskOffering) { + _diskOffering = diskOffering; + } + + public DiskOffering getDiskOffering() { + return _diskOffering; + } + + public void setSize(Long size) { + _size = size; + } + + public Long getSize() { + return _size; + } + + public void setMinIops(Long minIops) { + _minIops = minIops; + } + + public Long getMinIops() { + return _minIops; + } + + public void setMaxIops(Long maxIops) { + _maxIops = maxIops; + } + + public Long getMaxIops() { + return _maxIops; + } +} \ No newline at end of file diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java index b4f3863293a..f1ef69c2f68 100644 --- a/api/src/com/cloud/offering/NetworkOffering.java +++ b/api/src/com/cloud/offering/NetworkOffering.java @@ -129,4 +129,6 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity, Integer getConcurrentConnections(); boolean isKeepAliveEnabled(); + + boolean getSupportsStrechedL2(); } diff --git a/api/src/com/cloud/serializer/Param.java b/api/src/com/cloud/serializer/Param.java index 02deb6f1c1f..3e6f852128a 100644 --- a/api/src/com/cloud/serializer/Param.java +++ b/api/src/com/cloud/serializer/Param.java @@ -19,6 +19,8 @@ package com.cloud.serializer; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import org.apache.cloudstack.acl.RoleType; + @Retention(RetentionPolicy.RUNTIME) public @interface Param { String name() default ""; @@ -33,4 +35,6 @@ public @interface Param { boolean includeInApiDoc() default true; String since() default ""; + + RoleType[] authorized() default {}; } diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java index 24fad87ea0f..abe6e2cd36e 100755 --- a/api/src/com/cloud/server/ManagementService.java +++ b/api/src/com/cloud/server/ManagementService.java @@ -23,6 +23,13 @@ import java.util.Map; import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd; import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd; import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd; +import org.apache.cloudstack.api.command.admin.guest.AddGuestOsCmd; +import org.apache.cloudstack.api.command.admin.guest.AddGuestOsMappingCmd; +import org.apache.cloudstack.api.command.admin.guest.ListGuestOsMappingCmd; +import org.apache.cloudstack.api.command.admin.guest.RemoveGuestOsCmd; +import org.apache.cloudstack.api.command.admin.guest.RemoveGuestOsMappingCmd; +import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsCmd; +import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsMappingCmd; import org.apache.cloudstack.api.command.admin.host.ListHostsCmd; import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd; import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd; @@ -67,6 +74,7 @@ import com.cloud.hypervisor.HypervisorCapabilities; import com.cloud.network.IpAddress; import com.cloud.org.Cluster; import com.cloud.storage.GuestOS; +import com.cloud.storage.GuestOSHypervisor; import com.cloud.storage.GuestOsCategory; import com.cloud.storage.StoragePool; import com.cloud.user.SSHKeyPair; @@ -146,6 +154,69 @@ public interface ManagementService { */ Pair, Integer> listGuestOSCategoriesByCriteria(ListGuestOsCategoriesCmd cmd); + /** + * Obtains a list of all guest OS mappings + * + * @return list of GuestOSHypervisor + */ + Pair, Integer> listGuestOSMappingByCriteria(ListGuestOsMappingCmd cmd); + + /** + * Adds a new guest OS mapping + * + * @return A VO containing the new mapping, with its hypervisor, hypervisor type, guest OS name, and the name of guest OS specific to hypervisor + */ + GuestOSHypervisor addGuestOsMapping(AddGuestOsMappingCmd addGuestOsMappingCmd); + + /** + * Find newly added guest OS mapping by ID + * + * @return A VO containing the guest OS mapping specified by ID, with its hypervisor, hypervisor type, guest OS name, and the name of guest OS specific to hypervisor + */ + GuestOSHypervisor getAddedGuestOsMapping(Long guestOsHypervisorId); + + /** + * Adds a new guest OS + * + * @return A VO containing the new guest OS, with its category ID, name and display name + */ + GuestOS addGuestOs(AddGuestOsCmd addGuestOsCmd); + + /** + * Find newly added guest OS by ID + * + * @return A VO containing the guest OS specified by ID, with its category ID, name and display name + */ + GuestOS getAddedGuestOs(Long guestOsId); + + /** + * Updates an existing guest OS + * + * @return A VO containing the updated display name + */ + GuestOS updateGuestOs(UpdateGuestOsCmd updateGuestOsCmd); + + /** + * Updates an existing guest OS mapping + * + * @return A VO containing the updated OS name for hypervisor + */ + GuestOSHypervisor updateGuestOsMapping(UpdateGuestOsMappingCmd updateGuestOsMappingCmd); + + /** + * Removes an existing guest OS + * + * @return True is successfully marked for delete, false otherwise + */ + boolean removeGuestOs(RemoveGuestOsCmd removeGuestOsCmd); + + /** + * Removes an existing guest OS mapping + * + * @return True is successfully marked for delete, false otherwise + */ + boolean removeGuestOsMapping(RemoveGuestOsMappingCmd removeGuestOsMappingCmd); + VirtualMachine stopSystemVM(StopSystemVmCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException; VirtualMachine startSystemVM(long vmId); @@ -269,10 +340,6 @@ public interface ManagementService { */ String generateRandomPassword(); - public Long saveStartedEvent(Long userId, Long accountId, String type, String description, long startEventId); - - public Long saveCompletedEvent(Long userId, Long accountId, String level, String type, String description, long startEventId); - /** * Search registered key pairs for the logged in user. * @@ -365,4 +432,6 @@ public interface ManagementService { ConcurrentOperationException; void cleanupVMReservations(); + + } diff --git a/api/src/com/cloud/server/ResourceMetaDataService.java b/api/src/com/cloud/server/ResourceMetaDataService.java index 2871d991ab7..56fe1045ab3 100644 --- a/api/src/com/cloud/server/ResourceMetaDataService.java +++ b/api/src/com/cloud/server/ResourceMetaDataService.java @@ -30,9 +30,10 @@ public interface ResourceMetaDataService { * @param resourceId TODO * @param resourceType * @param details + * @param forDisplay TODO * @return */ - boolean addResourceMetaData(String resourceId, ResourceObjectType resourceType, Map details); + boolean addResourceMetaData(String resourceId, ResourceObjectType resourceType, Map details, boolean forDisplay); /** * diff --git a/api/src/com/cloud/server/ResourceTag.java b/api/src/com/cloud/server/ResourceTag.java index 41931f0949b..275510e1a1a 100644 --- a/api/src/com/cloud/server/ResourceTag.java +++ b/api/src/com/cloud/server/ResourceTag.java @@ -51,7 +51,9 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit CustomerGateway(false, true), VpnConnection(false, true), User(true, true), - DiskOffering(false, true); + DiskOffering(false, true), + AutoScaleVmProfile(false, true), + AutoScaleVmGroup(false, true); ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) { this.resourceTagsSupport = resourceTagsSupport; diff --git a/api/src/com/cloud/storage/GuestOS.java b/api/src/com/cloud/storage/GuestOS.java index 437cd37d1ab..767a60ecf9f 100644 --- a/api/src/com/cloud/storage/GuestOS.java +++ b/api/src/com/cloud/storage/GuestOS.java @@ -16,6 +16,8 @@ // under the License. package com.cloud.storage; +import java.util.Date; + import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; @@ -26,4 +28,8 @@ public interface GuestOS extends InternalIdentity, Identity { String getDisplayName(); long getCategoryId(); + + Date getCreated(); + + Date getRemoved(); } diff --git a/api/src/com/cloud/storage/GuestOSHypervisor.java b/api/src/com/cloud/storage/GuestOSHypervisor.java index f022722af04..1cfc3a17285 100644 --- a/api/src/com/cloud/storage/GuestOSHypervisor.java +++ b/api/src/com/cloud/storage/GuestOSHypervisor.java @@ -16,6 +16,8 @@ // under the License. package com.cloud.storage; +import java.util.Date; + import org.apache.cloudstack.api.InternalIdentity; public interface GuestOSHypervisor extends InternalIdentity { @@ -25,4 +27,12 @@ public interface GuestOSHypervisor extends InternalIdentity { String getGuestOsName(); long getGuestOsId(); + + String getHypervisorVersion(); + + String getUuid(); + + Date getRemoved(); + + Date getCreated(); } diff --git a/api/src/com/cloud/storage/Storage.java b/api/src/com/cloud/storage/Storage.java index 2175c9b1a0c..8ab2463a81b 100755 --- a/api/src/com/cloud/storage/Storage.java +++ b/api/src/com/cloud/storage/Storage.java @@ -86,7 +86,7 @@ public class Storage { public static enum StoragePoolType { Filesystem(false), // local directory - NetworkFilesystem(true), // NFS or CIFS + NetworkFilesystem(true), // NFS IscsiLUN(true), // shared LUN, with a clusterfs overlay Iscsi(true), // for e.g., ZFS Comstar ISO(false), // for iso image @@ -97,7 +97,9 @@ public class Storage { VMFS(true), // VMware VMFS storage PreSetup(true), // for XenServer, Storage Pool is set up by customers. EXT(false), // XenServer local EXT SR - OCFS2(true); + OCFS2(true), + SMB(true), + Gluster(true); boolean shared; diff --git a/api/src/com/cloud/storage/StoragePool.java b/api/src/com/cloud/storage/StoragePool.java index 6ede960c1f0..8e03c3348f3 100644 --- a/api/src/com/cloud/storage/StoragePool.java +++ b/api/src/com/cloud/storage/StoragePool.java @@ -21,6 +21,7 @@ import java.util.Date; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; +import com.cloud.hypervisor.Hypervisor; import com.cloud.storage.Storage.StoragePoolType; public interface StoragePool extends Identity, InternalIdentity { @@ -98,10 +99,9 @@ public interface StoragePool extends Identity, InternalIdentity { Long getPodId(); - /** - * @return - */ String getStorageProviderName(); boolean isInMaintenance(); + + Hypervisor.HypervisorType getHypervisor(); } diff --git a/api/src/com/cloud/storage/Volume.java b/api/src/com/cloud/storage/Volume.java index 84f0872f909..304dbcfe342 100755 --- a/api/src/com/cloud/storage/Volume.java +++ b/api/src/com/cloud/storage/Volume.java @@ -82,7 +82,7 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba s_fsm.addTransition(Destroy, Event.ExpungingRequested, Expunging); s_fsm.addTransition(Expunging, Event.ExpungingRequested, Expunging); s_fsm.addTransition(Expunging, Event.OperationSucceeded, Expunged); - s_fsm.addTransition(Expunging, Event.OperationFailed, Expunging); + s_fsm.addTransition(Expunging, Event.OperationFailed, Destroy); s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting); s_fsm.addTransition(Snapshotting, Event.OperationSucceeded, Ready); s_fsm.addTransition(Snapshotting, Event.OperationFailed, Ready); @@ -190,4 +190,6 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba Long getVmSnapshotChainSize(); Integer getHypervisorSnapshotReserve(); + + boolean isDisplayVolume(); } diff --git a/api/src/com/cloud/storage/VolumeApiService.java b/api/src/com/cloud/storage/VolumeApiService.java index 09ac3ee2cbb..5487a4bf9b2 100644 --- a/api/src/com/cloud/storage/VolumeApiService.java +++ b/api/src/com/cloud/storage/VolumeApiService.java @@ -66,11 +66,11 @@ public interface VolumeApiService { /** * Uploads the volume to secondary storage * - * @param UploadVolumeCmd cmd + * @param UploadVolumeCmdByAdmin cmd * * @return Volume object */ - Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException; + Volume uploadVolume(UploadVolumeCmd cmd) throws ResourceAllocationException; boolean deleteVolume(long volumeId, Account caller) throws ConcurrentOperationException; @@ -82,7 +82,7 @@ public interface VolumeApiService { Snapshot allocSnapshot(Long volumeId, Long policyId) throws ResourceAllocationException; - Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume, String customId, long owner); + Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume, String customId, long owner, String chainInfo); /** * Extracts the volume to a particular location. @@ -94,4 +94,8 @@ public interface VolumeApiService { * */ String extractVolume(ExtractVolumeCmd cmd); + + boolean isDisplayResourceEnabled(Long id); + + void updateDisplay(Volume volume, Boolean displayVolume); } diff --git a/api/src/com/cloud/template/VirtualMachineTemplate.java b/api/src/com/cloud/template/VirtualMachineTemplate.java index 9118bb22755..599212bb039 100755 --- a/api/src/com/cloud/template/VirtualMachineTemplate.java +++ b/api/src/com/cloud/template/VirtualMachineTemplate.java @@ -99,5 +99,5 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte Map getDetails(); - Boolean isDynamicallyScalable(); + boolean isDynamicallyScalable(); } diff --git a/api/src/com/cloud/user/Account.java b/api/src/com/cloud/user/Account.java index 99ef954feac..b912e515bf3 100755 --- a/api/src/com/cloud/user/Account.java +++ b/api/src/com/cloud/user/Account.java @@ -23,9 +23,7 @@ import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; public interface Account extends ControlledEntity, InternalIdentity, Identity { - public enum Type { - Normal, Admin, DomainAdmin, CustomerCare, Project - } + public enum State { disabled, enabled, locked diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java index a9be2922edf..49652700ff5 100755 --- a/api/src/com/cloud/user/AccountService.java +++ b/api/src/com/cloud/user/AccountService.java @@ -24,6 +24,7 @@ import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.command.admin.user.RegisterCmd; import com.cloud.domain.Domain; +import com.cloud.domain.PartOf; import com.cloud.exception.PermissionDeniedException; public interface AccountService { @@ -87,7 +88,11 @@ public interface AccountService { User getUserIncludingRemoved(long userId); - boolean isRootAdmin(short accountType); + boolean isRootAdmin(Long accountId); + + boolean isDomainAdmin(Long accountId); + + boolean isNormalUser(long accountId); User getActiveUserByRegistrationToken(String registrationToken); @@ -101,6 +106,18 @@ public interface AccountService { void checkAccess(Account account, Domain domain) throws PermissionDeniedException; + void checkAccess(Account account, AccessType accessType, ControlledEntity... entities) throws PermissionDeniedException; + + void checkAccess(Account account, AccessType accessType, String apiName, ControlledEntity... entities) throws PermissionDeniedException; + + // TODO: the following two interfaces will be deprecated by the above two counterparts when securityChecker implementation is in place void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException; + void checkAccess(Account account, AccessType accessType, boolean sameOwner, String apiName, + ControlledEntity... entities) throws PermissionDeniedException; + + //TO be implemented, to check accessibility for an entity owned by domain + void checkAccess(Account account, AccessType accessType, boolean sameOwner, PartOf... entities) throws PermissionDeniedException; + + Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly); } diff --git a/api/src/com/cloud/user/ResourceLimitService.java b/api/src/com/cloud/user/ResourceLimitService.java index de2773a955c..fef16da942f 100644 --- a/api/src/com/cloud/user/ResourceLimitService.java +++ b/api/src/com/cloud/user/ResourceLimitService.java @@ -88,7 +88,7 @@ public interface ResourceLimitService { * @param type * @return */ - public long findCorrectResourceLimitForAccount(short accountType, Long limit, ResourceType type); + public long findCorrectResourceLimitForAccount(long accountId, Long limit, ResourceType type); /** * Finds the resource limit for a specified domain and type. If the domain has an infinite limit, will check diff --git a/api/src/com/cloud/uservm/UserVm.java b/api/src/com/cloud/uservm/UserVm.java index b1d1712d9cf..16a203746a9 100755 --- a/api/src/com/cloud/uservm/UserVm.java +++ b/api/src/com/cloud/uservm/UserVm.java @@ -39,4 +39,5 @@ public interface UserVm extends VirtualMachine, ControlledEntity { void setAccountId(long accountId); + public boolean isDisplayVm(); } diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java index 51a8fdfbe38..af4e1d3699e 100755 --- a/api/src/com/cloud/vm/UserVmService.java +++ b/api/src/com/cloud/vm/UserVmService.java @@ -469,4 +469,10 @@ public interface UserVmService { */ String getVmUserData(long vmId); + /** + * determin whether the uservm should be visible to the end user + * @return value of the display flag + */ + public boolean isDisplayResourceEnabled(Long vmId); + } diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java index d6e70a8a6cf..e7cfd64c4e7 100755 --- a/api/src/com/cloud/vm/VirtualMachine.java +++ b/api/src/com/cloud/vm/VirtualMachine.java @@ -34,7 +34,10 @@ import com.cloud.utils.fsm.StateObject; public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, InternalIdentity, StateObject { public enum PowerState { - PowerUnknown, PowerOn, PowerOff, + PowerUnknown, + PowerOn, + PowerOff, + PowerReportMissing } public enum State { @@ -99,6 +102,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I s_fsm.addTransition(State.Running, VirtualMachine.Event.StopRequested, State.Stopping); s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportShutdowned, State.Stopped); s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportMigrated, State.Running); + s_fsm.addTransition(State.Running, VirtualMachine.Event.OperationSucceeded, State.Running); s_fsm.addTransition(State.Migrating, VirtualMachine.Event.MigrationRequested, State.Migrating); s_fsm.addTransition(State.Migrating, VirtualMachine.Event.OperationSucceeded, State.Running); s_fsm.addTransition(State.Migrating, VirtualMachine.Event.OperationFailed, State.Running); @@ -116,10 +120,12 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I s_fsm.addTransition(State.Error, VirtualMachine.Event.DestroyRequested, State.Expunging); s_fsm.addTransition(State.Error, VirtualMachine.Event.ExpungeOperation, State.Expunging); + s_fsm.addTransition(State.Starting, VirtualMachine.Event.FollowAgentPowerOnReport, State.Running); s_fsm.addTransition(State.Stopping, VirtualMachine.Event.FollowAgentPowerOnReport, State.Running); s_fsm.addTransition(State.Stopped, VirtualMachine.Event.FollowAgentPowerOnReport, State.Running); s_fsm.addTransition(State.Running, VirtualMachine.Event.FollowAgentPowerOnReport, State.Running); s_fsm.addTransition(State.Migrating, VirtualMachine.Event.FollowAgentPowerOnReport, State.Running); + s_fsm.addTransition(State.Starting, VirtualMachine.Event.FollowAgentPowerOffReport, State.Stopped); s_fsm.addTransition(State.Stopping, VirtualMachine.Event.FollowAgentPowerOffReport, State.Stopped); s_fsm.addTransition(State.Running, VirtualMachine.Event.FollowAgentPowerOffReport, State.Stopped); @@ -315,4 +321,6 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I long getUpdated(); + boolean isDisplay(); + } diff --git a/api/src/org/apache/cloudstack/acl/ControlledEntity.java b/api/src/org/apache/cloudstack/acl/ControlledEntity.java index 59575768011..b8a244f3bdd 100644 --- a/api/src/org/apache/cloudstack/acl/ControlledEntity.java +++ b/api/src/org/apache/cloudstack/acl/ControlledEntity.java @@ -29,4 +29,5 @@ public interface ControlledEntity extends OwnedBy, PartOf { Account, Domain } + Class getEntityType(); } diff --git a/api/src/org/apache/cloudstack/acl/Role.java b/api/src/org/apache/cloudstack/acl/PermissionScope.java similarity index 59% rename from api/src/org/apache/cloudstack/acl/Role.java rename to api/src/org/apache/cloudstack/acl/PermissionScope.java index 947a8c2e4d7..6647440d555 100644 --- a/api/src/org/apache/cloudstack/acl/Role.java +++ b/api/src/org/apache/cloudstack/acl/PermissionScope.java @@ -16,19 +16,26 @@ // under the License. package org.apache.cloudstack.acl; -//metadata - consists of default dynamic roles in CS + any custom roles added by user -public interface Role { +public enum PermissionScope { + RESOURCE(0), + ACCOUNT(1), + DOMAIN(2), + REGION(3), ALL(4); - public static final short ROOT_ADMIN = 0; - public static final short DOMAIN_ADMIN = 1; - public static final short DOMAIN_USER = 2; - public static final short OWNER = 3; - public static final short PARENT_DOMAIN_ADMIN = 4; - public static final short PARENT_DOMAIN_USER = 5; - public static final short CHILD_DOMAIN_ADMIN = 6; - public static final short CHILD_DOMAIN_USER = 7; + private int _scale; - public long getId(); + private PermissionScope(int scale) { + _scale = scale; + } - public short getRoleType(); + public int getScale() { + return _scale; + } + + public boolean greaterThan(PermissionScope s) { + if (_scale > s.getScale()) + return true; + else + return false; + } } diff --git a/api/src/org/apache/cloudstack/acl/QuerySelector.java b/api/src/org/apache/cloudstack/acl/QuerySelector.java new file mode 100644 index 00000000000..b89aa4e9ef5 --- /dev/null +++ b/api/src/org/apache/cloudstack/acl/QuerySelector.java @@ -0,0 +1,72 @@ +// 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 org.apache.cloudstack.acl; + +import java.util.List; + +import com.cloud.user.Account; +import com.cloud.utils.component.Adapter; + +/** + * QueryChecker returns granted access at domain, account or resource level. + */ +public interface QuerySelector extends Adapter { + + /** + * List granted domains for the caller, given a specific action. + * + * @param caller account to check against. + * @param action action + * @return list of domain Ids granted to the caller account. + */ + List getAuthorizedDomains(Account caller, String action); + + /** + * List granted accounts for the caller, given a specific action. + * + * @param caller account to check against. + * @param action action. + * @return list of domain Ids granted to the caller account. + */ + List getAuthorizedAccounts(Account caller, String action); + + + /** + * List granted resources for the caller, given a specific action. + * + * @param caller account to check against. + * @param action action. + * @return list of domain Ids granted to the caller account. + */ + List getAuthorizedResources(Account caller, String action); + + /** + * Check if this account is associated with a policy with scope of ALL + * @param caller account to check + * @param action action. + * @return true if this account is attached with a policy for the given action of ALL scope. + */ + boolean isGrantedAll(Account caller, String action); + + /** + * List of ACL group the given account belongs to + * @param accountId account id. + * @return ACL group names + */ + List listAclGroupsByAccount(long accountId); + +} diff --git a/api/src/org/apache/cloudstack/acl/RoleType.java b/api/src/org/apache/cloudstack/acl/RoleType.java index 8505256fa57..90e3d1ef604 100644 --- a/api/src/org/apache/cloudstack/acl/RoleType.java +++ b/api/src/org/apache/cloudstack/acl/RoleType.java @@ -18,7 +18,6 @@ package org.apache.cloudstack.acl; // Enum for default roles in CloudStack public enum RoleType { - Admin(1), ResourceAdmin(2), DomainAdmin(4), User(8), Unknown(0); private int mask; @@ -31,3 +30,4 @@ public enum RoleType { return mask; } } + diff --git a/api/src/org/apache/cloudstack/acl/SecurityChecker.java b/api/src/org/apache/cloudstack/acl/SecurityChecker.java index ab3f7c5f320..41708717548 100644 --- a/api/src/org/apache/cloudstack/acl/SecurityChecker.java +++ b/api/src/org/apache/cloudstack/acl/SecurityChecker.java @@ -31,7 +31,10 @@ import com.cloud.utils.component.Adapter; public interface SecurityChecker extends Adapter { public enum AccessType { - ListEntry, ModifyEntry, ModifyProject, UseNetwork + ModifyProject, + OperateEntry, + UseEntry, + ListEntry } /** @@ -69,11 +72,54 @@ public interface SecurityChecker extends Adapter { * object that the account is trying to access. * @param accessType * TODO - * @return true if access allowed. false if this adapter cannot provide permission. + * @return true if access allowed. false if this adapter cannot provide + * permission. * @throws PermissionDeniedException - * if this adapter is suppose to authenticate ownership and the check failed. + * if this adapter is suppose to authenticate ownership and the + * check failed. */ - boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType) throws PermissionDeniedException; + boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType) + throws PermissionDeniedException; + + /** + * Checks if the account can access the object. + * + * @param caller + * account to check against. + * @param entity + * object that the account is trying to access. + * @param accessType + * TODO + * @param action + * name of the API + * @return true if access allowed. false if this adapter cannot provide + * permission. + * @throws PermissionDeniedException + * if this adapter is suppose to authenticate ownership and the + * check failed. + */ + boolean checkAccess(Account caller, ControlledEntity entity, AccessType accessType, String action) throws PermissionDeniedException; + + /** + * Checks if the account can access multiple objects. + * + * @param caller + * account to check against. + * @param entities + * objects that the account is trying to access. + * @param accessType + * TODO + * @param action + * name of the API + * @return true if access allowed. false if this adapter cannot provide + * permission. + * @throws PermissionDeniedException + * if this adapter is suppose to authenticate ownership and the + * check failed. + */ + boolean checkAccess(Account caller, AccessType accessType, String action, ControlledEntity... entities) + throws PermissionDeniedException; + /** * Checks if the user belongs to an account that can access the object. diff --git a/api/src/org/apache/cloudstack/api/ACL.java b/api/src/org/apache/cloudstack/api/ACL.java index 4955120887e..2b0d4c33609 100644 --- a/api/src/org/apache/cloudstack/api/ACL.java +++ b/api/src/org/apache/cloudstack/api/ACL.java @@ -28,7 +28,9 @@ import org.apache.cloudstack.acl.SecurityChecker.AccessType; @Target({FIELD}) public @interface ACL { - AccessType accessType() default AccessType.ListEntry; + AccessType accessType() default AccessType.UseEntry; + + String pointerToEntity() default ""; boolean checkKeyAccess() default false; diff --git a/api/src/org/apache/cloudstack/api/APICommand.java b/api/src/org/apache/cloudstack/api/APICommand.java index 5587a48b765..d451e4b10a3 100644 --- a/api/src/org/apache/cloudstack/api/APICommand.java +++ b/api/src/org/apache/cloudstack/api/APICommand.java @@ -23,6 +23,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.ResponseObject.ResponseView; @Retention(RetentionPolicy.RUNTIME) @Target({TYPE}) @@ -39,5 +40,13 @@ public @interface APICommand { String since() default ""; + ResponseView responseView() default ResponseView.Full; + + boolean requestHasSensitiveInfo() default true; + + boolean responseHasSensitiveInfo() default true; + RoleType[] authorized() default {}; + + Class[] entityType() default {}; } diff --git a/api/src/org/apache/cloudstack/api/ApiCommandJobType.java b/api/src/org/apache/cloudstack/api/ApiCommandJobType.java index 3067af8a528..227fb30114f 100644 --- a/api/src/org/apache/cloudstack/api/ApiCommandJobType.java +++ b/api/src/org/apache/cloudstack/api/ApiCommandJobType.java @@ -49,5 +49,9 @@ public enum ApiCommandJobType { LoadBalancerRule, AffinityGroup, InternalLbVm, - DedicatedGuestVlanRange -} \ No newline at end of file + DedicatedGuestVlanRange, + IAMPolicy, + IAMGroup, + GuestOs, + GuestOsMapping +} diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java index d500303bcac..c7d6da1d3c8 100755 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/org/apache/cloudstack/api/ApiConstants.java @@ -23,8 +23,10 @@ public class ApiConstants { public static final String ACCOUNT_ID = "accountid"; public static final String ALGORITHM = "algorithm"; public static final String ALLOCATED_ONLY = "allocatedonly"; - public static final String API_KEY = "userapikey"; + public static final String API_KEY = "apikey"; + public static final String USER_API_KEY = "userapikey"; public static final String APPLIED = "applied"; + public static final String LIST_LB_VMIPS = "lbvmips"; public static final String AVAILABLE = "available"; public static final String BITS = "bits"; public static final String BOOTABLE = "bootable"; @@ -41,6 +43,7 @@ public class ApiConstants { public static final String PRIVATE_KEY = "privatekey"; public static final String DOMAIN_SUFFIX = "domainsuffix"; public static final String DNS_SEARCH_ORDER = "dnssearchorder"; + public static final String CHAIN_INFO = "chaininfo"; public static final String CIDR = "cidr"; public static final String IP6_CIDR = "ip6cidr"; public static final String CIDR_LIST = "cidrlist"; @@ -48,10 +51,16 @@ public class ApiConstants { public static final String CLUSTER_ID = "clusterid"; public static final String CLUSTER_NAME = "clustername"; public static final String CLUSTER_TYPE = "clustertype"; + public static final String COMMAND = "command"; + public static final String CMD_EVENT_TYPE = "cmdeventtype"; public static final String COMPONENT = "component"; public static final String CPU_NUMBER = "cpunumber"; public static final String CPU_SPEED = "cpuspeed"; public static final String CREATED = "created"; + public static final String CTX_ACCOUNT_ID = "ctxaccountid"; + public static final String CTX_USER_ID = "ctxuserid"; + public static final String CTXSTARTEVENTID = "ctxstarteventid"; + public static final String CTX_START_EVENT_ID = "ctxStartEventId"; public static final String CUSTOMIZED = "customized"; public static final String CUSTOMIZED_IOPS = "customizediops"; public static final String CUSTOM_ID = "customid"; @@ -78,6 +87,7 @@ public class ApiConstants { public static final String IP6_DNS2 = "ip6dns2"; public static final String DOMAIN = "domain"; public static final String DOMAIN_ID = "domainid"; + public static final String DOMAIN__ID = "domainId"; public static final String DURATION = "duration"; public static final String EMAIL = "email"; public static final String END_DATE = "enddate"; @@ -85,6 +95,7 @@ public class ApiConstants { public static final String END_IPV6 = "endipv6"; public static final String END_PORT = "endport"; public static final String ENTRY_TIME = "entrytime"; + public static final String EXPIRES = "expires"; public static final String FETCH_LATEST = "fetchlatest"; public static final String FIRSTNAME = "firstname"; public static final String FORCED = "forced"; @@ -161,6 +172,8 @@ public class ApiConstants { public static final String OP = "op"; public static final String OS_CATEGORY_ID = "oscategoryid"; public static final String OS_TYPE_ID = "ostypeid"; + public static final String OS_DISPLAY_NAME = "osdisplayname"; + public static final String OS_NAME_FOR_HYPERVISOR = "osnameforhypervisor"; public static final String PARAMS = "params"; public static final String PARENT_DOMAIN_ID = "parentdomainid"; public static final String PASSWORD = "password"; @@ -208,8 +221,11 @@ public class ApiConstants { public static final String SENT = "sent"; public static final String SENT_BYTES = "sentbytes"; public static final String SERVICE_OFFERING_ID = "serviceofferingid"; + public static final String SESSIONKEY = "sessionkey"; public static final String SHOW_CAPACITIES = "showcapacities"; public static final String SHOW_REMOVED = "showremoved"; + public static final String SIGNATURE = "signature"; + public static final String SIGNATURE_VERSION = "signatureversion"; public static final String SIZE = "size"; public static final String SNAPSHOT_ID = "snapshotid"; public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid"; @@ -247,6 +263,8 @@ public class ApiConstants { public static final String VALUE = "value"; public static final String VIRTUAL_MACHINE_ID = "virtualmachineid"; public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids"; + public static final String VIRTUAL_MACHINE_ID_IP = "vmidipmap"; + public static final String VLAN = "vlan"; public static final String VLAN_RANGE = "vlanrange"; public static final String REMOVE_VLAN = "removevlan"; @@ -276,6 +294,7 @@ public class ApiConstants { public static final String NETWORKRATE = "networkrate"; public static final String HOST_TAGS = "hosttags"; public static final String SSH_KEYPAIR = "keypair"; + public static final String HTTPMETHOD = "httpmethod"; public static final String HOST_CPU_CAPACITY = "hostcpucapacity"; public static final String HOST_CPU_NUM = "hostcpunum"; public static final String HOST_MEM_CAPACITY = "hostmemcapacity"; @@ -401,6 +420,7 @@ public class ApiConstants { public static final String INSTANCE_NAME = "instancename"; public static final String START_VM = "startvm"; public static final String HA_HOST = "hahost"; + public static final String CUSTOM_DISK_OFF_MIN_SIZE = "customdiskofferingminsize"; public static final String CUSTOM_DISK_OFF_MAX_SIZE = "customdiskofferingmaxsize"; public static final String DEFAULT_ZONE_ID = "defaultzoneid"; public static final String LIVE_MIGRATE = "livemigrate"; @@ -543,12 +563,42 @@ public class ApiConstants { public static final String ROUTING = "isrouting"; public static final String MAX_CONNECTIONS = "maxconnections"; public static final String SERVICE_STATE = "servicestate"; + + public static final String IAM_ACCOUNT_IDS = "accountids"; + public static final String IAM_MEMBER_ACCOUNTS = "memberaccounts"; + public static final String IAM_PARENT_POLICY_ID = "parentpolicyid"; + public static final String IAM_PARENT_POLICY_NAME = "parentpolicyname"; + public static final String IAM_POLICY_IDS = "policyids"; + public static final String IAM_POLICIES = "policies"; + public static final String IAM_APIS = "apis"; + public static final String IAM_GROUPS = "groups"; + public static final String IAM_PERMISSIONS = "permission"; + public static final String IAM_ACTION = "action"; + public static final String IAM_SCOPE = "scope"; + public static final String IAM_SCOPE_ID = "scopeid"; + public static final String IAM_ALLOW_DENY = "permission"; + public static final String ENTITY_TYPE = "entitytype"; + public static final String ENTITY_ID = "entityid"; + public static final String ACCESS_TYPE = "accesstype"; + public static final String RESOURCE_DETAILS = "resourcedetails"; public static final String EXPUNGE = "expunge"; public static final String FOR_DISPLAY = "fordisplay"; public static final String PASSIVE = "passive"; public static final String VERSION = "version"; public static final String START = "start"; + public static final String GPUGROUP = "gpugroup"; + public static final String GPUGROUPNAME = "gpugroupname"; + public static final String VGPU = "vgpu"; + public static final String VGPUTYPE = "vgputype"; + public static final String REMAININGCAPACITY = "remainingcapacity"; + public static final String DISTRIBUTED_VPC_ROUTER = "distributedvpcrouter"; + public static final String READ_ONLY = "readonly"; + public static final String SUPPORTS_REGION_LEVEL_VPC = "supportsregionLevelvpc"; + public static final String SUPPORTS_STRECHED_L2_SUBNET = "supportsstrechedl2subnet"; + public static final String REGION_LEVEL_VPC = "regionlevelvpc"; + public static final String STRECHED_L2_SUBNET = "strechedl2subnet"; + public static final String NETWORK_SPANNED_ZONES = "zonesnetworkspans"; public enum HostDetails { all, capacity, events, stats, min; diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java index ae0f5d703bc..0b1396fbf83 100644 --- a/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseAsyncCmd.java @@ -16,9 +16,6 @@ // under the License. package org.apache.cloudstack.api; -import org.apache.cloudstack.context.CallContext; - -import com.cloud.user.User; /** * queryAsyncJobResult API command. @@ -92,35 +89,4 @@ public abstract class BaseAsyncCmd extends BaseCmd { public Object getJob() { return job; } - - protected long saveStartedEvent() { - return saveStartedEvent(getEventType(), "Executing job for " + getEventDescription(), getStartEventId()); - } - - protected long saveStartedEvent(String eventType, String description, Long startEventId) { - CallContext ctx = CallContext.current(); - Long userId = ctx.getCallingUserId(); - userId = (userId == null) ? User.UID_SYSTEM : userId; - Long startEvent = startEventId; - if (startEvent == null) { - startEvent = 0L; - } - return _mgr.saveStartedEvent((userId == null) ? User.UID_SYSTEM : userId, getEntityOwnerId(), eventType, description, startEvent); - } - - protected long saveCompletedEvent(String level, String description) { - return saveCompletedEvent(level, getEventType(), description, getStartEventId()); - } - - protected long saveCompletedEvent(String level, String eventType, String description, Long startEventId) { - CallContext ctx = CallContext.current(); - Long userId = ctx.getCallingUserId(); - userId = (userId == null) ? User.UID_SYSTEM : userId; - Long startEvent = startEventId; - if (startEvent == null) { - startEvent = 0L; - } - return _mgr.saveCompletedEvent((userId == null) ? User.UID_SYSTEM : userId, getEntityOwnerId(), level, eventType, description, startEvent); - } - } diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncCustomIdCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncCustomIdCmd.java index 18264da1aa2..b251c6ef2ec 100644 --- a/api/src/org/apache/cloudstack/api/BaseAsyncCustomIdCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseAsyncCustomIdCmd.java @@ -16,13 +16,18 @@ // under the License. package org.apache.cloudstack.api; +import org.apache.cloudstack.acl.RoleType; + public abstract class BaseAsyncCustomIdCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.CUSTOM_ID, type = CommandType.STRING, - description = "an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only") + description = "an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only", since = "4.4", authorized = {RoleType.Admin}) private String customId; public String getCustomId() { return customId; } + + public abstract void checkUuid(); + } diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncVMCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncVMCmd.java new file mode 100644 index 00000000000..abfc9530274 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/BaseAsyncVMCmd.java @@ -0,0 +1,30 @@ +// 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 org.apache.cloudstack.api; + +/** + * A generic class for implementing methods common to all async vm commands + */ +public abstract class BaseAsyncVMCmd extends BaseAsyncCmd { + + @Override + public boolean isDisplayResourceEnabled(){ + return _userVmService.isDisplayResourceEnabled(getId()); + } + + public abstract Long getId(); +} diff --git a/api/src/org/apache/cloudstack/api/BaseAsyncVolumeCmd.java b/api/src/org/apache/cloudstack/api/BaseAsyncVolumeCmd.java new file mode 100644 index 00000000000..1782e4a1348 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/BaseAsyncVolumeCmd.java @@ -0,0 +1,30 @@ +// 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 org.apache.cloudstack.api; + +/** + * A generic class for implementing methods common to all async volume commands + */ +public abstract class BaseAsyncVolumeCmd extends BaseAsyncCmd { + + @Override + public boolean isDisplayResourceEnabled(){ + return _volumeService.isDisplayResourceEnabled(getId()); + } + + public abstract Long getId(); +} diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java index 4229ec9302b..f6f21ae7162 100644 --- a/api/src/org/apache/cloudstack/api/BaseCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseCmd.java @@ -17,10 +17,13 @@ package org.apache.cloudstack.api; +import java.lang.reflect.Field; import java.text.DateFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.regex.Pattern; @@ -28,8 +31,10 @@ import javax.inject.Inject; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.affinity.AffinityGroupService; import org.apache.cloudstack.alert.AlertService; +import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.network.element.InternalLoadBalancerElementService; import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService; import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService; @@ -37,12 +42,9 @@ import org.apache.cloudstack.query.QueryService; import org.apache.cloudstack.usage.UsageService; import com.cloud.configuration.ConfigurationService; -import com.cloud.domain.Domain; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.NetworkRuleConflictException; -import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.NetworkModel; @@ -60,7 +62,6 @@ import com.cloud.network.vpc.VpcProvisioningService; import com.cloud.network.vpc.VpcService; import com.cloud.network.vpn.RemoteAccessVpnService; import com.cloud.network.vpn.Site2SiteVpnService; -import com.cloud.projects.Project; import com.cloud.projects.ProjectService; import com.cloud.resource.ResourceService; import com.cloud.server.ManagementService; @@ -75,40 +76,36 @@ import com.cloud.user.Account; import com.cloud.user.AccountService; import com.cloud.user.DomainService; import com.cloud.user.ResourceLimitService; +import com.cloud.utils.ReflectUtil; import com.cloud.utils.db.EntityManager; +import com.cloud.utils.db.UUIDManager; import com.cloud.vm.UserVmService; import com.cloud.vm.snapshot.VMSnapshotService; public abstract class BaseCmd { private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName()); - - public static final String USER_ERROR_MESSAGE = "Internal error executing command, please contact your system administrator"; - public static final int PROGRESS_INSTANCE_CREATED = 1; - public static final String RESPONSE_TYPE_XML = "xml"; public static final String RESPONSE_TYPE_JSON = "json"; - - public enum CommandType { + public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + public static final DateFormat NEW_INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + public static final String USER_ERROR_MESSAGE = "Internal error executing command, please contact your system administrator"; + public static Pattern newInputDateFormat = Pattern.compile("[\\d]+-[\\d]+-[\\d]+ [\\d]+:[\\d]+:[\\d]+"); + private static final DateFormat s_outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); + protected static final Map, List> fieldsForCmdClass = new HashMap, List>(); + public static enum HTTPMethod { + GET, POST, PUT, DELETE + } + public static enum CommandType { BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE, UUID } - public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - public static final DateFormat NEW_INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - public static Pattern newInputDateFormat = Pattern.compile("[\\d]+-[\\d]+-[\\d]+ [\\d]+:[\\d]+:[\\d]+"); - private static final DateFormat s_outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); - - private Object _responseObject = null; + private Object _responseObject; private Map fullUrlParams; - - public enum HTTPMethod { - GET, POST, PUT, DELETE - } - private HTTPMethod httpMethod; - @Parameter(name = "response", type = CommandType.STRING) private String responseType; + @Inject public ConfigurationService _configService; @Inject @@ -165,7 +162,6 @@ public abstract class BaseCmd { public NetworkACLService _networkACLService; @Inject public Site2SiteVpnService _s2sVpnService; - @Inject public QueryService _queryService; @Inject @@ -192,6 +188,8 @@ public abstract class BaseCmd { public NetworkModel _ntwkModel; @Inject public AlertService _alertSvc; + @Inject + public UUIDManager _uuidMgr; public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException; @@ -203,7 +201,7 @@ public abstract class BaseCmd { return httpMethod; } - public void setHttpMethod(String method) { + public void setHttpMethod(final String method) { if (method != null) { if (method.equalsIgnoreCase("GET")) httpMethod = HTTPMethod.GET; @@ -225,12 +223,36 @@ public abstract class BaseCmd { return responseType; } - public void setResponseType(String responseType) { + public void setResponseType(final String responseType) { this.responseType = responseType; } + /** + * For some reason this method does not return the actual command name, but more a name that + * is used to create the response. So you can expect for a XCmd a value like xcmdresponse. Anyways + * this methods is used in too many places so for now instead of changing it we just create another + * method {@link BaseCmd#getActualCommandName()} that returns the value from {@link APICommand#name()} + * + * @return + */ public abstract String getCommandName(); + + /** + * Gets the CommandName based on the class annotations: the value from {@link APICommand#name()} + * + * @return the value from {@link APICommand#name()} + */ + public String getActualCommandName() { + String cmdName = null; + if (this.getClass().getAnnotation(APICommand.class) != null) { + cmdName = this.getClass().getAnnotation(APICommand.class).name(); + } else { + cmdName = this.getClass().getName(); + } + return cmdName; + } + /** * For commands the API framework needs to know the owner of the object being acted upon. This method is * used to determine that information. @@ -243,15 +265,11 @@ public abstract class BaseCmd { return _responseObject; } - public void setResponseObject(Object responseObject) { + public void setResponseObject(final Object responseObject) { _responseObject = responseObject; } - public ManagementService getMgmtServiceRef() { - return _mgr; - } - - public static String getDateString(Date date) { + public static String getDateString(final Date date) { if (date == null) { return ""; } @@ -262,101 +280,68 @@ public abstract class BaseCmd { return formattedString; } - // FIXME: move this to a utils method so that maps can be unpacked and integer/long values can be appropriately cast - @SuppressWarnings({"unchecked", "rawtypes"}) - public Map unpackParams(Map params) { - Map lowercaseParams = new HashMap(); - for (String key : params.keySet()) { - int arrayStartIndex = key.indexOf('['); - int arrayStartLastIndex = key.lastIndexOf('['); - if (arrayStartIndex != arrayStartLastIndex) { - throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key + - "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); + protected List getAllFieldsForClass(final Class clazz) { + List filteredFields = fieldsForCmdClass.get(clazz); + + // If list of fields was not cached yet + if (filteredFields == null) { + final List allFields = ReflectUtil.getAllFieldsForClass(this.getClass(), BaseCmd.class); + filteredFields = new ArrayList(); + + for (final Field field : allFields) { + final Parameter parameterAnnotation = field.getAnnotation(Parameter.class); + if ((parameterAnnotation != null) && parameterAnnotation.expose()) { + filteredFields.add(field); + } + } + + // Cache the prepared list for future use + fieldsForCmdClass.put(clazz, filteredFields); + } + return filteredFields; + } + + /** + * This method doesn't return all the @{link Parameter}, but only the ones exposed + * and allowed for current @{link RoleType}. This method will get the fields for a given + * Cmd class only once and never again, so in case of a dynamic update the result would + * be obsolete (this might be a plugin update. It is agreed upon that we will not do + * upgrades dynamically but in case we come back on that decision we need to revisit this) + * + * @return + */ + public List getParamFields() { + final List allFields = getAllFieldsForClass(this.getClass()); + final List validFields = new ArrayList(); + final Account caller = CallContext.current().getCallingAccount(); + + for (final Field field : allFields) { + final Parameter parameterAnnotation = field.getAnnotation(Parameter.class); + + //TODO: Annotate @Validate on API Cmd classes, FIXME how to process Validate + final RoleType[] allowedRoles = parameterAnnotation.authorized(); + boolean roleIsAllowed = true; + if (allowedRoles.length > 0) { + roleIsAllowed = false; + for (final RoleType allowedRole : allowedRoles) { + if (allowedRole.getValue() == caller.getType()) { + roleIsAllowed = true; + break; + } + } } - if (arrayStartIndex > 0) { - int arrayEndIndex = key.indexOf(']'); - int arrayEndLastIndex = key.lastIndexOf(']'); - if ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) { - // malformed parameter - throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key + - "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); - } - - // Now that we have an array object, check for a field name in the case of a complex object - int fieldIndex = key.indexOf('.'); - String fieldName = null; - if (fieldIndex < arrayEndIndex) { - throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key + - "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); - } else { - fieldName = key.substring(fieldIndex + 1); - } - - // parse the parameter name as the text before the first '[' character - String paramName = key.substring(0, arrayStartIndex); - paramName = paramName.toLowerCase(); - - Map mapArray = null; - Map mapValue = null; - String indexStr = key.substring(arrayStartIndex + 1, arrayEndIndex); - int index = 0; - boolean parsedIndex = false; - try { - if (indexStr != null) { - index = Integer.parseInt(indexStr); - parsedIndex = true; - } - } catch (NumberFormatException nfe) { - s_logger.warn("Invalid parameter " + key + " received, unable to parse object array, returning an error."); - } - - if (!parsedIndex) { - throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key + - "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup"); - } - - Object value = lowercaseParams.get(paramName); - if (value == null) { - // for now, assume object array with sub fields - mapArray = new HashMap(); - mapValue = new HashMap(); - mapArray.put(Integer.valueOf(index), mapValue); - } else if (value instanceof Map) { - mapArray = (HashMap)value; - mapValue = mapArray.get(Integer.valueOf(index)); - if (mapValue == null) { - mapValue = new HashMap(); - mapArray.put(Integer.valueOf(index), mapValue); - } - } - - // we are ready to store the value for a particular field into the map for this object - mapValue.put(fieldName, params.get(key)); - - lowercaseParams.put(paramName, mapArray); + if (roleIsAllowed) { + validFields.add(field); } else { - lowercaseParams.put(key.toLowerCase(), params.get(key)); + s_logger.debug("Ignoring paremeter " + parameterAnnotation.name() + " as the caller is not authorized to pass it in"); } } - return lowercaseParams; + + return validFields; } - protected long getInstanceIdFromJobSuccessResult(String result) { - s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName()); - return 0; - } - - public static boolean isAdmin(short accountType) { - return ((accountType == Account.ACCOUNT_TYPE_ADMIN) || (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) || - (accountType == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) || (accountType == Account.ACCOUNT_TYPE_READ_ONLY_ADMIN)); - } - - public static boolean isRootAdmin(short accountType) { - return ((accountType == Account.ACCOUNT_TYPE_ADMIN)); - } - - public void setFullUrlParams(Map map) { + public void setFullUrlParams(final Map map) { fullUrlParams = map; } @@ -364,49 +349,18 @@ public abstract class BaseCmd { return fullUrlParams; } - public Long finalyzeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly) { - if (accountName != null) { - if (domainId == null) { - throw new InvalidParameterValueException("Account must be specified with domainId parameter"); - } + /** + * To be overwritten by any class who needs specific validation + */ + public void validateSpecificParameters(final Map params){ + // To be overwritten by any class who needs specific validation + } - Domain domain = _domainService.getDomain(domainId); - if (domain == null) { - throw new InvalidParameterValueException("Unable to find domain by id"); - } - - Account account = _accountService.getActiveAccountByName(accountName, domainId); - if (account != null && account.getType() != Account.ACCOUNT_TYPE_PROJECT) { - if (!enabledOnly || account.getState() == Account.State.enabled) { - return account.getId(); - } else { - throw new PermissionDeniedException("Can't add resources to the account id=" + account.getId() + " in state=" + account.getState() + - " as it's no longer active"); - } - } else { - // idList is not used anywhere, so removed it now - //List idList = new ArrayList(); - //idList.add(new IdentityProxy("domain", domainId, "domainId")); - throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain with specified id"); - } - } - - if (projectId != null) { - Project project = _projectService.getProject(projectId); - if (project != null) { - if (!enabledOnly || project.getState() == Project.State.Active) { - return project.getProjectAccountId(); - } else { - PermissionDeniedException ex = - new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() + - " as it's no longer active"); - ex.addProxyObject(project.getUuid(), "projectId"); - throw ex; - } - } else { - throw new InvalidParameterValueException("Unable to find project by id"); - } - } - return null; + /** + * display flag is used to control the display of the resource only to the end user. It doesnt affect Root Admin. + * @return display flag + */ + public boolean isDisplayResourceEnabled(){ + return true; } } diff --git a/api/src/org/apache/cloudstack/api/BaseCustomIdCmd.java b/api/src/org/apache/cloudstack/api/BaseCustomIdCmd.java index 8ae746f319e..7ca9f1efe7e 100644 --- a/api/src/org/apache/cloudstack/api/BaseCustomIdCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseCustomIdCmd.java @@ -16,14 +16,19 @@ // under the License. package org.apache.cloudstack.api; +import org.apache.cloudstack.acl.RoleType; + public abstract class BaseCustomIdCmd extends BaseCmd { @Parameter(name = ApiConstants.CUSTOM_ID, type = CommandType.STRING, - description = "an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only") + description = "an optional field, in case you want to set a custom id to the resource. Allowed to Root Admins only", since = "4.4", authorized = {RoleType.Admin}) private String customId; public String getCustomId() { return customId; } + + public abstract void checkUuid(); + } diff --git a/api/src/org/apache/cloudstack/api/BaseListAccountResourcesCmd.java b/api/src/org/apache/cloudstack/api/BaseListAccountResourcesCmd.java index 0586117f0c6..63d2b7f7615 100644 --- a/api/src/org/apache/cloudstack/api/BaseListAccountResourcesCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseListAccountResourcesCmd.java @@ -16,6 +16,10 @@ // under the License. package org.apache.cloudstack.api; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.user.Account; + public abstract class BaseListAccountResourcesCmd extends BaseListDomainResourcesCmd { @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "list resources by account. Must be used with the domainId parameter.") @@ -24,4 +28,12 @@ public abstract class BaseListAccountResourcesCmd extends BaseListDomainResource public String getAccountName() { return accountName; } + + public Boolean getDisplay() { + Account caller = CallContext.current().getCallingAccount(); + if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) { + return true; + } + return null; + } } diff --git a/api/src/org/apache/cloudstack/api/BaseListCmd.java b/api/src/org/apache/cloudstack/api/BaseListCmd.java index c1a4b4c440f..407ad22b606 100644 --- a/api/src/org/apache/cloudstack/api/BaseListCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseListCmd.java @@ -16,12 +16,15 @@ // under the License. package org.apache.cloudstack.api; +import java.util.Map; + import com.cloud.exception.InvalidParameterValueException; +import com.cloud.utils.exception.CSExceptionErrorCode; public abstract class BaseListCmd extends BaseCmd { private static Long s_maxPageSize = null; - public static Long s_pageSizeUnlimited = -1L; + public static final Long s_pageSizeUnlimited = -1L; // /////////////////////////////////////////////////// // ///////// BaseList API parameters ///////////////// @@ -83,7 +86,7 @@ public abstract class BaseListCmd extends BaseCmd { public Long getPageSizeVal() { Long defaultPageSize = s_maxPageSize; - Integer pageSizeInt = getPageSize(); + final Integer pageSizeInt = getPageSize(); if (pageSizeInt != null) { defaultPageSize = pageSizeInt.longValue(); } @@ -96,12 +99,12 @@ public abstract class BaseListCmd extends BaseCmd { public Long getStartIndex() { Long startIndex = Long.valueOf(0); - Long pageSizeVal = getPageSizeVal(); + final Long pageSizeVal = getPageSizeVal(); if (pageSizeVal == null) { startIndex = null; } else if (page != null) { - int pageNum = page.intValue(); + final int pageNum = page.intValue(); if (pageNum > 0) { startIndex = Long.valueOf(pageSizeVal * (pageNum - 1)); } @@ -112,4 +115,25 @@ public abstract class BaseListCmd extends BaseCmd { public ApiCommandJobType getInstanceType() { return ApiCommandJobType.None; } + + @Override + public void validateSpecificParameters(final Map params){ + super.validateSpecificParameters(params); + + final Object pageSizeObj = params.get(ApiConstants.PAGE_SIZE); + Long pageSize = null; + if (pageSizeObj != null) { + pageSize = Long.valueOf((String)pageSizeObj); + } + + if (params.get(ApiConstants.PAGE) == null && + pageSize != null && + !pageSize.equals(BaseListCmd.s_pageSizeUnlimited)) { + final ServerApiException ex = new ServerApiException(ApiErrorCode.PARAM_ERROR, "\"page\" parameter is required when \"pagesize\" is specified"); + ex.setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ex.getClass().getName())); + throw ex; + } else if (pageSize == null && (params.get(ApiConstants.PAGE) != null)) { + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "\"pagesize\" parameter is required when \"page\" is specified"); + } + } } diff --git a/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java index 48c1e02cfd5..d149dffe291 100644 --- a/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java +++ b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java @@ -20,16 +20,17 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.TemplatePermissionsResponse; -import org.apache.cloudstack.context.CallContext; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd { +public abstract class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd { public Logger logger = getLogger(); protected static final String s_name = "listtemplatepermissionsresponse"; + ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// @@ -59,7 +60,7 @@ public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd { } protected Logger getLogger() { - return Logger.getLogger(BaseUpdateTemplateOrIsoPermissionsCmd.class); + return Logger.getLogger(BaseListTemplateOrIsoPermissionsCmd.class); } @Override @@ -75,15 +76,14 @@ public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd { return "templateOrIso"; } - @Override - public void execute() { + + protected void executeWithView(ResponseView view) { List accountNames = _templateService.listTemplatePermissions(this); - Account account = CallContext.current().getCallingAccount(); - boolean isAdmin = (isAdmin(account.getType())); - - TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(accountNames, id, isAdmin); + TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(view, accountNames, id); response.setResponseName(getCommandName()); setResponseObject(response); } + + } diff --git a/api/src/org/apache/cloudstack/api/Parameter.java b/api/src/org/apache/cloudstack/api/Parameter.java index f1c6e1a4555..7ee6897af29 100644 --- a/api/src/org/apache/cloudstack/api/Parameter.java +++ b/api/src/org/apache/cloudstack/api/Parameter.java @@ -48,7 +48,5 @@ public @interface Parameter { String since() default ""; - String retrieveMethod() default "getById"; - RoleType[] authorized() default {}; } diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java index 1cb53886a7c..10fb6df3a18 100644 --- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java +++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java @@ -25,6 +25,7 @@ import org.apache.cloudstack.affinity.AffinityGroup; import org.apache.cloudstack.affinity.AffinityGroupResponse; import org.apache.cloudstack.api.ApiConstants.HostDetails; import org.apache.cloudstack.api.ApiConstants.VMDetails; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse; @@ -47,6 +48,7 @@ import org.apache.cloudstack.api.response.FirewallResponse; import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse; import org.apache.cloudstack.api.response.GuestOSResponse; +import org.apache.cloudstack.api.response.GuestOsMappingResponse; import org.apache.cloudstack.api.response.GuestVlanRangeResponse; import org.apache.cloudstack.api.response.HostForMigrationResponse; import org.apache.cloudstack.api.response.HostResponse; @@ -175,6 +177,7 @@ import com.cloud.projects.ProjectInvitation; import com.cloud.region.ha.GlobalLoadBalancerRule; import com.cloud.server.ResourceTag; import com.cloud.storage.GuestOS; +import com.cloud.storage.GuestOSHypervisor; import com.cloud.storage.ImageStore; import com.cloud.storage.Snapshot; import com.cloud.storage.StoragePool; @@ -196,7 +199,7 @@ import com.cloud.vm.snapshot.VMSnapshot; public interface ResponseGenerator { UserResponse createUserResponse(UserAccount user); - AccountResponse createAccountResponse(Account account); + AccountResponse createAccountResponse(ResponseView view, Account account); DomainResponse createDomainResponse(Domain domain); @@ -214,9 +217,9 @@ public interface ResponseGenerator { SnapshotPolicyResponse createSnapshotPolicyResponse(SnapshotPolicy policy); - List createUserVmResponse(String objectName, UserVm... userVms); + List createUserVmResponse(ResponseView view, String objectName, UserVm... userVms); - List createUserVmResponse(String objectName, EnumSet details, UserVm... userVms); + List createUserVmResponse(ResponseView view, String objectName, EnumSet details, UserVm... userVms); SystemVmResponse createSystemVmResponse(VirtualMachine systemVM); @@ -232,7 +235,7 @@ public interface ResponseGenerator { VlanIpRangeResponse createVlanIpRangeResponse(Vlan vlan); - IPAddressResponse createIPAddressResponse(IpAddress ipAddress); + IPAddressResponse createIPAddressResponse(ResponseView view, IpAddress ipAddress); GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan result); @@ -250,9 +253,9 @@ public interface ResponseGenerator { PodResponse createPodResponse(Pod pod, Boolean showCapacities); - ZoneResponse createZoneResponse(DataCenter dataCenter, Boolean showCapacities); + ZoneResponse createZoneResponse(ResponseView view, DataCenter dataCenter, Boolean showCapacities); - VolumeResponse createVolumeResponse(Volume volume); + VolumeResponse createVolumeResponse(ResponseView view, Volume volume); InstanceGroupResponse createInstanceGroupResponse(InstanceGroup group); @@ -278,17 +281,13 @@ public interface ResponseGenerator { Host findHostById(Long hostId); - //List createTemplateResponses(long templateId, long zoneId, boolean readyOnly); - VpnUsersResponse createVpnUserResponse(VpnUser user); RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn); - List createTemplateResponses(long templateId, Long zoneId, boolean readyOnly); + List createTemplateResponses(ResponseView view, long templateId, Long zoneId, boolean readyOnly); - List createTemplateResponses(long templateId, Long snapshotId, Long volumeId, boolean readyOnly); - - //ListResponse createSecurityGroupResponses(List networkGroups); + List createTemplateResponses(ResponseView view, long templateId, Long snapshotId, Long volumeId, boolean readyOnly); SecurityGroupResponse createSecurityGroupResponseFromSecurityGroupRule(List securityRules); @@ -302,38 +301,31 @@ public interface ResponseGenerator { EventResponse createEventResponse(Event event); - //List createEventResponse(EventJoinVO... events); + TemplateResponse createTemplateUpdateResponse(ResponseView view, VirtualMachineTemplate result); - TemplateResponse createTemplateUpdateResponse(VirtualMachineTemplate result); - - List createTemplateResponses(VirtualMachineTemplate result, Long zoneId, boolean readyOnly); + List createTemplateResponses(ResponseView view, VirtualMachineTemplate result, Long zoneId, boolean readyOnly); List createCapacityResponse(List result, DecimalFormat format); - TemplatePermissionsResponse createTemplatePermissionsResponse(List accountNames, Long id, boolean isAdmin); + TemplatePermissionsResponse createTemplatePermissionsResponse(ResponseView view, List accountNames, Long id); AsyncJobResponse queryJobResult(QueryAsyncJobResultCmd cmd); NetworkOfferingResponse createNetworkOfferingResponse(NetworkOffering offering); - NetworkResponse createNetworkResponse(Network network); + NetworkResponse createNetworkResponse(ResponseView view, Network network); UserResponse createUserResponse(User user); - //List createUserResponse(UserAccountJoinVO... users); - - AccountResponse createUserAccountResponse(UserAccount user); + AccountResponse createUserAccountResponse(ResponseView view, UserAccount user); Long getSecurityGroupId(String groupName, long accountId); - List createIsoResponses(VirtualMachineTemplate iso, Long zoneId, boolean readyOnly); - - // List createIsoResponses(long isoId, Long zoneId, boolean readyOnly); - //List createIsoResponses(VirtualMachineTemplate iso, long zoneId, boolean readyOnly); + List createIsoResponses(ResponseView view, VirtualMachineTemplate iso, Long zoneId, boolean readyOnly); ProjectResponse createProjectResponse(Project project); - List createTemplateResponses(long templateId, Long vmId); + List createTemplateResponses(ResponseView view, long templateId, Long vmId); FirewallResponse createFirewallResponse(FirewallRule fwRule); @@ -382,7 +374,7 @@ public interface ResponseGenerator { * @param vpc * @return */ - VpcResponse createVpcResponse(Vpc vpc); + VpcResponse createVpcResponse(ResponseView view, Vpc vpc); /** * @param networkACLItem @@ -424,6 +416,8 @@ public interface ResponseGenerator { GuestOSResponse createGuestOSResponse(GuestOS os); + GuestOsMappingResponse createGuestOSMappingResponse(GuestOSHypervisor osHypervisor); + SnapshotScheduleResponse createSnapshotScheduleResponse(SnapshotSchedule sched); UsageRecordResponse createUsageResponse(Usage usageRecord); diff --git a/api/src/org/apache/cloudstack/api/ResponseObject.java b/api/src/org/apache/cloudstack/api/ResponseObject.java index 10867b4abad..ff2e172b70b 100644 --- a/api/src/org/apache/cloudstack/api/ResponseObject.java +++ b/api/src/org/apache/cloudstack/api/ResponseObject.java @@ -75,4 +75,9 @@ public interface ResponseObject { * @param jobStatus */ void setJobStatus(Integer jobStatus); + + public enum ResponseView { + Full, + Restricted + } } diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java index c5a2d1a0cc3..50d67d993df 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java @@ -26,6 +26,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.DomainResponse; @@ -34,7 +35,9 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.user.Account; import com.cloud.user.UserAccount; -@APICommand(name = "createAccount", description = "Creates an account", responseObject = AccountResponse.class) + +@APICommand(name = "createAccount", description = "Creates an account", responseObject = AccountResponse.class, entityType = {Account.class}, + requestHasSensitiveInfo = true, responseHasSensitiveInfo = true) public class CreateAccountCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateAccountCmd.class.getName()); @@ -176,9 +179,9 @@ public class CreateAccountCmd extends BaseCmd { _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), getDomainId(), getNetworkDomain(), getDetails(), getAccountUUID(), getUserUUID()); if (userAccount != null) { - AccountResponse response = _responseGenerator.createUserAccountResponse(userAccount); + AccountResponse response = _responseGenerator.createUserAccountResponse(ResponseView.Full, userAccount); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user account"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java index 7c1b206d067..5754ec50108 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java @@ -20,6 +20,8 @@ import javax.inject.Inject; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -36,7 +38,8 @@ import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.user.User; -@APICommand(name = "deleteAccount", description = "Deletes a account, and all users associated with this account", responseObject = SuccessResponse.class) +@APICommand(name = "deleteAccount", description = "Deletes a account, and all users associated with this account", responseObject = SuccessResponse.class, entityType = {Account.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteAccountCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteAccountCmd.class.getName()); private static final String s_name = "deleteaccountresponse"; @@ -44,7 +47,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, required = true, description = "Account id") private Long id; @@ -101,7 +104,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd { boolean result = _regionService.deleteUserAccount(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete user account and all corresponding users"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java index 6fdbefe7afe..3e5e1d3d017 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java @@ -20,12 +20,15 @@ import javax.inject.Inject; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.DomainResponse; @@ -37,7 +40,8 @@ import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "disableAccount", description = "Disables an account", responseObject = AccountResponse.class) +@APICommand(name = "disableAccount", description = "Disables an account", responseObject = AccountResponse.class, entityType = {Account.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class DisableAccountCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DisableAccountCmd.class.getName()); private static final String s_name = "disableaccountresponse"; @@ -45,6 +49,7 @@ public class DisableAccountCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "Account id") private Long id; @@ -111,17 +116,17 @@ public class DisableAccountCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "disabling account: " + getAccountName() + " in domain: " + getDomainId(); + return "disabling account: " + getAccountName() + " in domain: " + getDomainId(); } @Override public void execute() throws ConcurrentOperationException, ResourceUnavailableException { CallContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId()); Account result = _regionService.disableAccount(this); - if (result != null) { - AccountResponse response = _responseGenerator.createAccountResponse(result); + if (result != null){ + AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java index 59d6acd5d5f..f30c985c961 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java @@ -20,11 +20,14 @@ import javax.inject.Inject; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.DomainResponse; @@ -32,7 +35,8 @@ import org.apache.cloudstack.region.RegionService; import com.cloud.user.Account; -@APICommand(name = "enableAccount", description = "Enables an account", responseObject = AccountResponse.class) +@APICommand(name = "enableAccount", description = "Enables an account", responseObject = AccountResponse.class, entityType = {Account.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class EnableAccountCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(EnableAccountCmd.class.getName()); private static final String s_name = "enableaccountresponse"; @@ -40,6 +44,7 @@ public class EnableAccountCmd extends BaseCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "Account id") private Long id; @@ -95,10 +100,10 @@ public class EnableAccountCmd extends BaseCmd { @Override public void execute() { Account result = _regionService.enableAccount(this); - if (result != null) { - AccountResponse response = _responseGenerator.createAccountResponse(result); + if (result != null){ + AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable account"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/ListAccountsCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/account/ListAccountsCmdByAdmin.java new file mode 100644 index 00000000000..555567bb5cc --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/account/ListAccountsCmdByAdmin.java @@ -0,0 +1,26 @@ +// 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 org.apache.cloudstack.api.command.admin.account; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.account.ListAccountsCmd; +import org.apache.cloudstack.api.response.AccountResponse; + +@APICommand(name = "listAccounts", description = "Lists accounts and provides detailed account information for listed accounts", responseObject = AccountResponse.class, responseView = ResponseView.Full) +public class ListAccountsCmdByAdmin extends ListAccountsCmd { +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/LockAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/LockAccountCmd.java index 93ec1be9f88..3c185e41bdd 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/account/LockAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/account/LockAccountCmd.java @@ -27,7 +27,8 @@ import org.apache.cloudstack.api.response.DomainResponse; import com.cloud.user.Account; -@APICommand(name = "lockAccount", description = "Locks an account", responseObject = AccountResponse.class) +@APICommand(name = "lockAccount", description = "Locks an account", responseObject = AccountResponse.class, entityType = {Account.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class LockAccountCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(LockAccountCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java index a8cf63fe5a4..a7ce74a1292 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java @@ -23,11 +23,14 @@ import javax.inject.Inject; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.DomainResponse; @@ -35,7 +38,8 @@ import org.apache.cloudstack.region.RegionService; import com.cloud.user.Account; -@APICommand(name = "updateAccount", description = "Updates account information for the authenticated user", responseObject = AccountResponse.class) +@APICommand(name = "updateAccount", description = "Updates account information for the authenticated user", responseObject = AccountResponse.class, entityType = {Account.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class UpdateAccountCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateAccountCmd.class.getName()); private static final String s_name = "updateaccountresponse"; @@ -43,7 +47,7 @@ public class UpdateAccountCmd extends BaseCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "Account id") private Long id; @@ -127,10 +131,10 @@ public class UpdateAccountCmd extends BaseCmd { @Override public void execute() { Account result = _regionService.updateAccount(this); - if (result != null) { - AccountResponse response = _responseGenerator.createAccountResponse(result); + if (result != null){ + AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update account"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/address/AssociateIPAddrCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/address/AssociateIPAddrCmdByAdmin.java new file mode 100644 index 00000000000..494a6d66e40 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/address/AssociateIPAddrCmdByAdmin.java @@ -0,0 +1,68 @@ +// 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 org.apache.cloudstack.api.command.admin.address; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.address.AssociateIPAddrCmd; +import org.apache.cloudstack.api.response.IPAddressResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.IpAddress; +import com.cloud.network.vpc.Vpc; + +@APICommand(name = "associateIpAddress", description = "Acquires and associates a public IP to an account.", responseObject = IPAddressResponse.class, responseView = ResponseView.Full, + entityType = {IpAddress.class, Vpc.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class AssociateIPAddrCmdByAdmin extends AssociateIPAddrCmd { + public static final Logger s_logger = Logger.getLogger(AssociateIPAddrCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceUnavailableException, ResourceAllocationException, + ConcurrentOperationException, InsufficientCapacityException { + CallContext.current().setEventDetails("Ip Id: " + getEntityId()); + + IpAddress result = null; + + if (getVpcId() != null) { + result = _vpcService.associateIPToVpc(getEntityId(), getVpcId()); + } else if (getNetworkId() != null) { + result = _networkService.associateIPToNetwork(getEntityId(), getNetworkId()); + } + + if (result != null) { + IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Full, result); + ipResponse.setResponseName(getCommandName()); + setResponseObject(ipResponse); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign ip address"); + } + } + + + + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/address/ListPublicIpAddressesCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/address/ListPublicIpAddressesCmdByAdmin.java new file mode 100644 index 00000000000..3762e5f2a1b --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/address/ListPublicIpAddressesCmdByAdmin.java @@ -0,0 +1,53 @@ +// 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 org.apache.cloudstack.api.command.admin.address; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.address.ListPublicIpAddressesCmd; +import org.apache.cloudstack.api.response.IPAddressResponse; +import org.apache.cloudstack.api.response.ListResponse; + +import com.cloud.network.IpAddress; +import com.cloud.utils.Pair; + +@APICommand(name = "listPublicIpAddresses", description = "Lists all public ip addresses", responseObject = IPAddressResponse.class, responseView = ResponseView.Full) +public class ListPublicIpAddressesCmdByAdmin extends ListPublicIpAddressesCmd { + public static final Logger s_logger = Logger.getLogger(ListPublicIpAddressesCmdByAdmin.class.getName()); + + @Override + public void execute(){ + Pair, Integer> result = _mgr.searchForIPAddresses(this); + ListResponse response = new ListResponse(); + List ipAddrResponses = new ArrayList(); + for (IpAddress ipAddress : result.first()) { + IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Full, ipAddress); + ipResponse.setObjectName("publicipaddress"); + ipAddrResponses.add(ipResponse); + } + + response.setResponses(ipAddrResponses, result.second()); + response.setResponseName(getCommandName()); + setResponseObject(response); + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/affinitygroup/UpdateVMAffinityGroupCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/affinitygroup/UpdateVMAffinityGroupCmdByAdmin.java new file mode 100644 index 00000000000..85b8dd711d1 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/affinitygroup/UpdateVMAffinityGroupCmdByAdmin.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 org.apache.cloudstack.api.command.admin.affinitygroup; + +import java.util.ArrayList; +import java.util.EnumSet; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants.VMDetails; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.affinitygroup.UpdateVMAffinityGroupCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + + +@APICommand(name = "updateVMAffinityGroup", description = "Updates the affinity/anti-affinity group associations of a virtual machine. The VM has to be stopped and restarted for the " + + "new properties to take effect.", responseObject = UserVmResponse.class, responseView = ResponseView.Full) +public class UpdateVMAffinityGroupCmdByAdmin extends UpdateVMAffinityGroupCmd { + public static final Logger s_logger = Logger.getLogger(UpdateVMAffinityGroupCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceUnavailableException, + InsufficientCapacityException, ServerApiException { + CallContext.current().setEventDetails("Vm Id: "+getId()); + UserVm result = _affinityGroupService.updateVMAffinityGroups(getId(), getAffinityGroupIdList()); + ArrayList dc = new ArrayList(); + dc.add(VMDetails.valueOf("affgrp")); + EnumSet details = EnumSet.copyOf(dc); + + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", details, result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm's affinity groups"); + } + } + + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/alert/GenerateAlertCmd.java b/api/src/org/apache/cloudstack/api/command/admin/alert/GenerateAlertCmd.java index 620c5ed8faa..58920d7dd74 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/alert/GenerateAlertCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/alert/GenerateAlertCmd.java @@ -31,7 +31,8 @@ import org.apache.log4j.Logger; import com.cloud.event.EventTypes; -@APICommand(name = "generateAlert", description = "Generates an alert", responseObject = SuccessResponse.class, since = "4.3") +@APICommand(name = "generateAlert", description = "Generates an alert", responseObject = SuccessResponse.class, since = "4.3", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class GenerateAlertCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(GenerateAlertCmd.class.getName()); @@ -48,7 +49,7 @@ public class GenerateAlertCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "Name of the alert", required = true) private String name; - @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Alert description", required = true) + @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "Alert description", required = true, length = 999) private String description; @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "Zone id for which alert is generated") diff --git a/api/src/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java index 6c4b81b4f0e..ea715663d9c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java @@ -32,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.Counter; import com.cloud.user.Account; -@APICommand(name = "createCounter", description = "Adds metric counter", responseObject = CounterResponse.class) +@APICommand(name = "createCounter", description = "Adds metric counter", responseObject = CounterResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateCounterCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateCounterCmd.class.getName()); private static final String s_name = "counterresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/autoscale/DeleteCounterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/autoscale/DeleteCounterCmd.java index 50477f53760..3547ef10c8c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/autoscale/DeleteCounterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/autoscale/DeleteCounterCmd.java @@ -33,7 +33,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.ResourceInUseException; import com.cloud.user.Account; -@APICommand(name = "deleteCounter", description = "Deletes a counter", responseObject = SuccessResponse.class) +@APICommand(name = "deleteCounter", description = "Deletes a counter", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteCounterCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteCounterCmd.class.getName()); private static final String s_name = "deletecounterresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java index d0e73807392..b9df18e01ed 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java @@ -38,7 +38,8 @@ import com.cloud.exception.ResourceInUseException; import com.cloud.org.Cluster; import com.cloud.user.Account; -@APICommand(name = "addCluster", description = "Adds a new cluster", responseObject = ClusterResponse.class) +@APICommand(name = "addCluster", description = "Adds a new cluster", responseObject = ClusterResponse.class, + requestHasSensitiveInfo = true, responseHasSensitiveInfo = false) public class AddClusterCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddClusterCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/DeleteClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/DeleteClusterCmd.java index e1bc5855ee8..5d046758007 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/cluster/DeleteClusterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/DeleteClusterCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "deleteCluster", description = "Deletes a cluster.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteCluster", description = "Deletes a cluster.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteClusterCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteClusterCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java index 8640f371445..432ca921c4d 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java @@ -34,7 +34,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.org.Cluster; import com.cloud.utils.Pair; -@APICommand(name = "listClusters", description = "Lists clusters.", responseObject = ClusterResponse.class) +@APICommand(name = "listClusters", description = "Lists clusters.", responseObject = ClusterResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListClustersCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java index b13f81a16bc..53d01c58a56 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java @@ -30,7 +30,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.org.Cluster; import com.cloud.user.Account; -@APICommand(name = "updateCluster", description = "Updates an existing cluster", responseObject = ClusterResponse.class) +@APICommand(name = "updateCluster", description = "Updates an existing cluster", responseObject = ClusterResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateClusterCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddClusterCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java index 517807d4a78..a34bc3eb622 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java @@ -35,7 +35,8 @@ import org.apache.cloudstack.config.Configuration; import com.cloud.utils.Pair; -@APICommand(name = "listConfigurations", description = "Lists all configurations.", responseObject = ConfigurationResponse.class) +@APICommand(name = "listConfigurations", description = "Lists all configurations.", responseObject = ConfigurationResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListCfgsByCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListCfgsByCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/ListDeploymentPlannersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/ListDeploymentPlannersCmd.java index 1d9d2d935ff..b5a24b9bda8 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/config/ListDeploymentPlannersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/config/ListDeploymentPlannersCmd.java @@ -26,7 +26,8 @@ import org.apache.cloudstack.api.BaseListCmd; import org.apache.cloudstack.api.response.DeploymentPlannersResponse; import org.apache.cloudstack.api.response.ListResponse; -@APICommand(name = "listDeploymentPlanners", description = "Lists all DeploymentPlanners available.", responseObject = DeploymentPlannersResponse.class) +@APICommand(name = "listDeploymentPlanners", description = "Lists all DeploymentPlanners available.", responseObject = DeploymentPlannersResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListDeploymentPlannersCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListDeploymentPlannersCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/ListHypervisorCapabilitiesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/ListHypervisorCapabilitiesCmd.java index 16adf664bdd..6d3c2012af7 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/config/ListHypervisorCapabilitiesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/config/ListHypervisorCapabilitiesCmd.java @@ -35,7 +35,9 @@ import com.cloud.utils.Pair; @APICommand(name = "listHypervisorCapabilities", description = "Lists all hypervisor capabilities.", responseObject = HypervisorCapabilitiesResponse.class, - since = "3.0.0") + since = "3.0.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListHypervisorCapabilitiesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListHypervisorCapabilitiesCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java index 9bc9b3cbb5c..0124d5997b3 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.config.Configuration; import com.cloud.user.Account; -@APICommand(name = "updateConfiguration", description = "Updates a configuration.", responseObject = ConfigurationResponse.class) +@APICommand(name = "updateConfiguration", description = "Updates a configuration.", responseObject = ConfigurationResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateCfgCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateCfgCmd.class.getName()); private static final String s_name = "updateconfigurationresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/UpdateHypervisorCapabilitiesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/UpdateHypervisorCapabilitiesCmd.java index 5cb5f9c3e52..6550c89240b 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/config/UpdateHypervisorCapabilitiesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/config/UpdateHypervisorCapabilitiesCmd.java @@ -32,7 +32,9 @@ import com.cloud.user.Account; @APICommand(name = "updateHypervisorCapabilities", description = "Updates a hypervisor capabilities.", responseObject = HypervisorCapabilitiesResponse.class, - since = "3.0.0") + since = "3.0.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class UpdateHypervisorCapabilitiesCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateHypervisorCapabilitiesCmd.class.getName()); private static final String s_name = "updatehypervisorcapabilitiesresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java index 47375551aea..312c9ee4b09 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java @@ -30,7 +30,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.domain.Domain; import com.cloud.user.Account; -@APICommand(name = "createDomain", description = "Creates a domain", responseObject = DomainResponse.class) +@APICommand(name = "createDomain", description = "Creates a domain", responseObject = DomainResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateDomainCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateDomainCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java index b1075c10fc5..a6d2b0b10c1 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java @@ -35,7 +35,8 @@ import com.cloud.domain.Domain; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "deleteDomain", description = "Deletes a specified domain", responseObject = SuccessResponse.class) +@APICommand(name = "deleteDomain", description = "Deletes a specified domain", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteDomainCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteDomainCmd.class.getName()); private static final String s_name = "deletedomainresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainChildrenCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainChildrenCmd.java index e1ba1789616..cf35295358b 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainChildrenCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainChildrenCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.domain.Domain; import com.cloud.utils.Pair; -@APICommand(name = "listDomainChildren", description = "Lists all children domains belonging to a specified domain", responseObject = DomainResponse.class) +@APICommand(name = "listDomainChildren", description = "Lists all children domains belonging to a specified domain", responseObject = DomainResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListDomainChildrenCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListDomainChildrenCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java index 5a3786cda20..1942afd9af3 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.domain.Domain; import com.cloud.utils.Pair; -@APICommand(name = "listDomains", description = "Lists domains and provides detailed information for listed domains", responseObject = DomainResponse.class) +@APICommand(name = "listDomains", description = "Lists domains and provides detailed information for listed domains", responseObject = DomainResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListDomainsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListDomainsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java index 8acfcd5acda..409a84d7d80 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.region.RegionService; import com.cloud.domain.Domain; import com.cloud.user.Account; -@APICommand(name = "updateDomain", description = "Updates a domain with a new name", responseObject = DomainResponse.class) +@APICommand(name = "updateDomain", description = "Updates a domain with a new name", responseObject = DomainResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateDomainCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateDomainCmd.class.getName()); private static final String s_name = "updatedomainresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/guest/AddGuestOsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/guest/AddGuestOsCmd.java new file mode 100644 index 00000000000..3ba9669b305 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/guest/AddGuestOsCmd.java @@ -0,0 +1,136 @@ +// 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 org.apache.cloudstack.api.command.admin.guest; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiCommandJobType; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseAsyncCreateCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.GuestOSCategoryResponse; +import org.apache.cloudstack.api.response.GuestOSResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.event.EventTypes; +import com.cloud.storage.GuestOS; +import com.cloud.user.Account; + +@APICommand(name = "addGuestOs", description = "Add a new guest OS type", responseObject = GuestOSResponse.class, + since = "4.4.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class AddGuestOsCmd extends BaseAsyncCreateCmd { + public static final Logger s_logger = Logger.getLogger(AddGuestOsCmd.class.getName()); + + private static final String s_name = "addguestosresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.OS_CATEGORY_ID, type = CommandType.UUID, entityType = GuestOSCategoryResponse.class, required = true, description = "ID of Guest OS category") + private Long osCategoryId; + + @Parameter(name = ApiConstants.OS_DISPLAY_NAME, type = CommandType.STRING, required = true, description = "Unique display name for Guest OS") + private String osDisplayName; + + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = false, description = "Optional name for Guest OS") + private String osName; + + +///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getOsCategoryId() { + return osCategoryId; + } + + public String getOsDisplayName() { + return osDisplayName; + } + + public String getOsName() { + return osName; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void create() { + GuestOS guestOs = _mgr.addGuestOs(this); + if (guestOs != null) { + setEntityId(guestOs.getId()); + setEntityUuid(guestOs.getUuid()); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new guest OS type entity"); + } + } + + @Override + public void execute() { + CallContext.current().setEventDetails("Guest OS Id: " + getEntityId()); + GuestOS guestOs = _mgr.getAddedGuestOs(getEntityId()); + if (guestOs != null) { + GuestOSResponse response = _responseGenerator.createGuestOSResponse(guestOs); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add new guest OS type"); + } + } + + @Override + public String getEventType() { + return EventTypes.EVENT_GUEST_OS_ADD; + } + + @Override + public String getEventDescription() { + return "adding a new guest OS type Id: " + getEntityId(); + } + + @Override + public ApiCommandJobType getInstanceType() { + return ApiCommandJobType.GuestOs; + } + + @Override + public String getCreateEventType() { + return EventTypes.EVENT_GUEST_OS_ADD; + } + + @Override + public String getCreateEventDescription() { + return "adding new guest OS type"; + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/guest/AddGuestOsMappingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/guest/AddGuestOsMappingCmd.java new file mode 100644 index 00000000000..8af50a15bfa --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/guest/AddGuestOsMappingCmd.java @@ -0,0 +1,146 @@ +// 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 org.apache.cloudstack.api.command.admin.guest; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiCommandJobType; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseAsyncCreateCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.GuestOSResponse; +import org.apache.cloudstack.api.response.GuestOsMappingResponse; + +import com.cloud.event.EventTypes; +import com.cloud.storage.GuestOSHypervisor; +import com.cloud.user.Account; + +@APICommand(name = "addGuestOsMapping", description = "Adds a guest OS name to hypervisor OS name mapping", responseObject = GuestOsMappingResponse.class, + since = "4.4.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class AddGuestOsMappingCmd extends BaseAsyncCreateCmd { + public static final Logger s_logger = Logger.getLogger(AddGuestOsMappingCmd.class.getName()); + + private static final String s_name = "addguestosmappingresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.UUID, required = false, entityType = GuestOSResponse.class, description = "UUID of Guest OS type. Either the UUID or Display Name must be passed") + private Long osTypeId; + + @Parameter(name = ApiConstants.OS_DISPLAY_NAME, type = CommandType.STRING, required = false, description = "Display Name of Guest OS standard type. Either Display Name or UUID must be passed") + private String osStdName; + + @Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, required = true, description = "Hypervisor type. One of : XenServer, KVM, VMWare") + private String hypervisor; + + @Parameter(name = ApiConstants.HYPERVISOR_VERSION, type = CommandType.STRING, required = true, description = "Hypervisor version to create the mapping for. Use 'default' for default versions") + private String hypervisorVersion; + + @Parameter(name = ApiConstants.OS_NAME_FOR_HYPERVISOR, type = CommandType.STRING, required = true, description = "OS name specific to the hypervisor") + private String osNameForHypervisor; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getOsTypeId() { + return osTypeId; + } + + public String getOsStdName() { + return osStdName; + } + + public String getHypervisor() { + return hypervisor; + } + + public String getHypervisorVersion() { + return hypervisorVersion; + } + + public String getOsNameForHypervisor() { + return osNameForHypervisor; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void create() { + GuestOSHypervisor guestOsMapping = _mgr.addGuestOsMapping(this); + if (guestOsMapping != null) { + setEntityId(guestOsMapping.getId()); + setEntityUuid(guestOsMapping.getUuid()); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add guest OS mapping entity"); + } + } + + @Override + public void execute() { + GuestOSHypervisor guestOsMapping = _mgr.getAddedGuestOsMapping(getEntityId()); + if (guestOsMapping != null) { + GuestOsMappingResponse response = _responseGenerator.createGuestOSMappingResponse(guestOsMapping); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add guest OS mapping"); + } + } + + @Override + public String getEventType() { + return EventTypes.EVENT_GUEST_OS_MAPPING_ADD; + } + + @Override + public String getEventDescription() { + return "adding a new guest OS mapping Id: " + getEntityId(); + } + + @Override + public ApiCommandJobType getInstanceType() { + return ApiCommandJobType.GuestOsMapping; + } + + @Override + public String getCreateEventType() { + return EventTypes.EVENT_GUEST_OS_MAPPING_ADD; + } + + @Override + public String getCreateEventDescription() { + return "adding new guest OS mapping"; + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/guest/ListGuestOsMappingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/guest/ListGuestOsMappingCmd.java new file mode 100644 index 00000000000..a7fc9e0decd --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/guest/ListGuestOsMappingCmd.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 org.apache.cloudstack.api.command.admin.guest; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseListCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.GuestOSResponse; +import org.apache.cloudstack.api.response.GuestOsMappingResponse; +import org.apache.cloudstack.api.response.ListResponse; + +import com.cloud.storage.GuestOSHypervisor; +import com.cloud.utils.Pair; + +@APICommand(name = "listGuestOsMapping", description = "Lists all available OS mappings for given hypervisor", responseObject = GuestOsMappingResponse.class, + since = "4.4.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class ListGuestOsMappingCmd extends BaseListCmd { + public static final Logger s_logger = Logger.getLogger(ListGuestOsMappingCmd.class.getName()); + + private static final String s_name = "listguestosmappingresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOsMappingResponse.class, required = false, description = "list mapping by its UUID") + private Long id; + + @Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.UUID, entityType = GuestOSResponse.class, required = false, description = "list mapping by Guest OS Type UUID") + private Long osTypeId; + + @Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, required = false, description = "list Guest OS mapping by hypervisor") + private String hypervisor; + + @Parameter(name = ApiConstants.HYPERVISOR_VERSION, type = CommandType.STRING, required = false, description = "list Guest OS mapping by hypervisor version. Must be used with hypervisor parameter") + private String hypervisorVersion; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + public Long getOsTypeId() { + return osTypeId; + } + + public String getHypervisor() { + return hypervisor; + } + + public String getHypervisorVersion() { + return hypervisorVersion; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public void execute() { + Pair, Integer> result = _mgr.listGuestOSMappingByCriteria(this); + ListResponse response = new ListResponse(); + List osMappingResponses = new ArrayList(); + for (GuestOSHypervisor guestOSHypervisor : result.first()) { + GuestOsMappingResponse guestOsMappingResponse = _responseGenerator.createGuestOSMappingResponse(guestOSHypervisor); + osMappingResponses.add(guestOsMappingResponse); + } + + response.setResponses(osMappingResponses, result.second()); + response.setResponseName(getCommandName()); + setResponseObject(response); + } +} \ No newline at end of file diff --git a/api/src/org/apache/cloudstack/api/command/admin/guest/RemoveGuestOsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/guest/RemoveGuestOsCmd.java new file mode 100644 index 00000000000..3de7f7a68da --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/guest/RemoveGuestOsCmd.java @@ -0,0 +1,98 @@ +// 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 org.apache.cloudstack.api.command.admin.guest; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiCommandJobType; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.GuestOSResponse; +import org.apache.cloudstack.api.response.SuccessResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.event.EventTypes; +import com.cloud.user.Account; + +@APICommand(name = "removeGuestOs", description = "Removes a Guest OS from listing.", responseObject = SuccessResponse.class, since = "4.4.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class RemoveGuestOsCmd extends BaseAsyncCmd { + + public static final Logger s_logger = Logger.getLogger(RemoveGuestOsCmd.class.getName()); + private static final String s_name = "removeguestosresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOSResponse.class, required = true, description = "ID of the guest OS") + private Long id; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() { + CallContext.current().setEventDetails("Guest OS Id: " + id); + boolean result = _mgr.removeGuestOs(this); + if (result) { + SuccessResponse response = new SuccessResponse(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove guest OS"); + } + } + + @Override + public String getEventDescription() { + return "Removing Guest OS: " + getId(); + } + + @Override + public String getEventType() { + return EventTypes.EVENT_GUEST_OS_REMOVE; + } + + @Override + public ApiCommandJobType getInstanceType() { + return ApiCommandJobType.GuestOs; + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/guest/RemoveGuestOsMappingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/guest/RemoveGuestOsMappingCmd.java new file mode 100644 index 00000000000..ddd45399de2 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/guest/RemoveGuestOsMappingCmd.java @@ -0,0 +1,98 @@ +// 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 org.apache.cloudstack.api.command.admin.guest; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiCommandJobType; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.GuestOsMappingResponse; +import org.apache.cloudstack.api.response.SuccessResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.event.EventTypes; +import com.cloud.user.Account; + +@APICommand(name = "removeGuestOsMapping", description = "Removes a Guest OS Mapping.", responseObject = SuccessResponse.class, since = "4.4.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class RemoveGuestOsMappingCmd extends BaseAsyncCmd { + + public static final Logger s_logger = Logger.getLogger(RemoveGuestOsMappingCmd.class.getName()); + private static final String s_name = "removeguestosmappingresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOsMappingResponse.class, required = true, description = "ID of the guest OS mapping") + private Long id; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() { + CallContext.current().setEventDetails("Guest OS Mapping Id: " + id); + boolean result = _mgr.removeGuestOsMapping(this); + if (result) { + SuccessResponse response = new SuccessResponse(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove guest OS mapping"); + } + } + + @Override + public String getEventDescription() { + return "Removing Guest OS Mapping: " + getId(); + } + + @Override + public String getEventType() { + return EventTypes.EVENT_GUEST_OS_MAPPING_REMOVE; + } + + @Override + public ApiCommandJobType getInstanceType() { + return ApiCommandJobType.GuestOsMapping; + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCmd.java new file mode 100644 index 00000000000..e4b1ecd5719 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCmd.java @@ -0,0 +1,104 @@ +// 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 org.apache.cloudstack.api.command.admin.guest; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiCommandJobType; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.GuestOSResponse; + +import com.cloud.event.EventTypes; +import com.cloud.storage.GuestOS; +import com.cloud.user.Account; + +@APICommand(name = "updateGuestOs", description = "Updates the information about Guest OS", responseObject = GuestOSResponse.class, + since = "4.4.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateGuestOsCmd extends BaseAsyncCmd { + + public static final Logger s_logger = Logger.getLogger(UpdateGuestOsCmd.class.getName()); + + private static final String s_name = "updateguestosresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOSResponse.class, required = true, description = "UUID of the Guest OS") + private Long id; + + @Parameter(name = ApiConstants.OS_DISPLAY_NAME, type = CommandType.STRING, required = true, description = "Unique display name for Guest OS") + private String osDisplayName; + +///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + public String getOsDisplayName() { + return osDisplayName; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() { + GuestOS guestOs = _mgr.updateGuestOs(this); + if (guestOs != null) { + GuestOSResponse response = _responseGenerator.createGuestOSResponse(guestOs); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest OS type"); + } + } + + @Override + public String getEventDescription() { + return "Updating guest OS: " + getId(); + } + + @Override + public String getEventType() { + return EventTypes.EVENT_GUEST_OS_UPDATE; + } + + @Override + public ApiCommandJobType getInstanceType() { + return ApiCommandJobType.GuestOs; + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsMappingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsMappingCmd.java new file mode 100644 index 00000000000..d760d534cfb --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsMappingCmd.java @@ -0,0 +1,102 @@ +// 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 org.apache.cloudstack.api.command.admin.guest; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiCommandJobType; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.GuestOsMappingResponse; + +import com.cloud.event.EventTypes; +import com.cloud.storage.GuestOSHypervisor; +import com.cloud.user.Account; + +@APICommand(name = "updateGuestOsMapping", description = "Updates the information about Guest OS to Hypervisor specific name mapping", responseObject = GuestOsMappingResponse.class, + since = "4.4.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateGuestOsMappingCmd extends BaseAsyncCmd { + public static final Logger s_logger = Logger.getLogger(UpdateGuestOsMappingCmd.class.getName()); + + private static final String s_name = "updateguestosmappingresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuestOsMappingResponse.class, required = true, description = "UUID of the Guest OS to hypervisor name Mapping") + private Long id; + + @Parameter(name = ApiConstants.OS_NAME_FOR_HYPERVISOR, type = CommandType.STRING, required = true, description = "Hypervisor specific name for this Guest OS") + private String osNameForHypervisor; + +///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + public String getOsNameForHypervisor() { + return osNameForHypervisor; + } + + @Override + public void execute() { + GuestOSHypervisor guestOsMapping = _mgr.updateGuestOsMapping(this); + if (guestOsMapping != null) { + GuestOsMappingResponse response = _responseGenerator.createGuestOSMappingResponse(guestOsMapping); + response.setResponseName(getCommandName()); + setResponseObject(response); + } + else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update guest OS mapping"); + } + + } + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public String getEventDescription() { + return "Updating Guest OS Mapping: " + getId(); + } + + @Override + public String getEventType() { + return EventTypes.EVENT_GUEST_OS_MAPPING_UPDATE; + } + + @Override + public ApiCommandJobType getInstanceType() { + return ApiCommandJobType.GuestOsMapping; + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java index 363bcd6db50..960be8df577 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java @@ -37,7 +37,8 @@ import com.cloud.exception.DiscoveryException; import com.cloud.host.Host; import com.cloud.user.Account; -@APICommand(name = "addHost", description = "Adds a new host.", responseObject = HostResponse.class) +@APICommand(name = "addHost", description = "Adds a new host.", responseObject = HostResponse.class, + requestHasSensitiveInfo = true, responseHasSensitiveInfo = false) public class AddHostCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddHostCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java index b573bea3e84..9108d600419 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java @@ -31,7 +31,8 @@ import com.cloud.exception.DiscoveryException; import com.cloud.storage.ImageStore; import com.cloud.user.Account; -@APICommand(name = "addSecondaryStorage", description = "Adds secondary storage.", responseObject = ImageStoreResponse.class) +@APICommand(name = "addSecondaryStorage", description = "Adds secondary storage.", responseObject = ImageStoreResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddSecondaryStorageCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddSecondaryStorageCmd.class.getName()); private static final String s_name = "addsecondarystorageresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java index 46289ee49bd..d23a7651bbc 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/CancelMaintenanceCmd.java @@ -32,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.host.Host; import com.cloud.user.Account; -@APICommand(name = "cancelHostMaintenance", description = "Cancels host maintenance.", responseObject = HostResponse.class) +@APICommand(name = "cancelHostMaintenance", description = "Cancels host maintenance.", responseObject = HostResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CancelMaintenanceCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(CancelMaintenanceCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/DeleteHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/DeleteHostCmd.java index 5a4478e21a3..b9945281296 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/DeleteHostCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/DeleteHostCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "deleteHost", description = "Deletes a host.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteHost", description = "Deletes a host.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteHostCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteHostCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/FindHostsForMigrationCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/FindHostsForMigrationCmd.java index 0faf72cc245..dbb94384523 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/FindHostsForMigrationCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/FindHostsForMigrationCmd.java @@ -34,7 +34,8 @@ import com.cloud.host.Host; import com.cloud.utils.Pair; import com.cloud.utils.Ternary; -@APICommand(name = "findHostsForMigration", description = "Find hosts suitable for migrating a virtual machine.", responseObject = HostForMigrationResponse.class) +@APICommand(name = "findHostsForMigration", description = "Find hosts suitable for migrating a virtual machine.", responseObject = HostForMigrationResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class FindHostsForMigrationCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(FindHostsForMigrationCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java index eda821b0498..d7aa18bbfef 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java @@ -42,7 +42,8 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.utils.Pair; import com.cloud.utils.Ternary; -@APICommand(name = "listHosts", description = "Lists hosts.", responseObject = HostResponse.class) +@APICommand(name = "listHosts", description = "Lists hosts.", responseObject = HostResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListHostsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListHostsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java index 23cfacfa87a..e49aabc49d4 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/PrepareForMaintenanceCmd.java @@ -32,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.host.Host; import com.cloud.user.Account; -@APICommand(name = "prepareHostForMaintenance", description = "Prepares a host for maintenance.", responseObject = HostResponse.class) +@APICommand(name = "prepareHostForMaintenance", description = "Prepares a host for maintenance.", responseObject = HostResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class PrepareForMaintenanceCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(PrepareForMaintenanceCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java index 1ce888b1570..5e156372681 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/ReconnectHostCmd.java @@ -32,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.host.Host; import com.cloud.user.Account; -@APICommand(name = "reconnectHost", description = "Reconnects a host.", responseObject = HostResponse.class) +@APICommand(name = "reconnectHost", description = "Reconnects a host.", responseObject = HostResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReconnectHostCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReconnectHostCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java index b60feca5977..6aeff6312c9 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/ReleaseHostReservationCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "releaseHostReservation", description = "Releases host reservation.", responseObject = SuccessResponse.class) +@APICommand(name = "releaseHostReservation", description = "Releases host reservation.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReleaseHostReservationCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReleaseHostReservationCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java index d778b37bed1..c6f6530dc50 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.HostResponse; import com.cloud.host.Host; import com.cloud.user.Account; -@APICommand(name = "updateHost", description = "Updates a host.", responseObject = HostResponse.class) +@APICommand(name = "updateHost", description = "Updates a host.", responseObject = HostResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateHostCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateHostCmd.class.getName()); private static final String s_name = "updatehostresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java index 69480b14f4b..94f58254896 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/host/UpdateHostPasswordCmd.java @@ -28,7 +28,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "updateHostPassword", description = "Update password of a host/pool on management server.", responseObject = SuccessResponse.class) +@APICommand(name = "updateHostPassword", description = "Update password of a host/pool on management server.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = true, responseHasSensitiveInfo = false) public class UpdateHostPasswordCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateHostPasswordCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java index 51da7608dac..7e39749ff17 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ConfigureInternalLoadBalancerElementCmd.java @@ -43,7 +43,9 @@ import com.cloud.user.Account; @APICommand(name = "configureInternalLoadBalancerElement", responseObject = InternalLoadBalancerElementResponse.class, description = "Configures an Internal Load Balancer element.", - since = "4.2.0") + since = "4.2.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ConfigureInternalLoadBalancerElementCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ConfigureInternalLoadBalancerElementCmd.class.getName()); private static final String s_name = "configureinternalloadbalancerelementresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java index a6ece720455..b9c61f3bf90 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/CreateInternalLoadBalancerElementCmd.java @@ -41,7 +41,9 @@ import com.cloud.user.Account; @APICommand(name = "createInternalLoadBalancerElement", responseObject = InternalLoadBalancerElementResponse.class, description = "Create an Internal Load Balancer element.", - since = "4.2.0") + since = "4.2.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class CreateInternalLoadBalancerElementCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateInternalLoadBalancerElementCmd.class.getName()); private static final String s_name = "createinternalloadbalancerelementresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java index 0e01be142ee..0b59b73f9d2 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLBVMsCmd.java @@ -33,8 +33,10 @@ import org.apache.cloudstack.api.response.VpcResponse; import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.network.router.VirtualRouter.Role; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "listInternalLoadBalancerVMs", description = "List internal LB VMs.", responseObject = DomainRouterResponse.class) +@APICommand(name = "listInternalLoadBalancerVMs", description = "List internal LB VMs.", responseObject = DomainRouterResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListInternalLBVMsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListInternalLBVMsCmd.class.getName()); @@ -133,6 +135,6 @@ public class ListInternalLBVMsCmd extends BaseListProjectAndAccountResourcesCmd public void execute() { ListResponse response = _queryService.searchForInternalLbVms(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java index a42a0b306af..8f62b419691 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/ListInternalLoadBalancerElementsCmd.java @@ -42,10 +42,12 @@ import com.cloud.network.VirtualRouterProvider; @APICommand(name = "listInternalLoadBalancerElements", description = "Lists all available Internal Load Balancer elements.", responseObject = InternalLoadBalancerElementResponse.class, - since = "4.2.0") + since = "4.2.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListInternalLoadBalancerElementsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListInternalLoadBalancerElementsCmd.class.getName()); - private static final String Name = "listinternalloadbalancerelementsresponse"; + private static final String s_name = "listinternalloadbalancerelementsresponse"; @Inject private InternalLoadBalancerElementService _service; @@ -86,7 +88,7 @@ public class ListInternalLoadBalancerElementsCmd extends BaseListCmd { @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java index 56dcb4f8403..7040e7cf29a 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StartInternalLBVMCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.admin.internallb; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -35,8 +37,10 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.Role; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "startInternalLoadBalancerVM", responseObject = DomainRouterResponse.class, description = "Starts an existing internal lb vm.") +@APICommand(name = "startInternalLoadBalancerVM", responseObject = DomainRouterResponse.class, description = "Starts an existing internal lb vm.", entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class StartInternalLBVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(StartInternalLBVMCmd.class.getName()); private static final String s_name = "startinternallbvmresponse"; @@ -44,7 +48,7 @@ public class StartInternalLBVMCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class, required = true, description = "the ID of the internal lb vm") private Long id; @@ -113,7 +117,7 @@ public class StartInternalLBVMCmd extends BaseAsyncCmd { if (result != null) { DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result); routerResponse.setResponseName(getCommandName()); - this.setResponseObject(routerResponse); + setResponseObject(routerResponse); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start internal lb vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java index 9da4db072db..51a3d9f8fa0 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/internallb/StopInternalLBVMCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.admin.internallb; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -34,8 +36,10 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.Role; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "stopInternalLoadBalancerVM", description = "Stops an Internal LB vm.", responseObject = DomainRouterResponse.class) +@APICommand(name = "stopInternalLoadBalancerVM", description = "Stops an Internal LB vm.", responseObject = DomainRouterResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class StopInternalLBVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(StopInternalLBVMCmd.class.getName()); private static final String s_name = "stopinternallbvmresponse"; @@ -43,7 +47,7 @@ public class StopInternalLBVMCmd extends BaseAsyncCmd { // /////////////////////////////////////////////////// // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = DomainRouterResponse.class, required = true, description = "the ID of the internal lb vm") private Long id; @@ -115,7 +119,7 @@ public class StopInternalLBVMCmd extends BaseAsyncCmd { if (result != null) { DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop internal lb vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/AttachIsoCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/AttachIsoCmdByAdmin.java new file mode 100644 index 00000000000..7c3db62d1af --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/iso/AttachIsoCmdByAdmin.java @@ -0,0 +1,53 @@ +// 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 org.apache.cloudstack.api.command.admin.iso; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.iso.AttachIsoCmd; +import org.apache.cloudstack.api.command.user.vm.DeployVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.uservm.UserVm; + +@APICommand(name = "attachIso", description = "Attaches an ISO to a virtual machine.", responseObject = UserVmResponse.class, responseView = ResponseView.Full) +public class AttachIsoCmdByAdmin extends AttachIsoCmd { + public static final Logger s_logger = Logger.getLogger(AttachIsoCmdByAdmin.class.getName()); + + @Override + public void execute(){ + CallContext.current().setEventDetails("Vm Id: " +getVirtualMachineId()+ " ISO Id: "+getId()); + boolean result = _templateService.attachIso(id, virtualMachineId); + if (result) { + UserVm userVm = _responseGenerator.findUserVmById(virtualMachineId); + if (userVm != null) { + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", userVm).get(0); + response.setResponseName(DeployVMCmd.getResultObjectName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach iso"); + } + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach iso"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/CopyIsoCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/CopyIsoCmdByAdmin.java new file mode 100644 index 00000000000..f27c0c5c234 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/iso/CopyIsoCmdByAdmin.java @@ -0,0 +1,28 @@ +// 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 org.apache.cloudstack.api.command.admin.iso; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.iso.CopyIsoCmd; +import org.apache.cloudstack.api.response.TemplateResponse; + +@APICommand(name = "copyIso", description = "Copies an iso from one zone to another.", responseObject = TemplateResponse.class, responseView = ResponseView.Full, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class CopyIsoCmdByAdmin extends CopyIsoCmd { + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/DetachIsoCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/DetachIsoCmdByAdmin.java new file mode 100644 index 00000000000..144e3f98663 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/iso/DetachIsoCmdByAdmin.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 org.apache.cloudstack.api.command.admin.iso; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.iso.DetachIsoCmd; +import org.apache.cloudstack.api.command.user.vm.DeployVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; + +import com.cloud.uservm.UserVm; + +@APICommand(name = "detachIso", description = "Detaches any ISO file (if any) currently attached to a virtual machine.", responseObject = UserVmResponse.class, responseView = ResponseView.Full) +public class DetachIsoCmdByAdmin extends DetachIsoCmd { + public static final Logger s_logger = Logger.getLogger(DetachIsoCmdByAdmin.class.getName()); + + @Override + public void execute(){ + boolean result = _templateService.detachIso(virtualMachineId); + if (result) { + UserVm userVm = _entityMgr.findById(UserVm.class, virtualMachineId); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", userVm).get(0); + response.setResponseName(DeployVMCmd.getResultObjectName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach iso"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsoPermissionsCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsoPermissionsCmdByAdmin.java new file mode 100644 index 00000000000..613a4a7942c --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsoPermissionsCmdByAdmin.java @@ -0,0 +1,31 @@ +// Licensedname = "listIsoPermissions", 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 org.apache.cloudstack.api.command.admin.iso; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.iso.ListIsoPermissionsCmd; +import org.apache.cloudstack.api.response.TemplatePermissionsResponse; + +@APICommand(name = "listIsoPermissions", description = "List iso visibility and all accounts that have permissions to view this iso.", responseObject = TemplatePermissionsResponse.class, responseView = ResponseView.Full) +public class ListIsoPermissionsCmdByAdmin extends ListIsoPermissionsCmd { + + @Override + public void execute() { + executeWithView(ResponseView.Full); + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsosCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsosCmdByAdmin.java new file mode 100644 index 00000000000..6d87bcd4241 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsosCmdByAdmin.java @@ -0,0 +1,26 @@ +// 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 org.apache.cloudstack.api.command.admin.iso; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.iso.ListIsosCmd; +import org.apache.cloudstack.api.response.TemplateResponse; + +@APICommand(name = "listIsos", description = "Lists all available ISO files.", responseObject = TemplateResponse.class, responseView = ResponseView.Full) +public class ListIsosCmdByAdmin extends ListIsosCmd { +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/RegisterIsoCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/RegisterIsoCmdByAdmin.java new file mode 100644 index 00000000000..79687f19fed --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/iso/RegisterIsoCmdByAdmin.java @@ -0,0 +1,53 @@ +// 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 org.apache.cloudstack.api.command.admin.iso; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.TemplateResponse; + +import com.cloud.exception.ResourceAllocationException; +import com.cloud.template.VirtualMachineTemplate; + +@APICommand(name = "registerIso", responseObject = TemplateResponse.class, description = "Registers an existing ISO into the CloudStack Cloud.", responseView = ResponseView.Full) +public class RegisterIsoCmdByAdmin extends RegisterIsoCmd { + public static final Logger s_logger = Logger.getLogger(RegisterIsoCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceAllocationException{ + VirtualMachineTemplate template = _templateService.registerIso(this); + if (template != null) { + ListResponse response = new ListResponse(); + List templateResponses = _responseGenerator.createIsoResponses(ResponseView.Full, template, zoneId, false); + response.setResponses(templateResponses); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register iso"); + } + + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/UpdateIsoCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/UpdateIsoCmdByAdmin.java new file mode 100644 index 00000000000..1caf3982d4b --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/iso/UpdateIsoCmdByAdmin.java @@ -0,0 +1,45 @@ +// 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 org.apache.cloudstack.api.command.admin.iso; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd; +import org.apache.cloudstack.api.response.TemplateResponse; + +import com.cloud.template.VirtualMachineTemplate; + +@APICommand(name = "updateIso", description = "Updates an ISO file.", responseObject = TemplateResponse.class, responseView = ResponseView.Full) +public class UpdateIsoCmdByAdmin extends UpdateIsoCmd { + public static final Logger s_logger = Logger.getLogger(UpdateIsoCmdByAdmin.class.getName()); + + @Override + public void execute(){ + VirtualMachineTemplate result = _templateService.updateTemplate(this); + if (result != null) { + TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Full, result); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update iso"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/loadbalancer/ListLoadBalancerRuleInstancesCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/loadbalancer/ListLoadBalancerRuleInstancesCmdByAdmin.java new file mode 100644 index 00000000000..6c0d8a4888e --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/loadbalancer/ListLoadBalancerRuleInstancesCmdByAdmin.java @@ -0,0 +1,92 @@ +// 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 org.apache.cloudstack.api.command.admin.loadbalancer; + +import java.util.ArrayList; +import java.util.List; + +import com.cloud.vm.VirtualMachine; +import org.apache.cloudstack.api.response.LoadBalancerRuleVmMapResponse; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.loadbalancer.ListLoadBalancerRuleInstancesCmd; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.UserVmResponse; + +import com.cloud.uservm.UserVm; +import com.cloud.utils.Pair; + +@APICommand(name = "listLoadBalancerRuleInstances", description = "List all virtual machine instances that are assigned to a load balancer rule.", responseObject = LoadBalancerRuleVmMapResponse.class, responseView = ResponseView.Full) +public class ListLoadBalancerRuleInstancesCmdByAdmin extends ListLoadBalancerRuleInstancesCmd { + public static final Logger s_logger = Logger.getLogger (ListLoadBalancerRuleInstancesCmdByAdmin.class.getName()); + + + + @Override + public void execute(){ + Pair, List> vmServiceMap = _lbService.listLoadBalancerInstances(this); + List result = vmServiceMap.first(); + List serviceStates = vmServiceMap.second(); + + + if (!isListLbVmip()) { + // list lb instances + ListResponse response = new ListResponse(); + List vmResponses = new ArrayList(); + if (result != null) { + vmResponses = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "loadbalancerruleinstance", result.toArray(new UserVm[result.size()])); + + + for (int i = 0; i < result.size(); i++) { + vmResponses.get(i).setServiceState(serviceStates.get(i)); + } + } + response.setResponses(vmResponses); + response.setResponseName(getCommandName()); + setResponseObject(response); + + } else { + ListResponse lbRes = new ListResponse(); + + List vmResponses = new ArrayList(); + List listlbVmRes = new ArrayList(); + + if (result != null) { + vmResponses = _responseGenerator.createUserVmResponse(ResponseView.Full, "loadbalancerruleinstance", result.toArray(new UserVm[result.size()])); + + List ipaddr = null; + + for (int i=0;i, Integer> networks = _networkService.searchForNetworks(this); + ListResponse response = new ListResponse(); + List networkResponses = new ArrayList(); + for (Network network : networks.first()) { + NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Full, network); + networkResponses.add(networkResponse); + } + response.setResponses(networkResponses, networks.second()); + response.setResponseName(getCommandName()); + setResponseObject(response); + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListPhysicalNetworksCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ListPhysicalNetworksCmd.java index 3ac2faaacd9..e495fd6a398 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/ListPhysicalNetworksCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListPhysicalNetworksCmd.java @@ -35,7 +35,8 @@ import com.cloud.network.PhysicalNetwork; import com.cloud.user.Account; import com.cloud.utils.Pair; -@APICommand(name = "listPhysicalNetworks", description = "Lists physical networks", responseObject = PhysicalNetworkResponse.class, since = "3.0.0") +@APICommand(name = "listPhysicalNetworks", description = "Lists physical networks", responseObject = PhysicalNetworkResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListPhysicalNetworksCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListPhysicalNetworksCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListStorageNetworkIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ListStorageNetworkIpRangeCmd.java index 89cba471041..b3f8b8197a4 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/ListStorageNetworkIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListStorageNetworkIpRangeCmd.java @@ -39,7 +39,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "listStorageNetworkIpRange", description = "List a storage network IP range.", responseObject = StorageNetworkIpRangeResponse.class, since = "3.0.0") +@APICommand(name = "listStorageNetworkIpRange", description = "List a storage network IP range.", responseObject = StorageNetworkIpRangeResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListStorageNetworkIpRangeCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListStorageNetworkIpRangeCmd.class); diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ListSupportedNetworkServicesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ListSupportedNetworkServicesCmd.java index 342f9b04d88..39e99a43a6c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/ListSupportedNetworkServicesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/ListSupportedNetworkServicesCmd.java @@ -36,10 +36,12 @@ import com.cloud.user.Account; @APICommand(name = "listSupportedNetworkServices", description = "Lists all network services provided by CloudStack or for the given Provider.", responseObject = ServiceResponse.class, - since = "3.0.0") + since = "3.0.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListSupportedNetworkServicesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListSupportedNetworkServicesCmd.class.getName()); - private static final String Name = "listsupportednetworkservicesresponse"; + private static final String s_name = "listsupportednetworkservicesresponse"; @Parameter(name = ApiConstants.PROVIDER, type = CommandType.STRING, description = "network service provider name") private String providerName; @@ -72,7 +74,7 @@ public class ListSupportedNetworkServicesCmd extends BaseListCmd { ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java index 43e1149a1ec..263d46a7509 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/ReleaseDedicatedGuestVlanRangeCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "releaseDedicatedGuestVlanRange", description = "Releases a dedicated guest vlan range to the system", responseObject = SuccessResponse.class) +@APICommand(name = "releaseDedicatedGuestVlanRange", description = "Releases a dedicated guest vlan range to the system", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReleaseDedicatedGuestVlanRangeCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedGuestVlanRangeCmd.class.getName()); private static final String s_name = "releasededicatedguestvlanrangeresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkCmdByAdmin.java new file mode 100644 index 00000000000..644a0fa4cfd --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkCmdByAdmin.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 org.apache.cloudstack.api.command.admin.network; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd; +import org.apache.cloudstack.api.response.NetworkResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.network.Network; +import com.cloud.user.Account; +import com.cloud.user.User; + +@APICommand(name = "updateNetwork", description = "Updates a network", responseObject = NetworkResponse.class, responseView = ResponseView.Full) +public class UpdateNetworkCmdByAdmin extends UpdateNetworkCmd { + public static final Logger s_logger = Logger.getLogger(UpdateNetworkCmdByAdmin.class.getName()); + + + @Override + public void execute() throws InsufficientCapacityException, ConcurrentOperationException{ + User callerUser = _accountService.getActiveUser(CallContext.current().getCallingUserId()); + Account callerAccount = _accountService.getActiveAccountById(callerUser.getAccountId()); + Network network = _networkService.getNetwork(id); + if (network == null) { + throw new InvalidParameterValueException("Couldn't find network by id"); + } + + Network result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, + callerUser, getNetworkDomain(), getNetworkOfferingId(), getChangeCidr(), getGuestVmCidr(), getDisplayNetwork(), getCustomId()); + + + if (result != null) { + NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Full, result); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network"); + } + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java index 957450f78f7..411da4fd36b 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkOfferingCmd.java @@ -29,10 +29,11 @@ import org.apache.cloudstack.api.response.NetworkOfferingResponse; import com.cloud.offering.NetworkOffering; import com.cloud.user.Account; -@APICommand(name = "updateNetworkOffering", description = "Updates a network offering.", responseObject = NetworkOfferingResponse.class) +@APICommand(name = "updateNetworkOffering", description = "Updates a network offering.", responseObject = NetworkOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateNetworkOfferingCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateNetworkOfferingCmd.class.getName()); - private static final String Name = "updatenetworkofferingresponse"; + private static final String s_name = "updatenetworkofferingresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -109,7 +110,7 @@ public class UpdateNetworkOfferingCmd extends BaseCmd { ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkServiceProviderCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkServiceProviderCmd.java index c530c53b7f3..bb4f64e0400 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkServiceProviderCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateNetworkServiceProviderCmd.java @@ -36,7 +36,9 @@ import com.cloud.user.Account; @APICommand(name = "updateNetworkServiceProvider", description = "Updates a network serviceProvider of a physical network", responseObject = ProviderResponse.class, - since = "3.0.0") + since = "3.0.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class UpdateNetworkServiceProviderCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateNetworkServiceProviderCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java index f808424fc86..8e29c393813 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdatePhysicalNetworkCmd.java @@ -31,7 +31,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.PhysicalNetwork; import com.cloud.user.Account; -@APICommand(name = "updatePhysicalNetwork", description = "Updates a physical network", responseObject = PhysicalNetworkResponse.class, since = "3.0.0") +@APICommand(name = "updatePhysicalNetwork", description = "Updates a physical network", responseObject = PhysicalNetworkResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdatePhysicalNetworkCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdatePhysicalNetworkCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateStorageNetworkIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateStorageNetworkIpRangeCmd.java index 9fd084a104f..d82c28d1bff 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/network/UpdateStorageNetworkIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/network/UpdateStorageNetworkIpRangeCmd.java @@ -37,7 +37,9 @@ import com.cloud.user.Account; @APICommand(name = "updateStorageNetworkIpRange", description = "Update a Storage network IP range, only allowed when no IPs in this range have been allocated.", responseObject = StorageNetworkIpRangeResponse.class, - since = "3.0.0") + since = "3.0.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class UpdateStorageNetworkIpRangeCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateStorageNetworkIpRangeCmd.class); private static final String s_name = "updatestoragenetworkiprangeresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java index 1d959a0589b..67c97923c06 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateDiskOfferingCmd.java @@ -31,7 +31,8 @@ import com.cloud.offering.DiskOffering; import com.cloud.offering.ServiceOffering; import com.cloud.user.Account; -@APICommand(name = "createDiskOffering", description = "Creates a disk offering.", responseObject = DiskOfferingResponse.class) +@APICommand(name = "createDiskOffering", description = "Creates a disk offering.", responseObject = DiskOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateDiskOfferingCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateDiskOfferingCmd.class.getName()); @@ -92,9 +93,9 @@ public class CreateDiskOfferingCmd extends BaseCmd { private Long maxIops; @Parameter(name = ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE, - type = CommandType.INTEGER, - required = false, - description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)") + type = CommandType.INTEGER, + required = false, + description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)") private Integer hypervisorSnapshotReserve; ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java index 6f9693cbcb0..6cd5d84a07c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java @@ -17,10 +17,10 @@ package org.apache.cloudstack.api.command.admin.offering; import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.Map; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -29,14 +29,16 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ServiceOfferingResponse; +import org.apache.log4j.Logger; import com.cloud.offering.ServiceOffering; import com.cloud.user.Account; -@APICommand(name = "createServiceOffering", description = "Creates a service offering.", responseObject = ServiceOfferingResponse.class) +@APICommand(name = "createServiceOffering", description = "Creates a service offering.", responseObject = ServiceOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateServiceOfferingCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateServiceOfferingCmd.class.getName()); - private static final String Name = "createserviceofferingresponse"; + private static final String s_name = "createserviceofferingresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -102,7 +104,7 @@ public class CreateServiceOfferingCmd extends BaseCmd { private String deploymentPlanner; @Parameter(name = ApiConstants.SERVICE_OFFERING_DETAILS, type = CommandType.MAP, description = "details for planner, used to store specific parameters") - private Map details; + private Map details; @Parameter(name = ApiConstants.BYTES_READ_RATE, type = CommandType.LONG, required = false, description = "bytes read rate of the disk offering") private Long bytesReadRate; @@ -116,6 +118,22 @@ public class CreateServiceOfferingCmd extends BaseCmd { @Parameter(name = ApiConstants.IOPS_WRITE_RATE, type = CommandType.LONG, required = false, description = "io requests write rate of the disk offering") private Long iopsWriteRate; + @Parameter(name = ApiConstants.CUSTOMIZED_IOPS, type = CommandType.BOOLEAN, required = false, description = "whether compute offering iops is custom or not", since = "4.4") + private Boolean customizedIops; + + @Parameter(name = ApiConstants.MIN_IOPS, type = CommandType.LONG, required = false, description = "min iops of the compute offering", since = "4.4") + private Long minIops; + + @Parameter(name = ApiConstants.MAX_IOPS, type = CommandType.LONG, required = false, description = "max iops of the compute offering", since = "4.4") + private Long maxIops; + + @Parameter(name = ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE, + type = CommandType.INTEGER, + required = false, + description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)", + since = "4.4") + private Integer hypervisorSnapshotReserve; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -189,13 +207,17 @@ public class CreateServiceOfferingCmd extends BaseCmd { } public Map getDetails() { - if (details == null || details.isEmpty()) { - return null; + Map detailsMap = null; + if (details != null && !details.isEmpty()) { + detailsMap = new HashMap(); + Collection props = details.values(); + Iterator iter = props.iterator(); + while (iter.hasNext()) { + HashMap detail = (HashMap) iter.next(); + detailsMap.put(detail.get("key"), detail.get("value")); + } } - - Collection paramsCollection = details.values(); - Map params = (Map)(paramsCollection.toArray())[0]; - return params; + return detailsMap; } public Long getBytesReadRate() { @@ -214,13 +236,29 @@ public class CreateServiceOfferingCmd extends BaseCmd { return iopsWriteRate; } + public Boolean isCustomizedIops() { + return customizedIops; + } + + public Long getMinIops() { + return minIops; + } + + public Long getMaxIops() { + return maxIops; + } + + public Integer getHypervisorSnapshotReserve() { + return hypervisorSnapshotReserve; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteDiskOfferingCmd.java index 9845aa49e2b..8987d50066e 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteDiskOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteDiskOfferingCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "deleteDiskOffering", description = "Updates a disk offering.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteDiskOffering", description = "Updates a disk offering.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteDiskOfferingCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteDiskOfferingCmd.class.getName()); private static final String s_name = "deletediskofferingresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCmd.java index 0f81409d264..2a07fff9b15 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/offering/DeleteServiceOfferingCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "deleteServiceOffering", description = "Deletes a service offering.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteServiceOffering", description = "Deletes a service offering.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteServiceOfferingCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteServiceOfferingCmd.class.getName()); private static final String s_name = "deleteserviceofferingresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java index 6d45fb5d55d..6e1fde55a30 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.DiskOfferingResponse; import com.cloud.offering.DiskOffering; import com.cloud.user.Account; -@APICommand(name = "updateDiskOffering", description = "Updates a disk offering.", responseObject = DiskOfferingResponse.class) +@APICommand(name = "updateDiskOffering", description = "Updates a disk offering.", responseObject = DiskOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateDiskOfferingCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateDiskOfferingCmd.class.getName()); private static final String s_name = "updatediskofferingresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java index fbc88450fea..f4f4bdfac88 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateServiceOfferingCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse; import com.cloud.offering.ServiceOffering; import com.cloud.user.Account; -@APICommand(name = "updateServiceOffering", description = "Updates a service offering.", responseObject = ServiceOfferingResponse.class) +@APICommand(name = "updateServiceOffering", description = "Updates a service offering.", responseObject = ServiceOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateServiceOfferingCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateServiceOfferingCmd.class.getName()); private static final String s_name = "updateserviceofferingresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java index 835a3b98bc4..d912b44132f 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java @@ -30,7 +30,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.dc.Pod; import com.cloud.user.Account; -@APICommand(name = "createPod", description = "Creates a new Pod.", responseObject = PodResponse.class) +@APICommand(name = "createPod", description = "Creates a new Pod.", responseObject = PodResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreatePodCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreatePodCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/DeletePodCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/DeletePodCmd.java index 584eed41e7d..c2edacba353 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/pod/DeletePodCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/pod/DeletePodCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "deletePod", description = "Deletes a Pod.", responseObject = SuccessResponse.class) +@APICommand(name = "deletePod", description = "Deletes a Pod.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeletePodCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeletePodCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java index 75b5efd2fab..3cc03f24d7c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.dc.Pod; import com.cloud.utils.Pair; -@APICommand(name = "listPods", description = "Lists all Pods.", responseObject = PodResponse.class) +@APICommand(name = "listPods", description = "Lists all Pods.", responseObject = PodResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListPodsByCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListPodsByCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/pod/UpdatePodCmd.java b/api/src/org/apache/cloudstack/api/command/admin/pod/UpdatePodCmd.java index 7b8f6eb0f97..c89694c56bb 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/pod/UpdatePodCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/pod/UpdatePodCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.PodResponse; import com.cloud.dc.Pod; import com.cloud.user.Account; -@APICommand(name = "updatePod", description = "Updates a Pod.", responseObject = PodResponse.class) +@APICommand(name = "updatePod", description = "Updates a Pod.", responseObject = PodResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdatePodCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdatePodCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/AddRegionCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/AddRegionCmd.java index 9e7c035bb9d..f6743baf625 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/AddRegionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/AddRegionCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.region.RegionService; import com.cloud.user.Account; -@APICommand(name = "addRegion", description = "Adds a Region", responseObject = RegionResponse.class) +@APICommand(name = "addRegion", description = "Adds a Region", responseObject = RegionResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddRegionCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddRegionCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java index e900f47476f..955bb9c292c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/CreatePortableIpRangeCmd.java @@ -38,7 +38,9 @@ import com.cloud.user.Account; @APICommand(name = "createPortableIpRange", responseObject = PortableIpRangeResponse.class, description = "adds a range of portable public IP's to a region", - since = "4.2.0") + since = "4.2.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class CreatePortableIpRangeCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreatePortableIpRangeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/DeletePortableIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/DeletePortableIpRangeCmd.java index 5408eda5658..413818b8242 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/DeletePortableIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/DeletePortableIpRangeCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "deletePortableIpRange", description = "deletes a range of portable public IP's associated with a region", responseObject = SuccessResponse.class) +@APICommand(name = "deletePortableIpRange", description = "deletes a range of portable public IP's associated with a region", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeletePortableIpRangeCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeletePortableIpRangeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java index 42a92e62873..100572ef5ad 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/ListPortableIpRangesCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.region.PortableIpRange; import com.cloud.user.Account; -@APICommand(name = "listPortableIpRanges", description = "list portable IP ranges", responseObject = PortableIpRangeResponse.class) +@APICommand(name = "listPortableIpRanges", description = "list portable IP ranges", responseObject = PortableIpRangeResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListPortableIpRangesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListPortableIpRangesCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/RemoveRegionCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/RemoveRegionCmd.java index e9126595f9f..415456f9414 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/RemoveRegionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/RemoveRegionCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.region.RegionService; import com.cloud.user.Account; -@APICommand(name = "removeRegion", description = "Removes specified region", responseObject = SuccessResponse.class) +@APICommand(name = "removeRegion", description = "Removes specified region", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RemoveRegionCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(RemoveRegionCmd.class.getName()); private static final String s_name = "removeregionresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/UpdateRegionCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/UpdateRegionCmd.java index 527e142ee8b..b08cbbbb10c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/UpdateRegionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/UpdateRegionCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.region.RegionService; import com.cloud.user.Account; -@APICommand(name = "updateRegion", description = "Updates a region", responseObject = RegionResponse.class) +@APICommand(name = "updateRegion", description = "Updates a region", responseObject = RegionResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateRegionCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateRegionCmd.class.getName()); private static final String s_name = "updateregionresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java index b1177b9e3eb..79b3520b0b4 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/resource/ArchiveAlertsCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; -@APICommand(name = "archiveAlerts", description = "Archive one or more alerts.", responseObject = SuccessResponse.class) +@APICommand(name = "archiveAlerts", description = "Archive one or more alerts.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ArchiveAlertsCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ArchiveAlertsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/CleanVMReservationsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/CleanVMReservationsCmd.java index edc3bcf42d0..9acc71ce693 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/resource/CleanVMReservationsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/resource/CleanVMReservationsCmd.java @@ -28,7 +28,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "cleanVMReservations", description = "Cleanups VM reservations in the database.", responseObject = SuccessResponse.class) +@APICommand(name = "cleanVMReservations", description = "Cleanups VM reservations in the database.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CleanVMReservationsCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(CleanVMReservationsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java index 8ba25251a70..246b25785b3 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/resource/DeleteAlertsCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; -@APICommand(name = "deleteAlerts", description = "Delete one or more alerts.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteAlerts", description = "Delete one or more alerts.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteAlertsCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteAlertsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java index 397b00a034e..8f21263b85c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/resource/ListAlertsCmd.java @@ -30,7 +30,8 @@ import org.apache.log4j.Logger; import com.cloud.alert.Alert; import com.cloud.utils.Pair; -@APICommand(name = "listAlerts", description = "Lists all alerts.", responseObject = AlertResponse.class) +@APICommand(name = "listAlerts", description = "Lists all alerts.", responseObject = AlertResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListAlertsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListAlertsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java index 2b0f82715aa..d79ff07fbcc 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java @@ -34,7 +34,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.capacity.Capacity; import com.cloud.exception.InvalidParameterValueException; -@APICommand(name = "listCapacity", description = "Lists all the system wide capacities.", responseObject = CapacityResponse.class) +@APICommand(name = "listCapacity", description = "Lists all the system wide capacities.", responseObject = CapacityResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListCapacityCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListCapacityCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/resource/UploadCustomCertificateCmd.java b/api/src/org/apache/cloudstack/api/command/admin/resource/UploadCustomCertificateCmd.java index 68ef5accb17..e11876a6816 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/resource/UploadCustomCertificateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/resource/UploadCustomCertificateCmd.java @@ -31,7 +31,8 @@ import com.cloud.user.Account; @APICommand(name = "uploadCustomCertificate", responseObject = CustomCertificateResponse.class, - description = "Uploads a custom certificate for the console proxy VMs to use for SSL. Can be used to upload a single certificate signed by a known CA. Can also be used, through multiple calls, to upload a chain of certificates from CA to the custom certificate itself.") + description = "Uploads a custom certificate for the console proxy VMs to use for SSL. Can be used to upload a single certificate signed by a known CA. Can also be used, through multiple calls, to upload a chain of certificates from CA to the custom certificate itself.", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UploadCustomCertificateCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UploadCustomCertificateCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java index 75b08b1fab5..7577f2eb884 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureOvsElementCmd.java @@ -39,7 +39,8 @@ import com.cloud.network.OvsProvider; import com.cloud.network.element.VirtualRouterElementService; import com.cloud.user.Account; -@APICommand(name = "configureOvsElement", responseObject = OvsProviderResponse.class, description = "Configures an ovs element.") +@APICommand(name = "configureOvsElement", responseObject = OvsProviderResponse.class, description = "Configures an ovs element.", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ConfigureOvsElementCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger .getLogger(ConfigureOvsElementCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java index 2cfefda8c40..b8fafb63a6f 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/ConfigureVirtualRouterElementCmd.java @@ -40,7 +40,8 @@ import com.cloud.network.VirtualRouterProvider; import com.cloud.network.element.VirtualRouterElementService; import com.cloud.user.Account; -@APICommand(name = "configureVirtualRouterElement", responseObject = VirtualRouterProviderResponse.class, description = "Configures a virtual router element.") +@APICommand(name = "configureVirtualRouterElement", responseObject = VirtualRouterProviderResponse.class, description = "Configures a virtual router element.", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ConfigureVirtualRouterElementCmd.class.getName()); private static final String s_name = "configurevirtualrouterelementresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java index bf5eb188a01..f43b143d4ec 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/CreateVirtualRouterElementCmd.java @@ -40,7 +40,8 @@ import com.cloud.network.VirtualRouterProvider.Type; import com.cloud.network.element.VirtualRouterElementService; import com.cloud.user.Account; -@APICommand(name = "createVirtualRouterElement", responseObject = VirtualRouterProviderResponse.class, description = "Create a virtual router element.") +@APICommand(name = "createVirtualRouterElement", responseObject = VirtualRouterProviderResponse.class, description = "Create a virtual router element.", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateVirtualRouterElementCmd.class.getName()); private static final String s_name = "createvirtualrouterelementresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java index 2ad312ee282..4513e2e85e2 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/DestroyRouterCmd.java @@ -33,8 +33,10 @@ import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.router.VirtualRouter; import com.cloud.user.Account; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "destroyRouter", description = "Destroys a router.", responseObject = DomainRouterResponse.class) +@APICommand(name = "destroyRouter", description = "Destroys a router.", responseObject = DomainRouterResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DestroyRouterCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DestroyRouterCmd.class.getName()); private static final String s_name = "destroyrouterresponse"; @@ -102,7 +104,7 @@ public class DestroyRouterCmd extends BaseAsyncCmd { if (result != null) { DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy router"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ListOvsElementsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ListOvsElementsCmd.java index d5f73fd742a..75c69564188 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/ListOvsElementsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/ListOvsElementsCmd.java @@ -39,7 +39,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.OvsProvider; import com.cloud.network.element.VirtualRouterElementService; -@APICommand(name = "listOvsElements", description = "Lists all available ovs elements.", responseObject = OvsProviderResponse.class) +@APICommand(name = "listOvsElements", description = "Lists all available ovs elements.", responseObject = OvsProviderResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListOvsElementsCmd extends BaseListCmd { public static final Logger s_logger = Logger .getLogger(ListNetworkOfferingsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java index 9c91e0fb2c7..121fc5bc14d 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java @@ -34,8 +34,10 @@ import org.apache.cloudstack.api.response.VpcResponse; import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.network.router.VirtualRouter.Role; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "listRouters", description = "List routers.", responseObject = DomainRouterResponse.class) +@APICommand(name = "listRouters", description = "List routers.", responseObject = DomainRouterResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListRoutersCmd.class.getName()); @@ -148,6 +150,6 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd { public void execute() { ListResponse response = _queryService.searchForRouters(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ListVirtualRouterElementsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ListVirtualRouterElementsCmd.java index 6f1792145be..24bbf5ae2ed 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/ListVirtualRouterElementsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/ListVirtualRouterElementsCmd.java @@ -40,10 +40,11 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.VirtualRouterProvider; import com.cloud.network.element.VirtualRouterElementService; -@APICommand(name = "listVirtualRouterElements", description = "Lists all available virtual router elements.", responseObject = VirtualRouterProviderResponse.class) +@APICommand(name = "listVirtualRouterElements", description = "Lists all available virtual router elements.", responseObject = VirtualRouterProviderResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVirtualRouterElementsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListNetworkOfferingsCmd.class.getName()); - private static final String Name = "listvirtualrouterelementsresponse"; + private static final String s_name = "listvirtualrouterelementsresponse"; // TODO, VirtualRouterElementServer is not singleton in system! @Inject @@ -94,7 +95,7 @@ public class ListVirtualRouterElementsCmd extends BaseListCmd { @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java index 15527d3de36..4b138f3cfc1 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/RebootRouterCmd.java @@ -34,8 +34,10 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.router.VirtualRouter; import com.cloud.user.Account; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "rebootRouter", description = "Starts a router.", responseObject = DomainRouterResponse.class) +@APICommand(name = "rebootRouter", description = "Starts a router.", responseObject = DomainRouterResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RebootRouterCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RebootRouterCmd.class.getName()); private static final String s_name = "rebootrouterresponse"; @@ -97,11 +99,11 @@ public class RebootRouterCmd extends BaseAsyncCmd { @Override public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { CallContext.current().setEventDetails("Router Id: " + getId()); - VirtualRouter result = _routerService.rebootRouter(this.getId(), true); + VirtualRouter result = _routerService.rebootRouter(getId(), true); if (result != null) { DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result); response.setResponseName("router"); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reboot router"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java index 9196cd0dbde..173833cb42c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java @@ -36,8 +36,10 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.Role; import com.cloud.user.Account; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "startRouter", responseObject = DomainRouterResponse.class, description = "Starts a router.") +@APICommand(name = "startRouter", responseObject = DomainRouterResponse.class, description = "Starts a router.", entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class StartRouterCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(StartRouterCmd.class.getName()); private static final String s_name = "startrouterresponse"; @@ -113,7 +115,7 @@ public class StartRouterCmd extends BaseAsyncCmd { if (result != null) { DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result); routerResponse.setResponseName(getCommandName()); - this.setResponseObject(routerResponse); + setResponseObject(routerResponse); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start router"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java index ee2b9ebc83a..2592cae545a 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java @@ -35,8 +35,10 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter.Role; import com.cloud.user.Account; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "stopRouter", description = "Stops a router.", responseObject = DomainRouterResponse.class) +@APICommand(name = "stopRouter", description = "Stops a router.", responseObject = DomainRouterResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class StopRouterCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(StopRouterCmd.class.getName()); private static final String s_name = "stoprouterresponse"; @@ -116,7 +118,7 @@ public class StopRouterCmd extends BaseAsyncCmd { if (result != null) { DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop router"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterCmd.java index 04a4e6706f6..067d344337b 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterCmd.java @@ -29,8 +29,10 @@ import org.apache.cloudstack.api.response.ServiceOfferingResponse; import com.cloud.network.router.VirtualRouter; import com.cloud.user.Account; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "changeServiceForRouter", description = "Upgrades domain router to a new service offering", responseObject = DomainRouterResponse.class) +@APICommand(name = "changeServiceForRouter", description = "Upgrades domain router to a new service offering", responseObject = DomainRouterResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpgradeRouterCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpgradeRouterCmd.class.getName()); private static final String s_name = "changeserviceforrouterresponse"; @@ -86,7 +88,7 @@ public class UpgradeRouterCmd extends BaseCmd { if (router != null) { DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router); routerResponse.setResponseName(getCommandName()); - this.setResponseObject(routerResponse); + setResponseObject(routerResponse); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade router"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java index 49477452142..65d26cc7f96 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/UpgradeRouterTemplateCmd.java @@ -40,7 +40,8 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "upgradeRouterTemplate", description = "Upgrades router to use newer template", responseObject = BaseResponse.class) +@APICommand(name = "upgradeRouterTemplate", description = "Upgrades router to use newer template", responseObject = BaseResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpgradeRouterTemplateCmd extends org.apache.cloudstack.api.BaseCmd { public static final Logger s_logger = Logger.getLogger(UpgradeRouterTemplateCmd.class.getName()); private static final String s_name = "upgraderoutertemplateresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/AddImageStoreCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/AddImageStoreCmd.java index 5e5bd3dcde5..6b673cf6322 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/AddImageStoreCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/AddImageStoreCmd.java @@ -36,7 +36,8 @@ import com.cloud.exception.DiscoveryException; import com.cloud.storage.ImageStore; import com.cloud.user.Account; -@APICommand(name = "addImageStore", description = "Adds backup image store.", responseObject = ImageStoreResponse.class, since = "4.2.0") +@APICommand(name = "addImageStore", description = "Adds backup image store.", responseObject = ImageStoreResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddImageStoreCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddImageStoreCmd.class.getName()); private static final String s_name = "addimagestoreresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java index 32897e4d59d..4164394f5ec 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/AddS3Cmd.java @@ -52,11 +52,12 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.storage.ImageStore; -@APICommand(name = "addS3", description = "Adds S3", responseObject = ImageStoreResponse.class, since = "4.0.0") +@APICommand(name = "addS3", description = "Adds S3", responseObject = ImageStoreResponse.class, since = "4.0.0", + requestHasSensitiveInfo = true, responseHasSensitiveInfo = false) public final class AddS3Cmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddS3Cmd.class.getName()); - private static final String COMMAND_NAME = "adds3response"; + private static final String s_name = "adds3response"; @Parameter(name = S3_ACCESS_KEY, type = STRING, required = true, description = "S3 access key") private String accessKey; @@ -189,7 +190,7 @@ public final class AddS3Cmd extends BaseCmd { @Override public String getCommandName() { - return COMMAND_NAME; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java index b1c55944638..91348ecf6b0 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/CancelPrimaryStorageMaintenanceCmd.java @@ -33,7 +33,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.storage.StoragePool; import com.cloud.user.Account; -@APICommand(name = "cancelStorageMaintenance", description = "Cancels maintenance for primary storage", responseObject = StoragePoolResponse.class) +@APICommand(name = "cancelStorageMaintenance", description = "Cancels maintenance for primary storage", responseObject = StoragePoolResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(CancelPrimaryStorageMaintenanceCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/CreateSecondaryStagingStoreCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/CreateSecondaryStagingStoreCmd.java index 1480e75c063..39ec6098516 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/CreateSecondaryStagingStoreCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/CreateSecondaryStagingStoreCmd.java @@ -37,7 +37,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.storage.ImageStore; import com.cloud.user.Account; -@APICommand(name = "createSecondaryStagingStore", description = "create secondary staging store.", responseObject = ImageStoreResponse.class) +@APICommand(name = "createSecondaryStagingStore", description = "create secondary staging store.", responseObject = ImageStoreResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateSecondaryStagingStoreCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddImageStoreCmd.class.getName()); private static final String s_name = "createsecondarystagingstoreresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java index dfd00266835..ae44bc93732 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/CreateStoragePoolCmd.java @@ -38,7 +38,8 @@ import com.cloud.storage.StoragePool; import com.cloud.user.Account; @SuppressWarnings("rawtypes") -@APICommand(name = "createStoragePool", description = "Creates a storage pool.", responseObject = StoragePoolResponse.class) +@APICommand(name = "createStoragePool", description = "Creates a storage pool.", responseObject = StoragePoolResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateStoragePoolCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateStoragePoolCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/DeleteImageStoreCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/DeleteImageStoreCmd.java index 602da8350e9..669c0ec7b81 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/DeleteImageStoreCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/DeleteImageStoreCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "deleteImageStore", description = "Deletes an image store .", responseObject = SuccessResponse.class, since = "4.2.0") +@APICommand(name = "deleteImageStore", description = "Deletes an image store .", responseObject = SuccessResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteImageStoreCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteImageStoreCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/DeletePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/DeletePoolCmd.java index fb63daa51d2..5465fd1440f 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/DeletePoolCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/DeletePoolCmd.java @@ -31,7 +31,8 @@ import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolStatus; import com.cloud.user.Account; -@APICommand(name = "deleteStoragePool", description = "Deletes a storage pool.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteStoragePool", description = "Deletes a storage pool.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeletePoolCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeletePoolCmd.class.getName()); private static final String s_name = "deletestoragepoolresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/DeleteSecondaryStagingStoreCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/DeleteSecondaryStagingStoreCmd.java index caf937fed00..16398623359 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/DeleteSecondaryStagingStoreCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/DeleteSecondaryStagingStoreCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "deleteSecondaryStagingStore", description = "Deletes a secondary staging store .", responseObject = SuccessResponse.class, since = "4.2.0") +@APICommand(name = "deleteSecondaryStagingStore", description = "Deletes a secondary staging store .", responseObject = SuccessResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteSecondaryStagingStoreCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteSecondaryStagingStoreCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/FindStoragePoolsForMigrationCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/FindStoragePoolsForMigrationCmd.java index 10813cadc04..47fa965e7dd 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/FindStoragePoolsForMigrationCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/FindStoragePoolsForMigrationCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.api.response.VolumeResponse; import com.cloud.storage.StoragePool; import com.cloud.utils.Pair; -@APICommand(name = "findStoragePoolsForMigration", description = "Lists storage pools available for migration of a volume.", responseObject = StoragePoolResponse.class) +@APICommand(name = "findStoragePoolsForMigration", description = "Lists storage pools available for migration of a volume.", responseObject = StoragePoolResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class FindStoragePoolsForMigrationCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(FindStoragePoolsForMigrationCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListImageStoresCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListImageStoresCmd.java index bf470844e68..8c37c78c763 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/ListImageStoresCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListImageStoresCmd.java @@ -26,7 +26,8 @@ import org.apache.cloudstack.api.response.ImageStoreResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ZoneResponse; -@APICommand(name = "listImageStores", description = "Lists image stores.", responseObject = ImageStoreResponse.class, since = "4.2.0") +@APICommand(name = "listImageStores", description = "Lists image stores.", responseObject = ImageStoreResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListImageStoresCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListImageStoresCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListS3sCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListS3sCmd.java index 362d69ef6fc..c1889e72a0b 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/ListS3sCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListS3sCmd.java @@ -30,7 +30,8 @@ import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; -@APICommand(name = "listS3s", description = "Lists S3s", responseObject = ImageStoreResponse.class, since = "4.0.0") +@APICommand(name = "listS3s", description = "Lists S3s", responseObject = ImageStoreResponse.class, since = "4.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListS3sCmd extends BaseListCmd { private static final String COMMAND_NAME = "lists3sresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListSecondaryStagingStoresCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListSecondaryStagingStoresCmd.java index 171f9714aef..e315c8a6d47 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/ListSecondaryStagingStoresCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListSecondaryStagingStoresCmd.java @@ -26,7 +26,8 @@ import org.apache.cloudstack.api.response.ImageStoreResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ZoneResponse; -@APICommand(name = "listSecondaryStagingStores", description = "Lists secondary staging stores.", responseObject = ImageStoreResponse.class, since = "4.2.0") +@APICommand(name = "listSecondaryStagingStores", description = "Lists secondary staging stores.", responseObject = ImageStoreResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListSecondaryStagingStoresCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListSecondaryStagingStoresCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java index 868b402b9db..ed123dbb6c3 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.PodResponse; import org.apache.cloudstack.api.response.StoragePoolResponse; import org.apache.cloudstack.api.response.ZoneResponse; -@APICommand(name = "listStoragePools", description = "Lists storage pools.", responseObject = StoragePoolResponse.class) +@APICommand(name = "listStoragePools", description = "Lists storage pools.", responseObject = StoragePoolResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListStoragePoolsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListStoragePoolsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/ListStorageProvidersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStorageProvidersCmd.java index bac6b7c46ac..3e960ee84a8 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/ListStorageProvidersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/ListStorageProvidersCmd.java @@ -37,7 +37,8 @@ import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; -@APICommand(name = "listStorageProviders", description = "Lists storage providers.", responseObject = StorageProviderResponse.class) +@APICommand(name = "listStorageProviders", description = "Lists storage providers.", responseObject = StorageProviderResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListStorageProvidersCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListStorageProvidersCmd.class.getName()); private static final String s_name = "liststorageprovidersresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java index 9d1196648ce..cf5fdf66c64 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/PreparePrimaryStorageForMaintenanceCmd.java @@ -34,7 +34,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.storage.StoragePool; import com.cloud.user.Account; -@APICommand(name = "enableStorageMaintenance", description = "Puts storage pool into maintenance state", responseObject = StoragePoolResponse.class) +@APICommand(name = "enableStorageMaintenance", description = "Puts storage pool into maintenance state", responseObject = StoragePoolResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(PreparePrimaryStorageForMaintenanceCmd.class.getName()); private static final String s_name = "prepareprimarystorageformaintenanceresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateCloudToUseObjectStoreCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateCloudToUseObjectStoreCmd.java index 983a01c7fbe..a99c5e5d75c 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateCloudToUseObjectStoreCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateCloudToUseObjectStoreCmd.java @@ -35,7 +35,8 @@ import com.cloud.exception.DiscoveryException; import com.cloud.storage.ImageStore; import com.cloud.user.Account; -@APICommand(name = "updateCloudToUseObjectStore", description = "Migrate current NFS secondary storages to use object store.", responseObject = ImageStoreResponse.class, since = "4.3.0") +@APICommand(name = "updateCloudToUseObjectStore", description = "Migrate current NFS secondary storages to use object store.", responseObject = ImageStoreResponse.class, since = "4.3.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateCloudToUseObjectStoreCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateCloudToUseObjectStoreCmd.class.getName()); private static final String s_name = "updatecloudtouseobjectstoreresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java index 50be6ba13f7..3d1a7735325 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.StoragePoolResponse; import com.cloud.storage.StoragePool; import com.cloud.user.Account; -@APICommand(name = "updateStoragePool", description = "Updates a storage pool.", responseObject = StoragePoolResponse.class, since = "3.0.0") +@APICommand(name = "updateStoragePool", description = "Updates a storage pool.", responseObject = StoragePoolResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateStoragePoolCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateStoragePoolCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/swift/AddSwiftCmd.java b/api/src/org/apache/cloudstack/api/command/admin/swift/AddSwiftCmd.java index 173c95e2c0d..19a84252dd7 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/swift/AddSwiftCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/swift/AddSwiftCmd.java @@ -33,7 +33,8 @@ import com.cloud.exception.DiscoveryException; import com.cloud.storage.ImageStore; import com.cloud.user.Account; -@APICommand(name = "addSwift", description = "Adds Swift.", responseObject = ImageStoreResponse.class, since = "3.0.0") +@APICommand(name = "addSwift", description = "Adds Swift.", responseObject = ImageStoreResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddSwiftCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddSwiftCmd.class.getName()); private static final String s_name = "addswiftresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java index fcc8e465903..f80cfab4bdd 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/swift/ListSwiftsCmd.java @@ -28,7 +28,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.user.Account; -@APICommand(name = "listSwifts", description = "List Swift.", responseObject = ImageStoreResponse.class, since = "3.0.0") +@APICommand(name = "listSwifts", description = "List Swift.", responseObject = ImageStoreResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListSwiftsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListSwiftsCmd.class.getName()); private static final String s_name = "listswiftsresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java index 07e111cbccd..47dfe8b7241 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.admin.systemvm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -32,12 +34,14 @@ import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.vm.VirtualMachine; -@APICommand(name = "destroySystemVm", responseObject = SystemVmResponse.class, description = "Destroyes a system virtual machine.") +@APICommand(name = "destroySystemVm", responseObject = SystemVmResponse.class, description = "Destroyes a system virtual machine.", entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DestroySystemVmCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DestroySystemVmCmd.class.getName()); private static final String s_name = "destroysystemvmresponse"; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class, @@ -100,7 +104,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd { if (instance != null) { SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to destroy system vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java index 9480497cdd5..2b2faf50113 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java @@ -36,7 +36,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.utils.Pair; import com.cloud.vm.VirtualMachine; -@APICommand(name = "listSystemVms", description = "List system virtual machines.", responseObject = SystemVmResponse.class) +@APICommand(name = "listSystemVms", description = "List system virtual machines.", responseObject = SystemVmResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListSystemVMsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListSystemVMsCmd.class.getName()); @@ -139,6 +140,6 @@ public class ListSystemVMsCmd extends BaseListCmd { response.setResponses(vmResponses, systemVMs.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java index 8199e683caf..97acfe0c46a 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.admin.systemvm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -38,7 +40,8 @@ import com.cloud.host.Host; import com.cloud.user.Account; import com.cloud.vm.VirtualMachine; -@APICommand(name = "migrateSystemVm", description = "Attempts Migration of a system virtual machine to the host specified.", responseObject = SystemVmResponse.class) +@APICommand(name = "migrateSystemVm", description = "Attempts Migration of a system virtual machine to the host specified.", responseObject = SystemVmResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class MigrateSystemVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(MigrateSystemVMCmd.class.getName()); @@ -55,6 +58,7 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd { description = "destination Host ID to migrate VM to") private Long hostId; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = SystemVmResponse.class, @@ -118,7 +122,7 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd { // return the generic system VM instance response SystemVmResponse response = _responseGenerator.createSystemVmResponse(migratedVm); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate the system vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java index 1c38b056f04..f439ddf4def 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.admin.systemvm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -32,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.vm.VirtualMachine; -@APICommand(name = "rebootSystemVm", description = "Reboots a system VM.", responseObject = SystemVmResponse.class) +@APICommand(name = "rebootSystemVm", description = "Reboots a system VM.", responseObject = SystemVmResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RebootSystemVmCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RebootSystemVmCmd.class.getName()); @@ -41,7 +44,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class, @@ -108,7 +111,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd { if (result != null) { SystemVmResponse response = _responseGenerator.createSystemVmResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java index 370815d625c..68e9f94a8ba 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java @@ -21,6 +21,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -31,7 +35,6 @@ import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd; import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.SystemVmResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; @@ -44,7 +47,8 @@ import com.cloud.user.Account; import com.cloud.vm.VirtualMachine; @APICommand(name = "scaleSystemVm", responseObject = SystemVmResponse.class, description = "Scale the service offering for a system vm (console proxy or secondary storage). " - + "The system vm must be in a \"Stopped\" state for " + "this command to take effect.") + + "The system vm must be in a \"Stopped\" state for " + "this command to take effect.", entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ScaleSystemVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpgradeVMCmd.class.getName()); private static final String s_name = "changeserviceforsystemvmresponse"; @@ -53,6 +57,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class, required = true, description = "The ID of the system vm") private Long id; diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java index 2e65928af68..c456592d105 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.admin.systemvm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -32,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.vm.VirtualMachine; -@APICommand(name = "startSystemVm", responseObject = SystemVmResponse.class, description = "Starts a system virtual machine.") +@APICommand(name = "startSystemVm", responseObject = SystemVmResponse.class, description = "Starts a system virtual machine.", entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class StartSystemVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(StartSystemVMCmd.class.getName()); @@ -41,7 +44,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class, @@ -112,7 +115,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd { if (instance != null) { SystemVmResponse response = _responseGenerator.createSystemVmResponse(instance); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to start system vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java index 7709ebe5cfe..d60460ced1e 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.admin.systemvm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -34,7 +36,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.vm.VirtualMachine; -@APICommand(name = "stopSystemVm", description = "Stops a system VM.", responseObject = SystemVmResponse.class) +@APICommand(name = "stopSystemVm", description = "Stops a system VM.", responseObject = SystemVmResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class StopSystemVmCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(StopSystemVmCmd.class.getName()); @@ -44,6 +47,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class, @@ -117,7 +121,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd { if (result != null) { SystemVmResponse response = _responseGenerator.createSystemVmResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to stop system vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java index da0564e9e67..d71ef03244b 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java @@ -21,6 +21,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -31,7 +35,6 @@ import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd; import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.SystemVmResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.exception.InvalidParameterValueException; import com.cloud.offering.ServiceOffering; @@ -39,7 +42,8 @@ import com.cloud.user.Account; import com.cloud.vm.VirtualMachine; @APICommand(name = "changeServiceForSystemVm", responseObject = SystemVmResponse.class, description = "Changes the service offering for a system vm (console proxy or secondary storage). " - + "The system vm must be in a \"Stopped\" state for " + "this command to take effect.") + + "The system vm must be in a \"Stopped\" state for " + "this command to take effect.", entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpgradeSystemVMCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpgradeVMCmd.class.getName()); private static final String s_name = "changeserviceforsystemvmresponse"; @@ -48,6 +52,7 @@ public class UpgradeSystemVMCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class, required = true, description = "The ID of the system vm") private Long id; diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/CopyTemplateCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/CopyTemplateCmdByAdmin.java new file mode 100644 index 00000000000..c6a5ee753d9 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/template/CopyTemplateCmdByAdmin.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 org.apache.cloudstack.api.command.admin.template; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd; +import org.apache.cloudstack.api.response.TemplateResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.StorageUnavailableException; +import com.cloud.template.VirtualMachineTemplate; + +@APICommand(name = "copyTemplate", description = "Copies a template from one zone to another.", responseObject = TemplateResponse.class, responseView = ResponseView.Full) +public class CopyTemplateCmdByAdmin extends CopyTemplateCmd { + public static final Logger s_logger = Logger.getLogger(CopyTemplateCmdByAdmin.class.getName()); + + @Override + public void execute() throws ResourceAllocationException{ + try { + CallContext.current().setEventDetails(getEventDescription()); + VirtualMachineTemplate template = _templateService.copyTemplate(this); + + if (template != null){ + List listResponse = _responseGenerator.createTemplateResponses(ResponseView.Full, template, getDestinationZoneId(), false); + TemplateResponse response = new TemplateResponse(); + if (listResponse != null && !listResponse.isEmpty()) { + response = listResponse.get(0); + } + + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to copy template"); + } + } catch (StorageUnavailableException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); + } + } +} + diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/CreateTemplateCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/CreateTemplateCmdByAdmin.java new file mode 100644 index 00000000000..d316278aa32 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/template/CreateTemplateCmdByAdmin.java @@ -0,0 +1,62 @@ +// 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 org.apache.cloudstack.api.command.admin.template; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd; +import org.apache.cloudstack.api.response.TemplateResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.template.VirtualMachineTemplate; + +@APICommand(name = "createTemplate", responseObject = TemplateResponse.class, description = "Creates a template of a virtual machine. " + "The virtual machine must be in a STOPPED state. " + + "A template created from this command is automatically designated as a private template visible to the account that created it.", responseView = ResponseView.Full) +public class CreateTemplateCmdByAdmin extends CreateTemplateCmd { + public static final Logger s_logger = Logger.getLogger(CreateTemplateCmdByAdmin.class.getName()); + + @Override + public void execute() { + CallContext.current().setEventDetails("Template Id: "+getEntityId()+((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId())); + VirtualMachineTemplate template = null; + template = _templateService.createPrivateTemplate(this); + + if (template != null){ + List templateResponses; + if (isBareMetal()) { + templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template.getId(), vmId); + } else { + templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template.getId(), snapshotId, volumeId, false); + } + TemplateResponse response = new TemplateResponse(); + if (templateResponses != null && !templateResponses.isEmpty()) { + response = templateResponses.get(0); + } + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private template"); + } + + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatePermissionsCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatePermissionsCmdByAdmin.java new file mode 100644 index 00000000000..1b6fbab3605 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatePermissionsCmdByAdmin.java @@ -0,0 +1,32 @@ +// Licensedname = "listTemplatePermissions", 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 org.apache.cloudstack.api.command.admin.template; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.template.ListTemplatePermissionsCmd; +import org.apache.cloudstack.api.response.TemplatePermissionsResponse; + +@APICommand(name = "listTemplatePermissions", description = "List template visibility and all accounts that have permissions to view this template.", responseObject = TemplatePermissionsResponse.class, responseView = ResponseView.Full) +public class ListTemplatePermissionsCmdByAdmin extends ListTemplatePermissionsCmd { + + @Override + public void execute() { + executeWithView(ResponseView.Full); + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatesCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatesCmdByAdmin.java new file mode 100644 index 00000000000..4e2bb018d07 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatesCmdByAdmin.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 org.apache.cloudstack.api.command.admin.template; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.template.ListTemplatesCmd; +import org.apache.cloudstack.api.response.TemplateResponse; + +import com.cloud.template.VirtualMachineTemplate; + +@APICommand(name = "listTemplates", description = "List all public, private, and privileged templates.", responseObject = TemplateResponse.class, entityType = {VirtualMachineTemplate.class}, responseView = ResponseView.Full) +public class ListTemplatesCmdByAdmin extends ListTemplatesCmd { + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java index 16761bab373..d4c26966d91 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java @@ -20,10 +20,13 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.ZoneResponse; @@ -31,7 +34,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "prepareTemplate", responseObject = TemplateResponse.class, description = "load template into primary storage") +@APICommand(name = "prepareTemplate", responseObject = TemplateResponse.class, description = "load template into primary storage", entityType = {VirtualMachineTemplate.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class PrepareTemplateCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(PrepareTemplateCmd.class.getName()); @@ -48,6 +52,7 @@ public class PrepareTemplateCmd extends BaseCmd { description = "zone ID of the template to be prepared in primary storage(s).") private Long zoneId; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, @@ -86,9 +91,9 @@ public class PrepareTemplateCmd extends BaseCmd { ListResponse response = new ListResponse(); VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId); - List templateResponses = _responseGenerator.createTemplateResponses(vmTemplate, zoneId, true); + List templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, vmTemplate, zoneId, true); response.setResponses(templateResponses); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/RegisterTemplateCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/RegisterTemplateCmdByAdmin.java new file mode 100644 index 00000000000..c6239383d13 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/template/RegisterTemplateCmdByAdmin.java @@ -0,0 +1,57 @@ +// 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 org.apache.cloudstack.api.command.admin.template; + +import java.net.URISyntaxException; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.TemplateResponse; + +import com.cloud.exception.ResourceAllocationException; +import com.cloud.template.VirtualMachineTemplate; + +@APICommand(name = "registerTemplate", description = "Registers an existing template into the CloudStack cloud. ", responseObject = TemplateResponse.class, responseView = ResponseView.Full) +public class RegisterTemplateCmdByAdmin extends RegisterTemplateCmd { + public static final Logger s_logger = Logger.getLogger(RegisterTemplateCmdByAdmin.class.getName()); + + @Override + public void execute() throws ResourceAllocationException{ + try { + VirtualMachineTemplate template = _templateService.registerTemplate(this); + if (template != null){ + ListResponse response = new ListResponse(); + List templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template, zoneId, false); + response.setResponses(templateResponses); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register template"); + } + } catch (URISyntaxException ex1) { + s_logger.info(ex1); + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex1.getMessage()); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/UpdateTemplateCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/UpdateTemplateCmdByAdmin.java new file mode 100644 index 00000000000..6587020b1d3 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/template/UpdateTemplateCmdByAdmin.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 org.apache.cloudstack.api.command.admin.template; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd; +import org.apache.cloudstack.api.response.TemplateResponse; + +import com.cloud.template.VirtualMachineTemplate; + +@APICommand(name = "updateTemplate", description = "Updates attributes of a template.", responseObject = TemplateResponse.class, responseView = ResponseView.Full) +public class UpdateTemplateCmdByAdmin extends UpdateTemplateCmd { + public static final Logger s_logger = Logger.getLogger(UpdateTemplateCmdByAdmin.class.getName()); + + @Override + public void execute(){ + VirtualMachineTemplate result = _templateService.updateTemplate(this); + if (result != null) { + TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Full, result); + response.setObjectName("template"); + response.setTemplateType(result.getTemplateType().toString());//Template can be either USER or ROUTING type + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update template"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficMonitorCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficMonitorCmd.java index 031fc8d752a..e0d755518f9 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficMonitorCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficMonitorCmd.java @@ -32,7 +32,8 @@ import com.cloud.host.Host; import com.cloud.user.Account; import com.cloud.utils.exception.CloudRuntimeException; -@APICommand(name = "addTrafficMonitor", description = "Adds Traffic Monitor Host for Direct Network Usage", responseObject = TrafficMonitorResponse.class) +@APICommand(name = "addTrafficMonitor", description = "Adds Traffic Monitor Host for Direct Network Usage", responseObject = TrafficMonitorResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddTrafficMonitorCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AddTrafficMonitorCmd.class.getName()); private static final String s_name = "addtrafficmonitorresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java index 0fcb8f87e54..a71d5bb6c26 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/AddTrafficTypeCmd.java @@ -34,7 +34,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.network.PhysicalNetworkTrafficType; import com.cloud.user.Account; -@APICommand(name = "addTrafficType", description = "Adds traffic type to a physical network", responseObject = TrafficTypeResponse.class, since = "3.0.0") +@APICommand(name = "addTrafficType", description = "Adds traffic type to a physical network", responseObject = TrafficTypeResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddTrafficTypeCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(AddTrafficTypeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/DeleteTrafficMonitorCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/DeleteTrafficMonitorCmd.java index debaf0030f1..4c2bac23a17 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/DeleteTrafficMonitorCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/DeleteTrafficMonitorCmd.java @@ -30,7 +30,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; -@APICommand(name = "deleteTrafficMonitor", description = "Deletes an traffic monitor host.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteTrafficMonitor", description = "Deletes an traffic monitor host.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteTrafficMonitorCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteTrafficMonitorCmd.class.getName()); private static final String s_name = "deletetrafficmonitorresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/DeleteTrafficTypeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/DeleteTrafficTypeCmd.java index 111e1774268..46383cca725 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/DeleteTrafficTypeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/DeleteTrafficTypeCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.TrafficTypeResponse; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "deleteTrafficType", description = "Deletes traffic type of a physical network", responseObject = SuccessResponse.class, since = "3.0.0") +@APICommand(name = "deleteTrafficType", description = "Deletes traffic type of a physical network", responseObject = SuccessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteTrafficTypeCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteTrafficTypeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/GenerateUsageRecordsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/GenerateUsageRecordsCmd.java index 4fc36ab5582..184f88aed24 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/GenerateUsageRecordsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/GenerateUsageRecordsCmd.java @@ -33,7 +33,9 @@ import com.cloud.user.Account; @APICommand(name = "generateUsageRecords", description = "Generates usage records. This will generate records only if there any records to be generated, i.e if the scheduled usage job was not run or failed", - responseObject = SuccessResponse.class) + responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class GenerateUsageRecordsCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(GenerateUsageRecordsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java index a8bd1e52358..21a7e4a1b06 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/GetUsageRecordsCmd.java @@ -35,7 +35,8 @@ import org.apache.cloudstack.usage.Usage; import com.cloud.utils.Pair; -@APICommand(name = "listUsageRecords", description = "Lists usage records for accounts", responseObject = UsageRecordResponse.class) +@APICommand(name = "listUsageRecords", description = "Lists usage records for accounts", responseObject = UsageRecordResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class GetUsageRecordsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(GetUsageRecordsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficMonitorsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficMonitorsCmd.java index 3592539aab4..4c398633f14 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficMonitorsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficMonitorsCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.host.Host; -@APICommand(name = "listTrafficMonitors", description = "List traffic monitor Hosts.", responseObject = TrafficMonitorResponse.class) +@APICommand(name = "listTrafficMonitors", description = "List traffic monitor Hosts.", responseObject = TrafficMonitorResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListTrafficMonitorsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName()); private static final String s_name = "listtrafficmonitorsresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypeImplementorsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypeImplementorsCmd.java index 159608ec589..bd634bbe5c2 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypeImplementorsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypeImplementorsCmd.java @@ -40,10 +40,12 @@ import com.cloud.utils.Pair; @APICommand(name = "listTrafficTypeImplementors", description = "Lists implementors of implementor of a network traffic type or implementors of all network traffic types", responseObject = TrafficTypeImplementorResponse.class, - since = "3.0.0") + since = "3.0.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListTrafficTypeImplementorsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListTrafficTypeImplementorsCmd.class); - private static final String Name = "listtraffictypeimplementorsresponse"; + private static final String s_name = "listtraffictypeimplementorsresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -87,6 +89,6 @@ public class ListTrafficTypeImplementorsCmd extends BaseListCmd { @Override public String getCommandName() { - return Name; + return s_name; } } diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java index 47ba781cdef..fd0635959b8 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/ListTrafficTypesCmd.java @@ -34,10 +34,11 @@ import com.cloud.network.PhysicalNetworkTrafficType; import com.cloud.user.Account; import com.cloud.utils.Pair; -@APICommand(name = "listTrafficTypes", description = "Lists traffic types of a given physical network.", responseObject = ProviderResponse.class, since = "3.0.0") +@APICommand(name = "listTrafficTypes", description = "Lists traffic types of a given physical network.", responseObject = ProviderResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListTrafficTypesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListTrafficTypesCmd.class.getName()); - private static final String Name = "listtraffictypesresponse"; + private static final String s_name = "listtraffictypesresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -66,7 +67,7 @@ public class ListTrafficTypesCmd extends BaseListCmd { ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/ListUsageTypesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/ListUsageTypesCmd.java index b5e445bbb53..2c5a7866cbb 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/ListUsageTypesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/ListUsageTypesCmd.java @@ -27,7 +27,8 @@ import org.apache.cloudstack.api.response.UsageTypeResponse; import com.cloud.user.Account; -@APICommand(name = "listUsageTypes", description = "List Usage Types", responseObject = UsageTypeResponse.class) +@APICommand(name = "listUsageTypes", description = "List Usage Types", responseObject = UsageTypeResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListUsageTypesCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ListUsageTypesCmd.class.getName()); private static final String s_name = "listusagetypesresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/usage/UpdateTrafficTypeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/usage/UpdateTrafficTypeCmd.java index 2ad470ea761..3de8905fa95 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/usage/UpdateTrafficTypeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/usage/UpdateTrafficTypeCmd.java @@ -31,7 +31,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.PhysicalNetworkTrafficType; import com.cloud.user.Account; -@APICommand(name = "updateTrafficType", description = "Updates traffic type of a physical network", responseObject = TrafficTypeResponse.class, since = "3.0.0") +@APICommand(name = "updateTrafficType", description = "Updates traffic type of a physical network", responseObject = TrafficTypeResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateTrafficTypeCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateTrafficTypeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java index 03512db321a..51e218d7de8 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java @@ -16,8 +16,6 @@ // under the License. package org.apache.cloudstack.api.command.admin.user; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -27,11 +25,13 @@ import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.UserResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.user.Account; import com.cloud.user.User; -@APICommand(name = "createUser", description = "Creates a user for an account that already exists", responseObject = UserResponse.class) +@APICommand(name = "createUser", description = "Creates a user for an account that already exists", responseObject = UserResponse.class, + requestHasSensitiveInfo = true, responseHasSensitiveInfo = true) public class CreateUserCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateUserCmd.class.getName()); @@ -131,7 +131,7 @@ public class CreateUserCmd extends BaseCmd { @Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); - if ((account == null) || isAdmin(account.getType())) { + if ((account == null) || _accountService.isAdmin(account.getType())) { if ((domainId != null) && (accountName != null)) { Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); if (userAccount != null) { diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/DeleteUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/DeleteUserCmd.java index 6ba382aec71..08ba521ed62 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/DeleteUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/DeleteUserCmd.java @@ -34,7 +34,8 @@ import org.apache.cloudstack.region.RegionService; import com.cloud.user.Account; import com.cloud.user.User; -@APICommand(name = "deleteUser", description = "Deletes a user for an account", responseObject = SuccessResponse.class) +@APICommand(name = "deleteUser", description = "Deletes a user for an account", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteUserCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteUserCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/DisableUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/DisableUserCmd.java index 599328d1c35..c6e09ef0f9e 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/DisableUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/DisableUserCmd.java @@ -36,7 +36,8 @@ import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.user.UserAccount; -@APICommand(name = "disableUser", description = "Disables a user account", responseObject = UserResponse.class) +@APICommand(name = "disableUser", description = "Disables a user account", responseObject = UserResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class DisableUserCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DisableUserCmd.class.getName()); private static final String s_name = "disableuserresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/EnableUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/EnableUserCmd.java index 8d37eda36e9..d69eccf9342 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/EnableUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/EnableUserCmd.java @@ -34,7 +34,8 @@ import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.user.UserAccount; -@APICommand(name = "enableUser", description = "Enables a user account", responseObject = UserResponse.class) +@APICommand(name = "enableUser", description = "Enables a user account", responseObject = UserResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class EnableUserCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(EnableUserCmd.class.getName()); private static final String s_name = "enableuserresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/GetUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/GetUserCmd.java index 592b8285727..b2c6734c9e6 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/GetUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/GetUserCmd.java @@ -27,7 +27,8 @@ import org.apache.cloudstack.api.response.UserResponse; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.UserAccount; -@APICommand(name = "getUser", description = "Find user account by API key", responseObject = UserResponse.class) +@APICommand(name = "getUser", description = "Find user account by API key", responseObject = UserResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class GetUserCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(GetUserCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java index 41d6acda1f4..c0c2b24814a 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/ListUsersCmd.java @@ -25,7 +25,8 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.UserResponse; -@APICommand(name = "listUsers", description = "Lists user accounts", responseObject = UserResponse.class) +@APICommand(name = "listUsers", description = "Lists user accounts", responseObject = UserResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class ListUsersCmd extends BaseListAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListUsersCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/LockUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/LockUserCmd.java index 9533004907f..69623d013d4 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/LockUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/LockUserCmd.java @@ -30,7 +30,8 @@ import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.user.UserAccount; -@APICommand(name = "lockUser", description = "Locks a user account", responseObject = UserResponse.class) +@APICommand(name = "lockUser", description = "Locks a user account", responseObject = UserResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class LockUserCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(LockUserCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java index facdc876759..2090d21e4a6 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/RegisterCmd.java @@ -30,7 +30,8 @@ import com.cloud.user.User; @APICommand(name = "registerUserKeys", responseObject = RegisterResponse.class, - description = "This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user") + description = "This command allows a user to register for the developer API, returning a secret key and an API key. This request is made through the integration API port, so it is a privileged command and must be made on behalf of a user. It is up to the implementer just how the username and password are entered, and then how that translates to an integration API request. Both secret key and API key should be returned to the user", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class RegisterCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(RegisterCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java index de6e550018a..cf5d355e260 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/UpdateUserCmd.java @@ -34,7 +34,8 @@ import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.user.UserAccount; -@APICommand(name = "updateUser", description = "Updates a user account", responseObject = UserResponse.class) +@APICommand(name = "updateUser", description = "Updates a user account", responseObject = UserResponse.class, + requestHasSensitiveInfo = true, responseHasSensitiveInfo = true) public class UpdateUserCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateUserCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java index cd3dd7ea9bf..75edfce3f96 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java @@ -39,7 +39,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "createVlanIpRange", description = "Creates a VLAN IP range.", responseObject = VlanIpRangeResponse.class) +@APICommand(name = "createVlanIpRange", description = "Creates a VLAN IP range.", responseObject = VlanIpRangeResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVlanIpRangeCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateVlanIpRangeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vlan/DedicatePublicIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vlan/DedicatePublicIpRangeCmd.java index 2650482e9bb..2cba8e69e45 100755 --- a/api/src/org/apache/cloudstack/api/command/admin/vlan/DedicatePublicIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vlan/DedicatePublicIpRangeCmd.java @@ -33,7 +33,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "dedicatePublicIpRange", description = "Dedicates a Public IP range to an account", responseObject = VlanIpRangeResponse.class) +@APICommand(name = "dedicatePublicIpRange", description = "Dedicates a Public IP range to an account", responseObject = VlanIpRangeResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DedicatePublicIpRangeCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DedicatePublicIpRangeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vlan/DeleteVlanIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vlan/DeleteVlanIpRangeCmd.java index 8d291309f4d..af32fc4ebd7 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vlan/DeleteVlanIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vlan/DeleteVlanIpRangeCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.VlanIpRangeResponse; import com.cloud.user.Account; -@APICommand(name = "deleteVlanIpRange", description = "Creates a VLAN IP range.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteVlanIpRange", description = "Creates a VLAN IP range.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVlanIpRangeCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteVlanIpRangeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vlan/ListVlanIpRangesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vlan/ListVlanIpRangesCmd.java index 9d6eae66e76..d4f2d5ad611 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vlan/ListVlanIpRangesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vlan/ListVlanIpRangesCmd.java @@ -37,7 +37,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.dc.Vlan; import com.cloud.utils.Pair; -@APICommand(name = "listVlanIpRanges", description = "Lists all VLAN IP ranges.", responseObject = VlanIpRangeResponse.class) +@APICommand(name = "listVlanIpRanges", description = "Lists all VLAN IP ranges.", responseObject = VlanIpRangeResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVlanIpRangesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListVlanIpRangesCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vlan/ReleasePublicIpRangeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vlan/ReleasePublicIpRangeCmd.java index 2c160be3a73..15cfbc64e30 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vlan/ReleasePublicIpRangeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vlan/ReleasePublicIpRangeCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.api.response.VlanIpRangeResponse; import com.cloud.user.Account; -@APICommand(name = "releasePublicIpRange", description = "Releases a Public IP range back to the system pool", responseObject = SuccessResponse.class) +@APICommand(name = "releasePublicIpRange", description = "Releases a Public IP range back to the system pool", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReleasePublicIpRangeCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ReleasePublicIpRangeCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/AddNicToVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/AddNicToVMCmdByAdmin.java new file mode 100644 index 00000000000..ee6d0e78e09 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/AddNicToVMCmdByAdmin.java @@ -0,0 +1,55 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import java.util.ArrayList; +import java.util.EnumSet; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants.VMDetails; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.uservm.UserVm; + +@APICommand(name = "addNicToVirtualMachine", description = "Adds VM to specified network by creating a NIC", responseObject = UserVmResponse.class, responseView = ResponseView.Full, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) +public class AddNicToVMCmdByAdmin extends AddNicToVMCmd { + public static final Logger s_logger = Logger.getLogger(AddNicToVMCmdByAdmin.class); + + @Override + public void execute(){ + CallContext.current().setEventDetails("Vm Id: " + getVmId() + " Network Id: " + getNetworkId()); + UserVm result = _userVmService.addNicToVirtualMachine(this); + ArrayList dc = new ArrayList(); + dc.add(VMDetails.valueOf("nics")); + EnumSet details = EnumSet.copyOf(dc); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", details, result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add NIC to vm. Refer to server logs for details."); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java index c9b5c9f8f47..435b7f18484 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/AssignVMCmd.java @@ -25,6 +25,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.NetworkResponse; @@ -33,12 +34,15 @@ import org.apache.cloudstack.api.response.UserVmResponse; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; @APICommand(name = "assignVirtualMachine", description = "Change ownership of a VM from one account to another. This API is available for Basic zones with security groups and Advanced zones with guest networks. A root administrator can reassign a VM from any account to any other account in any domain. A domain administrator can reassign a VM to any account in the same domain.", responseObject = UserVmResponse.class, - since = "3.0.0") -public class AssignVMCmd extends BaseCmd { + since = "3.0.0", entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = true) +public class AssignVMCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AssignVMCmd.class.getName()); private static final String s_name = "assignvirtualmachineresponse"; @@ -118,7 +122,7 @@ public class AssignVMCmd extends BaseCmd { if (userVm == null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to move vm"); } - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", userVm).get(0); response.setResponseName(getCommandName()); setResponseObject(response); } catch (Exception e) { diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/DeployVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/DeployVMCmdByAdmin.java new file mode 100755 index 00000000000..99fec6b5a7d --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/DeployVMCmdByAdmin.java @@ -0,0 +1,79 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.DeployVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.InsufficientServerCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + + +@APICommand(name = "deployVirtualMachine", description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", responseObject = UserVmResponse.class, responseView = ResponseView.Full) +public class DeployVMCmdByAdmin extends DeployVMCmd { + public static final Logger s_logger = Logger.getLogger(DeployVMCmdByAdmin.class.getName()); + + + @Override + public void execute(){ + UserVm result; + + if (getStartVm()) { + try { + CallContext.current().setEventDetails("Vm Id: "+getEntityId()); + result = _userVmService.startVirtualMachine(this); + } catch (ResourceUnavailableException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); + } catch (ConcurrentOperationException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } catch (InsufficientCapacityException ex) { + StringBuilder message = new StringBuilder(ex.getMessage()); + if (ex instanceof InsufficientServerCapacityException) { + if(((InsufficientServerCapacityException)ex).isAffinityApplied()){ + message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them"); + } + } + s_logger.info(ex); + s_logger.info(message.toString(), ex); + throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString()); + } + } else { + result = _userVmService.getUserVm(getEntityId()); + } + + if (result != null) { + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to deploy vm"); + } + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/DestroyVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/DestroyVMCmdByAdmin.java new file mode 100644 index 00000000000..b14e5b02511 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/DestroyVMCmdByAdmin.java @@ -0,0 +1,57 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + +@APICommand(name = "destroyVirtualMachine", description = "Destroys a virtual machine. Once destroyed, only the administrator can recover it.", responseObject = UserVmResponse.class, responseView = ResponseView.Full) +public class DestroyVMCmdByAdmin extends DestroyVMCmd { + public static final Logger s_logger = Logger.getLogger(DestroyVMCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceUnavailableException, ConcurrentOperationException{ + CallContext.current().setEventDetails("Vm Id: "+getId()); + UserVm result = _userVmService.destroyVm(this); + + UserVmResponse response = new UserVmResponse(); + if (result != null) { + List responses = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result); + if (responses != null && !responses.isEmpty()) { + response = responses.get(0); + } + response.setResponseName("virtualmachine"); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy vm"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/ExpungeVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vm/ExpungeVMCmd.java index 7b166864a28..40b9bb82562 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vm/ExpungeVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/ExpungeVMCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.admin.vm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -36,8 +38,10 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "expungeVirtualMachine", description = "Expunge a virtual machine. Once expunged, it cannot be recoverd.", responseObject = SuccessResponse.class) +@APICommand(name = "expungeVirtualMachine", description = "Expunge a virtual machine. Once expunged, it cannot be recoverd.", responseObject = SuccessResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ExpungeVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ExpungeVMCmd.class.getName()); @@ -47,6 +51,7 @@ public class ExpungeVMCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") private Long id; @@ -105,7 +110,7 @@ public class ExpungeVMCmd extends BaseAsyncCmd { if (result != null) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to expunge vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/GetVMUserDataCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vm/GetVMUserDataCmd.java index 0e527149821..bf39f99519f 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vm/GetVMUserDataCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/GetVMUserDataCmd.java @@ -29,7 +29,8 @@ import org.apache.log4j.Logger; import com.cloud.user.Account; import com.cloud.uservm.UserVm; -@APICommand(name = "getVirtualMachineUserData", description = "Returns user data associated with the VM", responseObject = VMUserDataResponse.class, since = "4.4") +@APICommand(name = "getVirtualMachineUserData", description = "Returns user data associated with the VM", responseObject = VMUserDataResponse.class, since = "4.4", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class GetVMUserDataCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(GetVMUserDataCmd.class); private static final String s_name = "getvirtualmachineuserdataresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/ListVMsCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/ListVMsCmdByAdmin.java new file mode 100644 index 00000000000..489af297b8d --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/ListVMsCmdByAdmin.java @@ -0,0 +1,69 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.vm.ListVMsCmd; +import org.apache.cloudstack.api.response.HostResponse; +import org.apache.cloudstack.api.response.PodResponse; +import org.apache.cloudstack.api.response.StoragePoolResponse; +import org.apache.cloudstack.api.response.UserVmResponse; + + +@APICommand(name = "listVirtualMachines", description = "List the virtual machines owned by the account.", responseObject = UserVmResponse.class, responseView = ResponseView.Full) +public class ListVMsCmdByAdmin extends ListVMsCmd { + public static final Logger s_logger = Logger.getLogger(ListVMsCmdByAdmin.class.getName()); + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class, + description="the host ID") + private Long hostId; + + @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class, + description="the pod ID") + private Long podId; + + @Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.UUID, entityType=StoragePoolResponse.class, + description="the storage ID where vm's volumes belong to") + private Long storageId; + + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getHostId() { + return hostId; + } + + public Long getPodId() { + return podId; + } + + public Long getStorageId() { + return storageId; + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/MigrateVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vm/MigrateVMCmd.java index 3706d5060f7..ef9619effa2 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vm/MigrateVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/MigrateVMCmd.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.HostResponse; import org.apache.cloudstack.api.response.StoragePoolResponse; @@ -43,7 +44,9 @@ import com.cloud.vm.VirtualMachine; @APICommand(name = "migrateVirtualMachine", description = "Attempts Migration of a VM to a different host or Root volume of the vm to a different storage pool", - responseObject = UserVmResponse.class) + responseObject = UserVmResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = true) public class MigrateVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(MigrateVMCmd.class.getName()); @@ -160,9 +163,9 @@ public class MigrateVMCmd extends BaseAsyncCmd { migratedVm = _userVmService.vmStorageMigration(getVirtualMachineId(), destStoragePool); } if (migratedVm != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", (UserVm)migratedVm).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", (UserVm)migratedVm).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/MigrateVirtualMachineWithVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vm/MigrateVirtualMachineWithVolumeCmd.java index 90918bfa8d8..f1d3fe975fd 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vm/MigrateVirtualMachineWithVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/MigrateVirtualMachineWithVolumeCmd.java @@ -28,6 +28,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.HostResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -45,7 +46,9 @@ import com.cloud.vm.VirtualMachine; @APICommand(name = "migrateVirtualMachineWithVolume", description = "Attempts Migration of a VM with its volumes to a different host", - responseObject = UserVmResponse.class) + responseObject = UserVmResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = true) public class MigrateVirtualMachineWithVolumeCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(MigrateVMCmd.class.getName()); @@ -72,7 +75,7 @@ public class MigrateVirtualMachineWithVolumeCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.MIGRATE_TO, type = CommandType.MAP, required = false, - description = "Map of pool to which each volume should be migrated (volume/pool pair)") + description = "Map of pool to which each volume should be migrated (volume/pool pair)") private Map migrateVolumeTo; ///////////////////////////////////////////////////// @@ -146,9 +149,9 @@ public class MigrateVirtualMachineWithVolumeCmd extends BaseAsyncCmd { try { VirtualMachine migratedVm = _userVmService.migrateVirtualMachineWithVolume(getVirtualMachineId(), destinationHost, getVolumeToPool()); if (migratedVm != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", (UserVm)migratedVm).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", (UserVm)migratedVm).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/RebootVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/RebootVMCmdByAdmin.java new file mode 100644 index 00000000000..7fa8edad839 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/RebootVMCmdByAdmin.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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.RebootVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + +@APICommand(name = "rebootVirtualMachine", description = "Reboots a virtual machine.", responseObject = UserVmResponse.class, responseView = ResponseView.Full) +public class RebootVMCmdByAdmin extends RebootVMCmd { + public static final Logger s_logger = Logger.getLogger(RebootVMCmdByAdmin.class.getName()); + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException{ + CallContext.current().setEventDetails("Vm Id: "+getId()); + UserVm result; + result = _userVmService.rebootVirtualMachine(this); + + if (result !=null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reboot vm instance"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/RecoverVMCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vm/RecoverVMCmd.java index abf5168ff28..4ad09171540 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vm/RecoverVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/RecoverVMCmd.java @@ -23,14 +23,17 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import com.cloud.exception.ResourceAllocationException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "recoverVirtualMachine", description = "Recovers a virtual machine.", responseObject = UserVmResponse.class) +@APICommand(name = "recoverVirtualMachine", description = "Recovers a virtual machine.", responseObject = UserVmResponse.class, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class RecoverVMCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(RecoverVMCmd.class.getName()); @@ -73,10 +76,10 @@ public class RecoverVMCmd extends BaseCmd { @Override public void execute() throws ResourceAllocationException { UserVm result = _userVmService.recoverVirtualMachine(this); - if (result != null) { - UserVmResponse recoverVmResponse = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + if (result != null){ + UserVmResponse recoverVmResponse = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); recoverVmResponse.setResponseName(getCommandName()); - this.setResponseObject(recoverVmResponse); + setResponseObject(recoverVmResponse); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to recover vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/RemoveNicFromVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/RemoveNicFromVMCmdByAdmin.java new file mode 100644 index 00000000000..ba0ff27f12b --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/RemoveNicFromVMCmdByAdmin.java @@ -0,0 +1,55 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import java.util.ArrayList; +import java.util.EnumSet; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants.VMDetails; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.RemoveNicFromVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.uservm.UserVm; + +@APICommand(name = "removeNicFromVirtualMachine", description = "Removes VM from specified network by deleting a NIC", responseObject = UserVmResponse.class, responseView = ResponseView.Full) + +public class RemoveNicFromVMCmdByAdmin extends RemoveNicFromVMCmd { + public static final Logger s_logger = Logger.getLogger(RemoveNicFromVMCmdByAdmin.class); + + @Override + public void execute(){ + CallContext.current().setEventDetails("Vm Id: "+getVmId() + " Nic Id: " + getNicId()); + UserVm result = _userVmService.removeNicFromVirtualMachine(this); + ArrayList dc = new ArrayList(); + dc.add(VMDetails.valueOf("nics")); + EnumSet details = EnumSet.copyOf(dc); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", details, result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove NIC from vm, see error log for details"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/ResetVMPasswordCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/ResetVMPasswordCmdByAdmin.java new file mode 100644 index 00000000000..1b3e1cc1dcf --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/ResetVMPasswordCmdByAdmin.java @@ -0,0 +1,54 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + +@APICommand(name = "resetPasswordForVirtualMachine", responseObject=UserVmResponse.class, description="Resets the password for virtual machine. " + + "The virtual machine must be in a \"Stopped\" state and the template must already " + + "support this feature for this command to take effect. [async]", responseView = ResponseView.Full) +public class ResetVMPasswordCmdByAdmin extends ResetVMPasswordCmd { + public static final Logger s_logger = Logger.getLogger(ResetVMPasswordCmdByAdmin.class.getName()); + + + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException{ + password = _mgr.generateRandomPassword(); + CallContext.current().setEventDetails("Vm Id: "+getId()); + UserVm result = _userVmService.resetVMPassword(this, password); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset vm password"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/ResetVMSSHKeyCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/ResetVMSSHKeyCmdByAdmin.java new file mode 100644 index 00000000000..1da083cec34 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/ResetVMSSHKeyCmdByAdmin.java @@ -0,0 +1,57 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.ResetVMSSHKeyCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + +@APICommand(name = "resetSSHKeyForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the SSH Key for virtual machine. " + + "The virtual machine must be in a \"Stopped\" state. [async]", responseView = ResponseView.Full) +public class ResetVMSSHKeyCmdByAdmin extends ResetVMSSHKeyCmd { + + public static final Logger s_logger = Logger.getLogger(ResetVMSSHKeyCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceUnavailableException, + InsufficientCapacityException { + + CallContext.current().setEventDetails("Vm Id: " + getId()); + UserVm result = _userVmService.resetVMSSHKey(this); + + if (result != null) { + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset vm SSHKey"); + } + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/RestoreVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/RestoreVMCmdByAdmin.java new file mode 100644 index 00000000000..fea2016c8c3 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/RestoreVMCmdByAdmin.java @@ -0,0 +1,54 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + +@APICommand(name = "restoreVirtualMachine", description = "Restore a VM to original template/ISO or new template/ISO", responseObject = UserVmResponse.class, since = "3.0.0", responseView = ResponseView.Full) +public class RestoreVMCmdByAdmin extends RestoreVMCmd { + public static final Logger s_logger = Logger.getLogger(RestoreVMCmdByAdmin.class); + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, + ResourceAllocationException { + UserVm result; + CallContext.current().setEventDetails("Vm Id: " + getVmId()); + result = _userVmService.restoreVM(this); + if (result != null) { + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restore vm " + getVmId()); + } + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java new file mode 100644 index 00000000000..68d3c332ddf --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/ScaleVMCmdByAdmin.java @@ -0,0 +1,69 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd; +import org.apache.cloudstack.api.response.SuccessResponse; +import org.apache.cloudstack.api.response.UserVmResponse; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.ManagementServerException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.VirtualMachineMigrationException; +import com.cloud.uservm.UserVm; + + +@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering.", responseObject = SuccessResponse.class, responseView = ResponseView.Full) +public class ScaleVMCmdByAdmin extends ScaleVMCmd { + public static final Logger s_logger = Logger.getLogger(ScaleVMCmdByAdmin.class.getName()); + + @Override + public void execute(){ + UserVm result; + try { + result = _userVmService.upgradeVirtualMachine(this); + } catch (ResourceUnavailableException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); + } catch (ConcurrentOperationException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } catch (ManagementServerException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } catch (VirtualMachineMigrationException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } + if (result != null){ + List responseList = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result); + UserVmResponse response = responseList.get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to scale vm"); + } + } +} \ No newline at end of file diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/StartVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/StartVMCmdByAdmin.java new file mode 100644 index 00000000000..e814784ba3d --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/StartVMCmdByAdmin.java @@ -0,0 +1,80 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.StartVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.InsufficientServerCapacityException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.StorageUnavailableException; +import com.cloud.uservm.UserVm; +import com.cloud.utils.exception.ExecutionException; + +@APICommand(name = "startVirtualMachine", responseObject = UserVmResponse.class, description = "Starts a virtual machine.", responseView = ResponseView.Full) +public class StartVMCmdByAdmin extends StartVMCmd { + public static final Logger s_logger = Logger.getLogger(StartVMCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceUnavailableException, ResourceAllocationException { + try { + CallContext.current().setEventDetails("Vm Id: " + getId()); + + UserVm result ; + result = _userVmService.startVirtualMachine(this); + + if (result != null) { + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start a vm"); + } + } catch (ConcurrentOperationException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } catch (StorageUnavailableException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); + } catch (ExecutionException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } catch (InsufficientCapacityException ex) { + StringBuilder message = new StringBuilder(ex.getMessage()); + if (ex instanceof InsufficientServerCapacityException) { + if (((InsufficientServerCapacityException) ex).isAffinityApplied()) { + message.append(", Please check the affinity groups provided, there may not be sufficient capacity to follow them"); + } + } + s_logger.info(ex); + s_logger.info(message.toString(), ex); + throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString()); + } + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/StopVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/StopVMCmdByAdmin.java new file mode 100644 index 00000000000..6c906c74227 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/StopVMCmdByAdmin.java @@ -0,0 +1,53 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.StopVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.uservm.UserVm; + +@APICommand(name = "stopVirtualMachine", responseObject = UserVmResponse.class, description = "Stops a virtual machine.", responseView = ResponseView.Full) +public class StopVMCmdByAdmin extends StopVMCmd { + public static final Logger s_logger = Logger.getLogger(StopVMCmdByAdmin.class.getName()); + + + + @Override + public void execute() throws ServerApiException, ConcurrentOperationException { + CallContext.current().setEventDetails("Vm Id: " + getId()); + UserVm result; + + result = _userVmService.stopVirtualMachine(getId(), isForced()); + + if (result != null) { + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop vm"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/UpdateDefaultNicForVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/UpdateDefaultNicForVMCmdByAdmin.java new file mode 100644 index 00000000000..82385ba8f26 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/UpdateDefaultNicForVMCmdByAdmin.java @@ -0,0 +1,56 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import java.util.ArrayList; +import java.util.EnumSet; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants.VMDetails; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.UpdateDefaultNicForVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.uservm.UserVm; + +@APICommand(name = "updateDefaultNicForVirtualMachine", description = "Changes the default NIC on a VM", responseObject = UserVmResponse.class, responseView = ResponseView.Full) + +public class UpdateDefaultNicForVMCmdByAdmin extends UpdateDefaultNicForVMCmd { + public static final Logger s_logger = Logger.getLogger(UpdateDefaultNicForVMCmdByAdmin.class); + + + @Override + public void execute(){ + CallContext.current().setEventDetails("Vm Id: "+getVmId() + " Nic Id: " + getNicId()); + UserVm result = _userVmService.updateDefaultNicForVirtualMachine(this); + ArrayList dc = new ArrayList(); + dc.add(VMDetails.valueOf("nics")); + EnumSet details = EnumSet.copyOf(dc); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", details, result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to set default nic for VM. Refer to server logs for details."); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/UpdateVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/UpdateVMCmdByAdmin.java new file mode 100644 index 00000000000..ef598b1a2ae --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/UpdateVMCmdByAdmin.java @@ -0,0 +1,53 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + + +@APICommand(name = "updateVirtualMachine", description="Updates properties of a virtual machine. The VM has to be stopped and restarted for the " + + "new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. " + + "Therefore, stop the VM manually before issuing this call.", responseObject = UserVmResponse.class, responseView = ResponseView.Full) +public class UpdateVMCmdByAdmin extends UpdateVMCmd { + public static final Logger s_logger = Logger.getLogger(UpdateVMCmdByAdmin.class.getName()); + + @Override + public void execute() throws ResourceUnavailableException, + InsufficientCapacityException, ServerApiException { + CallContext.current().setEventDetails("Vm Id: "+getId()); + UserVm result = _userVmService.updateVirtualMachine(this); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vm/UpgradeVMCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vm/UpgradeVMCmdByAdmin.java new file mode 100644 index 00000000000..bfbe3d6ff0b --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vm/UpgradeVMCmdByAdmin.java @@ -0,0 +1,59 @@ +// 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 org.apache.cloudstack.api.command.admin.vm; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.offering.ServiceOffering; +import com.cloud.uservm.UserVm; + +@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="Changes the service offering for a virtual machine. " + + "The virtual machine must be in a \"Stopped\" state for " + + "this command to take effect.", responseView = ResponseView.Full) +public class UpgradeVMCmdByAdmin extends UpgradeVMCmd { + public static final Logger s_logger = Logger.getLogger(UpgradeVMCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceAllocationException{ + CallContext.current().setEventDetails("Vm Id: "+getId()); + + ServiceOffering serviceOffering = _entityMgr.findById(ServiceOffering.class, serviceOfferingId); + if (serviceOffering == null) { + throw new InvalidParameterValueException("Unable to find service offering: " + serviceOfferingId); + } + + UserVm result = _userVmService.upgradeVirtualMachine(this); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade vm"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vmsnapshot/RevertToVMSnapshotCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vmsnapshot/RevertToVMSnapshotCmdByAdmin.java new file mode 100644 index 00000000000..92df872b0b5 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vmsnapshot/RevertToVMSnapshotCmdByAdmin.java @@ -0,0 +1,57 @@ +// 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 org.apache.cloudstack.api.command.admin.vmsnapshot; + +import java.util.logging.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToVMSnapshotCmd; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.uservm.UserVm; + +@APICommand(name = "revertToVMSnapshot", description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class, since = "4.2.0", responseView = ResponseView.Full) +public class RevertToVMSnapshotCmdByAdmin extends RevertToVMSnapshotCmd { + public static final Logger s_logger = Logger + .getLogger(RevertToVMSnapshotCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException, ConcurrentOperationException { + CallContext.current().setEventDetails( + "vmsnapshot id: " + getVmSnapShotId()); + UserVm result = _vmSnapshotService.revertToSnapshot(getVmSnapShotId()); + if (result != null) { + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Full, + "virtualmachine", result).get(0); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,"Failed to revert VM snapshot"); + } + } + + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/AttachVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/AttachVolumeCmdByAdmin.java new file mode 100644 index 00000000000..3634a976c63 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/volume/AttachVolumeCmdByAdmin.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 org.apache.cloudstack.api.command.admin.volume; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd; +import org.apache.cloudstack.api.response.VolumeResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.storage.Volume; + +@APICommand(name = "attachVolume", description = "Attaches a disk volume to a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Full) +public class AttachVolumeCmdByAdmin extends AttachVolumeCmd { + public static final Logger s_logger = Logger.getLogger(AttachVolumeCmdByAdmin.class.getName()); + + @Override + public void execute(){ + CallContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId()); + Volume result = _volumeService.attachVolumeToVM(this); + if (result != null) { + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach volume"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/CreateVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/CreateVolumeCmdByAdmin.java new file mode 100644 index 00000000000..5df7481497c --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/volume/CreateVolumeCmdByAdmin.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 org.apache.cloudstack.api.command.admin.volume; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd; +import org.apache.cloudstack.api.response.VolumeResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.storage.Snapshot; +import com.cloud.storage.Volume; + +@APICommand(name = "createVolume", responseObject = VolumeResponse.class, description = "Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.", responseView = ResponseView.Full) +public class CreateVolumeCmdByAdmin extends CreateVolumeCmd { + public static final Logger s_logger = Logger.getLogger(CreateVolumeCmdByAdmin.class.getName()); + + @Override + public void execute(){ + CallContext.current().setEventDetails("Volume Id: "+getEntityId()+((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId())); + Volume volume = _volumeService.createVolume(this); + if (volume != null) { + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume); + //FIXME - have to be moved to ApiResponseHelper + if (getSnapshotId() != null) { + Snapshot snap = _entityMgr.findById(Snapshot.class, getSnapshotId()); + if (snap != null) { + response.setSnapshotId(snap.getUuid()); // if the volume was + // created from a + // snapshot, + // snapshotId will + // be set so we pass + // it back in the + // response + } + } + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a volume"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/DetachVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/DetachVolumeCmdByAdmin.java new file mode 100644 index 00000000000..ab07a786639 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/volume/DetachVolumeCmdByAdmin.java @@ -0,0 +1,48 @@ +// 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 org.apache.cloudstack.api.command.admin.volume; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd; +import org.apache.cloudstack.api.response.VolumeResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.storage.Volume; + +@APICommand(name = "detachVolume", description = "Detaches a disk volume from a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Full) +public class DetachVolumeCmdByAdmin extends DetachVolumeCmd { + public static final Logger s_logger = Logger.getLogger(DetachVolumeCmdByAdmin.class.getName()); + + + @Override + public void execute(){ + CallContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId()); + Volume result = _volumeService.detachVolumeFromVM(this); + if (result != null){ + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result); + response.setResponseName("volume"); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach volume"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/ListVolumesCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/ListVolumesCmdByAdmin.java new file mode 100644 index 00000000000..1cd54d1e22a --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/volume/ListVolumesCmdByAdmin.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 org.apache.cloudstack.api.command.admin.volume; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd; +import org.apache.cloudstack.api.response.PodResponse; +import org.apache.cloudstack.api.response.StoragePoolResponse; +import org.apache.cloudstack.api.response.VolumeResponse; + + + +@APICommand(name = "listVolumes", description = "Lists all volumes.", responseObject = VolumeResponse.class, responseView = ResponseView.Full) +public class ListVolumesCmdByAdmin extends ListVolumesCmd { + public static final Logger s_logger = Logger.getLogger(ListVolumesCmdByAdmin.class.getName()); + + @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class, + description="the pod id the disk volume belongs to") + private Long podId; + + + @Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.UUID, entityType=StoragePoolResponse.class, + description="the ID of the storage pool, available to ROOT admin only", since="4.3", authorized = { RoleType.Admin }) + private Long storageId; + + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + + @Override + public Long getPodId() { + return podId; + } + + + @Override + public Long getStorageId() { + return storageId; + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/MigrateVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/MigrateVolumeCmdByAdmin.java new file mode 100644 index 00000000000..44a08e802db --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/volume/MigrateVolumeCmdByAdmin.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 org.apache.cloudstack.api.command.admin.volume; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd; +import org.apache.cloudstack.api.response.VolumeResponse; + +import com.cloud.storage.Volume; + + +@APICommand(name = "migrateVolume", description = "Migrate volume", responseObject = VolumeResponse.class, since = "3.0.0", responseView = ResponseView.Full) +public class MigrateVolumeCmdByAdmin extends MigrateVolumeCmd { + + + @Override + public void execute(){ + Volume result; + + result = _volumeService.migrateVolume(this); + if (result != null) { + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate volume"); + } + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java new file mode 100644 index 00000000000..d1d253c02b7 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.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 org.apache.cloudstack.api.command.admin.volume; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd; +import org.apache.cloudstack.api.response.VolumeResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.exception.ResourceAllocationException; +import com.cloud.storage.Volume; + + +@APICommand(name = "resizeVolume", description = "Resizes a volume", responseObject = VolumeResponse.class, responseView = ResponseView.Full) +public class ResizeVolumeCmdByAdmin extends ResizeVolumeCmd { + + @Override + public void execute() throws ResourceAllocationException{ + CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G"); + Volume volume = _volumeService.resizeVolume(this); + if (volume != null) { + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume); + //FIXME - have to be moved to ApiResponseHelper + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to resize volume"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/UpdateVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/UpdateVolumeCmdByAdmin.java new file mode 100644 index 00000000000..16b2d5db10e --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/volume/UpdateVolumeCmdByAdmin.java @@ -0,0 +1,45 @@ +// 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 org.apache.cloudstack.api.command.admin.volume; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.volume.UpdateVolumeCmd; +import org.apache.cloudstack.api.response.VolumeResponse; +import org.apache.cloudstack.context.CallContext; + +import com.cloud.storage.Volume; + +@APICommand(name = "updateVolume", description = "Updates the volume.", responseObject = VolumeResponse.class, responseView = ResponseView.Full) +public class UpdateVolumeCmdByAdmin extends UpdateVolumeCmd { + + @Override + public void execute(){ + CallContext.current().setEventDetails("Volume Id: "+getId()); + Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume(), + getCustomId(), getEntityOwnerId(), getChainInfo()); + if (result != null) { + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update volume"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/UploadVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/UploadVolumeCmdByAdmin.java new file mode 100644 index 00000000000..e3e0c9b8ade --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/volume/UploadVolumeCmdByAdmin.java @@ -0,0 +1,57 @@ +// 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 org.apache.cloudstack.api.command.admin.volume; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd; +import org.apache.cloudstack.api.response.VolumeResponse; + +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.Volume; + +@APICommand(name = "uploadVolume", description = "Uploads a data disk.", responseObject = VolumeResponse.class, responseView = ResponseView.Full) +public class UploadVolumeCmdByAdmin extends UploadVolumeCmd { + public static final Logger s_logger = Logger.getLogger(UploadVolumeCmdByAdmin.class.getName()); + + + @Override + public void execute() throws ResourceUnavailableException, + InsufficientCapacityException, ServerApiException, + ConcurrentOperationException, ResourceAllocationException, + NetworkRuleConflictException { + + Volume volume = _volumeService.uploadVolume(this); + if (volume != null){ + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload volume"); + } + } + + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java index c3201f13ffc..01db44e25df 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreatePrivateGatewayCmd.java @@ -40,9 +40,11 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.vpc.PrivateGateway; import com.cloud.network.vpc.Vpc; +import com.cloud.network.vpc.VpcGateway; import com.cloud.user.Account; -@APICommand(name = "createPrivateGateway", description = "Creates a private gateway", responseObject = PrivateGatewayResponse.class) +@APICommand(name = "createPrivateGateway", description = "Creates a private gateway", responseObject = PrivateGatewayResponse.class, entityType = {VpcGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreatePrivateGatewayCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreatePrivateGatewayCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCCmdByAdmin.java new file mode 100644 index 00000000000..f063cdbde44 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCCmdByAdmin.java @@ -0,0 +1,64 @@ +// 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 org.apache.cloudstack.api.command.admin.vpc; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vpc.CreateVPCCmd; +import org.apache.cloudstack.api.response.VpcResponse; + +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.vpc.Vpc; + +@APICommand(name = "createVPC", description = "Creates a VPC", responseObject = VpcResponse.class, responseView = ResponseView.Full) +public class CreateVPCCmdByAdmin extends CreateVPCCmd { + public static final Logger s_logger = Logger.getLogger(CreateVPCCmdByAdmin.class.getName()); + + @Override + public void execute() { + Vpc vpc = null; + try { + if (_vpcService.startVpc(getEntityId(), true)) { + vpc = _entityMgr.findById(Vpc.class, getEntityId()); + } + } catch (ResourceUnavailableException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); + } catch (ConcurrentOperationException ex) { + s_logger.warn("Exception: ", ex); + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); + } catch (InsufficientCapacityException ex) { + s_logger.info(ex); + s_logger.trace(ex); + throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); + } + + if (vpc != null) { + VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Full, vpc); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create VPC"); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java index 96d5c6acece..13e4c0e04b1 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java @@ -39,10 +39,11 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.network.vpc.VpcOffering; import com.cloud.user.Account; -@APICommand(name = "createVPCOffering", description = "Creates VPC offering", responseObject = VpcOfferingResponse.class) +@APICommand(name = "createVPCOffering", description = "Creates VPC offering", responseObject = VpcOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateVPCOfferingCmd.class.getName()); - private static final String Name = "createvpcofferingresponse"; + private static final String s_name = "createvpcofferingresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -65,6 +66,9 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd { + "If not specified, the provider for the service will be mapped to the default provider on the physical network") private Map serviceProviderList; + @Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "desired service capabilities as part of vpc offering", since = "4.4") + private Map serviceCapabilitystList; + @Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, @@ -111,13 +115,18 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd { return serviceProviderMap; } + public Map> getServiceCapabilitystList() { + return serviceCapabilitystList; + } + public Long getServiceOfferingId() { return serviceOfferingId; } @Override public void create() throws ResourceAllocationException { - VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(), getSupportedServices(), getServiceProviders(), getServiceOfferingId()); + VpcOffering vpcOff = _vpcProvSvc.createVpcOffering(getVpcOfferingName(), getDisplayText(), + getSupportedServices(), getServiceProviders(), getServiceCapabilitystList(), getServiceOfferingId()); if (vpcOff != null) { setEntityId(vpcOff.getId()); setEntityUuid(vpcOff.getUuid()); @@ -150,7 +159,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd { @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/DeletePrivateGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/DeletePrivateGatewayCmd.java index a5bb00c9ac4..8d67a4ed8c5 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/DeletePrivateGatewayCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/DeletePrivateGatewayCmd.java @@ -36,7 +36,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.vpc.VpcGateway; import com.cloud.user.Account; -@APICommand(name = "deletePrivateGateway", description = "Deletes a Private gateway", responseObject = SuccessResponse.class) +@APICommand(name = "deletePrivateGateway", description = "Deletes a Private gateway", responseObject = SuccessResponse.class, entityType = {VpcGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeletePrivateGatewayCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeletePrivateGatewayCmd.class.getName()); private static final String s_name = "deleteprivategatewayresponse"; @@ -85,7 +86,7 @@ public class DeletePrivateGatewayCmd extends BaseAsyncCmd { boolean result = _vpcService.deleteVpcPrivateGateway(id); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete private gateway"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/DeleteVPCOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/DeleteVPCOfferingCmd.java index 7abaa7d565c..0959f5f8c07 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/DeleteVPCOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/DeleteVPCOfferingCmd.java @@ -30,7 +30,8 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "deleteVPCOffering", description = "Deletes VPC offering", responseObject = SuccessResponse.class) +@APICommand(name = "deleteVPCOffering", description = "Deletes VPC offering", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVPCOfferingCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteVPCOfferingCmd.class.getName()); private static final String s_name = "deletevpcofferingresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/ListVPCsCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/ListVPCsCmdByAdmin.java new file mode 100644 index 00000000000..3a95e44df45 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/ListVPCsCmdByAdmin.java @@ -0,0 +1,55 @@ +// 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 org.apache.cloudstack.api.command.admin.vpc; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.vpc.ListVPCsCmd; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.VpcResponse; + +import com.cloud.network.vpc.Vpc; + + +@APICommand(name = "listVPCs", description = "Lists VPCs", responseObject = VpcResponse.class, responseView = ResponseView.Full) +public class ListVPCsCmdByAdmin extends ListVPCsCmd { + public static final Logger s_logger = Logger.getLogger(ListVPCsCmdByAdmin.class.getName()); + + @Override + public void execute() { + List vpcs = + _vpcService.listVpcs(getId(), getVpcName(), getDisplayText(), getSupportedServices(), getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(), + getKeyword(), getStartIndex(), getPageSizeVal(), getZoneId(), isRecursive(), listAll(), getRestartRequired(), getTags(), + getProjectId(), getDisplay()); + ListResponse response = new ListResponse(); + List offeringResponses = new ArrayList(); + for (Vpc vpc : vpcs) { + VpcResponse offeringResponse = _responseGenerator.createVpcResponse(ResponseView.Full, vpc); + offeringResponses.add(offeringResponse); + } + + response.setResponses(offeringResponses); + response.setResponseName(getCommandName()); + setResponseObject(response); + } + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCCmdByAdmin.java new file mode 100644 index 00000000000..b94cdcf8d20 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCCmdByAdmin.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 org.apache.cloudstack.api.command.admin.vpc; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.command.user.vpc.UpdateVPCCmd; +import org.apache.cloudstack.api.response.VpcResponse; + +import com.cloud.network.vpc.Vpc; + +@APICommand(name = "updateVPC", description = "Updates a VPC", responseObject = VpcResponse.class, responseView = ResponseView.Full) +public class UpdateVPCCmdByAdmin extends UpdateVPCCmd { + public static final Logger s_logger = Logger.getLogger(UpdateVPCCmdByAdmin.class.getName()); + + @Override + public void execute(){ + Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), getCustomId(), getDisplayVpc()); + if (result != null) { + VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Full, result); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VPC"); + } + } + + +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java b/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java index 3526b4b3ac9..5af47d3a4c7 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/vpc/UpdateVPCOfferingCmd.java @@ -30,10 +30,11 @@ import com.cloud.event.EventTypes; import com.cloud.network.vpc.VpcOffering; import com.cloud.user.Account; -@APICommand(name = "updateVPCOffering", description = "Updates VPC offering", responseObject = VpcOfferingResponse.class) +@APICommand(name = "updateVPCOffering", description = "Updates VPC offering", responseObject = VpcOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateVPCOfferingCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateVPCOfferingCmd.class.getName()); - private static final String Name = "updatevpcofferingresponse"; + private static final String s_name = "updatevpcofferingresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -76,7 +77,7 @@ public class UpdateVPCOfferingCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/admin/zone/CreateZoneCmd.java b/api/src/org/apache/cloudstack/api/command/admin/zone/CreateZoneCmd.java index 0846102652f..414c058e66d 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/zone/CreateZoneCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/zone/CreateZoneCmd.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ZoneResponse; @@ -31,7 +32,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.dc.DataCenter; import com.cloud.user.Account; -@APICommand(name = "createZone", description = "Creates a Zone.", responseObject = ZoneResponse.class) +@APICommand(name = "createZone", description = "Creates a Zone.", responseObject = ZoneResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateZoneCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateZoneCmd.class.getName()); @@ -168,10 +170,10 @@ public class CreateZoneCmd extends BaseCmd { public void execute() { CallContext.current().setEventDetails("Zone Name: " + getZoneName()); DataCenter result = _configService.createZone(this); - if (result != null) { - ZoneResponse response = _responseGenerator.createZoneResponse(result, false); + if (result != null){ + ZoneResponse response = _responseGenerator.createZoneResponse(ResponseView.Full, result, false); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a zone"); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/zone/DeleteZoneCmd.java b/api/src/org/apache/cloudstack/api/command/admin/zone/DeleteZoneCmd.java index 3e7462567e1..c7029b052ec 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/zone/DeleteZoneCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/zone/DeleteZoneCmd.java @@ -30,7 +30,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.user.Account; -@APICommand(name = "deleteZone", description = "Deletes a Zone.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteZone", description = "Deletes a Zone.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteZoneCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteZoneCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/zone/ListZonesCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/zone/ListZonesCmdByAdmin.java new file mode 100644 index 00000000000..772a4dcfeb3 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/admin/zone/ListZonesCmdByAdmin.java @@ -0,0 +1,26 @@ +// 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 org.apache.cloudstack.api.command.admin.zone; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.command.user.zone.ListZonesCmd; +import org.apache.cloudstack.api.response.ZoneResponse; + +@APICommand(name = "listZones", description = "Lists zones", responseObject = ZoneResponse.class, responseView = ResponseView.Full) +public class ListZonesCmdByAdmin extends ListZonesCmd { +} diff --git a/api/src/org/apache/cloudstack/api/command/admin/zone/MarkDefaultZoneForAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/zone/MarkDefaultZoneForAccountCmd.java index fe2bc6a7eb6..28a6d6ccc13 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/zone/MarkDefaultZoneForAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/zone/MarkDefaultZoneForAccountCmd.java @@ -25,6 +25,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.DomainResponse; @@ -33,7 +34,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "markDefaultZoneForAccount", description = "Marks a default zone for this account", responseObject = AccountResponse.class, since = "4.0") +@APICommand(name = "markDefaultZoneForAccount", description = "Marks a default zone for this account", responseObject = AccountResponse.class, since = "4.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class MarkDefaultZoneForAccountCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(MarkDefaultZoneForAccountCmd.class.getName()); @@ -101,7 +103,7 @@ public class MarkDefaultZoneForAccountCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "Marking account with the default zone: " + getDefaultZoneId(); + return "Marking account with the default zone: " + getDefaultZoneId(); } @Override @@ -113,10 +115,11 @@ public class MarkDefaultZoneForAccountCmd extends BaseAsyncCmd { public void execute() { Account result = _configService.markDefaultZone(getAccountName(), getDomainId(), getDefaultZoneId()); if (result != null) { - AccountResponse response = _responseGenerator.createAccountResponse(result); + AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { + setResponseObject(response); + } + else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to mark the account with the default zone"); } } diff --git a/api/src/org/apache/cloudstack/api/command/admin/zone/UpdateZoneCmd.java b/api/src/org/apache/cloudstack/api/command/admin/zone/UpdateZoneCmd.java index f0074c5c6da..9ad8972ecfd 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/zone/UpdateZoneCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/zone/UpdateZoneCmd.java @@ -26,6 +26,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; @@ -33,7 +34,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.dc.DataCenter; import com.cloud.user.Account; -@APICommand(name = "updateZone", description = "Updates a Zone.", responseObject = ZoneResponse.class) +@APICommand(name = "updateZone", description = "Updates a Zone.", responseObject = ZoneResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateZoneCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateZoneCmd.class.getName()); @@ -180,9 +182,9 @@ public class UpdateZoneCmd extends BaseCmd { CallContext.current().setEventDetails("Zone Id: " + getId()); DataCenter result = _configService.editZone(this); if (result != null) { - ZoneResponse response = _responseGenerator.createZoneResponse(result, false); + ZoneResponse response = _responseGenerator.createZoneResponse(ResponseView.Full, result, false); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update zone; internal error."); } diff --git a/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java index 36df579d2a6..ef36038c5c4 100644 --- a/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/account/AddAccountToProjectCmd.java @@ -32,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.projects.Project; -@APICommand(name = "addAccountToProject", description = "Adds acoount to a project", responseObject = SuccessResponse.class, since = "3.0.0") +@APICommand(name = "addAccountToProject", description = "Adds acoount to a project", responseObject = SuccessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddAccountToProjectCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AddAccountToProjectCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java index f6aa36c2ea0..5c891733b5a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/account/DeleteAccountFromProjectCmd.java @@ -33,7 +33,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.projects.Project; -@APICommand(name = "deleteAccountFromProject", description = "Deletes account from the project", responseObject = SuccessResponse.class, since = "3.0.0") +@APICommand(name = "deleteAccountFromProject", description = "Deletes account from the project", responseObject = SuccessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteAccountFromProjectCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteProjectCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java b/api/src/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java index bc93d2147f7..0b5ae7c0baf 100644 --- a/api/src/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/account/ListAccountsCmd.java @@ -22,10 +22,14 @@ import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListDomainResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.ListResponse; -@APICommand(name = "listAccounts", description = "Lists accounts and provides detailed account information for listed accounts", responseObject = AccountResponse.class) +import com.cloud.user.Account; + +@APICommand(name = "listAccounts", description = "Lists accounts and provides detailed account information for listed accounts", responseObject = AccountResponse.class, responseView = ResponseView.Restricted, entityType = {Account.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class ListAccountsCmd extends BaseListDomainResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListAccountsCmd.class.getName()); private static final String s_name = "listaccountsresponse"; @@ -88,6 +92,6 @@ public class ListAccountsCmd extends BaseListDomainResourcesCmd { public void execute() { ListResponse response = _queryService.searchForAccounts(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/account/ListProjectAccountsCmd.java b/api/src/org/apache/cloudstack/api/command/user/account/ListProjectAccountsCmd.java index aa600166a6f..a70024edd51 100644 --- a/api/src/org/apache/cloudstack/api/command/user/account/ListProjectAccountsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/account/ListProjectAccountsCmd.java @@ -28,7 +28,8 @@ import org.apache.cloudstack.api.response.ProjectResponse; import com.cloud.user.Account; -@APICommand(name = "listProjectAccounts", description = "Lists project's accounts", responseObject = ProjectResponse.class, since = "3.0.0") +@APICommand(name = "listProjectAccounts", description = "Lists project's accounts", responseObject = ProjectResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListProjectAccountsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListProjectAccountsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java index 4df658bcbb4..091229f6817 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java @@ -20,6 +20,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -28,6 +29,7 @@ import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.BaseAsyncCreateCmd; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.IPAddressResponse; @@ -55,7 +57,9 @@ import com.cloud.offering.NetworkOffering; import com.cloud.projects.Project; import com.cloud.user.Account; -@APICommand(name = "associateIpAddress", description = "Acquires and associates a public IP to an account.", responseObject = IPAddressResponse.class) +@APICommand(name = "associateIpAddress", description = "Acquires and associates a public IP to an account.", responseObject = IPAddressResponse.class, responseView = ResponseView.Restricted, + entityType = {IpAddress.class, Vpc.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(AssociateIPAddrCmd.class.getName()); private static final String s_name = "associateipaddressresponse"; @@ -103,6 +107,9 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { description = "region ID from where portable ip is to be associated.") private Integer regionId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the ip to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -195,6 +202,10 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { } } + public Boolean getDisplayIp() { + return display; + } + @Override public long getEntityOwnerId() { Account caller = CallContext.current().getCallingAccount(); @@ -252,7 +263,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { @Override public String getEventDescription() { - return "associating ip to network id: " + getNetworkId() + " in zone " + getZoneId(); + return "associating ip to network id: " + getNetworkId() + " in zone " + getZoneId(); } ///////////////////////////////////////////////////// @@ -274,7 +285,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { IpAddress ip = null; if (!isPortable()) { - ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId()); + ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId(), getDisplayIp()); } else { ip = _networkService.allocatePortableIP(_accountService.getAccount(getEntityOwnerId()), 1, getZoneId(), getNetworkId(), getVpcId()); } @@ -308,7 +319,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd { } if (result != null) { - IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(result); + IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result); ipResponse.setResponseName(getCommandName()); setResponseObject(ipResponse); } else { diff --git a/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java index e3669be4bb0..269fcb552b3 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java @@ -36,7 +36,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.IpAddress; import com.cloud.user.Account; -@APICommand(name = "disassociateIpAddress", description = "Disassociates an ip address from the account.", responseObject = SuccessResponse.class) +@APICommand(name = "disassociateIpAddress", description = "Disassociates an ip address from the account.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DisassociateIPAddrCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DisassociateIPAddrCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java index a5c54ad2fd0..321871380da 100644 --- a/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/address/ListPublicIpAddressesCmd.java @@ -21,11 +21,13 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.IPAddressResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.NetworkResponse; @@ -37,7 +39,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.network.IpAddress; import com.cloud.utils.Pair; -@APICommand(name = "listPublicIpAddresses", description = "Lists all public ip addresses", responseObject = IPAddressResponse.class) +@APICommand(name = "listPublicIpAddresses", description = "Lists all public ip addresses", responseObject = IPAddressResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListPublicIpAddressesCmd.class.getName()); @@ -89,6 +92,9 @@ public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "List ips belonging to the VPC") private Long vpcId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -136,6 +142,14 @@ public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd { return vpcId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -150,14 +164,14 @@ public class ListPublicIpAddressesCmd extends BaseListTaggedResourcesCmd { ListResponse response = new ListResponse(); List ipAddrResponses = new ArrayList(); for (IpAddress ipAddress : result.first()) { - IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ipAddress); + IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, ipAddress); ipResponse.setObjectName("publicipaddress"); ipAddrResponses.add(ipResponse); } response.setResponses(ipAddrResponses, result.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java new file mode 100644 index 00000000000..cc736d0d64a --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/address/UpdateIPAddrCmd.java @@ -0,0 +1,134 @@ +// 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 org.apache.cloudstack.api.command.user.address; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.AccountResponse; +import org.apache.cloudstack.api.response.IPAddressResponse; + +import com.cloud.event.EventTypes; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.exception.NetworkRuleConflictException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.IpAddress; +import com.cloud.user.Account; + +@APICommand(name = "updatePublicIpAddress", description = "Updates an ip address", responseObject = IPAddressResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateIPAddrCmd extends BaseAsyncCustomIdCmd { + public static final Logger s_logger = Logger.getLogger(UpdateIPAddrCmd.class.getName()); + private static final String s_name = "updateipaddressresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, description = "the id of the public ip address" + + " to update") + private Long id; + // unexposed parameter needed for events logging + @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, expose = false) + private Long ownerId; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the ip to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + @Override + public String getCommandName() { + return s_name; + } + + public Long getId() { + return id; + } + + public Boolean getDisplayIp() { + return display; + } + + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + @Override + public String getEventType() { + return EventTypes.EVENT_NET_IP_UPDATE; + } + + @Override + public String getEventDescription() { + return ("Updating ip address with id=" + id); + } + + + @Override + public long getEntityOwnerId() { + if (ownerId == null) { + IpAddress ip = getIpAddress(id); + if (ip == null) { + throw new InvalidParameterValueException("Unable to find ip address by id=" + id); + } + ownerId = ip.getAccountId(); + } + + if (ownerId == null) { + return Account.ACCOUNT_ID_SYSTEM; + } + return ownerId; + } + + private IpAddress getIpAddress(long id) { + IpAddress ip = _entityMgr.findById(IpAddress.class, id); + + if (ip == null) { + throw new InvalidParameterValueException("Unable to find ip address by id=" + id); + } else { + return ip; + } + } + + @Override + public void checkUuid() { + if (getCustomId() != null) { + _uuidMgr.checkUuid(getCustomId(), IpAddress.class); + } + } + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, + NetworkRuleConflictException { + + IpAddress result = _networkService.updateIP(getId(), getCustomId(), getDisplayIp()); + IPAddressResponse ipResponse = _responseGenerator.createIPAddressResponse(ResponseView.Restricted, result); + ipResponse.setResponseName(getCommandName()); + setResponseObject(ipResponse); + } +} \ No newline at end of file diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java index a2542a87bc9..c30e52820eb 100644 --- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/CreateAffinityGroupCmd.java @@ -34,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.ResourceAllocationException; import com.cloud.user.Account; -@APICommand(name = "createAffinityGroup", responseObject = AffinityGroupResponse.class, description = "Creates an affinity/anti-affinity group") +@APICommand(name = "createAffinityGroup", responseObject = AffinityGroupResponse.class, description = "Creates an affinity/anti-affinity group", entityType = {AffinityGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateAffinityGroupCmd.class.getName()); @@ -101,7 +102,7 @@ public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd { @Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); - if ((account == null) || isAdmin(account.getType())) { + if ((account == null) || _accountService.isAdmin(account.getType())) { if ((domainId != null) && (accountName != null)) { Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); if (userAccount != null) { @@ -125,7 +126,7 @@ public class CreateAffinityGroupCmd extends BaseAsyncCreateCmd { if (group != null) { AffinityGroupResponse response = _responseGenerator.createAffinityGroupResponse(group); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create affinity group:" + affinityGroupName); } diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java index a6cf1bb29cb..945592b7f93 100644 --- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/DeleteAffinityGroupCmd.java @@ -16,9 +16,13 @@ // under the License. package org.apache.cloudstack.api.command.user.affinitygroup; + import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.affinity.AffinityGroup; import org.apache.cloudstack.affinity.AffinityGroupResponse; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -34,7 +38,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; -@APICommand(name = "deleteAffinityGroup", description = "Deletes affinity group", responseObject = SuccessResponse.class) +@APICommand(name = "deleteAffinityGroup", description = "Deletes affinity group", responseObject = SuccessResponse.class, entityType = {AffinityGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteAffinityGroupCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteAffinityGroupCmd.class.getName()); private static final String s_name = "deleteaffinitygroupresponse"; @@ -52,6 +57,7 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd { entityType = DomainResponse.class) private Long domainId; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The ID of the affinity group. Mutually exclusive with name parameter", @@ -104,7 +110,7 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); - if ((account == null) || isAdmin(account.getType())) { + if ((account == null) || _accountService.isAdmin(account.getType())) { if ((domainId != null) && (accountName != null)) { Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); if (userAccount != null) { @@ -128,7 +134,7 @@ public class DeleteAffinityGroupCmd extends BaseAsyncCmd { boolean result = _affinityGroupService.deleteAffinityGroup(id, accountName, domainId, name); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete affinity group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupTypesCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupTypesCmd.java index 87de7f7acbd..84ad0328463 100644 --- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupTypesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupTypesCmd.java @@ -28,7 +28,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.user.Account; -@APICommand(name = "listAffinityGroupTypes", description = "Lists affinity group types available", responseObject = AffinityGroupTypeResponse.class) +@APICommand(name = "listAffinityGroupTypes", description = "Lists affinity group types available", responseObject = AffinityGroupTypeResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListAffinityGroupTypesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListAffinityGroupTypesCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java index 0761a643452..6313c4812e9 100644 --- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/ListAffinityGroupsCmd.java @@ -17,6 +17,8 @@ package org.apache.cloudstack.api.command.user.affinitygroup; import org.apache.log4j.Logger; + +import org.apache.cloudstack.affinity.AffinityGroup; import org.apache.cloudstack.affinity.AffinityGroupResponse; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; @@ -26,7 +28,8 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.UserVmResponse; -@APICommand(name = "listAffinityGroups", description = "Lists affinity groups", responseObject = AffinityGroupResponse.class) +@APICommand(name = "listAffinityGroups", description = "Lists affinity groups", responseObject = AffinityGroupResponse.class, entityType = {AffinityGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListAffinityGroupsCmd extends BaseListAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListAffinityGroupsCmd.class.getName()); @@ -79,10 +82,10 @@ public class ListAffinityGroupsCmd extends BaseListAccountResourcesCmd { public void execute() { ListResponse response = _queryService.listAffinityGroups(id, affinityGroupName, - affinityGroupType, virtualMachineId, this.getAccountName(), this.getDomainId(), this.isRecursive(), - this.listAll(), this.getStartIndex(), this.getPageSizeVal(), this.getKeyword()); + affinityGroupType, virtualMachineId, getAccountName(), getDomainId(), isRecursive(), + listAll(), getStartIndex(), getPageSizeVal(), getKeyword()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } diff --git a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java index 7bb1c5bb4a0..66201477b97 100644 --- a/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/affinitygroup/UpdateVMAffinityGroupCmd.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.affinity.AffinityGroupResponse; import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; @@ -31,6 +32,7 @@ import org.apache.cloudstack.api.ApiConstants.VMDetails; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.context.CallContext; @@ -41,11 +43,16 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; @APICommand(name = "updateVMAffinityGroup", description = "Updates the affinity/anti-affinity group associations of a virtual machine. The VM has to be stopped and restarted for the " + "new properties to take effect.", - responseObject = UserVmResponse.class) + responseObject = UserVmResponse.class, + responseView = ResponseView.Restricted, + entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = true) public class UpdateVMAffinityGroupCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateVMAffinityGroupCmd.class.getName()); private static final String s_name = "updatevirtualmachineresponse"; @@ -54,7 +61,7 @@ public class UpdateVMAffinityGroupCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @ACL + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") private Long id; @@ -137,10 +144,10 @@ public class UpdateVMAffinityGroupCmd extends BaseAsyncCmd { dc.add(VMDetails.valueOf("affgrp")); EnumSet details = EnumSet.copyOf(dc); - if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", details, result).get(0); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", details, result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm's affinity groups"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScalePolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScalePolicyCmd.java index ce6dc68b074..4541efa7980 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScalePolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScalePolicyCmd.java @@ -39,7 +39,9 @@ import com.cloud.user.Account; @APICommand(name = "createAutoScalePolicy", description = "Creates an autoscale policy for a provision or deprovision action, the action is taken when the all the conditions evaluates to true for the specified duration. The policy is in effect once it is attached to a autscale vm group.", - responseObject = AutoScalePolicyResponse.class) + responseObject = AutoScalePolicyResponse.class, entityType = {AutoScalePolicy.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateAutoScalePolicyCmd.class.getName()); @@ -163,15 +165,15 @@ public class CreateAutoScalePolicyCmd extends BaseAsyncCreateCmd { AutoScalePolicy result = _entityMgr.findById(AutoScalePolicy.class, getEntityId()); AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } @Override public void create() throws ResourceAllocationException { AutoScalePolicy result = _autoScaleService.createAutoScalePolicy(this); if (result != null) { - this.setEntityId(result.getId()); - this.setEntityUuid(result.getUuid()); + setEntityId(result.getId()); + setEntityUuid(result.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create AutoScale Policy"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java index 55479748990..1fd0029e342 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmGroupCmd.java @@ -20,6 +20,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -40,7 +41,9 @@ import com.cloud.network.rules.LoadBalancer; @APICommand(name = "createAutoScaleVmGroup", description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", - responseObject = AutoScaleVmGroupResponse.class) + responseObject = AutoScaleVmGroupResponse.class, entityType = {AutoScaleVmGroup.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateAutoScaleVmGroupCmd.class.getName()); @@ -95,6 +98,9 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd { description = "the autoscale profile that contains information about the vms in the vm group.") private long profileId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the group to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -178,12 +184,16 @@ public class CreateAutoScaleVmGroupCmd extends BaseAsyncCreateCmd { return ApiCommandJobType.AutoScaleVmGroup; } + public Boolean getDisplay() { + return display; + } + @Override public void create() throws ResourceAllocationException { AutoScaleVmGroup result = _autoScaleService.createAutoScaleVmGroup(this); if (result != null) { - this.setEntityId(result.getId()); - this.setEntityUuid(result.getUuid()); + setEntityId(result.getId()); + setEntityUuid(result.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Autoscale Vm Group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java index bee1b22ea85..189217a2022 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateAutoScaleVmProfileCmd.java @@ -21,6 +21,7 @@ import java.util.Map; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -44,7 +45,9 @@ import com.cloud.user.User; @APICommand(name = "createAutoScaleVmProfile", description = "Creates a profile that contains information about the virtual machine which will be provisioned automatically by autoscale feature.", - responseObject = AutoScaleVmProfileResponse.class) + responseObject = AutoScaleVmProfileResponse.class, entityType = {AutoScaleVmProfile.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) @SuppressWarnings("rawtypes") public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateAutoScaleVmProfileCmd.class.getName()); @@ -97,6 +100,9 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd { description = "the ID of the user used to launch and destroy the VMs") private Long autoscaleUserId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the profile to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + private Map otherDeployParamMap; // /////////////////////////////////////////////////// @@ -125,6 +131,10 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd { return templateId; } + public Boolean getDisplay() { + return display; + } + public Map getCounterParamList() { return counterParamList; } @@ -235,7 +245,7 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd { AutoScaleVmProfile result = _entityMgr.findById(AutoScaleVmProfile.class, getEntityId()); AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } @Override @@ -243,8 +253,8 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd { AutoScaleVmProfile result = _autoScaleService.createAutoScaleVmProfile(this); if (result != null) { - this.setEntityId(result.getId()); - this.setEntityUuid(result.getUuid()); + setEntityId(result.getId()); + setEntityUuid(result.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Autoscale Vm Profile"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java index 914848a40c8..847866ef3ae 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java @@ -35,7 +35,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.ResourceAllocationException; import com.cloud.network.as.Condition; -@APICommand(name = "createCondition", description = "Creates a condition", responseObject = ConditionResponse.class) +@APICommand(name = "createCondition", description = "Creates a condition", responseObject = ConditionResponse.class, entityType = {Condition.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateConditionCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateConditionCmd.class.getName()); private static final String s_name = "conditionresponse"; @@ -69,8 +70,8 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd { condition = _autoScaleService.createCondition(this); if (condition != null) { - this.setEntityId(condition.getId()); - this.setEntityUuid(condition.getUuid()); + setEntityId(condition.getId()); + setEntityUuid(condition.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create condition."); } @@ -81,7 +82,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd { Condition condition = _entityMgr.findById(Condition.class, getEntityId()); ConditionResponse response = _responseGenerator.createConditionResponse(condition); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } // ///////////////////////////////////////////////// @@ -137,7 +138,7 @@ public class CreateConditionCmd extends BaseAsyncCreateCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, null, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScalePolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScalePolicyCmd.java index 1aedf574682..c0a3a00f7d4 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScalePolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScalePolicyCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.autoscale; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -33,7 +35,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.AutoScalePolicy; import com.cloud.user.Account; -@APICommand(name = "deleteAutoScalePolicy", description = "Deletes a autoscale policy.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteAutoScalePolicy", description = "Deletes a autoscale policy.", responseObject = SuccessResponse.class, entityType = {AutoScalePolicy.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteAutoScalePolicyCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteAutoScalePolicyCmd.class.getName()); private static final String s_name = "deleteautoscalepolicyresponse"; @@ -41,6 +44,7 @@ public class DeleteAutoScalePolicyCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AutoScalePolicyResponse.class, @@ -93,7 +97,7 @@ public class DeleteAutoScalePolicyCmd extends BaseAsyncCmd { if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { s_logger.warn("Failed to delete autoscale policy " + getId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete AutoScale Policy"); diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmGroupCmd.java index a7823b4920c..a9d2f4e2329 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmGroupCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.autoscale; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -33,7 +35,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.AutoScaleVmGroup; import com.cloud.user.Account; -@APICommand(name = "deleteAutoScaleVmGroup", description = "Deletes a autoscale vm group.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteAutoScaleVmGroup", description = "Deletes a autoscale vm group.", responseObject = SuccessResponse.class, entityType = {AutoScaleVmGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteAutoScaleVmGroupCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteAutoScaleVmGroupCmd.class.getName()); private static final String s_name = "deleteautoscalevmgroupresponse"; @@ -41,6 +44,7 @@ public class DeleteAutoScaleVmGroupCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AutoScaleVmGroupResponse.class, @@ -93,7 +97,7 @@ public class DeleteAutoScaleVmGroupCmd extends BaseAsyncCmd { if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { s_logger.warn("Failed to delete autoscale vm group " + getId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete autoscale vm group"); diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmProfileCmd.java index 3d6d0305f88..779315a96dd 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmProfileCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteAutoScaleVmProfileCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.autoscale; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -33,7 +35,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.AutoScaleVmProfile; import com.cloud.user.Account; -@APICommand(name = "deleteAutoScaleVmProfile", description = "Deletes a autoscale vm profile.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteAutoScaleVmProfile", description = "Deletes a autoscale vm profile.", responseObject = SuccessResponse.class, entityType = {AutoScaleVmProfile.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteAutoScaleVmProfileCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteAutoScaleVmProfileCmd.class.getName()); private static final String s_name = "deleteautoscalevmprofileresponse"; @@ -41,6 +44,7 @@ public class DeleteAutoScaleVmProfileCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AutoScaleVmProfileResponse.class, @@ -92,7 +96,7 @@ public class DeleteAutoScaleVmProfileCmd extends BaseAsyncCmd { boolean result = _autoScaleService.deleteAutoScaleVmProfile(id); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { s_logger.warn("Failed to delete autoscale vm profile " + getId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete autoscale vm profile"); diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteConditionCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteConditionCmd.java index 0cc23195c5a..24f4cc68784 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteConditionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/DeleteConditionCmd.java @@ -19,6 +19,8 @@ package org.apache.cloudstack.api.command.user.autoscale; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -34,7 +36,8 @@ import com.cloud.exception.ResourceInUseException; import com.cloud.network.as.Condition; import com.cloud.user.Account; -@APICommand(name = "deleteCondition", description = "Removes a condition", responseObject = SuccessResponse.class) +@APICommand(name = "deleteCondition", description = "Removes a condition", responseObject = SuccessResponse.class, entityType = {Condition.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteConditionCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteConditionCmd.class.getName()); private static final String s_name = "deleteconditionresponse"; @@ -43,6 +46,7 @@ public class DeleteConditionCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ConditionResponse.class, required = true, description = "the ID of the condition.") private Long id; @@ -61,7 +65,7 @@ public class DeleteConditionCmd extends BaseAsyncCmd { } if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { s_logger.warn("Failed to delete condition " + getId()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete condition."); diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/DisableAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/DisableAutoScaleVmGroupCmd.java index 2bd6f87b01c..8eb1809f887 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/DisableAutoScaleVmGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/DisableAutoScaleVmGroupCmd.java @@ -19,6 +19,8 @@ package org.apache.cloudstack.api.command.user.autoscale; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -32,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.AutoScaleVmGroup; import com.cloud.user.Account; -@APICommand(name = "disableAutoScaleVmGroup", description = "Disables an AutoScale Vm Group", responseObject = AutoScaleVmGroupResponse.class) +@APICommand(name = "disableAutoScaleVmGroup", description = "Disables an AutoScale Vm Group", responseObject = AutoScaleVmGroupResponse.class, entityType = {AutoScaleVmGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DisableAutoScaleVmGroupCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DisableAutoScaleVmGroupCmd.class.getName()); private static final String s_name = "disableautoscalevmGroupresponse"; @@ -41,6 +44,7 @@ public class DisableAutoScaleVmGroupCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AutoScaleVmGroupResponse.class, @@ -58,7 +62,7 @@ public class DisableAutoScaleVmGroupCmd extends BaseAsyncCmd { if (result != null) { AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable AutoScale Vm Group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/EnableAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/EnableAutoScaleVmGroupCmd.java index dc89f2b0794..59c9f7a9aa3 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/EnableAutoScaleVmGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/EnableAutoScaleVmGroupCmd.java @@ -19,6 +19,8 @@ package org.apache.cloudstack.api.command.user.autoscale; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -32,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.AutoScaleVmGroup; import com.cloud.user.Account; -@APICommand(name = "enableAutoScaleVmGroup", description = "Enables an AutoScale Vm Group", responseObject = AutoScaleVmGroupResponse.class) +@APICommand(name = "enableAutoScaleVmGroup", description = "Enables an AutoScale Vm Group", responseObject = AutoScaleVmGroupResponse.class, entityType = {AutoScaleVmGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class EnableAutoScaleVmGroupCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(EnableAutoScaleVmGroupCmd.class.getName()); private static final String s_name = "enableautoscalevmGroupresponse"; @@ -41,6 +44,7 @@ public class EnableAutoScaleVmGroupCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AutoScaleVmGroupResponse.class, @@ -58,7 +62,7 @@ public class EnableAutoScaleVmGroupCmd extends BaseAsyncCmd { if (result != null) { AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable AutoScale Vm Group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScalePoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScalePoliciesCmd.java index 84ed30a25ce..c2b244f2a7f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScalePoliciesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScalePoliciesCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.network.as.AutoScalePolicy; -@APICommand(name = "listAutoScalePolicies", description = "Lists autoscale policies.", responseObject = AutoScalePolicyResponse.class) +@APICommand(name = "listAutoScalePolicies", description = "Lists autoscale policies.", responseObject = AutoScalePolicyResponse.class, entityType = {AutoScalePolicy.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListAutoScalePoliciesCmd extends BaseListAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListAutoScalePoliciesCmd.class.getName()); @@ -99,7 +100,7 @@ public class ListAutoScalePoliciesCmd extends BaseListAccountResourcesCmd { } response.setResponses(responses); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmGroupsCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmGroupsCmd.java index 4eda7a80608..37c90b9bfdb 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmGroupsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmGroupsCmd.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; @@ -35,7 +36,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.as.AutoScaleVmGroup; -@APICommand(name = "listAutoScaleVmGroups", description = "Lists autoscale vm groups.", responseObject = AutoScaleVmGroupResponse.class) +@APICommand(name = "listAutoScaleVmGroups", description = "Lists autoscale vm groups.", responseObject = AutoScaleVmGroupResponse.class, entityType = {AutoScaleVmGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListAutoScaleVmGroupsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListAutoScaleVmGroupsCmd.class.getName()); @@ -60,6 +62,9 @@ public class ListAutoScaleVmGroupsCmd extends BaseListProjectAndAccountResources @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the availability zone ID") private Long zoneId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -84,6 +89,14 @@ public class ListAutoScaleVmGroupsCmd extends BaseListProjectAndAccountResources return zoneId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// @@ -110,6 +123,6 @@ public class ListAutoScaleVmGroupsCmd extends BaseListProjectAndAccountResources } response.setResponses(responses); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmProfilesCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmProfilesCmd.java index 651f98703e8..554b48854a4 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmProfilesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListAutoScaleVmProfilesCmd.java @@ -21,17 +21,21 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse; import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.TemplateResponse; +import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.network.as.AutoScaleVmProfile; -@APICommand(name = "listAutoScaleVmProfiles", description = "Lists autoscale vm profiles.", responseObject = AutoScaleVmProfileResponse.class) +@APICommand(name = "listAutoScaleVmProfiles", description = "Lists autoscale vm profiles.", responseObject = AutoScaleVmProfileResponse.class, entityType = {AutoScaleVmProfile.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListAutoScaleVmProfilesCmd.class.getName()); @@ -47,9 +51,18 @@ public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourc @Parameter(name = ApiConstants.TEMPLATE_ID, type = CommandType.UUID, entityType = TemplateResponse.class, description = "the templateid of the autoscale vm profile") private Long templateId; + @Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, description = "list profiles by service offering id", since = "4.4") + private Long serviceOffId; + @Parameter(name = ApiConstants.OTHER_DEPLOY_PARAMS, type = CommandType.STRING, description = "the otherdeployparameters of the autoscale vm profile") private String otherDeployParams; + @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, since = "4.4", description = "availability zone for the auto deployed virtual machine") + private Long zoneId; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -66,10 +79,27 @@ public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourc return otherDeployParams; } + public Long getServiceOfferingId() { + return serviceOffId; + } + + public Long getZoneId() { + return zoneId; + } + + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// + @Override public String getCommandName() { return s_name; @@ -89,7 +119,7 @@ public class ListAutoScaleVmProfilesCmd extends BaseListProjectAndAccountResourc } response.setResponses(responses); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListConditionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListConditionsCmd.java index 015f3ed2c6a..d75d64942f9 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListConditionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListConditionsCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.network.as.Condition; -@APICommand(name = "listConditions", description = "List Conditions for the specific user", responseObject = ConditionResponse.class) +@APICommand(name = "listConditions", description = "List Conditions for the specific user", responseObject = ConditionResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListConditionsCmd extends BaseListAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListConditionsCmd.class.getName()); private static final String s_name = "listconditionsresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListCountersCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListCountersCmd.java index f503b2bc81e..6a9ac8dfdcb 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/ListCountersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/ListCountersCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.network.as.Counter; import com.cloud.user.Account; -@APICommand(name = "listCounters", description = "List the counters", responseObject = CounterResponse.class) +@APICommand(name = "listCounters", description = "List the counters", responseObject = CounterResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListCountersCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListCountersCmd.class.getName()); private static final String s_name = "counterresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScalePolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScalePolicyCmd.java index 91adeb130b7..24858f4656b 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScalePolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScalePolicyCmd.java @@ -21,6 +21,8 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -36,7 +38,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.AutoScalePolicy; import com.cloud.user.Account; -@APICommand(name = "updateAutoScalePolicy", description = "Updates an existing autoscale policy.", responseObject = AutoScalePolicyResponse.class) +@APICommand(name = "updateAutoScalePolicy", description = "Updates an existing autoscale policy.", responseObject = AutoScalePolicyResponse.class, entityType = {AutoScalePolicy.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateAutoScalePolicyCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateAutoScalePolicyCmd.class.getName()); @@ -61,6 +64,7 @@ public class UpdateAutoScalePolicyCmd extends BaseAsyncCmd { description = "the list of IDs of the conditions that are being evaluated on every interval") private List conditionIds; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AutoScalePolicyResponse.class, @@ -75,7 +79,7 @@ public class UpdateAutoScalePolicyCmd extends BaseAsyncCmd { if (result != null) { AutoScalePolicyResponse response = _responseGenerator.createAutoScalePolicyResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update autoscale policy"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java index dbbd85f1c3a..76fa3d75d18 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmGroupCmd.java @@ -21,11 +21,14 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.AutoScalePolicyResponse; @@ -36,8 +39,9 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.AutoScaleVmGroup; import com.cloud.user.Account; -@APICommand(name = "updateAutoScaleVmGroup", description = "Updates an existing autoscale vm group.", responseObject = AutoScaleVmGroupResponse.class) -public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd { +@APICommand(name = "updateAutoScaleVmGroup", description = "Updates an existing autoscale vm group.", responseObject = AutoScaleVmGroupResponse.class, entityType = {AutoScaleVmGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateAutoScaleVmGroupCmd.class.getName()); private static final String s_name = "updateautoscalevmgroupresponse"; @@ -73,6 +77,7 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd { description = "list of scaledown autoscale policies") private List scaleDownPolicyIds; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AutoScaleVmGroupResponse.class, @@ -80,6 +85,9 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd { description = "the ID of the autoscale group") private Long id; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the group to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// @@ -91,7 +99,7 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd { if (result != null) { AutoScaleVmGroupResponse response = _responseGenerator.createAutoScaleVmGroupResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update autoscale VmGroup"); } @@ -125,6 +133,10 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd { return scaleDownPolicyIds; } + public Boolean getDisplay() { + return display; + } + @Override public String getEventType() { return EventTypes.EVENT_AUTOSCALEVMGROUP_UPDATE; @@ -154,4 +166,11 @@ public class UpdateAutoScaleVmGroupCmd extends BaseAsyncCmd { public ApiCommandJobType getInstanceType() { return ApiCommandJobType.AutoScaleVmGroup; } + + @Override + public void checkUuid() { + if (getCustomId() != null) { + _uuidMgr.checkUuid(getCustomId(), AutoScaleVmGroup.class); + } + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java index f3361d82fd9..deebe2ecc9a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/UpdateAutoScaleVmProfileCmd.java @@ -21,11 +21,14 @@ import java.util.Map; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.AutoScaleVmProfileResponse; @@ -37,8 +40,9 @@ import com.cloud.event.EventTypes; import com.cloud.network.as.AutoScaleVmProfile; import com.cloud.user.Account; -@APICommand(name = "updateAutoScaleVmProfile", description = "Updates an existing autoscale vm profile.", responseObject = AutoScaleVmProfileResponse.class) -public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd { +@APICommand(name = "updateAutoScaleVmProfile", description = "Updates an existing autoscale vm profile.", responseObject = AutoScaleVmProfileResponse.class, entityType = {AutoScaleVmProfile.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateAutoScaleVmProfileCmd.class.getName()); private static final String s_name = "updateautoscalevmprofileresponse"; @@ -47,6 +51,7 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AutoScaleVmProfileResponse.class, @@ -76,6 +81,9 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd { description = "the ID of the user used to launch and destroy the VMs") private Long autoscaleUserId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the profile to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// @@ -87,7 +95,7 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd { if (result != null) { AutoScaleVmProfileResponse response = _responseGenerator.createAutoScaleVmProfileResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update autoscale vm profile"); } @@ -117,6 +125,10 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd { return destroyVmGraceperiod; } + public Boolean getDisplay() { + return display; + } + @Override public String getEventType() { return EventTypes.EVENT_AUTOSCALEVMPROFILE_UPDATE; @@ -146,4 +158,11 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd { public ApiCommandJobType getInstanceType() { return ApiCommandJobType.AutoScaleVmProfile; } + + @Override + public void checkUuid() { + if (getCustomId() != null) { + _uuidMgr.checkUuid(getCustomId(), AutoScaleVmProfile.class); + } + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java b/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java index 5c008148207..e6696e17ff0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java @@ -26,7 +26,8 @@ import org.apache.cloudstack.api.response.CapabilitiesResponse; import com.cloud.user.Account; -@APICommand(name = "listCapabilities", description = "Lists capabilities", responseObject = CapabilitiesResponse.class) +@APICommand(name = "listCapabilities", description = "Lists capabilities", responseObject = CapabilitiesResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListCapabilitiesCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ListCapabilitiesCmd.class.getName()); @@ -52,6 +53,7 @@ public class ListCapabilitiesCmd extends BaseCmd { response.setSupportELB((String)capabilities.get("supportELB")); response.setProjectInviteRequired((Boolean)capabilities.get("projectInviteRequired")); response.setAllowUsersCreateProjects((Boolean)capabilities.get("allowusercreateprojects")); + response.setDiskOffMinSize((Long)capabilities.get("customDiskOffMinSize")); response.setDiskOffMaxSize((Long)capabilities.get("customDiskOffMaxSize")); response.setRegionSecondaryEnabled((Boolean)capabilities.get("regionSecondaryEnabled")); response.setKVMSnapshotEnabled((Boolean)capabilities.get("KVMSnapshotEnabled")); diff --git a/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java index e51f85071de..e4970d6530e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/event/ArchiveEventsCmd.java @@ -31,10 +31,12 @@ import org.apache.cloudstack.api.response.EventResponse; import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.cloudstack.context.CallContext; +import com.cloud.event.Event; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; -@APICommand(name = "archiveEvents", description = "Archive one or more events.", responseObject = SuccessResponse.class) +@APICommand(name = "archiveEvents", description = "Archive one or more events.", responseObject = SuccessResponse.class, entityType = {Event.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ArchiveEventsCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ArchiveEventsCmd.class.getName()); @@ -111,7 +113,7 @@ public class ArchiveEventsCmd extends BaseCmd { boolean result = _mgr.archiveEvents(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to archive Events, one or more parameters has invalid values"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java index d00b58dd826..defb0096962 100644 --- a/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/event/DeleteEventsCmd.java @@ -31,10 +31,12 @@ import org.apache.cloudstack.api.response.EventResponse; import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.cloudstack.context.CallContext; +import com.cloud.event.Event; import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; -@APICommand(name = "deleteEvents", description = "Delete one or more events.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteEvents", description = "Delete one or more events.", responseObject = SuccessResponse.class, entityType = {Event.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteEventsCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteEventsCmd.class.getName()); @@ -111,7 +113,7 @@ public class DeleteEventsCmd extends BaseCmd { boolean result = _mgr.deleteEvents(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Unable to delete Events, one or more parameters has invalid values"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/event/ListEventTypesCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/ListEventTypesCmd.java index 7a58d4c32ed..91f316c3d00 100644 --- a/api/src/org/apache/cloudstack/api/command/user/event/ListEventTypesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/event/ListEventTypesCmd.java @@ -27,7 +27,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.user.Account; -@APICommand(name = "listEventTypes", description = "List Event Types", responseObject = EventTypeResponse.class) +@APICommand(name = "listEventTypes", description = "List Event Types", responseObject = EventTypeResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListEventTypesCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ListEventTypesCmd.class.getName()); private static final String s_name = "listeventtypesresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/event/ListEventsCmd.java b/api/src/org/apache/cloudstack/api/command/user/event/ListEventsCmd.java index 0e45e4e86f4..a4934fa1dd9 100644 --- a/api/src/org/apache/cloudstack/api/command/user/event/ListEventsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/event/ListEventsCmd.java @@ -27,7 +27,10 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.EventResponse; import org.apache.cloudstack.api.response.ListResponse; -@APICommand(name = "listEvents", description = "A command to list events.", responseObject = EventResponse.class) +import com.cloud.event.Event; + +@APICommand(name = "listEvents", description = "A command to list events.", responseObject = EventResponse.class, entityType = {Event.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListEventsCmd.class.getName()); @@ -108,6 +111,6 @@ public class ListEventsCmd extends BaseListProjectAndAccountResourcesCmd { ListResponse response = _queryService.searchForEvents(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java index 778a18bc07c..579cccbfb25 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -43,7 +44,8 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.user.Account; import com.cloud.utils.net.NetUtils; -@APICommand(name = "createEgressFirewallRule", description = "Creates a egress firewall rule for a given network ", responseObject = FirewallResponse.class) +@APICommand(name = "createEgressFirewallRule", description = "Creates a egress firewall rule for a given network ", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements FirewallRule { public static final Logger s_logger = Logger.getLogger(CreateEgressFirewallRuleCmd.class.getName()); @@ -84,6 +86,9 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "type of firewallrule: system/user") private String type; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -221,8 +226,8 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F @Override public long getDomainId() { Network network = _networkService.getNetwork(networkId); - return network.getDomainId(); - } + return network.getDomainId(); + } @Override public void create() { @@ -249,9 +254,9 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F } if (getVpcId() != null) { - throw new InvalidParameterValueException("Unable to create firewall rule for the network id=" + networkId + - " as firewall egress rule can be created only for non vpc networks."); - } + throw new InvalidParameterValueException("Unable to create firewall rule for the network id=" + networkId + + " as firewall egress rule can be created only for non vpc networks."); + } try { FirewallRule result = _firewallService.createEgressFirewallRule(this); @@ -270,8 +275,8 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F @Override public String getEventDescription() { - Network network = _networkService.getNetwork(networkId); - return ("Creating firewall rule for network: " + network + " for protocol:" + this.getProtocol()); + Network network = _networkService.getNetwork(networkId); + return ("Creating firewall rule for network: " + network + " for protocol:" + getProtocol()); } @Override @@ -287,7 +292,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F @Override public Long getSyncObjId() { - return getNetworkId(); + return getNetworkId(); } @Override @@ -332,7 +337,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F @Override public TrafficType getTrafficType() { - return TrafficType.Egress; + return TrafficType.Egress; } @Override @@ -341,4 +346,18 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F return null; } + @Override + public boolean isDisplay() { + if (display != null) { + return display; + } else { + return true; + } + } + + @Override + public Class getEntityType() { + return FirewallRule.class; + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java index 44aa26fa519..b09d3a73a76 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -42,7 +43,8 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.user.Account; import com.cloud.utils.net.NetUtils; -@APICommand(name = "createFirewallRule", description = "Creates a firewall rule for a given ip address", responseObject = FirewallResponse.class) +@APICommand(name = "createFirewallRule", description = "Creates a firewall rule for a given ip address", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements FirewallRule { public static final Logger s_logger = Logger.getLogger(CreateFirewallRuleCmd.class.getName()); @@ -83,10 +85,14 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, description = "type of firewallrule: system/user") private String type; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// + public Long getIpAddressId() { return ipAddressId; } @@ -210,7 +216,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal if (ntwkId == null) { throw new InvalidParameterValueException("Unable to create firewall rule for the ipAddress id=" + ipAddressId + - " as ip is not associated with any network and no networkId is passed in"); + " as ip is not associated with any network and no networkId is passed in"); } return ntwkId; } @@ -261,7 +267,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal @Override public String getEventDescription() { IpAddress ip = _networkService.getIp(ipAddressId); - return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + this.getProtocol()); + return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + getProtocol()); } @Override @@ -303,7 +309,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal if (icmpType != null) { return icmpType; } else if (protocol.equalsIgnoreCase(NetUtils.ICMP_PROTO)) { - return -1; + return -1; } return null; @@ -333,4 +339,18 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal return FirewallRule.TrafficType.Ingress; } + @Override + public boolean isDisplay() { + if (display != null) { + return display; + } else { + return true; + } + } + + @Override + public Class getEntityType() { + return FirewallRule.class; + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java index 89dc0772562..f18767e1da6 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java @@ -20,6 +20,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -39,11 +40,16 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; +import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.PortForwardingRule; import com.cloud.user.Account; import com.cloud.utils.net.Ip; +import com.cloud.utils.net.NetUtils; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "createPortForwardingRule", description = "Creates a port forwarding rule", responseObject = FirewallRuleResponse.class) +@APICommand(name = "createPortForwardingRule", description = "Creates a port forwarding rule", responseObject = FirewallRuleResponse.class, entityType = {FirewallRule.class, + VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements PortForwardingRule { public static final Logger s_logger = Logger.getLogger(CreatePortForwardingRuleCmd.class.getName()); @@ -56,20 +62,20 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - required = true, - description = "the IP address id of the port forwarding rule") + required = true, + description = "the IP address id of the port forwarding rule") private Long ipAddressId; @Parameter(name = ApiConstants.PRIVATE_START_PORT, type = CommandType.INTEGER, required = true, - description = "the starting port of port forwarding rule's private port range") + description = "the starting port of port forwarding rule's private port range") private Integer privateStartPort; @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, required = true, - description = "the protocol for the port fowarding rule. Valid values are TCP or UDP.") + description = "the protocol for the port fowarding rule. Valid values are TCP or UDP.") private String protocol; @Parameter(name = ApiConstants.PRIVATE_END_PORT, @@ -81,7 +87,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P @Parameter(name = ApiConstants.PUBLIC_START_PORT, type = CommandType.INTEGER, required = true, - description = "the starting port of port forwarding rule's public port range") + description = "the starting port of port forwarding rule's public port range") private Integer publicStartPort; @Parameter(name = ApiConstants.PUBLIC_END_PORT, @@ -93,8 +99,8 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, - required = true, - description = "the ID of the virtual machine for the port forwarding rule") + required = true, + description = "the ID of the virtual machine for the port forwarding rule") private Long virtualMachineId; @Parameter(name = ApiConstants.CIDR_LIST, type = CommandType.LIST, collectionType = CommandType.STRING, description = "the cidr list to forward traffic from") @@ -114,9 +120,12 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P @Parameter(name = ApiConstants.VM_GUEST_IP, type = CommandType.STRING, required = false, - description = "VM guest nic Secondary ip address for the port forwarding rule") + description = "VM guest nic Secondary ip address for the port forwarding rule") private String vmSecondaryIp; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -281,7 +290,7 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P } if (ntwkId == null) { throw new InvalidParameterValueException("Unable to create port forwarding rule for the ipAddress id=" + ipAddressId + - " as ip is not associated with any network and no networkId is passed in"); + " as ip is not associated with any network and no networkId is passed in"); } return ntwkId; } @@ -334,13 +343,13 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P Ip privateIp = getVmSecondaryIp(); if (privateIp != null) { - if (!privateIp.isIp4()) { + if (!NetUtils.isValidIp(privateIp.toString())) { throw new InvalidParameterValueException("Invalid vm ip address"); } } try { - PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, getOpenFirewall()); + PortForwardingRule result = _rulesService.createPortForwardingRule(this, virtualMachineId, privateIp, getOpenFirewall(), isDisplay()); setEntityId(result.getId()); setEntityUuid(result.getUuid()); } catch (NetworkRuleConflictException ex) { @@ -415,4 +424,18 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P return null; } + @Override + public boolean isDisplay() { + if (display != null) { + return display; + } else { + return true; + } + } + + @Override + public Class getEntityType() { + return FirewallRule.class; + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java index 8e7b67996be..4d227722f8f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteEgressFirewallRuleCmd.java @@ -19,6 +19,8 @@ package org.apache.cloudstack.api.command.user.firewall; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -36,7 +38,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.rules.FirewallRule; -@APICommand(name = "deleteEgressFirewallRule", description = "Deletes an ggress firewall rule", responseObject = SuccessResponse.class) +@APICommand(name = "deleteEgressFirewallRule", description = "Deletes an ggress firewall rule", responseObject = SuccessResponse.class, entityType = {FirewallRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteEgressFirewallRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteEgressFirewallRuleCmd.class.getName()); private static final String s_name = "deleteegressfirewallruleresponse"; @@ -45,6 +48,7 @@ public class DeleteEgressFirewallRuleCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the firewall rule") private Long id; @@ -98,7 +102,7 @@ public class DeleteEgressFirewallRuleCmd extends BaseAsyncCmd { if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete egress firewall rule"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java index c3029b87d61..66dcc039c35 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/DeleteFirewallRuleCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.firewall; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -35,7 +37,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.rules.FirewallRule; -@APICommand(name = "deleteFirewallRule", description = "Deletes a firewall rule", responseObject = SuccessResponse.class) +@APICommand(name = "deleteFirewallRule", description = "Deletes a firewall rule", responseObject = SuccessResponse.class, entityType = {FirewallRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteFirewallRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteFirewallRuleCmd.class.getName()); private static final String s_name = "deletefirewallruleresponse"; @@ -43,7 +46,7 @@ public class DeleteFirewallRuleCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the firewall rule") private Long id; @@ -97,7 +100,7 @@ public class DeleteFirewallRuleCmd extends BaseAsyncCmd { if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete firewall rule"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java index c493dd08970..4c7b07f14f0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/DeletePortForwardingRuleCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.firewall; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -34,7 +36,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.rules.PortForwardingRule; -@APICommand(name = "deletePortForwardingRule", description = "Deletes a port forwarding rule", responseObject = SuccessResponse.class) +@APICommand(name = "deletePortForwardingRule", description = "Deletes a port forwarding rule", responseObject = SuccessResponse.class, entityType = {PortForwardingRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeletePortForwardingRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeletePortForwardingRuleCmd.class.getName()); private static final String s_name = "deleteportforwardingruleresponse"; @@ -43,6 +46,7 @@ public class DeletePortForwardingRuleCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java index 4ac94df50d5..e31496e4747 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListEgressFirewallRulesCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.api.response.NetworkResponse; import com.cloud.network.rules.FirewallRule; import com.cloud.utils.Pair; -@APICommand(name = "listEgressFirewallRules", description = "Lists all egress firewall rules for network id.", responseObject = FirewallResponse.class) +@APICommand(name = "listEgressFirewallRules", description = "Lists all egress firewall rules for network id.", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListEgressFirewallRulesCmd extends ListFirewallRulesCmd { public static final Logger s_logger = Logger.getLogger(ListEgressFirewallRulesCmd.class.getName()); private static final String s_name = "listegressfirewallrulesresponse"; @@ -91,6 +92,6 @@ public class ListEgressFirewallRulesCmd extends ListFirewallRulesCmd { } response.setResponses(fwResponses, result.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java index 44d26e405a4..9c9fbc83971 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; @@ -34,7 +35,8 @@ import org.apache.cloudstack.api.response.NetworkResponse; import com.cloud.network.rules.FirewallRule; import com.cloud.utils.Pair; -@APICommand(name = "listFirewallRules", description = "Lists all firewall rules for an IP address.", responseObject = FirewallResponse.class) +@APICommand(name = "listFirewallRules", description = "Lists all firewall rules for an IP address.", responseObject = FirewallResponse.class, entityType = {FirewallRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListFirewallRulesCmd.class.getName()); private static final String s_name = "listfirewallrulesresponse"; @@ -58,6 +60,9 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd { since = "4.3") private Long networkId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -78,6 +83,14 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd { return networkId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -100,6 +113,6 @@ public class ListFirewallRulesCmd extends BaseListTaggedResourcesCmd { } response.setResponses(fwResponses, result.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java index bd8a7a1c7a4..cde2563f9ab 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/ListPortForwardingRulesCmd.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; @@ -33,7 +34,8 @@ import org.apache.cloudstack.api.response.NetworkResponse; import com.cloud.network.rules.PortForwardingRule; import com.cloud.utils.Pair; -@APICommand(name = "listPortForwardingRules", description = "Lists all port forwarding rules for an IP address.", responseObject = FirewallRuleResponse.class) +@APICommand(name = "listPortForwardingRules", description = "Lists all port forwarding rules for an IP address.", responseObject = FirewallRuleResponse.class, entityType = {PortForwardingRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListPortForwardingRulesCmd.class.getName()); @@ -59,6 +61,9 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd { since = "4.3") private Long networkId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -75,6 +80,14 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd { return networkId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -97,6 +110,6 @@ public class ListPortForwardingRulesCmd extends BaseListTaggedResourcesCmd { } response.setResponses(fwResponses, result.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateEgressFirewallRuleCmd.java new file mode 100644 index 00000000000..079539624c7 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateEgressFirewallRuleCmd.java @@ -0,0 +1,122 @@ +// 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 org.apache.cloudstack.api.command.user.firewall; + +package org.apache.cloudstack.api.command.user.firewall; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.AccountResponse; +import org.apache.cloudstack.api.response.FirewallResponse; +import org.apache.cloudstack.api.response.FirewallRuleResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; + +import com.cloud.event.EventTypes; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.rules.FirewallRule; +import com.cloud.network.rules.FirewallRule.TrafficType; + +@APICommand(name = "updateEgressFirewallRule", description = "Updates egress firewall rule ", responseObject = FirewallResponse.class, since = "4.4", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateEgressFirewallRuleCmd extends BaseAsyncCustomIdCmd { + public static final Logger s_logger = Logger.getLogger(UpdateEgressFirewallRuleCmd.class.getName()); + + private static final String s_name = "updateegressfirewallruleresponse"; + + // /////////////////////////////////////////////////// + // ////////////// API parameters ///////////////////// + // /////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the egress firewall rule") + private Long id; + + // unexposed parameter needed for events logging + @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, expose = false) + private Long ownerId; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + + // /////////////////////////////////////////////////// + // ///////////////// Accessors /////////////////////// + // /////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + public Boolean getDisplay() { + return display; + } + // /////////////////////////////////////////////////// + // ///////////// API Implementation/////////////////// + // /////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public void execute() throws ResourceUnavailableException { + CallContext.current().setEventDetails("Rule Id: " + id); + FirewallRule rule = _firewallService.updateFirewallRule(id, this.getCustomId(), getDisplay()); + + FirewallResponse fwResponse = new FirewallResponse(); + if (rule != null) { + fwResponse = _responseGenerator.createFirewallResponse(rule); + setResponseObject(fwResponse); + } + fwResponse.setResponseName(getCommandName()); + } + + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), FirewallRule.class); + } + } + + @Override + public String getEventType() { + return EventTypes.EVENT_FIREWALL_UPDATE; + + } + + @Override + public String getEventDescription() { + return ("Updating egress firewall rule id=" + id); + + } + + @Override + public long getEntityOwnerId() { + if (ownerId == null) { + FirewallRule rule = _entityMgr.findById(FirewallRule.class, id); + if (rule == null || rule.getTrafficType() != TrafficType.Egress) { + throw new InvalidParameterValueException("Unable to find egress firewall rule by id"); + } else { + ownerId = _entityMgr.findById(FirewallRule.class, id).getAccountId(); + } + } + return ownerId; + } +} diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateFirewallRuleCmd.java new file mode 100644 index 00000000000..f68437192b7 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdateFirewallRuleCmd.java @@ -0,0 +1,123 @@ +// 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 org.apache.cloudstack.api.command.user.firewall; + +package org.apache.cloudstack.api.command.user.firewall; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.AccountResponse; +import org.apache.cloudstack.api.response.FirewallResponse; +import org.apache.cloudstack.api.response.FirewallRuleResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; + +import com.cloud.event.EventTypes; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.rules.FirewallRule; +import com.cloud.network.rules.FirewallRule.TrafficType; + +@APICommand(name = "updateFirewallRule", description = "Updates firewall rule ", responseObject = FirewallResponse.class, since = "4.4", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateFirewallRuleCmd extends BaseAsyncCustomIdCmd { + public static final Logger s_logger = Logger.getLogger(UpdateFirewallRuleCmd.class.getName()); + + private static final String s_name = "updatefirewallruleresponse"; + + // /////////////////////////////////////////////////// + // ////////////// API parameters ///////////////////// + // /////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the firewall rule") + private Long id; + + // unexposed parameter needed for events logging + @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, expose = false) + private Long ownerId; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + + // /////////////////////////////////////////////////// + // ///////////////// Accessors /////////////////////// + // /////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + public Boolean getDisplay() { + return display; + } + + // /////////////////////////////////////////////////// + // ///////////// API Implementation/////////////////// + // /////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public void execute() throws ResourceUnavailableException { + CallContext.current().setEventDetails("Rule Id: " + id); + FirewallRule rule = _firewallService.updateFirewallRule(id, this.getCustomId(), getDisplay()); + + FirewallResponse fwResponse = new FirewallResponse(); + if (rule != null) { + fwResponse = _responseGenerator.createFirewallResponse(rule); + setResponseObject(fwResponse); + } + fwResponse.setResponseName(getCommandName()); + } + + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), FirewallRule.class); + } + } + + @Override + public String getEventType() { + return EventTypes.EVENT_FIREWALL_UPDATE; + + } + + @Override + public String getEventDescription() { + return ("Updating firewall rule id=" + id); + + } + + @Override + public long getEntityOwnerId() { + if (ownerId == null) { + FirewallRule rule = _entityMgr.findById(FirewallRule.class, id); + if (rule == null || rule.getTrafficType() != TrafficType.Ingress) { + throw new InvalidParameterValueException("Unable to find firewall rule by id"); + } else { + ownerId = _entityMgr.findById(FirewallRule.class, id).getAccountId(); + } + } + return ownerId; + } +} \ No newline at end of file diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java index d7e380feb57..78525ba0d87 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/UpdatePortForwardingRuleCmd.java @@ -18,9 +18,11 @@ package org.apache.cloudstack.api.command.user.firewall; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.IPAddressResponse; @@ -29,39 +31,42 @@ import org.apache.cloudstack.api.response.UserVmResponse; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.IpAddress; +import com.cloud.network.rules.FirewallRule; +import com.cloud.network.rules.PortForwardingRule; import com.cloud.user.Account; @APICommand(name = "updatePortForwardingRule", responseObject = FirewallRuleResponse.class, - description = "Updates a port forwarding rule. Only the private port and the virtual machine can be updated.") -public class UpdatePortForwardingRuleCmd extends BaseAsyncCmd { + description = "Updates a port forwarding rule. Only the private port and the virtual machine can be updated.", entityType = {PortForwardingRule.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdatePortForwardingRuleCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdatePortForwardingRuleCmd.class.getName()); private static final String s_name = "updateportforwardingruleresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the port forwarding rule", since = "4.4") + private Long id; @Parameter(name = ApiConstants.PRIVATE_IP, type = CommandType.STRING, description = "the private IP address of the port forwarding rule") private String privateIp; - @Parameter(name = ApiConstants.PRIVATE_PORT, type = CommandType.STRING, required = true, description = "the private port of the port forwarding rule") + @Parameter(name = ApiConstants.PRIVATE_PORT, type = CommandType.STRING, description = "the private port of the port forwarding rule") private String privatePort; @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, - required = true, description = "the protocol for the port fowarding rule. Valid values are TCP or UDP.") private String protocol; @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, - required = true, description = "the IP address id of the port forwarding rule") private Long publicIpId; - @Parameter(name = ApiConstants.PUBLIC_PORT, type = CommandType.STRING, required = true, description = "the public port of the port forwarding rule") + @Parameter(name = ApiConstants.PUBLIC_PORT, type = CommandType.STRING, description = "the public port of the port forwarding rule") private String publicPort; @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, @@ -70,6 +75,9 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCmd { description = "the ID of the virtual machine for the port forwarding rule") private Long virtualMachineId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -98,6 +106,10 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCmd { return virtualMachineId; } + public Boolean getDisplay() { + return display; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -128,8 +140,22 @@ public class UpdatePortForwardingRuleCmd extends BaseAsyncCmd { return "updating port forwarding rule"; } + @Override + public void checkUuid() { + if (getCustomId() != null) { + _uuidMgr.checkUuid(getCustomId(), FirewallRule.class); + } + } + @Override public void execute() { + PortForwardingRule rule = _rulesService.updatePortForwardingRule(id, getCustomId(), getDisplay()); + FirewallRuleResponse fwResponse = new FirewallRuleResponse(); + if (rule != null) { + fwResponse = _responseGenerator.createPortForwardingRuleResponse(rule); + setResponseObject(fwResponse); + } + fwResponse.setResponseName(getCommandName()); //FIXME: PortForwardingRule result = _mgr.updatePortForwardingRule(this); // if (result != null) { // FirewallRuleResponse response = _responseGenerator.createFirewallRuleResponse(result); diff --git a/api/src/org/apache/cloudstack/api/command/user/guest/ListGuestOsCategoriesCmd.java b/api/src/org/apache/cloudstack/api/command/user/guest/ListGuestOsCategoriesCmd.java index 604f1ede0df..e82e3c45d1f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/guest/ListGuestOsCategoriesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/guest/ListGuestOsCategoriesCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.storage.GuestOsCategory; import com.cloud.utils.Pair; -@APICommand(name = "listOsCategories", description = "Lists all supported OS categories for this cloud.", responseObject = GuestOSCategoryResponse.class) +@APICommand(name = "listOsCategories", description = "Lists all supported OS categories for this cloud.", responseObject = GuestOSCategoryResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListGuestOsCategoriesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListIsosCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/guest/ListGuestOsCmd.java b/api/src/org/apache/cloudstack/api/command/user/guest/ListGuestOsCmd.java index 287fb1e8ef5..15a625abfaa 100644 --- a/api/src/org/apache/cloudstack/api/command/user/guest/ListGuestOsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/guest/ListGuestOsCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.storage.GuestOS; import com.cloud.utils.Pair; -@APICommand(name = "listOsTypes", description = "Lists all supported OS types for this cloud.", responseObject = GuestOSResponse.class) +@APICommand(name = "listOsTypes", description = "Lists all supported OS types for this cloud.", responseObject = GuestOSResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListGuestOsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListIsosCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/AttachIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/AttachIsoCmd.java index d38c8164273..1b8087b8c12 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/AttachIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/AttachIsoCmd.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.command.user.vm.DeployVMCmd; import org.apache.cloudstack.api.response.TemplateResponse; @@ -33,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.uservm.UserVm; -@APICommand(name = "attachIso", description = "Attaches an ISO to a virtual machine.", responseObject = UserVmResponse.class) +@APICommand(name = "attachIso", description = "Attaches an ISO to a virtual machine.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class AttachIsoCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AttachIsoCmd.class.getName()); @@ -43,15 +45,13 @@ public class AttachIsoCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = TemplateResponse.class, required = true, description = "the ID of the ISO file") - private Long id; + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = TemplateResponse.class, + required = true, description = "the ID of the ISO file") + protected Long id; - @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, - type = CommandType.UUID, - entityType = UserVmResponse.class, - required = true, - description = "the ID of the virtual machine") - private Long virtualMachineId; + @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, + required = true, description = "the ID of the virtual machine") + protected Long virtualMachineId; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -91,7 +91,7 @@ public class AttachIsoCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "attaching ISO: " + getId() + " to vm: " + getVirtualMachineId(); + return "attaching ISO: " + getId() + " to vm: " + getVirtualMachineId(); } @Override @@ -101,9 +101,9 @@ public class AttachIsoCmd extends BaseAsyncCmd { if (result) { UserVm userVm = _responseGenerator.findUserVmById(virtualMachineId); if (userVm != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", userVm).get(0); response.setResponseName(DeployVMCmd.getResultObjectName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach iso"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/CopyIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/CopyIsoCmd.java index 36193182be3..9002624c487 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/CopyIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/CopyIsoCmd.java @@ -19,10 +19,12 @@ package org.apache.cloudstack.api.command.user.iso; import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd; import org.apache.cloudstack.api.response.TemplateResponse; -@APICommand(name = "copyIso", description = "Copies an iso from one zone to another.", responseObject = TemplateResponse.class) +@APICommand(name = "copyIso", description = "Copies an iso from one zone to another.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CopyIsoCmd extends CopyTemplateCmd { public static final Logger s_logger = Logger.getLogger(CopyIsoCmd.class.getName()); private static final String s_name = "copyisoresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java index 91ad5f1e11a..b07b08dbf84 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/DeleteIsoCmd.java @@ -34,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "deleteIso", description = "Deletes an ISO file.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteIso", description = "Deletes an ISO file.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteIsoCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteIsoCmd.class.getName()); private static final String s_name = "deleteisosresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/DetachIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/DetachIsoCmd.java index e40195b3185..97db2f37598 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/DetachIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/DetachIsoCmd.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.command.user.vm.DeployVMCmd; import org.apache.cloudstack.api.response.UserVmResponse; @@ -31,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.uservm.UserVm; -@APICommand(name = "detachIso", description = "Detaches any ISO file (if any) currently attached to a virtual machine.", responseObject = UserVmResponse.class) +@APICommand(name = "detachIso", description = "Detaches any ISO file (if any) currently attached to a virtual machine.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class DetachIsoCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DetachIsoCmd.class.getName()); @@ -41,12 +43,9 @@ public class DetachIsoCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, - type = CommandType.UUID, - entityType = UserVmResponse.class, - required = true, - description = "The ID of the virtual machine") - private Long virtualMachineId; + @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType = UserVmResponse.class, + required=true, description="The ID of the virtual machine") + protected Long virtualMachineId; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -82,7 +81,7 @@ public class DetachIsoCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "detaching ISO from vm: " + getVirtualMachineId(); + return "detaching ISO from vm: " + getVirtualMachineId(); } @Override @@ -90,9 +89,9 @@ public class DetachIsoCmd extends BaseAsyncCmd { boolean result = _templateService.detachIso(virtualMachineId); if (result) { UserVm userVm = _entityMgr.findById(UserVm.class, virtualMachineId); - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", userVm).get(0); response.setResponseName(DeployVMCmd.getResultObjectName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach iso"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ExtractIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ExtractIsoCmd.java index 2fb215aea5d..b78a3d3db66 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/ExtractIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/ExtractIsoCmd.java @@ -35,7 +35,8 @@ import com.cloud.exception.InternalErrorException; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "extractIso", description = "Extracts an ISO", responseObject = ExtractResponse.class) +@APICommand(name = "extractIso", description = "Extracts an ISO", responseObject = ExtractResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ExtractIsoCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ExtractIsoCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java index 9d9e44b447a..f8863d1f753 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java @@ -20,14 +20,15 @@ import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.TemplatePermissionsResponse; import com.cloud.storage.Storage.ImageFormat; import com.cloud.template.VirtualMachineTemplate; -@APICommand(name = "listIsoPermissions", - description = "List iso visibility and all accounts that have permissions to view this iso.", - responseObject = TemplatePermissionsResponse.class) +@APICommand(name = "listIsoPermissions", description = "List iso visibility and all accounts that have permissions to view this iso.", responseObject = TemplatePermissionsResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListIsoPermissionsCmd extends BaseListTemplateOrIsoPermissionsCmd { protected String getResponseName() { return "listisopermissionsresponse"; @@ -47,4 +48,9 @@ public class ListIsoPermissionsCmd extends BaseListTemplateOrIsoPermissionsCmd { protected boolean templateIsCorrectType(VirtualMachineTemplate template) { return template.getFormat().equals(ImageFormat.ISO); } + + @Override + public void execute() { + executeWithView(ResponseView.Restricted); + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java index 95b771fcc43..3aabf926fc6 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.ZoneResponse; @@ -31,7 +32,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.template.VirtualMachineTemplate.TemplateFilter; import com.cloud.user.Account; -@APICommand(name = "listIsos", description = "Lists all available ISO files.", responseObject = TemplateResponse.class) +@APICommand(name = "listIsos", description = "Lists all available ISO files.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListIsosCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListIsosCmd.class.getName()); @@ -119,7 +121,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd { public boolean listInReadyState() { Account account = CallContext.current().getCallingAccount(); // It is account specific if account is admin type and domainId and accountName are not null - boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null); + boolean isAccountSpecific = (account == null || _accountService.isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null); // Show only those that are downloaded. TemplateFilter templateFilter = TemplateFilter.valueOf(getIsoFilter()); boolean onlyReady = @@ -153,6 +155,6 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd { public void execute() { ListResponse response = _queryService.listIsos(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java index 29e3d678857..37f294c31dc 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java @@ -18,13 +18,12 @@ package org.apache.cloudstack.api.command.user.iso; import java.util.List; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.GuestOSResponse; @@ -33,11 +32,13 @@ import org.apache.cloudstack.api.response.ProjectResponse; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.exception.ResourceAllocationException; import com.cloud.template.VirtualMachineTemplate; -@APICommand(name = "registerIso", responseObject = TemplateResponse.class, description = "Registers an existing ISO into the CloudStack Cloud.") +@APICommand(name = "registerIso", responseObject = TemplateResponse.class, description = "Registers an existing ISO into the CloudStack Cloud.", responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RegisterIsoCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(RegisterIsoCmd.class.getName()); @@ -80,12 +81,9 @@ public class RegisterIsoCmd extends BaseCmd { @Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "the URL to where the ISO is currently being hosted") private String url; - @Parameter(name = ApiConstants.ZONE_ID, - type = CommandType.UUID, - entityType = ZoneResponse.class, - required = true, - description = "the ID of the zone you wish to register the ISO to.") - private Long zoneId; + @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class, + required=true, description="the ID of the zone you wish to register the ISO to.") + protected Long zoneId; @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, @@ -163,11 +161,11 @@ public class RegisterIsoCmd extends BaseCmd { } public String getImageStoreUuid() { - return this.imageStoreUuid; + return imageStoreUuid; } public Boolean isDynamicallyScalable() { - return isDynamicallyScalable == null ? false : isDynamicallyScalable; + return isDynamicallyScalable == null ? false : isDynamicallyScalable; } ///////////////////////////////////////////////////// @@ -181,7 +179,7 @@ public class RegisterIsoCmd extends BaseCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -194,10 +192,10 @@ public class RegisterIsoCmd extends BaseCmd { VirtualMachineTemplate template = _templateService.registerIso(this); if (template != null) { ListResponse response = new ListResponse(); - List templateResponses = _responseGenerator.createIsoResponses(template, zoneId, false); + List templateResponses = _responseGenerator.createIsoResponses(ResponseView.Restricted, template, zoneId, false); response.setResponses(templateResponses); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register iso"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java index 6a471c944f8..b569d657beb 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java @@ -21,13 +21,15 @@ import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.TemplateResponse; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "updateIso", description = "Updates an ISO file.", responseObject = TemplateResponse.class) +@APICommand(name = "updateIso", description = "Updates an ISO file.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateIsoCmd extends BaseUpdateTemplateOrIsoCmd { public static final Logger s_logger = Logger.getLogger(UpdateIsoCmd.class.getName()); private static final String s_name = "updateisoresponse"; @@ -69,9 +71,9 @@ public class UpdateIsoCmd extends BaseUpdateTemplateOrIsoCmd { public void execute() { VirtualMachineTemplate result = _templateService.updateTemplate(this); if (result != null) { - TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(result); + TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Restricted, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update iso"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java index 8267b5c294a..b52bc91c7a5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java @@ -25,7 +25,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "updateIsoPermissions", description = "Updates iso permissions", responseObject = SuccessResponse.class) +@APICommand(name = "updateIsoPermissions", description = "Updates iso permissions", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateIsoPermissionsCmd extends BaseUpdateTemplateOrIsoPermissionsCmd { @Override protected String getResponseName() { diff --git a/api/src/org/apache/cloudstack/api/command/user/job/ListAsyncJobsCmd.java b/api/src/org/apache/cloudstack/api/command/user/job/ListAsyncJobsCmd.java index 9d45d506bac..f7bfb94c7a0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/job/ListAsyncJobsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/job/ListAsyncJobsCmd.java @@ -25,7 +25,8 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.AsyncJobResponse; import org.apache.cloudstack.api.response.ListResponse; -@APICommand(name = "listAsyncJobs", description = "Lists all pending asynchronous jobs for the account.", responseObject = AsyncJobResponse.class) +@APICommand(name = "listAsyncJobs", description = "Lists all pending asynchronous jobs for the account.", responseObject = AsyncJobResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListAsyncJobsCmd extends BaseListAccountResourcesCmd { private static final String s_name = "listasyncjobsresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/job/QueryAsyncJobResultCmd.java b/api/src/org/apache/cloudstack/api/command/user/job/QueryAsyncJobResultCmd.java index 1f9f5dbc411..fc46300a7ac 100644 --- a/api/src/org/apache/cloudstack/api/command/user/job/QueryAsyncJobResultCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/job/QueryAsyncJobResultCmd.java @@ -26,7 +26,8 @@ import org.apache.cloudstack.api.response.AsyncJobResponse; import com.cloud.user.Account; -@APICommand(name = "queryAsyncJobResult", description = "Retrieves the current status of asynchronous job.", responseObject = AsyncJobResponse.class) +@APICommand(name = "queryAsyncJobResult", description = "Retrieves the current status of asynchronous job.", responseObject = AsyncJobResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QueryAsyncJobResultCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(QueryAsyncJobResultCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignCertToLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignCertToLoadBalancerCmd.java index 4ea4a588cea..ddafa72a674 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignCertToLoadBalancerCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignCertToLoadBalancerCmd.java @@ -1,3 +1,4 @@ + // 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 @@ -37,12 +38,13 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; -@APICommand(name = "assignCertToLoadBalancer", description = "Assigns a certificate to a Load Balancer Rule", responseObject = SuccessResponse.class) +@APICommand(name = "assignCertToLoadBalancer", description = "Assigns a certificate to a Load Balancer Rule", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AssignCertToLoadBalancerCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AssignCertToLoadBalancerCmd.class.getName()); - private static final String s_name = "assignCertToLoadBalancer"; + private static final String s_name = "assigncerttoloadbalancerresponse"; @Parameter(name = ApiConstants.LBID, type = CommandType.UUID, diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignToLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignToLoadBalancerRuleCmd.java index bcf6200ca10..a5199937f4e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignToLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/AssignToLoadBalancerRuleCmd.java @@ -16,10 +16,17 @@ // under the License. package org.apache.cloudstack.api.command.user.loadbalancer; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -33,13 +40,17 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; +import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; import com.cloud.utils.StringUtils; +import com.cloud.vm.VirtualMachine; @APICommand(name = "assignToLoadBalancerRule", description = "Assigns virtual machine or a list of virtual machines to a load balancer rule.", - responseObject = SuccessResponse.class) + responseObject = SuccessResponse.class, entityType = {FirewallRule.class, VirtualMachine.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AssignToLoadBalancerRuleCmd.class.getName()); @@ -49,6 +60,7 @@ public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, @@ -56,14 +68,20 @@ public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd { description = "the ID of the load balancer rule") private Long id; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.VIRTUAL_MACHINE_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = UserVmResponse.class, - required = true, description = "the list of IDs of the virtual machine that are being assigned to the load balancer rule(i.e. virtualMachineIds=1,2,3)") private List virtualMachineIds; + @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID_IP, + type = CommandType.MAP, + description = "VM ID and IP map, vmidipmap[0].vmid=1 vmidipmap[0].ip=10.1.1.75", + since = "4.4") + private Map vmIdIpMap; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -76,6 +94,10 @@ public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd { return virtualMachineIds; } + public Map getVmIdIpMap() { + return vmIdIpMap; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -104,13 +126,49 @@ public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd { return "applying instances for load balancer: " + getLoadBalancerId() + " (ids: " + StringUtils.join(getVirtualMachineIds(), ",") + ")"; } + + public Map> getVmIdIpListMap() { + Map> vmIdIpsMap = new HashMap>(); + if (vmIdIpMap != null && !vmIdIpMap.isEmpty()) { + Collection idIpsCollection = vmIdIpMap.values(); + Iterator iter = idIpsCollection.iterator(); + while (iter.hasNext()) { + HashMap idIpsMap = (HashMap)iter.next(); + String vmId = idIpsMap.get("vmid"); + String vmIp = idIpsMap.get("vmip"); + + VirtualMachine lbvm = _entityMgr.findByUuid(VirtualMachine.class, vmId); + if (lbvm == null) { + throw new InvalidParameterValueException("Unable to find virtual machine ID: " + vmId); + } + + Long longVmId = lbvm.getId(); + + List ipsList = null; + if (vmIdIpsMap.containsKey(longVmId)) { + ipsList = vmIdIpsMap.get(longVmId); + } else { + ipsList = new ArrayList(); + } + ipsList.add(vmIp); + vmIdIpsMap.put(longVmId, ipsList); + + } + } + + return vmIdIpsMap; + } + @Override public void execute() { CallContext.current().setEventDetails("Load balancer Id: " + getLoadBalancerId() + " VmIds: " + StringUtils.join(getVirtualMachineIds(), ",")); - boolean result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds); + + Map> vmIdIpsMap = getVmIdIpListMap(); + + boolean result = _lbService.assignToLoadBalancer(getLoadBalancerId(), virtualMachineIds, vmIdIpsMap); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign load balancer rule"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java index 0b8d3774dfa..fa9c22eec76 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateApplicationLoadBalancerCmd.java @@ -16,8 +16,7 @@ // under the License. package org.apache.cloudstack.api.command.user.loadbalancer; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -29,6 +28,7 @@ import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InsufficientAddressCapacityException; @@ -41,7 +41,8 @@ import com.cloud.network.Network; import com.cloud.network.rules.LoadBalancerContainer.Scheme; import com.cloud.utils.net.NetUtils; -@APICommand(name = "createLoadBalancer", description = "Creates a Load Balancer", responseObject = ApplicationLoadBalancerResponse.class, since = "4.2.0") +@APICommand(name = "createLoadBalancer", description = "Creates a Load Balancer", responseObject = ApplicationLoadBalancerResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateApplicationLoadBalancerCmd.class.getName()); @@ -94,9 +95,15 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd { description = "the load balancer scheme. Supported value in this release is Internal") private String scheme; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + public Boolean getDisplay() { + return display; + } public String getAlgorithm() { return algorithm; @@ -215,7 +222,7 @@ public class CreateApplicationLoadBalancerCmd extends BaseAsyncCreateCmd { ApplicationLoadBalancerRule result = _appLbService.createApplicationLoadBalancer(getName(), getDescription(), getScheme(), getSourceIpNetworkId(), getSourceIp(), getSourcePort(), - getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId()); + getInstancePort(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getDisplay()); this.setEntityId(result.getId()); this.setEntityUuid(result.getUuid()); } catch (NetworkRuleConflictException e) { diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java index 5ff7239e832..547274dc530 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBHealthCheckPolicyCmd.java @@ -39,7 +39,9 @@ import com.cloud.user.Account; @APICommand(name = "createLBHealthCheckPolicy", description = "Creates a Load Balancer healthcheck policy ", responseObject = LBHealthCheckResponse.class, - since = "4.2.0") + since = "4.2.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) @SuppressWarnings("rawtypes") public class CreateLBHealthCheckPolicyCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateLBHealthCheckPolicyCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java index 159fcf542d6..738f837ccd2 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLBStickinessPolicyCmd.java @@ -40,7 +40,8 @@ import com.cloud.network.rules.LoadBalancer; import com.cloud.network.rules.StickinessPolicy; import com.cloud.user.Account; -@APICommand(name = "createLBStickinessPolicy", description = "Creates a Load Balancer stickiness policy ", responseObject = LBStickinessResponse.class, since = "3.0.0") +@APICommand(name = "createLBStickinessPolicy", description = "Creates a Load Balancer stickiness policy ", responseObject = LBStickinessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) @SuppressWarnings("rawtypes") public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateLBStickinessPolicyCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java index 764e3793728..a405913f78e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java @@ -18,8 +18,7 @@ package org.apache.cloudstack.api.command.user.loadbalancer; import java.util.List; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -34,6 +33,7 @@ import org.apache.cloudstack.api.response.LoadBalancerResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; @@ -49,7 +49,8 @@ import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; import com.cloud.utils.net.NetUtils; -@APICommand(name = "createLoadBalancerRule", description = "Creates a load balancer rule", responseObject = LoadBalancerResponse.class) +@APICommand(name = "createLoadBalancerRule", description = "Creates a load balancer rule", responseObject = LoadBalancerResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements LoadBalancer */{ public static final Logger s_logger = Logger.getLogger(CreateLoadBalancerRuleCmd.class.getName()); @@ -116,10 +117,17 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L @Parameter(name = ApiConstants.PROTOCOL, type = CommandType.STRING, description = "The protocol for the LB") private String lbProtocol; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + public Boolean getDisplay() { + return display; + } + public String getAlgorithm() { return algorithm; } @@ -301,7 +309,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd /*implements L try { LoadBalancer result = _lbService.createPublicLoadBalancerRule(getXid(), getName(), getDescription(), getSourcePortStart(), getSourcePortEnd(), getDefaultPortStart(), - getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getOpenFirewall(), getLbProtocol()); + getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getOpenFirewall(), getLbProtocol(), getDisplay()); this.setEntityId(result.getId()); this.setEntityUuid(result.getUuid()); } catch (NetworkRuleConflictException e) { diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java index 0b53d53f808..8f4ecca58f8 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteApplicationLoadBalancerCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; -@APICommand(name = "deleteLoadBalancer", description = "Deletes a load balancer", responseObject = SuccessResponse.class, since = "4.2.0") +@APICommand(name = "deleteLoadBalancer", description = "Deletes a load balancer", responseObject = SuccessResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteApplicationLoadBalancerCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteApplicationLoadBalancerCmd.class.getName()); private static final String s_name = "deleteloadbalancerresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java index d625ed571e4..3f27477903c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBHealthCheckPolicyCmd.java @@ -34,7 +34,8 @@ import com.cloud.network.rules.HealthCheckPolicy; import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; -@APICommand(name = "deleteLBHealthCheckPolicy", description = "Deletes a load balancer HealthCheck policy.", responseObject = SuccessResponse.class, since = "4.2.0") +@APICommand(name = "deleteLBHealthCheckPolicy", description = "Deletes a load balancer HealthCheck policy.", responseObject = SuccessResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteLBHealthCheckPolicyCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteLBHealthCheckPolicyCmd.class.getName()); private static final String s_name = "deletelbhealthcheckpolicyresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java index c4f72d9742b..ffed94bff12 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLBStickinessPolicyCmd.java @@ -34,7 +34,8 @@ import com.cloud.network.rules.LoadBalancer; import com.cloud.network.rules.StickinessPolicy; import com.cloud.user.Account; -@APICommand(name = "deleteLBStickinessPolicy", description = "Deletes a LB stickiness policy.", responseObject = SuccessResponse.class, since = "3.0.0") +@APICommand(name = "deleteLBStickinessPolicy", description = "Deletes a LB stickiness policy.", responseObject = SuccessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteLBStickinessPolicyCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteLBStickinessPolicyCmd.class.getName()); private static final String s_name = "deleteLBstickinessrruleresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLoadBalancerRuleCmd.java index 1dc3cd17604..3423cab0518 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteLoadBalancerRuleCmd.java @@ -34,7 +34,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; -@APICommand(name = "deleteLoadBalancerRule", description = "Deletes a load balancer rule.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteLoadBalancerRule", description = "Deletes a load balancer rule.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteLoadBalancerRuleCmd.class.getName()); private static final String s_name = "deleteloadbalancerruleresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteSslCertCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteSslCertCmd.java index d5683b0b198..fab11250687 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteSslCertCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/DeleteSslCertCmd.java @@ -37,7 +37,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.lb.CertService; import com.cloud.utils.exception.CloudRuntimeException; -@APICommand(name = "deleteSslCert", description = "Delete a certificate to cloudstack", responseObject = SuccessResponse.class) +@APICommand(name = "deleteSslCert", description = "Delete a certificate to cloudstack", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteSslCertCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteSslCertCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java index 05572c81b13..f8696d4b3f6 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListApplicationLoadBalancersCmd.java @@ -19,8 +19,7 @@ package org.apache.cloudstack.api.command.user.loadbalancer; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; @@ -30,12 +29,14 @@ import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule; +import org.apache.log4j.Logger; import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.rules.LoadBalancerContainer.Scheme; import com.cloud.utils.Pair; -@APICommand(name = "listLoadBalancers", description = "Lists Load Balancers", responseObject = ApplicationLoadBalancerResponse.class, since = "4.2.0") +@APICommand(name = "listLoadBalancers", description = "Lists Load Balancers", responseObject = ApplicationLoadBalancerResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListApplicationLoadBalancersCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListApplicationLoadBalancersCmd.class.getName()); @@ -66,6 +67,9 @@ public class ListApplicationLoadBalancersCmd extends BaseListTaggedResourcesCmd @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "the network id of the Load Balancer") private Long networkId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -90,6 +94,14 @@ public class ListApplicationLoadBalancersCmd extends BaseListTaggedResourcesCmd return sourceIpNetworkId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + @Override public String getCommandName() { return s_name; diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java index 8aa286fb3d7..5f4ca09ec98 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.ListResponse; import com.cloud.network.rules.HealthCheckPolicy; import com.cloud.network.rules.LoadBalancer; -@APICommand(name = "listLBHealthCheckPolicies", description = "Lists load balancer HealthCheck policies.", responseObject = LBHealthCheckResponse.class, since = "4.2.0") +@APICommand(name = "listLBHealthCheckPolicies", description = "Lists load balancer HealthCheck policies.", responseObject = LBHealthCheckResponse.class, since = "4.2.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListLBHealthCheckPoliciesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListLBHealthCheckPoliciesCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java index ade487881b0..1ceb214b306 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBStickinessPoliciesCmd.java @@ -34,7 +34,8 @@ import com.cloud.network.rules.LoadBalancer; import com.cloud.network.rules.StickinessPolicy; import com.cloud.user.Account; -@APICommand(name = "listLBStickinessPolicies", description = "Lists LBStickiness policies.", responseObject = LBStickinessResponse.class, since = "3.0.0") +@APICommand(name = "listLBStickinessPolicies", description = "Lists LBStickiness policies.", responseObject = LBStickinessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListLBStickinessPoliciesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListLBStickinessPoliciesCmd.class.getName()); @@ -75,7 +76,7 @@ public class ListLBStickinessPoliciesCmd extends BaseListCmd { if (lb != null) { //check permissions Account caller = CallContext.current().getCallingAccount(); - _accountService.checkAccess(caller, null, true, lb); + _accountService.checkAccess(caller, null, lb); List stickinessPolicies = _lbService.searchForLBStickinessPolicies(this); LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies, lb); spResponses.add(spResponse); @@ -83,7 +84,7 @@ public class ListLBStickinessPoliciesCmd extends BaseListCmd { } response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java index 2a39e1ac073..cc4203c359c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java @@ -19,12 +19,14 @@ package org.apache.cloudstack.api.command.user.loadbalancer; import java.util.ArrayList; import java.util.List; +import org.apache.cloudstack.api.response.LoadBalancerRuleVmMapResponse; import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -32,9 +34,9 @@ import org.apache.cloudstack.api.response.UserVmResponse; import com.cloud.uservm.UserVm; import com.cloud.utils.Pair; -@APICommand(name = "listLoadBalancerRuleInstances", - description = "List all virtual machine instances that are assigned to a load balancer rule.", - responseObject = UserVmResponse.class) +@APICommand(name = "listLoadBalancerRuleInstances", description = "List all virtual machine instances that are assigned to a load balancer rule.", responseObject = LoadBalancerRuleVmMapResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = true) public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListLoadBalancerRuleInstancesCmd.class.getName()); @@ -56,6 +58,13 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd { description = "the ID of the load balancer rule") private Long id; + + @Parameter(name = ApiConstants.LIST_LB_VMIPS, + type = CommandType.BOOLEAN, + description = "true if lb rule vm ip information to be included; default is false") + private boolean isListLbVmip; + + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -68,6 +77,10 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd { return id; } + public boolean isListLbVmip() { + return isListLbVmip; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -79,20 +92,52 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd { @Override public void execute() { - Pair, List> vmServiceMap = _lbService.listLoadBalancerInstances(this); + Pair, List> vmServiceMap = _lbService.listLoadBalancerInstances(this); List result = vmServiceMap.first(); - List serviceStates = vmServiceMap.second(); - ListResponse response = new ListResponse(); - List vmResponses = new ArrayList(); - if (result != null) { - vmResponses = _responseGenerator.createUserVmResponse("loadbalancerruleinstance", result.toArray(new UserVm[result.size()])); - } + List serviceStates = vmServiceMap.second(); - for (int i = 0; i < result.size(); i++) { - vmResponses.get(i).setServiceState(serviceStates.get(i)); + if (!isListLbVmip()) { + // list lb instances + ListResponse response = new ListResponse(); + List vmResponses = new ArrayList(); + if (result != null) { + vmResponses = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "loadbalancerruleinstance", result.toArray(new UserVm[result.size()])); + + + for (int i = 0; i < result.size(); i++) { + vmResponses.get(i).setServiceState(serviceStates.get(i)); + } + } + response.setResponses(vmResponses); + response.setResponseName(getCommandName()); + setResponseObject(response); + + + } else { + ListResponse lbRes = new ListResponse(); + + List vmResponses = new ArrayList(); + List listlbVmRes = new ArrayList(); + + if (result != null) { + vmResponses = _responseGenerator.createUserVmResponse(ResponseView.Full, "loadbalancerruleinstance", result.toArray(new UserVm[result.size()])); + + + List ipaddr = null; + + for (int i=0;i virtualMachineIds; + @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID_IP, + type = CommandType.MAP, + description = "VM ID and IP map, vmidipmap[0].vmid=1 vmidipmap[0].ip=10.1.1.75", + since = "4.4") + private Map vmIdIpMap; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -76,6 +89,10 @@ public class RemoveFromLoadBalancerRuleCmd extends BaseAsyncCmd { return virtualMachineIds; } + public Map getVmIdIpMap() { + return vmIdIpMap; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -99,20 +116,58 @@ public class RemoveFromLoadBalancerRuleCmd extends BaseAsyncCmd { return EventTypes.EVENT_REMOVE_FROM_LOAD_BALANCER_RULE; } + + public Map> getVmIdIpListMap() { + Map> vmIdIpsMap = new HashMap>(); + if (vmIdIpMap != null && !vmIdIpMap.isEmpty()) { + Collection idIpsCollection = vmIdIpMap.values(); + Iterator iter = idIpsCollection.iterator(); + while (iter.hasNext()) { + HashMap idIpsMap = (HashMap)iter.next(); + String vmId = idIpsMap.get("vmid"); + String vmIp = idIpsMap.get("vmip"); + + VirtualMachine lbvm = _entityMgr.findByUuid(VirtualMachine.class, vmId); + if (lbvm == null) { + throw new InvalidParameterValueException("Unable to find virtual machine ID: " + vmId); + } + + Long longVmId = lbvm.getId(); + + List ipsList = null; + if (vmIdIpsMap.containsKey(longVmId)) { + ipsList = vmIdIpsMap.get(longVmId); + } else { + ipsList = new ArrayList(); + } + ipsList.add(vmIp); + vmIdIpsMap.put(longVmId, ipsList); + + } + } + + return vmIdIpsMap; + } + @Override public String getEventDescription() { return "removing instances from load balancer: " + getId() + " (ids: " + StringUtils.join(getVirtualMachineIds(), ",") + ")"; } @Override - public void execute() { + public void execute() { CallContext.current().setEventDetails("Load balancer Id: " + getId() + " VmIds: " + StringUtils.join(getVirtualMachineIds(), ",")); - boolean result = _lbService.removeFromLoadBalancer(id, virtualMachineIds); - if (result) { - SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove instance from load balancer rule"); + Map> vmIdIpsMap = getVmIdIpListMap(); + try { + boolean result = _lbService.removeFromLoadBalancer(id, virtualMachineIds, vmIdIpsMap); + if (result) { + SuccessResponse response = new SuccessResponse(getCommandName()); + this.setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove instance from load balancer rule"); + } + }catch (InvalidParameterValueException ex) { + throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Failed to remove instance from load balancer rule"); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateApplicationLoadBalancerCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateApplicationLoadBalancerCmd.java new file mode 100644 index 00000000000..fbda84ddce9 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateApplicationLoadBalancerCmd.java @@ -0,0 +1,105 @@ +// 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 org.apache.cloudstack.api.command.user.loadbalancer; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse; +import org.apache.cloudstack.api.response.FirewallRuleResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule; +import org.apache.log4j.Logger; + +import com.cloud.event.EventTypes; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.network.rules.FirewallRule; + +@APICommand(name = "updateLoadBalancer", description = "Updates a Load Balancer", responseObject = ApplicationLoadBalancerResponse.class, since = "4.4.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateApplicationLoadBalancerCmd extends BaseAsyncCustomIdCmd { + public static final Logger s_logger = Logger.getLogger(UpdateApplicationLoadBalancerCmd.class.getName()); + + private static final String s_name = "updateloadbalancerresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = FirewallRuleResponse.class, required = true, description = "the ID of the Load Balancer") + private Long id; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + @Override + public String getCommandName() { + return s_name; + } + + public Long getId() { + return id; + } + + public Boolean getDisplay() { + return display; + } + + @Override + public long getEntityOwnerId() { + ApplicationLoadBalancerRule lb = _entityMgr.findById(ApplicationLoadBalancerRule.class, getId()); + if (lb != null) { + return lb.getAccountId(); + } else { + throw new InvalidParameterValueException("Can't find load balancer by id specified"); + } + } + + @Override + public String getEventType() { + return EventTypes.EVENT_LOAD_BALANCER_UPDATE; + } + + @Override + public String getEventDescription() { + return "updating load balancer: " + getId(); + } + + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + @Override + public void execute() { + CallContext.current().setEventDetails("Load balancer Id: " + getId()); + ApplicationLoadBalancerRule rule = _appLbService.updateApplicationLoadBalancer(getId(), this.getCustomId(), getDisplay()); + ApplicationLoadBalancerResponse lbResponse = _responseGenerator.createLoadBalancerContainerReponse(rule, _lbService.getLbInstances(getId())); + setResponseObject(lbResponse); + lbResponse.setResponseName(getCommandName()); + } + + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), FirewallRule.class); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java index d68167d425d..03dd62179ea 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UpdateLoadBalancerRuleCmd.java @@ -16,25 +16,28 @@ // under the License. package org.apache.cloudstack.api.command.user.loadbalancer; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.LoadBalancerResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; +import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.LoadBalancer; import com.cloud.user.Account; -@APICommand(name = "updateLoadBalancerRule", description = "Updates load balancer", responseObject = LoadBalancerResponse.class) -public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd { +@APICommand(name = "updateLoadBalancerRule", description = "Updates load balancer", responseObject = LoadBalancerResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateLoadBalancerRuleCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateLoadBalancerRuleCmd.class.getName()); private static final String s_name = "updateloadbalancerruleresponse"; @@ -58,6 +61,9 @@ public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the load balancer rule") private String loadBalancerName; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -78,6 +84,10 @@ public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd { return loadBalancerName; } + public Boolean getDisplay() { + return display; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -132,4 +142,11 @@ public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd { } return lb.getNetworkId(); } + + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), FirewallRule.class); + } + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UploadSslCertCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UploadSslCertCmd.java index 00bd01343dd..7b150a7fe06 100644 --- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UploadSslCertCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/UploadSslCertCmd.java @@ -36,7 +36,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.lb.CertService; -@APICommand(name = "uploadSslCert", description = "Upload a certificate to cloudstack", responseObject = SslCertResponse.class) +@APICommand(name = "uploadSslCert", description = "Upload a certificate to cloudstack", responseObject = SslCertResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UploadSslCertCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UploadSslCertCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java index 0917d526b13..8925d066fe9 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java @@ -42,7 +42,8 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.StaticNatRule; import com.cloud.user.Account; -@APICommand(name = "createIpForwardingRule", description = "Creates an ip forwarding rule", responseObject = FirewallRuleResponse.class) +@APICommand(name = "createIpForwardingRule", description = "Creates an ip forwarding rule", responseObject = FirewallRuleResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements StaticNatRule { public static final Logger s_logger = Logger.getLogger(CreateIpForwardingRuleCmd.class.getName()); @@ -126,7 +127,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); fwResponse.setResponseName(getCommandName()); - this.setResponseObject(fwResponse); + setResponseObject(fwResponse); } finally { if (!result || rule == null) { @@ -152,8 +153,8 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta try { StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall()); - this.setEntityId(rule.getId()); - this.setEntityUuid(rule.getUuid()); + setEntityId(rule.getId()); + setEntityUuid(rule.getUuid()); } catch (NetworkRuleConflictException e) { s_logger.info("Unable to create Static Nat Rule due to ", e); throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage()); @@ -179,7 +180,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta @Override public String getEventDescription() { IpAddress ip = _networkService.getIp(ipAddressId); - return ("Applying an ipforwarding 1:1 NAT rule for Ip: " + ip.getAddress() + " with virtual machine:" + this.getVirtualMachineId()); + return ("Applying an ipforwarding 1:1 NAT rule for Ip: " + ip.getAddress() + " with virtual machine:" + getVirtualMachineId()); } private long getVirtualMachineId() { @@ -317,4 +318,14 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta return null; } + @Override + public boolean isDisplay() { + return true; + } + + @Override + public Class getEntityType() { + return FirewallRule.class; + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java index 66a9f8aee9e..52a5ba777e0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/DeleteIpForwardingRuleCmd.java @@ -34,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.rules.FirewallRule; -@APICommand(name = "deleteIpForwardingRule", description = "Deletes an ip forwarding rule", responseObject = SuccessResponse.class) +@APICommand(name = "deleteIpForwardingRule", description = "Deletes an ip forwarding rule", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteIpForwardingRuleCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/DisableStaticNatCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/DisableStaticNatCmd.java index 351d3ae2c2b..1df77ec0fda 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/DisableStaticNatCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/DisableStaticNatCmd.java @@ -35,7 +35,8 @@ import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; -@APICommand(name = "disableStaticNat", description = "Disables static rule for given ip address", responseObject = SuccessResponse.class) +@APICommand(name = "disableStaticNat", description = "Disables static rule for given ip address", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DisableStaticNatCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeletePortForwardingRuleCmd.class.getName()); private static final String s_name = "disablestaticnatresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java index 832cbc2d06d..94699ac6ffa 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.nat; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -35,8 +37,11 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "enableStaticNat", description = "Enables static nat for given ip address", responseObject = SuccessResponse.class) +@APICommand(name = "enableStaticNat", description = "Enables static nat for given ip address", responseObject = SuccessResponse.class, + entityType = {IpAddress.class, VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class EnableStaticNatCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateIpForwardingRuleCmd.class.getName()); @@ -46,10 +51,12 @@ public class EnableStaticNatCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.IP_ADDRESS_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, required = true, description = "the public IP " + "address id for which static nat feature is being enabled") private Long ipAddressId; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "the ID of " + "the virtual machine for enabling static nat feature") private Long virtualMachineId; @@ -132,7 +139,7 @@ public class EnableStaticNatCmd extends BaseCmd { boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), getVmSecondaryIp()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable static nat"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/ListIpForwardingRulesCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/ListIpForwardingRulesCmd.java index dca1c2379e5..ecb0c44c700 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/ListIpForwardingRulesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/ListIpForwardingRulesCmd.java @@ -35,7 +35,8 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.StaticNatRule; import com.cloud.utils.Pair; -@APICommand(name = "listIpForwardingRules", description = "List the ip forwarding rules", responseObject = FirewallRuleResponse.class) +@APICommand(name = "listIpForwardingRules", description = "List the ip forwarding rules", responseObject = FirewallRuleResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListIpForwardingRulesCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListIpForwardingRulesCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java index 9934a4fefcc..e47fa8b2cf7 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLCmd.java @@ -19,9 +19,7 @@ package org.apache.cloudstack.api.command.user.network; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -32,6 +30,8 @@ import org.apache.cloudstack.api.response.NetworkACLItemResponse; import org.apache.cloudstack.api.response.NetworkACLResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; @@ -42,7 +42,9 @@ import com.cloud.utils.net.NetUtils; @APICommand(name = "createNetworkACL", description = "Creates a ACL rule in the given network (the network has to belong to VPC)", - responseObject = NetworkACLItemResponse.class) + responseObject = NetworkACLItemResponse.class, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class CreateNetworkACLCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateNetworkACLCmd.class.getName()); @@ -95,9 +97,15 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, description = "scl entry action, allow or deny") private String action; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// + public Boolean getDisplay() { + return display; + } public String getProtocol() { String p = protocol.trim(); diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java index cd0eb3237bd..07156cf944f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkACLListCmd.java @@ -16,8 +16,7 @@ // under the License. package org.apache.cloudstack.api.command.user.network; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -26,6 +25,7 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.NetworkACLResponse; import org.apache.cloudstack.api.response.VpcResponse; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; @@ -34,7 +34,8 @@ import com.cloud.network.vpc.NetworkACL; import com.cloud.network.vpc.Vpc; import com.cloud.user.Account; -@APICommand(name = "createNetworkACLList", description = "Creates a Network ACL for the given VPC", responseObject = NetworkACLResponse.class) +@APICommand(name = "createNetworkACLList", description = "Creates a Network ACL for the given VPC", responseObject = NetworkACLResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateNetworkACLListCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateNetworkACLListCmd.class.getName()); @@ -57,6 +58,9 @@ public class CreateNetworkACLListCmd extends BaseAsyncCreateCmd { description = "Id of the VPC associated with this network ACL List") private Long vpcId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the list to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -73,6 +77,10 @@ public class CreateNetworkACLListCmd extends BaseAsyncCreateCmd { return vpcId; } + public Boolean getDisplay() { + return display; + } + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// @@ -84,7 +92,7 @@ public class CreateNetworkACLListCmd extends BaseAsyncCreateCmd { @Override public void create() { - NetworkACL result = _networkACLService.createNetworkACL(getName(), getDescription(), getVpcId()); + NetworkACL result = _networkACLService.createNetworkACL(getName(), getDescription(), getVpcId(), getDisplay()); setEntityId(result.getId()); setEntityUuid(result.getUuid()); } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java index c1e56ebd638..43c3d1b09e7 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/CreateNetworkCmd.java @@ -18,11 +18,13 @@ package org.apache.cloudstack.api.command.user.network; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.NetworkACLResponse; @@ -42,7 +44,8 @@ import com.cloud.network.Network; import com.cloud.network.Network.GuestType; import com.cloud.offering.NetworkOffering; -@APICommand(name = "createNetwork", description = "Creates a network", responseObject = NetworkResponse.class) +@APICommand(name = "createNetwork", description = "Creates a network", responseObject = NetworkResponse.class, responseView = ResponseView.Restricted, entityType = {Network.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateNetworkCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateNetworkCmd.class.getName()); @@ -136,7 +139,7 @@ public class CreateNetworkCmd extends BaseCmd { @Parameter(name = ApiConstants.DISPLAY_NETWORK, type = CommandType.BOOLEAN, - description = "an optional field, whether to the display the network to the end user or not.") + description = "an optional field, whether to the display the network to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayNetwork; @Parameter(name = ApiConstants.ACL_ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, description = "Network ACL Id associated for the network") @@ -153,10 +156,6 @@ public class CreateNetworkCmd extends BaseCmd { return gateway; } - public String getVlan() { - return vlan; - } - public String getIsolatedPvlan() { return isolatedPvlan; } @@ -285,7 +284,7 @@ public class CreateNetworkCmd extends BaseCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -299,7 +298,7 @@ public class CreateNetworkCmd extends BaseCmd { void execute() throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException { Network result = _networkService.createGuestNetwork(this); if (result != null) { - NetworkResponse response = _responseGenerator.createNetworkResponse(result); + NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Restricted, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java index 7413ea55b00..ecc651dbfa8 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLCmd.java @@ -32,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "deleteNetworkACL", description = "Deletes a Network ACL", responseObject = SuccessResponse.class) +@APICommand(name = "deleteNetworkACL", description = "Deletes a Network ACL", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteNetworkACLCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteNetworkACLCmd.class.getName()); private static final String s_name = "deletenetworkaclresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java index 632d710c39f..3b3a4ec4ae4 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkACLListCmd.java @@ -32,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "deleteNetworkACLList", description = "Deletes a Network ACL", responseObject = SuccessResponse.class) +@APICommand(name = "deleteNetworkACLList", description = "Deletes a Network ACL", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteNetworkACLListCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteNetworkACLListCmd.class.getName()); private static final String s_name = "deletenetworkacllistresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java index 808051ecdef..4c3a292c4a9 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/DeleteNetworkCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.network; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -33,7 +35,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.network.Network; -@APICommand(name = "deleteNetwork", description = "Deletes a network", responseObject = SuccessResponse.class) +@APICommand(name = "deleteNetwork", description = "Deletes a network", responseObject = SuccessResponse.class, entityType = {Network.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteNetworkCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteNetworkOfferingCmd.class.getName()); private static final String s_name = "deletenetworkresponse"; @@ -41,7 +44,7 @@ public class DeleteNetworkCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkResponse.class, required = true, description = "the ID of the network") private Long id; @@ -76,7 +79,7 @@ public class DeleteNetworkCmd extends BaseAsyncCmd { boolean result = _networkService.deleteNetwork(id, isForced()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java index 2e50bb8cf22..c115fb76165 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLListsCmd.java @@ -19,8 +19,7 @@ package org.apache.cloudstack.api.command.user.network; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; @@ -29,11 +28,13 @@ import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.NetworkACLResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.api.response.VpcResponse; +import org.apache.log4j.Logger; import com.cloud.network.vpc.NetworkACL; import com.cloud.utils.Pair; -@APICommand(name = "listNetworkACLLists", description = "Lists all network ACLs", responseObject = NetworkACLResponse.class) +@APICommand(name = "listNetworkACLLists", description = "Lists all network ACLs", responseObject = NetworkACLResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListNetworkACLListsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListNetworkACLListsCmd.class.getName()); @@ -54,6 +55,9 @@ public class ListNetworkACLListsCmd extends BaseListProjectAndAccountResourcesCm @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "list network ACLs by specified name") private String name; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -74,6 +78,13 @@ public class ListNetworkACLListsCmd extends BaseListProjectAndAccountResourcesCm return name; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java index 7f8aef4cd77..4f9065bf2cd 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkACLsCmd.java @@ -19,8 +19,7 @@ package org.apache.cloudstack.api.command.user.network; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; @@ -29,11 +28,13 @@ import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.NetworkACLItemResponse; import org.apache.cloudstack.api.response.NetworkACLResponse; import org.apache.cloudstack.api.response.NetworkResponse; +import org.apache.log4j.Logger; import com.cloud.network.vpc.NetworkACLItem; import com.cloud.utils.Pair; -@APICommand(name = "listNetworkACLs", description = "Lists all network ACL items", responseObject = NetworkACLItemResponse.class) +@APICommand(name = "listNetworkACLs", description = "Lists all network ACL items", responseObject = NetworkACLItemResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListNetworkACLsCmd.class.getName()); @@ -61,6 +62,9 @@ public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, description = "list network ACL Items by Action") private String action; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -89,6 +93,14 @@ public class ListNetworkACLsCmd extends BaseListTaggedResourcesCmd { return action; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkOfferingsCmd.java index 552a64a63b2..6ac0f395b77 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkOfferingsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworkOfferingsCmd.java @@ -32,10 +32,11 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.offering.NetworkOffering; -@APICommand(name = "listNetworkOfferings", description = "Lists all available network offerings.", responseObject = NetworkOfferingResponse.class) +@APICommand(name = "listNetworkOfferings", description = "Lists all available network offerings.", responseObject = NetworkOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListNetworkOfferingsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListNetworkOfferingsCmd.class.getName()); - private static final String Name = "listnetworkofferingsresponse"; + private static final String s_name = "listnetworkofferingsresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -181,7 +182,7 @@ public class ListNetworkOfferingsCmd extends BaseListCmd { ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java index 111fac31174..86f3ba2ad6b 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ListNetworksCmd.java @@ -19,24 +19,28 @@ package org.apache.cloudstack.api.command.user.network; import java.util.ArrayList; import java.util.List; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.api.response.PhysicalNetworkResponse; import org.apache.cloudstack.api.response.VpcResponse; import org.apache.cloudstack.api.response.ZoneResponse; -import org.apache.log4j.Logger; import com.cloud.network.Network; import com.cloud.utils.Pair; -@APICommand(name = "listNetworks", description = "Lists all available networks.", responseObject = NetworkResponse.class) +@APICommand(name = "listNetworks", description = "Lists all available networks.", responseObject = NetworkResponse.class, responseView = ResponseView.Restricted, entityType = {Network.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListNetworksCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListNetworksCmd.class.getName()); - private static final String Name = "listnetworksresponse"; + private static final String s_name = "listnetworksresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -80,6 +84,9 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.FOR_VPC, type = CommandType.BOOLEAN, description = "the network belongs to vpc") private Boolean forVpc; + @Parameter(name = ApiConstants.DISPLAY_NETWORK, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -136,12 +143,19 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd { return forVpc; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override @@ -150,11 +164,11 @@ public class ListNetworksCmd extends BaseListTaggedResourcesCmd { ListResponse response = new ListResponse(); List networkResponses = new ArrayList(); for (Network network : networks.first()) { - NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(network); + NetworkResponse networkResponse = _responseGenerator.createNetworkResponse(ResponseView.Restricted, network); networkResponses.add(networkResponse); } response.setResponses(networkResponses, networks.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java index de1f163ae0b..d005718428e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/ReplaceNetworkACLListCmd.java @@ -34,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; -@APICommand(name = "replaceNetworkACLList", description = "Replaces ACL associated with a Network or private gateway", responseObject = SuccessResponse.class) +@APICommand(name = "replaceNetworkACLList", description = "Replaces ACL associated with a Network or private gateway", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReplaceNetworkACLListCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReplaceNetworkACLListCmd.class.getName()); private static final String s_name = "replacenetworkacllistresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java index cd508ffbb11..eba83104218 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/RestartNetworkCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.network; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -38,7 +40,9 @@ import com.cloud.network.Network; @APICommand(name = "restartNetwork", description = "Restarts the network; includes 1) restarting network elements - virtual routers, dhcp servers 2) reapplying all public ips 3) reapplying loadBalancing/portForwarding rules", - responseObject = IPAddressResponse.class) + responseObject = IPAddressResponse.class, entityType = {Network.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class RestartNetworkCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RestartNetworkCmd.class.getName()); private static final String s_name = "restartnetworkresponse"; @@ -46,7 +50,7 @@ public class RestartNetworkCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkResponse.class, required = true, description = "The id of the network to restart.") private Long id; @@ -91,7 +95,7 @@ public class RestartNetworkCmd extends BaseAsyncCmd { boolean result = _networkService.restartNetwork(this, getCleanup()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restart network"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java index 1e559c2da7d..eb095df2091 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLItemCmd.java @@ -18,24 +18,25 @@ package org.apache.cloudstack.api.command.user.network; import java.util.List; -import org.apache.log4j.Logger; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.NetworkACLItemResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.vpc.NetworkACLItem; import com.cloud.user.Account; -@APICommand(name = "updateNetworkACLItem", description = "Updates ACL Item with specified Id", responseObject = NetworkACLItemResponse.class) -public class UpdateNetworkACLItemCmd extends BaseAsyncCmd { +@APICommand(name = "updateNetworkACLItem", description = "Updates ACL Item with specified Id", responseObject = NetworkACLItemResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateNetworkACLItemCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateNetworkACLItemCmd.class.getName()); private static final String s_name = "createnetworkaclresponse"; @@ -81,9 +82,15 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, description = "scl entry action, allow or deny") private String action; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// + public Boolean getDisplay() { + return display; + } public Long getId() { return id; @@ -165,7 +172,7 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCmd { CallContext.current().setEventDetails("Rule Id: " + getId()); NetworkACLItem aclItem = _networkACLService.updateNetworkACLItem(getId(), getProtocol(), getSourceCidrList(), getTrafficType(), getAction(), getNumber(), getSourcePortStart(), - getSourcePortEnd(), getIcmpCode(), getIcmpType()); + getSourcePortEnd(), getIcmpCode(), getIcmpType(), this.getCustomId(), this.getDisplay()); if (aclItem == null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network ACL Item"); } @@ -174,4 +181,11 @@ public class UpdateNetworkACLItemCmd extends BaseAsyncCmd { aclResponse.setResponseName(getCommandName()); } + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), NetworkACLItem.class); + } + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLListCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLListCmd.java new file mode 100644 index 00000000000..c58f9658364 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkACLListCmd.java @@ -0,0 +1,100 @@ +// 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 org.apache.cloudstack.api.command.user.network; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.NetworkACLResponse; +import org.apache.cloudstack.api.response.SuccessResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; + +import com.cloud.event.EventTypes; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.vpc.NetworkACL; +import com.cloud.user.Account; + +@APICommand(name = "updateNetworkACLList", description = "Updates Network ACL list", responseObject = SuccessResponse.class, since = "4.4", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateNetworkACLListCmd extends BaseAsyncCustomIdCmd { + public static final Logger s_logger = Logger.getLogger(UpdateNetworkACLListCmd.class.getName()); + private static final String s_name = "updatenetworkacllistresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkACLResponse.class, required = true, description = "the ID of the network ACL") + private Long id; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the list to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + public Boolean getDisplay() { + return display; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + @Override + public String getCommandName() { + return s_name; + } + + @Override + public String getEventType() { + return EventTypes.EVENT_NETWORK_ACL_UPDATE; + } + + @Override + public String getEventDescription() { + return ("Updating network acl list id=" + id); + } + + @Override + public long getEntityOwnerId() { + Account caller = CallContext.current().getCallingAccount(); + return caller.getAccountId(); + } + + @Override + public void execute() throws ResourceUnavailableException { + NetworkACL acl = _networkACLService.updateNetworkACL(id, this.getCustomId(), getDisplay()); + NetworkACLResponse aclResponse = _responseGenerator.createNetworkACLResponse(acl); + setResponseObject(aclResponse); + aclResponse.setResponseName(getCommandName()); + } + + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), NetworkACL.class); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java index 2091102f40c..0f73ddef93a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/network/UpdateNetworkCmd.java @@ -18,11 +18,16 @@ package org.apache.cloudstack.api.command.user.network; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.NetworkOfferingResponse; import org.apache.cloudstack.api.response.NetworkResponse; @@ -37,8 +42,9 @@ import com.cloud.offering.NetworkOffering; import com.cloud.user.Account; import com.cloud.user.User; -@APICommand(name = "updateNetwork", description = "Updates a network", responseObject = NetworkResponse.class) -public class UpdateNetworkCmd extends BaseAsyncCmd { +@APICommand(name = "updateNetwork", description = "Updates a network", responseObject = NetworkResponse.class, responseView = ResponseView.Restricted, entityType = {Network.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateNetworkCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateNetworkCmd.class.getName()); private static final String s_name = "updatenetworkresponse"; @@ -46,8 +52,10 @@ public class UpdateNetworkCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = NetworkResponse.class, required = true, description = "the ID of the network") - private Long id; + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = NetworkResponse.class, + required=true, description="the ID of the network") + protected Long id; @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the new name for the network") private String name; @@ -69,7 +77,7 @@ public class UpdateNetworkCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.DISPLAY_NETWORK, type = CommandType.BOOLEAN, - description = "an optional field, whether to the display the network to the end user or not.") + description = "an optional field, whether to the display the network to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayNetwork; ///////////////////////////////////////////////////// @@ -88,11 +96,11 @@ public class UpdateNetworkCmd extends BaseAsyncCmd { return displayText; } - private String getNetworkDomain() { + public String getNetworkDomain() { return networkDomain; } - private Long getNetworkOfferingId() { + public Long getNetworkOfferingId() { return networkOfferingId; } @@ -103,7 +111,7 @@ public class UpdateNetworkCmd extends BaseAsyncCmd { return false; } - private String getGuestVmCidr() { + public String getGuestVmCidr() { return guestVmCidr; } @@ -141,12 +149,12 @@ public class UpdateNetworkCmd extends BaseAsyncCmd { Network result = _networkService.updateGuestNetwork(getId(), getNetworkName(), getDisplayText(), callerAccount, callerUser, getNetworkDomain(), getNetworkOfferingId(), - getChangeCidr(), getGuestVmCidr(), getDisplayNetwork()); + getChangeCidr(), getGuestVmCidr(), getDisplayNetwork(), getCustomId()); if (result != null) { - NetworkResponse response = _responseGenerator.createNetworkResponse(result); + NetworkResponse response = _responseGenerator.createNetworkResponse(ResponseView.Restricted, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network"); } @@ -188,4 +196,11 @@ public class UpdateNetworkCmd extends BaseAsyncCmd { public Long getSyncObjId() { return id; } + + @Override + public void checkUuid() { + if (getCustomId() != null) { + _uuidMgr.checkUuid(getCustomId(), Network.class); + } + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java index 954b64e2a41..0e4806a534c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/offering/ListDiskOfferingsCmd.java @@ -26,7 +26,8 @@ import org.apache.cloudstack.api.response.DiskOfferingResponse; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ListResponse; -@APICommand(name = "listDiskOfferings", description = "Lists all available disk offerings.", responseObject = DiskOfferingResponse.class) +@APICommand(name = "listDiskOfferings", description = "Lists all available disk offerings.", responseObject = DiskOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListDiskOfferingsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListDiskOfferingsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java index 08c69e830c2..abeebcbfae6 100644 --- a/api/src/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/offering/ListServiceOfferingsCmd.java @@ -27,7 +27,8 @@ import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.UserVmResponse; -@APICommand(name = "listServiceOfferings", description = "Lists all available service offerings.", responseObject = ServiceOfferingResponse.class) +@APICommand(name = "listServiceOfferings", description = "Lists all available service offerings.", responseObject = ServiceOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListServiceOfferingsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/project/ActivateProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/ActivateProjectCmd.java index 66c64a6e3f9..5b1b76e95ea 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/ActivateProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/ActivateProjectCmd.java @@ -31,7 +31,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.projects.Project; -@APICommand(name = "activateProject", description = "Activates a project", responseObject = ProjectResponse.class, since = "3.0.0") +@APICommand(name = "activateProject", description = "Activates a project", responseObject = ProjectResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ActivateProjectCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ActivateProjectCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java index dcb83a89031..e8a045ca1cc 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java @@ -34,7 +34,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.projects.Project; import com.cloud.user.Account; -@APICommand(name = "createProject", description = "Creates a project", responseObject = ProjectResponse.class, since = "3.0.0") +@APICommand(name = "createProject", description = "Creates a project", responseObject = ProjectResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateProjectCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateProjectCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/project/DeleteProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/DeleteProjectCmd.java index 88205e856bc..3a2e48d51ab 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/DeleteProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/DeleteProjectCmd.java @@ -32,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.projects.Project; -@APICommand(name = "deleteProject", description = "Deletes a project", responseObject = SuccessResponse.class, since = "3.0.0") +@APICommand(name = "deleteProject", description = "Deletes a project", responseObject = SuccessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteProjectCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteProjectCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/project/DeleteProjectInvitationCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/DeleteProjectInvitationCmd.java index 9d4d8383283..9f8baad6408 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/DeleteProjectInvitationCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/DeleteProjectInvitationCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "deleteProjectInvitation", description = "Accepts or declines project invitation", responseObject = SuccessResponse.class, since = "3.0.0") +@APICommand(name = "deleteProjectInvitation", description = "Accepts or declines project invitation", responseObject = SuccessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteProjectInvitationCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteProjectInvitationCmd.class.getName()); private static final String s_name = "deleteprojectinvitationresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java index 0e9e7ae4aeb..dc607e4faf0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/ListProjectInvitationsCmd.java @@ -29,7 +29,9 @@ import org.apache.cloudstack.api.response.ProjectResponse; @APICommand(name = "listProjectInvitations", description = "Lists projects and provides detailed information for listed projects", responseObject = ProjectInvitationResponse.class, - since = "3.0.0") + since = "3.0.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListProjectInvitationsCmd extends BaseListAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListProjectInvitationsCmd.class.getName()); private static final String s_name = "listprojectinvitationsresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/project/ListProjectsCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/ListProjectsCmd.java index 2cf610634b7..7b479b1a9ff 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/ListProjectsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/ListProjectsCmd.java @@ -35,7 +35,9 @@ import com.cloud.exception.InvalidParameterValueException; @APICommand(name = "listProjects", description = "Lists projects and provides detailed information for listed projects", responseObject = ProjectResponse.class, - since = "3.0.0") + since = "3.0.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListProjectsCmd extends BaseListAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListProjectsCmd.class.getName()); private static final String s_name = "listprojectsresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/project/SuspendProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/SuspendProjectCmd.java index c2a1885472d..69a4b77c7a5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/SuspendProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/SuspendProjectCmd.java @@ -33,7 +33,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.projects.Project; -@APICommand(name = "suspendProject", description = "Suspends a project", responseObject = ProjectResponse.class, since = "3.0.0") +@APICommand(name = "suspendProject", description = "Suspends a project", responseObject = ProjectResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class SuspendProjectCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(SuspendProjectCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectCmd.java index 78903bf80e2..11e5e35bac3 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectCmd.java @@ -32,7 +32,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceAllocationException; import com.cloud.projects.Project; -@APICommand(name = "updateProject", description = "Updates a project", responseObject = ProjectResponse.class, since = "3.0.0") +@APICommand(name = "updateProject", description = "Updates a project", responseObject = ProjectResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateProjectCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateProjectCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java b/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java index dda7b5400ba..79e3f8a9cfd 100644 --- a/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/project/UpdateProjectInvitationCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "updateProjectInvitation", description = "Accepts or declines project invitation", responseObject = SuccessResponse.class, since = "3.0.0") +@APICommand(name = "updateProjectInvitation", description = "Accepts or declines project invitation", responseObject = SuccessResponse.class, since = "3.0.0", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateProjectInvitationCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateProjectInvitationCmd.class.getName()); private static final String s_name = "updateprojectinvitationresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ListRegionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ListRegionsCmd.java index c369b9cf6f3..9a0b186d9ea 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ListRegionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ListRegionsCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.RegionResponse; import org.apache.cloudstack.region.Region; import org.apache.cloudstack.region.RegionService; -@APICommand(name = "listRegions", description = "Lists Regions", responseObject = RegionResponse.class) +@APICommand(name = "listRegions", description = "Lists Regions", responseObject = RegionResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListRegionsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListRegionsCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java index 1fe73b555e1..177939b2327 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/AssignToGlobalLoadBalancerRuleCmd.java @@ -49,7 +49,9 @@ import com.cloud.utils.db.EntityManager; @APICommand(name = "assignToGlobalLoadBalancerRule", description = "Assign load balancer rule or list of load " + "balancer rules to a global load balancer rules.", - responseObject = SuccessResponse.class) + responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class AssignToGlobalLoadBalancerRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AssignToGlobalLoadBalancerRuleCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java index 550d81755eb..67825761b8a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/CreateGlobalLoadBalancerRuleCmd.java @@ -19,8 +19,6 @@ package org.apache.cloudstack.api.command.user.region.ha.gslb; import javax.inject.Inject; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -32,6 +30,7 @@ import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse; import org.apache.cloudstack.api.response.RegionResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.ResourceAllocationException; @@ -39,7 +38,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.region.ha.GlobalLoadBalancerRule; import com.cloud.region.ha.GlobalLoadBalancingRulesService; -@APICommand(name = "createGlobalLoadBalancerRule", description = "Creates a global load balancer rule", responseObject = GlobalLoadBalancerResponse.class) +@APICommand(name = "createGlobalLoadBalancerRule", description = "Creates a global load balancer rule", responseObject = GlobalLoadBalancerResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateGlobalLoadBalancerRuleCmd.class.getName()); @@ -191,7 +191,7 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, null, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/DeleteGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/DeleteGlobalLoadBalancerRuleCmd.java index 2e96965bdce..dfb093d5b16 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/DeleteGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/DeleteGlobalLoadBalancerRuleCmd.java @@ -37,7 +37,8 @@ import com.cloud.region.ha.GlobalLoadBalancerRule; import com.cloud.region.ha.GlobalLoadBalancingRulesService; import com.cloud.user.Account; -@APICommand(name = "deleteGlobalLoadBalancerRule", description = "Deletes a global load balancer rule.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteGlobalLoadBalancerRule", description = "Deletes a global load balancer rule.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteGlobalLoadBalancerRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteGlobalLoadBalancerRuleCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/ListGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/ListGlobalLoadBalancerRuleCmd.java index f37aba2ac09..e5630f87e14 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/ListGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/ListGlobalLoadBalancerRuleCmd.java @@ -35,7 +35,8 @@ import org.apache.cloudstack.api.response.RegionResponse; import com.cloud.region.ha.GlobalLoadBalancerRule; import com.cloud.region.ha.GlobalLoadBalancingRulesService; -@APICommand(name = "listGlobalLoadBalancerRules", description = "Lists load balancer rules.", responseObject = GlobalLoadBalancerResponse.class) +@APICommand(name = "listGlobalLoadBalancerRules", description = "Lists load balancer rules.", responseObject = GlobalLoadBalancerResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListGlobalLoadBalancerRuleCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListGlobalLoadBalancerRuleCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java index b30f4d8d546..af3fa349322 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/RemoveFromGlobalLoadBalancerRuleCmd.java @@ -43,7 +43,9 @@ import com.cloud.utils.StringUtils; @APICommand(name = "removeFromGlobalLoadBalancerRule", description = "Removes a load balancer rule association with" + " global load balancer rule", - responseObject = SuccessResponse.class) + responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class RemoveFromGlobalLoadBalancerRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RemoveFromGlobalLoadBalancerRuleCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java index e8c5326c604..6c75400c2df 100644 --- a/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/region/ha/gslb/UpdateGlobalLoadBalancerRuleCmd.java @@ -34,7 +34,8 @@ import com.cloud.region.ha.GlobalLoadBalancerRule; import com.cloud.region.ha.GlobalLoadBalancingRulesService; import com.cloud.user.Account; -@APICommand(name = "updateGlobalLoadBalancerRule", description = "update global load balancer rules.", responseObject = GlobalLoadBalancerResponse.class) +@APICommand(name = "updateGlobalLoadBalancerRule", description = "update global load balancer rules.", responseObject = GlobalLoadBalancerResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateGlobalLoadBalancerRuleCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(GlobalLoadBalancerResponse.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/GetCloudIdentifierCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/GetCloudIdentifierCmd.java index ccaca2dbbcc..366401f3a6f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/resource/GetCloudIdentifierCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/resource/GetCloudIdentifierCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.UserResponse; import com.cloud.user.Account; -@APICommand(name = "getCloudIdentifier", description = "Retrieves a cloud identifier.", responseObject = CloudIdentifierResponse.class) +@APICommand(name = "getCloudIdentifier", description = "Retrieves a cloud identifier.", responseObject = CloudIdentifierResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class GetCloudIdentifierCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(GetCloudIdentifierCmd.class.getName()); private static final String s_name = "getcloudidentifierresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/ListHypervisorsCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/ListHypervisorsCmd.java index 5e546f4dd11..edaa4051c76 100644 --- a/api/src/org/apache/cloudstack/api/command/user/resource/ListHypervisorsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/resource/ListHypervisorsCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.user.Account; -@APICommand(name = "listHypervisors", description = "List hypervisors", responseObject = HypervisorResponse.class) +@APICommand(name = "listHypervisors", description = "List hypervisors", responseObject = HypervisorResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListHypervisorsCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpgradeRouterCmd.class.getName()); private static final String s_name = "listhypervisorsresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java index ba3cfc8d951..1576d93784b 100644 --- a/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/resource/ListResourceLimitsCmd.java @@ -19,18 +19,18 @@ package org.apache.cloudstack.api.command.user.resource; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ResourceLimitResponse; +import org.apache.log4j.Logger; import com.cloud.configuration.ResourceLimit; -@APICommand(name = "listResourceLimits", description = "Lists resource limits.", responseObject = ResourceLimitResponse.class) +@APICommand(name = "listResourceLimits", description = "Lists resource limits.", responseObject = ResourceLimitResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListResourceLimitsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListResourceLimitsCmd.class.getName()); @@ -77,7 +77,7 @@ public class ListResourceLimitsCmd extends BaseListProjectAndAccountResourcesCmd @Override public void execute() { List result = - _resourceLimitService.searchForLimits(id, finalyzeAccountId(this.getAccountName(), this.getDomainId(), this.getProjectId(), false), this.getDomainId(), + _resourceLimitService.searchForLimits(id, _accountService.finalyzeAccountId(this.getAccountName(), this.getDomainId(), this.getProjectId(), false), this.getDomainId(), resourceType, this.getStartIndex(), this.getPageSizeVal()); ListResponse response = new ListResponse(); List limitResponses = new ArrayList(); diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java index bd4f9956442..5a417496eb1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceCountCmd.java @@ -19,8 +19,6 @@ package org.apache.cloudstack.api.command.user.resource; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -32,11 +30,13 @@ import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ProjectResponse; import org.apache.cloudstack.api.response.ResourceCountResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.configuration.ResourceCount; import com.cloud.user.Account; -@APICommand(name = "updateResourceCount", description = "Recalculate and update resource count for an account or domain.", responseObject = ResourceCountResponse.class) +@APICommand(name = "updateResourceCount", description = "Recalculate and update resource count for an account or domain.", responseObject = ResourceCountResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateResourceCountCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateResourceCountCmd.class.getName()); @@ -106,7 +106,7 @@ public class UpdateResourceCountCmd extends BaseCmd { @Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); - if ((account == null) || isAdmin(account.getType())) { + if ((account == null) || _accountService.isAdmin(account.getType())) { if ((domainId != null) && (accountName != null)) { Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); if (userAccount != null) { @@ -125,7 +125,7 @@ public class UpdateResourceCountCmd extends BaseCmd { @Override public void execute() { List result = - _resourceLimitService.recalculateResourceCount(finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType()); + _resourceLimitService.recalculateResourceCount(_accountService.finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), getResourceType()); if ((result != null) && (result.size() > 0)) { ListResponse response = new ListResponse(); diff --git a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java index c33a9e71cc8..22d20d3e8e1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/resource/UpdateResourceLimitCmd.java @@ -16,8 +16,6 @@ // under the License. package org.apache.cloudstack.api.command.user.resource; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -28,10 +26,12 @@ import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ProjectResponse; import org.apache.cloudstack.api.response.ResourceLimitResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.configuration.ResourceLimit; -@APICommand(name = "updateResourceLimit", description = "Updates resource limits for an account or domain.", responseObject = ResourceLimitResponse.class) +@APICommand(name = "updateResourceLimit", description = "Updates resource limits for an account or domain.", responseObject = ResourceLimitResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateResourceLimitCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpdateResourceLimitCmd.class.getName()); @@ -95,7 +95,7 @@ public class UpdateResourceLimitCmd extends BaseCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -105,7 +105,7 @@ public class UpdateResourceLimitCmd extends BaseCmd { @Override public void execute() { - ResourceLimit result = _resourceLimitService.updateResourceLimit(finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), resourceType, max); + ResourceLimit result = _resourceLimitService.updateResourceLimit(_accountService.finalyzeAccountId(accountName, domainId, projectId, true), getDomainId(), resourceType, max); if (result != null || (result == null && max != null && max.longValue() == -1L)) { ResourceLimitResponse response = _responseGenerator.createResourceLimitResponse(result); response.setResponseName(getCommandName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java index 6a054a4dbdf..aef0a7c7382 100644 --- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java @@ -24,6 +24,8 @@ import java.util.Map; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -39,13 +41,13 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; +import com.cloud.network.security.SecurityGroup; import com.cloud.network.security.SecurityRule; import com.cloud.utils.StringUtils; -@APICommand(name = "authorizeSecurityGroupEgress", - responseObject = SecurityGroupRuleResponse.class, - description = "Authorizes a particular egress rule for this security group", - since = "3.0.0") +@APICommand(name = "authorizeSecurityGroupEgress", responseObject = SecurityGroupRuleResponse.class, description = "Authorizes a particular egress rule for this security group", since = "3.0.0", entityType = {SecurityGroup.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) @SuppressWarnings("rawtypes") public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AuthorizeSecurityGroupIngressCmd.class.getName()); @@ -89,15 +91,12 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, description = "an optional project of the security group", entityType = ProjectResponse.class) private Long projectId; - @Parameter(name = ApiConstants.SECURITY_GROUP_ID, - type = CommandType.UUID, - description = "The ID of the security group. Mutually exclusive with securityGroupName parameter", - entityType = SecurityGroupResponse.class) + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.UUID, description="The ID of the security group. Mutually exclusive with securityGroupName parameter", entityType=SecurityGroupResponse.class) private Long securityGroupId; - @Parameter(name = ApiConstants.SECURITY_GROUP_NAME, - type = CommandType.STRING, - description = "The name of the security group. Mutually exclusive with securityGroupName parameter") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, description="The name of the security group. Mutually exclusive with securityGroupName parameter") private String securityGroupName; ///////////////////////////////////////////////////// @@ -174,7 +173,7 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -221,7 +220,7 @@ public class AuthorizeSecurityGroupEgressCmd extends BaseAsyncCmd { List egressRules = _securityGroupService.authorizeSecurityGroupEgress(this); if (egressRules != null && !egressRules.isEmpty()) { SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(egressRules); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to authorize security group egress rule(s)"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java index be91959b3eb..188df6e1114 100644 --- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java @@ -24,6 +24,8 @@ import java.util.Map; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -39,12 +41,13 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; +import com.cloud.network.security.SecurityGroup; import com.cloud.network.security.SecurityRule; import com.cloud.utils.StringUtils; -@APICommand(name = "authorizeSecurityGroupIngress", - responseObject = SecurityGroupRuleResponse.class, - description = "Authorizes a particular ingress rule for this security group") +@APICommand(name = "authorizeSecurityGroupIngress", responseObject = SecurityGroupRuleResponse.class, description = "Authorizes a particular ingress rule for this security group", entityType = {SecurityGroup.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) @SuppressWarnings("rawtypes") public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AuthorizeSecurityGroupIngressCmd.class.getName()); @@ -88,15 +91,12 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, description = "an optional project of the security group", entityType = ProjectResponse.class) private Long projectId; - @Parameter(name = ApiConstants.SECURITY_GROUP_ID, - type = CommandType.UUID, - description = "The ID of the security group. Mutually exclusive with securityGroupName parameter", - entityType = SecurityGroupResponse.class) + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.UUID, description="The ID of the security group. Mutually exclusive with securityGroupName parameter", entityType=SecurityGroupResponse.class) private Long securityGroupId; - @Parameter(name = ApiConstants.SECURITY_GROUP_NAME, - type = CommandType.STRING, - description = "The name of the security group. Mutually exclusive with securityGroupName parameter") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, description="The name of the security group. Mutually exclusive with securityGroupName parameter") private String securityGroupName; ///////////////////////////////////////////////////// @@ -173,7 +173,7 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -220,7 +220,7 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd { List ingressRules = _securityGroupService.authorizeSecurityGroupIngress(this); if (ingressRules != null && !ingressRules.isEmpty()) { SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(ingressRules); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to authorize security group ingress rule(s)"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java index 3b16821d46d..b5758ca282f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.network.security.SecurityGroup; import com.cloud.user.Account; -@APICommand(name = "createSecurityGroup", responseObject = SecurityGroupResponse.class, description = "Creates a security group") +@APICommand(name = "createSecurityGroup", responseObject = SecurityGroupResponse.class, description = "Creates a security group", entityType = {SecurityGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateSecurityGroupCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateSecurityGroupCmd.class.getName()); @@ -96,7 +97,7 @@ public class CreateSecurityGroupCmd extends BaseCmd { @Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); - if ((account == null) || isAdmin(account.getType())) { + if ((account == null) || _accountService.isAdmin(account.getType())) { if ((domainId != null) && (accountName != null)) { Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); if (userAccount != null) { @@ -119,7 +120,7 @@ public class CreateSecurityGroupCmd extends BaseCmd { if (group != null) { SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponse(group); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create security group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java index 0bcc144af4f..87e6df41b6b 100644 --- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.securitygroup; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -32,8 +34,10 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceInUseException; +import com.cloud.network.security.SecurityGroup; -@APICommand(name = "deleteSecurityGroup", description = "Deletes security group", responseObject = SuccessResponse.class) +@APICommand(name = "deleteSecurityGroup", description = "Deletes security group", responseObject = SuccessResponse.class, entityType = {SecurityGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteSecurityGroupCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteSecurityGroupCmd.class.getName()); private static final String s_name = "deletesecuritygroupresponse"; @@ -54,10 +58,8 @@ public class DeleteSecurityGroupCmd extends BaseCmd { @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, description = "the project of the security group", entityType = ProjectResponse.class) private Long projectId; - @Parameter(name = ApiConstants.ID, - type = CommandType.UUID, - description = "The ID of the security group. Mutually exclusive with name parameter", - entityType = SecurityGroupResponse.class) + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, description="The ID of the security group. Mutually exclusive with name parameter", entityType=SecurityGroupResponse.class) private Long id; @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The ID of the security group. Mutually exclusive with id parameter") @@ -109,7 +111,7 @@ public class DeleteSecurityGroupCmd extends BaseCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -123,7 +125,7 @@ public class DeleteSecurityGroupCmd extends BaseCmd { boolean result = _securityGroupService.deleteSecurityGroup(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete security group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java index ae745b30e57..4a8081a3507 100644 --- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java @@ -27,7 +27,10 @@ import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.SecurityGroupResponse; import org.apache.cloudstack.api.response.UserVmResponse; -@APICommand(name = "listSecurityGroups", description = "Lists security groups", responseObject = SecurityGroupResponse.class) +import com.cloud.network.security.SecurityGroup; + +@APICommand(name = "listSecurityGroups", description = "Lists security groups", responseObject = SecurityGroupResponse.class, entityType = {SecurityGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListSecurityGroupsCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListSecurityGroupsCmd.class.getName()); @@ -77,7 +80,7 @@ public class ListSecurityGroupsCmd extends BaseListTaggedResourcesCmd { public void execute() { ListResponse response = _queryService.searchForSecurityGroups(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java index 006aa7d7947..a28a220b534 100644 --- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java @@ -33,10 +33,10 @@ import com.cloud.network.security.SecurityGroup; import com.cloud.network.security.SecurityRule; import com.cloud.user.Account; -@APICommand(name = "revokeSecurityGroupEgress", - responseObject = SuccessResponse.class, - description = "Deletes a particular egress rule from this security group", - since = "3.0.0") + +@APICommand(name = "revokeSecurityGroupEgress", responseObject = SuccessResponse.class, description = "Deletes a particular egress rule from this security group", since = "3.0.0", entityType = {SecurityGroup.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class RevokeSecurityGroupEgressCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RevokeSecurityGroupEgressCmd.class.getName()); @@ -46,7 +46,7 @@ public class RevokeSecurityGroupEgressCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = true, description = "The ID of the egress rule", entityType = SecurityGroupRuleResponse.class) + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = true, description = "The ID of the egress rule", entityType=SecurityGroupRuleResponse.class) private Long id; // /////////////////////////////////////////////////// @@ -98,7 +98,7 @@ public class RevokeSecurityGroupEgressCmd extends BaseAsyncCmd { boolean result = _securityGroupService.revokeSecurityGroupEgress(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revoke security group egress rule"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java b/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java index 08585784fff..9e81d0bc4ee 100644 --- a/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.securitygroup; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -33,7 +35,8 @@ import com.cloud.network.security.SecurityGroup; import com.cloud.network.security.SecurityRule; import com.cloud.user.Account; -@APICommand(name = "revokeSecurityGroupIngress", responseObject = SuccessResponse.class, description = "Deletes a particular ingress rule from this security group") +@APICommand(name = "revokeSecurityGroupIngress", responseObject = SuccessResponse.class, description = "Deletes a particular ingress rule from this security group", entityType = {SecurityGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RevokeSecurityGroupIngressCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RevokeSecurityGroupIngressCmd.class.getName()); @@ -43,7 +46,8 @@ public class RevokeSecurityGroupIngressCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = true, description = "The ID of the ingress rule", entityType = SecurityGroupRuleResponse.class) + @ACL(accessType = AccessType.OperateEntry, pointerToEntity = "securityGroupId") + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = true, description = "The ID of the ingress rule", entityType=SecurityGroupRuleResponse.class) private Long id; // /////////////////////////////////////////////////// @@ -95,7 +99,7 @@ public class RevokeSecurityGroupIngressCmd extends BaseAsyncCmd { boolean result = _securityGroupService.revokeSecurityGroupIngress(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revoke security group ingress rule"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java index a0f307ba07a..bd8662e1460 100644 --- a/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotCmd.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.user.snapshot; import org.apache.log4j.Logger; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -41,7 +42,8 @@ import com.cloud.storage.Snapshot; import com.cloud.storage.Volume; import com.cloud.user.Account; -@APICommand(name = "createSnapshot", description = "Creates an instant snapshot of a volume.", responseObject = SnapshotResponse.class) +@APICommand(name = "createSnapshot", description = "Creates an instant snapshot of a volume.", responseObject = SnapshotResponse.class, entityType = {Snapshot.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateSnapshotCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateSnapshotCmd.class.getName()); private static final String s_name = "createsnapshotresponse"; @@ -58,16 +60,17 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, - description = "The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume.") + description = "The domain ID of the snapshot. If used with the account parameter, specifies a domain for the account associated with the disk volume.") private Long domainId; + @ACL @Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.UUID, entityType = VolumeResponse.class, required = true, description = "The ID of the disk volume") private Long volumeId; @Parameter(name = ApiConstants.POLICY_ID, type = CommandType.UUID, entityType = SnapshotPolicyResponse.class, - description = "policy id of the snapshot, if this is null, then use MANUAL_POLICY.") + description = "policy id of the snapshot, if this is null, then use MANUAL_POLICY.") private Long policyId; @Parameter(name = ApiConstants.SNAPSHOT_QUIESCEVM, type = CommandType.BOOLEAN, required = false, description = "quiesce vm if true") @@ -168,10 +171,10 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd { @Override public void create() throws ResourceAllocationException { - Snapshot snapshot = this._volumeService.allocSnapshot(getVolumeId(), getPolicyId()); + Snapshot snapshot = _volumeService.allocSnapshot(getVolumeId(), getPolicyId()); if (snapshot != null) { - this.setEntityId(snapshot.getId()); - this.setEntityUuid(snapshot.getUuid()); + setEntityId(snapshot.getId()); + setEntityUuid(snapshot.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot"); } @@ -184,11 +187,11 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd { Snapshot snapshot; try { snapshot = - _volumeService.takeSnapshot(this.getVolumeId(), this.getPolicyId(), this.getEntityId(), _accountService.getAccount(getEntityOwnerId()), getQuiescevm()); + _volumeService.takeSnapshot(getVolumeId(), getPolicyId(), getEntityId(), _accountService.getAccount(getEntityOwnerId()), getQuiescevm()); if (snapshot != null) { SnapshotResponse response = _responseGenerator.createSnapshotResponse(snapshot); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot for volume " + volumeId); } diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotPolicyCmd.java b/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotPolicyCmd.java index 5ecbaaa2bc9..c1381c8d7cc 100644 --- a/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotPolicyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/CreateSnapshotPolicyCmd.java @@ -34,7 +34,8 @@ import com.cloud.storage.Volume; import com.cloud.storage.snapshot.SnapshotPolicy; import com.cloud.user.Account; -@APICommand(name = "createSnapshotPolicy", description = "Creates a snapshot policy for the account.", responseObject = SnapshotPolicyResponse.class) +@APICommand(name = "createSnapshotPolicy", description = "Creates a snapshot policy for the account.", responseObject = SnapshotPolicyResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateSnapshotPolicyCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateSnapshotPolicyCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/DeleteSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/snapshot/DeleteSnapshotCmd.java index 35caaff8e10..64a432d0bcb 100644 --- a/api/src/org/apache/cloudstack/api/command/user/snapshot/DeleteSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/DeleteSnapshotCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.snapshot; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -33,7 +35,8 @@ import com.cloud.event.EventTypes; import com.cloud.storage.Snapshot; import com.cloud.user.Account; -@APICommand(name = "deleteSnapshot", description = "Deletes a snapshot of a disk volume.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteSnapshot", description = "Deletes a snapshot of a disk volume.", responseObject = SuccessResponse.class, entityType = {Snapshot.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteSnapshotCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteSnapshotCmd.class.getName()); private static final String s_name = "deletesnapshotresponse"; @@ -42,7 +45,9 @@ public class DeleteSnapshotCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SnapshotResponse.class, required = true, description = "The ID of the snapshot") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = SnapshotResponse.class, + required=true, description="The ID of the snapshot") private Long id; ///////////////////////////////////////////////////// @@ -79,7 +84,7 @@ public class DeleteSnapshotCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "deleting snapshot: " + getId(); + return "deleting snapshot: " + getId(); } @Override @@ -98,7 +103,7 @@ public class DeleteSnapshotCmd extends BaseAsyncCmd { boolean result = _snapshotService.deleteSnapshot(getId()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete snapshot"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/DeleteSnapshotPoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/snapshot/DeleteSnapshotPoliciesCmd.java index bcccf8b4f3e..2d97d3df261 100644 --- a/api/src/org/apache/cloudstack/api/command/user/snapshot/DeleteSnapshotPoliciesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/DeleteSnapshotPoliciesCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; -@APICommand(name = "deleteSnapshotPolicies", description = "Deletes snapshot policies for the account.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteSnapshotPolicies", description = "Deletes snapshot policies for the account.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteSnapshotPoliciesCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteSnapshotPoliciesCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java index 7c2899fe67c..ffafe2df7b7 100644 --- a/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotPoliciesCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.api.response.VolumeResponse; import com.cloud.storage.snapshot.SnapshotPolicy; import com.cloud.utils.Pair; -@APICommand(name = "listSnapshotPolicies", description = "Lists snapshot policies.", responseObject = SnapshotPolicyResponse.class) +@APICommand(name = "listSnapshotPolicies", description = "Lists snapshot policies.", responseObject = SnapshotPolicyResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListSnapshotPoliciesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListSnapshotPoliciesCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java b/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java index e4d566a3c5a..47a6876d09f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/ListSnapshotsCmd.java @@ -34,7 +34,8 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.storage.Snapshot; import com.cloud.utils.Pair; -@APICommand(name = "listSnapshots", description = "Lists all available snapshots for the account.", responseObject = SnapshotResponse.class) +@APICommand(name = "listSnapshots", description = "Lists all available snapshots for the account.", responseObject = SnapshotResponse.class, entityType = {Snapshot.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListSnapshotsCmd.class.getName()); @@ -117,6 +118,6 @@ public class ListSnapshotsCmd extends BaseListTaggedResourcesCmd { response.setResponses(snapshotResponses, result.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java index f11fa3f04aa..0c79f81564d 100644 --- a/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/snapshot/RevertSnapshotCmd.java @@ -18,6 +18,8 @@ */ package org.apache.cloudstack.api.command.user.snapshot; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -34,10 +36,14 @@ import com.cloud.event.EventTypes; import com.cloud.storage.Snapshot; import com.cloud.user.Account; -@APICommand(name = "revertSnapshot", description = "revert a volume snapshot.", responseObject = SnapshotResponse.class) +@APICommand(name = "revertSnapshot", description = "revert a volume snapshot.", responseObject = SnapshotResponse.class, entityType = {Snapshot.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RevertSnapshotCmd extends BaseAsyncCmd { private static final String s_name = "revertsnapshotresponse"; - @Parameter(name = ApiConstants.ID, type = BaseCmd.CommandType.UUID, entityType = SnapshotResponse.class, required = true, description = "The ID of the snapshot") + + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name= ApiConstants.ID, type= BaseCmd.CommandType.UUID, entityType = SnapshotResponse.class, + required=true, description="The ID of the snapshot") private Long id; public Long getId() { @@ -66,7 +72,7 @@ public class RevertSnapshotCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "revert snapshot: " + getId(); + return "revert snapshot: " + getId(); } @Override @@ -86,7 +92,7 @@ public class RevertSnapshotCmd extends BaseAsyncCmd { if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revert snapshot"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java index 1fc9d13fde1..bd7f613f897 100644 --- a/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/ssh/CreateSSHKeyPairCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.user.SSHKeyPair; -@APICommand(name = "createSSHKeyPair", description = "Create a new keypair and returns the private key", responseObject = CreateSSHKeyPairResponse.class) +@APICommand(name = "createSSHKeyPair", description = "Create a new keypair and returns the private key", responseObject = CreateSSHKeyPairResponse.class, entityType = {SSHKeyPair.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class CreateSSHKeyPairCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateSSHKeyPairCmd.class.getName()); private static final String s_name = "createsshkeypairresponse"; @@ -79,7 +80,7 @@ public class CreateSSHKeyPairCmd extends BaseCmd { ///////////////////////////////////////////////////// @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -93,7 +94,7 @@ public class CreateSSHKeyPairCmd extends BaseCmd { CreateSSHKeyPairResponse response = new CreateSSHKeyPairResponse(r.getName(), r.getFingerprint(), r.getPrivateKey()); response.setResponseName(getCommandName()); response.setObjectName("keypair"); - this.setResponseObject(response); + setResponseObject(response); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java index a638eb9d771..0709686ebf4 100644 --- a/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/ssh/DeleteSSHKeyPairCmd.java @@ -16,6 +16,7 @@ // under the License. package org.apache.cloudstack.api.command.user.ssh; + import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; @@ -28,8 +29,10 @@ import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.cloudstack.context.CallContext; import com.cloud.user.Account; +import com.cloud.user.SSHKeyPair; -@APICommand(name = "deleteSSHKeyPair", description = "Deletes a keypair by name", responseObject = SuccessResponse.class) +@APICommand(name = "deleteSSHKeyPair", description = "Deletes a keypair by name", responseObject = SuccessResponse.class, entityType = {SSHKeyPair.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteSSHKeyPairCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateSSHKeyPairCmd.class.getName()); private static final String s_name = "deletesshkeypairresponse"; @@ -79,7 +82,7 @@ public class DeleteSSHKeyPairCmd extends BaseCmd { boolean result = _mgr.deleteSSHKeyPair(this); SuccessResponse response = new SuccessResponse(getCommandName()); response.setSuccess(result); - this.setResponseObject(response); + setResponseObject(response); } @Override @@ -90,7 +93,7 @@ public class DeleteSSHKeyPairCmd extends BaseCmd { @Override public long getEntityOwnerId() { Account account = CallContext.current().getCallingAccount(); - if ((account == null) || isAdmin(account.getType())) { + if ((account == null) || _accountService.isAdmin(account.getType())) { if ((domainId != null) && (accountName != null)) { Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); if (userAccount != null) { diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/ListSSHKeyPairsCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/ListSSHKeyPairsCmd.java index 52fca5f031b..022cbc5068f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/ssh/ListSSHKeyPairsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/ssh/ListSSHKeyPairsCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.SSHKeyPairResponse; import com.cloud.user.SSHKeyPair; import com.cloud.utils.Pair; -@APICommand(name = "listSSHKeyPairs", description = "List registered keypairs", responseObject = SSHKeyPairResponse.class) +@APICommand(name = "listSSHKeyPairs", description = "List registered keypairs", responseObject = SSHKeyPairResponse.class, entityType = {SSHKeyPair.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListSSHKeyPairsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListSSHKeyPairsCmd.class.getName()); private static final String s_name = "listsshkeypairsresponse"; @@ -75,7 +76,7 @@ public class ListSSHKeyPairsCmd extends BaseListProjectAndAccountResourcesCmd { ListResponse response = new ListResponse(); response.setResponses(responses, resultList.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java b/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java index 8ed5cbd5605..c7cbc56ae65 100644 --- a/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/ssh/RegisterSSHKeyPairCmd.java @@ -29,7 +29,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.user.SSHKeyPair; -@APICommand(name = "registerSSHKeyPair", description = "Register a public key in a keypair under a certain name", responseObject = SSHKeyPairResponse.class) +@APICommand(name = "registerSSHKeyPair", description = "Register a public key in a keypair under a certain name", responseObject = SSHKeyPairResponse.class, entityType = {SSHKeyPair.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RegisterSSHKeyPairCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(RegisterSSHKeyPairCmd.class.getName()); private static final String s_name = "registersshkeypairresponse"; @@ -87,7 +88,7 @@ public class RegisterSSHKeyPairCmd extends BaseCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -101,7 +102,7 @@ public class RegisterSSHKeyPairCmd extends BaseCmd { SSHKeyPairResponse response = new SSHKeyPairResponse(result.getName(), result.getFingerprint()); response.setResponseName(getCommandName()); response.setObjectName("keypair"); - this.setResponseObject(response); + setResponseObject(response); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/tag/CreateTagsCmd.java b/api/src/org/apache/cloudstack/api/command/user/tag/CreateTagsCmd.java index ee0add438a7..6aecc055480 100644 --- a/api/src/org/apache/cloudstack/api/command/user/tag/CreateTagsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/tag/CreateTagsCmd.java @@ -37,7 +37,8 @@ import com.cloud.event.EventTypes; import com.cloud.server.ResourceTag; import com.cloud.server.ResourceTag.ResourceObjectType; -@APICommand(name = "createTags", description = "Creates resource tag(s)", responseObject = SuccessResponse.class, since = "4.0.0") +@APICommand(name = "createTags", description = "Creates resource tag(s)", responseObject = SuccessResponse.class, since = "4.0.0", entityType = {ResourceTag.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateTagsCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(CreateTagsCmd.class.getName()); @@ -117,7 +118,7 @@ public class CreateTagsCmd extends BaseAsyncCmd { if (tags != null && !tags.isEmpty()) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create tags"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/tag/DeleteTagsCmd.java b/api/src/org/apache/cloudstack/api/command/user/tag/DeleteTagsCmd.java index 3ee7c06469a..e42cfce4d91 100644 --- a/api/src/org/apache/cloudstack/api/command/user/tag/DeleteTagsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/tag/DeleteTagsCmd.java @@ -34,9 +34,11 @@ import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.event.EventTypes; +import com.cloud.server.ResourceTag; import com.cloud.server.ResourceTag.ResourceObjectType; -@APICommand(name = "deleteTags", description = "Deleting resource tag(s)", responseObject = SuccessResponse.class, since = "4.0.0") +@APICommand(name = "deleteTags", description = "Deleting resource tag(s)", responseObject = SuccessResponse.class, since = "4.0.0", entityType = {ResourceTag.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteTagsCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteTagsCmd.class.getName()); @@ -108,7 +110,7 @@ public class DeleteTagsCmd extends BaseAsyncCmd { if (success) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete tags"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/tag/ListTagsCmd.java b/api/src/org/apache/cloudstack/api/command/user/tag/ListTagsCmd.java index 893f6dfcedb..e02b25c4468 100644 --- a/api/src/org/apache/cloudstack/api/command/user/tag/ListTagsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/tag/ListTagsCmd.java @@ -24,7 +24,10 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ResourceTagResponse; -@APICommand(name = "listTags", description = "List resource tag(s)", responseObject = ResourceTagResponse.class, since = "4.0.0") +import com.cloud.server.ResourceTag; + +@APICommand(name = "listTags", description = "List resource tag(s)", responseObject = ResourceTagResponse.class, since = "4.0.0", entityType = {ResourceTag.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd { private static final String s_name = "listtagsresponse"; @@ -52,7 +55,7 @@ public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd { ListResponse response = _queryService.listTags(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } public String getResourceType() { diff --git a/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java index 87f94f72aa1..fdbdafd1446 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java @@ -26,6 +26,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.ZoneResponse; @@ -37,7 +38,8 @@ import com.cloud.exception.StorageUnavailableException; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "copyTemplate", description = "Copies a template from one zone to another.", responseObject = TemplateResponse.class) +@APICommand(name = "copyTemplate", description = "Copies a template from one zone to another.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CopyTemplateCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(CopyTemplateCmd.class.getName()); private static final String s_name = "copytemplateresponse"; @@ -109,7 +111,7 @@ public class CopyTemplateCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "copying template: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId(); + return "copying template: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId(); } @Override @@ -128,8 +130,8 @@ public class CopyTemplateCmd extends BaseAsyncCmd { CallContext.current().setEventDetails(getEventDescription()); VirtualMachineTemplate template = _templateService.copyTemplate(this); - if (template != null) { - List listResponse = _responseGenerator.createTemplateResponses(template, getDestinationZoneId(), false); + if (template != null){ + List listResponse = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template, getDestinationZoneId(), false); TemplateResponse response = new TemplateResponse(); if (listResponse != null && !listResponse.isEmpty()) { response = listResponse.get(0); diff --git a/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java index 0030a7e9ce8..10b150df01e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java @@ -28,6 +28,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCreateCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.GuestOSResponse; import org.apache.cloudstack.api.response.SnapshotResponse; @@ -46,9 +47,9 @@ import com.cloud.storage.Volume; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "createTemplate", responseObject = TemplateResponse.class, description = "Creates a template of a virtual machine. " - + "The virtual machine must be in a STOPPED state. " - + "A template created from this command is automatically designated as a private template visible to the account that created it.") +@APICommand(name = "createTemplate", responseObject = TemplateResponse.class, description = "Creates a template of a virtual machine. " + "The virtual machine must be in a STOPPED state. " + + "A template created from this command is automatically designated as a private template visible to the account that created it.", responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateTemplateCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateTemplateCmd.class.getName()); private static final String s_name = "createtemplateresponse"; @@ -94,20 +95,18 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.UUID, entityType = SnapshotResponse.class, - description = "the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in") - private Long snapshotId; + description = "the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in") + protected Long snapshotId; @Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.UUID, entityType = VolumeResponse.class, - description = "the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in") - private Long volumeId; + description = "the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in") + protected Long volumeId; - @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, - type = CommandType.UUID, - entityType = UserVmResponse.class, - description = "Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal") - private Long vmId; + @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType = UserVmResponse.class, + description="Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal") + protected Long vmId; @Parameter(name = ApiConstants.URL, type = CommandType.STRING, @@ -260,17 +259,17 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd { return ApiCommandJobType.Template; } - private boolean isBareMetal() { - return (this.getVmId() != null && this.getUrl() != null); + protected boolean isBareMetal() { + return (getVmId() != null && getUrl() != null); } @Override public void create() throws ResourceAllocationException { VirtualMachineTemplate template = null; - template = this._templateService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId())); + template = _templateService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId())); if (template != null) { - this.setEntityId(template.getId()); - this.setEntityUuid(template.getUuid()); + setEntityId(template.getId()); + setEntityUuid(template.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a template"); } @@ -282,21 +281,21 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd { CallContext.current().setEventDetails( "Template Id: " + getEntityId() + ((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId())); VirtualMachineTemplate template = null; - template = this._templateService.createPrivateTemplate(this); + template = _templateService.createPrivateTemplate(this); if (template != null) { List templateResponses; if (isBareMetal()) { - templateResponses = _responseGenerator.createTemplateResponses(template.getId(), vmId); + templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template.getId(), vmId); } else { - templateResponses = _responseGenerator.createTemplateResponses(template.getId(), snapshotId, volumeId, false); + templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template.getId(), snapshotId, volumeId, false); } TemplateResponse response = new TemplateResponse(); if (templateResponses != null && !templateResponses.isEmpty()) { response = templateResponses.get(0); } response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private template"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/template/DeleteTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/DeleteTemplateCmd.java index 890af70330f..98d53be836e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/DeleteTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/DeleteTemplateCmd.java @@ -36,7 +36,8 @@ import com.cloud.user.Account; @APICommand(name = "deleteTemplate", responseObject = SuccessResponse.class, - description = "Deletes a template from the system. All virtual machines using the deleted template will not be affected.") + description = "Deletes a template from the system. All virtual machines using the deleted template will not be affected.", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteTemplateCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteTemplateCmd.class.getName()); private static final String s_name = "deletetemplateresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ExtractTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/ExtractTemplateCmd.java index 082f46a5abf..c88b5e334b6 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/ExtractTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/ExtractTemplateCmd.java @@ -35,7 +35,8 @@ import com.cloud.exception.InternalErrorException; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "extractTemplate", description = "Extracts a template", responseObject = ExtractResponse.class) +@APICommand(name = "extractTemplate", description = "Extracts a template", responseObject = ExtractResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ExtractTemplateCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ExtractTemplateCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java index 08acf632a4c..48f8ffff586 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java @@ -20,14 +20,15 @@ import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.TemplatePermissionsResponse; import com.cloud.storage.Storage.ImageFormat; import com.cloud.template.VirtualMachineTemplate; -@APICommand(name = "listTemplatePermissions", - description = "List template visibility and all accounts that have permissions to view this template.", - responseObject = TemplatePermissionsResponse.class) +@APICommand(name = "listTemplatePermissions", description = "List template visibility and all accounts that have permissions to view this template.", responseObject = TemplatePermissionsResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListTemplatePermissionsCmd extends BaseListTemplateOrIsoPermissionsCmd { protected String getResponseName() { return "listtemplatepermissionsresponse"; @@ -47,4 +48,10 @@ public class ListTemplatePermissionsCmd extends BaseListTemplateOrIsoPermissions protected boolean templateIsCorrectType(VirtualMachineTemplate template) { return !template.getFormat().equals(ImageFormat.ISO); } + + @Override + public void execute() { + executeWithView(ResponseView.Restricted); + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java index d393c6a5fdf..249aa0e9be0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java @@ -23,15 +23,18 @@ import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; +import com.cloud.template.VirtualMachineTemplate; import com.cloud.template.VirtualMachineTemplate.TemplateFilter; import com.cloud.user.Account; -@APICommand(name = "listTemplates", description = "List all public, private, and privileged templates.", responseObject = TemplateResponse.class) +@APICommand(name = "listTemplates", description = "List all public, private, and privileged templates.", responseObject = TemplateResponse.class, entityType = {VirtualMachineTemplate.class}, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListTemplatesCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListTemplatesCmd.class.getName()); @@ -100,7 +103,7 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd { Account account = CallContext.current().getCallingAccount(); // It is account specific if account is admin type and domainId and accountName are not null - boolean isAccountSpecific = (account == null || isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null); + boolean isAccountSpecific = (account == null || _accountService.isAdmin(account.getType())) && (getAccountName() != null) && (getDomainId() != null); // Show only those that are downloaded. TemplateFilter templateFilter = TemplateFilter.valueOf(getTemplateFilter()); boolean onlyReady = @@ -127,6 +130,6 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd { public void execute() { ListResponse response = _queryService.listTemplates(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java index 48ed6ea6aac..f478c9bc8ee 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java @@ -21,14 +21,13 @@ import java.util.Collection; import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.GuestOSResponse; @@ -37,11 +36,13 @@ import org.apache.cloudstack.api.response.ProjectResponse; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; +import org.apache.log4j.Logger; import com.cloud.exception.ResourceAllocationException; import com.cloud.template.VirtualMachineTemplate; -@APICommand(name = "registerTemplate", description = "Registers an existing template into the CloudStack cloud. ", responseObject = TemplateResponse.class) +@APICommand(name = "registerTemplate", description = "Registers an existing template into the CloudStack cloud. ", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RegisterTemplateCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(RegisterTemplateCmd.class.getName()); @@ -106,12 +107,9 @@ public class RegisterTemplateCmd extends BaseCmd { description = "the URL of where the template is hosted. Possible URL include http:// and https://") private String url; - @Parameter(name = ApiConstants.ZONE_ID, - type = CommandType.UUID, - entityType = ZoneResponse.class, - required = true, - description = "the ID of the zone the template is to be hosted on") - private Long zoneId; + @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class, + required=true, description="the ID of the zone the template is to be hosted on") + protected Long zoneId; @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, @@ -251,7 +249,7 @@ public class RegisterTemplateCmd extends BaseCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -265,10 +263,10 @@ public class RegisterTemplateCmd extends BaseCmd { VirtualMachineTemplate template = _templateService.registerTemplate(this); if (template != null) { ListResponse response = new ListResponse(); - List templateResponses = _responseGenerator.createTemplateResponses(template, zoneId, false); + List templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template, zoneId, false); response.setResponses(templateResponses); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register template"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java index f80a4ee3062..81da7eea625 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java @@ -21,13 +21,15 @@ import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.TemplateResponse; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; -@APICommand(name = "updateTemplate", description = "Updates attributes of a template.", responseObject = TemplateResponse.class) +@APICommand(name = "updateTemplate", description = "Updates attributes of a template.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd { public static final Logger s_logger = Logger.getLogger(UpdateTemplateCmd.class.getName()); private static final String s_name = "updatetemplateresponse"; @@ -52,7 +54,7 @@ public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd { @SuppressWarnings("unchecked") public TemplateResponse getResponse() { - return null; + return null; } @Override @@ -69,11 +71,11 @@ public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd { public void execute() { VirtualMachineTemplate result = _templateService.updateTemplate(this); if (result != null) { - TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(result); + TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Restricted, result); response.setObjectName("template"); response.setTemplateType(result.getTemplateType().toString());//Template can be either USER or ROUTING type response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update template"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java index 96d1f55751a..2029156837e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java @@ -27,7 +27,8 @@ import com.cloud.user.Account; @APICommand(name = "updateTemplatePermissions", responseObject = SuccessResponse.class, description = "Updates a template visibility permissions. " + "A public template is visible to all accounts within the same domain. " + "A private template is visible only to the owner of the template. " - + "A priviledged template is a private template with account permissions added. " + "Only accounts specified under the template permissions are visible to them.") + + "A priviledged template is a private template with account permissions added. " + "Only accounts specified under the template permissions are visible to them.", entityType = {VirtualMachineTemplate.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateTemplatePermissionsCmd extends BaseUpdateTemplateOrIsoPermissionsCmd { @Override protected String getResponseName() { diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java index 439879add9b..870bbbf01e9 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/AddIpToVmNicCmd.java @@ -43,7 +43,8 @@ import com.cloud.vm.Nic; import com.cloud.vm.NicSecondaryIp; import com.cloud.vm.VirtualMachine; -@APICommand(name = "addIpToNic", description = "Assigns secondary IP to NIC", responseObject = NicSecondaryIpResponse.class) +@APICommand(name = "addIpToNic", description = "Assigns secondary IP to NIC", responseObject = NicSecondaryIpResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddIpToVmNicCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AddIpToVmNicCmd.class.getName()); private static final String s_name = "addiptovmnicresponse"; @@ -91,6 +92,12 @@ public class AddIpToVmNicCmd extends BaseAsyncCmd { return dc.getNetworkType(); } + private boolean isZoneSGEnabled() { + Network ntwk = _entityMgr.findById(Network.class, getNetworkId()); + DataCenter dc = _entityMgr.findById(DataCenter.class, ntwk.getDataCenterId()); + return dc.isSecurityGroupEnabled(); + } + @Override public String getEventType() { return EventTypes.EVENT_NET_IP_ASSIGN; @@ -135,7 +142,7 @@ public class AddIpToVmNicCmd extends BaseAsyncCmd { if (result != null) { secondaryIp = result.getIp4Address(); - if (getNetworkType() == NetworkType.Basic) { + if (isZoneSGEnabled()) { // add security group rules for the secondary ip addresses boolean success = false; success = _securityGroupService.securityGroupRulesForVmSecIp(getNicId(), secondaryIp, true); diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/AddNicToVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/AddNicToVMCmd.java index 43efe166895..fd30152ae08 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/AddNicToVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/AddNicToVMCmd.java @@ -21,12 +21,15 @@ import java.util.EnumSet; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants.VMDetails; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -35,8 +38,10 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "addNicToVirtualMachine", description = "Adds VM to specified network by creating a NIC", responseObject = UserVmResponse.class) +@APICommand(name = "addNicToVirtualMachine", description = "Adds VM to specified network by creating a NIC", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class AddNicToVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AddNicToVMCmd.class); private static final String s_name = "addnictovirtualmachineresponse"; @@ -44,10 +49,12 @@ public class AddNicToVMCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "Virtual Machine ID") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="Virtual Machine ID") private Long vmId; + @ACL @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, required = true, description = "Network ID") private Long netId; @@ -90,14 +97,14 @@ public class AddNicToVMCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "Adding network " + getNetworkId() + " to user vm: " + getVmId(); + return "Adding network " + getNetworkId() + " to user vm: " + getVmId(); } @Override public long getEntityOwnerId() { UserVm vm = _responseGenerator.findUserVmById(getVmId()); if (vm == null) { - return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked + return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked } return vm.getAccountId(); } @@ -109,10 +116,10 @@ public class AddNicToVMCmd extends BaseAsyncCmd { ArrayList dc = new ArrayList(); dc.add(VMDetails.valueOf("nics")); EnumSet details = EnumSet.copyOf(dc); - if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", details, result).get(0); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", details, result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add NIC to vm. Refer to server logs for details."); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java index eb19db43866..cc91013d5fc 100755 --- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java @@ -24,6 +24,9 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.affinity.AffinityGroupResponse; import org.apache.cloudstack.api.ACL; @@ -33,6 +36,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCreateCustomIdCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DiskOfferingResponse; import org.apache.cloudstack.api.response.DomainResponse; @@ -45,7 +49,6 @@ import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter.NetworkType; @@ -64,8 +67,10 @@ import com.cloud.offering.ServiceOffering; import com.cloud.template.VirtualMachineTemplate; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "deployVirtualMachine", description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", responseObject = UserVmResponse.class) +@APICommand(name = "deployVirtualMachine", description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { public static final Logger s_logger = Logger.getLogger(DeployVMCmd.class.getName()); @@ -100,7 +105,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { private Long domainId; //Network information - @ACL(accessType = AccessType.UseNetwork) + @ACL(accessType = AccessType.UseEntry) @Parameter(name = ApiConstants.NETWORK_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = NetworkResponse.class, description = "list of network ids used by virtual machine. Can't be specified with ipToNetworkList parameter") private List networkIds; @@ -116,6 +121,12 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { @Parameter(name = ApiConstants.SIZE, type = CommandType.LONG, description = "the arbitrary size for the DATADISK volume. Mutually exclusive with diskOfferingId") private Long size; + @Parameter(name = ApiConstants.ROOT_DISK_SIZE, + type = CommandType.LONG, + description = "Optional field to resize root disk on deploy. Only applies to template-based deployments. Analogous to details[0].rootdisksize, which takes precedence over this parameter if both are provided", + since = "4.4") + private Long rootdisksize; + @Parameter(name = ApiConstants.GROUP, type = CommandType.STRING, description = "an optional group for the virtual machine") private String group; @@ -170,12 +181,15 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { + "Mutually exclusive with affinitygroupids parameter") private List affinityGroupNameList; - @Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, since = "4.2", description = "an optional field, whether to the display the vm to the end user or not.") + @Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, since = "4.2", description = "an optional field, whether to the display the vm to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayVm; @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, since = "4.3", description = "used to specify the custom parameters.") private Map details; + @Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description = "Deployment planner to use for vm allocation. Available to ROOT admin only", since = "4.4", authorized = { RoleType.Admin }) + private String deploymentPlanner; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -191,6 +205,10 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { return diskOfferingId; } + public String getDeploymentPlanner() { + return deploymentPlanner; + } + public String getDisplayName() { return displayName; } @@ -214,6 +232,9 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { } } } + if (rootdisksize != null && !customparameterMap.containsKey("rootdisksize")) { + customparameterMap.put("rootdisksize", rootdisksize.toString()); + } return customparameterMap; } @@ -234,8 +255,8 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { throw new InvalidParameterValueException("securitygroupids parameter is mutually exclusive with securitygroupnames parameter"); } - //transform group names to ids here - if (securityGroupNameList != null) { + //transform group names to ids here + if (securityGroupNameList != null) { List securityGroupIds = new ArrayList(); for (String groupName : securityGroupNameList) { Long groupId = _responseGenerator.getSecurityGroupId(groupName, getEntityOwnerId()); @@ -272,15 +293,15 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { } public List getNetworkIds() { - if (ipToNetworkList != null) { - if (networkIds != null || ipAddress != null || getIp6Address() != null) { - throw new InvalidParameterValueException("ipToNetworkMap can't be specified along with networkIds or ipAddress"); - } else { - List networks = new ArrayList(); - networks.addAll(getIpToNetworkMap().keySet()); - return networks; - } - } + if (ipToNetworkList != null) { + if (networkIds != null || ipAddress != null || getIp6Address() != null) { + throw new InvalidParameterValueException("ipToNetworkMap can't be specified along with networkIds or ipAddress"); + } else { + List networks = new ArrayList(); + networks.addAll(getIpToNetworkMap().keySet()); + return networks; + } + } return networkIds; } @@ -379,7 +400,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -387,6 +408,16 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { return accountId; } + @Override + public boolean isDisplayResourceEnabled(){ + Boolean display = getDisplayVm(); + if(display == null){ + return true; + } else { + return display; + } + } + @Override public String getEventType() { return EventTypes.EVENT_VM_CREATE; @@ -442,7 +473,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { } if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); setResponseObject(response); } else { @@ -450,12 +481,71 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { } } + // this is an opportunity to verify that parameters that came in via the Details Map are OK + // for example, minIops and maxIops should either both be specified or neither be specified and, + // if specified, minIops should be <= maxIops + private void verifyDetails() { + Map map = getDetails(); + + if (map != null) { + String minIops = (String)map.get("minIops"); + String maxIops = (String)map.get("maxIops"); + + verifyMinAndMaxIops(minIops, maxIops); + + minIops = (String)map.get("minIopsDo"); + maxIops = (String)map.get("maxIopsDo"); + + verifyMinAndMaxIops(minIops, maxIops); + } + } + + private void verifyMinAndMaxIops(String minIops, String maxIops) { + if ((minIops != null && maxIops == null) || (minIops == null && maxIops != null)) { + throw new InvalidParameterValueException("Either 'Min IOPS' and 'Max IOPS' must both be specified or neither be specified."); + } + + long lMinIops; + + try { + if (minIops != null) { + lMinIops = Long.valueOf(minIops); + } + else { + lMinIops = 0; + } + } + catch (NumberFormatException ex) { + throw new InvalidParameterValueException("'Min IOPS' must be a whole number."); + } + + long lMaxIops; + + try { + if (maxIops != null) { + lMaxIops = Long.valueOf(maxIops); + } + else { + lMaxIops = 0; + } + } + catch (NumberFormatException ex) { + throw new InvalidParameterValueException("'Max IOPS' must be a whole number."); + } + + if (lMinIops > lMaxIops) { + throw new InvalidParameterValueException("'Min IOPS' must be less than or equal to 'Max IOPS'."); + } + } + @Override public void create() throws ResourceAllocationException { try { //Verify that all objects exist before passing them to the service Account owner = _accountService.getActiveAccountById(getEntityOwnerId()); + verifyDetails(); + DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId); if (zone == null) { throw new InvalidParameterValueException("Unable to find zone by id=" + zoneId); @@ -500,7 +590,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { getDetails(), getCustomId()); } } else { - if (zone.isSecurityGroupEnabled()) { + if (zone.isSecurityGroupEnabled()) { vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(), owner, name, displayName, diskOfferingId, size, group, getHypervisor(), getHttpMethod(), userData, sshKeyPairName, getIpToNetworkMap(), addrs, displayVm, keyboard, getAffinityGroupIdList(), getDetails(), getCustomId()); @@ -528,7 +618,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd { } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage()); - } catch (ConcurrentOperationException ex) { + } catch (ConcurrentOperationException ex) { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } catch (ResourceAllocationException ex) { diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java index 3c63e8d3402..f2caa15d558 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java @@ -20,12 +20,15 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVMCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.context.CallContext; @@ -35,11 +38,12 @@ import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "destroyVirtualMachine", - description = "Destroys a virtual machine. Once destroyed, only the administrator can recover it.", - responseObject = UserVmResponse.class) -public class DestroyVMCmd extends BaseAsyncCmd { +@APICommand(name = "destroyVirtualMachine", description = "Destroys a virtual machine. Once destroyed, only the administrator can recover it.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = true) +public class DestroyVMCmd extends BaseAsyncVMCmd { public static final Logger s_logger = Logger.getLogger(DestroyVMCmd.class.getName()); private static final String s_name = "destroyvirtualmachineresponse"; @@ -48,7 +52,9 @@ public class DestroyVMCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="The ID of the virtual machine") private Long id; @Parameter(name = ApiConstants.EXPUNGE, @@ -61,6 +67,7 @@ public class DestroyVMCmd extends BaseAsyncCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + @Override public Long getId() { return id; } @@ -98,7 +105,7 @@ public class DestroyVMCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "destroying vm: " + getId(); + return "destroying vm: " + getId(); } @Override @@ -118,12 +125,12 @@ public class DestroyVMCmd extends BaseAsyncCmd { UserVmResponse response = new UserVmResponse(); if (result != null) { - List responses = _responseGenerator.createUserVmResponse("virtualmachine", result); + List responses = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result); if (responses != null && !responses.isEmpty()) { response = responses.get(0); } response.setResponseName("virtualmachine"); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/GetVMPasswordCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/GetVMPasswordCmd.java index d0503d16201..0ba9db538a5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/GetVMPasswordCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/GetVMPasswordCmd.java @@ -20,6 +20,8 @@ import java.security.InvalidParameterException; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd; @@ -29,8 +31,10 @@ import org.apache.cloudstack.api.response.UserVmResponse; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "getVMPassword", responseObject = GetVMPasswordResponse.class, description = "Returns an encrypted password for the VM") +@APICommand(name = "getVMPassword", responseObject = GetVMPasswordResponse.class, description = "Returns an encrypted password for the VM", entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class GetVMPasswordCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(GetVMPasswordCmd.class.getName()); private static final String s_name = "getvmpasswordresponse"; @@ -39,7 +43,9 @@ public class GetVMPasswordCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class + , required=true, description="The ID of the virtual machine") private Long id; ///////////////////////////////////////////////////// @@ -60,7 +66,7 @@ public class GetVMPasswordCmd extends BaseCmd { if (passwd == null || passwd.equals("")) throw new InvalidParameterException("No password for VM with id '" + getId() + "' found."); - this.setResponseObject(new GetVMPasswordResponse(getCommandName(), passwd)); + setResponseObject(new GetVMPasswordResponse(getCommandName(), passwd)); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java index 95d4990bf57..408497cbc64 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/ListNicsCmd.java @@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.user.vm; import java.util.ArrayList; import java.util.List; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -40,7 +41,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.vm.Nic; -@APICommand(name = "listNics", description = "list the vm nics IP to NIC", responseObject = NicResponse.class) +@APICommand(name = "listNics", description = "list the vm nics IP to NIC", responseObject = NicResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListNicsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListNicsCmd.class.getName()); private static final String s_name = "listnicsresponse"; @@ -58,6 +60,9 @@ public class ListNicsCmd extends BaseListCmd { @Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class, description = "list nic of the specific vm's network") private Long networkId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -92,6 +97,15 @@ public class ListNicsCmd extends BaseListCmd { return caller.getAccountId(); } + + public Boolean getDisplay() { + Account caller = CallContext.current().getCallingAccount(); + if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) { + return true; + } + return display; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java index 28637fbbb35..76e3db07b75 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.affinity.AffinityGroupResponse; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; @@ -29,12 +30,14 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants.VMDetails; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.HostResponse; import org.apache.cloudstack.api.response.InstanceGroupResponse; import org.apache.cloudstack.api.response.IsoVmResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.api.response.PodResponse; +import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.StoragePoolResponse; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -42,8 +45,11 @@ import org.apache.cloudstack.api.response.VpcResponse; import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.exception.InvalidParameterValueException; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "listVirtualMachines", description = "List the virtual machines owned by the account.", responseObject = UserVmResponse.class) + +@APICommand(name = "listVirtualMachines", description = "List the virtual machines owned by the account.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class ListVMsCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListVMsCmd.class.getName()); @@ -62,6 +68,9 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, description = "the ID of the virtual machine") private Long id; + @Parameter(name=ApiConstants.IDS, type=CommandType.LIST, collectionType=CommandType.UUID, entityType=UserVmResponse.class, description="the IDs of the virtual machines, mutually exclusive with id", since = "4.4") + private List ids; + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "name of the virtual machine") private String name; @@ -111,6 +120,12 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.AFFINITY_GROUP_ID, type = CommandType.UUID, entityType = AffinityGroupResponse.class, description = "list vms by affinity group") private Long affinityGroupId; + @Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, description = "list by the service offering", since = "4.4") + private Long serviceOffId; + + @Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -119,37 +134,30 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd { return groupId; } - public Long getHostId() { - return hostId; - } - public Long getId() { return id; } + public List getIds() { + return ids; + } + public String getName() { return name; } - public Long getPodId() { - return podId; - } - public String getState() { return state; } + public Long getServiceOfferingId() { + return serviceOffId; + } + public Long getZoneId() { return zoneId; } - public Boolean getForVirtualNetwork() { - return forVirtualNetwork; - } - - public void setForVirtualNetwork(Boolean forVirtualNetwork) { - this.forVirtualNetwork = forVirtualNetwork; - } public Long getNetworkId() { return networkId; @@ -159,9 +167,6 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd { return hypervisor; } - public Long getStorageId() { - return storageId; - } public Long getTemplateId() { return templateId; @@ -197,6 +202,13 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd { return dv; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -214,6 +226,6 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd { public void execute() { ListResponse response = _queryService.searchForUserVMs(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java index 7ac913888de..2bafc739fa5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java @@ -18,12 +18,15 @@ package org.apache.cloudstack.api.command.user.vm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVMCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.context.CallContext; @@ -33,23 +36,27 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "rebootVirtualMachine", description = "Reboots a virtual machine.", responseObject = UserVmResponse.class) -public class RebootVMCmd extends BaseAsyncCmd { +@APICommand(name = "rebootVirtualMachine", description = "Reboots a virtual machine.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) +public class RebootVMCmd extends BaseAsyncVMCmd { public static final Logger s_logger = Logger.getLogger(RebootVMCmd.class.getName()); private static final String s_name = "rebootvirtualmachineresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="The ID of the virtual machine") private Long id; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + @Override public Long getId() { return id; } @@ -80,7 +87,7 @@ public class RebootVMCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "rebooting user vm: " + getId(); + return "rebooting user vm: " + getId(); } @Override @@ -98,11 +105,10 @@ public class RebootVMCmd extends BaseAsyncCmd { CallContext.current().setEventDetails("Vm Id: " + getId()); UserVm result; result = _userVmService.rebootVirtualMachine(this); - - if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + if (result !=null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reboot vm instance"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/RemoveIpFromVmNicCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/RemoveIpFromVmNicCmd.java index 24582472b53..70d5b48a16a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/RemoveIpFromVmNicCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/RemoveIpFromVmNicCmd.java @@ -37,7 +37,9 @@ import com.cloud.network.Network; import com.cloud.user.Account; import com.cloud.vm.NicSecondaryIp; -@APICommand(name = "removeIpFromNic", description = "Removes secondary IP from the NIC.", responseObject = SuccessResponse.class) + +@APICommand(name = "removeIpFromNic", description = "Removes secondary IP from the NIC.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RemoveIpFromVmNicCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RemoveIpFromVmNicCmd.class.getName()); private static final String s_name = "removeipfromnicresponse"; @@ -45,12 +47,11 @@ public class RemoveIpFromVmNicCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, - type = CommandType.UUID, - required = true, - entityType = NicSecondaryIpResponse.class, - description = "the ID of the secondary ip address to nic") + type = CommandType.UUID, + required = true, + entityType = NicSecondaryIpResponse.class, + description = "the ID of the secondary ip address to nic") private Long id; // unexposed parameter needed for events logging @@ -95,7 +96,7 @@ public class RemoveIpFromVmNicCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return ("Disassociating ip address with id=" + id); + return ("Disassociating ip address with id=" + id); } ///////////////////////////////////////////////////// @@ -130,6 +131,13 @@ public class RemoveIpFromVmNicCmd extends BaseAsyncCmd { return null; } + + private boolean isZoneSGEnabled() { + Network ntwk = _entityMgr.findById(Network.class, getNetworkId()); + DataCenter dc = _entityMgr.findById(DataCenter.class, ntwk.getDataCenterId()); + return dc.isSecurityGroupEnabled(); + } + @Override public void execute() throws InvalidParameterValueException { CallContext.current().setEventDetails("Ip Id: " + id); @@ -139,7 +147,7 @@ public class RemoveIpFromVmNicCmd extends BaseAsyncCmd { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Invalid IP id is passed"); } - if (getNetworkType() == NetworkType.Basic) { + if (isZoneSGEnabled()) { //remove the security group rules for this secondary ip boolean success = false; success = _securityGroupService.securityGroupRulesForVmSecIp(nicSecIp.getNicId(), nicSecIp.getIp4Address(), false); @@ -152,7 +160,7 @@ public class RemoveIpFromVmNicCmd extends BaseAsyncCmd { boolean result = _networkService.releaseSecondaryIpFromNic(id); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove secondary ip address for the nic"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/RemoveNicFromVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/RemoveNicFromVMCmd.java index 92becb77ae4..d740260fc63 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/RemoveNicFromVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/RemoveNicFromVMCmd.java @@ -21,12 +21,15 @@ import java.util.EnumSet; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants.VMDetails; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.NicResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -35,8 +38,10 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "removeNicFromVirtualMachine", description = "Removes VM from specified network by deleting a NIC", responseObject = UserVmResponse.class) +@APICommand(name = "removeNicFromVirtualMachine", description = "Removes VM from specified network by deleting a NIC", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class RemoveNicFromVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RemoveNicFromVMCmd.class); private static final String s_name = "removenicfromvirtualmachineresponse"; @@ -44,8 +49,9 @@ public class RemoveNicFromVMCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "Virtual Machine ID") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="Virtual Machine ID") private Long vmId; @Parameter(name = ApiConstants.NIC_ID, type = CommandType.UUID, entityType = NicResponse.class, required = true, description = "NIC ID") @@ -83,14 +89,14 @@ public class RemoveNicFromVMCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "Removing NIC " + getNicId() + " from user vm: " + getVmId(); + return "Removing NIC " + getNicId() + " from user vm: " + getVmId(); } @Override public long getEntityOwnerId() { UserVm vm = _responseGenerator.findUserVmById(getVmId()); if (vm == null) { - return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked + return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked } return vm.getAccountId(); } @@ -102,10 +108,10 @@ public class RemoveNicFromVMCmd extends BaseAsyncCmd { ArrayList dc = new ArrayList(); dc.add(VMDetails.valueOf("nics")); EnumSet details = EnumSet.copyOf(dc); - if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", details, result).get(0); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", details, result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove NIC from vm, see error log for details"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java index df341205cf3..d15ea47875a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMPasswordCmd.java @@ -18,12 +18,15 @@ package org.apache.cloudstack.api.command.user.vm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVMCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.context.CallContext; @@ -33,10 +36,13 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "resetPasswordForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the password for virtual machine. " - + "The virtual machine must be in a \"Stopped\" state and the template must already " + "support this feature for this command to take effect. [async]") -public class ResetVMPasswordCmd extends BaseAsyncCmd { +@APICommand(name = "resetPasswordForVirtualMachine", responseObject=UserVmResponse.class, description="Resets the password for virtual machine. " + + "The virtual machine must be in a \"Stopped\" state and the template must already " + + "support this feature for this command to take effect. [async]", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) +public class ResetVMPasswordCmd extends BaseAsyncVMCmd { public static final Logger s_logger = Logger.getLogger(ResetVMPasswordCmd.class.getName()); private static final String s_name = "resetpasswordforvirtualmachineresponse"; @@ -44,18 +50,21 @@ public class ResetVMPasswordCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="The ID of the virtual machine") private Long id; // unexposed parameter needed for serializing/deserializing the command - @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, expose = false) - private String password; + @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, expose=false) + protected String password; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + @Override public Long getId() { return id; } @@ -94,7 +103,7 @@ public class ResetVMPasswordCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "resetting password for vm: " + getId(); + return "resetting password for vm: " + getId(); } @Override @@ -112,10 +121,10 @@ public class ResetVMPasswordCmd extends BaseAsyncCmd { password = _mgr.generateRandomPassword(); CallContext.current().setEventDetails("Vm Id: " + getId()); UserVm result = _userVmService.resetVMPassword(this, password); - if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset vm password"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java index 7436e3de4cb..6b4ce5c9982 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/ResetVMSSHKeyCmd.java @@ -19,12 +19,15 @@ package org.apache.cloudstack.api.command.user.vm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVMCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ProjectResponse; @@ -36,10 +39,12 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "resetSSHKeyForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the SSH Key for virtual machine. " - + "The virtual machine must be in a \"Stopped\" state. [async]") -public class ResetVMSSHKeyCmd extends BaseAsyncCmd { +@APICommand(name = "resetSSHKeyForVirtualMachine", responseObject = UserVmResponse.class, description = "Resets the SSH Key for virtual machine. " + + "The virtual machine must be in a \"Stopped\" state. [async]", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) +public class ResetVMSSHKeyCmd extends BaseAsyncVMCmd { public static final Logger s_logger = Logger.getLogger(ResetVMSSHKeyCmd.class.getName()); @@ -48,7 +53,7 @@ public class ResetVMSSHKeyCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") private Long id; @@ -76,6 +81,7 @@ public class ResetVMSSHKeyCmd extends BaseAsyncCmd { return name; } + @Override public Long getId() { return id; } @@ -138,9 +144,9 @@ public class ResetVMSSHKeyCmd extends BaseAsyncCmd { UserVm result = _userVmService.resetVMSSHKey(this); if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset vm SSHKey"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java index b69b364a031..b1cc6021730 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java @@ -18,11 +18,14 @@ package org.apache.cloudstack.api.command.user.vm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVMCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -35,16 +38,18 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "restoreVirtualMachine", - description = "Restore a VM to original template/ISO or new template/ISO", - responseObject = UserVmResponse.class, - since = "3.0.0") -public class RestoreVMCmd extends BaseAsyncCmd { +@APICommand(name = "restoreVirtualMachine", description = "Restore a VM to original template/ISO or new template/ISO", responseObject = UserVmResponse.class, since = "3.0.0", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = true) +public class RestoreVMCmd extends BaseAsyncVMCmd { public static final Logger s_logger = Logger.getLogger(RestoreVMCmd.class); private static final String s_name = "restorevmresponse"; - @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "Virtual Machine ID") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="Virtual Machine ID") private Long vmId; @Parameter(name = ApiConstants.TEMPLATE_ID, @@ -65,14 +70,14 @@ public class RestoreVMCmd extends BaseAsyncCmd { @Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, - ResourceAllocationException { + ResourceAllocationException { UserVm result; CallContext.current().setEventDetails("Vm Id: " + getVmId()); result = _userVmService.restoreVM(this); if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restore vm " + getVmId()); } @@ -87,7 +92,7 @@ public class RestoreVMCmd extends BaseAsyncCmd { public long getEntityOwnerId() { UserVm vm = _responseGenerator.findUserVmById(getVmId()); if (vm == null) { - return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked + return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked } return vm.getAccountId(); } @@ -99,4 +104,10 @@ public class RestoreVMCmd extends BaseAsyncCmd { public Long getTemplateId() { return templateId; } + + // TODO - Remove vmid param and make it "id" in 5.0 so that we dont have two getters + @Override + public Long getId() { + return getVmId(); + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java index d23430095d2..76f9472dac9 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java @@ -22,18 +22,21 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVMCmd; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.cloudstack.api.response.UserVmResponse; -import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; @@ -42,22 +45,25 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.VirtualMachineMigrationException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering.", responseObject = SuccessResponse.class) -public class ScaleVMCmd extends BaseAsyncCmd { + +@APICommand(name = "scaleVirtualMachine", description = "Scales the virtual machine to a new service offering.", responseObject = SuccessResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class ScaleVMCmd extends BaseAsyncVMCmd { public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName()); private static final String s_name = "scalevirtualmachineresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - - @ACL - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="The ID of the virtual machine") private Long id; - @ACL - @Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, required = true, description = "the ID of the service offering for the virtual machine") + @Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType=ServiceOfferingResponse.class, + required=true, description="the ID of the service offering for the virtual machine") private Long serviceOfferingId; @Parameter(name = ApiConstants.DETAILS, type = BaseCmd.CommandType.MAP, description = "name value pairs of custom parameters for cpu,memory and cpunumber. example details[i].name=value") @@ -67,6 +73,7 @@ public class ScaleVMCmd extends BaseAsyncCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + @Override public Long getId() { return id; } @@ -123,7 +130,7 @@ public class ScaleVMCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "upgrading vm: " + getId() + " to service offering: " + getServiceOfferingId(); + return "upgrading vm: " + getId() + " to service offering: " + getServiceOfferingId(); } @Override @@ -144,11 +151,11 @@ public class ScaleVMCmd extends BaseAsyncCmd { s_logger.warn("Exception: ", ex); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage()); } - if (result != null) { - List responseList = _responseGenerator.createUserVmResponse("virtualmachine", result); + if (result != null){ + List responseList = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result); UserVmResponse response = responseList.get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to scale vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java index 4239a6471af..7b1cf8fd6ba 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java @@ -18,12 +18,16 @@ package org.apache.cloudstack.api.command.user.vm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVMCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.HostResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -39,9 +43,11 @@ import com.cloud.exception.StorageUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; import com.cloud.utils.exception.ExecutionException; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "startVirtualMachine", responseObject = UserVmResponse.class, description = "Starts a virtual machine.") -public class StartVMCmd extends BaseAsyncCmd { +@APICommand(name = "startVirtualMachine", responseObject = UserVmResponse.class, description = "Starts a virtual machine.", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) +public class StartVMCmd extends BaseAsyncVMCmd { public static final Logger s_logger = Logger.getLogger(StartVMCmd.class.getName()); private static final String s_name = "startvirtualmachineresponse"; @@ -49,8 +55,9 @@ public class StartVMCmd extends BaseAsyncCmd { // /////////////////////////////////////////////////// // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType=UserVmResponse.class, + required = true, description = "The ID of the virtual machine") private Long id; @Parameter(name = ApiConstants.HOST_ID, @@ -60,10 +67,14 @@ public class StartVMCmd extends BaseAsyncCmd { since = "3.0.1") private Long hostId; + @Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description = "Deployment planner to use for vm allocation. Available to ROOT admin only", since = "4.4", authorized = { RoleType.Admin }) + private String deploymentPlanner; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// + @Override public Long getId() { return id; } @@ -85,6 +96,10 @@ public class StartVMCmd extends BaseAsyncCmd { return "virtualmachine"; } + public String getDeploymentPlanner() { + return deploymentPlanner; + } + @Override public long getEntityOwnerId() { UserVm vm = _responseGenerator.findUserVmById(getId()); @@ -125,9 +140,9 @@ public class StartVMCmd extends BaseAsyncCmd { result = _userVmService.startVirtualMachine(this); if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start a vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java index 17f12f97f54..d02fd7d47a1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java @@ -18,13 +18,15 @@ package org.apache.cloudstack.api.command.user.vm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVMCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.context.CallContext; @@ -33,9 +35,11 @@ import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "stopVirtualMachine", responseObject = UserVmResponse.class, description = "Stops a virtual machine.") -public class StopVMCmd extends BaseAsyncCmd { +@APICommand(name = "stopVirtualMachine", responseObject = UserVmResponse.class, description = "Stops a virtual machine.", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) +public class StopVMCmd extends BaseAsyncVMCmd { public static final Logger s_logger = Logger.getLogger(StopVMCmd.class.getName()); private static final String s_name = "stopvirtualmachineresponse"; @@ -44,8 +48,9 @@ public class StopVMCmd extends BaseAsyncCmd { // ////////////// API parameters ///////////////////// // /////////////////////////////////////////////////// - @ACL - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType=UserVmResponse.class, + required = true, description = "The ID of the virtual machine") private Long id; @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, required = false, description = "Force stop the VM " @@ -56,6 +61,7 @@ public class StopVMCmd extends BaseAsyncCmd { // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// + @Override public Long getId() { return id; } @@ -116,9 +122,9 @@ public class StopVMCmd extends BaseAsyncCmd { result = _userVmService.stopVirtualMachine(getId(), isForced()); if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop vm"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateDefaultNicForVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateDefaultNicForVMCmd.java index f699cce4a1f..cffd9037920 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateDefaultNicForVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateDefaultNicForVMCmd.java @@ -21,12 +21,15 @@ import java.util.EnumSet; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants.VMDetails; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.NicResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -35,8 +38,10 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "updateDefaultNicForVirtualMachine", description = "Changes the default NIC on a VM", responseObject = UserVmResponse.class) +@APICommand(name = "updateDefaultNicForVirtualMachine", description = "Changes the default NIC on a VM", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class UpdateDefaultNicForVMCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateDefaultNicForVMCmd.class); private static final String s_name = "updatedefaultnicforvirtualmachineresponse"; @@ -45,7 +50,9 @@ public class UpdateDefaultNicForVMCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "Virtual Machine ID") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="Virtual Machine ID") private Long vmId; @Parameter(name = ApiConstants.NIC_ID, type = CommandType.UUID, entityType = NicResponse.class, required = true, description = "NIC ID") @@ -83,14 +90,14 @@ public class UpdateDefaultNicForVMCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "Updating NIC " + getNicId() + " on user vm: " + getVmId(); + return "Updating NIC " + getNicId() + " on user vm: " + getVmId(); } @Override public long getEntityOwnerId() { UserVm vm = _responseGenerator.findUserVmById(getVmId()); if (vm == null) { - return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked + return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked } return vm.getAccountId(); } @@ -102,10 +109,10 @@ public class UpdateDefaultNicForVMCmd extends BaseAsyncCmd { ArrayList dc = new ArrayList(); dc.add(VMDetails.valueOf("nics")); EnumSet details = EnumSet.copyOf(dc); - if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", details, result).get(0); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", details, result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to set default nic for VM. Refer to server logs for details."); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java index e0ca787b6d6..1d0e68dfc3a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpdateVMCmd.java @@ -18,11 +18,15 @@ package org.apache.cloudstack.api.command.user.vm; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCustomIdCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.GuestOSResponse; import org.apache.cloudstack.api.response.UserVmResponse; @@ -32,10 +36,12 @@ import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "updateVirtualMachine", description = "Updates properties of a virtual machine. The VM has to be stopped and restarted for the " - + "new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. " - + "Therefore, stop the VM manually before issuing this call.", responseObject = UserVmResponse.class) +@APICommand(name = "updateVirtualMachine", description="Updates properties of a virtual machine. The VM has to be stopped and restarted for the " + + "new properties to take effect. UpdateVirtualMachine does not first check whether the VM is stopped. " + + "Therefore, stop the VM manually before issuing this call.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class UpdateVMCmd extends BaseCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateVMCmd.class.getName()); private static final String s_name = "updatevirtualmachineresponse"; @@ -53,7 +59,9 @@ public class UpdateVMCmd extends BaseCustomIdCmd { @Parameter(name = ApiConstants.HA_ENABLE, type = CommandType.BOOLEAN, description = "true if high-availability is enabled for the virtual machine, false otherwise") private Boolean haEnable; - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="The ID of the virtual machine") private Long id; @Parameter(name = ApiConstants.OS_TYPE_ID, @@ -68,7 +76,7 @@ public class UpdateVMCmd extends BaseCustomIdCmd { length = 32768) private String userData; - @Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vm to the end user or not.") + @Parameter(name = ApiConstants.DISPLAY_VM, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vm to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayVm; @Parameter(name = ApiConstants.IS_DYNAMICALLY_SCALABLE, @@ -76,6 +84,9 @@ public class UpdateVMCmd extends BaseCustomIdCmd { description = "true if VM contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory") protected Boolean isDynamicallyScalable; + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "new host name of the vm. The VM has to be stopped/started for this update to take affect", since = "4.4") + private String name; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -108,6 +119,10 @@ public class UpdateVMCmd extends BaseCustomIdCmd { return isDynamicallyScalable; } + public String getHostName() { + return name; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -135,16 +150,34 @@ public class UpdateVMCmd extends BaseCustomIdCmd { return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked } + @Override + public boolean isDisplayResourceEnabled(){ + UserVm userVm = _entityMgr.findById(UserVm.class, getId()); + if (userVm != null) { + return userVm.isDisplayVm(); + } + + return true; // no info means true + } + @Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException { CallContext.current().setEventDetails("Vm Id: " + getId()); UserVm result = _userVmService.updateVirtualMachine(this); - if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm"); } } + + @Override + public void checkUuid() { + if (getCustomId() != null) { + _uuidMgr.checkUuid(getCustomId(), UserVm.class); + + } + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java index 12ab711afce..1923198eb5d 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java @@ -21,25 +21,32 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.ServiceOfferingResponse; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceAllocationException; import com.cloud.offering.ServiceOffering; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "changeServiceForVirtualMachine", responseObject = UserVmResponse.class, description = "Changes the service offering for a virtual machine. " - + "The virtual machine must be in a \"Stopped\" state for " + "this command to take effect.") +@APICommand(name = "changeServiceForVirtualMachine", responseObject=UserVmResponse.class, description="Changes the service offering for a virtual machine. " + + "The virtual machine must be in a \"Stopped\" state for " + + "this command to take effect.", responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class UpgradeVMCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(UpgradeVMCmd.class.getName()); private static final String s_name = "changeserviceforvirtualmachineresponse"; @@ -48,11 +55,14 @@ public class UpgradeVMCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = UserVmResponse.class, required = true, description = "The ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description="The ID of the virtual machine") private Long id; - @Parameter(name = ApiConstants.SERVICE_OFFERING_ID, type = CommandType.UUID, entityType = ServiceOfferingResponse.class, required = true, description = "the service offering ID to apply to the virtual machine") - private Long serviceOfferingId; + @Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.UUID, entityType=ServiceOfferingResponse.class, + required=true, description="the service offering ID to apply to the virtual machine") + protected Long serviceOfferingId; @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "name value pairs of custom parameters for cpu, memory and cpunumber. example details[i].name=value") private Map details; @@ -107,6 +117,11 @@ public class UpgradeVMCmd extends BaseCmd { return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked } + @Override + public boolean isDisplayResourceEnabled(){ + return _userVmService.isDisplayResourceEnabled(getId()); + } + @Override public void execute() throws ResourceAllocationException { CallContext.current().setEventDetails("Vm Id: " + getId()); @@ -117,8 +132,9 @@ public class UpgradeVMCmd extends BaseCmd { } UserVm result = _userVmService.upgradeVirtualMachine(this); - if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + + if (result != null){ + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", result).get(0); response.setResponseName(getCommandName()); setResponseObject(response); } else { diff --git a/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java index 937fca381a8..6947f150594 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmgroup/CreateVMGroupCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.vm.InstanceGroup; -@APICommand(name = "createInstanceGroup", description = "Creates a vm group", responseObject = InstanceGroupResponse.class) +@APICommand(name = "createInstanceGroup", description = "Creates a vm group", responseObject = InstanceGroupResponse.class, entityType = {InstanceGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVMGroupCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateVMGroupCmd.class.getName()); @@ -89,7 +90,7 @@ public class CreateVMGroupCmd extends BaseCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -103,7 +104,7 @@ public class CreateVMGroupCmd extends BaseCmd { if (result != null) { InstanceGroupResponse response = _responseGenerator.createInstanceGroupResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vm instance group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vmgroup/DeleteVMGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmgroup/DeleteVMGroupCmd.java index fbfb85a86c0..8311eccf99e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmgroup/DeleteVMGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmgroup/DeleteVMGroupCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.vmgroup; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -30,7 +32,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.user.Account; import com.cloud.vm.InstanceGroup; -@APICommand(name = "deleteInstanceGroup", description = "Deletes a vm group", responseObject = SuccessResponse.class) +@APICommand(name = "deleteInstanceGroup", description = "Deletes a vm group", responseObject = SuccessResponse.class, entityType = {InstanceGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVMGroupCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteVMGroupCmd.class.getName()); private static final String s_name = "deleteinstancegroupresponse"; @@ -39,6 +42,7 @@ public class DeleteVMGroupCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = InstanceGroupResponse.class, required = true, description = "the ID of the instance group") private Long id; @@ -74,7 +78,7 @@ public class DeleteVMGroupCmd extends BaseCmd { boolean result = _userVmService.deleteVmGroup(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete vm group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vmgroup/ListVMGroupsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmgroup/ListVMGroupsCmd.java index fda3e884365..73fdb8aa18a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmgroup/ListVMGroupsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmgroup/ListVMGroupsCmd.java @@ -25,7 +25,10 @@ import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.InstanceGroupResponse; import org.apache.cloudstack.api.response.ListResponse; -@APICommand(name = "listInstanceGroups", description = "Lists vm groups", responseObject = InstanceGroupResponse.class) +import com.cloud.vm.InstanceGroup; + +@APICommand(name = "listInstanceGroups", description = "Lists vm groups", responseObject = InstanceGroupResponse.class, entityType = {InstanceGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVMGroupsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListVMGroupsCmd.class.getName()); @@ -66,6 +69,6 @@ public class ListVMGroupsCmd extends BaseListProjectAndAccountResourcesCmd { public void execute() { ListResponse response = _queryService.searchForVmGroups(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vmgroup/UpdateVMGroupCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmgroup/UpdateVMGroupCmd.java index 1930bd837e6..befa46c9ce7 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmgroup/UpdateVMGroupCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmgroup/UpdateVMGroupCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.vmgroup; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -29,7 +31,8 @@ import org.apache.cloudstack.api.response.InstanceGroupResponse; import com.cloud.user.Account; import com.cloud.vm.InstanceGroup; -@APICommand(name = "updateInstanceGroup", description = "Updates a vm group", responseObject = InstanceGroupResponse.class) +@APICommand(name = "updateInstanceGroup", description = "Updates a vm group", responseObject = InstanceGroupResponse.class, entityType = {InstanceGroup.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateVMGroupCmd extends BaseCmd { private static final String s_name = "updateinstancegroupresponse"; @@ -38,7 +41,7 @@ public class UpdateVMGroupCmd extends BaseCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = InstanceGroupResponse.class, required = true, description = "Instance group ID") private Long id; @@ -82,7 +85,7 @@ public class UpdateVMGroupCmd extends BaseCmd { if (result != null) { InstanceGroupResponse response = _responseGenerator.createInstanceGroupResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update vm instance group"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java index de921f61979..1310ba5b759 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/CreateVMSnapshotCmd.java @@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.user.vmsnapshot; import java.util.logging.Logger; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -34,12 +35,14 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.uservm.UserVm; import com.cloud.vm.snapshot.VMSnapshot; -@APICommand(name = "createVMSnapshot", description = "Creates snapshot for a vm.", responseObject = VMSnapshotResponse.class, since = "4.2.0") +@APICommand(name = "createVMSnapshot", description = "Creates snapshot for a vm.", responseObject = VMSnapshotResponse.class, since = "4.2.0", entityType = {VMSnapshot.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateVMSnapshotCmd.class.getName()); private static final String s_name = "createvmsnapshotresponse"; + @ACL @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, required = true, entityType = UserVmResponse.class, description = "The ID of the vm") private Long vmId; @@ -87,7 +90,7 @@ public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd { public void create() throws ResourceAllocationException { VMSnapshot vmsnapshot = _vmSnapshotService.allocVMSnapshot(getVmId(), getDisplayName(), getDescription(), snapshotMemory()); if (vmsnapshot != null) { - this.setEntityId(vmsnapshot.getId()); + setEntityId(vmsnapshot.getId()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vm snapshot"); } @@ -110,7 +113,7 @@ public class CreateVMSnapshotCmd extends BaseAsyncCreateCmd { if (result != null) { VMSnapshotResponse response = _responseGenerator.createVMSnapshotResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create vm snapshot due to an internal error creating snapshot for vm " + getVmId()); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java index d29ff051251..7baad7cd599 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/DeleteVMSnapshotCmd.java @@ -19,6 +19,8 @@ package org.apache.cloudstack.api.command.user.vmsnapshot; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -33,11 +35,13 @@ import com.cloud.event.EventTypes; import com.cloud.user.Account; import com.cloud.vm.snapshot.VMSnapshot; -@APICommand(name = "deleteVMSnapshot", description = "Deletes a vmsnapshot.", responseObject = SuccessResponse.class, since = "4.2.0") +@APICommand(name = "deleteVMSnapshot", description = "Deletes a vmsnapshot.", responseObject = SuccessResponse.class, since = "4.2.0", entityType = {VMSnapshot.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVMSnapshotCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteVMSnapshotCmd.class.getName()); private static final String s_name = "deletevmsnapshotresponse"; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.VM_SNAPSHOT_ID, type = CommandType.UUID, entityType = VMSnapshotResponse.class, @@ -69,7 +73,7 @@ public class DeleteVMSnapshotCmd extends BaseAsyncCmd { boolean result = _vmSnapshotService.deleteVMSnapshot(getId()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete vm snapshot"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java index 84b552c1d97..c9bc2430d26 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/ListVMSnapshotCmd.java @@ -30,7 +30,8 @@ import org.apache.cloudstack.api.response.VMSnapshotResponse; import com.cloud.vm.snapshot.VMSnapshot; -@APICommand(name = "listVMSnapshot", description = "List virtual machine snapshot by conditions", responseObject = VMSnapshotResponse.class, since = "4.2.0") +@APICommand(name = "listVMSnapshot", description = "List virtual machine snapshot by conditions", responseObject = VMSnapshotResponse.class, since = "4.2.0", entityType = {VMSnapshot.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVMSnapshotCmd extends BaseListTaggedResourcesCmd { private static final String s_name = "listvmsnapshotresponse"; @@ -75,7 +76,7 @@ public class ListVMSnapshotCmd extends BaseListTaggedResourcesCmd { } response.setResponses(snapshotResponses); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java index cec2154596a..0ca500962b3 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vmsnapshot/RevertToVMSnapshotCmd.java @@ -18,11 +18,14 @@ package org.apache.cloudstack.api.command.user.vmsnapshot; import java.util.logging.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.VMSnapshotResponse; @@ -37,11 +40,13 @@ import com.cloud.user.Account; import com.cloud.uservm.UserVm; import com.cloud.vm.snapshot.VMSnapshot; -@APICommand(name = "revertToVMSnapshot", description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class, since = "4.2.0") +@APICommand(name = "revertToVMSnapshot", description = "Revert VM from a vmsnapshot.", responseObject = UserVmResponse.class, since = "4.2.0", responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = true) public class RevertToVMSnapshotCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RevertToVMSnapshotCmd.class.getName()); private static final String s_name = "reverttovmsnapshotresponse"; + @ACL(accessType = AccessType.OperateEntry, pointerToEntity = "getVmId()") @Parameter(name = ApiConstants.VM_SNAPSHOT_ID, type = CommandType.UUID, required = true, @@ -68,13 +73,14 @@ public class RevertToVMSnapshotCmd extends BaseAsyncCmd { } @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException, ConcurrentOperationException { + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException, ConcurrentOperationException { CallContext.current().setEventDetails("vmsnapshot id: " + getVmSnapShotId()); UserVm result = _vmSnapshotService.revertToSnapshot(getVmSnapShotId()); if (result != null) { - UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0); + UserVmResponse response = _responseGenerator.createUserVmResponse(ResponseView.Restricted, + "virtualmachine", result).get(0); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revert VM snapshot"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java index 618be7f3958..d53059ed152 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/AddResourceDetailCmd.java @@ -31,7 +31,8 @@ import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.server.ResourceTag; -@APICommand(name = "addResourceDetail", description = "Adds detail for the Resource.", responseObject = SuccessResponse.class) +@APICommand(name = "addResourceDetail", description = "Adds detail for the Resource.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddResourceDetailCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(AddResourceDetailCmd.class.getName()); private static final String s_name = "addresourcedetailresponse"; @@ -49,6 +50,9 @@ public class AddResourceDetailCmd extends BaseAsyncCmd { @Parameter(name = ApiConstants.RESOURCE_ID, type = CommandType.STRING, required = true, collectionType = CommandType.STRING, description = "resource id to create the details for") private String resourceId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "pass false if you want this detail to be disabled for the regular user. True by default", since = "4.4") + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -77,6 +81,14 @@ public class AddResourceDetailCmd extends BaseAsyncCmd { return resourceId; } + public boolean forDisplay() { + if (display != null) { + return display; + } else { + return true; + } + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -104,7 +116,7 @@ public class AddResourceDetailCmd extends BaseAsyncCmd { @Override public void execute() { - _resourceMetaDataService.addResourceMetaData(getResourceId(), getResourceType(), getDetails()); + _resourceMetaDataService.addResourceMetaData(getResourceId(), getResourceType(), getDetails(), forDisplay()); setResponseObject(new SuccessResponse(getCommandName())); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java index cd1e1ed64bc..bce4027c7dc 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java @@ -18,12 +18,15 @@ package org.apache.cloudstack.api.command.user.volume; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVolumeCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.VolumeResponse; @@ -32,9 +35,11 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.storage.Volume; import com.cloud.user.Account; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "attachVolume", description = "Attaches a disk volume to a virtual machine.", responseObject = VolumeResponse.class) -public class AttachVolumeCmd extends BaseAsyncCmd { +@APICommand(name = "attachVolume", description = "Attaches a disk volume to a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class AttachVolumeCmd extends BaseAsyncVolumeCmd { public static final Logger s_logger = Logger.getLogger(AttachVolumeCmd.class.getName()); private static final String s_name = "attachvolumeresponse"; @@ -43,18 +48,16 @@ public class AttachVolumeCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// @Parameter(name = ApiConstants.DEVICE_ID, type = CommandType.LONG, description = "the ID of the device to map the volume to within the guest OS. " - + "If no deviceId is passed in, the next available deviceId will be chosen. " + "Possible values for a Linux OS are:" + "* 1 - /dev/xvdb" + "* 2 - /dev/xvdc" + + "If no deviceId is passed in, the next available deviceId will be chosen. " + "Possible values for a Linux OS are:" + "* 0 - /dev/xvda" + "* 1 - /dev/xvdb" + "* 2 - /dev/xvdc" + "* 4 - /dev/xvde" + "* 5 - /dev/xvdf" + "* 6 - /dev/xvdg" + "* 7 - /dev/xvdh" + "* 8 - /dev/xvdi" + "* 9 - /dev/xvdj") private Long deviceId; @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VolumeResponse.class, required = true, description = "the ID of the disk volume") private Long id; - @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, - type = CommandType.UUID, - entityType = UserVmResponse.class, - required = true, - description = " the ID of the virtual machine") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType=UserVmResponse.class, + required=true, description=" the ID of the virtual machine") private Long virtualMachineId; ///////////////////////////////////////////////////// @@ -65,6 +68,7 @@ public class AttachVolumeCmd extends BaseAsyncCmd { return deviceId; } + @Override public Long getId() { return id; } @@ -108,7 +112,7 @@ public class AttachVolumeCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "attaching volume: " + getId() + " to vm: " + getVirtualMachineId(); + return "attaching volume: " + getId() + " to vm: " + getVirtualMachineId(); } @Override @@ -116,9 +120,9 @@ public class AttachVolumeCmd extends BaseAsyncCmd { CallContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId()); Volume result = _volumeService.attachVolumeToVM(this); if (result != null) { - VolumeResponse response = _responseGenerator.createVolumeResponse(result); + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach volume"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java index c6457c60eb3..2a651599b56 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java @@ -16,15 +16,18 @@ // under the License. package org.apache.cloudstack.api.command.user.volume; -import org.apache.cloudstack.api.BaseAsyncCreateCustomIdCmd; -import org.apache.cloudstack.api.BaseCmd; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseAsyncCreateCustomIdCmd; +import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DiskOfferingResponse; import org.apache.cloudstack.api.response.DomainResponse; @@ -40,9 +43,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.storage.Snapshot; import com.cloud.storage.Volume; -@APICommand(name = "createVolume", - responseObject = VolumeResponse.class, - description = "Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.") +@APICommand(name = "createVolume", responseObject = VolumeResponse.class, description = "Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.", responseView = ResponseView.Restricted, entityType = {Volume.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd { public static final Logger s_logger = Logger.getLogger(CreateVolumeCmd.class.getName()); private static final String s_name = "createvolumeresponse"; @@ -88,6 +90,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd { @Parameter(name = ApiConstants.MAX_IOPS, type = CommandType.LONG, description = "max iops") private Long maxIops; + @ACL @Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.UUID, entityType = SnapshotResponse.class, @@ -97,9 +100,10 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd { @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the ID of the availability zone") private Long zoneId; - @Parameter(name = ApiConstants.DISPLAY_VOLUME, type = CommandType.BOOLEAN, description = "an optional field, whether to display the volume to the end user or not.") + @Parameter(name = ApiConstants.DISPLAY_VOLUME, type = CommandType.BOOLEAN, description = "an optional field, whether to display the volume to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayVolume; + @ACL @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, @@ -177,7 +181,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -190,18 +194,28 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd { return EventTypes.EVENT_VOLUME_CREATE; } + @Override + public boolean isDisplayResourceEnabled(){ + Boolean display = getDisplayVolume(); + if(display == null){ + return true; + } else { + return display; + } + } + @Override public String getEventDescription() { - return "creating volume: " + getVolumeName() + ((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()); + return "creating volume: " + getVolumeName() + ((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()); } @Override public void create() throws ResourceAllocationException { - Volume volume = this._volumeService.allocVolume(this); + Volume volume = _volumeService.allocVolume(this); if (volume != null) { - this.setEntityId(volume.getId()); - this.setEntityUuid(volume.getUuid()); + setEntityId(volume.getId()); + setEntityUuid(volume.getUuid()); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create volume"); } @@ -212,7 +226,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd { CallContext.current().setEventDetails("Volume Id: " + getEntityId() + ((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId())); Volume volume = _volumeService.createVolume(this); if (volume != null) { - VolumeResponse response = _responseGenerator.createVolumeResponse(volume); + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume); //FIXME - have to be moved to ApiResponseHelper if (getSnapshotId() != null) { Snapshot snap = _entityMgr.findById(Snapshot.class, getSnapshotId()); @@ -227,7 +241,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCustomIdCmd { } } response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a volume"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java index 550adb9e524..02b80d983da 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java @@ -15,9 +15,10 @@ // specific language governing permissions and limitations // under the License. package org.apache.cloudstack.api.command.user.volume; - import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -32,7 +33,8 @@ import com.cloud.exception.ConcurrentOperationException; import com.cloud.storage.Volume; import com.cloud.user.Account; -@APICommand(name = "deleteVolume", description = "Deletes a detached disk volume.", responseObject = SuccessResponse.class) +@APICommand(name = "deleteVolume", description = "Deletes a detached disk volume.", responseObject = SuccessResponse.class, entityType = {Volume.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVolumeCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteVolumeCmd.class.getName()); private static final String s_name = "deletevolumeresponse"; @@ -41,7 +43,9 @@ public class DeleteVolumeCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VolumeResponse.class, required = true, description = "The ID of the disk volume") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VolumeResponse.class, + required=true, description="The ID of the disk volume") private Long id; ///////////////////////////////////////////////////// @@ -75,13 +79,18 @@ public class DeleteVolumeCmd extends BaseCmd { return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked } + @Override + public boolean isDisplayResourceEnabled(){ + return _volumeService.isDisplayResourceEnabled(getId()); + } + @Override public void execute() throws ConcurrentOperationException { CallContext.current().setEventDetails("Volume Id: " + getId()); - boolean result = this._volumeService.deleteVolume(id, CallContext.current().getCallingAccount()); + boolean result = _volumeService.deleteVolume(id, CallContext.current().getCallingAccount()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete volume"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java index 70283ff6679..270931c261b 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java @@ -18,12 +18,15 @@ package org.apache.cloudstack.api.command.user.volume; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVolumeCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.VolumeResponse; @@ -33,9 +36,11 @@ import com.cloud.event.EventTypes; import com.cloud.storage.Volume; import com.cloud.user.Account; import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; -@APICommand(name = "detachVolume", description = "Detaches a disk volume from a virtual machine.", responseObject = VolumeResponse.class) -public class DetachVolumeCmd extends BaseAsyncCmd { +@APICommand(name = "detachVolume", description = "Detaches a disk volume from a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class DetachVolumeCmd extends BaseAsyncVolumeCmd { public static final Logger s_logger = Logger.getLogger(DetachVolumeCmd.class.getName()); private static final String s_name = "detachvolumeresponse"; @@ -43,12 +48,14 @@ public class DetachVolumeCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VolumeResponse.class, description = "the ID of the disk volume") + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VolumeResponse.class, + description="the ID of the disk volume") private Long id; @Parameter(name = ApiConstants.DEVICE_ID, type = CommandType.LONG, description = "the device ID on the virtual machine where volume is detached from") private Long deviceId; + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, @@ -59,6 +66,7 @@ public class DetachVolumeCmd extends BaseAsyncCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + @Override public Long getId() { return id; } @@ -128,17 +136,17 @@ public class DetachVolumeCmd extends BaseAsyncCmd { } else { sb.append(" "); } - return "detaching volume" + sb.toString(); + return "detaching volume" + sb.toString(); } @Override public void execute() { CallContext.current().setEventDetails("Volume Id: " + getId() + " VmId: " + getVirtualMachineId()); Volume result = _volumeService.detachVolumeFromVM(this); - if (result != null) { - VolumeResponse response = _responseGenerator.createVolumeResponse(result); + if (result != null){ + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result); response.setResponseName("volume"); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach volume"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java index d73143a112e..d560fc2e897 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java @@ -18,11 +18,13 @@ package org.apache.cloudstack.api.command.user.volume; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVolumeCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.ExtractResponse; @@ -36,8 +38,9 @@ import com.cloud.storage.Upload; import com.cloud.storage.Volume; import com.cloud.user.Account; -@APICommand(name = "extractVolume", description = "Extracts volume", responseObject = ExtractResponse.class) -public class ExtractVolumeCmd extends BaseAsyncCmd { +@APICommand(name = "extractVolume", description = "Extracts volume", responseObject = ExtractResponse.class, entityType = {Volume.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class ExtractVolumeCmd extends BaseAsyncVolumeCmd { public static final Logger s_logger = Logger.getLogger(ExtractVolumeCmd.class.getName()); private static final String s_name = "extractvolumeresponse"; @@ -46,7 +49,9 @@ public class ExtractVolumeCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VolumeResponse.class, required = true, description = "the ID of the volume") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VolumeResponse.class, + required=true, description="the ID of the volume") private Long id; @Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = false, description = "the url to which the volume would be extracted") @@ -66,6 +71,7 @@ public class ExtractVolumeCmd extends BaseAsyncCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + @Override public Long getId() { return id; } @@ -123,7 +129,7 @@ public class ExtractVolumeCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "Extraction job"; + return "Extraction job"; } @Override @@ -145,7 +151,7 @@ public class ExtractVolumeCmd extends BaseAsyncCmd { Account account = _entityMgr.findById(Account.class, getEntityOwnerId()); response.setAccountId(account.getUuid()); response.setUrl(uploadUrl); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to extract volume"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ListResourceDetailsCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ListResourceDetailsCmd.java index aed0ae02f63..0aeff0c63ce 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/ListResourceDetailsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/ListResourceDetailsCmd.java @@ -30,14 +30,15 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.server.ResourceTag; -@APICommand(name = "listResourceDetails", description = "List resource detail(s)", responseObject = ResourceTagResponse.class, since = "4.2") +@APICommand(name = "listResourceDetails", description = "List resource detail(s)", responseObject = ResourceTagResponse.class, since = "4.2", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListResourceDetailsCmd extends BaseListProjectAndAccountResourcesCmd { private static final String s_name = "listresourcedetailsresponse"; @Parameter(name = ApiConstants.RESOURCE_TYPE, type = CommandType.STRING, description = "list by resource type", required = true) private String resourceType; - @Parameter(name = ApiConstants.RESOURCE_ID, type = CommandType.STRING, description = "list by resource id", required = true) + @Parameter(name = ApiConstants.RESOURCE_ID, type = CommandType.STRING, description = "list by resource id") private String resourceId; @Parameter(name = ApiConstants.KEY, type = CommandType.STRING, description = "list by key") diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java index 4ebe3bf5065..cc218f71972 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java @@ -24,6 +24,8 @@ import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.response.DiskOfferingResponse; import org.apache.cloudstack.api.response.HostResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.PodResponse; @@ -32,7 +34,10 @@ import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.VolumeResponse; import org.apache.cloudstack.api.response.ZoneResponse; -@APICommand(name = "listVolumes", description = "Lists all volumes.", responseObject = VolumeResponse.class) +import com.cloud.storage.Volume; + +@APICommand(name = "listVolumes", description = "Lists all volumes.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {Volume.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVolumesCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListVolumesCmd.class.getName()); @@ -71,6 +76,16 @@ public class ListVolumesCmd extends BaseListTaggedResourcesCmd { authorized = {RoleType.Admin}) private Long storageId; + @Parameter(name = ApiConstants.DISK_OFFERING_ID, + type = CommandType.UUID, + entityType = DiskOfferingResponse.class, + description = "list volumes by disk offering", + since = "4.4") + private Long diskOfferingId; + + @Parameter(name = ApiConstants.DISPLAY_VOLUME, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -91,6 +106,10 @@ public class ListVolumesCmd extends BaseListTaggedResourcesCmd { return podId; } + public Long getDiskOfferingId() { + return diskOfferingId; + } + public String getType() { return type; } @@ -107,6 +126,13 @@ public class ListVolumesCmd extends BaseListTaggedResourcesCmd { return storageId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -125,6 +151,6 @@ public class ListVolumesCmd extends BaseListTaggedResourcesCmd { public void execute() { ListResponse response = _queryService.searchForVolumes(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java index fa6ac6948f6..3cfcdc831a9 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java @@ -19,8 +19,9 @@ package org.apache.cloudstack.api.command.user.volume; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVolumeCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.StoragePoolResponse; import org.apache.cloudstack.api.response.VolumeResponse; @@ -29,11 +30,12 @@ import com.cloud.event.EventTypes; import com.cloud.storage.Volume; import com.cloud.user.Account; -@APICommand(name = "migrateVolume", description = "Migrate volume", responseObject = VolumeResponse.class, since = "3.0.0") -public class MigrateVolumeCmd extends BaseAsyncCmd { +@APICommand(name = "migrateVolume", description = "Migrate volume", responseObject = VolumeResponse.class, since = "3.0.0", responseView = ResponseView.Restricted, entityType = {Volume.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class MigrateVolumeCmd extends BaseAsyncVolumeCmd { private static final String s_name = "migratevolumeresponse"; - ///////////////////////////////////////////////////// + ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// @@ -57,10 +59,16 @@ public class MigrateVolumeCmd extends BaseAsyncCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + // TODO remove this in 5.0 and use id as param instead. public Long getVolumeId() { return volumeId; } + @Override + public Long getId() { + return getVolumeId(); + } + public Long getStoragePoolId() { return storageId; } @@ -80,12 +88,12 @@ public class MigrateVolumeCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { - Volume volume = _entityMgr.findById(Volume.class, getVolumeId()); - if (volume != null) { - return volume.getAccountId(); - } + Volume volume = _entityMgr.findById(Volume.class, getVolumeId()); + if (volume != null) { + return volume.getAccountId(); + } - return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked + return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked } @Override @@ -104,9 +112,9 @@ public class MigrateVolumeCmd extends BaseAsyncCmd { result = _volumeService.migrateVolume(this); if (result != null) { - VolumeResponse response = _responseGenerator.createVolumeResponse(result); + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate volume"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/RemoveResourceDetailCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/RemoveResourceDetailCmd.java index c4c7554dbdb..6fe576dc63c 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/RemoveResourceDetailCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/RemoveResourceDetailCmd.java @@ -28,7 +28,8 @@ import org.apache.cloudstack.api.response.SuccessResponse; import com.cloud.event.EventTypes; import com.cloud.server.ResourceTag; -@APICommand(name = "removeResourceDetail", description = "Removes detail for the Resource.", responseObject = SuccessResponse.class) +@APICommand(name = "removeResourceDetail", description = "Removes detail for the Resource.", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RemoveResourceDetailCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RemoveResourceDetailCmd.class.getName()); private static final String s_name = "removeresourcedetailresponse"; diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java index 0cc8039200d..dd887ac5add 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java @@ -15,15 +15,17 @@ // specific language governing permissions and limitations // under the License. package org.apache.cloudstack.api.command.user.volume; - import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncVolumeCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DiskOfferingResponse; import org.apache.cloudstack.api.response.VolumeResponse; @@ -37,8 +39,10 @@ import com.cloud.projects.Project; import com.cloud.storage.Volume; import com.cloud.user.Account; -@APICommand(name = "resizeVolume", description = "Resizes a volume", responseObject = VolumeResponse.class) -public class ResizeVolumeCmd extends BaseAsyncCmd { + +@APICommand(name = "resizeVolume", description = "Resizes a volume", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {Volume.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class ResizeVolumeCmd extends BaseAsyncVolumeCmd { public static final Logger s_logger = Logger.getLogger(ResizeVolumeCmd.class.getName()); private static final String s_name = "resizevolumeresponse"; @@ -47,7 +51,8 @@ public class ResizeVolumeCmd extends BaseAsyncCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, entityType = VolumeResponse.class, type = CommandType.UUID, description = "the ID of the disk volume") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name = ApiConstants.ID, entityType = VolumeResponse.class, required = true, type = CommandType.UUID, description = "the ID of the disk volume") private Long id; @Parameter(name = ApiConstants.SIZE, type = CommandType.LONG, required = false, description = "New volume size in G") @@ -67,10 +72,16 @@ public class ResizeVolumeCmd extends BaseAsyncCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + //TODO use the method getId() instead of this one. public Long getEntityId() { return id; } + @Override + public Long getId() { + return getEntityId(); + } + public Long getSize() { return size; } @@ -101,18 +112,18 @@ public class ResizeVolumeCmd extends BaseAsyncCmd { return "volume"; } - @Override + @Override public long getEntityOwnerId() { Volume volume = _entityMgr.findById(Volume.class, getEntityId()); if (volume == null) { - throw new InvalidParameterValueException("Unable to find volume by id=" + id); + throw new InvalidParameterValueException("Unable to find volume by id=" + id); } Account account = _accountService.getAccount(volume.getAccountId()); //Can resize volumes for enabled projects/accounts only if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) { - Project project = _projectService.findByProjectAccountId(volume.getAccountId()); + Project project = _projectService.findByProjectAccountId(volume.getAccountId()); if (project.getState() != Project.State.Active) { throw new PermissionDeniedException("Can't add resources to project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active"); @@ -139,10 +150,10 @@ public class ResizeVolumeCmd extends BaseAsyncCmd { CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G"); Volume volume = _volumeService.resizeVolume(this); if (volume != null) { - VolumeResponse response = _responseGenerator.createVolumeResponse(volume); + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume); //FIXME - have to be moved to ApiResponseHelper response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to resize volume"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java index b57f2b489d6..3ad6f47d271 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java @@ -18,12 +18,16 @@ package org.apache.cloudstack.api.command.user.volume; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.StoragePoolResponse; import org.apache.cloudstack.api.response.VolumeResponse; @@ -33,7 +37,8 @@ import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; import com.cloud.storage.Volume; -@APICommand(name = "updateVolume", description = "Updates the volume.", responseObject = VolumeResponse.class) +@APICommand(name = "updateVolume", description = "Updates the volume.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {Volume.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateVolumeCmd.class.getName()); private static final String s_name = "updatevolumeresponse"; @@ -42,12 +47,19 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VolumeResponse.class, description = "the ID of the disk volume") + @ACL(accessType = AccessType.OperateEntry) + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VolumeResponse.class, description="the ID of the disk volume") private Long id; @Parameter(name = ApiConstants.PATH, type = CommandType.STRING, description = "The path of the volume") private String path; + @Parameter(name = ApiConstants.CHAIN_INFO, + type = CommandType.STRING, + description = "The chain info of the volume", + since = "4.4") + private String chainInfo; + @Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.UUID, entityType = StoragePoolResponse.class, @@ -60,7 +72,7 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd { @Parameter(name = ApiConstants.DISPLAY_VOLUME, type = CommandType.BOOLEAN, - description = "an optional field, whether to the display the volume to the end user or not.") + description = "an optional field, whether to the display the volume to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayVolume; ///////////////////////////////////////////////////// @@ -87,7 +99,10 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd { return displayVolume; } -///////////////////////////////////////////////////// + public String getChainInfo() { + return chainInfo; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -115,6 +130,11 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd { return volume.getAccountId(); } + @Override + public boolean isDisplayResourceEnabled(){ + return _volumeService.isDisplayResourceEnabled(getId()); + } + @Override public String getEventType() { return EventTypes.EVENT_VOLUME_UPDATE; @@ -140,13 +160,22 @@ public class UpdateVolumeCmd extends BaseAsyncCustomIdCmd { @Override public void execute() { CallContext.current().setEventDetails("Volume Id: " + getId()); - Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume(), getCustomId(), getEntityOwnerId()); + Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume(), + getCustomId(), getEntityOwnerId(), getChainInfo()); if (result != null) { - VolumeResponse response = _responseGenerator.createVolumeResponse(result); + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update volume"); } } + + @Override + public void checkUuid() { + if (getCustomId() != null) { + _uuidMgr.checkUuid(getCustomId(), Volume.class); + } + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java index 991cfc1bd37..7a08abf2766 100644 --- a/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java @@ -23,6 +23,7 @@ import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ProjectResponse; @@ -38,7 +39,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.storage.Volume; -@APICommand(name = "uploadVolume", description = "Uploads a data disk.", responseObject = VolumeResponse.class) +@APICommand(name = "uploadVolume", description = "Uploads a data disk.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted, entityType = {Volume.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UploadVolumeCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UploadVolumeCmd.class.getName()); private static final String s_name = "uploadvolumeresponse"; @@ -120,7 +122,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd { } public String getImageStoreUuid() { - return this.imageStoreUuid; + return imageStoreUuid; } ///////////////////////////////////////////////////// @@ -131,24 +133,24 @@ public class UploadVolumeCmd extends BaseAsyncCmd { public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { - Volume volume = _volumeService.uploadVolume(this); - if (volume != null) { - VolumeResponse response = _responseGenerator.createVolumeResponse(volume); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload volume"); - } + Volume volume = _volumeService.uploadVolume(this); + if (volume != null){ + VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume); + response.setResponseName(getCommandName()); + setResponseObject(response); + } else { + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload volume"); + } } @Override public String getCommandName() { - return s_name; + return s_name; } @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -158,7 +160,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd { @Override public String getEventDescription() { - return "uploading volume: " + getVolumeName() + " in the zone " + getZoneId(); + return "uploading volume: " + getVolumeName() + " in the zone " + getZoneId(); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java index f2d2bce4990..e2f2029ce0a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateStaticRouteCmd.java @@ -39,7 +39,8 @@ import com.cloud.network.vpc.StaticRoute; import com.cloud.network.vpc.Vpc; import com.cloud.network.vpc.VpcGateway; -@APICommand(name = "createStaticRoute", description = "Creates a static route", responseObject = StaticRouteResponse.class) +@APICommand(name = "createStaticRoute", description = "Creates a static route", responseObject = StaticRouteResponse.class, entityType = {StaticRoute.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateStaticRouteCmd extends BaseAsyncCreateCmd { private static final String s_name = "createstaticrouteresponse"; public static final Logger s_logger = Logger.getLogger(CreateStaticRouteCmd.class.getName()); diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java index d4c52b8e42a..e2f261e1ba3 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/CreateVPCCmd.java @@ -16,11 +16,15 @@ // under the License. package org.apache.cloudstack.api.command.user.vpc; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCreateCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ProjectResponse; @@ -28,7 +32,6 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse; import org.apache.cloudstack.api.response.VpcResponse; import org.apache.cloudstack.api.response.ZoneResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; @@ -37,7 +40,8 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.vpc.Vpc; -@APICommand(name = "createVPC", description = "Creates a VPC", responseObject = VpcResponse.class) +@APICommand(name = "createVPC", description = "Creates a VPC", responseObject = VpcResponse.class, responseView = ResponseView.Restricted, entityType = {Vpc.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVPCCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateVPCCmd.class.getName()); private static final String s_name = "createvpcresponse"; @@ -47,12 +51,12 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd { // /////////////////////////////////////////////////// @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "the account associated with the VPC. " + - "Must be used with the domainId parameter.") + "Must be used with the domainId parameter.") private String accountName; @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "the domain ID associated with the VPC. " + - "If used with the account parameter returns the VPC associated with the account for the specified domain.") + "If used with the account parameter returns the VPC associated with the account for the specified domain.") private Long domainId; @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, @@ -60,18 +64,18 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd { private Long projectId; @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, - required = true, description = "the ID of the availability zone") + required = true, description = "the ID of the availability zone") private Long zoneId; @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the VPC") private String vpcName; @Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "the display text of " + - "the VPC") + "the VPC") private String displayText; @Parameter(name = ApiConstants.CIDR, type = CommandType.STRING, required = true, description = "the cidr of the VPC. All VPC " + - "guest networks' cidrs should be within this CIDR") + "guest networks' cidrs should be within this CIDR") private String cidr; @Parameter(name = ApiConstants.VPC_OFF_ID, type = CommandType.UUID, entityType = VpcOfferingResponse.class, @@ -87,6 +91,9 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd { "True by default.", since = "4.3") private Boolean start; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpc to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -130,9 +137,13 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd { return true; } + public Boolean getDisplayVpc() { + return display; + } + @Override public void create() throws ResourceAllocationException { - Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(), getCidr(), getNetworkDomain()); + Vpc vpc = _vpcService.createVpc(getZoneId(), getVpcOffering(), getEntityOwnerId(), getVpcName(), getDisplayText(), getCidr(), getNetworkDomain(), getDisplayVpc()); if (vpc != null) { setEntityId(vpc.getId()); setEntityUuid(vpc.getUuid()); @@ -150,7 +161,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd { success = _vpcService.startVpc(getEntityId(), true); } else { s_logger.debug("Not starting VPC as " + ApiConstants.START + "=false was passed to the API"); - } + } vpc = _entityMgr.findById(Vpc.class, getEntityId()); } catch (ResourceUnavailableException ex) { s_logger.warn("Exception: ", ex); @@ -164,8 +175,8 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd { throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage()); } - if (vpc != null && success) { - VpcResponse response = _responseGenerator.createVpcResponse(vpc); + if (vpc != null) { + VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Restricted, vpc); response.setResponseName(getCommandName()); setResponseObject(response); } else { @@ -180,7 +191,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd { @Override public String getEventDescription() { - return "creating VPC. Id: " + getEntityId(); + return "creating VPC. Id: " + getEntityId(); } @Override @@ -190,7 +201,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/DeleteStaticRouteCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/DeleteStaticRouteCmd.java index 937341e5b6d..9449e6d534a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/DeleteStaticRouteCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/DeleteStaticRouteCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.vpc; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -35,7 +37,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.vpc.StaticRoute; -@APICommand(name = "deleteStaticRoute", description = "Deletes a static route", responseObject = SuccessResponse.class) +@APICommand(name = "deleteStaticRoute", description = "Deletes a static route", responseObject = SuccessResponse.class, entityType = {StaticRoute.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteStaticRouteCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteStaticRouteCmd.class.getName()); private static final String s_name = "deletestaticrouteresponse"; @@ -43,7 +46,7 @@ public class DeleteStaticRouteCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = StaticRouteResponse.class, required = true, description = "the ID of the static route") private Long id; @@ -97,7 +100,7 @@ public class DeleteStaticRouteCmd extends BaseAsyncCmd { if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete static route"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/DeleteVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/DeleteVPCCmd.java index 14f21ba7806..9d13b63e6a2 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/DeleteVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/DeleteVPCCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.vpc; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -33,7 +35,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.vpc.Vpc; import com.cloud.user.Account; -@APICommand(name = "deleteVPC", description = "Deletes a VPC", responseObject = SuccessResponse.class) +@APICommand(name = "deleteVPC", description = "Deletes a VPC", responseObject = SuccessResponse.class, entityType = {Vpc.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVPCCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteVPCCmd.class.getName()); private static final String s_name = "deletevpcresponse"; @@ -41,7 +44,7 @@ public class DeleteVPCCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VpcResponse.class, required = true, description = "the ID of the VPC") private Long id; @@ -73,7 +76,7 @@ public class DeleteVPCCmd extends BaseAsyncCmd { boolean result = _vpcService.deleteVpc(getId()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete VPC"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/ListPrivateGatewaysCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/ListPrivateGatewaysCmd.java index 7870673f4b6..a985e7633c2 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/ListPrivateGatewaysCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/ListPrivateGatewaysCmd.java @@ -30,9 +30,11 @@ import org.apache.cloudstack.api.response.PrivateGatewayResponse; import org.apache.cloudstack.api.response.VpcResponse; import com.cloud.network.vpc.PrivateGateway; +import com.cloud.network.vpc.VpcGateway; import com.cloud.utils.Pair; -@APICommand(name = "listPrivateGateways", description = "List private gateways", responseObject = PrivateGatewayResponse.class) +@APICommand(name = "listPrivateGateways", description = "List private gateways", responseObject = PrivateGatewayResponse.class, entityType = {VpcGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListPrivateGatewaysCmd.class.getName()); @@ -100,6 +102,6 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm response.setResponses(projectResponses, gateways.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/ListStaticRoutesCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/ListStaticRoutesCmd.java index 931431bc9a6..3dba84c8a72 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/ListStaticRoutesCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/ListStaticRoutesCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.VpcResponse; import com.cloud.network.vpc.StaticRoute; import com.cloud.utils.Pair; -@APICommand(name = "listStaticRoutes", description = "Lists all static routes", responseObject = StaticRouteResponse.class) +@APICommand(name = "listStaticRoutes", description = "Lists all static routes", responseObject = StaticRouteResponse.class, entityType = {StaticRoute.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd { private static final String s_name = "liststaticroutesresponse"; @@ -79,7 +80,7 @@ public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd { } response.setResponses(routeResponses, result.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java index e3d0bc606f5..e76afc92cd5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCOfferingsCmd.java @@ -30,10 +30,11 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse; import com.cloud.network.vpc.VpcOffering; -@APICommand(name = "listVPCOfferings", description = "Lists VPC offerings", responseObject = VpcOfferingResponse.class) +@APICommand(name = "listVPCOfferings", description = "Lists VPC offerings", responseObject = VpcOfferingResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVPCOfferingsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListVPCOfferingsCmd.class.getName()); - private static final String Name = "listvpcofferingsresponse"; + private static final String s_name = "listvpcofferingsresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// @@ -109,7 +110,7 @@ public class ListVPCOfferingsCmd extends BaseListCmd { @Override public String getCommandName() { - return Name; + return s_name; } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java index 45ab863dcbb..9079dff11da 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/ListVPCsCmd.java @@ -21,10 +21,12 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.VpcOfferingResponse; import org.apache.cloudstack.api.response.VpcResponse; @@ -32,7 +34,9 @@ import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.network.vpc.Vpc; -@APICommand(name = "listVPCs", description = "Lists VPCs", responseObject = VpcResponse.class) + +@APICommand(name = "listVPCs", description = "Lists VPCs", responseObject = VpcResponse.class, responseView = ResponseView.Restricted, entityType = {Vpc.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVPCsCmd extends BaseListTaggedResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListVPCsCmd.class.getName()); private static final String s_name = "listvpcsresponse"; @@ -68,6 +72,9 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd { @Parameter(name = ApiConstants.RESTART_REQUIRED, type = CommandType.BOOLEAN, description = "list VPCs by restartRequired option") private Boolean restartRequired; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -108,6 +115,14 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd { return restartRequired; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -116,18 +131,18 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd { public void execute() { List vpcs = _vpcService.listVpcs(getId(), getVpcName(), getDisplayText(), getSupportedServices(), getCidr(), getVpcOffId(), getState(), getAccountName(), getDomainId(), - this.getKeyword(), this.getStartIndex(), this.getPageSizeVal(), getZoneId(), this.isRecursive(), this.listAll(), getRestartRequired(), getTags(), - getProjectId()); + getKeyword(), getStartIndex(), getPageSizeVal(), getZoneId(), isRecursive(), listAll(), getRestartRequired(), getTags(), + getProjectId(), getDisplay()); ListResponse response = new ListResponse(); List offeringResponses = new ArrayList(); for (Vpc vpc : vpcs) { - VpcResponse offeringResponse = _responseGenerator.createVpcResponse(vpc); + VpcResponse offeringResponse = _responseGenerator.createVpcResponse(ResponseView.Restricted, vpc); offeringResponses.add(offeringResponse); } response.setResponses(offeringResponses); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/RestartVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/RestartVPCCmd.java index eb048ceea0b..84e790c3b2e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/RestartVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/RestartVPCCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.vpc; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -34,15 +36,16 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.vpc.Vpc; import com.cloud.user.Account; -@APICommand(name = "restartVPC", description = "Restarts a VPC", responseObject = VpcResponse.class) +@APICommand(name = "restartVPC", description = "Restarts a VPC", responseObject = VpcResponse.class, entityType = {Vpc.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RestartVPCCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RestartVPCCmd.class.getName()); - private static final String Name = "restartvpcresponse"; + private static final String s_name = "restartvpcresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VpcResponse.class, required = true, description = "the id of the VPC") private Long id; @@ -59,7 +62,7 @@ public class RestartVPCCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override @@ -78,7 +81,7 @@ public class RestartVPCCmd extends BaseAsyncCmd { boolean result = _vpcService.restartVpc(getId()); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to restart VPC"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java index 5732c652214..94d0e6efcd4 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpc/UpdateVPCCmd.java @@ -18,11 +18,16 @@ package org.apache.cloudstack.api.command.user.vpc; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.BaseAsyncCmd; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.VpcResponse; @@ -30,24 +35,28 @@ import com.cloud.event.EventTypes; import com.cloud.network.vpc.Vpc; import com.cloud.user.Account; -@APICommand(name = "updateVPC", description = "Updates a VPC", responseObject = VpcResponse.class) -public class UpdateVPCCmd extends BaseAsyncCmd { +@APICommand(name = "updateVPC", description = "Updates a VPC", responseObject = VpcResponse.class, responseView = ResponseView.Restricted, entityType = {Vpc.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateVPCCmd extends BaseAsyncCustomIdCmd { public static final Logger s_logger = Logger.getLogger(UpdateVPCCmd.class.getName()); - private static final String Name = "updatevpcresponse"; + private static final String s_name = "updatevpcresponse"; ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VpcResponse.class, required = true, description = "the id of the VPC") private Long id; - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the VPC", required = true) + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the VPC") private String vpcName; @Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "the display text of the VPC") private String displayText; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpc to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -64,12 +73,16 @@ public class UpdateVPCCmd extends BaseAsyncCmd { return id; } + public Boolean getDisplayVpc() { + return display; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @Override public String getCommandName() { - return Name; + return s_name; } @Override @@ -84,11 +97,11 @@ public class UpdateVPCCmd extends BaseAsyncCmd { @Override public void execute() { - Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText()); + Vpc result = _vpcService.updateVpc(getId(), getVpcName(), getDisplayText(), getCustomId(), getDisplayVpc()); if (result != null) { - VpcResponse response = _responseGenerator.createVpcResponse(result); + VpcResponse response = _responseGenerator.createVpcResponse(ResponseView.Restricted, result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update VPC"); } @@ -113,4 +126,11 @@ public class UpdateVPCCmd extends BaseAsyncCmd { public Long getSyncObjId() { return getId(); } + + @Override + public void checkUuid() { + if (getCustomId() != null) { + _uuidMgr.checkUuid(getCustomId(), Vpc.class); + } + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java index 7c581178e4d..9993102eca1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/AddVpnUserCmd.java @@ -34,7 +34,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.VpnUser; import com.cloud.user.Account; -@APICommand(name = "addVpnUser", description = "Adds vpn users", responseObject = VpnUsersResponse.class) +@APICommand(name = "addVpnUser", description = "Adds vpn users", responseObject = VpnUsersResponse.class, entityType = {VpnUser.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddVpnUserCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(AddVpnUserCmd.class.getName()); @@ -96,7 +97,7 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -135,7 +136,7 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd { vpnResponse.setResponseName(getCommandName()); vpnResponse.setObjectName("vpnuser"); - this.setResponseObject(vpnResponse); + setResponseObject(vpnResponse); } @Override diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateRemoteAccessVpnCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateRemoteAccessVpnCmd.java index 9277c498bae..2883b1999d6 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateRemoteAccessVpnCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateRemoteAccessVpnCmd.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.user.vpn; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -36,7 +37,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.IpAddress; import com.cloud.network.RemoteAccessVpn; -@APICommand(name = "createRemoteAccessVpn", description = "Creates a l2tp/ipsec remote access vpn", responseObject = RemoteAccessVpnResponse.class) +@APICommand(name = "createRemoteAccessVpn", description = "Creates a l2tp/ipsec remote access vpn", responseObject = RemoteAccessVpnResponse.class, entityType = {RemoteAccessVpn.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateRemoteAccessVpnCmd.class.getName()); @@ -74,10 +76,14 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd { description = "if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default") private Boolean openFirewall; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + public Long getPublicIpId() { return publicIpId; } @@ -139,13 +145,13 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd { @Override public void create() { try { - RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall()); + RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall(), getDisplay()); if (vpn != null) { - this.setEntityId(vpn.getServerAddressId()); + setEntityId(vpn.getServerAddressId()); // find uuid for server ip address IpAddress ipAddr = _entityMgr.findById(IpAddress.class, vpn.getServerAddressId()); if (ipAddr != null) { - this.setEntityUuid(ipAddr.getUuid()); + setEntityUuid(ipAddr.getUuid()); } } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create remote access vpn"); @@ -164,7 +170,7 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd { if (result != null) { RemoteAccessVpnResponse response = _responseGenerator.createRemoteAccessVpnResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create remote access vpn"); } @@ -191,4 +197,8 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd { } return ip; } + + public Boolean getDisplay() { + return display; + } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnConnectionCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnConnectionCmd.java index 2c2bf5550d5..71245c340a3 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnConnectionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnConnectionCmd.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.user.vpn; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -36,7 +37,9 @@ import com.cloud.network.Site2SiteVpnConnection; import com.cloud.network.Site2SiteVpnGateway; import com.cloud.network.vpc.Vpc; -@APICommand(name = "createVpnConnection", description = "Create site to site vpn connection", responseObject = Site2SiteVpnConnectionResponse.class) + +@APICommand(name = "createVpnConnection", description = "Create site to site vpn connection", responseObject = Site2SiteVpnConnectionResponse.class, entityType = {Site2SiteVpnConnection.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd { public static final Logger s_logger = Logger.getLogger(CreateVpnConnectionCmd.class.getName()); @@ -62,6 +65,9 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd { @Parameter(name = ApiConstants.PASSIVE, type = CommandType.BOOLEAN, required = false, description = "connection is passive or not") private Boolean passive; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -81,6 +87,10 @@ public class CreateVpnConnectionCmd extends BaseAsyncCreateCmd { return passive; } + public Boolean getDisplay() { + return display; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java index 821a4b02fd6..6967ff49786 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnCustomerGatewayCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.network.Site2SiteCustomerGateway; -@APICommand(name = "createVpnCustomerGateway", description = "Creates site to site vpn customer gateway", responseObject = Site2SiteCustomerGatewayResponse.class) +@APICommand(name = "createVpnCustomerGateway", description = "Creates site to site vpn customer gateway", responseObject = Site2SiteCustomerGatewayResponse.class, entityType = {Site2SiteCustomerGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(CreateVpnCustomerGatewayCmd.class.getName()); @@ -142,7 +143,7 @@ public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, null, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true); if (accountId == null) { accountId = CallContext.current().getCallingAccount().getId(); } @@ -165,7 +166,7 @@ public class CreateVpnCustomerGatewayCmd extends BaseAsyncCmd { if (result != null) { Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create customer VPN gateway"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnGatewayCmd.java index 8955c8e9bd3..d5b5edbeeea 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnGatewayCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/CreateVpnGatewayCmd.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.user.vpn; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -31,7 +32,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.Site2SiteVpnGateway; import com.cloud.network.vpc.Vpc; -@APICommand(name = "createVpnGateway", description = "Creates site to site vpn local gateway", responseObject = Site2SiteVpnGatewayResponse.class) +@APICommand(name = "createVpnGateway", description = "Creates site to site vpn local gateway", responseObject = Site2SiteVpnGatewayResponse.class, entityType = {Site2SiteVpnGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVpnGatewayCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(CreateVpnGatewayCmd.class.getName()); @@ -47,6 +49,9 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd { description = "public ip address id of the vpn gateway") private Long vpcId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -55,6 +60,10 @@ public class CreateVpnGatewayCmd extends BaseAsyncCmd { return vpcId; } + public Boolean getDisplay() { + return display; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java index 41a8f1eaa0c..f8941246d68 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteRemoteAccessVpnCmd.java @@ -32,7 +32,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.RemoteAccessVpn; -@APICommand(name = "deleteRemoteAccessVpn", description = "Destroys a l2tp/ipsec remote access vpn", responseObject = SuccessResponse.class) +@APICommand(name = "deleteRemoteAccessVpn", description = "Destroys a l2tp/ipsec remote access vpn", responseObject = SuccessResponse.class, entityType = {RemoteAccessVpn.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteRemoteAccessVpnCmd.class.getName()); @@ -41,6 +42,7 @@ public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @Parameter(name = ApiConstants.PUBLIC_IP_ID, type = CommandType.UUID, entityType = IPAddressResponse.class, diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnConnectionCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnConnectionCmd.java index c86cc59f104..a76b0c804eb 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnConnectionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnConnectionCmd.java @@ -32,7 +32,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Site2SiteVpnConnection; import com.cloud.user.Account; -@APICommand(name = "deleteVpnConnection", description = "Delete site to site vpn connection", responseObject = SuccessResponse.class) +@APICommand(name = "deleteVpnConnection", description = "Delete site to site vpn connection", responseObject = SuccessResponse.class, entityType = {Site2SiteVpnConnection.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVpnConnectionCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteVpnConnectionCmd.class.getName()); @@ -86,7 +87,7 @@ public class DeleteVpnConnectionCmd extends BaseAsyncCmd { boolean result = _s2sVpnService.deleteVpnConnection(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete site to site VPN connection"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnCustomerGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnCustomerGatewayCmd.java index 4c777d771a1..aad69ce0a9a 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnCustomerGatewayCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnCustomerGatewayCmd.java @@ -18,6 +18,8 @@ package org.apache.cloudstack.api.command.user.vpn; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.SecurityChecker.AccessType; +import org.apache.cloudstack.api.ACL; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiErrorCode; @@ -31,7 +33,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.Site2SiteCustomerGateway; import com.cloud.user.Account; -@APICommand(name = "deleteVpnCustomerGateway", description = "Delete site to site vpn customer gateway", responseObject = SuccessResponse.class) +@APICommand(name = "deleteVpnCustomerGateway", description = "Delete site to site vpn customer gateway", responseObject = SuccessResponse.class, entityType = {Site2SiteCustomerGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVpnCustomerGatewayCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteVpnCustomerGatewayCmd.class.getName()); @@ -40,6 +43,7 @@ public class DeleteVpnCustomerGatewayCmd extends BaseAsyncCmd { ///////////////////////////////////////////////////// //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// + @ACL(accessType = AccessType.OperateEntry) @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = Site2SiteCustomerGatewayResponse.class, @@ -88,7 +92,7 @@ public class DeleteVpnCustomerGatewayCmd extends BaseAsyncCmd { boolean result = _s2sVpnService.deleteCustomerGateway(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete customer VPN gateway"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnGatewayCmd.java index 85f40049430..ff927408a24 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnGatewayCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/DeleteVpnGatewayCmd.java @@ -31,7 +31,8 @@ import com.cloud.event.EventTypes; import com.cloud.network.Site2SiteVpnGateway; import com.cloud.user.Account; -@APICommand(name = "deleteVpnGateway", description = "Delete site to site vpn gateway", responseObject = SuccessResponse.class) +@APICommand(name = "deleteVpnGateway", description = "Delete site to site vpn gateway", responseObject = SuccessResponse.class, entityType = {Site2SiteVpnGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVpnGatewayCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DeleteVpnGatewayCmd.class.getName()); @@ -85,7 +86,7 @@ public class DeleteVpnGatewayCmd extends BaseAsyncCmd { result = _s2sVpnService.deleteVpnGateway(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete customer VPN gateway"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java index 01e6d37fbb7..492eaccefa5 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ListRemoteAccessVpnsCmd.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; @@ -33,7 +34,8 @@ import org.apache.cloudstack.api.response.RemoteAccessVpnResponse; import com.cloud.network.RemoteAccessVpn; import com.cloud.utils.Pair; -@APICommand(name = "listRemoteAccessVpns", description = "Lists remote access vpns", responseObject = RemoteAccessVpnResponse.class) +@APICommand(name = "listRemoteAccessVpns", description = "Lists remote access vpns", responseObject = RemoteAccessVpnResponse.class, entityType = {RemoteAccessVpn.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListRemoteAccessVpnsCmd.class.getName()); @@ -59,6 +61,9 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC since = "4.3") private Long networkId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -75,6 +80,14 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC return networkId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -96,6 +109,6 @@ public class ListRemoteAccessVpnsCmd extends BaseListProjectAndAccountResourcesC } response.setResponses(vpnResponses, vpns.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnConnectionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnConnectionsCmd.java index 8de60592ade..74b9325eb22 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnConnectionsCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnConnectionsCmd.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; @@ -32,7 +33,8 @@ import org.apache.cloudstack.api.response.VpcResponse; import com.cloud.network.Site2SiteVpnConnection; import com.cloud.utils.Pair; -@APICommand(name = "listVpnConnections", description = "Lists site to site vpn connection gateways", responseObject = Site2SiteVpnConnectionResponse.class) +@APICommand(name = "listVpnConnections", description = "Lists site to site vpn connection gateways", responseObject = Site2SiteVpnConnectionResponse.class, entityType = {Site2SiteVpnConnection.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListVpnConnectionsCmd.class.getName()); @@ -47,6 +49,9 @@ public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "id of vpc") private Long vpcId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -59,6 +64,14 @@ public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd return vpcId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -84,6 +97,6 @@ public class ListVpnConnectionsCmd extends BaseListProjectAndAccountResourcesCmd response.setResponses(connResponses, conns.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnCustomerGatewaysCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnCustomerGatewaysCmd.java index 5cd4bfb98ed..6b870be138d 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnCustomerGatewaysCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnCustomerGatewaysCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse; import com.cloud.network.Site2SiteCustomerGateway; import com.cloud.utils.Pair; -@APICommand(name = "listVpnCustomerGateways", description = "Lists site to site vpn customer gateways", responseObject = Site2SiteCustomerGatewayResponse.class) +@APICommand(name = "listVpnCustomerGateways", description = "Lists site to site vpn customer gateways", responseObject = Site2SiteCustomerGatewayResponse.class, entityType = {Site2SiteCustomerGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVpnCustomerGatewaysCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListVpnCustomerGatewaysCmd.class.getName()); @@ -77,6 +78,6 @@ public class ListVpnCustomerGatewaysCmd extends BaseListProjectAndAccountResourc response.setResponses(gwResponses, gws.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnGatewaysCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnGatewaysCmd.java index 75a5e810294..3eade028804 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnGatewaysCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnGatewaysCmd.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.log4j.Logger; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; @@ -32,7 +33,8 @@ import org.apache.cloudstack.api.response.VpcResponse; import com.cloud.network.Site2SiteVpnGateway; import com.cloud.utils.Pair; -@APICommand(name = "listVpnGateways", description = "Lists site 2 site vpn gateways", responseObject = Site2SiteVpnGatewayResponse.class) +@APICommand(name = "listVpnGateways", description = "Lists site 2 site vpn gateways", responseObject = Site2SiteVpnGatewayResponse.class, entityType = {Site2SiteVpnGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVpnGatewaysCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListVpnGatewaysCmd.class.getName()); @@ -48,6 +50,9 @@ public class ListVpnGatewaysCmd extends BaseListProjectAndAccountResourcesCmd { @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, description = "id of vpc") private Long vpcId; + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -60,6 +65,14 @@ public class ListVpnGatewaysCmd extends BaseListProjectAndAccountResourcesCmd { return vpcId; } + @Override + public Boolean getDisplay() { + if (display != null) { + return display; + } + return super.getDisplay(); + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -85,6 +98,6 @@ public class ListVpnGatewaysCmd extends BaseListProjectAndAccountResourcesCmd { response.setResponses(gwResponses, gws.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnUsersCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnUsersCmd.java index 5136633f5c1..9af060ac00f 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnUsersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ListVpnUsersCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.api.response.VpnUsersResponse; import com.cloud.network.VpnUser; import com.cloud.utils.Pair; -@APICommand(name = "listVpnUsers", description = "Lists vpn users", responseObject = VpnUsersResponse.class) +@APICommand(name = "listVpnUsers", description = "Lists vpn users", responseObject = VpnUsersResponse.class, entityType = {VpnUser.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVpnUsersCmd extends BaseListProjectAndAccountResourcesCmd { public static final Logger s_logger = Logger.getLogger(ListVpnUsersCmd.class.getName()); @@ -79,6 +80,6 @@ public class ListVpnUsersCmd extends BaseListProjectAndAccountResourcesCmd { response.setResponses(vpnResponses, vpnUsers.second()); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java index 4eeef678154..f552b14fbf1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/RemoveVpnUserCmd.java @@ -30,9 +30,11 @@ import org.apache.cloudstack.api.response.SuccessResponse; import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; +import com.cloud.network.VpnUser; import com.cloud.user.Account; -@APICommand(name = "removeVpnUser", description = "Removes vpn user", responseObject = SuccessResponse.class) +@APICommand(name = "removeVpnUser", description = "Removes vpn user", responseObject = SuccessResponse.class, entityType = {VpnUser.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class RemoveVpnUserCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(RemoveVpnUserCmd.class.getName()); @@ -87,7 +89,7 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, projectId, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java index efe6db8589c..75e74adcda0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/ResetVpnConnectionCmd.java @@ -33,7 +33,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Site2SiteVpnConnection; import com.cloud.user.Account; -@APICommand(name = "resetVpnConnection", description = "Reset site to site vpn connection", responseObject = Site2SiteVpnConnectionResponse.class) +@APICommand(name = "resetVpnConnection", description = "Reset site to site vpn connection", responseObject = Site2SiteVpnConnectionResponse.class, entityType = {Site2SiteVpnConnection.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ResetVpnConnectionCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ResetVpnConnectionCmd.class.getName()); @@ -81,7 +82,7 @@ public class ResetVpnConnectionCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, null, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true); if (accountId == null) { return CallContext.current().getCallingAccount().getId(); } @@ -105,7 +106,7 @@ public class ResetVpnConnectionCmd extends BaseAsyncCmd { if (result != null) { Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reset site to site VPN connection"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateRemoteAccessVpnCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateRemoteAccessVpnCmd.java new file mode 100644 index 00000000000..08d3b0a5cd4 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateRemoteAccessVpnCmd.java @@ -0,0 +1,111 @@ +// 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 org.apache.cloudstack.api.command.user.vpn; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.AccountResponse; +import org.apache.cloudstack.api.response.RemoteAccessVpnResponse; +import org.apache.log4j.Logger; + +import com.cloud.event.EventTypes; +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.network.RemoteAccessVpn; + +@APICommand(name = "updateRemoteAccessVpn", description = "Updates remote access vpn", responseObject = RemoteAccessVpnResponse.class, since = "4.4", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateRemoteAccessVpnCmd extends BaseAsyncCustomIdCmd { + public static final Logger s_logger = Logger.getLogger(UpdateRemoteAccessVpnCmd.class.getName()); + + private static final String s_name = "updateremoteaccessvpnresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = true, entityType = RemoteAccessVpnResponse.class, description = "id of the remote access vpn") + private Long id; + + // unexposed parameter needed for events logging + @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, expose = false) + private Long ownerId; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public Long getId() { + return id; + } + + @Override + public String getCommandName() { + return s_name; + } + + public Boolean getDisplay() { + return display; + } + + @Override + public long getEntityOwnerId() { + if (ownerId == null) { + RemoteAccessVpn vpnEntity = _ravService.getRemoteAccessVpnById(id); + if (vpnEntity != null) + return vpnEntity.getAccountId(); + + throw new InvalidParameterValueException("The specified id is invalid"); + } + return ownerId; + } + + @Override + public String getEventDescription() { + return "Updating remote access vpn id=" + id; + } + + @Override + public String getEventType() { + return EventTypes.EVENT_REMOTE_ACCESS_VPN_UPDATE; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public void execute() { + RemoteAccessVpn result = _ravService.updateRemoteAccessVpn(id, this.getCustomId(), getDisplay()); + RemoteAccessVpnResponse response = _responseGenerator.createRemoteAccessVpnResponse(result); + response.setResponseName(getCommandName()); + this.setResponseObject(response); + + } + + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), RemoteAccessVpn.class); + } + } +} \ No newline at end of file diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnConnectionCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnConnectionCmd.java new file mode 100644 index 00000000000..282afe04267 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnConnectionCmd.java @@ -0,0 +1,99 @@ +// 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 org.apache.cloudstack.api.command.user.vpn; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse; +import org.apache.log4j.Logger; + +import com.cloud.event.EventTypes; +import com.cloud.network.Site2SiteVpnConnection; +import com.cloud.user.Account; + +@APICommand(name = "updateVpnConnection", description = "Updates site to site vpn connection", responseObject = Site2SiteVpnConnectionResponse.class, since = "4.4", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateVpnConnectionCmd extends BaseAsyncCustomIdCmd { + public static final Logger s_logger = Logger.getLogger(UpdateVpnConnectionCmd.class.getName()); + + private static final String s_name = "updatevpnconnectionresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = Site2SiteVpnConnectionResponse.class, required = true, description = "id of vpn connection") + private Long id; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + public Long getId() { + return id; + } + + public Boolean getDisplay() { + return display; + } + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + Site2SiteVpnConnection conn = _entityMgr.findById(Site2SiteVpnConnection.class, getId()); + if (conn != null) { + return conn.getAccountId(); + } + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public String getEventDescription() { + return "Updating site-to-site VPN connection id= " + id; + } + + @Override + public String getEventType() { + return EventTypes.EVENT_S2S_VPN_CONNECTION_UPDATE; + } + + @Override + public void execute() { + Site2SiteVpnConnection result = _s2sVpnService.updateVpnConnection(id, this.getCustomId(), getDisplay()); + Site2SiteVpnConnectionResponse response = _responseGenerator.createSite2SiteVpnConnectionResponse(result); + response.setResponseName(getCommandName()); + setResponseObject(response); + } + + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), Site2SiteVpnConnection.class); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java index 5694a747cd6..ceb67d510a0 100644 --- a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnCustomerGatewayCmd.java @@ -31,7 +31,8 @@ import org.apache.cloudstack.context.CallContext; import com.cloud.event.EventTypes; import com.cloud.network.Site2SiteCustomerGateway; -@APICommand(name = "updateVpnCustomerGateway", description = "Update site to site vpn customer gateway", responseObject = Site2SiteCustomerGatewayResponse.class) +@APICommand(name = "updateVpnCustomerGateway", description = "Update site to site vpn customer gateway", responseObject = Site2SiteCustomerGatewayResponse.class, entityType = {Site2SiteCustomerGateway.class}, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(UpdateVpnCustomerGatewayCmd.class.getName()); @@ -145,7 +146,7 @@ public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd { @Override public long getEntityOwnerId() { - Long accountId = finalyzeAccountId(accountName, domainId, null, true); + Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true); if (accountId == null) { accountId = CallContext.current().getCallingAccount().getId(); } @@ -168,7 +169,7 @@ public class UpdateVpnCustomerGatewayCmd extends BaseAsyncCmd { if (result != null) { Site2SiteCustomerGatewayResponse response = _responseGenerator.createSite2SiteCustomerGatewayResponse(result); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update customer VPN gateway"); } diff --git a/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java new file mode 100644 index 00000000000..66c59ad9f1b --- /dev/null +++ b/api/src/org/apache/cloudstack/api/command/user/vpn/UpdateVpnGatewayCmd.java @@ -0,0 +1,98 @@ +// 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 org.apache.cloudstack.api.command.user.vpn; + +import org.apache.cloudstack.acl.RoleType; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseAsyncCustomIdCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse; +import org.apache.log4j.Logger; + +import com.cloud.event.EventTypes; +import com.cloud.network.Site2SiteVpnGateway; +import com.cloud.user.Account; + +@APICommand(name = "updateVpnGateway", description = "Updates site to site vpn local gateway", responseObject = Site2SiteVpnGatewayResponse.class, since = "4.4", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateVpnGatewayCmd extends BaseAsyncCustomIdCmd { + public static final Logger s_logger = Logger.getLogger(UpdateVpnGatewayCmd.class.getName()); + + private static final String s_name = "updatevpngatewayresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = Site2SiteVpnGatewayResponse.class, required = true, description = "id of customer gateway") + private Long id; + + @Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the vpn to the end user or not", since = "4.4", authorized = {RoleType.Admin}) + private Boolean display; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + public Long getId() { + return id; + } + + public Boolean getDisplay() { + return display; + } + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + Site2SiteVpnGateway gw = _entityMgr.findById(Site2SiteVpnGateway.class, getId()); + if (gw != null) { + return gw.getAccountId(); + } + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public String getEventDescription() { + return "Update site-to-site VPN gateway id= " + id; + } + + @Override + public String getEventType() { + return EventTypes.EVENT_S2S_VPN_GATEWAY_UPDATE; + } + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + @Override + public void execute() { + Site2SiteVpnGateway result = _s2sVpnService.updateVpnGateway(id, this.getCustomId(), getDisplay()); + Site2SiteVpnGatewayResponse response = _responseGenerator.createSite2SiteVpnGatewayResponse(result); + response.setResponseName(getCommandName()); + } + + @Override + public void checkUuid() { + if (this.getCustomId() != null) { + _uuidMgr.checkUuid(this.getCustomId(), Site2SiteVpnGateway.class); + } + } +} diff --git a/api/src/org/apache/cloudstack/api/command/user/zone/ListZonesByCmd.java b/api/src/org/apache/cloudstack/api/command/user/zone/ListZonesCmd.java similarity index 93% rename from api/src/org/apache/cloudstack/api/command/user/zone/ListZonesByCmd.java rename to api/src/org/apache/cloudstack/api/command/user/zone/ListZonesCmd.java index 471e6d684c0..34a5440fb64 100644 --- a/api/src/org/apache/cloudstack/api/command/user/zone/ListZonesByCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/zone/ListZonesCmd.java @@ -27,15 +27,17 @@ import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListCmd; import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.exception.InvalidParameterValueException; -@APICommand(name = "listZones", description = "Lists zones", responseObject = ZoneResponse.class) -public class ListZonesByCmd extends BaseListCmd { - public static final Logger s_logger = Logger.getLogger(ListZonesByCmd.class.getName()); +@APICommand(name = "listZones", description = "Lists zones", responseObject = ZoneResponse.class, responseView = ResponseView.Restricted, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class ListZonesCmd extends BaseListCmd { + public static final Logger s_logger = Logger.getLogger(ListZonesCmd.class.getName()); private static final String s_name = "listzonesresponse"; @@ -127,6 +129,6 @@ public class ListZonesByCmd extends BaseListCmd { ListResponse response = _queryService.listDataCenters(this); response.setResponseName(getCommandName()); - this.setResponseObject(response); + setResponseObject(response); } } diff --git a/api/src/org/apache/cloudstack/api/response/AccountResponse.java b/api/src/org/apache/cloudstack/api/response/AccountResponse.java index b7d30ca6bfb..2e50c51858a 100644 --- a/api/src/org/apache/cloudstack/api/response/AccountResponse.java +++ b/api/src/org/apache/cloudstack/api/response/AccountResponse.java @@ -239,6 +239,10 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou @Param(description = "true if account is default, false otherwise", since = "4.2.0") private Boolean isDefault; + @SerializedName(ApiConstants.IAM_GROUPS) + @Param(description = "the list of acl groups that account belongs to", since = "4.4") + private List groups; + @Override public String getObjectId() { return id; @@ -486,4 +490,9 @@ public class AccountResponse extends BaseResponse implements ResourceLimitAndCou public void setIsDefault(Boolean isDefault) { this.isDefault = isDefault; } + + public void setGroups(List groups) { + this.groups = groups; + } + } diff --git a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java index edaac07b974..bdbb954df03 100644 --- a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java +++ b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerInstanceResponse.java @@ -16,12 +16,11 @@ // under the License. package org.apache.cloudstack.api.response; -import com.google.gson.annotations.SerializedName; - import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; /** * diff --git a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java index 1e9f9c7ba30..53e3f868a3b 100644 --- a/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java +++ b/api/src/org/apache/cloudstack/api/response/ApplicationLoadBalancerResponse.java @@ -19,12 +19,12 @@ package org.apache.cloudstack.api.response; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") public class ApplicationLoadBalancerResponse extends BaseResponse implements ControlledEntityResponse { @@ -88,6 +88,10 @@ public class ApplicationLoadBalancerResponse extends BaseResponse implements Con @Param(description = "the list of resource tags associated with the Load Balancer", responseObject = ResourceTagResponse.class) private List tags; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is rule for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + @Override public void setAccountName(String accountName) { this.accountName = accountName; @@ -152,4 +156,8 @@ public class ApplicationLoadBalancerResponse extends BaseResponse implements Con public void setLbInstances(List lbInstances) { this.lbInstances = lbInstances; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java b/api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java index a88325f98b0..572d4626fd9 100644 --- a/api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java +++ b/api/src/org/apache/cloudstack/api/response/AutoScaleVmGroupResponse.java @@ -18,14 +18,14 @@ package org.apache.cloudstack.api.response; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.as.AutoScaleVmGroup; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = AutoScaleVmGroup.class) public class AutoScaleVmGroupResponse extends BaseResponse implements ControlledEntityResponse { @@ -86,6 +86,10 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled @Param(description = "the domain name of the vm profile") private String domainName; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is group for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public AutoScaleVmGroupResponse() { } @@ -155,4 +159,8 @@ public class AutoScaleVmGroupResponse extends BaseResponse implements Controlled public void setProjectName(String projectName) { this.projectName = projectName; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java b/api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java index e1c33e7881b..2c219357150 100644 --- a/api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java +++ b/api/src/org/apache/cloudstack/api/response/AutoScaleVmProfileResponse.java @@ -20,8 +20,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseCmd.CommandType; import org.apache.cloudstack.api.BaseResponse; @@ -31,6 +30,7 @@ import org.apache.cloudstack.api.Parameter; import com.cloud.network.as.AutoScaleVmProfile; import com.cloud.serializer.Param; import com.cloud.utils.Pair; +import com.google.gson.annotations.SerializedName; @EntityReference(value = AutoScaleVmProfile.class) public class AutoScaleVmProfileResponse extends BaseResponse implements ControlledEntityResponse { @@ -97,8 +97,11 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll @Param(description = "the domain name of the vm profile") private String domainName; - public AutoScaleVmProfileResponse() { + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is profile for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public AutoScaleVmProfileResponse() { } @Override @@ -171,4 +174,8 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll public void setCsUrl(String csUrl) { this.csUrl = csUrl; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java b/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java index c8de5873367..f7fdb95fb6e 100644 --- a/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java +++ b/api/src/org/apache/cloudstack/api/response/CapabilitiesResponse.java @@ -49,6 +49,10 @@ public class CapabilitiesResponse extends BaseResponse { @Param(description = "true if regular user is allowed to create projects") private Boolean allowUsersCreateProjects; + @SerializedName(ApiConstants.CUSTOM_DISK_OFF_MIN_SIZE) + @Param(description = "minimum size that can be specified when " + "create disk from disk offering with custom size") + private Long diskOffMinSize; + @SerializedName(ApiConstants.CUSTOM_DISK_OFF_MAX_SIZE) @Param(description = "maximum size that can be specified when " + "create disk from disk offering with custom size") private Long diskOffMaxSize; @@ -93,6 +97,10 @@ public class CapabilitiesResponse extends BaseResponse { this.allowUsersCreateProjects = allowUsersCreateProjects; } + public void setDiskOffMinSize(Long diskOffMinSize) { + this.diskOffMinSize = diskOffMinSize; + } + public void setDiskOffMaxSize(Long diskOffMaxSize) { this.diskOffMaxSize = diskOffMaxSize; } diff --git a/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java index ebc22428326..91bd4413539 100644 --- a/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java +++ b/api/src/org/apache/cloudstack/api/response/DiskOfferingResponse.java @@ -73,6 +73,10 @@ public class DiskOfferingResponse extends BaseResponse { @Param(description = "the max iops of the disk offering") private Long maxIops; + @SerializedName(ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE) + @Param(description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)", since = "4.4") + private Integer hypervisorSnapshotReserve; + @SerializedName(ApiConstants.TAGS) @Param(description = "the tags for the disk offering") private String tags; @@ -98,7 +102,7 @@ public class DiskOfferingResponse extends BaseResponse { private Long iopsWriteRate; @SerializedName("cacheMode") - @Param(description = "the cache mode to use for this disk offering. none, writeback or writethrough") + @Param(description = "the cache mode to use for this disk offering. none, writeback or writethrough", since = "4.4") private String cacheMode; @SerializedName("displayoffering") @@ -210,6 +214,14 @@ public class DiskOfferingResponse extends BaseResponse { this.maxIops = maxIops; } + public Integer getHypervisorSnapshotReserve() { + return hypervisorSnapshotReserve; + } + + public void setHypervisorSnapshotReserve(Integer hypervisorSnapshotReserve) { + this.hypervisorSnapshotReserve = hypervisorSnapshotReserve; + } + public String getCacheMode() { return cacheMode; } diff --git a/api/src/org/apache/cloudstack/api/response/FirewallResponse.java b/api/src/org/apache/cloudstack/api/response/FirewallResponse.java index e3aaec567e1..4c1342a7ecb 100644 --- a/api/src/org/apache/cloudstack/api/response/FirewallResponse.java +++ b/api/src/org/apache/cloudstack/api/response/FirewallResponse.java @@ -18,12 +18,12 @@ package org.apache.cloudstack.api.response; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") public class FirewallResponse extends BaseResponse { @@ -75,6 +75,10 @@ public class FirewallResponse extends BaseResponse { @Param(description = "the list of resource tags associated with the rule", responseObject = ResourceTagResponse.class) private List tags; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is rule for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public void setId(String id) { this.id = id; } @@ -122,4 +126,8 @@ public class FirewallResponse extends BaseResponse { public void setTags(List tags) { this.tags = tags; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java b/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java index 71a3097688c..0d11e85af66 100644 --- a/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java +++ b/api/src/org/apache/cloudstack/api/response/FirewallRuleResponse.java @@ -18,14 +18,14 @@ package org.apache.cloudstack.api.response; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.rules.FirewallRule; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = FirewallRule.class) @SuppressWarnings("unused") @@ -94,6 +94,10 @@ public class FirewallRuleResponse extends BaseResponse { @Param(description = "the id of the guest network the port forwarding rule belongs to") private String networkId; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is firewall for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public String getDestNatVmIp() { return destNatVmIp; } @@ -218,4 +222,8 @@ public class FirewallRuleResponse extends BaseResponse { public void setNetworkId(String networkId) { this.networkId = networkId; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/GetVMPasswordResponse.java b/api/src/org/apache/cloudstack/api/response/GetVMPasswordResponse.java index c72031b8220..7a4543d4379 100644 --- a/api/src/org/apache/cloudstack/api/response/GetVMPasswordResponse.java +++ b/api/src/org/apache/cloudstack/api/response/GetVMPasswordResponse.java @@ -25,7 +25,7 @@ import com.cloud.serializer.Param; public class GetVMPasswordResponse extends BaseResponse { @SerializedName("encryptedpassword") - @Param(description = "The encrypted password of the VM") + @Param(description = "The base64 encoded encrypted password of the VM") private String encryptedPassword; public GetVMPasswordResponse() { diff --git a/api/src/org/apache/cloudstack/api/response/GpuResponse.java b/api/src/org/apache/cloudstack/api/response/GpuResponse.java new file mode 100644 index 00000000000..b655749126e --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/GpuResponse.java @@ -0,0 +1,46 @@ +// 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 org.apache.cloudstack.api.response; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseResponse; + +import com.cloud.serializer.Param; + +public class GpuResponse extends BaseResponse { + + @SerializedName(ApiConstants.GPUGROUPNAME) + @Param(description = "GPU cards present in the host") + private String gpuGroupName; + + @SerializedName(ApiConstants.VGPU) + @Param(description = "the list of enabled vGPUs", responseObject = VgpuResponse.class) + private List vgpu; + + public void setGpuGroupName(String gpuGroupName) { + this.gpuGroupName = gpuGroupName; + } + + public void setVgpu(List vgpu) { + this.vgpu = vgpu; + } + +} diff --git a/api/src/org/apache/cloudstack/api/response/GuestOsMappingResponse.java b/api/src/org/apache/cloudstack/api/response/GuestOsMappingResponse.java new file mode 100644 index 00000000000..a0f7d1d0edd --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/GuestOsMappingResponse.java @@ -0,0 +1,102 @@ +// 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 org.apache.cloudstack.api.response; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseResponse; +import org.apache.cloudstack.api.EntityReference; + +import com.cloud.serializer.Param; +import com.cloud.storage.GuestOSHypervisor; + +@EntityReference(value = GuestOSHypervisor.class) +public class GuestOsMappingResponse extends BaseResponse { + @SerializedName(ApiConstants.ID) + @Param(description = "the ID of the Guest OS mapping") + private String id; + + @SerializedName(ApiConstants.HYPERVISOR) + @Param(description = "the hypervisor") + private String hypervisor; + + @SerializedName(ApiConstants.HYPERVISOR_VERSION) + @Param(description = "version of the hypervisor for mapping") + private String hypervisorVersion; + + @SerializedName(ApiConstants.OS_TYPE_ID) + @Param(description = "the ID of the Guest OS type") + private String osTypeId; + + @SerializedName(ApiConstants.OS_DISPLAY_NAME) + @Param(description = "standard display name for the Guest OS") + private String osStdName; + + @SerializedName(ApiConstants.OS_NAME_FOR_HYPERVISOR) + @Param(description = "hypervisor specific name for the Guest OS") + private String osNameForHypervisor; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getHypervisor() { + return hypervisor; + } + + public void setHypervisor(String hypervisor) { + this.hypervisor = hypervisor; + } + + public String getHypervisorVersion() { + return hypervisorVersion; + } + + public void setHypervisorVersion(String hypervisorVersion) { + this.hypervisorVersion = hypervisorVersion; + } + + public String getOsTypeId() { + return osTypeId; + } + + public void setOsTypeId(String osTypeId) { + this.osTypeId = osTypeId; + } + + public String getOsStdName() { + return osStdName; + } + + public void setOsStdName(String osStdName) { + this.osStdName = osStdName; + } + + public String getOsNameForHypervisor() { + return osNameForHypervisor; + } + + public void setOsNameForHypervisor(String osNameForHypervisor) { + this.osNameForHypervisor = osNameForHypervisor; + } +} diff --git a/api/src/org/apache/cloudstack/api/response/HostResponse.java b/api/src/org/apache/cloudstack/api/response/HostResponse.java index e2d8eb5c473..008631ff7d1 100644 --- a/api/src/org/apache/cloudstack/api/response/HostResponse.java +++ b/api/src/org/apache/cloudstack/api/response/HostResponse.java @@ -17,6 +17,7 @@ package org.apache.cloudstack.api.response; import java.util.Date; +import java.util.List; import com.google.gson.annotations.SerializedName; @@ -135,6 +136,10 @@ public class HostResponse extends BaseResponse { @Param(description = "the amount of the host's memory currently used") private Long memoryUsed; + @SerializedName(ApiConstants.GPUGROUP) + @Param(description = "GPU cards present in the host", responseObject = GpuResponse.class, since = "4.4") + private List gpuGroup; + @SerializedName("disksizetotal") @Param(description = "the total disk size of the host") private Long diskSizeTotal; @@ -320,6 +325,9 @@ public class HostResponse extends BaseResponse { this.memoryUsed = memoryUsed; } + public void setGpuGroups(List gpuGroup) { + this.gpuGroup = gpuGroup; + } public void setDiskSizeTotal(Long diskSizeTotal) { this.diskSizeTotal = diskSizeTotal; } diff --git a/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java b/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java index 4889a5638c3..3c03247eddb 100644 --- a/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java +++ b/api/src/org/apache/cloudstack/api/response/IPAddressResponse.java @@ -19,14 +19,14 @@ package org.apache.cloudstack.api.response; import java.util.Date; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.IpAddress; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = IpAddress.class) @SuppressWarnings("unused") @@ -146,6 +146,10 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR @Param(description = "is public IP portable across the zones") private Boolean isPortable; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is public ip for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + /* @SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume") private IdentityProxy jobId = new IdentityProxy("async_job"); @@ -280,4 +284,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR public void setPortable(Boolean portable) { this.isPortable = portable; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/LoadBalancerResponse.java b/api/src/org/apache/cloudstack/api/response/LoadBalancerResponse.java index 03946b90064..21e1dab450e 100644 --- a/api/src/org/apache/cloudstack/api/response/LoadBalancerResponse.java +++ b/api/src/org/apache/cloudstack/api/response/LoadBalancerResponse.java @@ -18,12 +18,12 @@ package org.apache.cloudstack.api.response; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") public class LoadBalancerResponse extends BaseResponse implements ControlledEntityResponse { @@ -103,6 +103,10 @@ public class LoadBalancerResponse extends BaseResponse implements ControlledEnti @Param(description = "the list of resource tags associated with load balancer", responseObject = ResourceTagResponse.class) private List tags; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is rule for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public void setId(String id) { this.id = id; } @@ -183,4 +187,8 @@ public class LoadBalancerResponse extends BaseResponse implements ControlledEnti public void setLbProtocol(String lbProtocol) { this.lbProtocol = lbProtocol; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/LoadBalancerRuleVmMapResponse.java b/api/src/org/apache/cloudstack/api/response/LoadBalancerRuleVmMapResponse.java new file mode 100644 index 00000000000..57c45e64324 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/LoadBalancerRuleVmMapResponse.java @@ -0,0 +1,54 @@ +// 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 org.apache.cloudstack.api.response; + +import com.cloud.network.router.VirtualRouter; +import com.cloud.uservm.UserVm; +import com.cloud.vm.VirtualMachine; +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.BaseResponse; +import org.apache.cloudstack.api.EntityReference; + +import com.cloud.serializer.Param; + +import java.util.List; + +@EntityReference(value = {VirtualMachine.class, UserVm.class, VirtualRouter.class}) +@SuppressWarnings("unused") +public class LoadBalancerRuleVmMapResponse extends BaseResponse { + + + @SerializedName("loadbalancerruleinstance") + @Param(description = "the user vm set for lb rule") + private UserVmResponse UserVmResponse; + + @SerializedName("lbvmipaddresses") + @Param(description = "IP addresses of the vm set of lb rule") + private List ipAddr; + + public void setIpAddr(List ipAddr) { + this.ipAddr = ipAddr; + } + + public void setUserVmResponse(UserVmResponse userVmResponse) { + this.UserVmResponse = userVmResponse; + } + + + +} diff --git a/api/src/org/apache/cloudstack/api/response/NetworkACLItemResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkACLItemResponse.java index 430422c17e6..01012957978 100644 --- a/api/src/org/apache/cloudstack/api/response/NetworkACLItemResponse.java +++ b/api/src/org/apache/cloudstack/api/response/NetworkACLItemResponse.java @@ -18,14 +18,14 @@ package org.apache.cloudstack.api.response; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.vpc.NetworkACLItem; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = NetworkACLItem.class) public class NetworkACLItemResponse extends BaseResponse { @@ -81,6 +81,10 @@ public class NetworkACLItemResponse extends BaseResponse { @Param(description = "Action of ACL Item. Allow/Deny") private String action; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is rule for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public void setId(String id) { this.id = id; } @@ -132,4 +136,8 @@ public class NetworkACLItemResponse extends BaseResponse { public void setAction(String action) { this.action = action; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/NetworkACLResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkACLResponse.java index 1ee9c33d2b0..fca8bcdc4cf 100644 --- a/api/src/org/apache/cloudstack/api/response/NetworkACLResponse.java +++ b/api/src/org/apache/cloudstack/api/response/NetworkACLResponse.java @@ -16,14 +16,14 @@ // under the License. package org.apache.cloudstack.api.response; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.vpc.NetworkACL; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = NetworkACL.class) public class NetworkACLResponse extends BaseResponse { @@ -43,6 +43,10 @@ public class NetworkACLResponse extends BaseResponse { @Param(description = "Id of the VPC this ACL is associated with") private String vpcId; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is ACL for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public void setId(String id) { this.id = id; } @@ -58,4 +62,8 @@ public class NetworkACLResponse extends BaseResponse { public void setVpcId(String vpcId) { this.vpcId = vpcId; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java index 8219147726e..775c9a8fdd1 100644 --- a/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java +++ b/api/src/org/apache/cloudstack/api/response/NetworkOfferingResponse.java @@ -109,13 +109,17 @@ public class NetworkOfferingResponse extends BaseResponse { private Map details; @SerializedName(ApiConstants.EGRESS_DEFAULT_POLICY) - @Param(description = "true if network offering supports persistent networks, false otherwise") + @Param(description = "true if guest network default egress policy is allow; false if default egress policy is deny") private Boolean egressDefaultPolicy; @SerializedName(ApiConstants.MAX_CONNECTIONS) @Param(description = "maximum number of concurrents connections to be handled by lb") private Integer concurrentConnections; + @SerializedName(ApiConstants.SUPPORTS_STRECHED_L2_SUBNET) + @Param(description = "true if network offering supports network that span multiple zones", since = "4.4") + private Boolean supportsStrechedL2Subnet; + public void setId(String id) { this.id = id; } @@ -200,4 +204,7 @@ public class NetworkOfferingResponse extends BaseResponse { this.concurrentConnections = concurrentConnections; } + public void setSupportsStrechedL2Subnet(Boolean supportsStrechedL2Subnet) { + this.supportsStrechedL2Subnet = supportsStrechedL2Subnet; + } } diff --git a/api/src/org/apache/cloudstack/api/response/NetworkResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkResponse.java index 58ec956e9bc..40c90729cd6 100644 --- a/api/src/org/apache/cloudstack/api/response/NetworkResponse.java +++ b/api/src/org/apache/cloudstack/api/response/NetworkResponse.java @@ -18,8 +18,8 @@ package org.apache.cloudstack.api.response; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import java.util.Set; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; @@ -27,6 +27,7 @@ import org.apache.cloudstack.api.EntityReference; import com.cloud.network.Network; import com.cloud.projects.ProjectAccount; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") @EntityReference(value = {Network.class, ProjectAccount.class}) @@ -209,13 +210,21 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes private String ip6Cidr; @SerializedName(ApiConstants.DISPLAY_NETWORK) - @Param(description = "an optional field, whether to the display the network to the end user or not.") + @Param(description = "an optional field, whether to the display the network to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayNetwork; @SerializedName(ApiConstants.ACL_ID) @Param(description = "ACL Id associated with the VPC network") private String aclId; + @SerializedName(ApiConstants.STRECHED_L2_SUBNET) + @Param(description = "true if network can span multiple zones", since = "4.4") + private Boolean strechedL2Subnet; + + @SerializedName(ApiConstants.NETWORK_SPANNED_ZONES) + @Param(description = "If a network is enabled for 'streched l2 subnet' then represents zones on which network currently spans", since = "4.4") + private Set networkSpannedZones; + public Boolean getDisplayNetwork() { return displayNetwork; } @@ -412,4 +421,12 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes public void setAclId(String aclId) { this.aclId = aclId; } + + public void setStrechedL2Subnet(Boolean strechedL2Subnet) { + this.strechedL2Subnet = strechedL2Subnet; + } + + public void setNetworkSpannedZones(Set networkSpannedZones) { + this.networkSpannedZones = networkSpannedZones; + } } diff --git a/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java b/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java index e09bd946994..28d788b427b 100644 --- a/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java +++ b/api/src/org/apache/cloudstack/api/response/RemoteAccessVpnResponse.java @@ -16,14 +16,14 @@ // under the License. package org.apache.cloudstack.api.response; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.RemoteAccessVpn; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = RemoteAccessVpn.class) @SuppressWarnings("unused") @@ -73,6 +73,10 @@ public class RemoteAccessVpnResponse extends BaseResponse implements ControlledE @Param(description = "the id of the remote access vpn") private String id; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is vpn for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public void setPublicIp(String publicIp) { this.publicIp = publicIp; } @@ -122,4 +126,7 @@ public class RemoteAccessVpnResponse extends BaseResponse implements ControlledE this.id = id; } + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/ResourceTagResponse.java b/api/src/org/apache/cloudstack/api/response/ResourceTagResponse.java index 839876e345e..ae61347b480 100644 --- a/api/src/org/apache/cloudstack/api/response/ResourceTagResponse.java +++ b/api/src/org/apache/cloudstack/api/response/ResourceTagResponse.java @@ -109,4 +109,35 @@ public class ResourceTagResponse extends BaseResponse implements ControlledViewE public void setCustomer(String customer) { this.customer = customer; } + + public String getKey() { + return this.key; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + String key = this.getKey(); + result = prime * result + ((key == null) ? 0 : key.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; + ResourceTagResponse other = (ResourceTagResponse) obj; + String key = this.getKey(); + if (key == null) { + if (other.getKey() != null) + return false; + } else if (!key.equals(other.getKey())) + return false; + return true; + } } diff --git a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java index 526e52b71a5..764ade510ad 100644 --- a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java +++ b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java @@ -106,6 +106,22 @@ public class ServiceOfferingResponse extends BaseResponse { @Param(description = "data transfer rate in megabits per second allowed.") private Integer networkRate; + @SerializedName("iscustomizediops") + @Param(description = "true if disk offering uses custom iops, false otherwise", since = "4.4") + private Boolean customizedIops; + + @SerializedName(ApiConstants.MIN_IOPS) + @Param(description = "the min iops of the disk offering", since = "4.4") + private Long minIops; + + @SerializedName(ApiConstants.MAX_IOPS) + @Param(description = "the max iops of the disk offering", since = "4.4") + private Long maxIops; + + @SerializedName(ApiConstants.HYPERVISOR_SNAPSHOT_RESERVE) + @Param(description = "Hypervisor snapshot reserve space as a percent of a volume (for managed storage using Xen or VMware)", since = "4.4") + private Integer hypervisorSnapshotReserve; + @SerializedName("diskBytesReadRate") @Param(description = "bytes read rate of the service offering") private Long bytesReadRate; @@ -293,6 +309,38 @@ public class ServiceOfferingResponse extends BaseResponse { this.isVolatile = isVolatile; } + public Boolean isCustomizedIops() { + return customizedIops; + } + + public void setCustomizedIops(Boolean customizedIops) { + this.customizedIops = customizedIops; + } + + public Long getMinIops() { + return minIops; + } + + public void setMinIops(Long minIops) { + this.minIops = minIops; + } + + public Long getMaxIops() { + return maxIops; + } + + public void setMaxIops(Long maxIops) { + this.maxIops = maxIops; + } + + public Integer getHypervisorSnapshotReserve() { + return hypervisorSnapshotReserve; + } + + public void setHypervisorSnapshotReserve(Integer hypervisorSnapshotReserve) { + this.hypervisorSnapshotReserve = hypervisorSnapshotReserve; + } + public void setBytesReadRate(Long bytesReadRate) { this.bytesReadRate = bytesReadRate; } diff --git a/api/src/org/apache/cloudstack/api/response/Site2SiteVpnConnectionResponse.java b/api/src/org/apache/cloudstack/api/response/Site2SiteVpnConnectionResponse.java index 423b6cda71b..4c572566f85 100644 --- a/api/src/org/apache/cloudstack/api/response/Site2SiteVpnConnectionResponse.java +++ b/api/src/org/apache/cloudstack/api/response/Site2SiteVpnConnectionResponse.java @@ -18,20 +18,20 @@ package org.apache.cloudstack.api.response; import java.util.Date; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.Site2SiteVpnConnection; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = Site2SiteVpnConnection.class) @SuppressWarnings("unused") public class Site2SiteVpnConnectionResponse extends BaseResponse implements ControlledEntityResponse { @SerializedName(ApiConstants.ID) - @Param(description = "the vpn gateway ID") + @Param(description = "the connection ID") private String id; @SerializedName(ApiConstants.S2S_VPN_GATEWAY_ID) @@ -123,6 +123,10 @@ public class Site2SiteVpnConnectionResponse extends BaseResponse implements Cont @Param(description = "the date and time the host was removed") private Date removed; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is connection for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public void setId(String id) { this.id = id; } @@ -212,4 +216,8 @@ public class Site2SiteVpnConnectionResponse extends BaseResponse implements Cont this.domain = domainName; } + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } + } diff --git a/api/src/org/apache/cloudstack/api/response/Site2SiteVpnGatewayResponse.java b/api/src/org/apache/cloudstack/api/response/Site2SiteVpnGatewayResponse.java index c0917c7e09f..e7194d73e91 100644 --- a/api/src/org/apache/cloudstack/api/response/Site2SiteVpnGatewayResponse.java +++ b/api/src/org/apache/cloudstack/api/response/Site2SiteVpnGatewayResponse.java @@ -18,14 +18,14 @@ package org.apache.cloudstack.api.response; import java.util.Date; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.Site2SiteVpnGateway; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = Site2SiteVpnGateway.class) @SuppressWarnings("unused") @@ -66,6 +66,10 @@ public class Site2SiteVpnGatewayResponse extends BaseResponse implements Control @Param(description = "the date and time the host was removed") private Date removed; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is vpn gateway for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + public void setId(String id) { this.id = id; } @@ -107,4 +111,7 @@ public class Site2SiteVpnGatewayResponse extends BaseResponse implements Control this.domain = domainName; } + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } } diff --git a/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java b/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java index 03a4f349ba0..3571866fe74 100644 --- a/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java +++ b/api/src/org/apache/cloudstack/api/response/StoragePoolResponse.java @@ -107,6 +107,10 @@ public class StoragePoolResponse extends BaseResponse { @Param(description = "the scope of the storage pool") private String scope; + @SerializedName("overprovisionfactor") + @Param(description = "the overprovisionfactor for the storage pool", since = "4.4") + private String overProvisionFactor; + @SerializedName(ApiConstants.HYPERVISOR) @Param(description = "the hypervisor type of the storage pool") private String hypervisor; @@ -301,4 +305,8 @@ public class StoragePoolResponse extends BaseResponse { public void setSuitableForMigration(Boolean suitableForMigration) { this.suitableForMigration = suitableForMigration; } + + public void setOverProvisionFactor(String overProvisionFactor) { + this.overProvisionFactor = overProvisionFactor; + } } diff --git a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java index 26ecb5bb088..9fe3475f57a 100644 --- a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java +++ b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java @@ -21,6 +21,7 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.affinity.AffinityGroupResponse; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; @@ -140,11 +141,11 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp private String serviceOfferingName; @SerializedName(ApiConstants.DISK_OFFERING_ID) - @Param(description = "the ID of the disk offering of the virtual machine") + @Param(description = "the ID of the disk offering of the virtual machine", since = "4.4") private String diskOfferingId; @SerializedName("diskofferingname") - @Param(description = "the name of the disk offering of the virtual machine") + @Param(description = "the name of the disk offering of the virtual machine", since = "4.4") private String diskOfferingName; @SerializedName("forvirtualnetwork") @@ -163,6 +164,10 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp @Param(description = "the memory allocated for the virtual machine") private Integer memory; + @SerializedName(ApiConstants.VGPU) + @Param(description = "the vgpu type used by the virtual machine", since = "4.4") + private String vgpu; + @SerializedName("cpuused") @Param(description = "the amount of the vm's CPU currently used") private String cpuUsed; @@ -248,7 +253,7 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp private Set affinityGroupList; @SerializedName(ApiConstants.DISPLAY_VM) - @Param(description = "an optional field whether to the display the vm to the end user or not.") + @Param(description = "an optional field whether to the display the vm to the end user or not.", authorized = {RoleType.Admin}) private Boolean displayVm; @SerializedName(ApiConstants.IS_DYNAMICALLY_SCALABLE) @@ -419,6 +424,9 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp return memory; } + public String getVgpu() { + return vgpu; + } public String getCpuUsed() { return cpuUsed; } @@ -642,6 +650,9 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp this.memory = memory; } + public void setVgpu(String vgpu) { + this.vgpu = vgpu; + } public void setCpuUsed(String cpuUsed) { this.cpuUsed = cpuUsed; } diff --git a/api/src/org/apache/cloudstack/api/response/VgpuResponse.java b/api/src/org/apache/cloudstack/api/response/VgpuResponse.java new file mode 100644 index 00000000000..17e194be5b1 --- /dev/null +++ b/api/src/org/apache/cloudstack/api/response/VgpuResponse.java @@ -0,0 +1,52 @@ +// 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 org.apache.cloudstack.api.response; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.BaseResponse; + +import com.cloud.serializer.Param; + +public class VgpuResponse extends BaseResponse { + + @SerializedName(ApiConstants.VGPUTYPE) + @Param(description = "Model Name of vGPU") + private String name; + + @SerializedName(ApiConstants.REMAININGCAPACITY) + @Param(description = "No. of more VMs can be deployped with this vGPU type") + private Long capacity; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Long getCapacity() { + return capacity; + } + + public void setCapacity(Long capacity) { + this.capacity = capacity; + } + +} diff --git a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java index f511662993e..45c15daa6a4 100644 --- a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java +++ b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java @@ -20,14 +20,14 @@ import java.util.Date; import java.util.LinkedHashSet; import java.util.Set; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.serializer.Param; import com.cloud.storage.Volume; +import com.google.gson.annotations.SerializedName; @EntityReference(value = Volume.class) @SuppressWarnings("unused") @@ -189,17 +189,26 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity private Set tags; @SerializedName(ApiConstants.DISPLAY_VOLUME) - @Param(description = "an optional field whether to the display the volume to the end user or not.") - private Boolean displayVm; + @Param(description = "an optional field whether to the display the volume to the end user or not.", authorized = {RoleType.Admin}) + private Boolean displayVolume; @SerializedName(ApiConstants.PATH) - @Param(description = "The path of the volume") + @Param(description = "the path of the volume") private String path; @SerializedName(ApiConstants.STORAGE_ID) @Param(description = "id of the primary storage hosting the disk volume; returned to admin user only", since = "4.3") private String storagePoolId; + @SerializedName(ApiConstants.CHAIN_INFO) + @Param(description = "the chain info of the volume", since = "4.4") + String chainInfo; + + @SerializedName(ApiConstants.SNAPSHOT_QUIESCEVM) + @Param(description = "need quiesce vm or not when taking snapshot", since="4.3") + private boolean needQuiescevm; + + public String getPath() { return path; } @@ -406,15 +415,33 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity this.tags.add(tag); } - public Boolean getDisplayVm() { - return displayVm; - } - - public void setDisplayVm(Boolean displayVm) { - this.displayVm = displayVm; + public void setDisplayVolume(Boolean displayVm) { + this.displayVolume = displayVm; } public void setStoragePoolId(String storagePoolId) { this.storagePoolId = storagePoolId; } + + public String getChainInfo() { + return chainInfo; + } + + public void setChainInfo(String chainInfo) { + this.chainInfo = chainInfo; + } + + public String getStoragePoolId() { + return storagePoolId; + } + + public void setNeedQuiescevm(boolean quiescevm) { + this.needQuiescevm = quiescevm; + } + + public boolean isNeedQuiescevm() { + return this.needQuiescevm; + } + + } diff --git a/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java index 17e4dfdd0b6..512746fb6af 100644 --- a/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java +++ b/api/src/org/apache/cloudstack/api/response/VpcOfferingResponse.java @@ -59,6 +59,14 @@ public class VpcOfferingResponse extends BaseResponse { @Param(description = "the list of supported services", responseObject = ServiceResponse.class) private List services; + @SerializedName(ApiConstants.DISTRIBUTED_VPC_ROUTER) + @Param(description = " indicates if the vpc offering supports distributed router for one-hop forwarding", since = "4.4") + private Boolean supportsDistributedRouter; + + @SerializedName((ApiConstants.SUPPORTS_REGION_LEVEL_VPC)) + @Param(description = " indicated if the offering can support region level vpc", since = "4.4") + private Boolean supportsRegionLevelVpc; + public void setId(String id) { this.id = id; } @@ -86,4 +94,12 @@ public class VpcOfferingResponse extends BaseResponse { public void setState(String state) { this.state = state; } + + public void setSupportsDistributedRouter(Boolean supportsDistributedRouter) { + this.supportsDistributedRouter = supportsDistributedRouter; + } + + public void setSupportsRegionLevelVpc(Boolean supports) { + this.supportsRegionLevelVpc = supports; + } } diff --git a/api/src/org/apache/cloudstack/api/response/VpcResponse.java b/api/src/org/apache/cloudstack/api/response/VpcResponse.java index fd9b710bc27..d1afdfb8169 100644 --- a/api/src/org/apache/cloudstack/api/response/VpcResponse.java +++ b/api/src/org/apache/cloudstack/api/response/VpcResponse.java @@ -19,14 +19,14 @@ package org.apache.cloudstack.api.response; import java.util.Date; import java.util.List; -import com.google.gson.annotations.SerializedName; - +import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.EntityReference; import com.cloud.network.vpc.Vpc; import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; @EntityReference(value = Vpc.class) @SuppressWarnings("unused") @@ -107,6 +107,18 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons @Param(description = "the list of resource tags associated with the project", responseObject = ResourceTagResponse.class) private List tags; + @SerializedName(ApiConstants.FOR_DISPLAY) + @Param(description = "is vpc for display to the regular user", since = "4.4", authorized = {RoleType.Admin}) + private Boolean forDisplay; + + @SerializedName(ApiConstants.DISTRIBUTED_VPC_ROUTER) + @Param(description = "is VPC uses distributed router for one hop forwarding and host based network ACL's", since = "4.4") + private boolean usesDistributedRouter; + + @SerializedName((ApiConstants.REGION_LEVEL_VPC)) + @Param(description = "true if VPC is region level", since = "4.4") + private Boolean regionLevelVpc; + public void setId(String id) { this.id = id; } @@ -191,4 +203,16 @@ public class VpcResponse extends BaseResponse implements ControlledEntityRespons public void setTags(List tags) { this.tags = tags; } + + public void setForDisplay(Boolean forDisplay) { + this.forDisplay = forDisplay; + } + + public void setRegionLevelVpc(Boolean regionLevelVpc) { + this.regionLevelVpc = regionLevelVpc; + } + + public void setUsesDistributedRouter(Boolean usesDistributedRouter) { + this.usesDistributedRouter = usesDistributedRouter; + } } diff --git a/api/src/org/apache/cloudstack/config/ApiServiceConfiguration.java b/api/src/org/apache/cloudstack/config/ApiServiceConfiguration.java index edf5a21b673..94c0a55de6a 100644 --- a/api/src/org/apache/cloudstack/config/ApiServiceConfiguration.java +++ b/api/src/org/apache/cloudstack/config/ApiServiceConfiguration.java @@ -24,7 +24,7 @@ import org.apache.cloudstack.framework.config.Configurable; @Local(value = {ApiServiceConfiguration.class}) public class ApiServiceConfiguration implements Configurable { public static final ConfigKey ManagementHostIPAdr = new ConfigKey("Advanced", String.class, "host", "localhost", "The ip address of management server", true); - public static final ConfigKey ApiServletPath = new ConfigKey("Advanced", String.class, "api.servlet.endpoint", "http://localhost:8080/client/api?", + public static final ConfigKey ApiServletPath = new ConfigKey("Advanced", String.class, "endpointe.url", "http://localhost:8080/client/api", "API end point. Can be used by CS components/services deployed remotely, for sending CS API requests", true); @Override diff --git a/api/src/org/apache/cloudstack/context/CallContext.java b/api/src/org/apache/cloudstack/context/CallContext.java index dbeb5c7ea21..661b01dd55c 100644 --- a/api/src/org/apache/cloudstack/context/CallContext.java +++ b/api/src/org/apache/cloudstack/context/CallContext.java @@ -55,6 +55,7 @@ public class CallContext { private String eventDescription; private String eventDetails; private String eventType; + private boolean isEventDisplayEnabled = true; // default to true unless specifically set private User user; private long userId; private final Map context = new HashMap(); @@ -131,7 +132,10 @@ public class CallContext { protected static CallContext register(User callingUser, Account callingAccount, Long userId, Long accountId, String contextId) { /* +<<<<<<< HEAD Unit tests will have multiple times of setup/tear-down call to this, remove assertions to all unit test to run +======= +>>>>>>> a7a8a19... BUG-ID: CS-19295: add job path to help associate an API job to related internal job. Reviewed-By: Self assert s_currentContext.get() == null : "There's a context already so what does this new register context mean? " + s_currentContext.get().toString(); if (s_currentContext.get() != null) { // FIXME: This should be removed soon. I added this check only to surface all the places that have this problem. throw new CloudRuntimeException("There's a context already so what does this new register context mean? " + s_currentContext.get().toString()); @@ -154,6 +158,14 @@ public class CallContext { return callingContext; } + public static CallContext registerPlaceHolderContext() { + CallContext context = new CallContext(0, 0, UUID.randomUUID().toString()); + s_currentContext.set(context); + + s_currentContextStack.get().push(context); + return context; + } + public static CallContext register(User callingUser, Account callingAccount) { return register(callingUser, callingAccount, UUID.randomUUID().toString()); } @@ -228,7 +240,7 @@ public class CallContext { String sessionIdOnStack = null; String sessionIdPushedToNDC = "ctx-" + UuidUtils.first(contextId); while ((sessionIdOnStack = NDC.pop()) != null) { - if (sessionIdPushedToNDC.equals(sessionIdOnStack)) { + if (sessionIdOnStack.isEmpty() || sessionIdPushedToNDC.equals(sessionIdOnStack)) { break; } if (s_logger.isTraceEnabled()) { @@ -241,6 +253,8 @@ public class CallContext { if (!stack.isEmpty()) { s_currentContext.set(stack.peek()); + } else { + s_currentContext.set(null); } return context; @@ -290,6 +304,18 @@ public class CallContext { this.eventDescription = eventDescription; } + /** + * Whether to display the event to the end user. + * @return true - if the event is to be displayed to the end user, false otherwise. + */ + public boolean isEventDisplayEnabled() { + return isEventDisplayEnabled; + } + + public void setEventDisplayEnabled(boolean eventDisplayEnabled) { + isEventDisplayEnabled = eventDisplayEnabled; + } + public static void setActionEventInfo(String eventType, String description) { CallContext context = CallContext.current(); if (context != null) { diff --git a/api/src/org/apache/cloudstack/context/CallContextListener.java b/api/src/org/apache/cloudstack/context/CallContextListener.java index 49866e07733..ab9a8c30046 100644 --- a/api/src/org/apache/cloudstack/context/CallContextListener.java +++ b/api/src/org/apache/cloudstack/context/CallContextListener.java @@ -32,10 +32,9 @@ public class CallContextListener implements ManagedContextListener { @Override public Object onEnterContext(boolean reentry) { - if (!reentry) { + if (!reentry && CallContext.current() == null) { CallContext.registerSystemCallContextOnceOnly(); } - return null; } diff --git a/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java index 4908918c539..a05e9f4bf15 100644 --- a/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java +++ b/api/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerService.java @@ -30,7 +30,7 @@ import com.cloud.utils.Pair; public interface ApplicationLoadBalancerService { ApplicationLoadBalancerRule createApplicationLoadBalancer(String name, String description, Scheme scheme, long sourceIpNetworkId, String sourceIp, int sourcePort, - int instancePort, String algorithm, long networkId, long lbOwnerId) throws InsufficientAddressCapacityException, NetworkRuleConflictException, + int instancePort, String algorithm, long networkId, long lbOwnerId, Boolean forDisplay) throws InsufficientAddressCapacityException, NetworkRuleConflictException, InsufficientVirtualNetworkCapcityException; boolean deleteApplicationLoadBalancer(long id); @@ -39,4 +39,6 @@ public interface ApplicationLoadBalancerService { ApplicationLoadBalancerRule getApplicationLoadBalancer(long ruleId); + ApplicationLoadBalancerRule updateApplicationLoadBalancer(Long id, String customId, Boolean forDisplay); + } diff --git a/api/src/org/apache/cloudstack/query/QueryService.java b/api/src/org/apache/cloudstack/query/QueryService.java index 65a6b064b7c..01af631f129 100644 --- a/api/src/org/apache/cloudstack/query/QueryService.java +++ b/api/src/org/apache/cloudstack/query/QueryService.java @@ -18,6 +18,10 @@ package org.apache.cloudstack.query; import java.util.List; +import org.apache.cloudstack.affinity.AffinityGroupResponse; +import org.apache.cloudstack.api.command.admin.host.ListHostsCmd; +import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd; +import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd; import org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd; import org.apache.cloudstack.api.command.admin.storage.ListSecondaryStagingStoresCmd; import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd; @@ -38,11 +42,7 @@ import org.apache.cloudstack.api.command.user.vm.ListVMsCmd; import org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd; import org.apache.cloudstack.api.command.user.volume.ListResourceDetailsCmd; import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd; -import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd; -import org.apache.cloudstack.affinity.AffinityGroupResponse; -import org.apache.cloudstack.api.command.admin.host.ListHostsCmd; -import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd; -import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd; +import org.apache.cloudstack.api.command.user.zone.ListZonesCmd; import org.apache.cloudstack.api.response.AccountResponse; import org.apache.cloudstack.api.response.AsyncJobResponse; import org.apache.cloudstack.api.response.DiskOfferingResponse; @@ -106,13 +106,13 @@ public interface QueryService { public ListResponse searchForAccounts(ListAccountsCmd cmd); - public ListResponse searchForAsyncJobs(ListAsyncJobsCmd cmd); + public ListResponse searchForAsyncJobs(ListAsyncJobsCmd cmd); - public ListResponse searchForDiskOfferings(ListDiskOfferingsCmd cmd); + public ListResponse searchForDiskOfferings(ListDiskOfferingsCmd cmd); - public ListResponse searchForServiceOfferings(ListServiceOfferingsCmd cmd); + public ListResponse searchForServiceOfferings(ListServiceOfferingsCmd cmd); - public ListResponse listDataCenters(ListZonesByCmd cmd); + public ListResponse listDataCenters(ListZonesCmd cmd); public ListResponse listTemplates(ListTemplatesCmd cmd); diff --git a/api/test/org/apache/cloudstack/api/BaseCmdTest.java b/api/test/org/apache/cloudstack/api/BaseCmdTest.java new file mode 100644 index 00000000000..edf5776d2b3 --- /dev/null +++ b/api/test/org/apache/cloudstack/api/BaseCmdTest.java @@ -0,0 +1,69 @@ +// 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 org.apache.cloudstack.api; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +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; + +public class BaseCmdTest { + + private static final String NON_EXPECTED_COMMAND_NAME = "Non expected command name"; + protected static final String CMD1_NAME = "Cmd1Name"; + protected static final String CMD2_NAME = "Cmd2Name"; + protected static final String CMD1_RESPONSE = "cmd1response"; + protected static final String CMD2_RESPONSE = "cmd2response"; + + @Test + public void testGetActualCommandName(){ + BaseCmd cmd1 = new Cmd1(); + BaseCmd cmd2 = new Cmd2(); + + assertEquals(NON_EXPECTED_COMMAND_NAME, CMD1_NAME, cmd1.getActualCommandName()); + assertEquals(NON_EXPECTED_COMMAND_NAME, CMD2_NAME, cmd2.getActualCommandName()); + } +} + +@APICommand(name=BaseCmdTest.CMD1_NAME, responseObject=BaseResponse.class) +class Cmd1 extends BaseCmd { + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, + NetworkRuleConflictException { + } + @Override + public String getCommandName() { + return BaseCmdTest.CMD1_RESPONSE; + } + @Override + public long getEntityOwnerId() { + return 0; + } +} + +@APICommand(name=BaseCmdTest.CMD2_NAME, responseObject=BaseResponse.class) +class Cmd2 extends Cmd1 { + @Override + public String getCommandName() { + return BaseCmdTest.CMD2_RESPONSE; + } +} diff --git a/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java b/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java index 0c03e39b5d9..3ed1d9389d4 100644 --- a/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java +++ b/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java @@ -29,6 +29,7 @@ import org.junit.rules.ExpectedException; import org.mockito.Mockito; import org.apache.cloudstack.api.ResponseGenerator; +import org.apache.cloudstack.api.ResponseObject.ResponseView; import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd; import org.apache.cloudstack.api.response.UserVmResponse; @@ -85,7 +86,8 @@ public class ScaleVMCmdTest extends TestCase { List list = new LinkedList(); list.add(userVmResponse); - Mockito.when(responseGenerator.createUserVmResponse("virtualmachine", userVm)).thenReturn(list); + Mockito.when(responseGenerator.createUserVmResponse(ResponseView.Restricted, "virtualmachine", userVm)).thenReturn( + list); scaleVMCmd._userVmService = userVmService; diff --git a/awsapi/findbugsExcludeFilter.xml b/awsapi/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/awsapi/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/awsapi/pom.xml b/awsapi/pom.xml index 4a6c89c9e5f..edf9a918982 100644 --- a/awsapi/pom.xml +++ b/awsapi/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT @@ -126,94 +126,6 @@ CAStorSDK 1.3.1-CS40 - - org.apache.rampart - rahas - ${cs.rampart.version} - mar - - - bouncycastle - bcprov-jdk14 - - - org.apache.xalan - xalan - - - org.opensaml - opensaml1 - - - - - org.apache.rampart - rampart - ${cs.rampart.version} - mar - - - bouncycastle - bcprov-jdk14 - - - org.apache.xalan - xalan - - - org.opensaml - opensaml1 - - - - - org.apache.rampart - rampart-core - ${cs.rampart.version} - runtime - - - org.apache.xalan - xalan - - - org.opensaml - opensaml1 - - - - - org.apache.rampart - rampart-policy - ${cs.rampart.version} - runtime - - - org.apache.xalan - xalan - - - org.opensaml - opensaml1 - - - - - org.apache.rampart - rampart-trust - ${cs.rampart.version} - runtime - - - org.apache.xalan - xalan - - - org.opensaml - opensaml1 - - - org.slf4j slf4j-jdk14 @@ -272,11 +184,6 @@ bcprov-jdk16 runtime - - mysql - mysql-connector-java - runtime - org.antlr antlr-runtime diff --git a/awsapi/src/com/cloud/bridge/io/DimeDelimitedInputStream.java b/awsapi/src/com/cloud/bridge/io/DimeDelimitedInputStream.java index 0f40c934de2..d901c53aebe 100644 --- a/awsapi/src/com/cloud/bridge/io/DimeDelimitedInputStream.java +++ b/awsapi/src/com/cloud/bridge/io/DimeDelimitedInputStream.java @@ -354,13 +354,19 @@ public class DimeDelimitedInputStream extends FilterInputStream { } //OPTIONS_LENGTH - int optionsLength = ((((int)header[2]) << 8) & 0xff00) | ((int)header[3]); + int oneButLastByte = (((int)header[2]) << 8) & 0xff00; + int lastByte = (int)header[3] & 0xff; + int optionsLength = oneButLastByte | lastByte; //ID_LENGTH - int idLength = ((((int)header[4]) << 8) & 0xff00) | ((int)header[5]); + oneButLastByte = ((((int)header[4]) << 8) & 0xff00); + lastByte = ((int)header[5]) & 0xff; + int idLength = oneButLastByte | lastByte; //TYPE_LENGTH - int typeLength = ((((int)header[6]) << 8) & 0xff00) | ((int)header[7]); + oneButLastByte = ((((int)header[6]) << 8) & 0xff00); + lastByte = ((int)header[7]) & 0xff; + int typeLength = oneButLastByte | lastByte; //DATA_LENGTH recordLength = diff --git a/awsapi/src/com/cloud/bridge/model/SObjectItemVO.java b/awsapi/src/com/cloud/bridge/model/SObjectItemVO.java index 5eada3c136d..77077c6a2b6 100644 --- a/awsapi/src/com/cloud/bridge/model/SObjectItemVO.java +++ b/awsapi/src/com/cloud/bridge/model/SObjectItemVO.java @@ -168,7 +168,7 @@ public class SObjectItemVO { } if (theObject.getId() != null) { - if (!theObject.getId().equals(((SObjectItemVO)other).getTheObject())) + if (!theObject.getId().equals(((SObjectItemVO)other).getTheObject().getId())) return false; } else { if (((SObjectItemVO)other).getTheObject() != null) diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java index dac18e42d20..a1e8171537b 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java +++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java @@ -999,7 +999,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { if (null != fst) { String[] timeFilters = new String[1]; - timeFilters[0] = new String("start-time"); + timeFilters[0] = "start-time"; request = toSnapshotFilterSet(request, fst, timeFilters); } @@ -1035,8 +1035,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { if (null != fst) { String[] timeFilters = new String[2]; - timeFilters[0] = new String("attachment.attach-time"); - timeFilters[1] = new String("create-time"); + timeFilters[0] = "attachment.attach-time"; + timeFilters[1] = "create-time"; request = toVolumeFilterSet(request, fst, timeFilters); } @@ -1977,6 +1977,7 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { DescribeAddressesResponseItemType item = new DescribeAddressesResponseItemType(); item.setPublicIp(addr.getIpAddress()); item.setInstanceId(addr.getAssociatedInstanceId()); + item.setDomain("standard"); // Since VPC is not supported by AWSAPI default to 'standard' items.add(item); } DescribeAddressesResponseInfoType descAddrRespInfoType = new DescribeAddressesResponseInfoType(); @@ -2069,24 +2070,24 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { public static String toAmazonStateName(String cloudState) { if (null == cloudState) - return new String("terminated"); + return "terminated"; if (cloudState.equalsIgnoreCase("Destroyed")) - return new String("terminated"); + return "terminated"; else if (cloudState.equalsIgnoreCase("Stopped")) - return new String("stopped"); + return "stopped"; else if (cloudState.equalsIgnoreCase("Running")) - return new String("running"); + return "running"; else if (cloudState.equalsIgnoreCase("Starting")) - return new String("pending"); + return "pending"; else if (cloudState.equalsIgnoreCase("Stopping")) - return new String("stopping"); + return "stopping"; else if (cloudState.equalsIgnoreCase("Error")) - return new String("error"); + return "error"; else if (cloudState.equalsIgnoreCase("Expunging")) - return new String("terminated"); + return "terminated"; else - return new String("running"); + return "running"; } public static StopInstancesResponse toStopInstancesResponse(EC2StopInstancesResponse engineResponse) { diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java index ef7539f7350..cd202145402 100644 --- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java +++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java @@ -2233,9 +2233,9 @@ public class EC2Engine extends ManagerBase { perm.setProtocol(rule.getProtocol()); perm.setFromPort(rule.getStartPort()); perm.setToPort(rule.getEndPort()); - perm.setRuleId(rule.getRuleId() != null ? rule.getRuleId().toString() : new String()); - perm.setIcmpCode(rule.getIcmpCode() != null ? rule.getIcmpCode().toString() : new String()); - perm.setIcmpType(rule.getIcmpType() != null ? rule.getIcmpType().toString() : new String()); + perm.setRuleId(rule.getRuleId() != null ? rule.getRuleId().toString() : ""); + perm.setIcmpCode(rule.getIcmpCode() != null ? rule.getIcmpCode().toString() : ""); + perm.setIcmpType(rule.getIcmpType() != null ? rule.getIcmpType().toString() : ""); perm.setCIDR(rule.getCidr()); perm.addIpRange(rule.getCidr()); diff --git a/awsapi/src/com/cloud/bridge/util/EC2RestAuth.java b/awsapi/src/com/cloud/bridge/util/EC2RestAuth.java index d2f4b1e1b08..33368c10fe5 100644 --- a/awsapi/src/com/cloud/bridge/util/EC2RestAuth.java +++ b/awsapi/src/com/cloud/bridge/util/EC2RestAuth.java @@ -120,7 +120,7 @@ public class EC2RestAuth { public void setHTTPRequestURI(String uri) { if (null == uri || 0 == uri.length()) - this.httpRequestURI = new String("/"); + this.httpRequestURI = "/"; else this.httpRequestURI = uri.trim(); } diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index f1c166bda11..8abe874a299 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -14,11 +14,13 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +label.reinstall.vm=Reinstall VM +message.reinstall.vm=NOTE: Proceed with caution. This will cause the VM to be reinstalled from the template; data on the root disk will be lost. Extra data volumes, if any, will not be touched. +label.recover.vm=Recover VM +message.recover.vm=Please confirm that you would like to recover this VM. label.port=Port label.remove.ldap=Remove LDAP -message.remove.ldap=Are you sure you want to delete the LDAP configuration? label.configure.ldap=Configure LDAP -message.configure.ldap=Please confirm you would like to configure LDAP. label.ldap.configuration=LDAP Configuration label.ldap.port=LDAP port label.create.nfs.secondary.staging.store=Create NFS secondary staging store @@ -603,6 +605,7 @@ label.full=Full label.gateway=Gateway label.general.alerts=General Alerts label.generating.url=Generating URL +label.gluster.volume=Volume label.go.step.2=Go to Step 2 label.go.step.3=Go to Step 3 label.go.step.4=Go to Step 4 @@ -946,6 +949,7 @@ label.project.view=Project View label.project=Project label.projects=Projects label.protocol=Protocol +label.provider=Provider label.providers=Providers label.public.interface=Public Interface label.public.ip=Public IP Address @@ -1269,11 +1273,218 @@ label.zoneWizard.trafficType.management=Management\: Traffic between CloudStack\ label.zoneWizard.trafficType.public=Public\: Traffic between the internet and virtual machines in the cloud. label.zoneWizard.trafficType.storage=Storage\: Traffic between primary and secondary storage servers, such as VM templates and snapshots label.ldap.group.name=LDAP Group +label.password.reset.confirm=Password has been reset to +label.provider=Provider +label.resetVM=Reset VM label.openDaylight=OpenDaylight +label.assign.instance.another=Assign Instance to Another Account +label.network.addVM=Add network to VM +label.set.default.NIC=Set default NIC +label.Xenserver.Tools.Version61plus=XenServer Tools Version 6.1\+ +label.dynamically.scalable=Dynamically Scalable +label.instance.scaled.up=Instance Scaled Up +label.tag.key=Tag Key +label.tag.value=Tag Value +label.ipv6.address=IPv6 IP Address +label.ipv6.gateway=IPv6 Gateway +label.ipv6.CIDR=IPv6 CIDR +label.VPC.limits=VPC limits +label.edit.region=Edit Region +label.gslb.domain.name=GSLB Domain Name +label.add.gslb=Add GSLB +label.gslb.servicetype=Service Type +label.gslb.details=GSLB details +label.gslb.delete=delete GSLB +label.opendaylight.controller=OpenDaylight Controller label.opendaylight.controllers=OpenDaylight Controllers +label.portable.ip.ranges=Portable IP Ranges +label.add.portable.ip.range=Add Portable IP Range +label.delete.portable.ip.range=Delete Portable IP Range label.opendaylight.controllerdetail=OpenDaylight Controller Details +label.portable.ip.range.details=Portable IP Range details +label.portable.ips=Portable IPs +label.gslb.assigned.lb=assigned load balancing +label.gslb.assigned.lb.more=assign more load balancing +label.gslb.lb.rule=load balancing rule +label.gslb.lb.details=load balancing details +label.gslb.lb.remove=remove load balancing from this GSLB +label.enable.autoscale=Enable Autoscale +label.disable.autoscale=Disable Autoscale +label.min.instances=Min Instances +label.max.instances=Max Instances label.add.OpenDaylight.device=Add OpenDaylight Controller +label.show.advanced.settings=Show advanced settings label.delete.OpenDaylight.device=Delete OpenDaylight Controller +label.polling.interval.sec=Polling Interval (in sec) +label.quiet.time.sec=Quiet Time (in sec) +label.destroy.vm.graceperiod=Destroy VM Grace Period +label.SNMP.community=SNMP Community +label.SNMP.port=SNMP Port +label.add.ucs.manager=Add UCS Manager +label.ovm.traffic.label=OVM traffic label +label.lxc.traffic.label=LXC Traffic Label +label.hyperv.traffic.label=HyperV Traffic Label +label.resource.name=Resource Name +label.reource.id=Resource ID +label.vnmc.devices=VNMC Devices +label.add.vnmc.provider=Add VNMC provider +label.enable.vnmc.provider=Enable VNMC provider +label.add.vnmc.device=Add VNMC device +label.ciscovnmc.resource.details=CiscoVNMC resource details +label.delete.ciscovnmc.resource=delete CiscoVNMC resource +label.enable.vnmc.device=Enable VNMC device +label.disbale.vnmc.device=Disable VNMC device +label.disable.vnmc.provider=Disable VNMC provider +label.services=Services +label.secondary.staging.store=Secondary Staging Store +label.release.account=Release from Account +label.release.account.lowercase=release from account +label.vlan.vni.ranges=VLAN/VNI Range(s) +label.dedicated.vlan.vni.ranges=Dedicated VLAN/VNI Ranges +label.dedicate.vlan.vni.range=Dedicate VLAN/VNI Range +label.vlan.vni.range=VLAN/VNI Range +label.vlan.range.details=VLAN Range details +label.release.dedicated.vlan.range=Release dedicated VLAN range +label.broadcat.uri=broadcast URI +label.ipv4.cidr=IPv4 CIDR +label.guest.network.details=Guest network details +label.ipv4.gateway=IPv4 Gateway +label.release.dedicated.vlan.range=Release dedicated VLAN range +label.vlan.ranges=VLAN Range(s) +label.virtual.appliance.details=Virtual applicance details +label.start.lb.vm=Start LB VM +label.stop.lb.vm=Stop LB VM +label.migrate.lb.vm=Migrate LB VM +label.vpc.virtual.router=VPC Virtual Router +label.ovs=OVS +label.gslb.service=GSLB service +label.gslb.service.public.ip=GSLB service Public IP +label.gslb.service.private.ip=GSLB service Private IP +label.baremetal.dhcp.provider=Baremetal DHCP Provider +label.add.baremetal.dhcp.device=Add Baremetal DHCP Device +label.baremetal.pxe.provider=Baremetal PXE Provider +label.baremetal.pxe.device=Add Baremetal PXE Device +label.tftp.root.directory=Tftp root directory +label.add.vmware.datacenter=Add VMware datacenter +label.remove.vmware.datacenter=Remove VMware datacenter +label.dc.name=DC Name +label.vcenter=vcenter +label.dedicate.zone=Dedicate Zone +label.zone.dedicated=Zone Dedicated +label.release.dedicated.zone=Release Dedicated Zone +label.ipv6.dns1=IPv6 DNS1 +label.ipv6.dns2=IPv6 DNS2 +label.vmware.datacenter.name=VMware datacenter Name +label.vmware.datacenter.vcenter=VMware datacenter vcenter +label.vmware.datacenter.id=VMware datacenter ID +label.system.vm.details=System VM details +label.system.vm.scaled.up=System VM Scaled Up +label.console.proxy.vm=Console Proxy VM +label.settings=Settings +label.requires.upgrade=Requires Upgrade +label.upgrade.router.newer.template=Upgrade Router to Use Newer Template +label.router.vm.scaled.up=Router VM Scaled Up +label.total.virtual.routers=Total of Virtual Routers +label.upgrade.required=Upgrade is required +label.virtual.routers.group.zone=Virtual Routers group by zone +label.total.virtual.routers.upgrade=Total of Virtual Routers that require upgrade +label.virtual.routers.group.pod=Virtual Routers group by pod +label.virtual.routers.group.cluster=Virtual Routers group by cluster +label.zone.lower=zone +label.virtual.routers.group.account=Virtual Routers group by account +label.netscaler.details=NetScaler details +label.baremetal.dhcp.devices=Baremetal DHCP Devices +label.baremetal.pxe.devices=Baremetal PXE Devices +label.addes.new.f5=Added new F5 +label.f5.details=F5 details +label.srx.details=SRX details +label.palo.alto.details=Palo Alto details +label.added.nicira.nvp.controller=Added new Nicira NVP Controller\ +label.nicira.nvp.details=Nicira NVP details +label.added.new.bigswitch.vns.controller=Added new BigSwitch VNS Controller +label.bigswitch.vns.details=BigSwitch VNS details +label.dedicate=Dedicate +label.dedicate.pod=Dedicate Pod +label.pod.dedicated=Pod Dedicated +label.release.dedicated.pod=Release Dedicated Pod +label.override.public.traffic=Override Public-Traffic +label.public.traffic.vswitch.type=Public Traffic vSwitch Type +label.public.traffic.vswitch.name=Public Traffic vSwitch Name +label.override.guest.traffic=Override Guest-Traffic +label.guest.traffic.vswitch.type=Guest Traffic vSwitch Type +label.guest.traffic.vswitch.name=Guest Traffic vSwitch Name +label.cisco.nexus1000v.ip.address=Nexus 1000v IP Address +label.cisco.nexus1000v.username=Nexus 1000v Username +label.cisco.nexus1000v.password=Nexus 1000v Password +label.dedicate.cluster=Dedicate Cluster +label.release.dedicated.cluster=Release Dedicated Cluster +label.dedicate.host=Dedicate Host +label.release.dedicated.host=Release Dedicated Host +label.number.of.cpu.sockets=The Number of CPU Sockets +label.delete.ucs.manager=Delete UCS Manager +label.blades=Blades +label.chassis=Chassis +label.blade.id=Blade ID +label.associated.profile=Associated Profile +label.refresh.blades=Refresh Blades +label.instanciate.template.associate.profile.blade=Instanciate Template and Associate Profile to Blade +label.select.template=Select Template +label.profile=Profile +label.delete.profile=Delete Profile +label.disassociate.profile.blade=Disassociate Profile from Blade +label.secondary.storage.details=Secondary storage details +label.secondary.staging.store.details=Secondary Staging Store details +label.add.nfs.secondary.staging.store=Add NFS Secondary Staging Store +label.delete.secondary.staging.store=Delete Secondary Staging Store +label.ipv4.start.ip=IPv4 Start IP +label.ipv4.end.ip=IPv4 End IP +label.ipv6.start.ip=IPv6 Start IP +label.ipv6.end.ip=IPv6 End IP +label.vm.password=Password of the VM is +label.group.by.zone=group by zone +label.group.by.pod=group by pod +label.group.by.cluster=group by cluster +label.group.by.account=group by account +label.no.grouping=(no grouping) +label.create.nfs.secondary.staging.storage=Create NFS Secondary Staging Store +label.username.lower=username +label.password.lower=password +label.email.lower=email +label.firstname.lower=firstname +label.lastname.lower=lastname +label.domain.lower=domain +label.account.lower=account +label.type.lower=type +label.rule.number=Rule Number +label.action=Action +label.name.lower=name +label.ucs=UCS +label.change.affinity=Change Affinity +label.persistent=Persistent +label.broadcasturi=broadcasturi +label.network.cidr=Network CIDR +label.reserved.ip.range=Reserved IP Range +label.autoscale=AutoScale +label.health.check=Health Check +label.public.load.balancer.provider=Public Load Balancer Provider +label.add.isolated.network=Add Isolated Network +label.vlan=VLAN +label.secondary.isolated.vlan.id=Secondary Isolated VLAN ID +label.ipv4.netmask=IPv4 Netmask +label.custom=Custom +label.disable.network.offering=Disable network offering +label.enable.network.offering=Enable network offering +label.remove.network.offering=Remove network offering +label.system.offering.for.router=System Offering for Router +label.mode=Mode +label.associate.public.ip=Associate Public IP +label.acl=ACL +label.user.data=User Data +label.virtual.networking=Virtual Networking +label.allow=Allow +label.deny=Deny +label.default.egress.policy=Default egress policy +label.xenserver.tools.version.61.plus=XenServer Tools Version 6.1\+ managed.state=Managed State message.acquire.new.ip.vpc=Please confirm that you would like to acquire a new IP for this VPC. message.acquire.new.ip=Please confirm that you would like to acquire a new IP for this network. @@ -1573,7 +1784,7 @@ message.tooltip.reserved.system.netmask=The network prefix that defines the pod message.tooltip.zone.name=A name for the zone. message.update.os.preference=Please choose a OS preference for this host. All virtual instances with similar preferences will be first allocated to this host before choosing another. message.update.resource.count=Please confirm that you want to update resource counts for this account. -message.update.ssl=Please submit a new X.509 compliant SSL certificate to be updated to each console proxy virtual instance\: +message.update.ssl=Please submit a new X.509 compliant SSL certificate to be updated to each console proxy and secondary storage virtual instance\: message.validate.instance.name=Instance name can not be longer than 63 characters. Only ASCII letters a~z, A~Z, digits 0~9, hyphen are allowed. Must start with a letter and end with a letter or a digit. message.virtual.network.desc=A dedicated virtualized network for your account. The broadcast domain is contained within a VLAN and all public network access is routed out by a virtual router. message.vm.create.template.confirm=Create Template will reboot the VM automatically. @@ -1586,7 +1797,91 @@ message.zone.no.network.selection=The zone you selected does not have any choice message.zone.step.1.desc=Please select a network model for your zone. message.zone.step.2.desc=Please enter the following info to add a new zone message.zone.step.3.desc=Please enter the following info to add a new pod -message.zoneWizard.enable.local.storage=WARNING\: If you enable local storage for this zone, you must do the following, depending on where you would like your system VMs to launch\:

1. If system VMs need to be launched in primary storage, primary storage needs to be added to the zone after creation. You must also start the zone in a disabled state.

2. If system VMs need to be launched in local storage, system.vm.use.local.storage needs to be set to true before you enable the zone.


Would you like to continue? +message.zoneWizard.enable.local.storage=WARNING\: If you enable local storage for this zone, you must do the following, depending on where you would like your system VMs to launch\:

1. If system VMs need to be launched in shared primary storage, shared primary storage needs to be added to the zone after creation. You must also start the zone in a disabled state.

2. If system VMs need to be launched in local primary storage, system.vm.use.local.storage needs to be set to true before you enable the zone.


Would you like to continue? +message.validate.fieldrequired=This field is required. +message.validate.fixfield=Please fix this field. +message.validate.email.address=Please enter a valid email address. +message.validate.URL=Please enter a valid URL. +message.validate.date=Please enter a valid date. +message.validate.date.ISO=Please enter a valid date (ISO). +message.validate.number=Please enter a valid number. +message.validate.digits=Please enter only digits. +message.validate.creditcard=Please enter a valid credit card number. +message.validate.equalto=Please enter the same value again. +message.validate.accept=Please enter a value with a valid extension. +message.validate.maxlength=Please enter no more than {0} characters. +message.validate.minlength=Please enter at least {0} characters. +message.validate.range.length=Please enter a value between {0} and {1} characters long. +message.validate.range=Please enter a value between {0} and {1}. +message.validate.max=Please enter a value less than or equal to {0}. +messgae.validate.min=Please enter a value greater than or equal to {0}. +message.creating.systemVM=Creating system VMs (this may take a while) +message.enabling.zone.dots=Enabling zone... +message.restoreVM=Do you want to restore the VM ? +message.no.host.available=No Hosts are available for Migration +message.network.addVM.desc=Please specify the network that you would like to add this VM to. A new NIC will be added for this network. +message.network.addVMNIC=Please confirm that you would like to add a new VM NIC for this network. +message.set.default.NIC=Please confirm that you would like to make this NIC the default for this VM. +message.set.default.NIC.manual=Please manually update the default NIC on the VM now. +message.instance.scaled.up.confirm=Do you really want to scale Up your instance ? +message.copy.template.confirm=Are you sure you want to copy template? +message.template.copying=Template is being copied. +message.XSTools61plus.update.failed=Failed to update XenServer Tools Version 6.1\+ field. Error\: +message.gslb.delete.confirm=Please confirm you want to delete this GSLB +message.portable.ip.delete.confirm=Please confirm you want to delete Portable IP Range +message.gslb.lb.remove.confirm=Please confirm you want to remove load balancing from GSLB +message.admin.guide.read=For VMware-based VMs, please read the dynamic scaling section in the admin guide before scaling. Would you like to continue?\, +message.tier.required=Tier is required +message.remove.ldap=Are you sure you want to delete the LDAP configuration? +message.action.downloading.template=Downloading template. +message.configure.ldap=Please confirm you would like to configure LDAP. +message.confirm.delete.ciscovnmc.resource=Please confirm you want to delete CiscoVNMC resource +message.confirm.add.vnmc.provider=Please confirm you would like to add the VNMC provider. +message.confirm.enable.vnmc.provider=Please confirm you would like to enable the VNMC provider. +message.confirm.disable.vnmc.provider=Please confirm you would like to disable the VNMC provider. +message.vnmc.available.list=VNMC is not available from provider list. +message.vnmc.not.available.list=VNMC is not available from provider list. +message.confirm.release.dedicate.vlan.range=Please confirm you want to release dedicated VLAN range +message.confirm.start.lb.vm=Please confirm you want to start LB VM +message.confirm.stop.lb.vm=Please confirm you want to stop LB VM +message.confirm.remove.vmware.datacenter=Please confirm you want to remove VMware datacenter +message.confirm.dedicate.zone=Do you really want to dedicate this zone to a domain/account? +message.confirm.release.dedicated.zone=Do you want to release this dedicated zone ? +message.dedicated.zone.released=Zone dedication released +message.read.admin.guide.scaling.up=Please read the dynamic scaling section in the admin guide before scaling up. +message.confirm.scale.up.system.vm=Do you really want to scale up the system VM ? +message.confirm.upgrade.router.newer.template=Please confirm that you want to upgrade router to use newer template +message.confirm.scale.up.router.vm=Do you really want to scale up the Router VM ? +message.confirm.upgrade.routers.newtemplate=Please confirm that you want to upgrade all routers in this zone to use newer template +message.confirm.upgrade.routers.pod.newtemplate=Please confirm that you want to upgrade all routers in this pod to use newer template +message.confirm.upgrade.routers.cluster.newtemplate=Please confirm that you want to upgrade all routers in this cluster to use newer template +message.confirm.upgrade.routers.account.newtemplate=Please confirm that you want to upgrade all routers in this account to use newer template +message.confirm.dedicate.pod.domain.account=Do you really want to dedicate this pod to a domain/account? +message.confirm.release.dedicated.pod=Do you want to release this dedicated pod ? +message.pod.dedication.released=Pod dedication released +message.confirm.dedicate.cluster.domain.account=Do you really want to dedicate this cluster to a domain/account? +message.cluster.dedicated=Cluster Dedicated +message.confirm.release.dedicated.cluster=Do you want to release this dedicated cluster ? +message.cluster.dedication.released=Cluster dedication released +message.confirm.dedicate.host.domain.account=Do you really want to dedicate this host to a domain/account? +message.host.dedicated=Host Dedicated +message.confirm.release.dedicated.host=Do you want to release this dedicated host ? +message.host.dedication.released=Host dedication released +message.confirm.delete.ucs.manager=Please confirm that you want to delete UCS Manager +message.confirm.refresh.blades=Please confirm that you want to refresh blades. +message.confirm.delete.secondary.staging.store=Please confirm you want to delete Secondary Staging Store. +message.select.tier=Please select a tier +message.disallowed.characters=Disallowed characters: \<\,\> +message.waiting.for.builtin.templates.to.load=Waiting for builtin templates to load... +message.systems.vms.ready=System VMs ready. +message.your.cloudstack.is.ready=Your CloudStack is ready\! +message.specifiy.tag.key.value=Please specify a tag key and value +message.enter.seperated.list.multiple.cidrs=Please enter a comma separated list of CIDRs if more than one +message.disabling.network.offering=Disabling network offering +message.confirm.enable.network.offering=Are you sure you want to enable this network offering? +message.enabling.network.offering=Enabling network offering +message.confirm.remove.network.offering=Are you sure you want to remove this network offering? +message.confirm.disable.network.offering=Are you sure you want to disable this network offering? mode=Mode network.rate=Network Rate notification.reboot.instance=Reboot instance diff --git a/client/WEB-INF/classes/resources/messages_es.properties b/client/WEB-INF/classes/resources/messages_es.properties index 31a9c93646c..6d6e4860cf4 100644 --- a/client/WEB-INF/classes/resources/messages_es.properties +++ b/client/WEB-INF/classes/resources/messages_es.properties @@ -22,7 +22,6 @@ error.session.expired=Su sesi\u00c3\u00b3n ha caducado. error.unresolved.internet.name=El nombre de Internet no se puede resolver. extractable=extra\u00c3\u00adble force.delete.domain.warning=Advertencia\: Si elige esta opci\u00c3\u00b3n, la supresi\u00c3\u00b3n de todos los dominios secundarios y todas las cuentas asociadas y sus recursos. -<<<<<<< HEAD force.delete=Fuerza Borrar force.remove=Fuerza Retire force.remove.host.warning=Advertencia\: Si elige esta opci\u00c3\u00b3n, CloudStack para detener la fuerza todas las m\u00c3\u00a1quinas virtuales en ejecuci\u00c3\u00b3n antes de retirar este host del cl\u00c3\u00baster. @@ -32,7 +31,6 @@ ICMP.code=ICMP C\u00c3\u00b3digo ICMP.type=Tipo ICMP image.directory=Directorio de la imagen inline=en l\u00c3\u00adnea -======= force.delete=Forzar el borrado force.remove=Forzar el retiro force.remove.host.warning=Advertencia\: Si elige esta opci\u00f3n, CloudStack para detener la fuerza todas las m\u00e1quinas virtuales en ejecuci\u00f3n antes de retirar este host del cl\u00faster. @@ -44,7 +42,6 @@ image.directory=Directorio de im\u00e1genes inline=alineado label.about=Acerca de label.about.app=Acerca de CloudStack ->>>>>>> 4e449ff... Add Dutch (Netherlands, Polish languages in Web UI Change Japanese code (ja -> ja_JP) Update transifex sync config label.account=Cuenta label.account.id=ID de la cuenta label.account.name=Nombre de cuenta diff --git a/client/WEB-INF/classes/resources/messages_ja_JP.properties b/client/WEB-INF/classes/resources/messages_ja_JP.properties index 42324491418..d3d50f0e889 100644 --- a/client/WEB-INF/classes/resources/messages_ja_JP.properties +++ b/client/WEB-INF/classes/resources/messages_ja_JP.properties @@ -14,9 +14,22 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +label.port=\u30dd\u30fc\u30c8 +label.remove.ldap=LDAP \u306e\u524a\u9664 +label.configure.ldap=LDAP \u306e\u69cb\u6210 +label.ldap.configuration=LDAP \u69cb\u6210 +label.ldap.port=LDAP \u30dd\u30fc\u30c8 +label.create.nfs.secondary.staging.store=NFS \u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u3092\u4f5c\u6210\u3059\u308b +label.volatile=\u63ee\u767a\u6027 +label.planner.mode=\u30d7\u30e9\u30f3\u30ca\u30fc \u30e2\u30fc\u30c9 +label.deployment.planner=\u5c55\u958b\u30d7\u30e9\u30f3\u30ca\u30fc +label.quiesce.vm=VM \u3092\u4f11\u6b62\u3059\u308b +label.smb.username=SMB \u30e6\u30fc\u30b6\u30fc\u540d +label.smb.password=SMB \u30d1\u30b9\u30ef\u30fc\u30c9 +label.smb.domain=SMB \u30c9\u30e1\u30a4\u30f3 label.hypervisors=\u30cf\u30a4\u30d1\u30fc\u30d0\u30a4\u30b6\u30fc label.home=\u30db\u30fc\u30e0 -label.sockets=\u30bd\u30b1\u30c3\u30c8 +label.sockets=CPU \u30bd\u30b1\u30c3\u30c8 label.root.disk.size=\u30eb\u30fc\u30c8 \u30c7\u30a3\u30b9\u30af \u30b5\u30a4\u30ba label.s3.nfs.server=S3 NFS \u30b5\u30fc\u30d0\u30fc label.s3.nfs.path=S3 NFS \u30d1\u30b9 @@ -50,7 +63,7 @@ message.action.delete.nic=\u3053\u306e NIC \u3092\u524a\u9664\u3057\u3066\u3082\ changed.item.properties=\u9805\u76ee\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u5909\u66f4 confirm.enable.s3=S3 \u30d9\u30fc\u30b9\u306e\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u30b5\u30dd\u30fc\u30c8\u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u60c5\u5831\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 confirm.enable.swift=Swift \u306e\u30b5\u30dd\u30fc\u30c8\u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306f\u3001\u6b21\u306e\u60c5\u5831\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 -error.could.not.change.your.password.because.ldap.is.enabled=LDAP \u304c\u6709\u52b9\u306a\u305f\u3081\u3001\u30a8\u30e9\u30fc\u306b\u3088\u3063\u3066\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u5909\u66f4\u3055\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002 +error.could.not.change.your.password.because.ldap.is.enabled=\u30a8\u30e9\u30fc\u3002LDAP \u304c\u6709\u52b9\u306a\u305f\u3081\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5909\u66f4\u3067\u304d\u307e\u305b\u3093\u3002 error.could.not.enable.zone=\u30be\u30fc\u30f3\u3092\u6709\u52b9\u306b\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f error.installWizard.message=\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002\u623b\u3063\u3066\u30a8\u30e9\u30fc\u3092\u4fee\u6b63\u3067\u304d\u307e\u3059\u3002 error.invalid.username.password=\u7121\u52b9\u306a\u30e6\u30fc\u30b6\u30fc\u540d\u307e\u305f\u306f\u30d1\u30b9\u30ef\u30fc\u30c9\u3067\u3059\u3002 @@ -371,12 +384,12 @@ label.api.key=API \u30ad\u30fc label.apply=\u9069\u7528 label.assign.to.load.balancer=\u8ca0\u8377\u5206\u6563\u88c5\u7f6e\u306b\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5272\u308a\u5f53\u3066\u3066\u3044\u307e\u3059 label.assign=\u5272\u308a\u5f53\u3066 -label.associated.network.id=\u95a2\u9023\u3065\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af ID -label.associated.network=\u95a2\u9023\u3065\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af +label.associated.network.id=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af ID +label.associated.network=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af label.attached.iso=\u30a2\u30bf\u30c3\u30c1\u3055\u308c\u305f ISO label.author.email=\u4f5c\u6210\u8005\u306e\u96fb\u5b50\u30e1\u30fc\u30eb label.author.name=\u4f5c\u6210\u8005\u306e\u540d\u524d -label.availability.zone=\u5229\u7528\u53ef\u80fd\u30be\u30fc\u30f3 +label.availability.zone=\u30a2\u30d9\u30a4\u30e9\u30d3\u30ea\u30c6\u30a3 \u30be\u30fc\u30f3 label.availability=\u53ef\u7528\u6027 label.available.public.ips=\u4f7f\u7528\u3067\u304d\u308b\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9 label.available=\u4f7f\u7528\u53ef\u80fd @@ -451,7 +464,7 @@ label.continue=\u7d9a\u884c label.corrections.saved=\u63a5\u7d9a\u304c\u4fdd\u5b58\u3055\u308c\u307e\u3057\u305f label.cpu.allocated.for.VMs=VM \u306b\u5272\u308a\u5f53\u3066\u6e08\u307f\u306e CPU label.cpu.allocated=\u5272\u308a\u5f53\u3066\u6e08\u307f\u306e CPU -label.CPU.cap=CPU \u4e0a\u9650 +label.CPU.cap=CPU \u30ad\u30e3\u30c3\u30d7 label.cpu.limits=CPU \u5236\u9650 label.cpu.mhz=CPU (MHz) label.cpu.utilized=CPU \u4f7f\u7528\u7387 @@ -588,6 +601,7 @@ label.full=\u5b8c\u5168 label.gateway=\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4 label.general.alerts=\u4e00\u822c\u30a2\u30e9\u30fc\u30c8 label.generating.url=URL \u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059 +label.gluster.volume=\u30dc\u30ea\u30e5\u30fc\u30e0 label.go.step.2=\u624b\u9806 2 \u306b\u9032\u3080 label.go.step.3=\u624b\u9806 3 \u306b\u9032\u3080 label.go.step.4=\u624b\u9806 4 \u306b\u9032\u3080 @@ -691,6 +705,7 @@ label.lang.arabic=\u30a2\u30e9\u30d3\u30a2\u8a9e label.lang.brportugese=\u30dd\u30eb\u30c8\u30ac\u30eb\u8a9e (\u30d6\u30e9\u30b8\u30eb) label.lang.catalan=\u30ab\u30bf\u30eb\u30cb\u30a2\u8a9e label.lang.chinese=\u7c21\u4f53\u5b57\u4e2d\u56fd\u8a9e +label.lang.dutch=\u30aa\u30e9\u30f3\u30c0\u8a9e (\u30aa\u30e9\u30f3\u30c0) label.lang.english=\u82f1\u8a9e label.lang.french=\u30d5\u30e9\u30f3\u30b9\u8a9e label.lang.german=\u30c9\u30a4\u30c4\u8a9e @@ -698,6 +713,7 @@ label.lang.italian=\u30a4\u30bf\u30ea\u30a2\u8a9e label.lang.japanese=\u65e5\u672c\u8a9e label.lang.korean=\u97d3\u56fd\u8a9e label.lang.norwegian=\u30ce\u30eb\u30a6\u30a7\u30fc\u8a9e +label.lang.polish=\u30dd\u30fc\u30e9\u30f3\u30c9\u8a9e label.lang.russian=\u30ed\u30b7\u30a2\u8a9e label.lang.spanish=\u30b9\u30da\u30a4\u30f3\u8a9e label.last.disconnected=\u6700\u7d42\u5207\u65ad\u65e5\u6642 @@ -997,7 +1013,7 @@ label.s3.endpoint=\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8 label.s3.max_error_retry=\u6700\u5927\u30a8\u30e9\u30fc\u518d\u8a66\u884c\u6570 label.s3.secret_key=\u79d8\u5bc6\u30ad\u30fc label.s3.socket_timeout=\u30bd\u30b1\u30c3\u30c8 \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8 -label.s3.use_https=HTTPS \u3092\u4f7f\u7528 +label.s3.use_https=HTTPS \u3092\u4f7f\u7528\u3059\u308b label.saturday=\u571f\u66dc\u65e5 label.save.and.continue=\u4fdd\u5b58\u3057\u3066\u7d9a\u884c label.save=\u4fdd\u5b58 @@ -1052,7 +1068,7 @@ label.source=\u9001\u4fe1\u5143 label.specify.IP.ranges=IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u6307\u5b9a label.specify.vlan=VLAN \u3092\u6307\u5b9a\u3059\u308b label.specify.vxlan=VXLAN \u3092\u6307\u5b9a\u3059\u308b -label.SR.name = SR \u540d\u30e9\u30d9\u30eb +label.SR.name=SR \u540d\u30e9\u30d9\u30eb label.srx=SRX label.PA=Palo Alto label.start.IP=\u958b\u59cb IP \u30a2\u30c9\u30ec\u30b9 @@ -1129,7 +1145,7 @@ label.tier.details=\u968e\u5c64\u306e\u8a73\u7d30 label.tier=\u968e\u5c64 label.time.zone=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3 label.time=\u6642\u523b -label.timeout.in.second = \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8 (\u79d2) +label.timeout.in.second=\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8 (\u79d2) label.timeout=\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8 label.timezone=\u30bf\u30a4\u30e0\u30be\u30fc\u30f3 label.token=\u30c8\u30fc\u30af\u30f3 @@ -1151,8 +1167,8 @@ label.unavailable=\u4f7f\u7528\u4e0d\u80fd label.unlimited=\u7121\u5236\u9650 label.untagged=\u30bf\u30b0\u306a\u3057 label.update.project.resources=\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 \u30ea\u30bd\u30fc\u30b9\u306e\u66f4\u65b0 -label.update.ssl.cert= SSL \u8a3c\u660e\u66f8 -label.update.ssl= SSL \u8a3c\u660e\u66f8 +label.update.ssl.cert=SSL \u8a3c\u660e\u66f8 +label.update.ssl=SSL \u8a3c\u660e\u66f8 label.updating=\u66f4\u65b0\u3057\u3066\u3044\u307e\u3059 label.upload.volume=\u30dc\u30ea\u30e5\u30fc\u30e0\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9 label.upload=\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9 @@ -1252,6 +1268,218 @@ label.zoneWizard.trafficType.management=\u7ba1\u7406\: \u30db\u30b9\u30c8\u3084 label.zoneWizard.trafficType.public=\u30d1\u30d6\u30ea\u30c3\u30af\: \u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3068\u30af\u30e9\u30a6\u30c9\u5185\u306e\u4eee\u60f3\u30de\u30b7\u30f3\u306e\u9593\u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u3067\u3059\u3002 label.zoneWizard.trafficType.storage=\u30b9\u30c8\u30ec\u30fc\u30b8\: VM \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3084\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u306a\u3069\u3001\u30d7\u30e9\u30a4\u30de\u30ea\u304a\u3088\u3073\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8 \u30b5\u30fc\u30d0\u30fc\u9593\u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u3067\u3059\u3002 label.ldap.group.name=LDAP \u30b0\u30eb\u30fc\u30d7 +label.password.reset.confirm=\u6b21\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u306b\u30ea\u30bb\u30c3\u30c8\u3055\u308c\u307e\u3057\u305f: +label.provider=\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc +label.resetVM=VM \u306e\u30ea\u30bb\u30c3\u30c8 +label.openDaylight=OpenDaylight +label.assign.instance.another=\u307b\u304b\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3078\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u5272\u308a\u5f53\u3066 +label.network.addVM=VM \u3078\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u8ffd\u52a0 +label.set.default.NIC=\u30c7\u30d5\u30a9\u30eb\u30c8 NIC \u306e\u8a2d\u5b9a +label.Xenserver.Tools.Version61plus=XenServer Tools Version 6.1 \u4ee5\u964d +label.dynamically.scalable=\u52d5\u7684\u306b\u30b5\u30a4\u30ba\u8a2d\u5b9a\u3059\u308b +label.instance.scaled.up=\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30b5\u30a4\u30ba\u304c\u62e1\u5927\u3055\u308c\u307e\u3057\u305f +label.tag.key=\u30bf\u30b0 \u30ad\u30fc +label.tag.value=\u30bf\u30b0\u5024 +label.ipv6.address=IPv6 IP \u30a2\u30c9\u30ec\u30b9 +label.ipv6.gateway=IPv6 \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4 +label.ipv6.CIDR=IPv6 CIDR +label.VPC.limits=VPC \u5236\u9650 +label.edit.region=\u9818\u57df\u306e\u7de8\u96c6 +label.gslb.domain.name=GSLB \u30c9\u30e1\u30a4\u30f3\u540d +label.add.gslb=GSLB \u306e\u8ffd\u52a0 +label.gslb.servicetype=\u30b5\u30fc\u30d3\u30b9\u306e\u7a2e\u985e +label.gslb.details=GSLB \u306e\u8a73\u7d30 +label.gslb.delete=GSLB \u306e\u524a\u9664 +label.opendaylight.controller=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc +label.opendaylight.controllers=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc +label.portable.ip.ranges=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2 +label.add.portable.ip.range=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u8ffd\u52a0 +label.delete.portable.ip.range=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u524a\u9664 +label.opendaylight.controllerdetail=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u8a73\u7d30 +label.portable.ip.range.details=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u306e\u8a73\u7d30 +label.portable.ips=\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9 +label.gslb.assigned.lb=\u5272\u308a\u5f53\u3066\u6e08\u307f\u8ca0\u8377\u5206\u6563 +label.gslb.assigned.lb.more=\u8ca0\u8377\u5206\u6563\u306e\u8ffd\u52a0\u5272\u308a\u5f53\u3066 +label.gslb.lb.rule=\u8ca0\u8377\u5206\u6563\u898f\u5247 +label.gslb.lb.details=\u8ca0\u8377\u5206\u6563\u306e\u8a73\u7d30 +label.gslb.lb.remove=\u3053\u306e GSLB \u304b\u3089\u8ca0\u8377\u5206\u6563\u3092\u524a\u9664 +label.enable.autoscale=\u81ea\u52d5\u30b5\u30a4\u30ba\u8a2d\u5b9a\u306e\u6709\u52b9\u5316 +label.disable.autoscale=\u81ea\u52d5\u30b5\u30a4\u30ba\u8a2d\u5b9a\u306e\u7121\u52b9\u5316 +label.min.instances=\u6700\u5c0f\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u6570 +label.max.instances=\u6700\u5927\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u6570 +label.add.OpenDaylight.device=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u8ffd\u52a0 +label.show.advanced.settings=\u8a73\u7d30\u8a2d\u5b9a\u306e\u8868\u793a +label.delete.OpenDaylight.device=OpenDaylight \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u524a\u9664 +label.polling.interval.sec=\u30dd\u30fc\u30ea\u30f3\u30b0\u9593\u9694 (\u79d2) +label.quiet.time.sec=\u5f85\u3061\u6642\u9593 (\u79d2) +label.destroy.vm.graceperiod=VM \u7834\u68c4\u306e\u7336\u4e88\u671f\u9593 +label.SNMP.community=SNMP \u30b3\u30df\u30e5\u30cb\u30c6\u30a3 +label.SNMP.port=SNMP \u30dd\u30fc\u30c8 +label.add.ucs.manager=UCS Manager \u306e\u8ffd\u52a0 +label.ovm.traffic.label=OVM \u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af \u30e9\u30d9\u30eb +label.lxc.traffic.label=LXC \u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af \u30e9\u30d9\u30eb +label.hyperv.traffic.label=Hyper-V \u306e\u30c8\u30e9\u30d5\u30a3\u30c3\u30af \u30e9\u30d9\u30eb +label.resource.name=\u30ea\u30bd\u30fc\u30b9\u540d +label.reource.id=\u30ea\u30bd\u30fc\u30b9 ID +label.vnmc.devices=VNMC \u30c7\u30d0\u30a4\u30b9 +label.add.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u8ffd\u52a0 +label.enable.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u6709\u52b9\u5316 +label.add.vnmc.device=VNMC \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0 +label.ciscovnmc.resource.details=Cisco VNMC \u30ea\u30bd\u30fc\u30b9\u306e\u8a73\u7d30 +label.delete.ciscovnmc.resource=Cisco VNMC \u30ea\u30bd\u30fc\u30b9\u306e\u524a\u9664 +label.enable.vnmc.device=VNMC \u30c7\u30d0\u30a4\u30b9\u306e\u6709\u52b9\u5316 +label.disbale.vnmc.device=VNMC \u30c7\u30d0\u30a4\u30b9\u306e\u7121\u52b9\u5316 +label.disable.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u306e\u7121\u52b9\u5316 +label.services=\u30b5\u30fc\u30d3\u30b9 +label.secondary.staging.store=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2 +label.release.account=\u30a2\u30ab\u30a6\u30f3\u30c8\u304b\u3089\u89e3\u653e +label.release.account.lowercase=\u30a2\u30ab\u30a6\u30f3\u30c8\u304b\u3089\u89e3\u653e +label.vlan.vni.ranges=VLAN/VNI \u306e\u7bc4\u56f2 +label.dedicated.vlan.vni.ranges=\u5c02\u7528 VLAN/VNI \u306e\u7bc4\u56f2 +label.dedicate.vlan.vni.range=VLAN/VNI \u306e\u7bc4\u56f2\u3092\u5c02\u7528\u306b\u8a2d\u5b9a +label.vlan.vni.range=VLAN/VNI \u306e\u7bc4\u56f2 +label.vlan.range.details=VLAN \u306e\u7bc4\u56f2\u306e\u8a73\u7d30 +label.release.dedicated.vlan.range=\u5c02\u7528 VLAN \u306e\u7bc4\u56f2\u306e\u89e3\u653e +label.broadcat.uri=\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8 URI +label.ipv4.cidr=IPv4 CIDR +label.guest.network.details=\u30b2\u30b9\u30c8 \u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u8a73\u7d30 +label.ipv4.gateway=IPv4 \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4 +label.release.dedicated.vlan.range=\u5c02\u7528 VLAN \u306e\u7bc4\u56f2\u3092\u89e3\u653e +label.vlan.ranges=VLAN \u306e\u7bc4\u56f2 +label.virtual.appliance.details=\u4eee\u60f3\u30a2\u30d7\u30e9\u30a4\u30a2\u30f3\u30b9\u306e\u8a73\u7d30 +label.start.lb.vm=LB VM \u306e\u8d77\u52d5 +label.stop.lb.vm=LB VM \u306e\u505c\u6b62 +label.migrate.lb.vm=LB VM \u306e\u79fb\u884c +label.vpc.virtual.router=VPC \u4eee\u60f3\u30eb\u30fc\u30bf\u30fc +label.ovs=OVS +label.gslb.service=GSLB \u30b5\u30fc\u30d3\u30b9 +label.gslb.service.public.ip=GSLB \u30b5\u30fc\u30d3\u30b9\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9 +label.gslb.service.private.ip=GSLB \u30b5\u30fc\u30d3\u30b9\u306e\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8 IP \u30a2\u30c9\u30ec\u30b9 +label.baremetal.dhcp.provider=\u30d9\u30a2\u30e1\u30bf\u30eb DHCP \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc +label.add.baremetal.dhcp.device=\u30d9\u30a2\u30e1\u30bf\u30eb DHCP \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0 +label.baremetal.pxe.provider=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc +label.baremetal.pxe.device=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30c7\u30d0\u30a4\u30b9\u306e\u8ffd\u52a0 +label.tftp.root.directory=TFTP \u30eb\u30fc\u30c8 \u30c7\u30a3\u30ec\u30af\u30c8\u30ea +label.add.vmware.datacenter=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u306e\u8ffd\u52a0 +label.remove.vmware.datacenter=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u306e\u524a\u9664 +label.dc.name=DC \u540d +label.vcenter=vCenter +label.dedicate.zone=\u30be\u30fc\u30f3\u3092\u5c02\u7528\u306b\u8a2d\u5b9a +label.zone.dedicated=\u5c02\u7528\u30be\u30fc\u30f3 +label.release.dedicated.zone=\u5c02\u7528\u30be\u30fc\u30f3\u306e\u89e3\u653e +label.ipv6.dns1=IPv6 DNS 1 +label.ipv6.dns2=IPv6 DNS 2 +label.vmware.datacenter.name=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u540d +label.vmware.datacenter.vcenter=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u306e vCenter +label.vmware.datacenter.id=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc ID +label.system.vm.details=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u8a73\u7d30 +label.system.vm.scaled.up=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u30b5\u30a4\u30ba\u304c\u62e1\u5927\u3055\u308c\u307e\u3057\u305f +label.console.proxy.vm=\u30b3\u30f3\u30bd\u30fc\u30eb \u30d7\u30ed\u30ad\u30b7 VM +label.settings=\u8a2d\u5b9a +label.requires.upgrade=\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u304c\u5fc5\u8981 +label.upgrade.router.newer.template=\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3059\u308b +label.router.vm.scaled.up=\u30eb\u30fc\u30bf\u30fc VM \u306e\u30b5\u30a4\u30ba\u304c\u62e1\u5927\u3055\u308c\u307e\u3057\u305f +label.total.virtual.routers=\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc\u5408\u8a08 +label.upgrade.required=\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u304c\u5fc5\u8981\u3067\u3059 +label.virtual.routers.group.zone=\u30be\u30fc\u30f3\u5225\u306e\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc \u30b0\u30eb\u30fc\u30d7 +label.total.virtual.routers.upgrade=\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u304c\u5fc5\u8981\u306a\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc\u5408\u8a08 +label.virtual.routers.group.pod=\u30dd\u30c3\u30c9\u5225\u306e\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc \u30b0\u30eb\u30fc\u30d7 +label.virtual.routers.group.cluster=\u30af\u30e9\u30b9\u30bf\u30fc\u5225\u306e\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc \u30b0\u30eb\u30fc\u30d7 +label.zone.lower=\u30be\u30fc\u30f3 +label.virtual.routers.group.account=\u30a2\u30ab\u30a6\u30f3\u30c8\u5225\u306e\u4eee\u60f3\u30eb\u30fc\u30bf\u30fc \u30b0\u30eb\u30fc\u30d7 +label.netscaler.details=NetScaler \u306e\u8a73\u7d30 +label.baremetal.dhcp.devices=\u30d9\u30a2\u30e1\u30bf\u30eb DHCP \u30c7\u30d0\u30a4\u30b9 +label.baremetal.pxe.devices=\u30d9\u30a2\u30e1\u30bf\u30eb PXE \u30c7\u30d0\u30a4\u30b9 +label.addes.new.f5=\u65b0\u3057\u3044 F5 \u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f +label.f5.details=F5 \u306e\u8a73\u7d30 +label.srx.details=SRX \u306e\u8a73\u7d30 +label.palo.alto.details=Palo Alto \u306e\u8a73\u7d30 +label.added.nicira.nvp.controller=\u65b0\u3057\u3044 Nicira NVP Controller \u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\ +label.nicira.nvp.details=Nicira NVP \u306e\u8a73\u7d30 +label.added.new.bigswitch.vns.controller=\u65b0\u3057\u3044 Big Switch VNS \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f +label.bigswitch.vns.details=Big Switch VNS \u306e\u8a73\u7d30 +label.dedicate=\u5c02\u7528\u306b\u8a2d\u5b9a +label.dedicate.pod=\u30dd\u30c3\u30c9\u3092\u5c02\u7528\u306b\u8a2d\u5b9a +label.pod.dedicated=\u30dd\u30c3\u30c9\u3092\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f +label.release.dedicated.pod=\u5c02\u7528\u30dd\u30c3\u30c9\u306e\u89e3\u653e +label.override.public.traffic=\u30d1\u30d6\u30ea\u30c3\u30af \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b +label.public.traffic.vswitch.type=\u30d1\u30d6\u30ea\u30c3\u30af \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306e vSwitch \u306e\u7a2e\u985e +label.public.traffic.vswitch.name=\u30d1\u30d6\u30ea\u30c3\u30af \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306e vSwitch \u540d +label.override.guest.traffic=\u30b2\u30b9\u30c8 \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u3059\u308b +label.guest.traffic.vswitch.type=\u30b2\u30b9\u30c8 \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306e vSwitch \u306e\u7a2e\u985e +label.guest.traffic.vswitch.name=\u30b2\u30b9\u30c8 \u30c8\u30e9\u30d5\u30a3\u30c3\u30af\u306e vSwitch \u540d +label.cisco.nexus1000v.ip.address=Nexus 1000V \u306e IP \u30a2\u30c9\u30ec\u30b9 +label.cisco.nexus1000v.username=Nexus 1000V \u306e\u30e6\u30fc\u30b6\u30fc\u540d +label.cisco.nexus1000v.password=Nexus 1000V \u306e\u30d1\u30b9\u30ef\u30fc\u30c9 +label.dedicate.cluster=\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u5c02\u7528\u306b\u8a2d\u5b9a +label.release.dedicated.cluster=\u5c02\u7528\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u89e3\u653e +label.dedicate.host=\u30db\u30b9\u30c8\u3092\u5c02\u7528\u306b\u8a2d\u5b9a +label.release.dedicated.host=\u5c02\u7528\u30db\u30b9\u30c8\u306e\u89e3\u653e +label.number.of.cpu.sockets=CPU \u30bd\u30b1\u30c3\u30c8\u6570 +label.delete.ucs.manager=UCS Manager \u306e\u524a\u9664 +label.blades=\u30d6\u30ec\u30fc\u30c9 +label.chassis=\u30b7\u30e3\u30fc\u30b7 +label.blade.id=\u30d6\u30ec\u30fc\u30c9 ID +label.associated.profile=\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb +label.refresh.blades=\u30d6\u30ec\u30fc\u30c9\u306e\u66f4\u65b0 +label.instanciate.template.associate.profile.blade=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u4f5c\u6210\u304a\u3088\u3073\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3068\u30d6\u30ec\u30fc\u30c9\u306e\u95a2\u9023\u4ed8\u3051 +label.select.template=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u9078\u629e +label.profile=\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb +label.delete.profile=\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u306e\u524a\u9664 +label.disassociate.profile.blade=\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3068\u30d6\u30ec\u30fc\u30c9\u306e\u95a2\u9023\u4ed8\u3051\u306e\u89e3\u9664 +label.secondary.storage.details=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u8a73\u7d30 +label.secondary.staging.store.details=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u306e\u8a73\u7d30 +label.add.nfs.secondary.staging.store=NFS \u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u306e\u8ffd\u52a0 +label.delete.secondary.staging.store=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u306e\u524a\u9664 +label.ipv4.start.ip=IPv4 \u958b\u59cb IP \u30a2\u30c9\u30ec\u30b9 +label.ipv4.end.ip=IPv4 \u7d42\u4e86 IP \u30a2\u30c9\u30ec\u30b9 +label.ipv6.start.ip=IPv6 \u958b\u59cb IP \u30a2\u30c9\u30ec\u30b9 +label.ipv6.end.ip=IPv6 \u7d42\u4e86 IP \u30a2\u30c9\u30ec\u30b9 +label.vm.password=VM \u306e\u30d1\u30b9\u30ef\u30fc\u30c9: +label.group.by.zone=\u30be\u30fc\u30f3\u5225\u30b0\u30eb\u30fc\u30d7 +label.group.by.pod=\u30dd\u30c3\u30c9\u5225\u30b0\u30eb\u30fc\u30d7 +label.group.by.cluster=\u30af\u30e9\u30b9\u30bf\u30fc\u5225\u30b0\u30eb\u30fc\u30d7 +label.group.by.account=\u30a2\u30ab\u30a6\u30f3\u30c8\u5225\u30b0\u30eb\u30fc\u30d7 +label.no.grouping=(\u30b0\u30eb\u30fc\u30d7\u306a\u3057) +label.create.nfs.secondary.staging.storage=NFS \u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u3092\u4f5c\u6210\u3059\u308b +label.username.lower=\u30e6\u30fc\u30b6\u30fc\u540d +label.password.lower=\u30d1\u30b9\u30ef\u30fc\u30c9 +label.email.lower=\u96fb\u5b50\u30e1\u30fc\u30eb +label.firstname.lower=\u540d +label.lastname.lower=\u59d3 +label.domain.lower=\u30c9\u30e1\u30a4\u30f3 +label.account.lower=\u30a2\u30ab\u30a6\u30f3\u30c8 +label.type.lower=\u7a2e\u985e +label.rule.number=\u898f\u5247\u756a\u53f7 +label.action=\u64cd\u4f5c +label.name.lower=\u540d\u524d +label.ucs=UCS +label.change.affinity=\u30a2\u30d5\u30a3\u30cb\u30c6\u30a3\u306e\u5909\u66f4 +label.persistent=\u6c38\u7d9a +label.broadcasturi=\u30d6\u30ed\u30fc\u30c9\u30ad\u30e3\u30b9\u30c8 URI +label.network.cidr=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af CIDR +label.reserved.ip.range=\u4e88\u7d04\u6e08\u307f IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2 +label.autoscale=\u81ea\u52d5\u30b5\u30a4\u30ba\u8a2d\u5b9a +label.health.check=\u30d8\u30eb\u30b9 \u30c1\u30a7\u30c3\u30af +label.public.load.balancer.provider=\u30d1\u30d6\u30ea\u30c3\u30af\u8ca0\u8377\u5206\u6563\u88c5\u7f6e\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc +label.add.isolated.network=\u5206\u96e2\u3055\u308c\u305f\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u8ffd\u52a0 +label.vlan=VLAN +label.secondary.isolated.vlan.id=\u5206\u96e2\u3055\u308c\u305f\u30bb\u30ab\u30f3\u30c0\u30ea VLAN ID +label.ipv4.netmask=IPv4 \u30cd\u30c3\u30c8\u30de\u30b9\u30af +label.custom=\u30ab\u30b9\u30bf\u30e0 +label.disable.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u306e\u7121\u52b9\u5316 +label.enable.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u306e\u6709\u52b9\u5316 +label.remove.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u306e\u524a\u9664 +label.system.offering.for.router=\u30eb\u30fc\u30bf\u30fc\u7528\u30b7\u30b9\u30c6\u30e0 \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0 +label.mode=\u30e2\u30fc\u30c9 +label.associate.public.ip=\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u306e\u95a2\u9023\u4ed8\u3051 +label.acl=ACL +label.user.data=\u30e6\u30fc\u30b6\u30fc \u30c7\u30fc\u30bf +label.virtual.networking=\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af +label.allow=\u8a31\u53ef +label.deny=\u62d2\u5426 +label.default.egress.policy=\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u9001\u4fe1\u30dd\u30ea\u30b7\u30fc +label.xenserver.tools.version.61.plus=XenServer Tools Version 6.1 \u4ee5\u964d managed.state=\u7ba1\u7406\u5bfe\u8c61\u72b6\u614b message.acquire.new.ip.vpc=\u3053\u306e VPC \u306e\u65b0\u3057\u3044 IP \u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.acquire.new.ip=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u65b0\u3057\u3044 IP \u30a2\u30c9\u30ec\u30b9\u3092\u53d6\u5f97\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? @@ -1395,7 +1623,7 @@ message.creating.primary.storage=\u30d7\u30e9\u30a4\u30de\u30ea \u30b9\u30c8\u30 message.creating.secondary.storage=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059 message.creating.zone=\u30be\u30fc\u30f3\u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059 message.decline.invitation=\u3053\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3078\u306e\u62db\u5f85\u3092\u8f9e\u9000\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? -message.dedicate.zone=\u30be\u30fc\u30f3\u3092\u5c02\u7528\u5316\u3057\u3066\u3044\u307e\u3059 +message.dedicate.zone=\u30be\u30fc\u30f3\u3092\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059 message.delete.account=\u3053\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.delete.affinity.group=\u3053\u306e\u30a2\u30d5\u30a3\u30cb\u30c6\u30a3 \u30b0\u30eb\u30fc\u30d7\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? message.delete.gateway=\u3053\u306e\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? @@ -1565,6 +1793,90 @@ message.zone.step.1.desc=\u30be\u30fc\u30f3\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\ message.zone.step.2.desc=\u65b0\u3057\u3044\u30be\u30fc\u30f3\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306b\u3001\u6b21\u306e\u60c5\u5831\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 message.zone.step.3.desc=\u65b0\u3057\u3044\u30dd\u30c3\u30c9\u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306b\u3001\u6b21\u306e\u60c5\u5831\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 message.zoneWizard.enable.local.storage=\u8b66\u544a\: \u3053\u306e\u30be\u30fc\u30f3\u306e\u30ed\u30fc\u30ab\u30eb \u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u6709\u52b9\u306b\u3059\u308b\u5834\u5408\u306f\u3001\u30b7\u30b9\u30c6\u30e0 VM \u306e\u8d77\u52d5\u5834\u6240\u306b\u5fdc\u3058\u3066\u6b21\u306e\u64cd\u4f5c\u304c\u5fc5\u8981\u3067\u3059\u3002

1. \u30b7\u30b9\u30c6\u30e0 VM \u3092\u30d7\u30e9\u30a4\u30de\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u3067\u8d77\u52d5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u30d7\u30e9\u30a4\u30de\u30ea \u30b9\u30c8\u30ec\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u305f\u5f8c\u3067\u30be\u30fc\u30f3\u306b\u8ffd\u52a0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30be\u30fc\u30f3\u3092\u7121\u52b9\u72b6\u614b\u304b\u3089\u958b\u59cb\u3059\u308b\u5fc5\u8981\u3082\u3042\u308a\u307e\u3059\u3002

2. \u30b7\u30b9\u30c6\u30e0 VM \u3092\u30ed\u30fc\u30ab\u30eb \u30b9\u30c8\u30ec\u30fc\u30b8\u3067\u8d77\u52d5\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u306f\u3001\u30be\u30fc\u30f3\u3092\u6709\u52b9\u306b\u3059\u308b\u524d\u306b system.vm.use.local.storage \u3092 true \u306b\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002


\u7d9a\u884c\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.validate.fieldrequired=\u3053\u308c\u306f\u5fc5\u9808\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u3059\u3002 +message.validate.fixfield=\u3053\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4fee\u6b63\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.email.address=\u30e1\u30fc\u30eb \u30a2\u30c9\u30ec\u30b9\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.URL=URL \u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.date=\u65e5\u4ed8\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.date.ISO=\u65e5\u4ed8\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044 (ISO)\u3002 +message.validate.number=\u6570\u5024\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.digits=\u6570\u5b57\u306e\u307f\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.creditcard=\u30af\u30ec\u30b8\u30c3\u30c8 \u30ab\u30fc\u30c9\u756a\u53f7\u3092\u6b63\u3057\u304f\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.equalto=\u540c\u3058\u5024\u3092\u518d\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.accept=\u6709\u52b9\u306a\u62e1\u5f35\u5b50\u3092\u6301\u3064\u5024\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.maxlength={0} \u6587\u5b57\u4ee5\u4e0b\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.minlength={0} \u6587\u5b57\u4ee5\u4e0a\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.range.length={0} \uff5e {1} \u6587\u5b57\u3067\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.range={0} \uff5e {1} \u306e\u5024\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.validate.max={0} \u4ee5\u4e0b\u306e\u5024\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +messgae.validate.min={0} \u4ee5\u4e0a\u306e\u5024\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.creating.systemVM=\u30b7\u30b9\u30c6\u30e0 VM \u3092\u4f5c\u6210\u3057\u3066\u3044\u307e\u3059 (\u3057\u3070\u3089\u304f\u304a\u5f85\u3061\u304f\u3060\u3055\u3044) +message.enabling.zone.dots=\u30be\u30fc\u30f3\u3092\u6709\u52b9\u306b\u3057\u3066\u3044\u307e\u3059... +message.restoreVM=VM \u3092\u5fa9\u5143\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.no.host.available=\u79fb\u884c\u306b\u4f7f\u7528\u3067\u304d\u308b\u30db\u30b9\u30c8\u306f\u3042\u308a\u307e\u305b\u3093 +message.network.addVM.desc=\u3053\u306e VM \u3092\u8ffd\u52a0\u3059\u308b\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u305f\u3081\u306e\u65b0\u3057\u3044 NIC \u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002 +message.network.addVMNIC=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u65b0\u3057\u3044 VM NIC \u3092\u8ffd\u52a0\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.set.default.NIC=\u3053\u306e NIC \u3092\u3053\u306e VM \u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.set.default.NIC.manual=\u4eca\u3059\u3050\u306b\u3053\u306e VM \u306e\u30c7\u30d5\u30a9\u30eb\u30c8 NIC \u3092\u624b\u52d5\u3067\u66f4\u65b0\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.instance.scaled.up.confirm=\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30b5\u30a4\u30ba\u3092\u62e1\u5927\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.copy.template.confirm=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30b3\u30d4\u30fc\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.template.copying=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30b3\u30d4\u30fc\u3057\u3066\u3044\u307e\u3059\u3002 +message.XSTools61plus.update.failed=XenServer Tools Version 6.1 \u4ee5\u964d\u3078\u306e\u66f4\u65b0\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\u30a8\u30e9\u30fc\: +message.gslb.delete.confirm=\u3053\u306e GSLB \u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.portable.ip.delete.confirm=\u3053\u306e\u30dd\u30fc\u30bf\u30d6\u30eb IP \u30a2\u30c9\u30ec\u30b9\u306e\u7bc4\u56f2\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.gslb.lb.remove.confirm=GSLB \u304b\u3089\u8ca0\u8377\u5206\u6563\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.admin.guide.read=VMware \u30d9\u30fc\u30b9\u306e VM \u306b\u3064\u3044\u3066\u306f\u3001\u30b5\u30a4\u30ba\u5909\u66f4\u306e\u524d\u306b\u7ba1\u7406\u8005\u30ac\u30a4\u30c9\u306e\u52d5\u7684\u306a\u30b5\u30a4\u30ba\u5909\u66f4\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u304a\u8aad\u307f\u304f\u3060\u3055\u3044\u3002\u7d9a\u884c\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b?\, +message.tier.required=\u968e\u5c64\u306f\u5fc5\u9808\u3067\u3059 +message.remove.ldap=LDAP \u69cb\u6210\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.action.downloading.template=\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3044\u307e\u3059\u3002 +message.configure.ldap=LDAP \u3092\u69cb\u6210\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.delete.ciscovnmc.resource=Cisco VNMC \u30ea\u30bd\u30fc\u30b9\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.add.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.enable.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u6709\u52b9\u306b\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.disable.vnmc.provider=VNMC \u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u3092\u7121\u52b9\u306b\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.vnmc.available.list=\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u4e00\u89a7\u3067 VNMC \u3092\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002 +message.vnmc.not.available.list=\u30d7\u30ed\u30d0\u30a4\u30c0\u30fc\u4e00\u89a7\u3067 VNMC \u3092\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002 +message.confirm.release.dedicate.vlan.range=\u5c02\u7528 VLAN \u306e\u7bc4\u56f2\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.start.lb.vm=LB VM \u3092\u8d77\u52d5\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.stop.lb.vm=LB VM \u3092\u505c\u6b62\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.remove.vmware.datacenter=VMware \u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.dedicate.zone=\u3053\u306e\u30be\u30fc\u30f3\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.release.dedicated.zone=\u3053\u306e\u5c02\u7528\u30be\u30fc\u30f3\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.dedicated.zone.released=\u5c02\u7528\u30be\u30fc\u30f3\u304c\u89e3\u653e\u3055\u308c\u307e\u3057\u305f +message.read.admin.guide.scaling.up=\u30b5\u30a4\u30ba\u3092\u62e1\u5927\u3059\u308b\u524d\u306b\u7ba1\u7406\u8005\u30ac\u30a4\u30c9\u306e\u52d5\u7684\u306a\u30b5\u30a4\u30ba\u5909\u66f4\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3092\u304a\u8aad\u307f\u304f\u3060\u3055\u3044\u3002 +message.confirm.scale.up.system.vm=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u30b5\u30a4\u30ba\u3092\u62e1\u5927\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.upgrade.router.newer.template=\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.scale.up.router.vm=\u30eb\u30fc\u30bf\u30fc VM \u306e\u30b5\u30a4\u30ba\u3092\u62e1\u5927\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.upgrade.routers.newtemplate=\u3053\u306e\u30be\u30fc\u30f3\u306e\u3059\u3079\u3066\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.upgrade.routers.pod.newtemplate=\u3053\u306e\u30dd\u30c3\u30c9\u306e\u3059\u3079\u3066\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.upgrade.routers.cluster.newtemplate=\u3053\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u306e\u3059\u3079\u3066\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.upgrade.routers.account.newtemplate=\u3053\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u3059\u3079\u3066\u306e\u30eb\u30fc\u30bf\u30fc\u3092\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9\u3057\u3066\u65b0\u3057\u3044\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3092\u4f7f\u7528\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.dedicate.pod.domain.account=\u3053\u306e\u30dd\u30c3\u30c9\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.release.dedicated.pod=\u3053\u306e\u5c02\u7528\u30dd\u30c3\u30c9\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.pod.dedication.released=\u5c02\u7528\u30dd\u30c3\u30c9\u304c\u89e3\u653e\u3055\u308c\u307e\u3057\u305f +message.confirm.dedicate.cluster.domain.account=\u3053\u306e\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.cluster.dedicated=\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f +message.confirm.release.dedicated.cluster=\u3053\u306e\u5c02\u7528\u30af\u30e9\u30b9\u30bf\u30fc\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.cluster.dedication.released=\u5c02\u7528\u30af\u30e9\u30b9\u30bf\u30fc\u304c\u89e3\u653e\u3055\u308c\u307e\u3057\u305f +message.confirm.dedicate.host.domain.account=\u3053\u306e\u30db\u30b9\u30c8\u3092\u30c9\u30e1\u30a4\u30f3/\u30a2\u30ab\u30a6\u30f3\u30c8\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.host.dedicated=\u30db\u30b9\u30c8\u3092\u5c02\u7528\u306b\u8a2d\u5b9a\u3057\u307e\u3057\u305f +message.confirm.release.dedicated.host=\u3053\u306e\u5c02\u7528\u30db\u30b9\u30c8\u3092\u89e3\u653e\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.host.dedication.released=\u5c02\u7528\u30db\u30b9\u30c8\u304c\u89e3\u653e\u3055\u308c\u307e\u3057\u305f +message.confirm.delete.ucs.manager=UCS Manager \u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.refresh.blades=\u30d6\u30ec\u30fc\u30c9\u3092\u66f4\u65b0\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.delete.secondary.staging.store=\u30bb\u30ab\u30f3\u30c0\u30ea \u30b9\u30c6\u30fc\u30b8\u30f3\u30b0 \u30b9\u30c8\u30a2\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.select.tier=\u968e\u5c64\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002 +message.disallowed.characters=\u8a31\u53ef\u3055\u308c\u306a\u3044\u6587\u5b57: \<\,\> +message.waiting.for.builtin.templates.to.load=\u7d44\u307f\u8fbc\u307f\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30ed\u30fc\u30c9\u3092\u5f85\u6a5f\u3057\u3066\u3044\u307e\u3059... +message.systems.vms.ready=\u30b7\u30b9\u30c6\u30e0 VM \u306e\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002 +message.your.cloudstack.is.ready=CloudStack \u306e\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\! +message.specifiy.tag.key.value=\u30bf\u30b0 \u30ad\u30fc\u304a\u3088\u3073\u5024\u3092\u6307\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044 +message.enter.seperated.list.multiple.cidrs=CIDR \u304c\u8907\u6570\u3042\u308b\u5834\u5408\u306f\u3001\u30b3\u30f3\u30de\u533a\u5207\u308a\u306e\u4e00\u89a7\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044 +message.disabling.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u7121\u52b9\u306b\u3057\u3066\u3044\u307e\u3059 +message.confirm.enable.network.offering=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u6709\u52b9\u306b\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.enabling.network.offering=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u6709\u52b9\u306b\u3057\u3066\u3044\u307e\u3059 +message.confirm.remove.network.offering=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u524a\u9664\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? +message.confirm.disable.network.offering=\u3053\u306e\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30aa\u30d5\u30a1\u30ea\u30f3\u30b0\u3092\u7121\u52b9\u306b\u3057\u3066\u3082\u3088\u308d\u3057\u3044\u3067\u3059\u304b? mode=\u30e2\u30fc\u30c9 network.rate=\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u901f\u5ea6 notification.reboot.instance=\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u518d\u8d77\u52d5 diff --git a/client/WEB-INF/classes/resources/messages_nl_NL.properties b/client/WEB-INF/classes/resources/messages_nl_NL.properties index b1bfadb42af..5d666a4fb49 100644 --- a/client/WEB-INF/classes/resources/messages_nl_NL.properties +++ b/client/WEB-INF/classes/resources/messages_nl_NL.properties @@ -25,18 +25,18 @@ error.login=Uw gebruikersnaam/wachtwoord komt niet overeen met onze gegevens error.menu.select=Kan actie niet uitvoeren omdat geen items zijn geselecteerd error.mgmt.server.inaccessible=The Management Server is niet toegankelijk. Probeer het later opnieuw. error.password.not.match=De wachtwoord velden komen niet overeen -error.please.specify.physical.network.tags=Netwerk aanbiedingen zijn niet beschikbaar totdat u labels voor het fysieke netwerk specificeert. +error.please.specify.physical.network.tags=Netwerk aanbiedingen zijn niet beschikbaar totdat u labels voor het fysieke netwerk specificeert. error.session.expired=Uw sessie is verlopen -error.something.went.wrong.please.correct.the.following=Er is iets mis gegaan; Corrigeer het volgende +error.something.went.wrong.please.correct.the.following=Er is iets mis gegaan; Corrigeer het volgende error.unable.to.reach.management.server=Niet in staat om de Management Server te bereiken error.unresolved.internet.name=Uw internet naam kan niet worden omgezet. extractable=Uitpakbaar force.delete.domain.warning=Waarschuwing\: Wanneer u deze optie selecteert zullen alle onderliggende domeinen, hun gekoppelde accounts en hun verbruik worden verwijderd. force.delete=Geforceerd verwijderen force.remove=Geforceerd loskoppelen -force.remove.host.warning=Waarschuwing\: Wanneer u deze optie selecteert zal CloudStack alle draaiende virtuele machines geforceerd stoppen voordat de host van het cluster wordt verwijderd. +force.remove.host.warning=Waarschuwing\: Wanneer u deze optie selecteert zal CloudStack alle draaiende virtuele machines geforceerd stoppen voordat de host van het cluster wordt verwijderd. force.stop=Geforceerd stoppen -force.stop.instance.warning=Waarschuwing\: Een instantie geforceerd stoppen zou uw laatste optie moeten zijn. Het kan leiden tot dataverlies en inconsistent gedrag van de staat van de virtuele machine. +force.stop.instance.warning=Waarschuwing\: Een instantie geforceerd stoppen zou uw laatste optie moeten zijn. Het kan leiden tot dataverlies en inconsistent gedrag van de staat van de virtuele machine. ICMP.code=ICMP Code ICMP.type=ICMP Type image.directory=Afbeelding Directory @@ -48,7 +48,7 @@ label.account.and.security.group=Account, Security group label.account.id=Account ID label.account.name=Account Naam label.accounts=Accounts -label.account.specific=Account-specifiek +label.account.specific=Account-specifiek label.acquire.new.ip=Bemachtig nieuw IP label.action.attach.disk.processing=Schijf wordt toegevoegd.... label.action.attach.disk=Schijf toevoegen @@ -65,12 +65,12 @@ label.action.copy.template=Kopieer Template label.action.copy.template.processing=Bezig met kopi\u00ebren Template.... label.action.create.template=Cre\u00eber Template label.action.create.template.from.vm=Cre\u00eber Template vanaf VM -label.action.create.template.from.volume=Cre\u00eber Template van Volume +label.action.create.template.from.volume=Cre\u00eber Template van Volume label.action.create.template.processing=Bezig met aanmaken Template.... -label.action.create.vm=Cre\u00eber VM +label.action.create.vm=Cre\u00eber VM label.action.create.vm.processing=Bezig met aanmaken VM.... label.action.create.volume=Cre\u00eber Volume -label.action.create.volume.processing=Bezig met cre\u00ebren volume.... +label.action.create.volume.processing=Bezig met cre\u00ebren volume.... label.action.delete.account.processing=Bezig met verwijderen account.... label.action.delete.account=Verwijder account label.action.delete.cluster.processing=Bezig met verwijderen van Cluster.... @@ -81,7 +81,7 @@ label.action.delete.domain.processing=Bezig met verwijderen van Domein.... label.action.delete.domain=Verwijder Domein label.action.delete.firewall.processing=Bezig met verwijderen van Firewall.... label.action.delete.firewall=Verwijder firewall regel -label.action.delete.ingress.rule.processing=Bezig met verwijderen van Inkomende Regel.... +label.action.delete.ingress.rule.processing=Bezig met verwijderen van Inkomende Regel.... label.action.delete.ingress.rule=Verwijder Inkomende Regel label.action.delete.IP.range.processing=Bezig met verwijderen van IP Range.... label.action.delete.IP.range=Verwijder IP Range @@ -326,7 +326,7 @@ label.assign.to.load.balancer=Voeg instantie toe aan load balancer label.associated.network=Bijbehorend Netwerk label.associated.network.id=Bijbehorend Netwerk ID label.attached.iso=Gekoppelde ISO -label.author.email=Auteur e-mail +label.author.email=Auteur e-mail label.author.name=Auteur naam label.availability=Beschikbaarheid label.availability.zone=Beschikbaarheids-zone @@ -450,7 +450,7 @@ label.disabled=Uitgeschakeld label.disable.provider=Provider uitschakelen label.disable.vpn=VPN uitschakelen label.disabling.vpn.access=Uitschakelen van VPN Toegang -label.disk.allocated=Schijfruimte gealloceerd +label.disk.allocated=Schijfruimte gealloceerd label.disk.offering=Schijf Aanbieding label.disk.size.gb=Schijf Grootte (in GB) label.disk.size=Schijf Grootte @@ -471,7 +471,7 @@ label.domain.suffix=DNS domein achtervoegsel (v.b., xyz.com) label.done=Klaar label.double.quotes.are.not.allowed=Aanhalingstekens zijn hier niet toegestaan label.download.progress=Download Voortgang -label.drag.new.position=Sleep naar nieuwe positie +label.drag.new.position=Sleep naar nieuwe positie label.edit.lb.rule=Wijzig LB regel label.edit.network.details=Wijzig netwerk details label.edit.project.details=Wijzig project details @@ -568,7 +568,7 @@ label.installWizard.addHostIntro.subtitle=Wat is een host? label.installWizard.addHostIntro.title=Nu\: Host toevoegen label.installWizard.addPodIntro.subtitle=Wat is een pod? label.installWizard.addPodIntro.title=Nu\: Pod toevoegen -label.installWizard.addPrimaryStorageIntro.subtitle=Wat is primary storage? +label.installWizard.addPrimaryStorageIntro.subtitle=Wat is primary storage? label.installWizard.addPrimaryStorageIntro.title=Nu\: Primaire opslag toevoegen label.installWizard.addSecondaryStorageIntro.subtitle=Wat is secundaire opslag? label.installWizard.addSecondaryStorageIntro.title=Nu\: Secundaire opslag toevoegen @@ -620,7 +620,7 @@ label.keyboard.type=Toetsenbord type label.key=Sleutel label.kvm.traffic.label=KVM verkeer label label.label=Label -label.lang.brportugese=Braziliaans Portgees +label.lang.brportugese=Braziliaans Portgees label.lang.chinese=Chinees (Simplified) label.lang.english=Engels label.lang.french=Frans @@ -793,7 +793,7 @@ label.number.of.system.vms=Aantal Systeem VMs label.number.of.virtual.routers=Aantal Virtual Routers label.number.of.zones=Aantal Zones label.num.cpu.cores=Aantal CPU Cores -label.numretries=Keren opnieuw geprorbeerd +label.numretries=Keren opnieuw geprorbeerd label.ocfs2=OCFS2 label.offer.ha=HA aanbieden label.ok=OK @@ -1156,24 +1156,24 @@ label.zones=Zones label.zone.type=Type Zone label.zone.wide=Zone breed label.zoneWizard.trafficType.guest=Gast\: Verkeer tussen virtuele machines van de eindgebruiker -label.zoneWizard.trafficType.public=Publiek\: Verkeer tussen het internet en virtueele machines in de cloud. +label.zoneWizard.trafficType.public=Publiek\: Verkeer tussen het internet en virtueele machines in de cloud. label.zoneWizard.trafficType.storage=Opslag\: Verkeer tussen de primaire en secundaire opslag servers zoals VM templates en snapshots label.zone=Zone managed.state=Beheersstaat message.acquire.new.ip=Bevestigen dat je een nieuw IP voor dit netwerk wilt verkrijgen. -message.acquire.new.ip.vpc=Bevestig dat u een nieuw IP wilt verkrijgen voor deze VPC. +message.acquire.new.ip.vpc=Bevestig dat u een nieuw IP wilt verkrijgen voor deze VPC. message.acquire.public.ip=Selecteer de zone waarvan u een nieuw IP wenst te verkrijgen. -message.action.cancel.maintenance=Het onderhoud voor de host is succesvol geannuleerd. Het daadwerkelijke proces kan echter enkele minuten duren. +message.action.cancel.maintenance=Het onderhoud voor de host is succesvol geannuleerd. Het daadwerkelijke proces kan echter enkele minuten duren. message.action.cancel.maintenance.mode=Bevestig dat u het onderhoud wilt annuleren. message.action.change.service.warning.for.instance=Uw instantie moet uitgeschakeld zijn voordat u de service aanbieding kunt wijzigen. message.action.change.service.warning.for.router=Uw router moet uitgeschakeld zijn voordat u de service aanbieding kunt wijzigen. message.action.delete.cluster=Bevestig dat u dit cluster wilt verwijderen. message.action.delete.disk.offering=Bevestig dat u deze schijf aanbieding wilt verwijderen. message.action.delete.domain=Bevestig dat u dit domein wilt verwijderen. -message.action.delete.external.firewall=Bevestig dat u deze externe firewall wilt verwijderen. Waarschuwing\: Als u van plan bent dezelfde firewall opnieuw toe te voegen, dient u de verbruiksstatistieken eerst te resetten. -message.action.delete.external.load.balancer=Bevestig dat u deze externe loadbalancer wilt verwijderen. Waarschuwing\: Als u van plan bent dezelfde loadbalancer opnieuw toe te voegen, dient u de verbruiksstatistieken eerst te resetten. +message.action.delete.external.firewall=Bevestig dat u deze externe firewall wilt verwijderen. Waarschuwing\: Als u van plan bent dezelfde firewall opnieuw toe te voegen, dient u de verbruiksstatistieken eerst te resetten. +message.action.delete.external.load.balancer=Bevestig dat u deze externe loadbalancer wilt verwijderen. Waarschuwing\: Als u van plan bent dezelfde loadbalancer opnieuw toe te voegen, dient u de verbruiksstatistieken eerst te resetten. message.action.delete.ingress.rule=Bevestig dat u deze inkomende regel wilt verwijderen. -message.action.delete.ISO=Bevestig dat u deze ISO wilt verwijderen. +message.action.delete.ISO=Bevestig dat u deze ISO wilt verwijderen. message.action.delete.ISO.for.all.zones=Deze ISO wordt gebruikt door alle zones. Bevestig dat u deze wilt verwijderen van alle zones. message.action.delete.network=Bevestig dat u dit netwerk wilt verwijderen. message.action.delete.nexusVswitch=Bevestig dat u deze nexus 1000v wilt verwijderen @@ -1184,9 +1184,9 @@ message.action.delete.secondary.storage=Bevestig dat u deze secudaire opslag wil message.action.delete.security.group=Bevestig dat u deze security group wilt verwijderen. message.action.delete.service.offering=Bevestig dat u deze service aanbieding wilt verwijderen. message.action.delete.snapshot=Bevestig dat u deze snapshot wilt verwijderen. -message.action.delete.system.service.offering=Bevestig dat u deze systeem service aanbieding wilt verwijderen. +message.action.delete.system.service.offering=Bevestig dat u deze systeem service aanbieding wilt verwijderen. message.action.delete.template=Bevestig dat u deze template wilt verwijderen -message.action.delete.template.for.all.zones=Deze template wordt gebruikt door alle zones. Bevestig dat u deze wilt verwijderen van alle zones. +message.action.delete.template.for.all.zones=Deze template wordt gebruikt door alle zones. Bevestig dat u deze wilt verwijderen van alle zones. message.action.delete.volume=Bevestig dat u dit volume wilt verwijderen message.action.delete.zone=Bevestig dat u deze zone wilt verwijderen message.action.destroy.instance=Bevestig dat u deze instantie wilt vernietigen @@ -1200,13 +1200,13 @@ message.action.disable.zone=Bevestig dat u deze zone wilt uitschakelen. message.action.download.iso=Bevestig dat u deze ISO wilt downloaden. message.action.download.template=Bevestig dat u deze template wilt downloaden. message.action.enable.cluster=Bevestig dat u dit cluster wilt inschakelen. -message.action.enable.maintenance=Uw host is succesvol voorbereid op onderhoud. Het proces kan echter een paar minuten duren afhankelijk van de hoeveelheid VMs op de host. +message.action.enable.maintenance=Uw host is succesvol voorbereid op onderhoud. Het proces kan echter een paar minuten duren afhankelijk van de hoeveelheid VMs op de host. message.action.enable.nexusVswitch=Bevestig dat u deze nexus 1000v wilt inschakelen message.action.enable.physical.network=Bevestig dat u dit fysieke netwerk wilt inschakelen. message.action.enable.pod=Bevestigd dat u deze pod wilt inschakelen. message.action.enable.zone=Bevestig dat u deze zone wilt inschakelen. message.action.force.reconnect=De host is succesvol geforceerd om opnieuw te verbinden. Dit proces kan echter enkele minuten duren. -message.action.host.enable.maintenance.mode=Het inschakelen van de onderhoudsmodus zorgt ervoor dat alle draaiende instanties worden gemigreerd naar andere beschikbare hosts. +message.action.host.enable.maintenance.mode=Het inschakelen van de onderhoudsmodus zorgt ervoor dat alle draaiende instanties worden gemigreerd naar andere beschikbare hosts. message.step.2.desc= message.step.3.desc= mode=Modus diff --git a/client/WEB-INF/classes/resources/messages_pl.properties b/client/WEB-INF/classes/resources/messages_pl.properties index 9024030f51e..84808f818d8 100644 --- a/client/WEB-INF/classes/resources/messages_pl.properties +++ b/client/WEB-INF/classes/resources/messages_pl.properties @@ -37,7 +37,7 @@ label.action.create.vm.processing=Tworz\u0119 VM.... label.action.create.vm=Utw\u00f3rz VM label.action.create.volume.processing=Tworz\u0119 wolumen.... label.action.create.volume=Utw\u00f3rz wolumen -label.action.delete.account.processing=Usuwanie dost\u0119pu.... +label.action.delete.account.processing=Usuwanie dost\u0119pu.... label.action.delete.account=Usu\u0144 dost\u0119p label.action.delete.cluster.processing=Usuwam klaster.... label.action.delete.cluster=Usu\u0144 klaster @@ -160,7 +160,7 @@ label.adding.failed=Dodanie nieudane label.adding.processing=Dodawanie label.adding.succeeded=Dodanie udane label.add.more=Dodaj wi\u0119cej -label.add.network.device=Dodaj urz\u0105dzenie sieciowe +label.add.network.device=Dodaj urz\u0105dzenie sieciowe label.add.network=Dodaj sie\u0107 label.add.new.F5=Dodaj nowy F5 label.add.new.SRX=Dodaj nowy SRX @@ -373,7 +373,7 @@ label.resource=Zas\u00f3b label.restart.required=Wymagany restart label.rules=Zasady label.saturday=Sobota -label.save.and.continue=Zapisz i kontynuuj +label.save.and.continue=Zapisz i kontynuuj label.save=Zapisz label.saving.processing=Zapisywanie.... label.search=Szukaj @@ -396,7 +396,7 @@ label.sticky.domain=Domena label.sticky.expire=Wygasa label.sticky.length=D\u0142ugo\u015b\u0107 label.sticky.mode=Tryb -label.sticky.prefix=Prefiks +label.sticky.prefix=Prefiks label.stop=Stop label.sunday=Niedziela label.suspend.project=Zawie\u015b projekt @@ -458,8 +458,8 @@ state.Creating=Tworzenie state.Declined=Odrzucono state.Destroyed=Zniszczono state.Disabled=Wy\u0142\u0105czony -state.enabled=W\u0142\u0105czone -state.Enabled=W\u0142\u0105czone +state.enabled=W\u0142\u0105czone +state.Enabled=W\u0142\u0105czone state.Error=B\u0142\u0105d state.ready=Gotowe state.Ready=Gotowe diff --git a/client/WEB-INF/classes/resources/messages_pt_BR.properties b/client/WEB-INF/classes/resources/messages_pt_BR.properties index 07fd3f42d76..1bcdc9ce1bc 100644 --- a/client/WEB-INF/classes/resources/messages_pt_BR.properties +++ b/client/WEB-INF/classes/resources/messages_pt_BR.properties @@ -391,7 +391,7 @@ label.cpu.mhz=CPU (em MHz) label.cpu.utilized=CPU Utilizada label.created.by.system=Criado pelo sistema label.created=Criado -label.create.nfs.secondary.staging.store=Criar storage staging secund\u00e1rio NFS +label.create.nfs.secondary.staging.store=Criar storage staging secund\u00e1rio NFS label.create.project=Criar um projeto label.create.template=Criar template label.create.VPN.connection=Criar uma conex\u00e3o VPN @@ -837,15 +837,12 @@ label.public.zone=Zona P\u00fablica label.purpose=Prop\u00f3sito label.Pxe.server.type=Tipo de Servidor PXE label.quickview=Visualiza\u00e7\u00e3o r\u00e1pida -<<<<<<< HEAD -======= label.quiesce.vm=Quiesce VM label.rbd.id=Usu\u00e1rio Ceph label.rbd.monitor=Monitor Ceph label.rbd.pool=Pool Ceph label.rbd=RDB label.rbd.secret=Cephx secret ->>>>>>> 4e449ff... Add Dutch (Netherlands, Polish languages in Web UI Change Japanese code (ja -> ja_JP) Update transifex sync config label.reboot=Reiniciar label.recent.errors=Erros Recentes label.redundant.router.capability=Recurso de roteador redundante @@ -1101,12 +1098,9 @@ label.vm.state=Estado da VM label.vm.stop=Parar label.vms=VMs label.vmware.traffic.label=Etiqueta de tr\u00e1fego VMware -<<<<<<< HEAD -======= label.vnet.id=VLAN ID label.vnet=VLAN label.volatile=Vol\u00e1til ->>>>>>> 4e449ff... Add Dutch (Netherlands, Polish languages in Web UI Change Japanese code (ja -> ja_JP) Update transifex sync config label.volgroup=Grupo de Volume label.volume=Disco label.volume.limits=Limites de Disco @@ -1383,14 +1377,11 @@ message.please.select.a.different.public.and.management.network.before.removing= message.please.select.networks=Por favor selecione as redes para sua m\u00e1quina virtual. message.please.wait.while.zone.is.being.created=Por favor, espere enquanto sua zona est\u00e1 sendo criada; isto pode demorar um pouco... message.project.invite.sent=Convite enviado para o usu\u00e1rio; Eles ser\u00e3o adicionados ao projeto ap\u00f3s aceitarem o convite -<<<<<<< HEAD -======= message.public.traffic.in.advanced.zone=O tr\u00e1fego p\u00fablico \u00e9 gerado quando as VMs na nuvem acessam a internet. Os IPs acess\u00edveis ao p\u00fablico devem ser alocados para essa finalidade. Os usu\u00e1rios finais podem usar a interface do usu\u00e1rio CloudStack para adquirir esses IPs afim de implementar NAT entre a sua rede de guests e sua rede p\u00fablica.

Forne\u00e7a pelo menos um intervalo de endere\u00e7os IP para o tr\u00e1fego de internet. message.public.traffic.in.basic.zone=O tr\u00e1fego p\u00fablico \u00e9 gerado quando as VMs na nuvem acessam a Internet ou prestam servi\u00e7os aos clientes atrav\u00e9s da Internet. Os IPs acess\u00edveis ao p\u00fablico devem ser alocados para essa finalidade. Quando uma inst\u00e2ncia \u00e9 criada, um IP a partir deste conjunto de IPs p\u00fablicos ser\u00e3o destinados \u00e0 inst\u00e2ncia, al\u00e9m do endere\u00e7o IP guest. Um NAT est\u00e1tico 1-1 ser\u00e1 criada automaticamente entre o IP p\u00fablico e IP guest. Os usu\u00e1rios finais tamb\u00e9m podem usar a interface de usu\u00e1rio CloudStack para adquirir IPs adicionais afim de se implementar NAT est\u00e1tico entre suas inst\u00e2ncias e o IP p\u00fablico. message.redirecting.region=Redirecionando para regi\u00e3o... message.remove.ldap=Voc\u00ea tem certeza que deseja deletar a configura\u00e7\u00e3o LDAP? message.remove.region=Voc\u00ea tem certeza que deseja remover esta regi\u00e3o deste servidor de gerenciamento? ->>>>>>> 4e449ff... Add Dutch (Netherlands, Polish languages in Web UI Change Japanese code (ja -> ja_JP) Update transifex sync config message.remove.vpc=Favor confirmar que voc\u00ea deseja remover a VPC message.remove.vpn.access=Confirme se voc\u00ea deseja remover acesso VPN do seguinte Usu\u00e1rio. message.reset.password.warning.notPasswordEnabled=O template desta inst\u00e2ncia foi criado sem senha habilitada diff --git a/client/WEB-INF/classes/resources/messages_zh_CN.properties b/client/WEB-INF/classes/resources/messages_zh_CN.properties index 7cb65d3236b..ea7bfd4c6ef 100644 --- a/client/WEB-INF/classes/resources/messages_zh_CN.properties +++ b/client/WEB-INF/classes/resources/messages_zh_CN.properties @@ -14,9 +14,22 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +label.port=\u7aef\u53e3 +label.remove.ldap=\u5220\u9664 LDAP +label.configure.ldap=\u914d\u7f6e LDAP +label.ldap.configuration=LDAP \u914d\u7f6e +label.ldap.port=LDAP \u7aef\u53e3 +label.create.nfs.secondary.staging.store=\u521b\u5efa NFS \u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8 +label.volatile=\u53ef\u53d8 +label.planner.mode=\u89c4\u5212\u5668\u6a21\u5f0f +label.deployment.planner=\u90e8\u7f72\u89c4\u5212\u5668 +label.quiesce.vm=\u9759\u9ed8 VM +label.smb.username=SMB \u7528\u6237\u540d +label.smb.password=SMB \u5bc6\u7801 +label.smb.domain=SMB \u57df label.hypervisors=\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f label.home=\u9996\u9875 -label.sockets=\u63d2\u69fd +label.sockets=CPU \u63d2\u69fd label.root.disk.size=\u6839\u78c1\u76d8\u5927\u5c0f label.s3.nfs.server=S3 NFS \u670d\u52a1\u5668 label.s3.nfs.path=S3 NFS \u8def\u5f84 @@ -40,18 +53,18 @@ label.disk.iops.min=\u6700\u5c0f IOPS label.disk.iops.max=\u6700\u5927 IOPS label.disk.iops.total=\u603b IOPS label.hypervisor.snapshot.reserve=\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u5feb\u7167\u9884\u7559 -label.view.secondary.ips=\u67e5\u770b\u8f85\u52a9 IP +label.view.secondary.ips=\u67e5\u770b\u4e8c\u7ea7 IP message.validate.invalid.characters=\u67e5\u627e\u5230\u65e0\u6548\u5b57\u7b26\uff0c\u8bf7\u66f4\u6b63\u3002 -message.acquire.ip.nic=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u83b7\u53d6\u6b64 NIC \u7684\u65b0\u8f85\u52a9 IP\u3002
\u6ce8\u610f: \u60a8\u9700\u8981\u5728\u865a\u62df\u673a\u5185\u90e8\u624b\u52a8\u914d\u7f6e\u65b0\u83b7\u53d6\u7684\u8f85\u52a9 IP\u3002 +message.acquire.ip.nic=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u83b7\u53d6\u6b64 NIC \u7684\u65b0\u4e8c\u7ea7 IP\u3002
\u6ce8\u610f: \u60a8\u9700\u8981\u5728\u865a\u62df\u673a\u5185\u90e8\u624b\u52a8\u914d\u7f6e\u65b0\u83b7\u53d6\u7684\u4e8c\u7ea7 IP\u3002 message.select.affinity.groups=\u8bf7\u9009\u62e9\u60a8\u5e0c\u671b\u6b64 VM \u6240\u5c5e\u7684\u4efb\u4f55\u5173\u8054\u6027\u7ec4: message.no.affinity.groups=\u60a8\u6ca1\u6709\u4efb\u4f55\u5173\u8054\u6027\u7ec4\u3002\u8bf7\u7ee7\u7eed\u6267\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c\u3002 label.action.delete.nic=\u79fb\u9664 NIC message.action.delete.nic=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u79fb\u9664\u6b64 NIC\uff0c\u6b64\u64cd\u4f5c\u8fd8\u5c06\u4ece VM \u4e2d\u79fb\u9664\u5173\u8054\u7684\u7f51\u7edc\u3002 changed.item.properties=\u66f4\u6539\u9879\u76ee\u5c5e\u6027 -confirm.enable.s3=\u8bf7\u586b\u5199\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u542f\u7528\u5bf9 S3 \u652f\u6301\u7684\u8f85\u52a9\u5b58\u50a8\u7684\u652f\u6301 +confirm.enable.s3=\u8bf7\u586b\u5199\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u542f\u7528\u5bf9 S3 \u652f\u6301\u7684\u4e8c\u7ea7\u5b58\u50a8\u7684\u652f\u6301 confirm.enable.swift=\u8bf7\u586b\u5199\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u542f\u7528\u5bf9 SWIFT \u7684\u652f\u6301 error.could.not.change.your.password.because.ldap.is.enabled=\u9519\u8bef\u3002LDAP \u5904\u4e8e\u542f\u7528\u72b6\u6001\uff0c\u65e0\u6cd5\u66f4\u6539\u60a8\u7684\u5bc6\u7801\u3002 -error.could.not.enable.zone=\u65e0\u6cd5\u542f\u7528\u533a\u57df +error.could.not.enable.zone=\u65e0\u6cd5\u542f\u7528\u8d44\u6e90\u57df error.installWizard.message=\u51fa\u73b0\u95ee\u9898\uff1b\u8bf7\u8fd4\u56de\u5e76\u66f4\u6b63\u4efb\u4f55\u9519\u8bef error.invalid.username.password=\u7528\u6237\u540d\u6216\u5bc6\u7801\u65e0\u6548 error.login=\u60a8\u7684\u7528\u6237\u540d/\u5bc6\u7801\u4e0e\u6211\u4eec\u7684\u8bb0\u5f55\u4e0d\u4e00\u81f4\u3002 @@ -83,7 +96,7 @@ label.account.specific=\u5e10\u6237\u4e13\u7528 label.account=\u5e10\u6237 label.accounts=\u5e10\u6237 label.acquire.new.ip=\u83b7\u53d6\u65b0 IP -label.acquire.new.secondary.ip=\u83b7\u53d6\u65b0\u8f85\u52a9 IP +label.acquire.new.secondary.ip=\u83b7\u53d6\u65b0\u4e8c\u7ea7 IP label.action.attach.disk.processing=\u6b63\u5728\u9644\u52a0\u78c1\u76d8... label.action.attach.disk=\u9644\u52a0\u78c1\u76d8 label.action.attach.iso.processing=\u6b63\u5728\u9644\u52a0 ISO... @@ -131,8 +144,8 @@ label.action.delete.pod.processing=\u6b63\u5728\u5220\u9664\u63d0\u4f9b\u70b9... label.action.delete.pod=\u5220\u9664\u63d0\u4f9b\u70b9 label.action.delete.primary.storage.processing=\u6b63\u5728\u5220\u9664\u4e3b\u5b58\u50a8... label.action.delete.primary.storage=\u5220\u9664\u4e3b\u5b58\u50a8 -label.action.delete.secondary.storage.processing=\u6b63\u5728\u5220\u9664\u8f85\u52a9\u5b58\u50a8... -label.action.delete.secondary.storage=\u5220\u9664\u8f85\u52a9\u5b58\u50a8 +label.action.delete.secondary.storage.processing=\u6b63\u5728\u5220\u9664\u4e8c\u7ea7\u5b58\u50a8... +label.action.delete.secondary.storage=\u5220\u9664\u4e8c\u7ea7\u5b58\u50a8 label.action.delete.security.group.processing=\u6b63\u5728\u5220\u9664\u5b89\u5168\u7ec4... label.action.delete.security.group=\u5220\u9664\u5b89\u5168\u7ec4 label.action.delete.service.offering.processing=\u6b63\u5728\u5220\u9664\u670d\u52a1\u65b9\u6848... @@ -146,8 +159,8 @@ label.action.delete.user.processing=\u6b63\u5728\u5220\u9664\u7528\u6237... label.action.delete.user=\u5220\u9664\u7528\u6237 label.action.delete.volume.processing=\u6b63\u5728\u5220\u9664\u5377... label.action.delete.volume=\u5220\u9664\u5377 -label.action.delete.zone.processing=\u6b63\u5728\u5220\u9664\u533a\u57df... -label.action.delete.zone=\u5220\u9664\u533a\u57df +label.action.delete.zone.processing=\u6b63\u5728\u5220\u9664\u8d44\u6e90\u57df... +label.action.delete.zone=\u5220\u9664\u8d44\u6e90\u57df label.action.destroy.instance.processing=\u6b63\u5728\u9500\u6bc1\u5b9e\u4f8b... label.action.destroy.instance=\u9500\u6bc1\u5b9e\u4f8b label.action.destroy.systemvm.processing=\u6b63\u5728\u9500\u6bc1\u7cfb\u7edf VM... @@ -168,8 +181,8 @@ label.action.disable.static.NAT.processing=\u6b63\u5728\u7981\u7528\u9759\u6001 label.action.disable.static.NAT=\u7981\u7528\u9759\u6001 NAT label.action.disable.user.processing=\u6b63\u5728\u7981\u7528\u7528\u6237... label.action.disable.user=\u7981\u7528\u7528\u6237 -label.action.disable.zone.processing=\u6b63\u5728\u7981\u7528\u533a\u57df... -label.action.disable.zone=\u7981\u7528\u533a\u57df +label.action.disable.zone.processing=\u6b63\u5728\u7981\u7528\u8d44\u6e90\u57df... +label.action.disable.zone=\u7981\u7528\u8d44\u6e90\u57df label.action.download.ISO=\u4e0b\u8f7d ISO label.action.download.template=\u4e0b\u8f7d\u6a21\u677f label.action.download.volume.processing=\u6b63\u5728\u4e0b\u8f7d\u5377... @@ -190,7 +203,7 @@ label.action.edit.resource.limits=\u7f16\u8f91\u8d44\u6e90\u9650\u5236 label.action.edit.service.offering=\u7f16\u8f91\u670d\u52a1\u65b9\u6848 label.action.edit.template=\u7f16\u8f91\u6a21\u677f label.action.edit.user=\u7f16\u8f91\u7528\u6237 -label.action.edit.zone=\u7f16\u8f91\u533a\u57df +label.action.edit.zone=\u7f16\u8f91\u8d44\u6e90\u57df label.action.enable.account.processing=\u6b63\u5728\u542f\u7528\u5e10\u6237... label.action.enable.account=\u542f\u7528\u5e10\u6237 label.action.enable.cluster.processing=\u6b63\u5728\u542f\u7528\u7fa4\u96c6... @@ -205,8 +218,8 @@ label.action.enable.static.NAT.processing=\u6b63\u5728\u542f\u7528\u9759\u6001 N label.action.enable.static.NAT=\u542f\u7528\u9759\u6001 NAT label.action.enable.user.processing=\u6b63\u5728\u542f\u7528\u7528\u6237... label.action.enable.user=\u542f\u7528\u7528\u6237 -label.action.enable.zone.processing=\u6b63\u5728\u542f\u7528\u533a\u57df... -label.action.enable.zone=\u542f\u7528\u533a\u57df +label.action.enable.zone.processing=\u6b63\u5728\u542f\u7528\u8d44\u6e90\u57df... +label.action.enable.zone=\u542f\u7528\u8d44\u6e90\u57df label.action.expunge.instance=\u5220\u9664\u5b9e\u4f8b label.action.expunge.instance.processing=\u6b63\u5728\u5220\u9664\u5b9e\u4f8b... label.action.force.reconnect.processing=\u6b63\u5728\u91cd\u65b0\u8fde\u63a5... @@ -312,11 +325,11 @@ label.add.physical.network=\u6dfb\u52a0\u7269\u7406\u7f51\u7edc label.add.pod=\u6dfb\u52a0\u63d0\u4f9b\u70b9 label.add.port.forwarding.rule=\u6dfb\u52a0\u7aef\u53e3\u8f6c\u53d1\u89c4\u5219 label.add.primary.storage=\u6dfb\u52a0\u4e3b\u5b58\u50a8 -label.add.region=\u6dfb\u52a0\u533a\u57df +label.add.region=\u6dfb\u52a0\u5730\u7406\u533a\u57df label.add.resources=\u6dfb\u52a0\u8d44\u6e90 label.add.route=\u6dfb\u52a0\u8def\u7531 label.add.rule=\u6dfb\u52a0\u89c4\u5219 -label.add.secondary.storage=\u6dfb\u52a0\u8f85\u52a9\u5b58\u50a8 +label.add.secondary.storage=\u6dfb\u52a0\u4e8c\u7ea7\u5b58\u50a8 label.add.security.group=\u6dfb\u52a0\u5b89\u5168\u7ec4 label.add.service.offering=\u6dfb\u52a0\u670d\u52a1\u65b9\u6848 label.add.SRX.device=\u6dfb\u52a0 SRX \u8bbe\u5907 @@ -338,7 +351,7 @@ label.add.vpc=\u6dfb\u52a0 VPC label.add.vpn.customer.gateway=\u6dfb\u52a0 VPN \u5ba2\u6237\u7f51\u5173 label.add.VPN.gateway=\u6dfb\u52a0 VPN \u7f51\u5173 label.add.vpn.user=\u6dfb\u52a0 VPN \u7528\u6237 -label.add.zone=\u6dfb\u52a0\u533a\u57df +label.add.zone=\u6dfb\u52a0\u8d44\u6e90\u57df label.add=\u6dfb\u52a0 label.adding.cluster=\u6b63\u5728\u6dfb\u52a0\u7fa4\u96c6 label.adding.failed=\u6dfb\u52a0\u5931\u8d25 @@ -346,7 +359,7 @@ label.adding.pod=\u6b63\u5728\u6dfb\u52a0\u63d0\u4f9b\u70b9 label.adding.processing=\u6b63\u5728\u6dfb\u52a0... label.adding.succeeded=\u5df2\u6210\u529f\u6dfb\u52a0 label.adding.user=\u6b63\u5728\u6dfb\u52a0\u7528\u6237 -label.adding.zone=\u6b63\u5728\u6dfb\u52a0\u533a\u57df +label.adding.zone=\u6b63\u5728\u6dfb\u52a0\u8d44\u6e90\u57df label.adding=\u6b63\u5728\u6dfb\u52a0 label.additional.networks=\u5176\u4ed6\u7f51\u7edc label.admin.accounts=\u7ba1\u7406\u5458\u5e10\u6237 @@ -376,7 +389,7 @@ label.associated.network=\u5173\u8054\u7f51\u7edc label.attached.iso=\u5df2\u9644\u52a0 ISO label.author.email=\u4f5c\u8005\u7535\u5b50\u90ae\u4ef6 label.author.name=\u4f5c\u8005\u59d3\u540d -label.availability.zone=\u53ef\u7528\u533a\u57df +label.availability.zone=\u53ef\u7528\u8d44\u6e90\u57df label.availability=\u53ef\u7528\u6027 label.available.public.ips=\u53ef\u7528\u516c\u7528 IP \u5730\u5740 label.available=\u53ef\u7528 @@ -398,10 +411,10 @@ label.by.pod=\u6309\u63d0\u4f9b\u70b9 label.by.role=\u6309\u89d2\u8272 label.by.start.date=\u6309\u5f00\u59cb\u65e5\u671f label.by.state=\u6309\u72b6\u6001 -label.by.traffic.type=\u6309\u901a\u4fe1\u7c7b\u578b +label.by.traffic.type=\u6309\u6d41\u91cf\u7c7b\u578b label.by.type.id=\u6309\u7c7b\u578b ID label.by.type=\u6309\u7c7b\u578b -label.by.zone=\u6309\u533a\u57df +label.by.zone=\u6309\u8d44\u6e90\u57df label.bytes.received=\u63a5\u6536\u7684\u5b57\u8282\u6570 label.bytes.sent=\u53d1\u9001\u7684\u5b57\u8282\u6570 label.cancel=\u53d6\u6d88 @@ -461,7 +474,7 @@ label.create.template=\u521b\u5efa\u6a21\u677f label.create.VPN.connection=\u521b\u5efa VPN \u8fde\u63a5 label.created.by.system=\u7531\u7cfb\u7edf\u521b\u5efa label.created=\u521b\u5efa\u65e5\u671f -label.cross.zones=\u8de8\u533a\u57df +label.cross.zones=\u8de8\u8d44\u6e90\u57df label.custom.disk.size=\u81ea\u5b9a\u4e49\u78c1\u76d8\u5927\u5c0f label.daily=\u6bcf\u5929 label.data.disk.offering=\u6570\u636e\u78c1\u76d8\u65b9\u6848 @@ -492,7 +505,7 @@ label.deleting.failed=\u5220\u9664\u5931\u8d25 label.deleting.processing=\u6b63\u5728\u5220\u9664... label.description=\u8bf4\u660e label.destination.physical.network.id=\u76ee\u6807\u7269\u7406\u7f51\u7edc ID -label.destination.zone=\u76ee\u6807\u533a\u57df +label.destination.zone=\u76ee\u6807\u8d44\u6e90\u57df label.destroy.router=\u9500\u6bc1\u8def\u7531\u5668 label.destroy=\u9500\u6bc1 label.detaching.disk=\u6b63\u5728\u53d6\u6d88\u9644\u52a0\u78c1\u76d8 @@ -541,7 +554,7 @@ label.edit.lb.rule=\u7f16\u8f91\u8d1f\u8f7d\u5e73\u8861\u5668\u89c4\u5219 label.edit.network.details=\u7f16\u8f91\u7f51\u7edc\u8be6\u60c5 label.edit.project.details=\u7f16\u8f91\u9879\u76ee\u8be6\u60c5 label.edit.tags=\u7f16\u8f91\u6807\u7b7e -label.edit.traffic.type=\u7f16\u8f91\u901a\u4fe1\u7c7b\u578b +label.edit.traffic.type=\u7f16\u8f91\u6d41\u91cf\u7c7b\u578b label.edit.vpc=\u7f16\u8f91 VPC label.edit=\u7f16\u8f91 label.egress.rule=\u51fa\u53e3\u89c4\u5219 @@ -551,7 +564,7 @@ label.elastic.LB=\u5f39\u6027\u8d1f\u8f7d\u5e73\u8861\u5668 label.elastic=\u5f39\u6027 label.email=\u7535\u5b50\u90ae\u4ef6 label.enable.provider=\u542f\u7528\u63d0\u4f9b\u7a0b\u5e8f -label.enable.s3=\u542f\u7528 S3 \u652f\u6301\u7684\u8f85\u52a9\u5b58\u50a8 +label.enable.s3=\u542f\u7528 S3 \u652f\u6301\u7684\u4e8c\u7ea7\u5b58\u50a8 label.enable.swift=\u542f\u7528 SWIFT label.enable.vpn=\u542f\u7528 VPN label.enabling.vpn.access=\u6b63\u5728\u542f\u7528 VPN \u8bbf\u95ee @@ -588,6 +601,7 @@ label.full=\u6ee1\u8f7d label.gateway=\u7f51\u5173 label.general.alerts=\u5e38\u89c4\u8b66\u62a5 label.generating.url=\u6b63\u5728\u751f\u6210 URL +label.gluster.volume=\u5377 label.go.step.2=\u8f6c\u81f3\u6b65\u9aa4 2 label.go.step.3=\u8f6c\u81f3\u6b65\u9aa4 3 label.go.step.4=\u8f6c\u81f3\u6b65\u9aa4 4 @@ -602,7 +616,7 @@ label.guest.ip=\u6765\u5bbe IP \u5730\u5740 label.guest.netmask=\u6765\u5bbe\u7f51\u7edc\u63a9\u7801 label.guest.networks=\u6765\u5bbe\u7f51\u7edc label.guest.start.ip=\u6765\u5bbe\u8d77\u59cb IP -label.guest.traffic=\u6765\u5bbe\u901a\u4fe1 +label.guest.traffic=\u6765\u5bbe\u6d41\u91cf label.guest.type=\u6765\u5bbe\u7c7b\u578b label.guest=\u6765\u5bbe label.ha.enabled=\u5df2\u542f\u7528\u9ad8\u53ef\u7528\u6027 @@ -637,11 +651,11 @@ label.installWizard.addPodIntro.subtitle=\u4ec0\u4e48\u662f\u63d0\u4f9b\u70b9? label.installWizard.addPodIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u63d0\u4f9b\u70b9 label.installWizard.addPrimaryStorageIntro.subtitle=\u4ec0\u4e48\u662f\u4e3b\u5b58\u50a8? label.installWizard.addPrimaryStorageIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u4e3b\u5b58\u50a8 -label.installWizard.addSecondaryStorageIntro.subtitle=\u4ec0\u4e48\u662f\u8f85\u52a9\u5b58\u50a8? -label.installWizard.addSecondaryStorageIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u8f85\u52a9\u5b58\u50a8 -label.installWizard.addZone.title=\u6dfb\u52a0\u533a\u57df -label.installWizard.addZoneIntro.subtitle=\u4ec0\u4e48\u662f\u533a\u57df? -label.installWizard.addZoneIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u533a\u57df +label.installWizard.addSecondaryStorageIntro.subtitle=\u4ec0\u4e48\u662f\u4e8c\u7ea7\u5b58\u50a8? +label.installWizard.addSecondaryStorageIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u4e8c\u7ea7\u5b58\u50a8 +label.installWizard.addZone.title=\u6dfb\u52a0\u8d44\u6e90\u57df +label.installWizard.addZoneIntro.subtitle=\u4ec0\u4e48\u662f\u8d44\u6e90\u57df? +label.installWizard.addZoneIntro.title=\u6dfb\u52a0\u4e00\u4e2a\u8d44\u6e90\u57df label.installWizard.click.launch=\u8bf7\u5355\u51fb\u201c\u542f\u52a8\u201d\u6309\u94ae\u3002 label.installWizard.subtitle=\u6b64\u6559\u7a0b\u5c06\u5e2e\u52a9\u60a8\u8bbe\u7f6e CloudStack&\#8482 \u5b89\u88c5 label.installWizard.title=\u60a8\u597d\uff0c\u6b22\u8fce\u4f7f\u7528 CloudStack&\#8482 @@ -685,12 +699,13 @@ label.item.listing=\u9879\u76ee\u5217\u8868 label.keep=\u4fdd\u7559 label.key=\u5bc6\u94a5 label.keyboard.type=\u952e\u76d8\u7c7b\u578b -label.kvm.traffic.label=KVM \u901a\u4fe1\u6807\u7b7e +label.kvm.traffic.label=KVM \u6d41\u91cf\u6807\u7b7e label.label=\u6807\u7b7e label.lang.arabic=\u963f\u62c9\u4f2f\u8bed label.lang.brportugese=\u8461\u8404\u7259\u8bed(\u5df4\u897f) label.lang.catalan=\u52a0\u6cf0\u7f57\u5c3c\u4e9a\u8bed label.lang.chinese=\u7b80\u4f53\u4e2d\u6587 +label.lang.dutch=\u8377\u5170\u8bed(\u8377\u5170) label.lang.english=\u82f1\u8bed label.lang.french=\u6cd5\u8bed label.lang.german=\u5fb7\u8bed @@ -698,13 +713,14 @@ label.lang.italian=\u610f\u5927\u5229\u8bed label.lang.japanese=\u65e5\u8bed label.lang.korean=\u97e9\u8bed label.lang.norwegian=\u632a\u5a01\u8bed +label.lang.polish=\u6ce2\u5170\u8bed label.lang.russian=\u4fc4\u8bed label.lang.spanish=\u897f\u73ed\u7259\u8bed label.last.disconnected=\u4e0a\u6b21\u65ad\u5f00\u8fde\u63a5\u65f6\u95f4 label.last.name=\u59d3\u6c0f label.latest.events=\u6700\u65b0\u4e8b\u4ef6 label.launch.vm=\u542f\u52a8 VM -label.launch.zone=\u542f\u52a8\u533a\u57df +label.launch.zone=\u542f\u52a8\u8d44\u6e90\u57df label.launch=\u542f\u52a8 label.LB.isolation=\u8d1f\u8f7d\u5e73\u8861\u5668\u9694\u79bb label.least.connections=\u6700\u5c11\u8fde\u63a5\u7b97\u6cd5 @@ -732,7 +748,7 @@ label.max.memory=\u6700\u5927\u5185\u5b58(MiB) label.max.networks=\u6700\u5927\u7f51\u7edc\u6570 label.max.primary.storage=\u6700\u5927\u4e3b\u5b58\u50a8(GiB) label.max.public.ips=\u6700\u5927\u516c\u7528 IP \u6570 -label.max.secondary.storage=\u6700\u5927\u8f85\u52a9\u5b58\u50a8(GiB) +label.max.secondary.storage=\u6700\u5927\u4e8c\u7ea7\u5b58\u50a8(GiB) label.max.snapshots=\u6700\u5927\u5feb\u7167\u6570 label.max.templates=\u6700\u5927\u6a21\u677f\u6570 label.max.vms=\u6700\u5927\u7528\u6237 VM \u6570 @@ -772,7 +788,7 @@ label.menu.my.templates=\u6211\u7684\u6a21\u677f label.menu.network.offerings=\u7f51\u7edc\u65b9\u6848 label.menu.network=\u7f51\u7edc label.menu.physical.resources=\u7269\u7406\u8d44\u6e90 -label.menu.regions=\u533a\u57df +label.menu.regions=\u5730\u7406\u533a\u57df label.menu.running.instances=\u6b63\u5728\u8fd0\u884c\u7684\u5b9e\u4f8b label.menu.security.groups=\u5b89\u5168\u7ec4 label.menu.service.offerings=\u670d\u52a1\u65b9\u6848 @@ -848,7 +864,7 @@ label.nfs=NFS label.nic.adapter.type=NIC \u9002\u914d\u5668\u7c7b\u578b label.nicira.controller.address=\u63a7\u5236\u5668\u5730\u5740 label.nicira.l3gatewayserviceuuid=L3 Gateway Service UUID -label.nicira.transportzoneuuid=\u4f20\u8f93\u533a\u57df UUID +label.nicira.transportzoneuuid=\u4f20\u8f93\u8d44\u6e90\u57df UUID label.nics=NIC label.no.actions=\u65e0\u53ef\u7528\u64cd\u4f5c label.no.alerts=\u65e0\u6700\u8fd1\u53d1\u51fa\u7684\u8b66\u62a5 @@ -868,7 +884,7 @@ label.number.of.hosts=\u4e3b\u673a\u6570\u91cf label.number.of.pods=\u63d0\u4f9b\u70b9\u6570\u91cf label.number.of.system.vms=\u7cfb\u7edf VM \u6570 label.number.of.virtual.routers=\u865a\u62df\u8def\u7531\u5668\u6570 -label.number.of.zones=\u533a\u57df\u6570\u91cf +label.number.of.zones=\u8d44\u6e90\u57df\u6570\u91cf label.numretries=\u91cd\u8bd5\u6b21\u6570 label.ocfs2=OCFS2 label.offer.ha=\u63d0\u4f9b\u9ad8\u53ef\u7528\u6027 @@ -919,7 +935,7 @@ label.private.ip=\u4e13\u7528 IP \u5730\u5740 label.private.ips=\u4e13\u7528 IP \u5730\u5740 label.private.network=\u4e13\u7528\u7f51\u7edc label.private.port=\u4e13\u7528\u7aef\u53e3 -label.private.zone=\u4e13\u7528\u533a\u57df +label.private.zone=\u4e13\u7528\u8d44\u6e90\u57df label.privatekey=PKCS\#8 \u79c1\u94a5 label.project.dashboard=\u9879\u76ee\u63a7\u5236\u677f label.project.id=\u9879\u76ee ID @@ -935,8 +951,8 @@ label.public.ip=\u516c\u7528 IP \u5730\u5740 label.public.ips=\u516c\u7528 IP \u5730\u5740 label.public.network=\u516c\u7528\u7f51\u7edc label.public.port=\u516c\u7528\u7aef\u53e3 -label.public.traffic=\u516c\u5171\u901a\u4fe1 -label.public.zone=\u516c\u7528\u533a\u57df +label.public.traffic=\u516c\u5171\u6d41\u91cf +label.public.zone=\u516c\u7528\u8d44\u6e90\u57df label.public=\u516c\u7528 label.purpose=\u76ee\u7684 label.Pxe.server.type=Pxe \u670d\u52a1\u5668\u7c7b\u578b @@ -947,7 +963,7 @@ label.redundant.router.capability=\u5197\u4f59\u8def\u7531\u5668\u529f\u80fd label.redundant.router=\u5197\u4f59\u8def\u7531\u5668 label.redundant.state=\u5197\u4f59\u72b6\u6001 label.refresh=\u5237\u65b0 -label.region=\u533a\u57df +label.region=\u5730\u7406\u533a\u57df label.related=\u76f8\u5173\u8054 label.remind.later=\u4ee5\u540e\u63d0\u9192\u6211 label.remove.ACL=\u5220\u9664 ACL @@ -957,7 +973,7 @@ label.remove.ingress.rule=\u5220\u9664\u5165\u53e3\u89c4\u5219 label.remove.ip.range=\u5220\u9664 IP \u8303\u56f4 label.remove.pf=\u5220\u9664\u7aef\u53e3\u8f6c\u53d1\u89c4\u5219 label.remove.project.account=\u4ece\u9879\u76ee\u4e2d\u5220\u9664\u5e10\u6237 -label.remove.region=\u79fb\u9664\u533a\u57df +label.remove.region=\u5220\u9664\u5730\u7406\u533a\u57df label.remove.rule=\u5220\u9664\u89c4\u5219 label.remove.static.nat.rule=\u5220\u9664\u9759\u6001 NAT \u89c4\u5219 label.remove.static.route=\u5220\u9664\u9759\u6001\u8def\u7531 @@ -1004,11 +1020,11 @@ label.save=\u4fdd\u5b58 label.saving.processing=\u6b63\u5728\u4fdd\u5b58... label.scope=\u8303\u56f4 label.search=\u641c\u7d22 -label.secondary.storage.count=\u8f85\u52a9\u5b58\u50a8\u6c60 -label.secondary.storage.limits=\u8f85\u52a9\u5b58\u50a8\u9650\u5236(GiB) -label.secondary.storage.vm=\u8f85\u52a9\u5b58\u50a8 VM -label.secondary.storage=\u8f85\u52a9\u5b58\u50a8 -label.secondary.used=\u5df2\u4f7f\u7528\u7684\u8f85\u52a9\u5b58\u50a8 +label.secondary.storage.count=\u4e8c\u7ea7\u5b58\u50a8\u6c60 +label.secondary.storage.limits=\u4e8c\u7ea7\u5b58\u50a8\u9650\u5236(GiB) +label.secondary.storage.vm=\u4e8c\u7ea7\u5b58\u50a8 VM +label.secondary.storage=\u4e8c\u7ea7\u5b58\u50a8 +label.secondary.used=\u5df2\u4f7f\u7528\u7684\u4e8c\u7ea7\u5b58\u50a8 label.secret.key=\u5bc6\u94a5 label.security.group.name=\u5b89\u5168\u7ec4\u540d\u79f0 label.security.group=\u5b89\u5168\u7ec4 @@ -1016,7 +1032,7 @@ label.security.groups.enabled=\u5df2\u542f\u7528\u5b89\u5168\u7ec4 label.security.groups=\u5b89\u5168\u7ec4 label.select-view=\u9009\u62e9\u89c6\u56fe label.select.a.template=\u9009\u62e9\u4e00\u4e2a\u6a21\u677f -label.select.a.zone=\u9009\u62e9\u4e00\u4e2a\u533a\u57df +label.select.a.zone=\u9009\u62e9\u4e00\u4e2a\u8d44\u6e90\u57df label.select.instance.to.attach.volume.to=\u9009\u62e9\u8981\u5c06\u5377\u9644\u52a0\u5230\u7684\u5b9e\u4f8b label.select.instance=\u9009\u62e9\u5b9e\u4f8b label.select.iso.or.template=\u9009\u62e9 ISO \u6216\u6a21\u677f @@ -1030,9 +1046,9 @@ label.server=\u670d\u52a1\u5668 label.service.capabilities=\u670d\u52a1\u529f\u80fd label.service.offering=\u670d\u52a1\u65b9\u6848 label.session.expired=\u4f1a\u8bdd\u5df2\u8fc7\u671f -label.set.up.zone.type=\u8bbe\u7f6e\u533a\u57df\u7c7b\u578b +label.set.up.zone.type=\u8bbe\u7f6e\u8d44\u6e90\u57df\u7c7b\u578b label.setup.network=\u8bbe\u7f6e\u7f51\u7edc -label.setup.zone=\u8bbe\u7f6e\u533a\u57df +label.setup.zone=\u8bbe\u7f6e\u8d44\u6e90\u57df label.setup=\u8bbe\u7f6e label.shared=\u5df2\u5171\u4eab label.SharedMountPoint=SharedMountPoint @@ -1052,7 +1068,7 @@ label.source=\u6e90\u7b97\u6cd5 label.specify.IP.ranges=\u6307\u5b9a IP \u8303\u56f4 label.specify.vlan=\u6307\u5b9a VLAN label.specify.vxlan=\u6307\u5b9a VXLAN -label.SR.name = SR \u540d\u79f0\u6807\u7b7e +label.SR.name=SR \u540d\u79f0\u6807\u7b7e label.srx=SRX label.PA=Palo Alto label.start.IP=\u8d77\u59cb IP @@ -1093,7 +1109,7 @@ label.sticky.tablesize=\u8868\u5927\u5c0f label.stop=\u505c\u6b62 label.stopped.vms=\u5df2\u505c\u6b62\u7684 VM label.storage.tags=\u5b58\u50a8\u6807\u7b7e -label.storage.traffic=\u5b58\u50a8\u901a\u4fe1 +label.storage.traffic=\u5b58\u50a8\u6d41\u91cf label.storage.type=\u5b58\u50a8\u7c7b\u578b label.qos.type=QoS \u7c7b\u578b label.cache.mode=\u5199\u5165\u7f13\u5b58\u7c7b\u578b @@ -1129,7 +1145,7 @@ label.tier.details=\u5c42\u8be6\u7ec6\u4fe1\u606f label.tier=\u5c42 label.time.zone=\u65f6\u533a label.time=\u65f6\u95f4 -label.timeout.in.second = \u8d85\u65f6(\u79d2) +label.timeout.in.second=\u8d85\u65f6(\u79d2) label.timeout=\u8d85\u65f6 label.timezone=\u65f6\u533a label.token=\u4ee4\u724c @@ -1141,9 +1157,9 @@ label.total.of.ip=\u603b IP \u5730\u5740\u6570 label.total.of.vm=\u603b VM \u6570 label.total.storage=\u5b58\u50a8\u603b\u91cf label.total.vms=\u603b VM \u6570 -label.traffic.label=\u901a\u4fe1\u6807\u7b7e -label.traffic.type=\u901a\u4fe1\u7c7b\u578b -label.traffic.types=\u901a\u4fe1\u7c7b\u578b +label.traffic.label=\u6d41\u91cf\u6807\u7b7e +label.traffic.type=\u6d41\u91cf\u7c7b\u578b +label.traffic.types=\u6d41\u91cf\u7c7b\u578b label.tuesday=\u661f\u671f\u4e8c label.type.id=\u7c7b\u578b ID label.type=\u7c7b\u578b @@ -1151,8 +1167,8 @@ label.unavailable=\u4e0d\u53ef\u7528 label.unlimited=\u65e0\u9650\u5236 label.untagged=\u5df2\u53d6\u6d88\u6807\u8bb0 label.update.project.resources=\u66f4\u65b0\u9879\u76ee\u8d44\u6e90 -label.update.ssl.cert= SSL \u8bc1\u4e66 -label.update.ssl= SSL \u8bc1\u4e66 +label.update.ssl.cert=SSL \u8bc1\u4e66 +label.update.ssl=SSL \u8bc1\u4e66 label.updating=\u6b63\u5728\u66f4\u65b0 label.upload.volume=\u4e0a\u8f7d\u5377 label.upload=\u4e0a\u8f7d @@ -1209,7 +1225,7 @@ label.vmsnapshot.memory=\u5feb\u7167\u5185\u5b58 label.vmsnapshot.parentname=\u7236\u540d\u79f0 label.vmsnapshot.type=\u7c7b\u578b label.vmsnapshot=VM \u5feb\u7167 -label.vmware.traffic.label=VMware \u901a\u4fe1\u6807\u7b7e +label.vmware.traffic.label=VMware \u6d41\u91cf\u6807\u7b7e label.volgroup=\u5377\u7ec4 label.volume.limits=\u5377\u9650\u5236 label.volume.name=\u5377\u540d\u79f0 @@ -1234,28 +1250,240 @@ label.weekly=\u6bcf\u5468 label.welcome.cloud.console=\u6b22\u8fce\u4f7f\u7528\u7ba1\u7406\u63a7\u5236\u53f0 label.welcome=\u6b22\u8fce label.what.is.cloudstack=\u4ec0\u4e48\u662f CloudStack&\#8482? -label.xen.traffic.label=XenServer \u901a\u4fe1\u6807\u7b7e +label.xen.traffic.label=XenServer \u6d41\u91cf\u6807\u7b7e label.yes=\u662f -label.zone.details=\u533a\u57df\u8be6\u60c5 -label.zone.id=\u533a\u57df ID -label.zone.name=\u533a\u57df\u540d\u79f0 +label.zone.details=\u8d44\u6e90\u57df\u8be6\u7ec6\u4fe1\u606f +label.zone.id=\u8d44\u6e90\u57df ID +label.zone.name=\u8d44\u6e90\u57df\u540d\u79f0 label.zone.step.1.title=\u6b65\u9aa4 1\: \u9009\u62e9\u4e00\u4e2a\u7f51\u7edc -label.zone.step.2.title=\u6b65\u9aa4 2\: \u6dfb\u52a0\u4e00\u4e2a\u533a\u57df +label.zone.step.2.title=\u6b65\u9aa4 2\: \u6dfb\u52a0\u4e00\u4e2a\u8d44\u6e90\u57df label.zone.step.3.title=\u6b65\u9aa4 3\: \u6dfb\u52a0\u4e00\u4e2a\u63d0\u4f9b\u70b9 label.zone.step.4.title=\u6b65\u9aa4 4\: \u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4 -label.zone.type=\u533a\u57df\u7c7b\u578b -label.zone.wide=\u6574\u4e2a\u533a\u57df -label.zone=\u533a\u57df -label.zones=\u533a\u57df -label.zoneWizard.trafficType.guest=\u6765\u5bbe\: \u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1 -label.zoneWizard.trafficType.management=\u7ba1\u7406\: CloudStack \u7684\u5185\u90e8\u8d44\u6e90(\u5305\u62ec\u4e0e\u7ba1\u7406\u670d\u52a1\u5668\u901a\u4fe1\u7684\u4efb\u4f55\u7ec4\u4ef6\uff0c\u4f8b\u5982\u4e3b\u673a\u548c CloudStack \u7cfb\u7edf VM)\u4e4b\u95f4\u7684\u901a\u4fe1 -label.zoneWizard.trafficType.public=\u516c\u7528\: \u4e91\u4e2d Internet \u4e0e\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002 -label.zoneWizard.trafficType.storage=\u5b58\u50a8\: \u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u4e0e\u8f85\u52a9\u5b58\u50a8\u670d\u52a1\u5668(\u4f8b\u5982 VM \u6a21\u677f\u4e0e\u5feb\u7167)\u4e4b\u95f4\u7684\u901a\u4fe1 +label.zone.type=\u8d44\u6e90\u57df\u7c7b\u578b +label.zone.wide=\u6574\u4e2a\u8d44\u6e90\u57df +label.zone=\u8d44\u6e90\u57df +label.zones=\u8d44\u6e90\u57df +label.zoneWizard.trafficType.guest=\u6765\u5bbe\: \u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u6d41\u91cf +label.zoneWizard.trafficType.management=\u7ba1\u7406\: CloudStack \u7684\u5185\u90e8\u8d44\u6e90(\u5305\u62ec\u4e0e\u7ba1\u7406\u670d\u52a1\u5668\u901a\u4fe1\u7684\u4efb\u4f55\u7ec4\u4ef6\uff0c\u4f8b\u5982\u4e3b\u673a\u548c CloudStack \u7cfb\u7edf VM)\u4e4b\u95f4\u7684\u6d41\u91cf +label.zoneWizard.trafficType.public=\u516c\u5171\: \u4e91\u4e2d Internet \u4e0e\u865a\u62df\u673a\u4e4b\u95f4\u7684\u6d41\u91cf\u3002 +label.zoneWizard.trafficType.storage=\u5b58\u50a8\: \u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u4e0e\u4e8c\u7ea7\u5b58\u50a8\u670d\u52a1\u5668(\u4f8b\u5982 VM \u6a21\u677f\u4e0e\u5feb\u7167)\u4e4b\u95f4\u7684\u6d41\u91cf label.ldap.group.name=LDAP \u7ec4 +label.password.reset.confirm=\u5bc6\u7801\u5df2\u91cd\u7f6e\u4e3a +label.provider=\u63d0\u4f9b\u7a0b\u5e8f +label.resetVM=\u91cd\u7f6e VM +label.openDaylight=OpenDaylight +label.assign.instance.another=\u5c06\u5b9e\u4f8b\u5206\u914d\u7ed9\u5176\u4ed6\u5e10\u6237 +label.network.addVM=\u5c06\u7f51\u7edc\u6dfb\u52a0\u5230 VM +label.set.default.NIC=\u8bbe\u7f6e\u9ed8\u8ba4 NIC +label.Xenserver.Tools.Version61plus=XenServer Tools \u7248\u672c 6.1\+ +label.dynamically.scalable=\u53ef\u52a8\u6001\u6269\u5c55 +label.instance.scaled.up=\u5df2\u6269\u5c55\u5b9e\u4f8b +label.tag.key=\u6807\u8bb0\u5bc6\u94a5 +label.tag.value=\u6807\u8bb0\u503c +label.ipv6.address=IPv6 IP \u5730\u5740 +label.ipv6.gateway=IPv6 \u7f51\u5173 +label.ipv6.CIDR=IPv6 CIDR +label.VPC.limits=VPC \u9650\u5236 +label.edit.region=\u7f16\u8f91\u5730\u7406\u533a\u57df +label.gslb.domain.name=GSLB \u57df\u540d +label.add.gslb=\u6dfb\u52a0 GSLB +label.gslb.servicetype=\u670d\u52a1\u7c7b\u578b +label.gslb.details=GSLB \u8be6\u7ec6\u4fe1\u606f +label.gslb.delete=\u5220\u9664 GSLB +label.opendaylight.controller=OpenDaylight \u63a7\u5236\u5668 +label.opendaylight.controllers=OpenDaylight \u63a7\u5236\u5668 +label.portable.ip.ranges=\u53ef\u79fb\u690d IP \u8303\u56f4 +label.add.portable.ip.range=\u6dfb\u52a0\u53ef\u79fb\u690d IP \u8303\u56f4 +label.delete.portable.ip.range=\u5220\u9664\u53ef\u79fb\u690d IP \u8303\u56f4 +label.opendaylight.controllerdetail=OpenDaylight \u63a7\u5236\u5668\u8be6\u7ec6\u4fe1\u606f +label.portable.ip.range.details=\u53ef\u79fb\u690d IP \u8303\u56f4\u8be6\u7ec6\u4fe1\u606f +label.portable.ips=\u53ef\u79fb\u690d IP +label.gslb.assigned.lb=\u5df2\u5206\u914d\u8d1f\u8f7d\u5e73\u8861 +label.gslb.assigned.lb.more=\u5206\u914d\u66f4\u591a\u8d1f\u8f7d\u5e73\u8861 +label.gslb.lb.rule=\u8d1f\u8f7d\u5e73\u8861\u89c4\u5219 +label.gslb.lb.details=\u8d1f\u8f7d\u5e73\u8861\u8be6\u7ec6\u4fe1\u606f +label.gslb.lb.remove=\u4ece\u6b64 GSLB \u4e2d\u5220\u9664\u8d1f\u8f7d\u5e73\u8861 +label.enable.autoscale=\u542f\u7528\u81ea\u52a8\u6269\u5c55 +label.disable.autoscale=\u7981\u7528\u81ea\u52a8\u6269\u5c55 +label.min.instances=\u6700\u5c0f\u5b9e\u4f8b\u6570 +label.max.instances=\u6700\u5927\u5b9e\u4f8b\u6570 +label.add.OpenDaylight.device=\u6dfb\u52a0 OpenDaylight \u63a7\u5236\u5668 +label.show.advanced.settings=\u663e\u793a\u9ad8\u7ea7\u8bbe\u7f6e +label.delete.OpenDaylight.device=\u5220\u9664 OpenDaylight \u63a7\u5236\u5668 +label.polling.interval.sec=\u8f6e\u8be2\u65f6\u95f4\u95f4\u9694(\u79d2) +label.quiet.time.sec=\u5b89\u9759\u65f6\u95f4(\u79d2) +label.destroy.vm.graceperiod=\u9500\u6bc1 VM \u5bbd\u9650\u671f +label.SNMP.community=SNMP \u793e\u533a +label.SNMP.port=SNMP \u7aef\u53e3 +label.add.ucs.manager=\u6dfb\u52a0 UCS \u7ba1\u7406\u5668 +label.ovm.traffic.label=OVM \u6d41\u91cf\u6807\u7b7e +label.lxc.traffic.label=LXC \u6d41\u91cf\u6807\u7b7e +label.hyperv.traffic.label=HyperV \u6d41\u91cf\u6807\u7b7e +label.resource.name=\u8d44\u6e90\u540d\u79f0 +label.reource.id=\u8d44\u6e90 ID +label.vnmc.devices=VNMC \u8bbe\u5907 +label.add.vnmc.provider=\u6dfb\u52a0 VNMC \u63d0\u4f9b\u7a0b\u5e8f +label.enable.vnmc.provider=\u542f\u7528 VNMC \u63d0\u4f9b\u7a0b\u5e8f +label.add.vnmc.device=\u6dfb\u52a0 VNMC \u8bbe\u5907 +label.ciscovnmc.resource.details=CiscoVNMC \u8d44\u6e90\u8be6\u7ec6\u4fe1\u606f +label.delete.ciscovnmc.resource=\u5220\u9664 CiscoVNMC \u8d44\u6e90 +label.enable.vnmc.device=\u542f\u7528 VNMC \u8bbe\u5907 +label.disbale.vnmc.device=\u7981\u7528 VNMC \u8bbe\u5907 +label.disable.vnmc.provider=\u7981\u7528 VNMC \u63d0\u4f9b\u7a0b\u5e8f +label.services=\u670d\u52a1 +label.secondary.staging.store=\u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8 +label.release.account=\u4ece\u5e10\u6237\u4e2d\u91ca\u653e +label.release.account.lowercase=\u4ece\u5e10\u6237\u4e2d\u91ca\u653e +label.vlan.vni.ranges=VLAN/VNI \u8303\u56f4 +label.dedicated.vlan.vni.ranges=VLAN/VNI \u8303\u56f4\u5df2\u4e13\u7528 +label.dedicate.vlan.vni.range=\u5c06 VLAN/VNI \u8303\u56f4\u4e13\u7528 +label.vlan.vni.range=VLAN/VNI \u8303\u56f4 +label.vlan.range.details=VLAN \u8303\u56f4\u8be6\u7ec6\u4fe1\u606f +label.release.dedicated.vlan.range=\u91ca\u653e\u4e13\u7528 VLAN \u8303\u56f4 +label.broadcat.uri=\u5e7f\u64ad URI +label.ipv4.cidr=IPv4 CIDR +label.guest.network.details=\u6765\u5bbe\u7f51\u7edc\u8be6\u7ec6\u4fe1\u606f +label.ipv4.gateway=IPv4 \u7f51\u5173 +label.release.dedicated.vlan.range=\u91ca\u653e\u4e13\u7528 VLAN \u8303\u56f4 +label.vlan.ranges=VLAN \u8303\u56f4 +label.virtual.appliance.details=\u865a\u62df\u8bbe\u5907\u8be6\u7ec6\u4fe1\u606f +label.start.lb.vm=\u542f\u52a8 LB VM +label.stop.lb.vm=\u505c\u6b62 LB VM +label.migrate.lb.vm=\u8fc1\u79fb LB VM +label.vpc.virtual.router=VPC \u865a\u62df\u8def\u7531\u5668 +label.ovs=OVS +label.gslb.service=GSLB \u670d\u52a1 +label.gslb.service.public.ip=GSLB \u670d\u52a1\u516c\u7528 IP +label.gslb.service.private.ip=GSLB \u670d\u52a1\u4e13\u7528 IP +label.baremetal.dhcp.provider=\u88f8\u673a DHCP \u63d0\u4f9b\u7a0b\u5e8f +label.add.baremetal.dhcp.device=\u6dfb\u52a0\u88f8\u673a DHCP \u8bbe\u5907 +label.baremetal.pxe.provider=\u88f8\u673a PXE \u63d0\u4f9b\u7a0b\u5e8f +label.baremetal.pxe.device=\u6dfb\u52a0\u88f8\u673a PXE \u8bbe\u5907 +label.tftp.root.directory=Tftp \u6839\u76ee\u5f55 +label.add.vmware.datacenter=\u6dfb\u52a0 VMware \u6570\u636e\u4e2d\u5fc3 +label.remove.vmware.datacenter=\u5220\u9664 VMware \u6570\u636e\u4e2d\u5fc3 +label.dc.name=\u6570\u636e\u4e2d\u5fc3\u540d\u79f0 +label.vcenter=vCenter +label.dedicate.zone=\u5c06\u8d44\u6e90\u57df\u4e13\u7528 +label.zone.dedicated=\u8d44\u6e90\u57df\u5df2\u4e13\u7528 +label.release.dedicated.zone=\u91ca\u653e\u4e13\u7528\u8d44\u6e90\u57df +label.ipv6.dns1=IPv6 DNS1 +label.ipv6.dns2=IPv6 DNS2 +label.vmware.datacenter.name=VMware \u6570\u636e\u4e2d\u5fc3\u540d\u79f0 +label.vmware.datacenter.vcenter=VMware \u6570\u636e\u4e2d\u5fc3 vCenter +label.vmware.datacenter.id=VMware \u6570\u636e\u4e2d\u5fc3 ID +label.system.vm.details=\u7cfb\u7edf VM \u8be6\u7ec6\u4fe1\u606f +label.system.vm.scaled.up=\u5df2\u6269\u5c55\u7cfb\u7edf VM +label.console.proxy.vm=\u63a7\u5236\u5668\u4ee3\u7406 VM +label.settings=\u8bbe\u7f6e +label.requires.upgrade=\u9700\u8981\u5347\u7ea7 +label.upgrade.router.newer.template=\u5347\u7ea7\u8def\u7531\u5668\u4ee5\u4f7f\u7528\u66f4\u65b0\u7684\u6a21\u677f +label.router.vm.scaled.up=\u5df2\u6269\u5c55\u8def\u7531\u5668 VM +label.total.virtual.routers=\u865a\u62df\u8def\u7531\u5668\u603b\u6570 +label.upgrade.required=\u9700\u8981\u5347\u7ea7 +label.virtual.routers.group.zone=\u865a\u62df\u8def\u7531\u5668(\u6309\u8d44\u6e90\u57df\u5206\u7ec4) +label.total.virtual.routers.upgrade=\u9700\u8981\u5347\u7ea7\u7684\u865a\u62df\u8def\u7531\u5668\u603b\u6570 +label.virtual.routers.group.pod=\u865a\u62df\u8def\u7531\u5668(\u6309\u63d0\u4f9b\u70b9\u5206\u7ec4) +label.virtual.routers.group.cluster=\u865a\u62df\u8def\u7531\u5668(\u6309\u7fa4\u96c6\u5206\u7ec4) +label.zone.lower=\u8d44\u6e90\u57df +label.virtual.routers.group.account=\u865a\u62df\u8def\u7531\u5668(\u6309\u5e10\u6237\u5206\u7ec4) +label.netscaler.details=NetScaler \u8be6\u7ec6\u4fe1\u606f +label.baremetal.dhcp.devices=\u88f8\u673a DHCP \u8bbe\u5907 +label.baremetal.pxe.devices=\u88f8\u673a PXE \u8bbe\u5907 +label.addes.new.f5=\u5df2\u6dfb\u52a0\u65b0 F5 +label.f5.details=F5 \u8be6\u7ec6\u4fe1\u606f +label.srx.details=SRX \u8be6\u7ec6\u4fe1\u606f +label.palo.alto.details=Palo Alto \u8be6\u7ec6\u4fe1\u606f +label.added.nicira.nvp.controller=\u5df2\u6dfb\u52a0\u65b0 Nicira NVP \u63a7\u5236\u5668\ +label.nicira.nvp.details=Nicira NVP \u8be6\u7ec6\u4fe1\u606f +label.added.new.bigswitch.vns.controller=\u5df2\u6dfb\u52a0\u65b0 BigSwitch VNS \u63a7\u5236\u5668 +label.bigswitch.vns.details=BigSwitch VNS \u8be6\u7ec6\u4fe1\u606f +label.dedicate=\u4e13\u7528 +label.dedicate.pod=\u5c06\u63d0\u4f9b\u70b9\u4e13\u7528 +label.pod.dedicated=\u63d0\u4f9b\u70b9\u5df2\u4e13\u7528 +label.release.dedicated.pod=\u91ca\u653e\u4e13\u7528\u63d0\u4f9b\u70b9 +label.override.public.traffic=\u66ff\u4ee3\u516c\u5171\u6d41\u91cf +label.public.traffic.vswitch.type=\u516c\u5171\u6d41\u91cf\u865a\u62df\u4ea4\u6362\u673a\u7c7b\u578b +label.public.traffic.vswitch.name=\u516c\u5171\u6d41\u91cf\u865a\u62df\u4ea4\u6362\u673a\u540d\u79f0 +label.override.guest.traffic=\u66ff\u4ee3\u6765\u5bbe\u6d41\u91cf +label.guest.traffic.vswitch.type=\u6765\u5bbe\u6d41\u91cf\u865a\u62df\u4ea4\u6362\u673a\u7c7b\u578b +label.guest.traffic.vswitch.name=\u6765\u5bbe\u6d41\u91cf\u865a\u62df\u4ea4\u6362\u673a\u540d\u79f0 +label.cisco.nexus1000v.ip.address=Nexus 1000v IP \u5730\u5740 +label.cisco.nexus1000v.username=Nexus 1000v \u7528\u6237\u540d +label.cisco.nexus1000v.password=Nexus 1000v \u5bc6\u7801 +label.dedicate.cluster=\u5c06\u7fa4\u96c6\u4e13\u7528 +label.release.dedicated.cluster=\u91ca\u653e\u4e13\u7528\u7fa4\u96c6 +label.dedicate.host=\u5c06\u4e3b\u673a\u4e13\u7528 +label.release.dedicated.host=\u91ca\u653e\u4e13\u7528\u4e3b\u673a +label.number.of.cpu.sockets=CPU \u63d2\u69fd\u6570 +label.delete.ucs.manager=\u5220\u9664 UCS Manager +label.blades=\u5200\u7247\u5f0f\u670d\u52a1\u5668 +label.chassis=\u673a\u7bb1 +label.blade.id=\u5200\u7247\u5f0f\u670d\u52a1\u5668 ID +label.associated.profile=\u5df2\u5173\u8054\u914d\u7f6e\u6587\u4ef6 +label.refresh.blades=\u5237\u65b0\u5200\u7247\u5f0f\u670d\u52a1\u5668 +label.instanciate.template.associate.profile.blade=\u5c06\u6a21\u677f\u5b9e\u4f8b\u5316\u5e76\u5c06\u914d\u7f6e\u6587\u4ef6\u4e0e\u5200\u7247\u5f0f\u670d\u52a1\u5668\u5173\u8054 +label.select.template=\u9009\u62e9\u6a21\u677f +label.profile=\u914d\u7f6e\u6587\u4ef6 +label.delete.profile=\u5220\u9664\u914d\u7f6e\u6587\u4ef6 +label.disassociate.profile.blade=\u53d6\u6d88\u5c06\u914d\u7f6e\u6587\u4ef6\u4e0e\u5200\u7247\u5f0f\u670d\u52a1\u5668\u5173\u8054 +label.secondary.storage.details=\u4e8c\u7ea7\u5b58\u50a8\u8be6\u7ec6\u4fe1\u606f +label.secondary.staging.store.details=\u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8\u8be6\u7ec6\u4fe1\u606f +label.add.nfs.secondary.staging.store=\u6dfb\u52a0 NFS \u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8 +label.delete.secondary.staging.store=\u5220\u9664\u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8 +label.ipv4.start.ip=IPv4 \u8d77\u59cb IP +label.ipv4.end.ip=IPv4 \u7ed3\u675f IP +label.ipv6.start.ip=IPv6 \u8d77\u59cb IP +label.ipv6.end.ip=IPv6 \u7ed3\u675f IP +label.vm.password=VM \u7684\u5bc6\u7801 +label.group.by.zone=\u6309\u8d44\u6e90\u57df\u5206\u7ec4 +label.group.by.pod=\u6309\u63d0\u4f9b\u70b9\u5206\u7ec4 +label.group.by.cluster=\u6309\u7fa4\u96c6\u5206\u7ec4 +label.group.by.account=\u6309\u5e10\u6237\u5206\u7ec4 +label.no.grouping=(\u4e0d\u5206\u7ec4) +label.create.nfs.secondary.staging.storage=\u521b\u5efa NFS \u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8 +label.username.lower=\u7528\u6237\u540d +label.password.lower=\u5bc6\u7801 +label.email.lower=\u7535\u5b50\u90ae\u4ef6 +label.firstname.lower=\u540d\u5b57 +label.lastname.lower=\u59d3\u6c0f +label.domain.lower=\u57df +label.account.lower=\u5e10\u6237 +label.type.lower=\u7c7b\u578b +label.rule.number=\u89c4\u5219\u7f16\u53f7 +label.action=\u64cd\u4f5c +label.name.lower=\u540d\u79f0 +label.ucs=UCS +label.change.affinity=\u66f4\u6539\u5173\u8054\u6027 +label.persistent=\u6c38\u4e45 +label.broadcasturi=\u5e7f\u64ad URI +label.network.cidr=\u7f51\u7edc CIDR +label.reserved.ip.range=\u9884\u7559 IP \u8303\u56f4 +label.autoscale=\u81ea\u52a8\u6269\u5c55 +label.health.check=\u8fd0\u884c\u72b6\u51b5\u68c0\u67e5 +label.public.load.balancer.provider=\u516c\u7528\u8d1f\u8f7d\u5e73\u8861\u5668\u63d0\u4f9b\u7a0b\u5e8f +label.add.isolated.network=\u6dfb\u52a0\u9694\u79bb\u7f51\u7edc +label.vlan=VLAN +label.secondary.isolated.vlan.id=\u4e8c\u7ea7\u9694\u79bb VLAN ID +label.ipv4.netmask=IPv4 \u7f51\u7edc\u63a9\u7801 +label.custom=\u81ea\u5b9a\u4e49 +label.disable.network.offering=\u7981\u7528\u7f51\u7edc\u65b9\u6848 +label.enable.network.offering=\u542f\u7528\u7f51\u7edc\u65b9\u6848 +label.remove.network.offering=\u5220\u9664\u7f51\u7edc\u65b9\u6848 +label.system.offering.for.router=\u8def\u7531\u5668\u7684\u7cfb\u7edf\u65b9\u6848 +label.mode=\u6a21\u5f0f +label.associate.public.ip=\u5173\u8054\u516c\u7528 IP +label.acl=ACL +label.user.data=\u7528\u6237\u6570\u636e +label.virtual.networking=\u865a\u62df\u7f51\u7edc\u8fde\u63a5 +label.allow=\u5141\u8bb8 +label.deny=\u62d2\u7edd +label.default.egress.policy=\u9ed8\u8ba4\u51fa\u53e3\u89c4\u5219 +label.xenserver.tools.version.61.plus=XenServer Tools \u7248\u672c 6.1\+ managed.state=\u6258\u7ba1\u72b6\u6001 message.acquire.new.ip.vpc=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e3a\u6b64 VPC \u83b7\u53d6\u4e00\u4e2a\u65b0 IP\u3002 message.acquire.new.ip=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e3a\u6b64\u7f51\u7edc\u83b7\u53d6\u4e00\u4e2a\u65b0 IP\u3002 -message.acquire.public.ip=\u8bf7\u9009\u62e9\u4e00\u4e2a\u8981\u4ece\u4e2d\u83b7\u53d6\u65b0 IP \u7684\u533a\u57df\u3002 +message.acquire.public.ip=\u8bf7\u9009\u62e9\u4e00\u4e2a\u8981\u4ece\u4e2d\u83b7\u53d6\u65b0 IP \u7684\u8d44\u6e90\u57df\u3002 message.action.cancel.maintenance.mode=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u53d6\u6d88\u6b64\u7ef4\u62a4\u6a21\u5f0f\u3002 message.action.cancel.maintenance=\u5df2\u6210\u529f\u53d6\u6d88\u7ef4\u62a4\u60a8\u7684\u4e3b\u673a\u3002\u6b64\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u957f\u8fbe\u51e0\u5206\u949f\u65f6\u95f4\u3002 message.action.change.service.warning.for.instance=\u5fc5\u987b\u5148\u7981\u7528\u60a8\u7684\u5b9e\u4f8b\uff0c\u7136\u540e\u518d\u5c1d\u8bd5\u66f4\u6539\u5176\u5f53\u524d\u7684\u670d\u52a1\u65b9\u6848\u3002 @@ -1266,22 +1494,22 @@ message.action.delete.domain=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9 message.action.delete.external.firewall=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5916\u90e8\u9632\u706b\u5899\u3002\u8b66\u544a\: \u5982\u679c\u60a8\u8ba1\u5212\u91cd\u65b0\u6dfb\u52a0\u540c\u4e00\u4e2a\u5916\u90e8\u9632\u706b\u5899\uff0c\u5219\u5fc5\u987b\u5728\u8bbe\u5907\u4e0a\u91cd\u7f6e\u4f7f\u7528\u6570\u636e\u3002 message.action.delete.external.load.balancer=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5916\u90e8\u8d1f\u8f7d\u5e73\u8861\u5668\u3002\u8b66\u544a\: \u5982\u679c\u60a8\u8ba1\u5212\u91cd\u65b0\u6dfb\u52a0\u540c\u4e00\u4e2a\u5916\u90e8\u8d1f\u8f7d\u5e73\u8861\u5668\uff0c\u5219\u5fc5\u987b\u5728\u8bbe\u5907\u4e0a\u91cd\u7f6e\u4f7f\u7528\u6570\u636e\u3002 message.action.delete.ingress.rule=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5165\u53e3\u89c4\u5219\u3002 -message.action.delete.ISO.for.all.zones=\u6b64 ISO \u7531\u6240\u6709\u533a\u57df\u4f7f\u7528\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5176\u4ece\u6240\u6709\u533a\u57df\u4e2d\u5220\u9664\u3002 +message.action.delete.ISO.for.all.zones=\u6b64 ISO \u7531\u6240\u6709\u8d44\u6e90\u57df\u4f7f\u7528\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5176\u4ece\u6240\u6709\u8d44\u6e90\u57df\u4e2d\u5220\u9664\u3002 message.action.delete.ISO=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 ISO\u3002 message.action.delete.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7f51\u7edc\u3002 message.action.delete.nexusVswitch=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 Nexus 1000v message.action.delete.physical.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7269\u7406\u7f51\u7edc message.action.delete.pod=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u63d0\u4f9b\u70b9\u3002 message.action.delete.primary.storage=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u4e3b\u5b58\u50a8\u3002 -message.action.delete.secondary.storage=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u8f85\u52a9\u5b58\u50a8\u3002 +message.action.delete.secondary.storage=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u4e8c\u7ea7\u5b58\u50a8\u3002 message.action.delete.security.group=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5b89\u5168\u7ec4\u3002 message.action.delete.service.offering=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u670d\u52a1\u65b9\u6848\u3002 message.action.delete.snapshot=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5feb\u7167\u3002 message.action.delete.system.service.offering=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7cfb\u7edf\u670d\u52a1\u65b9\u6848\u3002 -message.action.delete.template.for.all.zones=\u6b64\u6a21\u677f\u7531\u6240\u6709\u533a\u57df\u4f7f\u7528\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5176\u4ece\u6240\u6709\u533a\u57df\u4e2d\u5220\u9664\u3002 +message.action.delete.template.for.all.zones=\u6b64\u6a21\u677f\u7531\u6240\u6709\u8d44\u6e90\u57df\u4f7f\u7528\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5176\u4ece\u6240\u6709\u8d44\u6e90\u57df\u4e2d\u5220\u9664\u3002 message.action.delete.template=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u6a21\u677f\u3002 message.action.delete.volume=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5377\u3002 -message.action.delete.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u533a\u57df\u3002 +message.action.delete.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u8d44\u6e90\u57df\u3002 message.action.destroy.instance=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u9500\u6bc1\u6b64\u5b9e\u4f8b\u3002 message.action.destroy.systemvm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u9500\u6bc1\u6b64\u7cfb\u7edf VM\u3002 message.action.disable.cluster=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u7fa4\u96c6\u3002 @@ -1289,7 +1517,7 @@ message.action.disable.nexusVswitch=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u message.action.disable.physical.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u7269\u7406\u7f51\u7edc\u3002 message.action.disable.pod=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u63d0\u4f9b\u70b9\u3002 message.action.disable.static.NAT=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u9759\u6001 NAT\u3002 -message.action.disable.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u533a\u57df\u3002 +message.action.disable.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u8d44\u6e90\u57df\u3002 message.action.download.iso=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e0b\u8f7d\u6b64 ISO\u3002 message.action.download.template=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e0b\u8f7d\u6b64\u6a21\u677f\u3002 message.action.enable.cluster=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u7fa4\u96c6\u3002 @@ -1297,7 +1525,7 @@ message.action.enable.maintenance=\u5df2\u6210\u529f\u51c6\u5907\u597d\u7ef4\u62 message.action.enable.nexusVswitch=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64 Nexus 1000v message.action.enable.physical.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u7269\u7406\u7f51\u7edc\u3002 message.action.enable.pod=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u63d0\u4f9b\u70b9\u3002 -message.action.enable.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u533a\u57df\u3002 +message.action.enable.zone=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u8d44\u6e90\u57df\u3002 message.action.expunge.instance=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5b9e\u4f8b\u3002 message.action.force.reconnect=\u5df2\u6210\u529f\u5f3a\u5236\u91cd\u65b0\u8fde\u63a5\u60a8\u7684\u4e3b\u673a\u3002\u6b64\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u957f\u8fbe\u51e0\u5206\u949f\u65f6\u95f4\u3002 message.action.host.enable.maintenance.mode=\u542f\u7528\u7ef4\u62a4\u6a21\u5f0f\u4f1a\u5bfc\u81f4\u5c06\u6b64\u4e3b\u673a\u4e0a\u6b63\u5728\u8fd0\u884c\u7684\u6240\u6709\u5b9e\u4f8b\u5b9e\u65f6\u8fc1\u79fb\u5230\u4efb\u4f55\u53ef\u7528\u7684\u4e3b\u673a\u3002 @@ -1324,26 +1552,26 @@ message.action.unmanage.cluster=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u53d6 message.action.vmsnapshot.delete=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 VM \u5feb\u7167\u3002 message.action.vmsnapshot.revert=\u8fd8\u539f VM \u5feb\u7167 message.activate.project=\u662f\u5426\u786e\u5b9e\u8981\u6fc0\u6d3b\u6b64\u9879\u76ee? -message.add.cluster.zone=\u5411\u533a\u57df \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u6258\u7ba1\u7684\u7fa4\u96c6 -message.add.cluster=\u5411\u533a\u57df \u3001\u63d0\u4f9b\u70b9 \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u6258\u7ba1\u7684\u7fa4\u96c6 +message.add.cluster.zone=\u5411\u8d44\u6e90\u57df \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u6258\u7ba1\u7684\u7fa4\u96c6 +message.add.cluster=\u5411\u8d44\u6e90\u57df \u3001\u63d0\u4f9b\u70b9 \u4e2d\u6dfb\u52a0\u4e00\u4e2a\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u6258\u7ba1\u7684\u7fa4\u96c6 message.add.disk.offering=\u8bf7\u6307\u5b9a\u4ee5\u4e0b\u53c2\u6570\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u78c1\u76d8\u65b9\u6848 message.add.domain=\u8bf7\u6307\u5b9a\u8981\u5728\u6b64\u57df\u4e0b\u521b\u5efa\u7684\u5b50\u57df -message.add.firewall=\u5411\u533a\u57df\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u9632\u706b\u5899 +message.add.firewall=\u5411\u8d44\u6e90\u57df\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u9632\u706b\u5899 message.add.guest.network=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u6dfb\u52a0\u4e00\u4e2a\u6765\u5bbe\u7f51\u7edc message.add.host=\u8bf7\u6307\u5b9a\u4ee5\u4e0b\u53c2\u6570\u4ee5\u6dfb\u52a0\u4e00\u53f0\u65b0\u4e3b\u673a -message.add.ip.range.direct.network=\u5411\u533a\u57df \u4e2d\u7684\u76f4\u63a5\u7f51\u7edc \u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4 +message.add.ip.range.direct.network=\u5411\u8d44\u6e90\u57df \u4e2d\u7684\u76f4\u63a5\u7f51\u7edc \u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4 message.add.ip.range.to.pod=

\u5411\u63d0\u4f9b\u70b9\u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4\:

-message.add.ip.range=\u5411\u533a\u57df\u4e2d\u7684\u516c\u7528\u7f51\u7edc\u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4 +message.add.ip.range=\u5411\u8d44\u6e90\u57df\u4e2d\u7684\u516c\u7528\u7f51\u7edc\u6dfb\u52a0\u4e00\u4e2a IP \u8303\u56f4 message.add.load.balancer.under.ip=\u5df2\u5728\u4ee5\u4e0b IP \u4e0b\u6dfb\u52a0\u8d1f\u8f7d\u5e73\u8861\u5668\u89c4\u5219\: -message.add.load.balancer=\u5411\u533a\u57df\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u8d1f\u8f7d\u5e73\u8861\u5668 -message.add.network=\u4e3a\u533a\u57df \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7f51\u7edc +message.add.load.balancer=\u5411\u8d44\u6e90\u57df\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u8d1f\u8f7d\u5e73\u8861\u5668 +message.add.network=\u4e3a\u8d44\u6e90\u57df \u6dfb\u52a0\u4e00\u4e2a\u65b0\u7f51\u7edc message.add.new.gateway.to.vpc=\u8bf7\u6307\u5b9a\u5c06\u65b0\u7f51\u5173\u6dfb\u52a0\u5230\u6b64 VPC \u6240\u9700\u7684\u4fe1\u606f\u3002 -message.add.pod.during.zone.creation=\u6bcf\u4e2a\u533a\u57df\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u63d0\u4f9b\u70b9\u3002\u63d0\u4f9b\u70b9\u4e2d\u5305\u542b\u4e3b\u673a\u548c\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u60a8\u5c06\u5728\u968f\u540e\u7684\u67d0\u4e2a\u6b65\u9aa4\u4e2d\u6dfb\u52a0\u8fd9\u4e9b\u4e3b\u673a\u548c\u670d\u52a1\u5668\u3002\u9996\u5148\uff0c\u8bf7\u4e3a CloudStack \u7684\u5185\u90e8\u7ba1\u7406\u901a\u4fe1\u914d\u7f6e\u4e00\u4e2a\u9884\u7559 IP \u5730\u5740\u8303\u56f4\u3002\u9884\u7559\u7684 IP \u8303\u56f4\u5bf9\u4e91\u4e2d\u7684\u6bcf\u4e2a\u533a\u57df\u6765\u8bf4\u5fc5\u987b\u552f\u4e00\u3002 -message.add.pod=\u4e3a\u533a\u57df \u6dfb\u52a0\u4e00\u4e2a\u65b0\u63d0\u4f9b\u70b9 -message.add.primary.storage=\u4e3a\u533a\u57df \u3001\u63d0\u4f9b\u70b9 \u6dfb\u52a0\u4e00\u4e2a\u65b0\u4e3b\u5b58\u50a8 +message.add.pod.during.zone.creation=\u6bcf\u4e2a\u8d44\u6e90\u57df\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u63d0\u4f9b\u70b9\u3002\u63d0\u4f9b\u70b9\u4e2d\u5305\u542b\u4e3b\u673a\u548c\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u60a8\u5c06\u5728\u968f\u540e\u7684\u67d0\u4e2a\u6b65\u9aa4\u4e2d\u6dfb\u52a0\u8fd9\u4e9b\u4e3b\u673a\u548c\u670d\u52a1\u5668\u3002\u9996\u5148\uff0c\u8bf7\u4e3a CloudStack \u7684\u5185\u90e8\u7ba1\u7406\u6d41\u91cf\u914d\u7f6e\u4e00\u4e2a\u9884\u7559 IP \u5730\u5740\u8303\u56f4\u3002\u9884\u7559\u7684 IP \u8303\u56f4\u5bf9\u4e91\u4e2d\u7684\u6bcf\u4e2a\u8d44\u6e90\u57df\u6765\u8bf4\u5fc5\u987b\u552f\u4e00\u3002 +message.add.pod=\u4e3a\u8d44\u6e90\u57df \u6dfb\u52a0\u4e00\u4e2a\u65b0\u63d0\u4f9b\u70b9 +message.add.primary.storage=\u4e3a\u8d44\u6e90\u57df \u3001\u63d0\u4f9b\u70b9 \u6dfb\u52a0\u4e00\u4e2a\u65b0\u4e3b\u5b58\u50a8 message.add.primary=\u8bf7\u6307\u5b9a\u4ee5\u4e0b\u53c2\u6570\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u4e3b\u5b58\u50a8 -message.add.region=\u8bf7\u6307\u5b9a\u6dfb\u52a0\u65b0\u533a\u57df\u6240\u9700\u7684\u4fe1\u606f\u3002 -message.add.secondary.storage=\u4e3a\u533a\u57df \u6dfb\u52a0\u4e00\u4e2a\u65b0\u5b58\u50a8 +message.add.region=\u8bf7\u6307\u5b9a\u6dfb\u52a0\u65b0\u5730\u7406\u533a\u57df\u6240\u9700\u7684\u4fe1\u606f\u3002 +message.add.secondary.storage=\u4e3a\u8d44\u6e90\u57df \u6dfb\u52a0\u4e00\u4e2a\u65b0\u5b58\u50a8 message.add.service.offering=\u8bf7\u586b\u5199\u4ee5\u4e0b\u6570\u636e\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u8ba1\u7b97\u65b9\u6848\u3002 message.add.system.service.offering=\u8bf7\u586b\u5199\u4ee5\u4e0b\u6570\u636e\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7684\u7cfb\u7edf\u670d\u52a1\u65b9\u6848\u3002 message.add.template=\u8bf7\u8f93\u5165\u4ee5\u4e0b\u6570\u636e\u4ee5\u521b\u5efa\u65b0\u6a21\u677f @@ -1355,8 +1583,8 @@ message.adding.Netscaler.provider=\u6b63\u5728\u6dfb\u52a0 Netscaler \u63d0\u4f9 message.additional.networks.desc=\u8bf7\u9009\u62e9\u865a\u62df\u673a\u8981\u8fde\u63a5\u5230\u7684\u5176\u4ed6\u7f51\u7edc\u3002 message.advanced.mode.desc=\u5982\u679c\u60a8\u5e0c\u671b\u542f\u7528 VLAN \u652f\u6301\uff0c\u8bf7\u9009\u62e9\u6b64\u7f51\u7edc\u6a21\u5f0f\u3002\u6b64\u7f51\u7edc\u6a21\u5f0f\u5728\u5141\u8bb8\u7ba1\u7406\u5458\u63d0\u4f9b\u9632\u706b\u5899\u3001VPN \u6216\u8d1f\u8f7d\u5e73\u8861\u5668\u652f\u6301\u7b49\u81ea\u5b9a\u4e49\u7f51\u7edc\u65b9\u6848\u4ee5\u53ca\u542f\u7528\u76f4\u63a5\u7f51\u7edc\u8fde\u63a5\u4e0e\u865a\u62df\u7f51\u7edc\u8fde\u63a5\u7b49\u65b9\u9762\u63d0\u4f9b\u4e86\u6700\u5927\u7684\u7075\u6d3b\u6027\u3002 message.advanced.security.group=\u5982\u679c\u8981\u4f7f\u7528\u5b89\u5168\u7ec4\u63d0\u4f9b\u6765\u5bbe VM \u9694\u79bb\uff0c\u8bf7\u9009\u62e9\u6b64\u6a21\u5f0f\u3002 -message.advanced.virtual=\u5982\u679c\u8981\u4f7f\u7528\u6574\u4e2a\u533a\u57df\u7684 VLAN \u63d0\u4f9b\u6765\u5bbe VM \u9694\u79bb\uff0c\u8bf7\u9009\u62e9\u6b64\u6a21\u5f0f\u3002 -message.after.enable.s3=\u5df2\u914d\u7f6e S3 \u652f\u6301\u7684\u8f85\u52a9\u5b58\u50a8\u3002\u6ce8\u610f\: \u9000\u51fa\u6b64\u9875\u9762\u540e\uff0c\u60a8\u5c06\u65e0\u6cd5\u518d\u6b21\u91cd\u65b0\u914d\u7f6e S3\u3002 +message.advanced.virtual=\u5982\u679c\u8981\u4f7f\u7528\u6574\u4e2a\u8d44\u6e90\u57df\u7684 VLAN \u63d0\u4f9b\u6765\u5bbe VM \u9694\u79bb\uff0c\u8bf7\u9009\u62e9\u6b64\u6a21\u5f0f\u3002 +message.after.enable.s3=\u5df2\u914d\u7f6e S3 \u652f\u6301\u7684\u4e8c\u7ea7\u5b58\u50a8\u3002\u6ce8\u610f\: \u9000\u51fa\u6b64\u9875\u9762\u540e\uff0c\u60a8\u5c06\u65e0\u6cd5\u518d\u6b21\u91cd\u65b0\u914d\u7f6e S3\u3002 message.after.enable.swift=\u5df2\u914d\u7f6e SWIFT\u3002\u6ce8\u610f\: \u9000\u51fa\u6b64\u9875\u9762\u540e\uff0c\u60a8\u5c06\u65e0\u6cd5\u518d\u6b21\u91cd\u65b0\u914d\u7f6e SWIFT\u3002 message.alert.state.detected=\u68c0\u6d4b\u5230\u8b66\u62a5\u72b6\u6001 message.allow.vpn.access=\u8bf7\u8f93\u5165\u8981\u5141\u8bb8\u8fdb\u884c VPN \u8bbf\u95ee\u7684\u7528\u6237\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002 @@ -1366,11 +1594,11 @@ message.attach.volume=\u8bf7\u586b\u5199\u4ee5\u4e0b\u6570\u636e\u4ee5\u9644\u52 message.basic.mode.desc=\u5982\u679c\u60a8*\u4e0d*\u5e0c\u671b\u542f\u7528\u4efb\u4f55 VLAN \u652f\u6301\uff0c\u8bf7\u9009\u62e9\u6b64\u7f51\u7edc\u6a21\u5f0f\u3002\u5c06\u76f4\u63a5\u4ece\u6b64\u7f51\u7edc\u4e2d\u4e3a\u5728\u6b64\u7f51\u7edc\u6a21\u5f0f\u4e0b\u521b\u5efa\u7684\u6240\u6709\u865a\u62df\u673a\u5b9e\u4f8b\u5206\u914d\u4e00\u4e2a IP\uff0c\u5e76\u4f7f\u7528\u5b89\u5168\u7ec4\u63d0\u4f9b\u5b89\u5168\u6027\u548c\u9694\u79bb\u3002 message.change.offering.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u66f4\u6539\u6b64\u865a\u62df\u5b9e\u4f8b\u7684\u670d\u52a1\u65b9\u6848\u3002 message.change.password=\u8bf7\u66f4\u6539\u60a8\u7684\u5bc6\u7801\u3002 -message.configure.all.traffic.types=\u60a8\u6709\u591a\u4e2a\u7269\u7406\u7f51\u7edc\uff0c\u8bf7\u5355\u51fb\u201c\u7f16\u8f91\u201d\u6309\u94ae\u4e3a\u6bcf\u79cd\u901a\u4fe1\u7c7b\u578b\u914d\u7f6e\u6807\u7b7e\u3002 -message.configuring.guest.traffic=\u6b63\u5728\u914d\u7f6e\u6765\u5bbe\u901a\u4fe1 +message.configure.all.traffic.types=\u60a8\u6709\u591a\u4e2a\u7269\u7406\u7f51\u7edc\uff0c\u8bf7\u5355\u51fb\u201c\u7f16\u8f91\u201d\u6309\u94ae\u4e3a\u6bcf\u79cd\u6d41\u91cf\u7c7b\u578b\u914d\u7f6e\u6807\u7b7e\u3002 +message.configuring.guest.traffic=\u6b63\u5728\u914d\u7f6e\u6765\u5bbe\u6d41\u91cf message.configuring.physical.networks=\u6b63\u5728\u914d\u7f6e\u7269\u7406\u7f51\u7edc -message.configuring.public.traffic=\u6b63\u5728\u914d\u7f6e\u516c\u5171\u901a\u4fe1 -message.configuring.storage.traffic=\u6b63\u5728\u914d\u7f6e\u5b58\u50a8\u901a\u4fe1 +message.configuring.public.traffic=\u6b63\u5728\u914d\u7f6e\u516c\u5171\u6d41\u91cf +message.configuring.storage.traffic=\u6b63\u5728\u914d\u7f6e\u5b58\u50a8\u6d41\u91cf message.confirm.action.force.reconnect=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5f3a\u5236\u91cd\u65b0\u8fde\u63a5\u6b64\u4e3b\u673a\u3002 message.confirm.delete.F5=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 F5 message.confirm.delete.NetScaler=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 NetScaler @@ -1383,7 +1611,7 @@ message.confirm.join.project=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u52a0\u5 message.confirm.remove.IP.range=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 IP \u8303\u56f4\u3002 message.confirm.shutdown.provider=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5173\u95ed\u6b64\u63d0\u4f9b\u7a0b\u5e8f message.copy.iso.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06 ISO \u590d\u5236\u5230 -message.copy.template=\u5c06\u6a21\u677f XXX \u4ece\u533a\u57df \u590d\u5236\u5230 +message.copy.template=\u5c06\u6a21\u677f XXX \u4ece\u8d44\u6e90\u57df \u590d\u5236\u5230 message.create.template.vm=\u57fa\u4e8e\u6a21\u677f \u521b\u5efa VM message.create.template.volume=\u8bf7\u5148\u6307\u5b9a\u4ee5\u4e0b\u4fe1\u606f\uff0c\u7136\u540e\u518d\u521b\u5efa\u78c1\u76d8\u5377 \u7684\u6a21\u677f\u3002\u521b\u5efa\u6a21\u677f\u53ef\u80fd\u9700\u8981\u51e0\u5206\u949f\u5230\u66f4\u957f\u7684\u65f6\u95f4\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u78c1\u76d8\u5377\u7684\u5927\u5c0f\u3002 message.create.template=\u662f\u5426\u786e\u5b9e\u8981\u521b\u5efa\u6a21\u677f? @@ -1392,10 +1620,10 @@ message.creating.guest.network=\u6b63\u5728\u521b\u5efa\u6765\u5bbe\u7f51\u7edc message.creating.physical.networks=\u6b63\u5728\u521b\u5efa\u7269\u7406\u7f51\u7edc message.creating.pod=\u6b63\u5728\u521b\u5efa\u63d0\u4f9b\u70b9 message.creating.primary.storage=\u6b63\u5728\u521b\u5efa\u4e3b\u5b58\u50a8 -message.creating.secondary.storage=\u6b63\u5728\u521b\u5efa\u8f85\u52a9\u5b58\u50a8 -message.creating.zone=\u6b63\u5728\u521b\u5efa\u533a\u57df +message.creating.secondary.storage=\u6b63\u5728\u521b\u5efa\u4e8c\u7ea7\u5b58\u50a8 +message.creating.zone=\u6b63\u5728\u521b\u5efa\u8d44\u6e90\u57df message.decline.invitation=\u662f\u5426\u786e\u5b9e\u8981\u62d2\u7edd\u6b64\u9879\u76ee\u9080\u8bf7? -message.dedicate.zone=\u6b63\u5728\u5c06\u533a\u57df\u4e13\u6709\u5316 +message.dedicate.zone=\u6b63\u5728\u5c06\u8d44\u6e90\u57df\u4e13\u7528 message.delete.account=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5e10\u6237\u3002 message.delete.affinity.group=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u5173\u8054\u6027\u7ec4\u3002 message.delete.gateway=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7f51\u5173 @@ -1409,8 +1637,8 @@ message.desc.basic.zone=\u63d0\u4f9b\u4e00\u4e2a\u7f51\u7edc\uff0c\u5c06\u76f4\u message.desc.cluster=\u6bcf\u4e2a\u63d0\u4f9b\u70b9\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u7fa4\u96c6\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u7fa4\u96c6\u3002\u7fa4\u96c6\u63d0\u4f9b\u4e86\u4e00\u79cd\u7f16\u7ec4\u4e3b\u673a\u7684\u65b9\u6cd5\u3002\u7fa4\u96c6\u4e2d\u7684\u6240\u6709\u4e3b\u673a\u90fd\u5177\u6709\u76f8\u540c\u7684\u786c\u4ef6\uff0c\u8fd0\u884c\u76f8\u540c\u7684\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\uff0c\u4f4d\u4e8e\u76f8\u540c\u7684\u5b50\u7f51\u4e2d\uff0c\u5e76\u8bbf\u95ee\u76f8\u540c\u7684\u5171\u4eab\u5b58\u50a8\u3002\u6bcf\u4e2a\u7fa4\u96c6\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u4e3b\u673a\u4ee5\u53ca\u4e00\u4e2a\u6216\u591a\u4e2a\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u7ec4\u6210\u3002 message.desc.host=\u6bcf\u4e2a\u7fa4\u96c6\u4e2d\u5fc5\u987b\u81f3\u5c11\u5305\u542b\u4e00\u4e2a\u4e3b\u673a\u4ee5\u4f9b\u6765\u5bbe VM \u5728\u4e0a\u9762\u8fd0\u884c\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u4e3b\u673a\u3002\u8981\u4f7f\u4e3b\u673a\u5728 CloudStack \u4e2d\u8fd0\u884c\uff0c\u5fc5\u987b\u5728\u6b64\u4e3b\u673a\u4e0a\u5b89\u88c5\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u8f6f\u4ef6\uff0c\u4e3a\u5176\u5206\u914d\u4e00\u4e2a IP \u5730\u5740\uff0c\u5e76\u786e\u4fdd\u5c06\u5176\u8fde\u63a5\u5230 CloudStack \u7ba1\u7406\u670d\u52a1\u5668\u3002

\u8bf7\u63d0\u4f9b\u4e3b\u673a\u7684 DNS \u6216 IP \u5730\u5740\u3001\u7528\u6237\u540d(\u901a\u5e38\u4e3a root)\u548c\u5bc6\u7801\uff0c\u4ee5\u53ca\u7528\u4e8e\u5bf9\u4e3b\u673a\u8fdb\u884c\u5206\u7c7b\u7684\u4efb\u4f55\u6807\u7b7e\u3002 message.desc.primary.storage=\u6bcf\u4e2a\u7fa4\u96c6\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u3002\u4e3b\u5b58\u50a8\u4e2d\u5305\u542b\u5728\u7fa4\u96c6\u4e2d\u7684\u4e3b\u673a\u4e0a\u8fd0\u884c\u7684\u6240\u6709 VM \u7684\u78c1\u76d8\u5377\u3002\u8bf7\u4f7f\u7528\u5e95\u5c42\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u652f\u6301\u7684\u7b26\u5408\u6807\u51c6\u7684\u534f\u8bae\u3002 -message.desc.secondary.storage=\u6bcf\u4e2a\u533a\u57df\u4e2d\u5fc5\u987b\u81f3\u5c11\u5305\u542b\u4e00\u4e2a NFS \u6216\u8f85\u52a9\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a NFS \u6216\u8f85\u52a9\u5b58\u50a8\u670d\u52a1\u5668\u3002\u8f85\u52a9\u5b58\u50a8\u7528\u4e8e\u5b58\u50a8 VM \u6a21\u677f\u3001ISO \u6620\u50cf\u548c VM \u78c1\u76d8\u5377\u5feb\u7167\u3002\u6b64\u670d\u52a1\u5668\u5fc5\u987b\u5bf9\u533a\u57df\u4e2d\u7684\u6240\u6709\u670d\u52a1\u5668\u53ef\u7528\u3002

\u8bf7\u63d0\u4f9b IP \u5730\u5740\u548c\u5bfc\u51fa\u8def\u5f84\u3002 -message.desc.zone=\u533a\u57df\u662f CloudStack \u4e2d\u6700\u5927\u7684\u7ec4\u7ec7\u5355\u4f4d\uff0c\u4e00\u4e2a\u533a\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u533a\u57df\u53ef\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\u3002\u4e00\u4e2a\u533a\u57df\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\u4ee5\u53ca\u7531\u533a\u57df\u4e2d\u7684\u6240\u6709\u63d0\u4f9b\u70b9\u5171\u4eab\u7684\u4e00\u4e2a\u8f85\u52a9\u5b58\u50a8\u670d\u52a1\u5668\u7ec4\u6210\uff0c\u5176\u4e2d\u6bcf\u4e2a\u63d0\u4f9b\u70b9\u4e2d\u5305\u542b\u591a\u4e2a\u4e3b\u673a\u548c\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u3002 +message.desc.secondary.storage=\u6bcf\u4e2a\u8d44\u6e90\u57df\u4e2d\u5fc5\u987b\u81f3\u5c11\u5305\u542b\u4e00\u4e2a NFS \u6216\u4e8c\u7ea7\u5b58\u50a8\u670d\u52a1\u5668\uff0c\u73b0\u5728\u6211\u4eec\u5c06\u6dfb\u52a0\u7b2c\u4e00\u4e2a NFS \u6216\u4e8c\u7ea7\u5b58\u50a8\u670d\u52a1\u5668\u3002\u4e8c\u7ea7\u5b58\u50a8\u7528\u4e8e\u5b58\u50a8 VM \u6a21\u677f\u3001ISO \u6620\u50cf\u548c VM \u78c1\u76d8\u5377\u5feb\u7167\u3002\u6b64\u670d\u52a1\u5668\u5fc5\u987b\u5bf9\u8d44\u6e90\u57df\u4e2d\u7684\u6240\u6709\u670d\u52a1\u5668\u53ef\u7528\u3002

\u8bf7\u63d0\u4f9b IP \u5730\u5740\u548c\u5bfc\u51fa\u8def\u5f84\u3002 +message.desc.zone=\u8d44\u6e90\u57df\u662f CloudStack \u4e2d\u6700\u5927\u7684\u7ec4\u7ec7\u5355\u4f4d\uff0c\u4e00\u4e2a\u8d44\u6e90\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u8d44\u6e90\u57df\u53ef\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\u3002\u4e00\u4e2a\u8d44\u6e90\u57df\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\u4ee5\u53ca\u7531\u8d44\u6e90\u57df\u4e2d\u7684\u6240\u6709\u63d0\u4f9b\u70b9\u5171\u4eab\u7684\u4e00\u4e2a\u4e8c\u7ea7\u5b58\u50a8\u670d\u52a1\u5668\u7ec4\u6210\uff0c\u5176\u4e2d\u6bcf\u4e2a\u63d0\u4f9b\u70b9\u4e2d\u5305\u542b\u591a\u4e2a\u4e3b\u673a\u548c\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u3002 message.detach.disk=\u662f\u5426\u786e\u5b9e\u8981\u53d6\u6d88\u9644\u52a0\u6b64\u78c1\u76d8? message.detach.iso.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4ece\u6b64\u865a\u62df\u673a\u4e2d\u53d6\u6d88\u9644\u52a0\u6b64 ISO\u3002 message.disable.account=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528\u6b64\u5e10\u6237\u3002\u7981\u7528\u540e\uff0c\u6b64\u5e10\u6237\u7684\u6240\u6709\u7528\u6237\u5c06\u4e0d\u518d\u6709\u6743\u8bbf\u95ee\u5404\u81ea\u7684\u4e91\u8d44\u6e90\u3002\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684\u865a\u62df\u673a\u5c06\u7acb\u5373\u5173\u95ed\u3002 @@ -1425,7 +1653,7 @@ message.download.volume=\u8bf7\u5355\u51fb 00000 \u4e0b\u8f7d\ message.edit.account=\u7f16\u8f91(\u201c-1\u201d\u8868\u793a\u5bf9\u8981\u521b\u5efa\u7684\u8d44\u6e90\u6570\u91cf\u6ca1\u6709\u4efb\u4f55\u9650\u5236) message.edit.confirm=\u8bf7\u5148\u786e\u8ba4\u60a8\u6240\u505a\u7684\u66f4\u6539\uff0c\u7136\u540e\u5355\u51fb\u201c\u4fdd\u5b58\u201d\u3002 message.edit.limits=\u8bf7\u6307\u5b9a\u5bf9\u4ee5\u4e0b\u8d44\u6e90\u7684\u9650\u5236\u3002\u201c-1\u201d\u8868\u793a\u4e0d\u9650\u5236\u8981\u521b\u5efa\u7684\u8d44\u6e90\u6570\u3002 -message.edit.traffic.type=\u8bf7\u6307\u5b9a\u60a8\u5e0c\u671b\u4e0e\u6b64\u901a\u4fe1\u7c7b\u578b\u5173\u8054\u7684\u901a\u4fe1\u6807\u7b7e\u3002 +message.edit.traffic.type=\u8bf7\u6307\u5b9a\u60a8\u5e0c\u671b\u4e0e\u6b64\u6d41\u91cf\u7c7b\u578b\u5173\u8054\u7684\u6d41\u91cf\u6807\u7b7e\u3002 message.enable.account=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u5e10\u6237\u3002 message.enable.user=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528\u6b64\u7528\u6237\u3002 message.enable.vpn.access=\u5f53\u524d\u5df2\u5bf9\u6b64 IP \u5730\u5740\u7981\u7528\u4e86 VPN\u3002\u662f\u5426\u8981\u542f\u7528 VPN \u8bbf\u95ee? @@ -1433,51 +1661,51 @@ message.enable.vpn=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5bf9\u6b64 IP \u5 message.enabled.vpn.ip.sec=\u60a8\u7684 IPSec \u9884\u5171\u4eab\u5bc6\u94a5 message.enabled.vpn=\u60a8\u7684 VPN \u8bbf\u95ee\u529f\u80fd\u5f53\u524d\u5df2\u542f\u7528\uff0c\u53ef\u4ee5\u901a\u8fc7 IP \u8fdb\u884c\u8bbf\u95ee message.enabling.security.group.provider=\u6b63\u5728\u542f\u7528\u5b89\u5168\u7ec4\u63d0\u4f9b\u7a0b\u5e8f -message.enabling.zone=\u6b63\u5728\u542f\u7528\u533a\u57df +message.enabling.zone=\u6b63\u5728\u542f\u7528\u8d44\u6e90\u57df message.enter.token=\u8bf7\u8f93\u5165\u60a8\u5728\u9080\u8bf7\u7535\u5b50\u90ae\u4ef6\u4e2d\u6536\u5230\u7684\u4ee4\u724c\u3002 message.generate.keys=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e3a\u6b64\u7528\u6237\u751f\u6210\u65b0\u5bc6\u94a5\u3002 -message.guest.traffic.in.advanced.zone=\u6765\u5bbe\u7f51\u7edc\u901a\u4fe1\u662f\u6307\u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u6307\u5b9a\u4e00\u4e2a VLAN ID \u8303\u56f4\u53ef\u4f20\u9001\u6bcf\u4e2a\u7269\u7406\u7f51\u7edc\u7684\u6765\u5bbe\u901a\u4fe1\u3002 -message.guest.traffic.in.basic.zone=\u6765\u5bbe\u7f51\u7edc\u901a\u4fe1\u662f\u6307\u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5e94\u6307\u5b9a\u4e00\u4e2a CloudStack \u53ef\u4ee5\u5206\u914d\u7ed9\u6765\u5bbe VM \u7684 IP \u5730\u5740\u8303\u56f4\u3002\u8bf7\u786e\u4fdd\u6b64\u8303\u56f4\u4e0e\u9884\u7559\u7684\u7cfb\u7edf IP \u8303\u56f4\u4e0d\u91cd\u53e0\u3002 +message.guest.traffic.in.advanced.zone=\u6765\u5bbe\u7f51\u7edc\u6d41\u91cf\u662f\u6307\u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u6307\u5b9a\u4e00\u4e2a VLAN ID \u8303\u56f4\u53ef\u4f20\u9001\u6bcf\u4e2a\u7269\u7406\u7f51\u7edc\u7684\u6765\u5bbe\u6d41\u91cf\u3002 +message.guest.traffic.in.basic.zone=\u6765\u5bbe\u7f51\u7edc\u6d41\u91cf\u662f\u6307\u6700\u7ec8\u7528\u6237\u865a\u62df\u673a\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u5e94\u6307\u5b9a\u4e00\u4e2a CloudStack \u53ef\u4ee5\u5206\u914d\u7ed9\u6765\u5bbe VM \u7684 IP \u5730\u5740\u8303\u56f4\u3002\u8bf7\u786e\u4fdd\u6b64\u8303\u56f4\u4e0e\u9884\u7559\u7684\u7cfb\u7edf IP \u8303\u56f4\u4e0d\u91cd\u53e0\u3002 message.installWizard.click.retry=\u8bf7\u5355\u51fb\u6b64\u6309\u94ae\u91cd\u65b0\u5c1d\u8bd5\u542f\u52a8\u3002 -message.installWizard.copy.whatIsACluster=\u7fa4\u96c6\u63d0\u4f9b\u4e86\u4e00\u79cd\u7f16\u7ec4\u4e3b\u673a\u7684\u65b9\u6cd5\u3002\u7fa4\u96c6\u4e2d\u7684\u6240\u6709\u4e3b\u673a\u90fd\u5177\u6709\u76f8\u540c\u7684\u786c\u4ef6\uff0c\u8fd0\u884c\u76f8\u540c\u7684\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\uff0c\u4f4d\u4e8e\u540c\u4e00\u5b50\u7f51\u4e2d\uff0c\u5e76\u8bbf\u95ee\u76f8\u540c\u7684\u5171\u4eab\u5b58\u50a8\u3002\u53ef\u4ee5\u5b9e\u65f6\u5c06\u865a\u62df\u673a\u5b9e\u4f8b(VM)\u4ece\u4e00\u53f0\u4e3b\u673a\u8fc1\u79fb\u5230\u540c\u4e00\u7fa4\u96c6\u5185\u7684\u5176\u4ed6\u4e3b\u673a\uff0c\u800c\u65e0\u9700\u4e2d\u65ad\u5411\u7528\u6237\u63d0\u4f9b\u670d\u52a1\u3002\u7fa4\u96c6\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u7684\u7b2c\u4e09\u5927\u7ec4\u7ec7\u5355\u4f4d\u3002\u7fa4\u96c6\u5305\u542b\u5728\u63d0\u4f9b\u70b9\u4e2d\uff0c\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u533a\u57df\u4e2d\u3002

CloudStack&\#8482; \u5141\u8bb8\u4e91\u90e8\u7f72\u4e2d\u5b58\u5728\u591a\u4e2a\u7fa4\u96c6\uff0c\u4f46\u5bf9\u4e8e\u57fa\u672c\u5b89\u88c5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4e00\u4e2a\u7fa4\u96c6\u3002 -message.installWizard.copy.whatIsAHost=\u4e3b\u673a\u662f\u6307\u4e00\u53f0\u8ba1\u7b97\u673a\u3002\u4e3b\u673a\u63d0\u4f9b\u8fd0\u884c\u6765\u5bbe\u865a\u62df\u673a\u7684\u8ba1\u7b97\u8d44\u6e90\u3002\u6bcf\u53f0\u4e3b\u673a\u4e0a\u90fd\u5b89\u88c5\u6709\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u8f6f\u4ef6\uff0c\u7528\u4e8e\u7ba1\u7406\u6765\u5bbe VM (\u88f8\u673a\u4e3b\u673a\u9664\u5916\uff0c\u5c06\u5728\u201c\u9ad8\u7ea7\u5b89\u88c5\u6307\u5357\u201d\u4e2d\u8ba8\u8bba\u8fd9\u4e00\u7279\u6b8a\u6848\u4f8b)\u3002\u4f8b\u5982\uff0c\u542f\u7528\u4e86 KVM \u7684 Linux \u670d\u52a1\u5668\u3001Citrix XenServer \u670d\u52a1\u5668\u548c ESXi \u670d\u52a1\u5668\u90fd\u53ef\u7528\u4f5c\u4e3b\u673a\u3002\u5728\u57fa\u672c\u5b89\u88c5\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4e00\u53f0\u8fd0\u884c XenServer \u7684\u4e3b\u673a\u3002

\u4e3b\u673a\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u6700\u5c0f\u7684\u7ec4\u7ec7\u5355\u4f4d\u3002\u4e3b\u673a\u5305\u542b\u5728\u7fa4\u96c6\u4e2d\uff0c\u7fa4\u96c6\u5305\u542b\u5728\u63d0\u4f9b\u70b9\u4e2d\uff0c\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u533a\u57df\u4e2d\u3002 -message.installWizard.copy.whatIsAPod=\u4e00\u4e2a\u63d0\u4f9b\u70b9\u901a\u5e38\u4ee3\u8868\u4e00\u4e2a\u673a\u67b6\u3002\u540c\u4e00\u63d0\u4f9b\u70b9\u4e2d\u7684\u4e3b\u673a\u4f4d\u4e8e\u540c\u4e00\u5b50\u7f51\u4e2d\u3002

\u63d0\u4f9b\u70b9\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u7684\u7b2c\u4e8c\u5927\u7ec4\u7ec7\u5355\u4f4d\u3002\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u533a\u57df\u4e2d\u3002\u6bcf\u4e2a\u533a\u57df\u4e2d\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\uff1b\u5728\u57fa\u672c\u5b89\u88c5\u4e2d\uff0c\u60a8\u7684\u533a\u57df\u4e2d\u5c06\u4ec5\u5305\u542b\u4e00\u4e2a\u63d0\u4f9b\u70b9\u3002 -message.installWizard.copy.whatIsAZone=\u533a\u57df\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u6700\u5927\u7684\u7ec4\u7ec7\u5355\u4f4d\u3002\u867d\u7136\u5141\u8bb8\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u4e2d\u5b58\u5728\u591a\u4e2a\u533a\u57df\uff0c\u4f46\u662f\u4e00\u4e2a\u533a\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u5c06\u57fa\u7840\u67b6\u6784\u7f16\u7ec4\u5230\u533a\u57df\u4e2d\u7684\u597d\u5904\u662f\u53ef\u4ee5\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\u3002\u4f8b\u5982\uff0c\u6bcf\u4e2a\u533a\u57df\u90fd\u53ef\u4ee5\u62e5\u6709\u5404\u81ea\u7684\u7535\u6e90\u4f9b\u5e94\u548c\u7f51\u7edc\u4e0a\u884c\u65b9\u6848\uff0c\u5e76\u4e14\u5404\u533a\u57df\u53ef\u4ee5\u5728\u5730\u7406\u4f4d\u7f6e\u4e0a\u76f8\u9694\u5f88\u8fdc(\u867d\u7136\u5e76\u975e\u5fc5\u987b\u76f8\u9694\u5f88\u8fdc)\u3002 -message.installWizard.copy.whatIsCloudStack=CloudStack&\#8482 \u662f\u4e00\u4e2a\u8f6f\u4ef6\u5e73\u53f0\uff0c\u53ef\u5c06\u8ba1\u7b97\u8d44\u6e90\u96c6\u4e2d\u5728\u4e00\u8d77\u4ee5\u6784\u5efa\u516c\u5171\u3001\u79c1\u6709\u548c\u6df7\u5408\u57fa\u7840\u8bbe\u65bd\u5373\u670d\u52a1(IaaS)\u4e91\u3002CloudStack&\#8482 \u8d1f\u8d23\u7ba1\u7406\u7ec4\u6210\u4e91\u57fa\u7840\u67b6\u6784\u7684\u7f51\u7edc\u3001\u5b58\u50a8\u548c\u8ba1\u7b97\u8282\u70b9\u3002\u4f7f\u7528 CloudStack&\#8482 \u53ef\u4ee5\u90e8\u7f72\u3001\u7ba1\u7406\u548c\u914d\u7f6e\u4e91\u8ba1\u7b97\u73af\u5883\u3002

CloudStack&\#8482 \u901a\u8fc7\u6269\u5c55\u5546\u7528\u786c\u4ef6\u4e0a\u8fd0\u884c\u7684\u6bcf\u4e2a\u865a\u62df\u673a\u6620\u50cf\u7684\u8303\u56f4\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5b9e\u65f6\u53ef\u7528\u7684\u4e91\u57fa\u7840\u67b6\u6784\u8f6f\u4ef6\u5806\u6808\u7528\u4e8e\u4ee5\u670d\u52a1\u65b9\u5f0f\u4ea4\u4ed8\u865a\u62df\u6570\u636e\u4e2d\u5fc3\uff0c\u5373\u4ea4\u4ed8\u6784\u5efa\u3001\u90e8\u7f72\u548c\u7ba1\u7406\u591a\u5c42\u6b21\u548c\u591a\u79df\u6237\u4e91\u5e94\u7528\u7a0b\u5e8f\u5fc5\u9700\u7684\u6240\u6709\u7ec4\u4ef6\u3002\u5f00\u6e90\u7248\u672c\u548c Premium \u7248\u672c\u90fd\u5df2\u53ef\u7528\uff0c\u4e14\u63d0\u4f9b\u7684\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\u3002 -message.installWizard.copy.whatIsPrimaryStorage=CloudStack&\#8482; \u4e91\u57fa\u7840\u67b6\u6784\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\: \u4e3b\u5b58\u50a8\u548c\u8f85\u52a9\u5b58\u50a8\u3002\u8fd9\u4e24\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\u53ef\u4ee5\u662f iSCSI \u6216 NFS \u670d\u52a1\u5668\uff0c\u4e5f\u53ef\u4ee5\u662f\u672c\u5730\u78c1\u76d8\u3002

\u4e3b\u5b58\u50a8\u4e0e\u7fa4\u96c6\u76f8\u5173\u8054\uff0c\u7528\u4e8e\u5b58\u50a8\u8be5\u7fa4\u96c6\u4e2d\u7684\u4e3b\u673a\u4e0a\u6b63\u5728\u8fd0\u884c\u7684\u6240\u6709 VM \u5bf9\u5e94\u7684\u6bcf\u4e2a\u6765\u5bbe VM \u7684\u78c1\u76d8\u5377\u3002\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u901a\u5e38\u4f4d\u4e8e\u9760\u8fd1\u4e3b\u673a\u7684\u4f4d\u7f6e\u3002 -message.installWizard.copy.whatIsSecondaryStorage=\u8f85\u52a9\u5b58\u50a8\u4e0e\u533a\u57df\u76f8\u5173\u8054\uff0c\u7528\u4e8e\u5b58\u50a8\u4ee5\u4e0b\u9879\u76ee\:
  • \u6a21\u677f - \u53ef\u7528\u4e8e\u542f\u52a8 VM \u5e76\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u914d\u7f6e\u4fe1\u606f(\u4f8b\u5982\uff0c\u5df2\u5b89\u88c5\u7684\u5e94\u7528\u7a0b\u5e8f)\u7684\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf
  • ISO \u6620\u50cf - \u53ef\u91cd\u65b0\u542f\u52a8\u6216\u4e0d\u53ef\u91cd\u65b0\u542f\u52a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf
  • \u78c1\u76d8\u5377\u5feb\u7167 - \u5df2\u4fdd\u5b58\u7684 VM \u6570\u636e\u526f\u672c\uff0c\u53ef\u7528\u4e8e\u6267\u884c\u6570\u636e\u6062\u590d\u6216\u521b\u5efa\u65b0\u6a21\u677f
+message.installWizard.copy.whatIsACluster=\u7fa4\u96c6\u63d0\u4f9b\u4e86\u4e00\u79cd\u7f16\u7ec4\u4e3b\u673a\u7684\u65b9\u6cd5\u3002\u7fa4\u96c6\u4e2d\u7684\u6240\u6709\u4e3b\u673a\u90fd\u5177\u6709\u76f8\u540c\u7684\u786c\u4ef6\uff0c\u8fd0\u884c\u76f8\u540c\u7684\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\uff0c\u4f4d\u4e8e\u540c\u4e00\u5b50\u7f51\u4e2d\uff0c\u5e76\u8bbf\u95ee\u76f8\u540c\u7684\u5171\u4eab\u5b58\u50a8\u3002\u53ef\u4ee5\u5b9e\u65f6\u5c06\u865a\u62df\u673a\u5b9e\u4f8b(VM)\u4ece\u4e00\u53f0\u4e3b\u673a\u8fc1\u79fb\u5230\u540c\u4e00\u7fa4\u96c6\u5185\u7684\u5176\u4ed6\u4e3b\u673a\uff0c\u800c\u65e0\u9700\u4e2d\u65ad\u5411\u7528\u6237\u63d0\u4f9b\u670d\u52a1\u3002\u7fa4\u96c6\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u7684\u7b2c\u4e09\u5927\u7ec4\u7ec7\u5355\u4f4d\u3002\u7fa4\u96c6\u5305\u542b\u5728\u63d0\u4f9b\u70b9\u4e2d\uff0c\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u8d44\u6e90\u57df\u4e2d\u3002

CloudStack&\#8482; \u5141\u8bb8\u4e91\u90e8\u7f72\u4e2d\u5b58\u5728\u591a\u4e2a\u7fa4\u96c6\uff0c\u4f46\u5bf9\u4e8e\u57fa\u672c\u5b89\u88c5\uff0c\u6211\u4eec\u53ea\u9700\u8981\u4e00\u4e2a\u7fa4\u96c6\u3002 +message.installWizard.copy.whatIsAHost=\u4e3b\u673a\u662f\u6307\u4e00\u53f0\u8ba1\u7b97\u673a\u3002\u4e3b\u673a\u63d0\u4f9b\u8fd0\u884c\u6765\u5bbe\u865a\u62df\u673a\u7684\u8ba1\u7b97\u8d44\u6e90\u3002\u6bcf\u53f0\u4e3b\u673a\u4e0a\u90fd\u5b89\u88c5\u6709\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u8f6f\u4ef6\uff0c\u7528\u4e8e\u7ba1\u7406\u6765\u5bbe VM (\u88f8\u673a\u4e3b\u673a\u9664\u5916\uff0c\u5c06\u5728\u201c\u9ad8\u7ea7\u5b89\u88c5\u6307\u5357\u201d\u4e2d\u8ba8\u8bba\u8fd9\u4e00\u7279\u6b8a\u6848\u4f8b)\u3002\u4f8b\u5982\uff0c\u542f\u7528\u4e86 KVM \u7684 Linux \u670d\u52a1\u5668\u3001Citrix XenServer \u670d\u52a1\u5668\u548c ESXi \u670d\u52a1\u5668\u90fd\u53ef\u7528\u4f5c\u4e3b\u673a\u3002\u5728\u57fa\u672c\u5b89\u88c5\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4e00\u53f0\u8fd0\u884c XenServer \u7684\u4e3b\u673a\u3002

\u4e3b\u673a\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u6700\u5c0f\u7684\u7ec4\u7ec7\u5355\u4f4d\u3002\u4e3b\u673a\u5305\u542b\u5728\u7fa4\u96c6\u4e2d\uff0c\u7fa4\u96c6\u5305\u542b\u5728\u63d0\u4f9b\u70b9\u4e2d\uff0c\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u8d44\u6e90\u57df\u4e2d\u3002 +message.installWizard.copy.whatIsAPod=\u4e00\u4e2a\u63d0\u4f9b\u70b9\u901a\u5e38\u4ee3\u8868\u4e00\u4e2a\u673a\u67b6\u3002\u540c\u4e00\u63d0\u4f9b\u70b9\u4e2d\u7684\u4e3b\u673a\u4f4d\u4e8e\u540c\u4e00\u5b50\u7f51\u4e2d\u3002

\u63d0\u4f9b\u70b9\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u7684\u7b2c\u4e8c\u5927\u7ec4\u7ec7\u5355\u4f4d\u3002\u63d0\u4f9b\u70b9\u5305\u542b\u5728\u8d44\u6e90\u57df\u4e2d\u3002\u6bcf\u4e2a\u8d44\u6e90\u57df\u4e2d\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u63d0\u4f9b\u70b9\uff1b\u5728\u57fa\u672c\u5b89\u88c5\u4e2d\uff0c\u60a8\u7684\u8d44\u6e90\u57df\u4e2d\u5c06\u4ec5\u5305\u542b\u4e00\u4e2a\u63d0\u4f9b\u70b9\u3002 +message.installWizard.copy.whatIsAZone=\u8d44\u6e90\u57df\u662f CloudStack&\#8482; \u90e8\u7f72\u4e2d\u6700\u5927\u7684\u7ec4\u7ec7\u5355\u4f4d\u3002\u867d\u7136\u5141\u8bb8\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u4e2d\u5b58\u5728\u591a\u4e2a\u8d44\u6e90\u57df\uff0c\u4f46\u662f\u4e00\u4e2a\u8d44\u6e90\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u5c06\u57fa\u7840\u67b6\u6784\u7f16\u7ec4\u5230\u8d44\u6e90\u57df\u4e2d\u7684\u597d\u5904\u662f\u53ef\u4ee5\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\u3002\u4f8b\u5982\uff0c\u6bcf\u4e2a\u8d44\u6e90\u57df\u90fd\u53ef\u4ee5\u62e5\u6709\u5404\u81ea\u7684\u7535\u6e90\u4f9b\u5e94\u548c\u7f51\u7edc\u4e0a\u884c\u65b9\u6848\uff0c\u5e76\u4e14\u5404\u8d44\u6e90\u57df\u53ef\u4ee5\u5728\u5730\u7406\u4f4d\u7f6e\u4e0a\u76f8\u9694\u5f88\u8fdc(\u867d\u7136\u5e76\u975e\u5fc5\u987b\u76f8\u9694\u5f88\u8fdc)\u3002 +message.installWizard.copy.whatIsCloudStack=CloudStack&\#8482 \u662f\u4e00\u4e2a\u8f6f\u4ef6\u5e73\u53f0\uff0c\u53ef\u5c06\u8ba1\u7b97\u8d44\u6e90\u96c6\u4e2d\u5728\u4e00\u8d77\u4ee5\u6784\u5efa\u516c\u6709\u3001\u79c1\u6709\u548c\u6df7\u5408\u57fa\u7840\u8bbe\u65bd\u5373\u670d\u52a1(IaaS)\u4e91\u3002CloudStack&\#8482 \u8d1f\u8d23\u7ba1\u7406\u7ec4\u6210\u4e91\u57fa\u7840\u67b6\u6784\u7684\u7f51\u7edc\u3001\u5b58\u50a8\u548c\u8ba1\u7b97\u8282\u70b9\u3002\u4f7f\u7528 CloudStack&\#8482 \u53ef\u4ee5\u90e8\u7f72\u3001\u7ba1\u7406\u548c\u914d\u7f6e\u4e91\u8ba1\u7b97\u73af\u5883\u3002

CloudStack&\#8482 \u901a\u8fc7\u6269\u5c55\u5546\u7528\u786c\u4ef6\u4e0a\u8fd0\u884c\u7684\u6bcf\u4e2a\u865a\u62df\u673a\u6620\u50cf\u7684\u8303\u56f4\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5b9e\u65f6\u53ef\u7528\u7684\u4e91\u57fa\u7840\u67b6\u6784\u8f6f\u4ef6\u5806\u6808\u7528\u4e8e\u4ee5\u670d\u52a1\u65b9\u5f0f\u4ea4\u4ed8\u865a\u62df\u6570\u636e\u4e2d\u5fc3\uff0c\u5373\u4ea4\u4ed8\u6784\u5efa\u3001\u90e8\u7f72\u548c\u7ba1\u7406\u591a\u5c42\u6b21\u548c\u591a\u79df\u6237\u4e91\u5e94\u7528\u7a0b\u5e8f\u5fc5\u9700\u7684\u6240\u6709\u7ec4\u4ef6\u3002\u5f00\u6e90\u7248\u672c\u548c Premium \u7248\u672c\u90fd\u5df2\u53ef\u7528\uff0c\u4e14\u63d0\u4f9b\u7684\u529f\u80fd\u51e0\u4e4e\u5b8c\u5168\u76f8\u540c\u3002 +message.installWizard.copy.whatIsPrimaryStorage=CloudStack&\#8482; \u4e91\u57fa\u7840\u67b6\u6784\u4f7f\u7528\u4ee5\u4e0b\u4e24\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\: \u4e3b\u5b58\u50a8\u548c\u4e8c\u7ea7\u5b58\u50a8\u3002\u8fd9\u4e24\u79cd\u7c7b\u578b\u7684\u5b58\u50a8\u53ef\u4ee5\u662f iSCSI \u6216 NFS \u670d\u52a1\u5668\uff0c\u4e5f\u53ef\u4ee5\u662f\u672c\u5730\u78c1\u76d8\u3002

\u4e3b\u5b58\u50a8\u4e0e\u7fa4\u96c6\u76f8\u5173\u8054\uff0c\u7528\u4e8e\u5b58\u50a8\u8be5\u7fa4\u96c6\u4e2d\u7684\u4e3b\u673a\u4e0a\u6b63\u5728\u8fd0\u884c\u7684\u6240\u6709 VM \u5bf9\u5e94\u7684\u6bcf\u4e2a\u6765\u5bbe VM \u7684\u78c1\u76d8\u5377\u3002\u4e3b\u5b58\u50a8\u670d\u52a1\u5668\u901a\u5e38\u4f4d\u4e8e\u9760\u8fd1\u4e3b\u673a\u7684\u4f4d\u7f6e\u3002 +message.installWizard.copy.whatIsSecondaryStorage=\u4e8c\u7ea7\u5b58\u50a8\u4e0e\u8d44\u6e90\u57df\u76f8\u5173\u8054\uff0c\u7528\u4e8e\u5b58\u50a8\u4ee5\u4e0b\u9879\u76ee\:
  • \u6a21\u677f - \u53ef\u7528\u4e8e\u542f\u52a8 VM \u5e76\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u914d\u7f6e\u4fe1\u606f(\u4f8b\u5982\uff0c\u5df2\u5b89\u88c5\u7684\u5e94\u7528\u7a0b\u5e8f)\u7684\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf
  • ISO \u6620\u50cf - \u53ef\u91cd\u65b0\u542f\u52a8\u6216\u4e0d\u53ef\u91cd\u65b0\u542f\u52a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf
  • \u78c1\u76d8\u5377\u5feb\u7167 - \u5df2\u4fdd\u5b58\u7684 VM \u6570\u636e\u526f\u672c\uff0c\u53ef\u7528\u4e8e\u6267\u884c\u6570\u636e\u6062\u590d\u6216\u521b\u5efa\u65b0\u6a21\u677f
message.installWizard.now.building=\u73b0\u5728\u6b63\u5728\u6784\u5efa\u60a8\u7684\u4e91... message.installWizard.tooltip.addCluster.name=\u7fa4\u96c6\u7684\u540d\u79f0\u3002\u6b64\u540d\u79f0\u53ef\u4ee5\u662f\u60a8\u9009\u62e9\u7684\u6587\u672c\uff0c\u4e14\u672a\u7531 CloudStack \u4f7f\u7528\u3002 message.installWizard.tooltip.addHost.hostname=\u4e3b\u673a\u7684 DNS \u540d\u79f0\u6216 IP \u5730\u5740\u3002 message.installWizard.tooltip.addHost.password=\u6b64\u4e3a\u4e0a\u8ff0\u7528\u6237\u7684\u5bc6\u7801(\u6765\u81ea XenServer \u5b89\u88c5)\u3002 message.installWizard.tooltip.addHost.username=\u901a\u5e38\u4e3a root\u3002 message.installWizard.tooltip.addPod.name=\u63d0\u4f9b\u70b9\u7684\u540d\u79f0 -message.installWizard.tooltip.addPod.reservedSystemEndIp=\u6b64\u4e3a CloudStack \u7528\u4e8e\u7ba1\u7406\u8f85\u52a9\u5b58\u50a8 VM \u548c\u63a7\u5236\u53f0\u4ee3\u7406 VM \u7684\u4e13\u7528\u7f51\u7edc\u4e2d\u7684 IP \u8303\u56f4\u3002\u8fd9\u4e9b IP \u5730\u5740\u6765\u81ea\u4e0e\u8ba1\u7b97\u670d\u52a1\u5668\u76f8\u540c\u7684\u5b50\u7f51\u3002 +message.installWizard.tooltip.addPod.reservedSystemEndIp=\u6b64\u4e3a CloudStack \u7528\u4e8e\u7ba1\u7406\u4e8c\u7ea7\u5b58\u50a8 VM \u548c\u63a7\u5236\u53f0\u4ee3\u7406 VM \u7684\u4e13\u7528\u7f51\u7edc\u4e2d\u7684 IP \u8303\u56f4\u3002\u8fd9\u4e9b IP \u5730\u5740\u6765\u81ea\u4e0e\u8ba1\u7b97\u670d\u52a1\u5668\u76f8\u540c\u7684\u5b50\u7f51\u3002 message.installWizard.tooltip.addPod.reservedSystemGateway=\u8be5\u63d0\u4f9b\u70b9\u4e2d\u7684\u4e3b\u673a\u7f51\u5173\u3002 message.installWizard.tooltip.addPod.reservedSystemNetmask=\u6765\u5bbe\u5c06\u8981\u4f7f\u7528\u7684\u5b50\u7f51\u4e0a\u6b63\u5728\u4f7f\u7528\u7684\u7f51\u7edc\u63a9\u7801\u3002 -message.installWizard.tooltip.addPod.reservedSystemStartIp=\u6b64\u4e3a CloudStack \u7528\u4e8e\u7ba1\u7406\u8f85\u52a9\u5b58\u50a8 VM \u548c\u63a7\u5236\u53f0\u4ee3\u7406 VM \u7684\u4e13\u7528\u7f51\u7edc\u4e2d\u7684 IP \u8303\u56f4\u3002\u8fd9\u4e9b IP \u5730\u5740\u6765\u81ea\u4e0e\u8ba1\u7b97\u670d\u52a1\u5668\u76f8\u540c\u7684\u5b50\u7f51\u3002 +message.installWizard.tooltip.addPod.reservedSystemStartIp=\u6b64\u4e3a CloudStack \u7528\u4e8e\u7ba1\u7406\u4e8c\u7ea7\u5b58\u50a8 VM \u548c\u63a7\u5236\u53f0\u4ee3\u7406 VM \u7684\u4e13\u7528\u7f51\u7edc\u4e2d\u7684 IP \u8303\u56f4\u3002\u8fd9\u4e9b IP \u5730\u5740\u6765\u81ea\u4e0e\u8ba1\u7b97\u670d\u52a1\u5668\u76f8\u540c\u7684\u5b50\u7f51\u3002 message.installWizard.tooltip.addPrimaryStorage.name=\u5b58\u50a8\u8bbe\u5907\u7684\u540d\u79f0\u3002 -message.installWizard.tooltip.addPrimaryStorage.path=(\u9002\u7528\u4e8e NFS)\u5728 NFS \u4e2d\uff0c\u6b64\u8def\u5f84\u4e3a\u670d\u52a1\u5668\u7684\u5bfc\u51fa\u8def\u5f84\u3002\u8def\u5f84(\u9488\u5bf9 SharedMountPoint)\u3002\u5bf9\u4e8e KVM\uff0c\u6b64\u8def\u5f84\u4e3a\u88c5\u8f7d\u4e86\u8f85\u52a9\u5b58\u50a8\u7684\u6bcf\u4e2a\u4e3b\u673a\u4e0a\u7684\u8def\u5f84\u3002\u4f8b\u5982\uff0c/mnt/primary\u3002 +message.installWizard.tooltip.addPrimaryStorage.path=(\u9002\u7528\u4e8e NFS)\u5728 NFS \u4e2d\uff0c\u6b64\u8def\u5f84\u4e3a\u670d\u52a1\u5668\u7684\u5bfc\u51fa\u8def\u5f84\u3002\u8def\u5f84(\u9488\u5bf9 SharedMountPoint)\u3002\u5bf9\u4e8e KVM\uff0c\u6b64\u8def\u5f84\u4e3a\u88c5\u8f7d\u4e86\u4e8c\u7ea7\u5b58\u50a8\u7684\u6bcf\u4e2a\u4e3b\u673a\u4e0a\u7684\u8def\u5f84\u3002\u4f8b\u5982\uff0c/mnt/primary\u3002 message.installWizard.tooltip.addPrimaryStorage.server=(\u9002\u7528\u4e8e NFS\u3001iSCSI \u6216 PreSetup)\u5b58\u50a8\u8bbe\u5907\u7684 IP \u5730\u5740\u6216 DNS \u540d\u79f0\u3002 -message.installWizard.tooltip.addSecondaryStorage.nfsServer=\u6258\u7ba1\u8f85\u52a9\u5b58\u50a8\u7684 NFS \u670d\u52a1\u5668\u7684 IP \u5730\u5740 +message.installWizard.tooltip.addSecondaryStorage.nfsServer=\u6258\u7ba1\u4e8c\u7ea7\u5b58\u50a8\u7684 NFS \u670d\u52a1\u5668\u7684 IP \u5730\u5740 message.installWizard.tooltip.addSecondaryStorage.path=\u5bfc\u51fa\u8def\u5f84(\u4f4d\u4e8e\u4e0a\u8ff0\u6307\u5b9a\u670d\u52a1\u5668\u4e0a) -message.installWizard.tooltip.addZone.dns1=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u533a\u57df\u4e2d\u7684\u6765\u5bbe VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u60a8\u7a0d\u540e\u8981\u6dfb\u52a0\u7684\u516c\u7528\u7f51\u7edc\u8fdb\u884c\u8bbf\u95ee\u3002\u6b64\u533a\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002 -message.installWizard.tooltip.addZone.dns2=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u533a\u57df\u4e2d\u7684\u6765\u5bbe VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u60a8\u7a0d\u540e\u8981\u6dfb\u52a0\u7684\u516c\u7528\u7f51\u7edc\u8fdb\u884c\u8bbf\u95ee\u3002\u6b64\u533a\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002 -message.installWizard.tooltip.addZone.internaldns1=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u533a\u57df\u4e2d\u7684\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u7cfb\u7edf VM \u7684\u4e13\u7528\u7f51\u7edc\u63a5\u53e3\u8fdb\u884c\u8bbf\u95ee\u3002\u60a8\u4e3a\u63d0\u4f9b\u70b9\u63d0\u4f9b\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002 -message.installWizard.tooltip.addZone.internaldns2=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u533a\u57df\u4e2d\u7684\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u7cfb\u7edf VM \u7684\u4e13\u7528\u7f51\u7edc\u63a5\u53e3\u8fdb\u884c\u8bbf\u95ee\u3002\u60a8\u4e3a\u63d0\u4f9b\u70b9\u63d0\u4f9b\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002 -message.installWizard.tooltip.addZone.name=\u533a\u57df\u540d\u79f0 +message.installWizard.tooltip.addZone.dns1=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u8d44\u6e90\u57df\u4e2d\u7684\u6765\u5bbe VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u60a8\u7a0d\u540e\u8981\u6dfb\u52a0\u7684\u516c\u7528\u7f51\u7edc\u8fdb\u884c\u8bbf\u95ee\u3002\u6b64\u8d44\u6e90\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002 +message.installWizard.tooltip.addZone.dns2=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u8d44\u6e90\u57df\u4e2d\u7684\u6765\u5bbe VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u60a8\u7a0d\u540e\u8981\u6dfb\u52a0\u7684\u516c\u7528\u7f51\u7edc\u8fdb\u884c\u8bbf\u95ee\u3002\u6b64\u8d44\u6e90\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002 +message.installWizard.tooltip.addZone.internaldns1=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u8d44\u6e90\u57df\u4e2d\u7684\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u7cfb\u7edf VM \u7684\u4e13\u7528\u7f51\u7edc\u63a5\u53e3\u8fdb\u884c\u8bbf\u95ee\u3002\u60a8\u4e3a\u63d0\u4f9b\u70b9\u63d0\u4f9b\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002 +message.installWizard.tooltip.addZone.internaldns2=\u8fd9\u4e9b\u670d\u52a1\u5668\u662f\u4f9b\u6b64\u8d44\u6e90\u57df\u4e2d\u7684\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\uff0c\u5c06\u901a\u8fc7\u7cfb\u7edf VM \u7684\u4e13\u7528\u7f51\u7edc\u63a5\u53e3\u8fdb\u884c\u8bbf\u95ee\u3002\u60a8\u4e3a\u63d0\u4f9b\u70b9\u63d0\u4f9b\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u5728\u6b64\u5904\u6307\u5b9a\u7684 DNS \u670d\u52a1\u5668\u3002 +message.installWizard.tooltip.addZone.name=\u8d44\u6e90\u57df\u540d\u79f0 message.installWizard.tooltip.configureGuestTraffic.description=\u60a8\u7684\u7f51\u7edc\u8bf4\u660e -message.installWizard.tooltip.configureGuestTraffic.guestEndIp=\u80fd\u591f\u5206\u914d\u7ed9\u6b64\u533a\u57df\u4e2d\u7684\u6765\u5bbe\u7684 IP \u5730\u5740\u8303\u56f4\u3002\u5982\u679c\u4f7f\u7528\u4e00\u4e2a NIC\uff0c\u8fd9\u4e9b IP \u5e94\u4f4d\u4e8e\u4e0e\u63d0\u4f9b\u70b9 CIDR \u76f8\u540c\u7684 CIDR \u4e2d\u3002 +message.installWizard.tooltip.configureGuestTraffic.guestEndIp=\u80fd\u591f\u5206\u914d\u7ed9\u6b64\u8d44\u6e90\u57df\u4e2d\u7684\u6765\u5bbe\u7684 IP \u5730\u5740\u8303\u56f4\u3002\u5982\u679c\u4f7f\u7528\u4e00\u4e2a NIC\uff0c\u8fd9\u4e9b IP \u5e94\u4f4d\u4e8e\u4e0e\u63d0\u4f9b\u70b9 CIDR \u76f8\u540c\u7684 CIDR \u4e2d\u3002 message.installWizard.tooltip.configureGuestTraffic.guestGateway=\u6765\u5bbe\u5e94\u4f7f\u7528\u7684\u7f51\u5173 message.installWizard.tooltip.configureGuestTraffic.guestNetmask=\u6765\u5bbe\u5e94\u4f7f\u7528\u7684\u5b50\u7f51\u4e0a\u6b63\u5728\u4f7f\u7528\u7684\u7f51\u7edc\u63a9\u7801 -message.installWizard.tooltip.configureGuestTraffic.guestStartIp=\u80fd\u591f\u5206\u914d\u7ed9\u6b64\u533a\u57df\u4e2d\u7684\u6765\u5bbe\u7684 IP \u5730\u5740\u8303\u56f4\u3002\u5982\u679c\u4f7f\u7528\u4e00\u4e2a NIC\uff0c\u8fd9\u4e9b IP \u5e94\u4f4d\u4e8e\u4e0e\u63d0\u4f9b\u70b9 CIDR \u76f8\u540c\u7684 CIDR \u4e2d\u3002 +message.installWizard.tooltip.configureGuestTraffic.guestStartIp=\u80fd\u591f\u5206\u914d\u7ed9\u6b64\u8d44\u6e90\u57df\u4e2d\u7684\u6765\u5bbe\u7684 IP \u5730\u5740\u8303\u56f4\u3002\u5982\u679c\u4f7f\u7528\u4e00\u4e2a NIC\uff0c\u8fd9\u4e9b IP \u5e94\u4f4d\u4e8e\u4e0e\u63d0\u4f9b\u70b9 CIDR \u76f8\u540c\u7684 CIDR \u4e2d\u3002 message.installWizard.tooltip.configureGuestTraffic.name=\u60a8\u7684\u7f51\u7edc\u540d\u79f0 message.instanceWizard.noTemplates=\u60a8\u6ca1\u6709\u4efb\u4f55\u53ef\u7528\u6a21\u677f\uff1b\u8bf7\u6dfb\u52a0\u4e00\u4e2a\u517c\u5bb9\u7684\u6a21\u677f\uff0c\u7136\u540e\u91cd\u65b0\u542f\u52a8\u5b9e\u4f8b\u5411\u5bfc\u3002 message.ip.address.changed=\u60a8\u7684 IP \u5730\u5740\u53ef\u80fd\u5df2\u53d1\u751f\u53d8\u5316\uff1b\u662f\u5426\u8981\u5237\u65b0\u6b64\u5217\u8868? \u8bf7\u6ce8\u610f\uff0c\u5237\u65b0\u6b64\u5217\u8868\u65f6\uff0c\u201c\u8be6\u7ec6\u4fe1\u606f\u201d\u7a97\u683c\u5c06\u5173\u95ed\u3002 message.iso.desc=\u78c1\u76d8\u6620\u50cf\uff0c\u5176\u4e2d\u5305\u542b\u64cd\u4f5c\u7cfb\u7edf\u7684\u6570\u636e\u6216\u53ef\u542f\u52a8\u4ecb\u8d28 message.join.project=\u60a8\u73b0\u5728\u5df2\u52a0\u5165\u4e86\u4e00\u4e2a\u9879\u76ee\u3002\u8bf7\u5207\u6362\u5230\u201c\u9879\u76ee\u89c6\u56fe\u201d\u4ee5\u67e5\u770b\u9879\u76ee\u3002 message.launch.vm.on.private.network=\u662f\u5426\u8981\u5728\u60a8\u7684\u79c1\u4eba\u4e13\u7528\u7f51\u7edc\u4e2d\u542f\u52a8\u5b9e\u4f8b? -message.launch.zone=\u533a\u57df\u5df2\u51c6\u5907\u5c31\u7eea\uff0c\u53ef\u968f\u65f6\u542f\u52a8\uff1b\u8bf7\u7ee7\u7eed\u6267\u884c\u4e0b\u4e00\u6b65\u9aa4\u3002 +message.launch.zone=\u8d44\u6e90\u57df\u5df2\u51c6\u5907\u5c31\u7eea\uff0c\u53ef\u968f\u65f6\u542f\u52a8\uff1b\u8bf7\u7ee7\u7eed\u6267\u884c\u4e0b\u4e00\u6b65\u9aa4\u3002 message.lock.account=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u9501\u5b9a\u6b64\u5e10\u6237\u3002\u901a\u8fc7\u9501\u5b9a\u6b64\u5e10\u6237\uff0c\u6b64\u5e10\u6237\u7684\u6240\u6709\u7528\u6237\u5c06\u4e0d\u518d\u80fd\u591f\u7ba1\u7406\u5404\u81ea\u7684\u4e91\u8d44\u6e90\uff0c\u4f46\u4ecd\u7136\u53ef\u4ee5\u8bbf\u95ee\u73b0\u6709\u8d44\u6e90\u3002 message.migrate.instance.confirm=\u8bf7\u786e\u8ba4\u8981\u5c06\u865a\u62df\u5b9e\u4f8b\u8fc1\u79fb\u5230\u7684\u4e3b\u673a\u3002 message.migrate.instance.to.host=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5b9e\u4f8b\u8fc1\u79fb\u5230\u5176\u4ed6\u4e3b\u673a\u3002 @@ -1486,7 +1714,7 @@ message.migrate.router.confirm=\u8bf7\u786e\u8ba4\u60a8\u8981\u5c06\u8def\u7531\ message.migrate.systemvm.confirm=\u8bf7\u786e\u8ba4\u60a8\u8981\u5c06\u7cfb\u7edf VM \u8fc1\u79fb\u5230\u7684\u4e3b\u673a\: message.migrate.volume=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u5377\u8fc1\u79fb\u5230\u5176\u4ed6\u4e3b\u5b58\u50a8\u3002 message.new.user=\u8bf7\u6307\u5b9a\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u5411\u5e10\u6237\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7528\u6237 -message.no.network.support.configuration.not.true=\u60a8\u7684\u6240\u6709\u533a\u57df\u90fd\u672a\u542f\u7528\u5b89\u5168\u7ec4\uff0c\u56e0\u6b64\u65e0\u5176\u4ed6\u7f51\u7edc\u529f\u80fd\u3002\u8bf7\u7ee7\u7eed\u6267\u884c\u6b65\u9aa4 5\u3002 +message.no.network.support.configuration.not.true=\u60a8\u7684\u6240\u6709\u8d44\u6e90\u57df\u90fd\u672a\u542f\u7528\u5b89\u5168\u7ec4\uff0c\u56e0\u6b64\u65e0\u5176\u4ed6\u7f51\u7edc\u529f\u80fd\u3002\u8bf7\u7ee7\u7eed\u6267\u884c\u6b65\u9aa4 5\u3002 message.no.network.support=\u60a8\u9009\u62e9\u7684\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f vSphere \u6ca1\u6709\u4efb\u4f55\u5176\u4ed6\u7f51\u7edc\u529f\u80fd\u3002\u8bf7\u7ee7\u7eed\u6267\u884c\u6b65\u9aa4 5\u3002 message.no.projects.adminOnly=\u60a8\u6ca1\u6709\u4efb\u4f55\u9879\u76ee\u3002
\u8bf7\u8981\u6c42\u7ba1\u7406\u5458\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u3002 message.no.projects=\u60a8\u6ca1\u6709\u4efb\u4f55\u9879\u76ee\u3002
\u8bf7\u4ece\u201c\u9879\u76ee\u201d\u90e8\u5206\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u3002 @@ -1494,20 +1722,20 @@ message.number.clusters=

\u7fa4\u96c6\u6570

message.number.hosts=

\u4e3b\u673a\u6570

message.number.pods=

\u63d0\u4f9b\u70b9\u6570

message.number.storage=

\u4e3b\u5b58\u50a8\u5377\u6570

-message.number.zones=

\u533a\u57df\u6570

+message.number.zones=

\u8d44\u6e90\u57df\u6570

message.pending.projects.1=\u60a8\u6709\u5f85\u5b9a\u9879\u76ee\u9080\u8bf7\: message.pending.projects.2=\u8981\u67e5\u770b\uff0c\u8bf7\u8f6c\u81f3\u201c\u9879\u76ee\u201d\u90e8\u5206\uff0c\u7136\u540e\u4ece\u4e0b\u62c9\u5217\u8868\u4e2d\u9009\u62e9\u201c\u9080\u8bf7\u201d\u3002 -message.please.add.at.lease.one.traffic.range=\u8bf7\u81f3\u5c11\u6dfb\u52a0\u4e00\u4e2a\u901a\u4fe1\u8303\u56f4\u3002 +message.please.add.at.lease.one.traffic.range=\u8bf7\u81f3\u5c11\u6dfb\u52a0\u4e00\u4e2a\u6d41\u91cf\u8303\u56f4\u3002 message.please.proceed=\u8bf7\u7ee7\u7eed\u6267\u884c\u4e0b\u4e2a\u6b65\u9aa4\u3002 -message.please.select.a.configuration.for.your.zone=\u8bf7\u4e3a\u60a8\u7684\u533a\u57df\u9009\u62e9\u4e00\u79cd\u914d\u7f6e\u3002 -message.please.select.a.different.public.and.management.network.before.removing=\u8bf7\u5148\u9009\u62e9\u5176\u4ed6\u516c\u5171\u7ba1\u7406\u7f51\u7edc\uff0c\u7136\u540e\u518d\u5220\u9664 +message.please.select.a.configuration.for.your.zone=\u8bf7\u4e3a\u60a8\u7684\u8d44\u6e90\u57df\u9009\u62e9\u4e00\u79cd\u914d\u7f6e\u3002 +message.please.select.a.different.public.and.management.network.before.removing=\u8bf7\u5148\u9009\u62e9\u5176\u4ed6\u516c\u7528\u7ba1\u7406\u7f51\u7edc\uff0c\u7136\u540e\u518d\u5220\u9664 message.please.select.networks=\u8bf7\u4e3a\u60a8\u7684\u865a\u62df\u673a\u9009\u62e9\u7f51\u7edc\u3002 -message.please.wait.while.zone.is.being.created=\u6b63\u5728\u521b\u5efa\u533a\u57df\uff0c\u8bf7\u7a0d\u5019\uff1b\u6b64\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u624d\u80fd\u5b8c\u6210... +message.please.wait.while.zone.is.being.created=\u6b63\u5728\u521b\u5efa\u8d44\u6e90\u57df\uff0c\u8bf7\u7a0d\u5019\uff1b\u6b64\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u624d\u80fd\u5b8c\u6210... message.project.invite.sent=\u53d1\u9001\u7ed9\u7528\u6237\u7684\u9080\u8bf7\uff1b\u7528\u6237\u63a5\u53d7\u9080\u8bf7\u540e\uff0c\u5c06\u52a0\u5165\u5230\u9879\u76ee\u4e2d -message.public.traffic.in.advanced.zone=\u4e91\u4e2d\u7684 VM \u8bbf\u95ee Internet \u65f6\u5c06\u751f\u6210\u516c\u5171\u901a\u4fe1\uff0c\u4f46\u5fc5\u987b\u5206\u914d\u53ef\u516c\u5f00\u8bbf\u95ee\u7684 IP \u624d\u80fd\u5b9e\u73b0\u3002\u6700\u7ec8\u7528\u6237\u53ef\u4ee5\u4f7f\u7528 CloudStack UI \u83b7\u53d6\u8fd9\u4e9b IP\uff0c\u4ee5\u5728\u5176\u6765\u5bbe\u7f51\u7edc\u4e0e\u516c\u7528\u7f51\u7edc\u4e4b\u95f4\u6267\u884c NAT\u3002

\u8bf7\u81f3\u5c11\u4e3a Internet \u901a\u4fe1\u63d0\u4f9b\u4e00\u4e2a IP \u5730\u5740\u8303\u56f4\u3002 -message.public.traffic.in.basic.zone=\u4e91\u4e2d\u7684 VM \u8bbf\u95ee Internet \u6216\u901a\u8fc7 Internet \u5411\u5ba2\u6237\u7aef\u63d0\u4f9b\u670d\u52a1\u65f6\u5c06\u751f\u6210\u516c\u5171\u901a\u4fe1\uff0c\u4f46\u5fc5\u987b\u5206\u914d\u53ef\u516c\u5f00\u8bbf\u95ee\u7684 IP \u624d\u80fd\u5b9e\u73b0\u3002\u521b\u5efa\u5b9e\u4f8b\u65f6\uff0c\u5c06\u628a\u8fd9\u4e00\u7ec4\u516c\u7528 IP \u4e2d\u7684 IP (\u6765\u5bbe IP \u5730\u5740\u9664\u5916)\u5206\u914d\u7ed9\u6b64\u5b9e\u4f8b\u3002\u9759\u6001 1-1 NAT \u5c06\u5728\u516c\u7528 IP \u4e0e\u6765\u5bbe IP \u4e4b\u95f4\u81ea\u52a8\u8bbe\u7f6e\u3002\u6700\u7ec8\u7528\u6237\u8fd8\u53ef\u4ee5\u4f7f\u7528 CloudStack UI \u83b7\u53d6\u5176\u4ed6 IP\uff0c\u4ee5\u5728\u5176\u5b9e\u4f8b\u4e0e\u516c\u7528 IP \u4e4b\u95f4\u6267\u884c\u9759\u6001 NAT\u3002 -message.redirecting.region=\u6b63\u5728\u91cd\u5b9a\u5411\u5230\u533a\u57df... -message.remove.region=\u662f\u5426\u786e\u5b9e\u8981\u4ece\u6b64\u7ba1\u7406\u670d\u52a1\u5668\u4e2d\u5220\u9664\u6b64\u533a\u57df? +message.public.traffic.in.advanced.zone=\u4e91\u4e2d\u7684 VM \u8bbf\u95ee Internet \u65f6\u5c06\u751f\u6210\u516c\u5171\u6d41\u91cf\uff0c\u4f46\u5fc5\u987b\u5206\u914d\u53ef\u516c\u5f00\u8bbf\u95ee\u7684 IP \u624d\u80fd\u5b9e\u73b0\u3002\u6700\u7ec8\u7528\u6237\u53ef\u4ee5\u4f7f\u7528 CloudStack UI \u83b7\u53d6\u8fd9\u4e9b IP\uff0c\u4ee5\u5728\u5176\u6765\u5bbe\u7f51\u7edc\u4e0e\u516c\u7528\u7f51\u7edc\u4e4b\u95f4\u6267\u884c NAT\u3002

\u8bf7\u81f3\u5c11\u4e3a Internet \u6d41\u91cf\u63d0\u4f9b\u4e00\u4e2a IP \u5730\u5740\u8303\u56f4\u3002 +message.public.traffic.in.basic.zone=\u4e91\u4e2d\u7684 VM \u8bbf\u95ee Internet \u6216\u901a\u8fc7 Internet \u5411\u5ba2\u6237\u7aef\u63d0\u4f9b\u670d\u52a1\u65f6\u5c06\u751f\u6210\u516c\u5171\u6d41\u91cf\uff0c\u4f46\u5fc5\u987b\u5206\u914d\u53ef\u516c\u5f00\u8bbf\u95ee\u7684 IP \u624d\u80fd\u5b9e\u73b0\u3002\u521b\u5efa\u5b9e\u4f8b\u65f6\uff0c\u5c06\u628a\u8fd9\u4e00\u7ec4\u516c\u7528 IP \u4e2d\u7684 IP (\u6765\u5bbe IP \u5730\u5740\u9664\u5916)\u5206\u914d\u7ed9\u6b64\u5b9e\u4f8b\u3002\u9759\u6001 1-1 NAT \u5c06\u5728\u516c\u7528 IP \u4e0e\u6765\u5bbe IP \u4e4b\u95f4\u81ea\u52a8\u8bbe\u7f6e\u3002\u6700\u7ec8\u7528\u6237\u8fd8\u53ef\u4ee5\u4f7f\u7528 CloudStack UI \u83b7\u53d6\u5176\u4ed6 IP\uff0c\u4ee5\u5728\u5176\u5b9e\u4f8b\u4e0e\u516c\u7528 IP \u4e4b\u95f4\u6267\u884c\u9759\u6001 NAT\u3002 +message.redirecting.region=\u6b63\u5728\u91cd\u5b9a\u5411\u5230\u5730\u7406\u533a\u57df... +message.remove.region=\u662f\u5426\u786e\u5b9e\u8981\u4ece\u6b64\u7ba1\u7406\u670d\u52a1\u5668\u4e2d\u5220\u9664\u6b64\u5730\u7406\u533a\u57df? message.remove.vpc=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 VPC message.remove.vpn.access=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u4ee5\u4e0b\u7528\u6237\u7684 VPN \u8bbf\u95ee\u3002 message.reset.password.warning.notPasswordEnabled=\u521b\u5efa\u6b64\u5b9e\u4f8b\u7684\u6a21\u677f\u65f6\u672a\u542f\u7528\u5bc6\u7801 @@ -1518,14 +1746,14 @@ message.restart.mgmt.usage.server=\u8bf7\u91cd\u65b0\u542f\u52a8\u7ba1\u7406\u67 message.restart.network=\u6b64\u7f51\u7edc\u63d0\u4f9b\u7684\u6240\u6709\u670d\u52a1\u90fd\u5c06\u4e2d\u65ad\u3002\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u91cd\u65b0\u542f\u52a8\u6b64\u7f51\u7edc\u3002 message.restart.vpc=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u91cd\u65b0\u542f\u52a8 VPC message.security.group.usage=(\u6309\u4f4f Ctrl \u952e\u5e76\u5355\u51fb\u9f20\u6807\u53ef\u9009\u62e9\u6240\u6709\u9002\u7528\u7684\u5b89\u5168\u7ec4) -message.select.a.zone=\u4e00\u4e2a\u533a\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u591a\u4e2a\u533a\u57df\u53ef\u4ee5\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\uff0c\u6709\u52a9\u4e8e\u4f7f\u4e91\u66f4\u52a0\u53ef\u9760\u3002 +message.select.a.zone=\u4e00\u4e2a\u8d44\u6e90\u57df\u901a\u5e38\u4e0e\u4e00\u4e2a\u6570\u636e\u4e2d\u5fc3\u76f8\u5bf9\u5e94\u3002\u591a\u4e2a\u8d44\u6e90\u57df\u53ef\u4ee5\u63d0\u4f9b\u7269\u7406\u9694\u79bb\u548c\u5197\u4f59\uff0c\u6709\u52a9\u4e8e\u4f7f\u4e91\u66f4\u52a0\u53ef\u9760\u3002 message.select.instance=\u8bf7\u9009\u62e9\u4e00\u4e2a\u5b9e\u4f8b\u3002 message.select.iso=\u8bf7\u4e3a\u60a8\u7684\u65b0\u865a\u62df\u5b9e\u4f8b\u9009\u62e9\u4e00\u4e2a ISO\u3002 message.select.item=\u8bf7\u9009\u62e9\u4e00\u4e2a\u9879\u76ee\u3002 message.select.security.groups=\u8bf7\u4e3a\u60a8\u7684\u65b0 VM \u9009\u62e9\u5b89\u5168\u7ec4 message.select.template=\u8bf7\u4e3a\u60a8\u7684\u65b0\u865a\u62df\u5b9e\u4f8b\u9009\u62e9\u4e00\u4e2a\u6a21\u677f\u3002 -message.setup.physical.network.during.zone.creation.basic=\u6dfb\u52a0\u57fa\u7840\u533a\u57df\u65f6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e2a\u7269\u7406\u7f51\u7edc\uff0c\u6b64\u7f51\u7edc\u5e94\u4e0e\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u4e2d\u7684 NIC \u76f8\u5bf9\u5e94\u3002\u6b64\u7f51\u7edc\u53ef\u4ee5\u627f\u8f7d\u591a\u79cd\u901a\u4fe1\u7c7b\u578b\u3002

\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u5c06\u5176\u4ed6\u901a\u4fe1\u7c7b\u578b\u62d6\u653e\u5230\u6b64\u7269\u7406\u7f51\u7edc\u3002 -message.setup.physical.network.during.zone.creation=\u6dfb\u52a0\u9ad8\u7ea7\u533a\u57df\u65f6\uff0c\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a\u6216\u591a\u4e2a\u7269\u7406\u7f51\u7edc\u3002\u6bcf\u4e2a\u7f51\u7edc\u90fd\u4e0e\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u4e2d\u7684\u4e00\u4e2a NIC \u76f8\u5bf9\u5e94\u3002\u6bcf\u4e2a\u7269\u7406\u7f51\u7edc\u4e2d\u53ef\u4ee5\u5305\u542b\u4e00\u79cd\u6216\u591a\u79cd\u901a\u4fe1\u7c7b\u578b\uff0c\u5e76\u5bf9\u8fd9\u4e9b\u901a\u4fe1\u7c7b\u578b\u53ef\u80fd\u7684\u7ec4\u5408\u65b9\u5f0f\u8bbe\u7f6e\u4e86\u67d0\u4e9b\u9650\u5236\u3002

\u53ef\u4ee5\u5c06\u4e00\u79cd\u6216\u591a\u79cd\u901a\u4fe1\u7c7b\u578b\u62d6\u653e\u5230\u6bcf\u4e2a\u7269\u7406\u7f51\u7edc\u4e2d\u3002 +message.setup.physical.network.during.zone.creation.basic=\u6dfb\u52a0\u57fa\u7840\u8d44\u6e90\u57df\u65f6\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e2a\u7269\u7406\u7f51\u7edc\uff0c\u6b64\u7f51\u7edc\u5e94\u4e0e\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u4e2d\u7684 NIC \u76f8\u5bf9\u5e94\u3002\u6b64\u7f51\u7edc\u53ef\u4ee5\u627f\u8f7d\u591a\u79cd\u6d41\u91cf\u7c7b\u578b\u3002

\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u5c06\u5176\u4ed6\u6d41\u91cf\u7c7b\u578b\u62d6\u653e\u5230\u6b64\u7269\u7406\u7f51\u7edc\u3002 +message.setup.physical.network.during.zone.creation=\u6dfb\u52a0\u9ad8\u7ea7\u8d44\u6e90\u57df\u65f6\uff0c\u9700\u8981\u8bbe\u7f6e\u4e00\u4e2a\u6216\u591a\u4e2a\u7269\u7406\u7f51\u7edc\u3002\u6bcf\u4e2a\u7f51\u7edc\u90fd\u4e0e\u865a\u62df\u673a\u7ba1\u7406\u7a0b\u5e8f\u4e2d\u7684\u4e00\u4e2a NIC \u76f8\u5bf9\u5e94\u3002\u6bcf\u4e2a\u7269\u7406\u7f51\u7edc\u4e2d\u53ef\u4ee5\u5305\u542b\u4e00\u79cd\u6216\u591a\u79cd\u6d41\u91cf\u7c7b\u578b\uff0c\u5e76\u5bf9\u8fd9\u4e9b\u6d41\u91cf\u7c7b\u578b\u53ef\u80fd\u7684\u7ec4\u5408\u65b9\u5f0f\u8bbe\u7f6e\u4e86\u67d0\u4e9b\u9650\u5236\u3002

\u53ef\u4ee5\u5c06\u4e00\u79cd\u6216\u591a\u79cd\u6d41\u91cf\u7c7b\u578b\u62d6\u653e\u5230\u6bcf\u4e2a\u7269\u7406\u7f51\u7edc\u4e2d\u3002 message.setup.successful=\u5df2\u6210\u529f\u8bbe\u7f6e\u4e91\! message.snapshot.schedule=\u53ef\u4ee5\u901a\u8fc7\u4ece\u4ee5\u4e0b\u53ef\u7528\u9009\u9879\u4e2d\u8fdb\u884c\u9009\u62e9\u5e76\u5e94\u7528\u60a8\u7684\u7b56\u7565\u9996\u9009\u9879\u6765\u8bbe\u7f6e\u91cd\u73b0\u5feb\u7167\u8ba1\u5212 message.specify.url=\u8bf7\u6307\u5b9a URL @@ -1537,18 +1765,18 @@ message.step.3.continue=\u8bf7\u9009\u62e9\u4e00\u79cd\u78c1\u76d8\u65b9\u6848\u message.step.3.desc= message.step.4.continue=\u8bf7\u81f3\u5c11\u9009\u62e9\u4e00\u4e2a\u7f51\u7edc\u4ee5\u7ee7\u7eed message.step.4.desc=\u8bf7\u9009\u62e9\u865a\u62df\u5b9e\u4f8b\u8981\u8fde\u63a5\u5230\u7684\u4e3b\u7f51\u7edc\u3002 -message.storage.traffic=CloudStack \u5185\u90e8\u8d44\u6e90(\u5305\u62ec\u4e0e\u7ba1\u7406\u670d\u52a1\u5668\u901a\u4fe1\u7684\u4efb\u4f55\u7ec4\u4ef6\uff0c\u4f8b\u5982\u4e3b\u673a\u548c CloudStack \u7cfb\u7edf VM)\u4e4b\u95f4\u7684\u901a\u4fe1\u3002\u8bf7\u5728\u6b64\u5904\u914d\u7f6e\u5b58\u50a8\u901a\u4fe1\u3002 +message.storage.traffic=CloudStack \u5185\u90e8\u8d44\u6e90(\u5305\u62ec\u4e0e\u7ba1\u7406\u670d\u52a1\u5668\u901a\u4fe1\u7684\u4efb\u4f55\u7ec4\u4ef6\uff0c\u4f8b\u5982\u4e3b\u673a\u548c CloudStack \u7cfb\u7edf VM)\u4e4b\u95f4\u7684\u6d41\u91cf\u3002\u8bf7\u5728\u6b64\u5904\u914d\u7f6e\u5b58\u50a8\u6d41\u91cf\u3002 message.suspend.project=\u662f\u5426\u786e\u5b9e\u8981\u6682\u505c\u6b64\u9879\u76ee? message.template.desc=\u64cd\u4f5c\u7cfb\u7edf\u6620\u50cf\uff0c\u53ef\u7528\u4e8e\u542f\u52a8 VM -message.tooltip.dns.1=\u4f9b\u533a\u57df\u4e2d\u7684 VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\u540d\u79f0\u3002\u533a\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u6b64\u670d\u52a1\u5668\u3002 -message.tooltip.dns.2=\u4f9b\u533a\u57df\u4e2d\u7684 VM \u4f7f\u7528\u7684\u8f85\u52a9 DNS \u670d\u52a1\u5668\u540d\u79f0\u3002\u533a\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u6b64\u670d\u52a1\u5668\u3002 -message.tooltip.internal.dns.1=\u4f9b\u533a\u57df\u4e2d\u7684 CloudStack \u5185\u90e8\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\u540d\u79f0\u3002\u63d0\u4f9b\u70b9\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u6b64\u670d\u52a1\u5668\u3002 -message.tooltip.internal.dns.2=\u4f9b\u533a\u57df\u4e2d\u7684 CloudStack \u5185\u90e8\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\u540d\u79f0\u3002\u63d0\u4f9b\u70b9\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u6b64\u670d\u52a1\u5668\u3002 +message.tooltip.dns.1=\u4f9b\u8d44\u6e90\u57df\u4e2d\u7684 VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\u540d\u79f0\u3002\u8d44\u6e90\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u6b64\u670d\u52a1\u5668\u3002 +message.tooltip.dns.2=\u4f9b\u8d44\u6e90\u57df\u4e2d\u7684 VM \u4f7f\u7528\u7684\u4e8c\u7ea7 DNS \u670d\u52a1\u5668\u540d\u79f0\u3002\u8d44\u6e90\u57df\u7684\u516c\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u6b64\u670d\u52a1\u5668\u3002 +message.tooltip.internal.dns.1=\u4f9b\u8d44\u6e90\u57df\u4e2d\u7684 CloudStack \u5185\u90e8\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\u540d\u79f0\u3002\u63d0\u4f9b\u70b9\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u6b64\u670d\u52a1\u5668\u3002 +message.tooltip.internal.dns.2=\u4f9b\u8d44\u6e90\u57df\u4e2d\u7684 CloudStack \u5185\u90e8\u7cfb\u7edf VM \u4f7f\u7528\u7684 DNS \u670d\u52a1\u5668\u540d\u79f0\u3002\u63d0\u4f9b\u70b9\u7684\u4e13\u7528 IP \u5730\u5740\u5fc5\u987b\u8def\u7531\u5230\u6b64\u670d\u52a1\u5668\u3002 message.tooltip.network.domain=DNS \u540e\u7f00\uff0c\u5c06\u4e3a\u7531\u6765\u5bbe VM \u8bbf\u95ee\u7684\u7f51\u7edc\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u57df\u540d\u3002 message.tooltip.pod.name=\u6b64\u63d0\u4f9b\u70b9\u7684\u540d\u79f0\u3002 message.tooltip.reserved.system.gateway=\u63d0\u4f9b\u70b9\u4e2d\u7684\u4e3b\u673a\u7f51\u5173\u3002 message.tooltip.reserved.system.netmask=\u7528\u4e8e\u5b9a\u4e49\u63d0\u4f9b\u70b9\u5b50\u7f51\u7684\u7f51\u7edc\u524d\u7f00\u3002\u8bf7\u4f7f\u7528 CIDR \u7b26\u53f7\u3002 -message.tooltip.zone.name=\u533a\u57df\u540d\u79f0\u3002 +message.tooltip.zone.name=\u8d44\u6e90\u57df\u540d\u79f0\u3002 message.update.os.preference=\u8bf7\u4e3a\u6b64\u4e3b\u673a\u9009\u62e9\u4e00\u4e2a\u64cd\u4f5c\u7cfb\u7edf\u9996\u9009\u9879\u3002\u9996\u5148\u5c06\u5177\u6709\u76f8\u4f3c\u9996\u9009\u9879\u7684\u6240\u6709\u865a\u62df\u5b9e\u4f8b\u5206\u914d\u81f3\u6b64\u4e3b\u673a\uff0c\u7136\u540e\u518d\u9009\u62e9\u5176\u4ed6\u5b9e\u4f8b\u3002 message.update.resource.count=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u66f4\u65b0\u6b64\u5e10\u6237\u7684\u8d44\u6e90\u6570\u3002 message.update.ssl=\u8bf7\u63d0\u4ea4\u4e00\u4e2a\u65b0\u7684 X.509 \u517c\u5bb9\u7684 SSL \u8bc1\u4e66\uff0c\u4ee5\u4fbf\u5c06\u5176\u66f4\u65b0\u5230\u6bcf\u4e2a\u63a7\u5236\u53f0\u4ee3\u7406\u865a\u62df\u5b9e\u4f8b\: @@ -1558,13 +1786,97 @@ message.vm.create.template.confirm=\u521b\u5efa\u6a21\u677f\u5c06\u81ea\u52a8\u9 message.vm.review.launch=\u8bf7\u5148\u6838\u5bf9\u4ee5\u4e0b\u4fe1\u606f\uff0c\u786e\u8ba4\u60a8\u7684\u865a\u62df\u5b9e\u4f8b\u6b63\u786e\u65e0\u8bef\uff0c\u7136\u540e\u518d\u542f\u52a8\u3002 message.volume.create.template.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e3a\u6b64\u78c1\u76d8\u5377\u521b\u5efa\u4e00\u4e2a\u6a21\u677f\u3002\u521b\u5efa\u6a21\u677f\u53ef\u80fd\u9700\u8981\u51e0\u5206\u949f\u5230\u66f4\u957f\u7684\u65f6\u95f4\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u5377\u7684\u5927\u5c0f\u3002 message.you.must.have.at.least.one.physical.network=\u60a8\u5fc5\u987b\u81f3\u5c11\u62e5\u6709\u4e00\u4e2a\u7269\u7406\u7f51\u7edc -message.zone.creation.complete.would.you.like.to.enable.this.zone=\u5df2\u5b8c\u6210\u521b\u5efa\u533a\u57df\u3002\u662f\u5426\u8981\u542f\u7528\u6b64\u533a\u57df? -message.Zone.creation.complete=\u5df2\u5b8c\u6210\u521b\u5efa\u533a\u57df -message.zone.no.network.selection=\u6240\u9009\u533a\u57df\u65e0\u4efb\u4f55\u7f51\u7edc\u9009\u9879\u3002 -message.zone.step.1.desc=\u8bf7\u4e3a\u60a8\u7684\u533a\u57df\u9009\u62e9\u4e00\u79cd\u7f51\u7edc\u6a21\u5f0f\u3002 -message.zone.step.2.desc=\u8bf7\u8f93\u5165\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u533a\u57df +message.zone.creation.complete.would.you.like.to.enable.this.zone=\u5df2\u5b8c\u6210\u521b\u5efa\u8d44\u6e90\u57df\u3002\u662f\u5426\u8981\u542f\u7528\u6b64\u8d44\u6e90\u57df? +message.Zone.creation.complete=\u5df2\u5b8c\u6210\u521b\u5efa\u8d44\u6e90\u57df +message.zone.no.network.selection=\u6240\u9009\u8d44\u6e90\u57df\u65e0\u4efb\u4f55\u7f51\u7edc\u9009\u9879\u3002 +message.zone.step.1.desc=\u8bf7\u4e3a\u60a8\u7684\u8d44\u6e90\u57df\u9009\u62e9\u4e00\u79cd\u7f51\u7edc\u6a21\u5f0f\u3002 +message.zone.step.2.desc=\u8bf7\u8f93\u5165\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u8d44\u6e90\u57df message.zone.step.3.desc=\u8bf7\u8f93\u5165\u4ee5\u4e0b\u4fe1\u606f\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u65b0\u63d0\u4f9b\u70b9 -message.zoneWizard.enable.local.storage=\u8b66\u544a\: \u5982\u679c\u4e3a\u6b64\u533a\u57df\u542f\u7528\u4e86\u672c\u5730\u5b58\u50a8\uff0c\u5219\u5fc5\u987b\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u60a8\u5e0c\u671b\u542f\u52a8\u7cfb\u7edf VM \u7684\u4f4d\u7f6e\:

1. \u5982\u679c\u9700\u8981\u5728\u4e3b\u5b58\u50a8\u4e2d\u542f\u52a8\u7cfb\u7edf VM\uff0c\u5219\u5fc5\u987b\u5728\u5b8c\u6210\u521b\u5efa\u540e\u5c06\u4e3b\u5b58\u50a8\u6dfb\u52a0\u5230\u6b64\u533a\u57df\u4e2d\u3002

2. \u5982\u679c\u9700\u8981\u5728\u672c\u5730\u5b58\u50a8\u4e2d\u542f\u52a8\u7cfb\u7edf VM\uff0c\u5219\u5fc5\u987b\u5c06 system.vm.use.local.storage \u8bbe\u7f6e\u4e3a true\u3002


\u662f\u5426\u8981\u7ee7\u7eed? +message.zoneWizard.enable.local.storage=\u8b66\u544a\: \u5982\u679c\u4e3a\u6b64\u8d44\u6e90\u57df\u542f\u7528\u4e86\u672c\u5730\u5b58\u50a8\uff0c\u5219\u5fc5\u987b\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u60a8\u5e0c\u671b\u542f\u52a8\u7cfb\u7edf VM \u7684\u4f4d\u7f6e\:

1. \u5982\u679c\u9700\u8981\u5728\u4e3b\u5b58\u50a8\u4e2d\u542f\u52a8\u7cfb\u7edf VM\uff0c\u5219\u5fc5\u987b\u5728\u5b8c\u6210\u521b\u5efa\u540e\u5c06\u4e3b\u5b58\u50a8\u6dfb\u52a0\u5230\u6b64\u8d44\u6e90\u57df\u4e2d\u3002

2. \u5982\u679c\u9700\u8981\u5728\u672c\u5730\u5b58\u50a8\u4e2d\u542f\u52a8\u7cfb\u7edf VM\uff0c\u5219\u5fc5\u987b\u5c06 system.vm.use.local.storage \u8bbe\u7f6e\u4e3a true\u3002


\u662f\u5426\u8981\u7ee7\u7eed? +message.validate.fieldrequired=\u6b64\u5b57\u6bb5\u4e3a\u5fc5\u586b\u5b57\u6bb5\u3002 +message.validate.fixfield=\u8bf7\u4fee\u590d\u6b64\u5b57\u6bb5\u3002 +message.validate.email.address=\u8bf7\u8f93\u5165\u4e00\u4e2a\u6709\u6548\u7684\u7535\u5b50\u90ae\u4ef6\u5730\u5740\u3002 +message.validate.URL=\u8bf7\u8f93\u5165\u6709\u6548\u7684 URL\u3002 +message.validate.date=\u8bf7\u8f93\u5165\u6709\u6548\u7684\u65e5\u671f\u3002 +message.validate.date.ISO=\u8bf7\u8f93\u5165\u6709\u6548\u7684\u65e5\u671f(ISO)\u3002 +message.validate.number=\u8bf7\u8f93\u5165\u4e00\u4e2a\u6709\u6548\u6570\u5b57\u3002 +message.validate.digits=\u8bf7\u4ec5\u8f93\u5165\u6570\u5b57\u3002 +message.validate.creditcard=\u8bf7\u8f93\u5165\u4e00\u4e2a\u6709\u6548\u7684\u4fe1\u7528\u5361\u5361\u53f7\u3002 +message.validate.equalto=\u8bf7\u91cd\u65b0\u8f93\u5165\u76f8\u540c\u7684\u503c\u3002 +message.validate.accept=\u8bf7\u8f93\u5165\u4e00\u4e2a\u5e26\u6709\u6709\u6548\u6269\u5c55\u540d\u7684\u503c\u3002 +message.validate.maxlength=\u8bf7\u6700\u591a\u8f93\u5165 {0} \u4e2a\u5b57\u7b26\u3002 +message.validate.minlength=\u8bf7\u81f3\u5c11\u8f93\u5165 {0} \u4e2a\u5b57\u7b26\u3002 +message.validate.range.length=\u8bf7\u8f93\u5165\u4e00\u4e2a\u957f\u5ea6\u4ecb\u4e8e {0} \u5230 {1} \u4e4b\u95f4\u7684\u503c\u3002 +message.validate.range=\u8bf7\u8f93\u5165\u4e00\u4e2a\u4ecb\u4e8e {0} \u5230 {1} \u4e4b\u95f4\u7684\u503c\u3002 +message.validate.max=\u8bf7\u8f93\u5165\u4e00\u4e2a\u5c0f\u4e8e\u6216\u7b49\u4e8e {0} \u7684\u503c\u3002 +messgae.validate.min=\u8bf7\u8f93\u5165\u4e00\u4e2a\u5927\u4e8e\u6216\u7b49\u4e8e {0} \u7684\u503c\u3002 +message.creating.systemVM=\u6b63\u5728\u521b\u5efa\u7cfb\u7edf VM (\u6b64\u64cd\u4f5c\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u65f6\u95f4) +message.enabling.zone.dots=\u6b63\u5728\u542f\u7528\u8d44\u6e90\u57df... +message.restoreVM=\u662f\u5426\u8981\u8fd8\u539f\u6b64 VM? +message.no.host.available=\u6ca1\u6709\u53ef\u7528\u4e8e\u8fc1\u79fb\u7684\u4e3b\u673a +message.network.addVM.desc=\u8bf7\u6307\u5b9a\u8981\u5c06\u6b64 VM \u6dfb\u52a0\u5230\u7684\u7f51\u7edc\u3002\u5c06\u4e3a\u6b64\u7f51\u7edc\u6dfb\u52a0\u4e00\u4e2a\u65b0 NIC\u3002 +message.network.addVMNIC=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4e3a\u6b64\u7f51\u7edc\u6dfb\u52a0\u4e00\u4e2a\u65b0 VM NIC\u3002 +message.set.default.NIC=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5c06\u6b64 NIC \u8bbe\u7f6e\u4e3a\u6b64 VM \u7684\u9ed8\u8ba4 NIC\u3002 +message.set.default.NIC.manual=\u8bf7\u7acb\u5373\u624b\u52a8\u66f4\u65b0\u6b64 VM \u4e0a\u7684\u9ed8\u8ba4 NIC\u3002 +message.instance.scaled.up.confirm=\u662f\u5426\u786e\u5b9e\u8981\u6269\u5c55\u60a8\u7684\u5b9e\u4f8b? +message.copy.template.confirm=\u662f\u5426\u786e\u5b9e\u8981\u590d\u5236\u6a21\u677f? +message.template.copying=\u6b63\u5728\u590d\u5236\u6a21\u677f\u3002 +message.XSTools61plus.update.failed=\u65e0\u6cd5\u66f4\u65b0\u201cXenServer Tools \u7248\u672c 6.1\+\u201d\u5b57\u6bb5\u3002\u9519\u8bef\: +message.gslb.delete.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u6b64 GSLB +message.portable.ip.delete.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u53ef\u79fb\u690d IP \u8303\u56f4 +message.gslb.lb.remove.confirm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u4ece GSLB \u4e2d\u5220\u9664\u8d1f\u8f7d\u5e73\u8861 +message.admin.guide.read=\u5bf9\u4e8e\u57fa\u4e8e VMware \u7684 VM\uff0c\u8bf7\u5148\u9605\u8bfb\u7ba1\u7406\u6307\u5357\u4e2d\u7684\u52a8\u6001\u6269\u5c55\u90e8\u5206\uff0c\u7136\u540e\u518d\u8fdb\u884c\u6269\u5c55\u3002\u662f\u5426\u8981\u7ee7\u7eed?\, +message.tier.required=\u201c\u5c42\u201d\u4e3a\u5fc5\u586b\u9879 +message.remove.ldap=\u662f\u5426\u786e\u5b9e\u8981\u5220\u9664 LDAP \u914d\u7f6e? +message.action.downloading.template=\u6b63\u5728\u4e0b\u8f7d\u6a21\u677f\u3002 +message.configure.ldap=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u914d\u7f6e LDAP\u3002 +message.confirm.delete.ciscovnmc.resource=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 CiscoVNMC \u8d44\u6e90 +message.confirm.add.vnmc.provider=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u6dfb\u52a0 VNMC \u63d0\u4f9b\u7a0b\u5e8f\u3002 +message.confirm.enable.vnmc.provider=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u7528 VNMC \u63d0\u4f9b\u7a0b\u5e8f\u3002 +message.confirm.disable.vnmc.provider=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u7981\u7528 VNMC \u63d0\u4f9b\u7a0b\u5e8f\u3002 +message.vnmc.available.list=\u63d0\u4f9b\u7a0b\u5e8f\u5217\u8868\u4e2d\u672a\u63d0\u4f9b VNMC\u3002 +message.vnmc.not.available.list=\u63d0\u4f9b\u7a0b\u5e8f\u5217\u8868\u4e2d\u672a\u63d0\u4f9b VNMC\u3002 +message.confirm.release.dedicate.vlan.range=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u91ca\u653e\u4e13\u7528 VLAN \u8303\u56f4 +message.confirm.start.lb.vm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u542f\u52a8 LB VM +message.confirm.stop.lb.vm=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u505c\u6b62 LB VM +message.confirm.remove.vmware.datacenter=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 VMware \u6570\u636e\u4e2d\u5fc3 +message.confirm.dedicate.zone=\u662f\u5426\u8981\u5c06\u6b64\u8d44\u6e90\u57df\u4e13\u7528\u4e8e\u57df/\u5e10\u6237? +message.confirm.release.dedicated.zone=\u662f\u5426\u8981\u91ca\u653e\u6b64\u4e13\u7528\u8d44\u6e90\u57df? +message.dedicated.zone.released=\u5df2\u91ca\u653e\u4e13\u7528\u8d44\u6e90\u57df +message.read.admin.guide.scaling.up=\u5f00\u59cb\u6269\u5c55\u4e4b\u524d\uff0c\u8bf7\u9605\u8bfb\u7ba1\u7406\u6307\u5357\u4e2d\u7684\u52a8\u6001\u6269\u5c55\u90e8\u5206\u3002 +message.confirm.scale.up.system.vm=\u662f\u5426\u786e\u5b9e\u8981\u6269\u5c55\u7cfb\u7edf VM? +message.confirm.upgrade.router.newer.template=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5347\u7ea7\u8def\u7531\u5668\u4ee5\u4f7f\u7528\u66f4\u65b0\u7684\u6a21\u677f +message.confirm.scale.up.router.vm=\u662f\u5426\u786e\u5b9e\u8981\u6269\u5c55\u8def\u7531\u5668 VM? +message.confirm.upgrade.routers.newtemplate=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5347\u7ea7\u6b64\u8d44\u6e90\u57df\u4e2d\u7684\u6240\u6709\u8def\u7531\u5668\u4ee5\u4f7f\u7528\u66f4\u65b0\u7684\u6a21\u677f +message.confirm.upgrade.routers.pod.newtemplate=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5347\u7ea7\u6b64\u63d0\u4f9b\u70b9\u4e2d\u7684\u6240\u6709\u8def\u7531\u5668\u4ee5\u4f7f\u7528\u66f4\u65b0\u7684\u6a21\u677f +message.confirm.upgrade.routers.cluster.newtemplate=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5347\u7ea7\u6b64\u7fa4\u96c6\u4e2d\u7684\u6240\u6709\u8def\u7531\u5668\u4ee5\u4f7f\u7528\u66f4\u65b0\u7684\u6a21\u677f +message.confirm.upgrade.routers.account.newtemplate=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5347\u7ea7\u6b64\u5e10\u6237\u4e2d\u7684\u6240\u6709\u8def\u7531\u5668\u4ee5\u4f7f\u7528\u66f4\u65b0\u7684\u6a21\u677f +message.confirm.dedicate.pod.domain.account=\u662f\u5426\u786e\u5b9e\u8981\u5c06\u6b64\u63d0\u4f9b\u70b9\u4e13\u7528\u4e8e\u57df/\u5e10\u6237? +message.confirm.release.dedicated.pod=\u662f\u5426\u8981\u91ca\u653e\u6b64\u4e13\u7528\u63d0\u4f9b\u70b9? +message.pod.dedication.released=\u5df2\u91ca\u653e\u4e13\u7528\u63d0\u4f9b\u70b9 +message.confirm.dedicate.cluster.domain.account=\u662f\u5426\u786e\u5b9e\u8981\u5c06\u6b64\u7fa4\u96c6\u4e13\u7528\u4e8e\u57df/\u5e10\u6237? +message.cluster.dedicated=\u7fa4\u96c6\u5df2\u4e13\u7528 +message.confirm.release.dedicated.cluster=\u662f\u5426\u8981\u91ca\u653e\u6b64\u4e13\u7528\u7fa4\u96c6? +message.cluster.dedication.released=\u5df2\u91ca\u653e\u4e13\u7528\u7fa4\u96c6 +message.confirm.dedicate.host.domain.account=\u662f\u5426\u786e\u5b9e\u8981\u5c06\u6b64\u4e3b\u673a\u4e13\u7528\u4e8e\u57df/\u5e10\u6237? +message.host.dedicated=\u4e3b\u673a\u5df2\u4e13\u7528 +message.confirm.release.dedicated.host=\u662f\u5426\u8981\u91ca\u653e\u6b64\u4e13\u7528\u4e3b\u673a? +message.host.dedication.released=\u5df2\u91ca\u653e\u4e13\u7528\u4e3b\u673a +message.confirm.delete.ucs.manager=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664 UCS Manager +message.confirm.refresh.blades=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5237\u65b0\u5200\u7247\u5f0f\u670d\u52a1\u5668\u3002 +message.confirm.delete.secondary.staging.store=\u8bf7\u786e\u8ba4\u60a8\u786e\u5b9e\u8981\u5220\u9664\u4e8c\u7ea7\u6682\u5b58\u5b58\u50a8\u3002 +message.select.tier=\u8bf7\u9009\u62e9\u4e00\u4e2a\u5c42 +message.disallowed.characters=\u7981\u7528\u5b57\u7b26: \<\,\> +message.waiting.for.builtin.templates.to.load=\u6b63\u5728\u7b49\u5f85\u52a0\u8f7d\u5185\u7f6e\u6a21\u677f... +message.systems.vms.ready=\u7cfb\u7edf VM \u5df2\u5c31\u7eea\u3002 +message.your.cloudstack.is.ready=\u60a8\u7684 CloudStack \u5df2\u5c31\u7eea\! +message.specifiy.tag.key.value=\u8bf7\u6307\u5b9a\u6807\u8bb0\u5bc6\u94a5\u548c\u503c +message.enter.seperated.list.multiple.cidrs=\u5982\u679c\u5b58\u5728\u591a\u4e2a CIDR\uff0c\u8bf7\u8f93\u5165\u7528\u9017\u53f7\u5206\u9694\u7684 CIDR \u5217\u8868 +message.disabling.network.offering=\u6b63\u5728\u7981\u7528\u7f51\u7edc\u65b9\u6848 +message.confirm.enable.network.offering=\u662f\u5426\u786e\u5b9e\u8981\u542f\u7528\u6b64\u7f51\u7edc\u65b9\u6848? +message.enabling.network.offering=\u6b63\u5728\u542f\u7528\u7f51\u7edc\u65b9\u6848 +message.confirm.remove.network.offering=\u662f\u5426\u786e\u5b9e\u8981\u5220\u9664\u6b64\u7f51\u7edc\u65b9\u6848? +message.confirm.disable.network.offering=\u662f\u5426\u786e\u5b9e\u8981\u7981\u7528\u6b64\u7f51\u7edc\u65b9\u6848? mode=\u6a21\u5f0f network.rate=\u7f51\u7edc\u901f\u7387 notification.reboot.instance=\u91cd\u65b0\u542f\u52a8\u5b9e\u4f8b diff --git a/client/pom.xml b/client/pom.xml index 5215e0cd90e..d8dbde72a8d 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -17,7 +17,7 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT @@ -35,6 +35,11 @@ cloud-plugin-storage-volume-solidfire ${project.version} + + org.apache.cloudstack + cloud-plugin-storage-volume-cloudbyte + ${project.version} + org.apache.cloudstack cloud-server @@ -97,6 +102,11 @@ org.apache.cloudstack + cloud-plugin-network-netscaler + ${project.version} + + + org.apache.cloudstack cloud-plugin-network-ovs ${project.version} @@ -182,7 +192,7 @@ ${project.version}
- org.apache.cloudstack + org.apache.cloudstack cloud-plugin-planner-skip-heurestics ${project.version} @@ -215,12 +225,17 @@ org.apache.cloudstack cloud-mom-inmemory ${project.version} - + - mysql - mysql-connector-java - runtime - + org.apache.cloudstack + cloud-plugin-iam + ${project.version} + + + org.apache.cloudstack + cloud-iam + ${project.version} + org.apache.cloudstack cloud-framework-ipc @@ -266,6 +281,11 @@ cloud-engine-storage-cache ${project.version} + + org.apache.cloudstack + cloud-controller-secondary-storage + ${project.version} + org.apache.cloudstack cloud-engine-storage-image @@ -360,6 +380,14 @@ org.mortbay.jetty maven-jetty-plugin 6.1.26 + + + + mysql + mysql-connector-java + ${cs.mysql.version} + + 0 9966 @@ -561,6 +589,17 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + + cloudstack-checkstyle + none + false + + + @@ -654,21 +693,6 @@
- - netscaler - - - noredist - - - - - org.apache.cloudstack - cloud-plugin-network-netscaler - ${project.version} - - - srx @@ -709,6 +733,21 @@ + + mysqlha + + + noredist + + + + + org.apache.cloudstack + cloud-plugin-database-mysqlha + ${project.version} + + + quickcloud diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in new file mode 100644 index 00000000000..da242b34746 --- /dev/null +++ b/client/tomcatconf/applicationContext.xml.in @@ -0,0 +1,951 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.cloudstack.framework + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/tomcatconf/catalina.properties.in b/client/tomcatconf/catalina.properties.in index dc2db354920..ce03ff6390b 100644 --- a/client/tomcatconf/catalina.properties.in +++ b/client/tomcatconf/catalina.properties.in @@ -44,7 +44,7 @@ package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache # "foo/*.jar": Add all the JARs of the specified folder as class # repositories # "foo/bar.jar": Add bar.jar as a class repository -common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar +common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,/usr/share/java/mysql-connector-java.jar # # List of comma-separated paths defining the contents of the "server" diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 4f38c317bdd..45debe41a98 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -110,6 +110,15 @@ extractIso=15 #### guest OS commands listOsTypes=15 listOsCategories=15 +addGuestOs=1 +updateGuestOs=1 +removeGuestOs=1 + +#### guest OS mapping commands +listGuestOsMapping=1 +addGuestOsMapping=1 +updateGuestOsMapping=1 +removeGuestOsMapping=1 #### service offering commands createServiceOffering=1 @@ -137,6 +146,7 @@ listDedicatedGuestVlanRanges=1 associateIpAddress=15 disassociateIpAddress=15 listPublicIpAddresses=15 +updatePublicIpAddress=15 #### firewall commands listPortForwardingRules=15 @@ -349,6 +359,8 @@ listHypervisors=15 createRemoteAccessVpn=15 deleteRemoteAccessVpn=15 listRemoteAccessVpns=15 +updateRemoteAccessVpn=15 + addVpnUser=15 removeVpnUser=15 @@ -401,11 +413,13 @@ deleteProjectInvitation=15 createFirewallRule=15 deleteFirewallRule=15 listFirewallRules=15 +updateFirewallRule=15 #### createEgressFirewallRule=15 deleteEgressFirewallRule=15 listEgressFirewallRules=15 +updateEgressFirewallRule=15 #### hypervisor capabilities commands updateHypervisorCapabilities=1 @@ -469,6 +483,7 @@ createNetworkACLList=15 deleteNetworkACLList=15 replaceNetworkACLList=15 listNetworkACLLists=15 +updateNetworkACLList=15 #### Static route commands @@ -498,6 +513,8 @@ resetVpnConnection=15 listVpnCustomerGateways=15 listVpnGateways=15 listVpnConnections=15 +updateVpnConnection=15 +updateVpnGateway=15 #### router commands createVirtualRouterElement=7 @@ -593,6 +610,11 @@ addBigSwitchVnsDevice=1 deleteBigSwitchVnsDevice=1 listBigSwitchVnsDevices=1 +#### stratosphere ssp commands + +addStratosphereSsp=1 +deleteStratoshereSsp=1 + #### host simulator commands configureSimulator=1 @@ -646,6 +668,7 @@ removedeleteUcsManager=1 createLoadBalancer=15 listLoadBalancers=15 deleteLoadBalancer=15 +updateLoadBalancer=15 #Internal Load Balancer Element commands configureInternalLoadBalancerElement=7 @@ -705,6 +728,22 @@ listLdapUsers=3 ldapCreateAccount=3 importLdapUsers=3 +### IAM commands +createIAMPolicy=1 +deleteIAMPolicy=1 +listIAMPolicies=1 +addIAMPermissionToIAMPolicy=1 +removeIAMPermissionFromIAMPolicy=1 +createIAMGroup=1 +deleteIAMGroup=1 +listIAMGroups=1 +addAccountToIAMGroup=1 +removeAccountFromIAMGroup=1 +attachIAMPolicyToIAMGroup=1 +removeIAMPolicyFromIAMGroup=1 +attachIAMPolicyToAccount=1 +removeIAMPolicyFromAccount=1 + #### juniper-contrail commands createServiceInstance=1 diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in new file mode 100644 index 00000000000..28b8d923be5 --- /dev/null +++ b/client/tomcatconf/componentContext.xml.in @@ -0,0 +1,317 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in new file mode 100644 index 00000000000..187b63d59a5 --- /dev/null +++ b/client/tomcatconf/nonossComponentContext.xml.in @@ -0,0 +1,422 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/client/tomcatconf/simulatorComponentContext.xml.in b/client/tomcatconf/simulatorComponentContext.xml.in new file mode 100644 index 00000000000..ef480b018d3 --- /dev/null +++ b/client/tomcatconf/simulatorComponentContext.xml.in @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.apache.cloudstack.framework + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/findbugsExcludeFilter.xml b/core/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/core/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/core/pom.xml b/core/pom.xml index 975e9f64072..ec681a8d5b8 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT diff --git a/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml b/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml index b0ed228c0da..f40684157e9 100644 --- a/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml +++ b/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml @@ -44,6 +44,11 @@ + + + + + diff --git a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml index 5e799c06483..0f58d7d35e0 100644 --- a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml +++ b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml @@ -46,7 +46,7 @@ + value="RoleBasedEntityAccessChecker,AffinityGroupAccessChecker,DomainChecker" /> - + @@ -249,6 +249,11 @@ class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry"> + + + + diff --git a/core/src/com/cloud/agent/api/CheckRouterCommand.java b/core/src/com/cloud/agent/api/CheckRouterCommand.java index 6215fc3722b..c89cdf7b23f 100644 --- a/core/src/com/cloud/agent/api/CheckRouterCommand.java +++ b/core/src/com/cloud/agent/api/CheckRouterCommand.java @@ -27,4 +27,9 @@ public class CheckRouterCommand extends NetworkElementCommand { public CheckRouterCommand() { super(); } + + @Override + public boolean isQuery() { + return true; + } } diff --git a/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java b/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java index 9cfb53b0828..bbd7c5f5284 100644 --- a/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java +++ b/core/src/com/cloud/agent/api/CheckS2SVpnConnectionsCommand.java @@ -16,10 +16,10 @@ // under the License. package com.cloud.agent.api; -import java.util.List; - import com.cloud.agent.api.routing.NetworkElementCommand; +import java.util.List; + public class CheckS2SVpnConnectionsCommand extends NetworkElementCommand { List vpnIps; @@ -36,4 +36,9 @@ public class CheckS2SVpnConnectionsCommand extends NetworkElementCommand { public List getVpnIps() { return vpnIps; } + + @Override + public boolean isQuery() { + return true; + } } diff --git a/core/src/com/cloud/agent/api/ClusterSyncAnswer.java b/core/src/com/cloud/agent/api/ClusterSyncAnswer.java index 90ce02da6b7..7b8a525b69e 100644 --- a/core/src/com/cloud/agent/api/ClusterSyncAnswer.java +++ b/core/src/com/cloud/agent/api/ClusterSyncAnswer.java @@ -18,18 +18,18 @@ package com.cloud.agent.api; import java.util.HashMap; -import com.cloud.utils.Ternary; +import com.cloud.utils.Pair; import com.cloud.vm.VirtualMachine.State; public class ClusterSyncAnswer extends Answer { private long _clusterId; - private HashMap> _newStates; + private HashMap> _newStates; private boolean _isExecuted = false; // this is here because a cron command answer is being sent twice // AgentAttache.processAnswers // AgentManagerImpl.notifyAnswersToMonitors - public boolean isExceuted() { + public boolean isExecuted() { return _isExecuted; } @@ -37,7 +37,7 @@ public class ClusterSyncAnswer extends Answer { _isExecuted = true; } - public ClusterSyncAnswer(long clusterId, HashMap> newStates) { + public ClusterSyncAnswer(long clusterId, HashMap> newStates) { _clusterId = clusterId; _newStates = newStates; result = true; @@ -47,7 +47,7 @@ public class ClusterSyncAnswer extends Answer { return _clusterId; } - public HashMap> getNewStates() { + public HashMap> getNewStates() { return _newStates; } diff --git a/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncAnswer.java b/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncAnswer.java new file mode 100644 index 00000000000..04fd967285f --- /dev/null +++ b/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncAnswer.java @@ -0,0 +1,52 @@ +// 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 java.util.HashMap; + +public class ClusterVMMetaDataSyncAnswer extends Answer { + private long _clusterId; + private HashMap _vmMetaDatum; + private boolean _isExecuted=false; + + // this is here because a cron command answer is being sent twice + // AgentAttache.processAnswers + // AgentManagerImpl.notifyAnswersToMonitors + public boolean isExecuted(){ + return _isExecuted; + } + + public void setExecuted(){ + _isExecuted = true; + } + + + public ClusterVMMetaDataSyncAnswer(long clusterId, HashMap vmMetaDatum){ + _clusterId = clusterId; + _vmMetaDatum = vmMetaDatum; + result = true; + } + + public long getClusterId() { + return _clusterId; + } + + public HashMap getVMMetaDatum() { + return _vmMetaDatum; + } + +} diff --git a/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncCommand.java b/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncCommand.java new file mode 100644 index 00000000000..0f6ca50e036 --- /dev/null +++ b/core/src/com/cloud/agent/api/ClusterVMMetaDataSyncCommand.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.agent.api; + + +public class ClusterVMMetaDataSyncCommand extends Command implements CronCommand { + int _interval; + + long _clusterId; + + public ClusterVMMetaDataSyncCommand() { + } + + public ClusterVMMetaDataSyncCommand(int interval, long clusterId){ + _interval = interval; + _clusterId = clusterId; + } + + @Override + public int getInterval() { + return _interval; + } + + public long getClusterId() { + return _clusterId; + } + + @Override + public boolean executeInSequence() { + return false; + } + +} diff --git a/core/src/com/cloud/agent/api/GetDomRVersionCmd.java b/core/src/com/cloud/agent/api/GetDomRVersionCmd.java index 577c386b873..7a73fac3e7d 100644 --- a/core/src/com/cloud/agent/api/GetDomRVersionCmd.java +++ b/core/src/com/cloud/agent/api/GetDomRVersionCmd.java @@ -27,4 +27,9 @@ public class GetDomRVersionCmd extends NetworkElementCommand { public GetDomRVersionCmd() { super(); } + + @Override + public boolean isQuery() { + return true; + } } diff --git a/core/src/com/cloud/agent/api/GetGPUStatsAnswer.java b/core/src/com/cloud/agent/api/GetGPUStatsAnswer.java new file mode 100644 index 00000000000..566eed5ab63 --- /dev/null +++ b/core/src/com/cloud/agent/api/GetGPUStatsAnswer.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.agent.api; + +import java.util.HashMap; + +import com.cloud.agent.api.LogLevel.Log4jLevel; + +@LogLevel(Log4jLevel.Trace) +public class GetGPUStatsAnswer extends Answer { + + private HashMap> groupDetails; + + public GetGPUStatsAnswer(GetGPUStatsCommand cmd, HashMap> groupDetails) { + super(cmd); + this.groupDetails = groupDetails; + } + + public HashMap> getGroupDetails() { + return this.groupDetails; + } +} diff --git a/core/src/com/cloud/agent/api/GetGPUStatsCommand.java b/core/src/com/cloud/agent/api/GetGPUStatsCommand.java new file mode 100644 index 00000000000..047f56283e0 --- /dev/null +++ b/core/src/com/cloud/agent/api/GetGPUStatsCommand.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.agent.api; + +import com.cloud.agent.api.LogLevel.Log4jLevel; + +@LogLevel(Log4jLevel.Trace) +public class GetGPUStatsCommand extends Command +{ + String hostGuid; + String hostName; + + protected GetGPUStatsCommand() { + } + + public GetGPUStatsCommand(String hostGuid, String hostName) { + this.hostGuid = hostGuid; + this.hostName = hostName; + } + + public String getHostGuid(){ + return this.hostGuid; + } + + public String getHostName(){ + return this.hostName; + } + + @Override + public boolean executeInSequence() { + return false; + } +} diff --git a/core/src/com/cloud/agent/api/GetRouterAlertsAnswer.java b/core/src/com/cloud/agent/api/GetRouterAlertsAnswer.java new file mode 100644 index 00000000000..06a7a7a84eb --- /dev/null +++ b/core/src/com/cloud/agent/api/GetRouterAlertsAnswer.java @@ -0,0 +1,62 @@ +// 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.routing.GetRouterAlertsCommand; + +public class GetRouterAlertsAnswer extends Answer { + + String routerName; + String[] alerts; + String timeStamp; + + protected GetRouterAlertsAnswer() { + } + + public GetRouterAlertsAnswer(GetRouterAlertsCommand cmd, String alerts[], String timeStamp) { + super(cmd, true, null); + this.alerts = alerts; + this.timeStamp = timeStamp; + } + + + public GetRouterAlertsAnswer(GetRouterAlertsCommand cmd, Exception ex) { + super(cmd, ex); + } + + public void setAlerts(String[] alerts) { + this.alerts = alerts; + } + + public String[] getAlerts() { + return alerts; + } + + public void setTimeStamp(String timeStamp) { + this.timeStamp = timeStamp; + } + + public String getTimeStamp() { + return timeStamp; + } + + public String getRouterName() { + return routerName; + } +} diff --git a/core/src/com/cloud/agent/api/MigrateWithStorageCommand.java b/core/src/com/cloud/agent/api/MigrateWithStorageCommand.java index a94697a279d..43ae8543139 100644 --- a/core/src/com/cloud/agent/api/MigrateWithStorageCommand.java +++ b/core/src/com/cloud/agent/api/MigrateWithStorageCommand.java @@ -16,26 +16,38 @@ // under the License. package com.cloud.agent.api; +import java.util.List; import java.util.Map; import com.cloud.agent.api.to.StorageFilerTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.api.to.VolumeTO; +import com.cloud.utils.Pair; public class MigrateWithStorageCommand extends Command { VirtualMachineTO vm; Map volumeToFiler; + List> volumeToFilerAsList; String tgtHost; public MigrateWithStorageCommand(VirtualMachineTO vm, Map volumeToFiler) { this.vm = vm; this.volumeToFiler = volumeToFiler; + this.volumeToFilerAsList = null; this.tgtHost = null; } public MigrateWithStorageCommand(VirtualMachineTO vm, Map volumeToFiler, String tgtHost) { this.vm = vm; this.volumeToFiler = volumeToFiler; + this.volumeToFilerAsList = null; + this.tgtHost = tgtHost; + } + + public MigrateWithStorageCommand(VirtualMachineTO vm, List> volumeToFilerAsList, String tgtHost) { + this.vm = vm; + this.volumeToFiler = null; + this.volumeToFilerAsList = volumeToFilerAsList; this.tgtHost = tgtHost; } @@ -47,6 +59,10 @@ public class MigrateWithStorageCommand extends Command { return volumeToFiler; } + public List> getVolumeToFilerAsList() { + return volumeToFilerAsList; + } + public String getTargetHost() { return tgtHost; } diff --git a/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java b/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java index 0230beca732..5f4f0e1d9ac 100644 --- a/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java +++ b/core/src/com/cloud/agent/api/ModifyVmNicConfigCommand.java @@ -21,6 +21,7 @@ public class ModifyVmNicConfigCommand extends Command { String vmName; int vlan; String macAddress; + int index; protected ModifyVmNicConfigCommand() { } @@ -30,6 +31,12 @@ public class ModifyVmNicConfigCommand extends Command { this.macAddress = macAddress; } + public ModifyVmNicConfigCommand(String vmName, int vlan, int position) { + this.vmName = vmName; + this.vlan = vlan; + this.index = position; + } + public String getVmName() { return vmName; } diff --git a/core/src/com/cloud/agent/api/StartupRoutingCommand.java b/core/src/com/cloud/agent/api/StartupRoutingCommand.java index 626c87f2a96..dc371133861 100755 --- a/core/src/com/cloud/agent/api/StartupRoutingCommand.java +++ b/core/src/com/cloud/agent/api/StartupRoutingCommand.java @@ -22,7 +22,7 @@ import java.util.Map; import com.cloud.host.Host; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.Networks.RouterPrivateIpStrategy; -import com.cloud.utils.Ternary; +import com.cloud.utils.Pair; import com.cloud.vm.VirtualMachine.State; public class StartupRoutingCommand extends StartupCommand { @@ -63,13 +63,14 @@ public class StartupRoutingCommand extends StartupCommand { // TODO vmsync // deprecated, will delete after full replacement Map vms; - HashMap> _clusterVMStates; + HashMap> _clusterVMStates; String caps; String pool; HypervisorType hypervisorType; Map hostDetails; //stuff like host os, cpu capabilities String hypervisorVersion; + HashMap> groupDetails = new HashMap>(); public StartupRoutingCommand() { super(Host.Type.Routing); @@ -137,7 +138,7 @@ public class StartupRoutingCommand extends StartupCommand { } } - public void setClusterVMStateChanges(HashMap> allStates) { + public void setClusterVMStateChanges(HashMap> allStates) { _clusterVMStates = allStates; } @@ -169,7 +170,7 @@ public class StartupRoutingCommand extends StartupCommand { return vms; } - public HashMap> getClusterVMStateChanges() { + public HashMap> getClusterVMStateChanges() { return _clusterVMStates; } @@ -244,4 +245,12 @@ public class StartupRoutingCommand extends StartupCommand { public void setHostVmStateReport(Map hostVmStateReport) { this._hostVmStateReport = hostVmStateReport; } + + public HashMap> getGpuGroupDetails() { + return groupDetails; + } + + public void setGpuGroupDetails(HashMap> groupDetails) { + this.groupDetails = groupDetails; + } } diff --git a/core/src/com/cloud/agent/api/StopCommand.java b/core/src/com/cloud/agent/api/StopCommand.java index 6a29aa69ba9..00d7f5fff6c 100755 --- a/core/src/com/cloud/agent/api/StopCommand.java +++ b/core/src/com/cloud/agent/api/StopCommand.java @@ -16,6 +16,7 @@ // under the License. package com.cloud.agent.api; +import com.cloud.agent.api.to.GPUDeviceTO; import com.cloud.vm.VirtualMachine; public class StopCommand extends RebootCommand { @@ -23,6 +24,7 @@ public class StopCommand extends RebootCommand { private String urlPort = null; private String publicConsoleProxyIpAddress = null; boolean executeInSequence = false; + private GPUDeviceTO gpuDevice; protected StopCommand() { } @@ -62,4 +64,11 @@ public class StopCommand extends RebootCommand { return this.publicConsoleProxyIpAddress; } + public GPUDeviceTO getGpuDevice() { + return this.gpuDevice; + } + + public void setGpuDevice(GPUDeviceTO gpuDevice) { + this.gpuDevice = gpuDevice; + } } diff --git a/core/src/com/cloud/agent/api/routing/AggregationControlCommand.java b/core/src/com/cloud/agent/api/routing/AggregationControlCommand.java new file mode 100644 index 00000000000..ef75360a70f --- /dev/null +++ b/core/src/com/cloud/agent/api/routing/AggregationControlCommand.java @@ -0,0 +1,44 @@ +// 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.routing; + +public class AggregationControlCommand extends NetworkElementCommand{ + public enum Action { + Start, + Finish, + Cleanup, + } + + private Action action; + + protected AggregationControlCommand() { + super(); + } + + public AggregationControlCommand(Action action, String name, String ip, String guestIp) { + super(); + this.action = action; + this.setAccessDetail(NetworkElementCommand.ROUTER_NAME, name); + this.setAccessDetail(NetworkElementCommand.ROUTER_IP, ip); + this.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, guestIp); + } + + public Action getAction() { + return action; + } +} diff --git a/core/src/com/cloud/agent/api/PoolEjectCommand.java b/core/src/com/cloud/agent/api/routing/GetRouterAlertsCommand.java similarity index 67% rename from core/src/com/cloud/agent/api/PoolEjectCommand.java rename to core/src/com/cloud/agent/api/routing/GetRouterAlertsCommand.java index fa6b6517971..a6769efa4ae 100644 --- a/core/src/com/cloud/agent/api/PoolEjectCommand.java +++ b/core/src/com/cloud/agent/api/routing/GetRouterAlertsCommand.java @@ -14,31 +14,33 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. -package com.cloud.agent.api; -public class PoolEjectCommand extends Command { - private String hostuuid; +package com.cloud.agent.api.routing; - public String getHostuuid() { - return hostuuid; - } - public void setHostuuid(String hostuuid) { - this.hostuuid = hostuuid; - } +public class GetRouterAlertsCommand extends NetworkElementCommand { - public PoolEjectCommand() { - super(); - } + private String previousAlertTimeStamp; + + protected GetRouterAlertsCommand() { - public PoolEjectCommand(String hostuuid) { - super(); - setHostuuid(hostuuid); } @Override public boolean executeInSequence() { - return true; + return false; } + public GetRouterAlertsCommand(String timeStamp) { + this.previousAlertTimeStamp = timeStamp; + } + + public String getPreviousAlertTimeStamp() { + return previousAlertTimeStamp; + } + + @Override + public boolean isQuery() { + return true; + } } diff --git a/core/src/com/cloud/agent/api/routing/GroupAnswer.java b/core/src/com/cloud/agent/api/routing/GroupAnswer.java new file mode 100644 index 00000000000..293934bce3a --- /dev/null +++ b/core/src/com/cloud/agent/api/routing/GroupAnswer.java @@ -0,0 +1,40 @@ +// 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.routing; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.Command; + +public class GroupAnswer extends Answer { + String[] results; + + protected GroupAnswer() { + super(); + } + + public GroupAnswer(Command cmd, boolean success, int rulesCount, String[] results) { + super(cmd, success, null); + + assert (rulesCount == results.length) : "Results' count should match requests' count!"; + this.results = results; + } + + public String[] getResults() { + return results; + } +} diff --git a/core/src/com/cloud/agent/api/routing/IpAssocCommand.java b/core/src/com/cloud/agent/api/routing/IpAssocCommand.java index df5d54a8c88..fe6ab6fef73 100644 --- a/core/src/com/cloud/agent/api/routing/IpAssocCommand.java +++ b/core/src/com/cloud/agent/api/routing/IpAssocCommand.java @@ -38,4 +38,8 @@ public class IpAssocCommand extends NetworkElementCommand { return ipAddresses; } + @Override + public int getAnswersCount() { + return ipAddresses.length; + } } diff --git a/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java b/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java index 3e5566a700c..d4996a5321e 100644 --- a/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java +++ b/core/src/com/cloud/agent/api/routing/IpAssocVpcCommand.java @@ -26,4 +26,10 @@ public class IpAssocVpcCommand extends IpAssocCommand { public IpAssocVpcCommand(IpAddressTO[] ips) { super(ips); } + + @Override + public int getAnswersCount() { + //Count private gateway to maximum value + return ipAddresses.length * 2; + } } diff --git a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java index 217e962d18a..120c717f9d1 100644 --- a/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java +++ b/core/src/com/cloud/agent/api/routing/NetworkElementCommand.java @@ -34,6 +34,7 @@ public abstract class NetworkElementCommand extends Command { public static final String GUEST_BRIDGE = "guest.bridge"; public static final String VPC_PRIVATE_GATEWAY = "vpc.gateway.private"; public static final String FIREWALL_EGRESS_DEFAULT = "firewall.egress.default"; + public static final String ROUTER_MONITORING_ENABLE = "router.monitor.enable"; private String routerAccessIp; @@ -61,4 +62,12 @@ public abstract class NetworkElementCommand extends Command { public void setRouterAccessIp(String routerAccessIp) { this.routerAccessIp = routerAccessIp; } + + public int getAnswersCount() { + return 1; + } + + public boolean isQuery() { + return false; + } } diff --git a/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java index f7ac052d72c..36771b9d0cc 100644 --- a/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java +++ b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java @@ -16,12 +16,12 @@ // under the License. package com.cloud.agent.api.routing; +import com.cloud.agent.api.to.FirewallRuleTO; + import java.util.HashSet; import java.util.List; import java.util.Set; -import com.cloud.agent.api.to.FirewallRuleTO; - /** * * AccessDetails allow different components to put in information about @@ -92,4 +92,9 @@ public class SetFirewallRulesCommand extends NetworkElementCommand { return result; } + + @Override + public int getAnswersCount() { + return rules.length; + } } diff --git a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java index 7edcdf38f17..0b9fec5155f 100644 --- a/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java +++ b/core/src/com/cloud/agent/api/routing/SetNetworkACLCommand.java @@ -17,14 +17,14 @@ package com.cloud.agent.api.routing; +import com.cloud.agent.api.to.NetworkACLTO; +import com.cloud.agent.api.to.NicTO; + import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; -import com.cloud.agent.api.to.NetworkACLTO; -import com.cloud.agent.api.to.NicTO; - public class SetNetworkACLCommand extends NetworkElementCommand { NetworkACLTO[] rules; NicTO nic; @@ -97,4 +97,9 @@ public class SetNetworkACLCommand extends NetworkElementCommand { public NicTO getNic() { return nic; } + + @Override + public int getAnswersCount() { + return rules.length; + } } diff --git a/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java b/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java index a7bf37f83ef..d93ccaf7201 100644 --- a/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java +++ b/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesCommand.java @@ -16,10 +16,10 @@ // under the License. package com.cloud.agent.api.routing; -import java.util.List; - import com.cloud.agent.api.to.PortForwardingRuleTO; +import java.util.List; + public class SetPortForwardingRulesCommand extends NetworkElementCommand { PortForwardingRuleTO[] rules; @@ -37,4 +37,10 @@ public class SetPortForwardingRulesCommand extends NetworkElementCommand { public PortForwardingRuleTO[] getRules() { return rules; } + + @Override + public int getAnswersCount() { + return rules.length; + } } + diff --git a/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java b/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java index 613ae5d7985..1bce50dbddf 100644 --- a/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java +++ b/core/src/com/cloud/agent/api/routing/SetPortForwardingRulesVpcCommand.java @@ -16,10 +16,10 @@ // under the License. package com.cloud.agent.api.routing; -import java.util.List; - import com.cloud.agent.api.to.PortForwardingRuleTO; +import java.util.List; + public class SetPortForwardingRulesVpcCommand extends SetPortForwardingRulesCommand { protected SetPortForwardingRulesVpcCommand() { } diff --git a/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java b/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java index a38bf5f22ff..64c76605765 100644 --- a/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java +++ b/core/src/com/cloud/agent/api/routing/SetStaticNatRulesCommand.java @@ -16,10 +16,10 @@ // under the License. package com.cloud.agent.api.routing; -import java.util.List; - import com.cloud.agent.api.to.StaticNatRuleTO; +import java.util.List; + public class SetStaticNatRulesCommand extends NetworkElementCommand { StaticNatRuleTO[] rules; @@ -44,4 +44,9 @@ public class SetStaticNatRulesCommand extends NetworkElementCommand { public Long getVpcId() { return vpcId; } + + @Override + public int getAnswersCount() { + return rules.length; + } } diff --git a/core/src/com/cloud/agent/api/routing/SetStaticRouteAnswer.java b/core/src/com/cloud/agent/api/routing/SetStaticRouteAnswer.java index abdcba86c6f..cf2b95288fe 100644 --- a/core/src/com/cloud/agent/api/routing/SetStaticRouteAnswer.java +++ b/core/src/com/cloud/agent/api/routing/SetStaticRouteAnswer.java @@ -16,6 +16,8 @@ // under the License. package com.cloud.agent.api.routing; +import java.util.Arrays; + import com.cloud.agent.api.Answer; public class SetStaticRouteAnswer extends Answer { @@ -26,11 +28,16 @@ public class SetStaticRouteAnswer extends Answer { public SetStaticRouteAnswer(SetStaticRouteCommand cmd, boolean success, String[] results) { super(cmd, success, null); - assert (cmd.getStaticRoutes().length == results.length) : "Static routes and their results should be the same length"; - this.results = results; + if (results != null) { + assert (cmd.getStaticRoutes().length == results.length) : "Static routes and their results should be the same length"; + this.results = Arrays.copyOf(results, results.length); + } } public String[] getResults() { - return results; + if (results != null) { + return Arrays.copyOf(results, results.length); + } + return null; } } diff --git a/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java b/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java index 26800a115a1..1e4f0c86e0f 100644 --- a/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java +++ b/core/src/com/cloud/agent/api/routing/SetStaticRouteCommand.java @@ -17,14 +17,14 @@ package com.cloud.agent.api.routing; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import com.cloud.network.vpc.StaticRoute; import com.cloud.network.vpc.StaticRouteProfile; import com.cloud.utils.net.NetUtils; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + public class SetStaticRouteCommand extends NetworkElementCommand { StaticRouteProfile[] staticRoutes; @@ -59,4 +59,9 @@ public class SetStaticRouteCommand extends NetworkElementCommand { result[0] = toAdd.toArray(new String[toAdd.size()]); return result; } + + @Override + public int getAnswersCount() { + return staticRoutes.length; + } } diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRouterDeployer.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRouterDeployer.java index 243098abeab..1feaaead9f0 100644 --- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRouterDeployer.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRouterDeployer.java @@ -21,6 +21,8 @@ import com.cloud.utils.ExecutionResult; public interface VirtualRouterDeployer { ExecutionResult executeInVR(String routerIp, String script, String args); + /* timeout in seconds */ + ExecutionResult executeInVR(String routerIp, String script, String args, int timeout); ExecutionResult createFileInVR(String routerIp, String path, String filename, String content); ExecutionResult prepareCommand(NetworkElementCommand cmd); ExecutionResult cleanupCommand(NetworkElementCommand cmd); diff --git a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java index 1ed38644536..df4ed2cc7db 100755 --- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java +++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java @@ -22,36 +22,32 @@ import com.cloud.agent.api.CheckRouterAnswer; import com.cloud.agent.api.CheckRouterCommand; import com.cloud.agent.api.CheckS2SVpnConnectionsAnswer; import com.cloud.agent.api.CheckS2SVpnConnectionsCommand; -import com.cloud.agent.api.Command; import com.cloud.agent.api.GetDomRVersionAnswer; import com.cloud.agent.api.GetDomRVersionCmd; -import com.cloud.agent.api.SetupGuestNetworkAnswer; import com.cloud.agent.api.SetupGuestNetworkCommand; +import com.cloud.agent.api.routing.AggregationControlCommand; +import com.cloud.agent.api.routing.AggregationControlCommand.Action; import com.cloud.agent.api.routing.CreateIpAliasCommand; import com.cloud.agent.api.routing.DeleteIpAliasCommand; import com.cloud.agent.api.routing.DhcpEntryCommand; import com.cloud.agent.api.routing.DnsMasqConfigCommand; +import com.cloud.agent.api.routing.GroupAnswer; +import com.cloud.agent.api.routing.GetRouterAlertsCommand; +import com.cloud.agent.api.GetRouterAlertsAnswer; import com.cloud.agent.api.routing.IpAliasTO; -import com.cloud.agent.api.routing.IpAssocAnswer; import com.cloud.agent.api.routing.IpAssocCommand; import com.cloud.agent.api.routing.IpAssocVpcCommand; import com.cloud.agent.api.routing.LoadBalancerConfigCommand; import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand; import com.cloud.agent.api.routing.SavePasswordCommand; -import com.cloud.agent.api.routing.SetFirewallRulesAnswer; import com.cloud.agent.api.routing.SetFirewallRulesCommand; import com.cloud.agent.api.routing.SetMonitorServiceCommand; -import com.cloud.agent.api.routing.SetNetworkACLAnswer; import com.cloud.agent.api.routing.SetNetworkACLCommand; -import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer; import com.cloud.agent.api.routing.SetPortForwardingRulesCommand; import com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand; -import com.cloud.agent.api.routing.SetSourceNatAnswer; import com.cloud.agent.api.routing.SetSourceNatCommand; -import com.cloud.agent.api.routing.SetStaticNatRulesAnswer; import com.cloud.agent.api.routing.SetStaticNatRulesCommand; -import com.cloud.agent.api.routing.SetStaticRouteAnswer; import com.cloud.agent.api.routing.SetStaticRouteCommand; import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand; import com.cloud.agent.api.routing.VmDataCommand; @@ -77,8 +73,14 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.nio.channels.SocketChannel; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Queue; +import java.util.UUID; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; /** * VirtualNetworkResource controls and configures virtual networking @@ -89,90 +91,257 @@ import java.util.Map; * } **/ public class VirtualRoutingResource { + protected class VRScripts { + protected static final String S2SVPN_CHECK = "checkbatchs2svpn.sh"; + protected static final String S2SVPN_IPSEC = "ipsectunnel.sh"; + protected static final String DHCP = "edithosts.sh"; + protected static final String DNSMASQ_CONFIG = "dnsmasq.sh"; + protected static final String FIREWALL_EGRESS = "firewall_egress.sh"; + protected static final String FIREWALL_INGRESS = "firewall_ingress.sh"; + protected static final String FIREWALL_NAT = "firewall_nat.sh"; + protected static final String IPALIAS_CREATE = "createipAlias.sh"; + protected static final String IPALIAS_DELETE = "deleteipAlias.sh"; + protected static final String IPASSOC = "ipassoc.sh"; + protected static final String LB = "loadbalancer.sh"; + protected static final String MONITOR_SERVICE = "monitor_service.sh"; + protected static final String ROUTER_ALERTS = "getRouterAlerts.sh"; + protected static final String PASSWORD = "savepassword.sh"; + protected static final String RVR_CHECK = "checkrouter.sh"; + protected static final String RVR_BUMPUP_PRI = "bumpup_priority.sh"; + protected static final String VMDATA = "vmdata.py"; + protected static final String VERSION = "get_template_version.sh"; + protected static final String VPC_ACL = "vpc_acl.sh"; + protected static final String VPC_GUEST_NETWORK = "vpc_guestnw.sh"; + protected static final String VPC_IPASSOC = "vpc_ipassoc.sh"; + protected static final String VPC_LB = "vpc_loadbalancer.sh"; + protected static final String VPC_PRIVATEGW = "vpc_privateGateway.sh"; + protected static final String VPC_PRIVATEGW_ACL = "vpc_privategw_acl.sh"; + protected static final String VPC_PORTFORWARDING = "vpc_portforwarding.sh"; + protected static final String VPC_SOURCE_NAT = "vpc_snat.sh"; + protected static final String VPC_STATIC_NAT = "vpc_staticnat.sh"; + protected static final String VPC_STATIC_ROUTE = "vpc_staticroute.sh"; + protected static final String VPN_L2TP = "vpn_l2tp.sh"; + + protected static final String VR_CFG = "vr_cfg.sh"; + } + private static final Logger s_logger = Logger.getLogger(VirtualRoutingResource.class); private VirtualRouterDeployer _vrDeployer; + private Map _vrAggregateCommandsSet; + protected Map _vrLockMap = new HashMap(); private String _name; private int _sleep; private int _retry; private int _port; + private String _cfgVersion = "1.0"; + public VirtualRoutingResource(VirtualRouterDeployer deployer) { this._vrDeployer = deployer; } - public Answer executeRequest(final Command cmd) { + public Answer executeRequest(final NetworkElementCommand cmd) { + boolean aggregated = false; + String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + Lock lock; + if (_vrLockMap.containsKey(routerName)) { + lock = _vrLockMap.get(routerName); + } else { + lock = new ReentrantLock(); + _vrLockMap.put(routerName, lock); + } + lock.lock(); + try { - ExecutionResult rc = _vrDeployer.prepareCommand((NetworkElementCommand)cmd); + ExecutionResult rc = _vrDeployer.prepareCommand(cmd); if (!rc.isSuccess()) { s_logger.error("Failed to prepare VR command due to " + rc.getDetails()); return new Answer(cmd, false, rc.getDetails()); } - if (cmd instanceof SetPortForwardingRulesVpcCommand) { - return execute((SetPortForwardingRulesVpcCommand)cmd); - } else if (cmd instanceof SetPortForwardingRulesCommand) { - return execute((SetPortForwardingRulesCommand)cmd); - } else if (cmd instanceof SetStaticRouteCommand) { - return execute((SetStaticRouteCommand)cmd); - } else if (cmd instanceof SetStaticNatRulesCommand) { - return execute((SetStaticNatRulesCommand)cmd); - } else if (cmd instanceof LoadBalancerConfigCommand) { - return execute((LoadBalancerConfigCommand)cmd); - } else if (cmd instanceof SavePasswordCommand) { - return execute((SavePasswordCommand)cmd); - } else if (cmd instanceof DhcpEntryCommand) { - return execute((DhcpEntryCommand)cmd); - } else if (cmd instanceof CreateIpAliasCommand) { - return execute((CreateIpAliasCommand)cmd); - } else if (cmd instanceof DnsMasqConfigCommand) { - return execute((DnsMasqConfigCommand)cmd); - } else if (cmd instanceof DeleteIpAliasCommand) { - return execute((DeleteIpAliasCommand)cmd); - } else if (cmd instanceof VmDataCommand) { - return execute((VmDataCommand)cmd); - } else if (cmd instanceof CheckRouterCommand) { - return execute((CheckRouterCommand)cmd); - } else if (cmd instanceof SetFirewallRulesCommand) { - return execute((SetFirewallRulesCommand)cmd); - } else if (cmd instanceof BumpUpPriorityCommand) { - return execute((BumpUpPriorityCommand)cmd); - } else if (cmd instanceof RemoteAccessVpnCfgCommand) { - return execute((RemoteAccessVpnCfgCommand)cmd); - } else if (cmd instanceof VpnUsersCfgCommand) { - return execute((VpnUsersCfgCommand)cmd); - } else if (cmd instanceof GetDomRVersionCmd) { - return execute((GetDomRVersionCmd)cmd); - } else if (cmd instanceof Site2SiteVpnCfgCommand) { - return execute((Site2SiteVpnCfgCommand)cmd); - } else if (cmd instanceof CheckS2SVpnConnectionsCommand) { - return execute((CheckS2SVpnConnectionsCommand)cmd); - } else if (cmd instanceof SetMonitorServiceCommand) { - return execute((SetMonitorServiceCommand)cmd); - } else if (cmd instanceof SetupGuestNetworkCommand) { - return execute((SetupGuestNetworkCommand)cmd); - } else if (cmd instanceof SetNetworkACLCommand) { - return execute((SetNetworkACLCommand)cmd); - } else if (cmd instanceof SetSourceNatCommand) { - return execute((SetSourceNatCommand)cmd); - } else if (cmd instanceof IpAssocVpcCommand) { - return execute((IpAssocVpcCommand)cmd); - } else if (cmd instanceof IpAssocCommand) { - return execute((IpAssocCommand)cmd); - } else { + assert cmd.getRouterAccessIp() != null : "Why there is no access IP for VR?"; + + if (cmd.isQuery()) { + return executeQueryCommand(cmd); + } + + if (cmd instanceof AggregationControlCommand) { + return execute((AggregationControlCommand)cmd); + } + + if (_vrAggregateCommandsSet.containsKey(routerName)) { + _vrAggregateCommandsSet.get(routerName).add(cmd); + aggregated = true; + // Clean up would be done after command has been executed + //TODO: Deal with group answer as well + return new Answer(cmd); + } + + List cfg = generateCommandCfg(cmd); + if (cfg == null) { return Answer.createUnsupportedCommandAnswer(cmd); } + + return applyConfig(cmd, cfg); } catch (final IllegalArgumentException e) { return new Answer(cmd, false, e.getMessage()); } finally { - ExecutionResult rc = _vrDeployer.cleanupCommand((NetworkElementCommand)cmd); - if (!rc.isSuccess()) { - s_logger.error("Failed to cleanup VR command due to " + rc.getDetails()); + lock.unlock(); + if (!aggregated) { + ExecutionResult rc = _vrDeployer.cleanupCommand(cmd); + if (!rc.isSuccess()) { + s_logger.error("Failed to cleanup VR command due to " + rc.getDetails()); + } } } } - private Answer execute(VpnUsersCfgCommand cmd) { + protected class ConfigItem { + private String script; + private String args; + private String info; + private String filePath; + private String fileName; + private String fileContents; + private boolean isFile; + + public ConfigItem(String script, String args) { + this.script = script; + this.args = args; + this.isFile = false; + } + + public ConfigItem(String filePath, String fileName, String fileContents) { + this.filePath = filePath; + this.fileName = fileName; + this.fileContents = fileContents; + this.isFile = true; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } + + public String getArgs() { + return args; + } + + public void setArgs(String args) { + this.args = args; + } + + public String getInfo() { + return info; + } + + public void setInfo(String info) { + this.info = info; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFileContents() { + return fileContents; + } + + public void setFileContents(String fileContents) { + this.fileContents = fileContents; + } + + public boolean isFile() { + return isFile; + } + } + + private Answer executeQueryCommand(NetworkElementCommand cmd) { + if (cmd instanceof CheckRouterCommand) { + return execute((CheckRouterCommand)cmd); + } else if (cmd instanceof GetDomRVersionCmd) { + return execute((GetDomRVersionCmd)cmd); + } else if (cmd instanceof CheckS2SVpnConnectionsCommand) { + return execute((CheckS2SVpnConnectionsCommand) cmd); + } else if (cmd instanceof GetRouterAlertsCommand) { + return execute((GetRouterAlertsCommand)cmd); + } else { + s_logger.error("Unknown query command in VirtualRoutingResource!"); + return Answer.createUnsupportedCommandAnswer(cmd); + } + } + + private ExecutionResult applyConfigToVR(NetworkElementCommand cmd, ConfigItem c) { + if (c.isFile()) { + return _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), c.getFilePath(), c.getFileName(), c.getFileContents()); + } else { + return _vrDeployer.executeInVR(cmd.getRouterAccessIp(), c.getScript(), c.getArgs()); + } + } + + private Answer applyConfig(NetworkElementCommand cmd, List cfg) { + int answersCount = cmd.getAnswersCount(); + + // Use the last answer as final answer + if (answersCount == 1) { + ExecutionResult result = new ExecutionResult(true, "No configure to be applied"); + for (ConfigItem c : cfg) { + result = applyConfigToVR(cmd, c); + if (!result.isSuccess()) { + break; + } + } + return new Answer(cmd, result.isSuccess(), result.getDetails()); + } + + ExecutionResult[] results = new ExecutionResult[answersCount]; + String[] resultsString = new String[answersCount]; + boolean finalResult = true; + int i = 0, j; + for (ConfigItem c : cfg) { + results[i] = applyConfigToVR(cmd, c); + if (c.getInfo() != null) { + if (results[i].isSuccess()) { + results[i].setDetails(c.getInfo() + " - success: " + results[i].getDetails()); + } else { + results[i].setDetails(c.getInfo() + " - failed: " + results[i].getDetails()); + } + } + i ++; + } + i = 0; j = 0; + while (j < answersCount) { + resultsString[j] = results[i].getDetails(); + if (!results[i].isSuccess()) { + finalResult = false; + } + // Fill the resultsString with the last result of execution, mostly in 1:n + if (i < cfg.size() - 1) { + i ++; + } + j ++; + } + return new GroupAnswer(cmd, finalResult, answersCount, resultsString); + } + + private List generateConfig(VpnUsersCfgCommand cmd) { + LinkedList cfg = new LinkedList<>(); for (VpnUsersCfgCommand.UsernamePassword userpwd : cmd.getUserpwds()) { String args = ""; if (!userpwd.isAdd()) { @@ -182,15 +351,13 @@ public class VirtualRoutingResource { args += "-u "; args += userpwd.getUsernamePassword(); } - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpn_l2tp.sh", args); - if (!result.isSuccess()) { - return new Answer(cmd, false, "Configure VPN user failed for user " + userpwd.getUsername() + ":" + result.getDetails()); - } + cfg.add(new ConfigItem(VRScripts.VPN_L2TP, args)); } - return new Answer(cmd); + return cfg; } - private Answer execute(RemoteAccessVpnCfgCommand cmd) { + private List generateConfig(RemoteAccessVpnCfgCommand cmd) { + LinkedList cfg = new LinkedList<>(); String args = ""; if (cmd.isCreate()) { args += "-r "; @@ -209,18 +376,14 @@ public class VirtualRoutingResource { } args += " -C " + cmd.getLocalCidr(); args += " -i " + cmd.getPublicInterface(); - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpn_l2tp.sh", args); - return new Answer(cmd, result.isSuccess(), result.getDetails()); + cfg.add(new ConfigItem(VRScripts.VPN_L2TP, args)); + return cfg; } - private Answer execute(SetFirewallRulesCommand cmd) { - String[] results = new String[cmd.getRules().length]; - String routerAccessIp = cmd.getRouterAccessIp(); - String egressDefault = cmd.getAccessDetail(NetworkElementCommand.FIREWALL_EGRESS_DEFAULT); + private List generateConfig(SetFirewallRulesCommand cmd) { + LinkedList cfg = new LinkedList<>(); - if (routerAccessIp == null) { - return new SetFirewallRulesAnswer(cmd, false, results); - } + String egressDefault = cmd.getAccessDetail(NetworkElementCommand.FIREWALL_EGRESS_DEFAULT); FirewallRuleTO[] allrules = cmd.getRules(); FirewallRule.TrafficType trafficType = allrules[0].getTrafficType(); @@ -248,116 +411,69 @@ public class VirtualRoutingResource { args += " -a " + sb.toString(); } - ExecutionResult result; - if (trafficType == FirewallRule.TrafficType.Egress) { - result = _vrDeployer.executeInVR(routerAccessIp, "firewall_egress.sh", args); + cfg.add(new ConfigItem(VRScripts.FIREWALL_EGRESS, args)); } else { - result = _vrDeployer.executeInVR(routerAccessIp, "firewall_ingress.sh", args); + cfg.add(new ConfigItem(VRScripts.FIREWALL_INGRESS, args)); } - if (!result.isSuccess()) { - //FIXME - in the future we have to process each rule separately; now we temporarily set every rule to be false if single rule fails - for (int i = 0; i < results.length; i++) { - results[i] = "Failed: " + result.getDetails(); - } - return new SetFirewallRulesAnswer(cmd, false, results); - } - return new SetFirewallRulesAnswer(cmd, true, results); - + return cfg; } - private Answer execute(SetPortForwardingRulesCommand cmd) { - String[] results = new String[cmd.getRules().length]; - int i = 0; - boolean endResult = true; + private List generateConfig(SetPortForwardingRulesCommand cmd) { + LinkedList cfg = new LinkedList<>(); + for (PortForwardingRuleTO rule : cmd.getRules()) { StringBuilder args = new StringBuilder(); - args.append(rule.revoked() ? " -D " : " -A "); + args.append(rule.revoked() ? "-D" : "-A"); args.append(" -P ").append(rule.getProtocol().toLowerCase()); args.append(" -l ").append(rule.getSrcIp()); args.append(" -p ").append(rule.getStringSrcPortRange()); args.append(" -r ").append(rule.getDstIp()); args.append(" -d ").append(rule.getStringDstPortRange()); - - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "firewall_nat.sh", args.toString()); - - if (!result.isSuccess()) { - results[i++] = "Failed"; - endResult = false; - } else { - results[i++] = null; - } + cfg.add(new ConfigItem(VRScripts.FIREWALL_NAT, args.toString())); } - return new SetPortForwardingRulesAnswer(cmd, results, endResult); + return cfg; } - protected SetStaticNatRulesAnswer SetVPCStaticNatRules(SetStaticNatRulesCommand cmd) { - String[] results = new String[cmd.getRules().length]; - int i = 0; - boolean endResult = true; - - for (StaticNatRuleTO rule : cmd.getRules()) { - String args = rule.revoked() ? " -D" : " -A"; - args += " -l " + rule.getSrcIp(); - args += " -r " + rule.getDstIp(); - - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_staticnat.sh", args); - - if (!result.isSuccess()) { - results[i++] = null; - } else { - results[i++] = "Failed"; - endResult = false; - } - } - return new SetStaticNatRulesAnswer(cmd, results, endResult); - - } - - private SetStaticNatRulesAnswer execute(SetStaticNatRulesCommand cmd) { + private List generateConfig(SetStaticNatRulesCommand cmd) { + LinkedList cfg = new LinkedList<>(); if (cmd.getVpcId() != null) { - return SetVPCStaticNatRules(cmd); - } - String[] results = new String[cmd.getRules().length]; - int i = 0; - boolean endResult = true; - for (StaticNatRuleTO rule : cmd.getRules()) { - //1:1 NAT needs instanceip;publicip;domrip;op - StringBuilder args = new StringBuilder(); - args.append(rule.revoked() ? " -D " : " -A "); - args.append(" -l ").append(rule.getSrcIp()); - args.append(" -r ").append(rule.getDstIp()); + for (StaticNatRuleTO rule : cmd.getRules()) { + String args = rule.revoked() ? " -D" : " -A"; + args += " -l " + rule.getSrcIp(); + args += " -r " + rule.getDstIp(); - if (rule.getProtocol() != null) { - args.append(" -P ").append(rule.getProtocol().toLowerCase()); + cfg.add(new ConfigItem(VRScripts.VPC_STATIC_NAT, args)); } + } else { + for (StaticNatRuleTO rule : cmd.getRules()) { + //1:1 NAT needs instanceip;publicip;domrip;op + StringBuilder args = new StringBuilder(); + args.append(rule.revoked() ? " -D " : " -A "); + args.append(" -l ").append(rule.getSrcIp()); + args.append(" -r ").append(rule.getDstIp()); - args.append(" -d ").append(rule.getStringSrcPortRange()); - args.append(" -G "); + if (rule.getProtocol() != null) { + args.append(" -P ").append(rule.getProtocol().toLowerCase()); + } - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "firewall_nat.sh", args.toString()); + args.append(" -d ").append(rule.getStringSrcPortRange()); + args.append(" -G "); - if (!result.isSuccess()) { - results[i++] = "Failed"; - endResult = false; - } else { - results[i++] = null; + cfg.add(new ConfigItem(VRScripts.FIREWALL_NAT, args.toString())); } } - - return new SetStaticNatRulesAnswer(cmd, results, endResult); + return cfg; } - private Answer execute(LoadBalancerConfigCommand cmd) { + private List generateConfig(LoadBalancerConfigCommand cmd) { + LinkedList cfg = new LinkedList<>(); + String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - - if (routerIp == null) { - return new Answer(cmd); - } - LoadBalancerConfigurator cfgtr = new HAProxyConfigurator(); + String[] config = cfgtr.generateConfiguration(cmd); String tmpCfgFileContents = ""; for (int i = 0; i < config.length; i++) { @@ -366,12 +482,8 @@ public class VirtualRoutingResource { } String tmpCfgFilePath = "/etc/haproxy/"; - String tmpCfgFileName = "haproxy.cfg.new"; - ExecutionResult result = _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents); - - if (!result.isSuccess()) { - return new Answer(cmd, false, "Fail to copy LB config file to VR"); - } + String tmpCfgFileName = "haproxy.cfg.new." + String.valueOf(System.currentTimeMillis()); + cfg.add(new ConfigItem(tmpCfgFilePath, tmpCfgFileName, tmpCfgFileContents)); String[][] rules = cfgtr.generateFwRules(cmd); @@ -379,7 +491,7 @@ public class VirtualRoutingResource { String[] removeRules = rules[LoadBalancerConfigurator.REMOVE]; String[] statRules = rules[LoadBalancerConfigurator.STATS]; - String args = ""; + String args = " -f " + tmpCfgFilePath + tmpCfgFileName; StringBuilder sb = new StringBuilder(); if (addRules.length > 0) { for (int i = 0; i < addRules.length; i++) { @@ -408,17 +520,17 @@ public class VirtualRoutingResource { if (cmd.getVpcId() == null) { args = " -i " + routerIp + args; - result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "loadbalancer.sh", args); + cfg.add(new ConfigItem(VRScripts.LB, args)); } else { args = " -i " + cmd.getNic().getIp() + args; - result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_loadbalancer.sh", args); + cfg.add(new ConfigItem(VRScripts.VPC_LB, args)); } - return new Answer(cmd, result.isSuccess(), result.getDetails()); + return cfg; } - - protected Answer execute(VmDataCommand cmd) { + private List generateConfig(VmDataCommand cmd) { + LinkedList cfg = new LinkedList<>(); Map> data = new HashMap>(); data.put(cmd.getVmIpAddress(), cmd.getVmData()); @@ -429,23 +541,26 @@ public class VirtualRoutingResource { String args = "-d " + json; - final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vmdata.py", args); - return new Answer(cmd, result.isSuccess(), result.getDetails()); + cfg.add(new ConfigItem(VRScripts.VMDATA, args)); + return cfg; } - protected Answer execute(final SavePasswordCommand cmd) { + private List generateConfig(SavePasswordCommand cmd) { + LinkedList cfg = new LinkedList<>(); + final String password = cmd.getPassword(); - final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); final String vmIpAddress = cmd.getVmIpAddress(); String args = "-v " + vmIpAddress; args += " -p " + password; - ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, "savepassword.sh", args); - return new Answer(cmd, result.isSuccess(), result.getDetails()); + cfg.add(new ConfigItem(VRScripts.PASSWORD, args)); + return cfg; } - protected Answer execute(final DhcpEntryCommand cmd) { + private List generateConfig(DhcpEntryCommand cmd) { + LinkedList cfg = new LinkedList<>(); + String args = " -m " + cmd.getVmMac(); if (cmd.getVmIpAddress() != null) { args += " -4 " + cmd.getVmIpAddress(); @@ -472,22 +587,27 @@ public class VirtualRoutingResource { if (!cmd.isDefault()) { args += " -N"; } + cfg.add(new ConfigItem(VRScripts.DHCP, args)); - final ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), "edithosts.sh", args); - return new Answer(cmd, result.isSuccess(), result.getDetails()); + return cfg; } - protected Answer execute(final CreateIpAliasCommand cmd) { + private List generateConfig(CreateIpAliasCommand cmd) { + LinkedList cfg = new LinkedList<>(); + List ipAliasTOs = cmd.getIpAliasList(); String args = ""; for (IpAliasTO ipaliasto : ipAliasTOs) { args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-"; } - final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "createipAlias.sh", args); - return new Answer(cmd, result.isSuccess(), result.getDetails()); + + cfg.add(new ConfigItem(VRScripts.IPALIAS_CREATE, args)); + return cfg; } - protected Answer execute(final DeleteIpAliasCommand cmd) { + private List generateConfig(DeleteIpAliasCommand cmd) { + LinkedList cfg = new LinkedList<>(); + String args = ""; List revokedIpAliasTOs = cmd.getDeleteIpAliasTos(); for (IpAliasTO ipAliasTO : revokedIpAliasTOs) { @@ -499,51 +619,73 @@ public class VirtualRoutingResource { for (IpAliasTO ipAliasTO : activeIpAliasTOs) { args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-"; } - final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "deleteipAlias.sh", args); - return new Answer(cmd, result.isSuccess(), result.getDetails()); + + cfg.add(new ConfigItem(VRScripts.IPALIAS_DELETE, args)); + return cfg; } - protected Answer execute(final DnsMasqConfigCommand cmd) { + private List generateConfig(DnsMasqConfigCommand cmd) { + LinkedList cfg = new LinkedList<>(); + List dhcpTos = cmd.getIps(); String args = ""; for (DhcpTO dhcpTo : dhcpTos) { args = args + dhcpTo.getRouterIp() + ":" + dhcpTo.getGateway() + ":" + dhcpTo.getNetmask() + ":" + dhcpTo.getStartIpOfSubnet() + "-"; } - final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "dnsmasq.sh", args); - return new Answer(cmd, result.isSuccess(), result.getDetails()); + + cfg.add(new ConfigItem(VRScripts.DNSMASQ_CONFIG, args)); + return cfg; } private CheckS2SVpnConnectionsAnswer execute(CheckS2SVpnConnectionsCommand cmd) { - final String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - String args = ""; for (String ip : cmd.getVpnIps()) { args += ip + " "; } - ExecutionResult result = _vrDeployer.executeInVR(routerIP, "checkbatchs2svpn.sh", args); + ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.S2SVPN_CHECK, args); return new CheckS2SVpnConnectionsAnswer(cmd, result.isSuccess(), result.getDetails()); } - protected Answer execute(CheckRouterCommand cmd) { - final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + private GetRouterAlertsAnswer execute(GetRouterAlertsCommand cmd) { - final ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, "checkrouter.sh", null); + String args = null; + String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + if (cmd.getPreviousAlertTimeStamp() != null) { + args = cmd.getPreviousAlertTimeStamp(); + } + + ExecutionResult result = _vrDeployer.executeInVR(routerIp, VRScripts.ROUTER_ALERTS, args); + String alerts[] = null; + String lastAlertTimestamp = null; + // CallHostPlugin results "success" when there are no alerts on virtual router + if (result.isSuccess()) { + if (!result.getDetails().isEmpty() && !result.getDetails().equals("No Alerts")) { + alerts = result.getDetails().split("\\\\n"); + String[] lastAlert = alerts[alerts.length - 1].split(" "); + lastAlertTimestamp = lastAlert[0] + " " + lastAlert[1]; + } + } + + return new GetRouterAlertsAnswer(cmd, alerts, lastAlertTimestamp); + } + + protected Answer execute(CheckRouterCommand cmd) { + final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.RVR_CHECK, null); if (!result.isSuccess()) { return new CheckRouterAnswer(cmd, result.getDetails()); } return new CheckRouterAnswer(cmd, result.getDetails(), true); } - protected Answer execute(BumpUpPriorityCommand cmd) { - ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), "bumpup_priority.sh", null); - return new Answer(cmd, result.isSuccess(), result.getDetails()); + private List generateConfig(BumpUpPriorityCommand cmd) { + LinkedList cfg = new LinkedList<>(); + cfg.add(new ConfigItem(VRScripts.RVR_BUMPUP_PRI, null)); + return cfg; } protected Answer execute(GetDomRVersionCmd cmd) { - final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - - final ExecutionResult result = _vrDeployer.executeInVR(routerPrivateIPAddress, "get_template_version.sh", null); + final ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VERSION, null); if (!result.isSuccess()) { return new GetDomRVersionAnswer(cmd, "GetDomRVersionCmd failed"); } @@ -554,7 +696,9 @@ public class VirtualRoutingResource { return new GetDomRVersionAnswer(cmd, result.getDetails(), lines[0], lines[1]); } - protected Answer execute(Site2SiteVpnCfgCommand cmd) { + private List generateConfig(Site2SiteVpnCfgCommand cmd) { + LinkedList cfg = new LinkedList<>(); + String args = ""; if (cmd.isCreate()) { args += "-A"; @@ -596,28 +740,45 @@ public class VirtualRoutingResource { args += " -N "; args += cmd.getPeerGuestCidrList(); } - ExecutionResult result = _vrDeployer.executeInVR(cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP), "ipsectunnel.sh", args); - if (!result.isSuccess()) { - return new Answer(cmd, false, "Configure site to site VPN failed due to " + result.getDetails()); - } - return new Answer(cmd); + + cfg.add(new ConfigItem(VRScripts.S2SVPN_IPSEC, args)); + return cfg; } - protected Answer execute(SetMonitorServiceCommand cmd) { + protected List generateConfig(SetMonitorServiceCommand cmd) { + LinkedList cfg = new LinkedList<>(); + String config = cmd.getConfiguration(); + String disableMonitoring = cmd.getAccessDetail(NetworkElementCommand.ROUTER_MONITORING_ENABLE); String args = " -c " + config; - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "monitor_service.sh", args); - - if (!result.isSuccess()) { - return new Answer(cmd, false, result.getDetails()); + if (disableMonitoring != null) { + args = args + " -d"; } - return new Answer(cmd); + + cfg.add(new ConfigItem(VRScripts.MONITOR_SERVICE, args)); + return cfg; } - protected SetupGuestNetworkAnswer execute(SetupGuestNetworkCommand cmd) { + protected List generateConfig(GetRouterAlertsCommand cmd) { + LinkedList cfg = new LinkedList<>(); + + String args = null; + String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + if (cmd.getPreviousAlertTimeStamp() != null) { + args = "getRouterAlerts.sh " + routerIp + " " + cmd.getPreviousAlertTimeStamp(); + } else { + args = "getRouterAlerts.sh " + routerIp; + } + + cfg.add(new ConfigItem(VRScripts.ROUTER_ALERTS, args)); + return cfg; + } + + protected List generateConfig(SetupGuestNetworkCommand cmd) { + LinkedList cfg = new LinkedList<>(); + NicTO nic = cmd.getNic(); - String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); String routerGIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP); String gateway = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY); String cidr = Long.toString(NetUtils.getCidrSize(nic.getNetmask())); @@ -637,6 +798,7 @@ public class VirtualRoutingResource { String netmask = NetUtils.getSubNet(routerGIP, nic.getNetmask()); String args = " -C"; + args += " -M " + nic.getMac(); args += " -d " + dev; args += " -i " + routerGIP; args += " -g " + gateway; @@ -648,224 +810,171 @@ public class VirtualRoutingResource { if (domainName != null && !domainName.isEmpty()) { args += " -e " + domainName; } - ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_guestnw.sh", args); - if (!result.isSuccess()) { - return new SetupGuestNetworkAnswer(cmd, false, "Creating guest network failed due to " + result.getDetails()); - } - return new SetupGuestNetworkAnswer(cmd, true, "success"); + cfg.add(new ConfigItem(VRScripts.VPC_GUEST_NETWORK, args)); + return cfg; } - private SetNetworkACLAnswer execute(SetNetworkACLCommand cmd) { - String[] results = new String[cmd.getRules().length]; + protected List generateConfig(SetNetworkACLCommand cmd) { + LinkedList cfg = new LinkedList<>(); String privateGw = cmd.getAccessDetail(NetworkElementCommand.VPC_PRIVATE_GATEWAY); - try { - String[][] rules = cmd.generateFwRules(); - String[] aclRules = rules[0]; - NicTO nic = cmd.getNic(); - String dev = "eth" + nic.getDeviceId(); - String netmask = Long.toString(NetUtils.getCidrSize(nic.getNetmask())); - StringBuilder sb = new StringBuilder(); + String[][] rules = cmd.generateFwRules(); + String[] aclRules = rules[0]; + NicTO nic = cmd.getNic(); + String dev = "eth" + nic.getDeviceId(); + String netmask = Long.toString(NetUtils.getCidrSize(nic.getNetmask())); + StringBuilder sb = new StringBuilder(); - for (int i = 0; i < aclRules.length; i++) { - sb.append(aclRules[i]).append(','); - } - - String rule = sb.toString(); - ExecutionResult result; - - String args = " -d " + dev; - if (privateGw != null) { - args += " -a " + rule; - result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_privategw_acl.sh", args); - } else { - args += " -i " + nic.getIp(); - args += " -m " + netmask; - args += " -a " + rule; - result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_acl.sh", args); - } - - if (!result.isSuccess()) { - for (int i = 0; i < results.length; i++) { - results[i] = "Failed"; - } - return new SetNetworkACLAnswer(cmd, false, results); - } - - return new SetNetworkACLAnswer(cmd, true, results); - } catch (Exception e) { - String msg = "SetNetworkACL failed due to " + e.toString(); - s_logger.error(msg, e); - return new SetNetworkACLAnswer(cmd, false, results); + for (int i = 0; i < aclRules.length; i++) { + sb.append(aclRules[i]).append(','); } + + String rule = sb.toString(); + + String args = " -d " + dev; + args += " -M " + nic.getMac(); + if (privateGw != null) { + args += " -a " + rule; + + cfg.add(new ConfigItem(VRScripts.VPC_PRIVATEGW_ACL, args)); + } else { + args += " -i " + nic.getIp(); + args += " -m " + netmask; + args += " -a " + rule; + cfg.add(new ConfigItem(VRScripts.VPC_ACL, args)); + } + + return cfg; } - protected SetSourceNatAnswer execute(SetSourceNatCommand cmd) { - String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + protected List generateConfig(SetSourceNatCommand cmd) { + LinkedList cfg = new LinkedList<>(); + IpAddressTO pubIP = cmd.getIpAddress(); String dev = "eth" + pubIP.getNicDevId(); - String args = " -A "; + String args = "-A"; args += " -l "; args += pubIP.getPublicIp(); args += " -c "; args += dev; - ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_snat.sh", args); - return new SetSourceNatAnswer(cmd, result.isSuccess(), result.getDetails()); + + cfg.add(new ConfigItem(VRScripts.VPC_SOURCE_NAT, args)); + return cfg; } - private SetPortForwardingRulesAnswer execute(SetPortForwardingRulesVpcCommand cmd) { - String[] results = new String[cmd.getRules().length]; - int i = 0; + protected List generateConfig(SetPortForwardingRulesVpcCommand cmd) { + LinkedList cfg = new LinkedList<>(); - boolean endResult = true; for (PortForwardingRuleTO rule : cmd.getRules()) { - String args = rule.revoked() ? " -D" : " -A"; + String args = rule.revoked() ? "-D" : "-A"; args += " -P " + rule.getProtocol().toLowerCase(); args += " -l " + rule.getSrcIp(); args += " -p " + rule.getStringSrcPortRange(); args += " -r " + rule.getDstIp(); args += " -d " + rule.getStringDstPortRange().replace(":", "-"); - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "vpc_portforwarding.sh", args); - - if (!result.isSuccess()) { - results[i++] = "Failed"; - endResult = false; - } else { - results[i++] = null; - } + cfg.add(new ConfigItem(VRScripts.VPC_PORTFORWARDING, args)); } - return new SetPortForwardingRulesAnswer(cmd, results, endResult); + + return cfg; } - public IpAssocAnswer execute(IpAssocVpcCommand cmd) { - String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - String[] results = new String[cmd.getIpAddresses().length]; - String args = ""; - String snatArgs = ""; - for (int i = 0; i < cmd.getIpAddresses().length; i ++) { - results[i] = "Failed"; + protected List generateConfig(SetStaticRouteCommand cmd) { + LinkedList cfg = new LinkedList<>(); + + String[][] rules = cmd.generateSRouteRules(); + StringBuilder sb = new StringBuilder(); + String[] srRules = rules[0]; + + for (int i = 0; i < srRules.length; i++) { + sb.append(srRules[i]).append(','); } - int i = 0; - for (IpAddressTO ip : cmd.getIpAddresses()) { - if (ip.isAdd()) { - args += " -A "; - snatArgs += " -A "; - } else { - args += " -D "; - snatArgs += " -D "; - } + String args = " -a " + sb.toString(); - args += " -l "; - args += ip.getPublicIp(); - String nicName = "eth" + ip.getNicDevId(); - args += " -c "; - args += nicName; - args += " -g "; - args += ip.getVlanGateway(); - args += " -m "; - args += Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask())); - args += " -n "; - args += NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask()); + cfg.add(new ConfigItem(VRScripts.VPC_STATIC_ROUTE, args)); + return cfg; + } - ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_ipassoc.sh", args); - if (!result.isSuccess()) { - results[i++] = ip.getPublicIp() + " - vpc_ipassoc failed:" + result.getDetails(); - break; - } + protected List generateConfig(IpAssocCommand cmd) { + LinkedList cfg = new LinkedList<>(); + ConfigItem c; - if (ip.isSourceNat()) { - snatArgs += " -l " + ip.getPublicIp(); - snatArgs += " -c " + nicName; + if (cmd instanceof IpAssocVpcCommand) { + for (IpAddressTO ip : cmd.getIpAddresses()) { + String args = ""; + String snatArgs = ""; - result = _vrDeployer.executeInVR(routerIP, "vpc_privateGateway.sh", snatArgs); - if (result != null) { - results[i++] = ip.getPublicIp() + " - vpc_privateGateway failed:" + result.getDetails(); - break; + if (ip.isAdd()) { + args += " -A "; + snatArgs += " -A "; + } else { + args += " -D "; + snatArgs += " -D "; + } + + args += " -l "; + args += ip.getPublicIp(); + String nicName = "eth" + ip.getNicDevId(); + args += " -c "; + args += nicName; + args += " -g "; + args += ip.getVlanGateway(); + args += " -m "; + args += Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask())); + args += " -n "; + args += NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask()); + + c = new ConfigItem(VRScripts.VPC_IPASSOC, args); + c.setInfo(ip.getPublicIp() + " - vpc_ipassoc"); + cfg.add(c); + + if (ip.isSourceNat()) { + snatArgs += " -l " + ip.getPublicIp(); + snatArgs += " -c " + nicName; + + c = new ConfigItem(VRScripts.VPC_PRIVATEGW, snatArgs); + c.setInfo(ip.getPublicIp() + " - vpc_privategateway"); + cfg.add(c); } } - results[i++] = ip.getPublicIp() + " - success "; - } - return new IpAssocAnswer(cmd, results); - } - - private SetStaticRouteAnswer execute(SetStaticRouteCommand cmd) { - String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); - try { - String[] results = new String[cmd.getStaticRoutes().length]; - String[][] rules = cmd.generateSRouteRules(); - StringBuilder sb = new StringBuilder(); - String[] srRules = rules[0]; - - for (int i = 0; i < srRules.length; i++) { - sb.append(srRules[i]).append(','); - } - - String args = " -a " + sb.toString(); - ExecutionResult result = _vrDeployer.executeInVR(routerIP, "vpc_staticroute.sh", args); - - if (!result.isSuccess()) { - for (int i = 0; i < results.length; i++) { - results[i] = "Failed"; + } else { + for (IpAddressTO ip: cmd.getIpAddresses()) { + String args = ""; + if (ip.isAdd()) { + args += "-A"; + } else { + args += "-D"; } - return new SetStaticRouteAnswer(cmd, false, results); - } + String cidrSize = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask())); + if (ip.isSourceNat()) { + args += " -s"; + } + if (ip.isFirstIP()) { + args += " -f"; + } + args += " -l "; + args += ip.getPublicIp() + "/" + cidrSize; - return new SetStaticRouteAnswer(cmd, true, results); - } catch (Exception e) { - String msg = "SetStaticRoute failed due to " + e.toString(); - s_logger.error(msg, e); - return new SetStaticRouteAnswer(cmd, false, null); - } - } + String publicNic = "eth" + ip.getNicDevId(); + args += " -c "; + args += publicNic; - public Answer execute(IpAssocCommand cmd) { - String[] results = new String[cmd.getIpAddresses().length]; - for (int i = 0; i < results.length; i++) { - results[i] = IpAssocAnswer.errorResult; - } + args += " -g "; + args += ip.getVlanGateway(); - int i = 0; - for (IpAddressTO ip: cmd.getIpAddresses()) { - String args = ""; - if (ip.isAdd()) { - args += "-A"; - } else { - args += "-D"; - } - String cidrSize = Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask())); - if (ip.isSourceNat()) { - args += " -s"; - } - if (ip.isFirstIP()) { - args += " -f"; - } - args += " -l "; - args += ip.getPublicIp() + "/" + cidrSize; + if (ip.isNewNic()) { + args += " -n"; + } - String publicNic = "eth" + ip.getNicDevId(); - args += " -c "; - args += publicNic; - - args += " -g "; - args += ip.getVlanGateway(); - - if (ip.isNewNic()) { - args += " -n"; - } - - ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), "ipassoc.sh", args); - if (result.isSuccess()) { - results[i++] = ip.getPublicIp() + " - success"; - } else { - results[i++] = ip.getPublicIp() + " - failed:" + result.getDetails(); - break; + c = new ConfigItem(VRScripts.IPASSOC, args); + c.setInfo(ip.getPublicIp()); + cfg.add(c); } } - return new IpAssocAnswer(cmd, results); + return cfg; } public boolean configure(final String name, final Map params) throws ConfigurationException { @@ -883,6 +992,8 @@ public class VirtualRoutingResource { if (_vrDeployer == null) { throw new ConfigurationException("Unable to find the resource for VirtualRouterDeployer!"); } + + _vrAggregateCommandsSet = new HashMap<>(); return true; } @@ -961,4 +1072,128 @@ public class VirtualRoutingResource { return false; } + + private List generateCommandCfg(NetworkElementCommand cmd) { + List cfg; + if (cmd instanceof SetPortForwardingRulesVpcCommand) { + cfg = generateConfig((SetPortForwardingRulesVpcCommand)cmd); + } else if (cmd instanceof SetPortForwardingRulesCommand) { + cfg = generateConfig((SetPortForwardingRulesCommand)cmd); + } else if (cmd instanceof SetStaticRouteCommand) { + cfg = generateConfig((SetStaticRouteCommand)cmd); + } else if (cmd instanceof SetStaticNatRulesCommand) { + cfg = generateConfig((SetStaticNatRulesCommand)cmd); + } else if (cmd instanceof LoadBalancerConfigCommand) { + cfg = generateConfig((LoadBalancerConfigCommand)cmd); + } else if (cmd instanceof SavePasswordCommand) { + cfg = generateConfig((SavePasswordCommand)cmd); + } else if (cmd instanceof DhcpEntryCommand) { + cfg = generateConfig((DhcpEntryCommand)cmd); + } else if (cmd instanceof CreateIpAliasCommand) { + cfg = generateConfig((CreateIpAliasCommand)cmd); + } else if (cmd instanceof DnsMasqConfigCommand) { + cfg = generateConfig((DnsMasqConfigCommand)cmd); + } else if (cmd instanceof DeleteIpAliasCommand) { + cfg = generateConfig((DeleteIpAliasCommand)cmd); + } else if (cmd instanceof VmDataCommand) { + cfg = generateConfig((VmDataCommand)cmd); + } else if (cmd instanceof SetFirewallRulesCommand) { + cfg = generateConfig((SetFirewallRulesCommand)cmd); + } else if (cmd instanceof BumpUpPriorityCommand) { + cfg = generateConfig((BumpUpPriorityCommand)cmd); + } else if (cmd instanceof RemoteAccessVpnCfgCommand) { + cfg = generateConfig((RemoteAccessVpnCfgCommand)cmd); + } else if (cmd instanceof VpnUsersCfgCommand) { + cfg = generateConfig((VpnUsersCfgCommand)cmd); + } else if (cmd instanceof Site2SiteVpnCfgCommand) { + cfg = generateConfig((Site2SiteVpnCfgCommand)cmd); + } else if (cmd instanceof SetMonitorServiceCommand) { + cfg = generateConfig((SetMonitorServiceCommand)cmd); + } else if (cmd instanceof SetupGuestNetworkCommand) { + cfg = generateConfig((SetupGuestNetworkCommand)cmd); + } else if (cmd instanceof SetNetworkACLCommand) { + cfg = generateConfig((SetNetworkACLCommand)cmd); + } else if (cmd instanceof SetSourceNatCommand) { + cfg = generateConfig((SetSourceNatCommand)cmd); + } else if (cmd instanceof IpAssocCommand) { + cfg = generateConfig((IpAssocCommand)cmd); + } else { + return null; + } + return cfg; + } + + private Answer execute(AggregationControlCommand cmd) { + Action action = cmd.getAction(); + String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + assert routerName != null; + assert cmd.getRouterAccessIp() != null; + + if (action == Action.Start) { + assert (!_vrAggregateCommandsSet.containsKey(routerName)); + + Queue queue = new LinkedBlockingQueue<>(); + _vrAggregateCommandsSet.put(routerName, queue); + return new Answer(cmd); + } else if (action == Action.Finish) { + Queue queue = _vrAggregateCommandsSet.get(routerName); + int answerCounts = 0; + try { + StringBuilder sb = new StringBuilder(); + sb.append("#Apache CloudStack Virtual Router Config File\n"); + sb.append("\n" + _cfgVersion + "\n\n"); + for (NetworkElementCommand command : queue) { + answerCounts += command.getAnswersCount(); + List cfg = generateCommandCfg(command); + if (cfg == null) { + s_logger.warn("Unknown commands for VirtualRoutingResource, but continue: " + cmd.toString()); + continue; + } + + for (ConfigItem c : cfg) { + if (c.isFile()) { + sb.append("\n"); + sb.append(c.getFilePath() + c.getFileName() + "\n"); + sb.append(c.getFileContents() + "\n"); + sb.append("\n"); + } else { + sb.append("\n"); + } + } + } + String cfgFilePath = "/var/cache/cloud/"; + String cfgFileName = "VR-"+ UUID.randomUUID().toString() + ".cfg"; + ExecutionResult result = _vrDeployer.createFileInVR(cmd.getRouterAccessIp(), cfgFilePath, cfgFileName, sb.toString()); + if (!result.isSuccess()) { + return new Answer(cmd, false, result.getDetails()); + } + + // 3 second for each answer should be enough, and 120s is the minimal timeout + int timeout = answerCounts * 3; + if (timeout < 120) { + timeout = 120; + } + result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), VRScripts.VR_CFG, "-c " + cfgFilePath + cfgFileName, timeout); + if (!result.isSuccess()) { + return new Answer(cmd, false, result.getDetails()); + } + return new Answer(cmd); + } finally { + queue.clear(); + _vrAggregateCommandsSet.remove(routerName); + } + } else if (action == Action.Cleanup) { + assert (_vrAggregateCommandsSet.containsKey(routerName)); + Queue queue = _vrAggregateCommandsSet.get(routerName); + if (queue != null) { + queue.clear(); + } + _vrAggregateCommandsSet.remove(routerName); + + return new Answer(cmd); + } + return new Answer(cmd, false, "Fail to recongize aggregation action " + action.toString()); + } } diff --git a/core/src/com/cloud/info/ConsoleProxyInfo.java b/core/src/com/cloud/info/ConsoleProxyInfo.java index 9a94474efda..0e57b7551fc 100644 --- a/core/src/com/cloud/info/ConsoleProxyInfo.java +++ b/core/src/com/cloud/info/ConsoleProxyInfo.java @@ -32,16 +32,17 @@ public class ConsoleProxyInfo { this.sslEnabled = sslEnabled; if (sslEnabled) { - StringBuffer sb = new StringBuffer(proxyIpAddress); - for (int i = 0; i < sb.length(); i++) - if (sb.charAt(i) == '.') - sb.setCharAt(i, '-'); - if (consoleProxyUrlDomain != null && consoleProxyUrlDomain.length() > 0) { - sb.append("."); + StringBuffer sb = new StringBuffer(); + if (consoleProxyUrlDomain.startsWith("*")) { + sb.append(proxyIpAddress); + for (int i = 0; i < proxyIpAddress.length(); i++) + if (sb.charAt(i) == '.') + sb.setCharAt(i, '-'); + sb.append(consoleProxyUrlDomain.substring(1));//skip the * + } else { + //LB address sb.append(consoleProxyUrlDomain); - } else - sb.append(".realhostip.com"); - + } proxyAddress = sb.toString(); proxyPort = port; this.proxyUrlPort = proxyUrlPort; diff --git a/core/src/org/apache/cloudstack/storage/command/AttachCommand.java b/core/src/org/apache/cloudstack/storage/command/AttachCommand.java index 7e47ba4e317..303457b4a4b 100644 --- a/core/src/org/apache/cloudstack/storage/command/AttachCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/AttachCommand.java @@ -24,6 +24,7 @@ import com.cloud.agent.api.to.DiskTO; public final class AttachCommand extends Command implements StorageSubSystemCommand { private DiskTO disk; private String vmName; + private boolean inSeq = false; public AttachCommand(DiskTO disk, String vmName) { super(); @@ -51,4 +52,9 @@ public final class AttachCommand extends Command implements StorageSubSystemComm public void setVmName(String vmName) { this.vmName = vmName; } + + @Override + public void setExecuteInSequence(boolean inSeq) { + this.inSeq = inSeq; + } } diff --git a/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java index 2083876b567..25679ba28c4 100644 --- a/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java +++ b/core/src/org/apache/cloudstack/storage/command/AttachPrimaryDataStoreCmd.java @@ -21,6 +21,11 @@ package org.apache.cloudstack.storage.command; import com.cloud.agent.api.Command; public final class AttachPrimaryDataStoreCmd extends Command implements StorageSubSystemCommand { + @Override + public void setExecuteInSequence(boolean inSeq) { + + } + private final String dataStore; public AttachPrimaryDataStoreCmd(String uri) { diff --git a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java index 446c61f9a7b..96822a4ff29 100644 --- a/core/src/org/apache/cloudstack/storage/command/CopyCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/CopyCommand.java @@ -78,4 +78,8 @@ public final class CopyCommand extends Command implements StorageSubSystemComman return options; } + @Override + public void setExecuteInSequence(boolean inSeq) { + this.executeInSequence = inSeq; + } } diff --git a/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java b/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java index 121a7ee449c..8c239b53047 100644 --- a/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/CreateObjectCommand.java @@ -42,4 +42,8 @@ public final class CreateObjectCommand extends Command implements StorageSubSyst return this.data; } + @Override + public void setExecuteInSequence(boolean inSeq) { + + } } diff --git a/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java b/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java index b536028927f..21716cf1113 100644 --- a/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java +++ b/core/src/org/apache/cloudstack/storage/command/CreatePrimaryDataStoreCmd.java @@ -35,4 +35,8 @@ public final class CreatePrimaryDataStoreCmd extends Command implements StorageS return false; } + @Override + public void setExecuteInSequence(boolean inSeq) { + + } } diff --git a/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java b/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java index 76696da30ae..74450507631 100644 --- a/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/DeleteCommand.java @@ -42,4 +42,8 @@ public final class DeleteCommand extends Command implements StorageSubSystemComm return this.data; } + @Override + public void setExecuteInSequence(boolean inSeq) { + + } } diff --git a/core/src/org/apache/cloudstack/storage/command/DettachCommand.java b/core/src/org/apache/cloudstack/storage/command/DettachCommand.java index 61cb88b284a..1e501d9600d 100644 --- a/core/src/org/apache/cloudstack/storage/command/DettachCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/DettachCommand.java @@ -87,4 +87,9 @@ public class DettachCommand extends Command implements StorageSubSystemCommand { public int getStoragePort() { return _storagePort; } + + @Override + public void setExecuteInSequence(boolean inSeq) { + + } } diff --git a/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java b/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java index ffee0ab9216..981a0981024 100644 --- a/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java +++ b/core/src/org/apache/cloudstack/storage/command/ForgetObjectCmd.java @@ -36,4 +36,9 @@ public class ForgetObjectCmd extends Command implements StorageSubSystemCommand public boolean executeInSequence() { return false; } + + @Override + public void setExecuteInSequence(boolean inSeq) { + + } } diff --git a/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java b/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java index c6c6d23726d..b463b2c5f03 100644 --- a/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java +++ b/core/src/org/apache/cloudstack/storage/command/IntroduceObjectCmd.java @@ -36,4 +36,9 @@ public class IntroduceObjectCmd extends Command implements StorageSubSystemComma public boolean executeInSequence() { return false; } + + @Override + public void setExecuteInSequence(boolean inSeq) { + + } } diff --git a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java index d14161ae4c5..fb7b3736844 100644 --- a/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java +++ b/core/src/org/apache/cloudstack/storage/command/StorageSubSystemCommand.java @@ -19,5 +19,5 @@ package org.apache.cloudstack.storage.command; public interface StorageSubSystemCommand { - + void setExecuteInSequence(boolean inSeq); } diff --git a/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java b/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java index 01c05f004f9..29e53b0d958 100644 --- a/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java +++ b/core/src/org/apache/cloudstack/storage/to/PrimaryDataStoreTO.java @@ -16,6 +16,8 @@ // under the License. package org.apache.cloudstack.storage.to; +import java.util.Map; + import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; import com.cloud.agent.api.to.DataStoreTO; @@ -23,6 +25,17 @@ import com.cloud.storage.DataStoreRole; import com.cloud.storage.Storage.StoragePoolType; public class PrimaryDataStoreTO implements DataStoreTO { + public static final String MANAGED = PrimaryDataStore.MANAGED; + public static final String STORAGE_HOST = PrimaryDataStore.STORAGE_HOST; + public static final String STORAGE_PORT = PrimaryDataStore.STORAGE_PORT; + public static final String MANAGED_STORE_TARGET = PrimaryDataStore.MANAGED_STORE_TARGET; + public static final String MANAGED_STORE_TARGET_ROOT_VOLUME = PrimaryDataStore.MANAGED_STORE_TARGET_ROOT_VOLUME; + public static final String CHAP_INITIATOR_USERNAME = PrimaryDataStore.CHAP_INITIATOR_USERNAME; + public static final String CHAP_INITIATOR_SECRET = PrimaryDataStore.CHAP_INITIATOR_SECRET; + public static final String CHAP_TARGET_USERNAME = PrimaryDataStore.CHAP_TARGET_USERNAME; + public static final String CHAP_TARGET_SECRET = PrimaryDataStore.CHAP_TARGET_SECRET; + public static final String VOLUME_SIZE = PrimaryDataStore.VOLUME_SIZE; + private final String uuid; private final String name; private String type; @@ -32,6 +45,7 @@ public class PrimaryDataStoreTO implements DataStoreTO { private String path; private int port; private final String url; + private Map details; public PrimaryDataStoreTO(PrimaryDataStore dataStore) { this.uuid = dataStore.getUuid(); @@ -42,6 +56,7 @@ public class PrimaryDataStoreTO implements DataStoreTO { this.setPath(dataStore.getPath()); this.setPort(dataStore.getPort()); this.url = dataStore.getUri(); + this.details = dataStore.getDetails(); } public long getId() { @@ -58,6 +73,10 @@ public class PrimaryDataStoreTO implements DataStoreTO { return this.url; } + public Map getDetails() { + return this.details; + } + public String getName() { return this.name; } diff --git a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java new file mode 100644 index 00000000000..531c71854dd --- /dev/null +++ b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java @@ -0,0 +1,1095 @@ +// 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.resource.virtualnetwork; + +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.BumpUpPriorityCommand; +import com.cloud.agent.api.SetupGuestNetworkCommand; +import com.cloud.agent.api.routing.AggregationControlCommand; +import com.cloud.agent.api.routing.AggregationControlCommand.Action; +import com.cloud.agent.api.routing.CreateIpAliasCommand; +import com.cloud.agent.api.routing.DeleteIpAliasCommand; +import com.cloud.agent.api.routing.DhcpEntryCommand; +import com.cloud.agent.api.routing.DnsMasqConfigCommand; +import com.cloud.agent.api.routing.GroupAnswer; +import com.cloud.agent.api.routing.IpAliasTO; +import com.cloud.agent.api.routing.IpAssocCommand; +import com.cloud.agent.api.routing.IpAssocVpcCommand; +import com.cloud.agent.api.routing.LoadBalancerConfigCommand; +import com.cloud.agent.api.routing.NetworkElementCommand; +import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand; +import com.cloud.agent.api.routing.SavePasswordCommand; +import com.cloud.agent.api.routing.SetFirewallRulesCommand; +import com.cloud.agent.api.routing.SetMonitorServiceCommand; +import com.cloud.agent.api.routing.SetNetworkACLCommand; +import com.cloud.agent.api.routing.SetPortForwardingRulesCommand; +import com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand; +import com.cloud.agent.api.routing.SetSourceNatCommand; +import com.cloud.agent.api.routing.SetStaticNatRulesCommand; +import com.cloud.agent.api.routing.SetStaticRouteCommand; +import com.cloud.agent.api.routing.Site2SiteVpnCfgCommand; +import com.cloud.agent.api.routing.VmDataCommand; +import com.cloud.agent.api.routing.VpnUsersCfgCommand; +import com.cloud.agent.api.to.DhcpTO; +import com.cloud.agent.api.to.FirewallRuleTO; +import com.cloud.agent.api.to.IpAddressTO; +import com.cloud.agent.api.to.LoadBalancerTO; +import com.cloud.agent.api.to.MonitorServiceTO; +import com.cloud.agent.api.to.NetworkACLTO; +import com.cloud.agent.api.to.NicTO; +import com.cloud.agent.api.to.PortForwardingRuleTO; +import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource.VRScripts; +import com.cloud.network.lb.LoadBalancingRule.LbDestination; +import com.cloud.network.rules.FirewallRule.Purpose; +import com.cloud.network.vpc.NetworkACLItem.TrafficType; +import com.cloud.network.vpc.VpcGateway; +import com.cloud.utils.ExecutionResult; +import com.cloud.utils.net.NetUtils; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import javax.naming.ConfigurationException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(loader = AnnotationConfigContextLoader.class) +public class VirtualRoutingResourceTest implements VirtualRouterDeployer { + VirtualRoutingResource _resource; + NetworkElementCommand _currentCmd; + int _count; + String _file; + + String ROUTERIP = "169.254.3.4"; + String ROUTERGUESTIP = "10.200.1.1"; + String ROUTERNAME = "r-4-VM"; + + @Override + public ExecutionResult executeInVR(String routerIp, String script, String args) { + return executeInVR(routerIp, script, args, 60); + } + + @Override + public ExecutionResult executeInVR(String routerIp, String script, String args, int timeout) { + assertEquals(routerIp, ROUTERIP); + verifyCommand(_currentCmd, script, args); + return new ExecutionResult(true, null); + } + + @Override + public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) { + assertEquals(routerIp, ROUTERIP); + verifyFile(_currentCmd, path, filename, content); + return new ExecutionResult(true, null); + } + + @Override + public ExecutionResult prepareCommand(NetworkElementCommand cmd) { + cmd.setRouterAccessIp(ROUTERIP); + _currentCmd = cmd; + if (cmd instanceof IpAssocVpcCommand) { + return prepareNetworkElementCommand((IpAssocVpcCommand)cmd); + } else if (cmd instanceof IpAssocCommand) { + return prepareNetworkElementCommand((IpAssocCommand)cmd); + } else if (cmd instanceof SetupGuestNetworkCommand) { + return prepareNetworkElementCommand((SetupGuestNetworkCommand)cmd); + } else if (cmd instanceof SetSourceNatCommand) { + return prepareNetworkElementCommand((SetSourceNatCommand)cmd); + } else if (cmd instanceof SetNetworkACLCommand) { + return prepareNetworkElementCommand((SetNetworkACLCommand)cmd); + } + return new ExecutionResult(true, null); + } + + @Override + public ExecutionResult cleanupCommand(NetworkElementCommand cmd) { + return new ExecutionResult(true, null); + } + + @Before + public void setup() { + _resource = new VirtualRoutingResource(this); + try { + _resource.configure("VRResource", new HashMap()); + } catch (ConfigurationException e) { + e.printStackTrace(); + } + } + + private void verifyFile(NetworkElementCommand cmd, String path, String filename, String content) { + if (cmd instanceof AggregationControlCommand) { + verifyFile((AggregationControlCommand)cmd, path, filename, content); + } else if (cmd instanceof LoadBalancerConfigCommand) { + verifyFile((LoadBalancerConfigCommand)cmd, path, filename, content); + } + } + + protected void verifyCommand(NetworkElementCommand cmd, String script, String args) { + if (cmd instanceof SetPortForwardingRulesVpcCommand) { + verifyArgs((SetPortForwardingRulesVpcCommand) cmd, script, args); + } else if (cmd instanceof SetPortForwardingRulesCommand) { + verifyArgs((SetPortForwardingRulesCommand) cmd, script, args); + } else if (cmd instanceof SetStaticRouteCommand) { + verifyArgs((SetStaticRouteCommand) cmd, script, args); + } else if (cmd instanceof SetStaticNatRulesCommand) { + verifyArgs((SetStaticNatRulesCommand) cmd, script, args); + } else if (cmd instanceof LoadBalancerConfigCommand) { + verifyArgs((LoadBalancerConfigCommand) cmd, script, args); + } else if (cmd instanceof SavePasswordCommand) { + verifyArgs((SavePasswordCommand)cmd, script, args); + } else if (cmd instanceof DhcpEntryCommand) { + verifyArgs((DhcpEntryCommand)cmd, script, args); + } else if (cmd instanceof CreateIpAliasCommand) { + verifyArgs((CreateIpAliasCommand)cmd, script, args); + } else if (cmd instanceof DnsMasqConfigCommand) { + verifyArgs((DnsMasqConfigCommand)cmd, script, args); + } else if (cmd instanceof DeleteIpAliasCommand) { + verifyArgs((DeleteIpAliasCommand)cmd, script, args); + } else if (cmd instanceof VmDataCommand) { + verifyArgs((VmDataCommand)cmd, script, args); + } else if (cmd instanceof SetFirewallRulesCommand) { + verifyArgs((SetFirewallRulesCommand)cmd, script, args); + } else if (cmd instanceof BumpUpPriorityCommand) { + verifyArgs((BumpUpPriorityCommand)cmd, script, args); + } else if (cmd instanceof RemoteAccessVpnCfgCommand) { + verifyArgs((RemoteAccessVpnCfgCommand)cmd, script, args); + } else if (cmd instanceof VpnUsersCfgCommand) { + verifyArgs((VpnUsersCfgCommand)cmd, script, args); + } else if (cmd instanceof Site2SiteVpnCfgCommand) { + verifyArgs((Site2SiteVpnCfgCommand)cmd, script, args); + } else if (cmd instanceof SetMonitorServiceCommand) { + verifyArgs((SetMonitorServiceCommand)cmd, script, args); + } else if (cmd instanceof SetupGuestNetworkCommand) { + verifyArgs((SetupGuestNetworkCommand)cmd, script, args); + } else if (cmd instanceof SetNetworkACLCommand) { + verifyArgs((SetNetworkACLCommand)cmd, script, args); + } else if (cmd instanceof SetSourceNatCommand) { + verifyArgs((SetSourceNatCommand)cmd, script, args); + } else if (cmd instanceof IpAssocCommand) { + verifyArgs((IpAssocCommand)cmd, script, args); + } + + if (cmd instanceof AggregationControlCommand) { + verifyArgs((AggregationControlCommand)cmd, script, args); + } + } + + private void verifyArgs(VpnUsersCfgCommand cmd, String script, String args) { + //To change body of created methods use File | Settings | File Templates. + } + + private void verifyArgs(SetStaticRouteCommand cmd, String script, String args) { + //To change body of created methods use File | Settings | File Templates. + } + + private void verifyArgs(SetStaticNatRulesCommand cmd, String script, String args) { + //To change body of created methods use File | Settings | File Templates. + } + + @Test + public void testBumpUpCommand() { + BumpUpPriorityCommand cmd = new BumpUpPriorityCommand(); + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + } + + private void verifyArgs(BumpUpPriorityCommand cmd, String script, String args) { + assertEquals(script, VRScripts.RVR_BUMPUP_PRI); + assertEquals(args, null); + } + + @Test + public void testSetPortForwardingRulesVpcCommand() { + SetPortForwardingRulesVpcCommand cmd = generateSetPortForwardingRulesVpcCommand(); + + // Reset rule check count + _count = 0; + + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer instanceof GroupAnswer); + assertEquals(((GroupAnswer) answer).getResults().length, 2); + assertTrue(answer.getResult()); + } + + protected SetPortForwardingRulesVpcCommand generateSetPortForwardingRulesVpcCommand() { + List pfRules = new ArrayList<>(); + pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false)); + pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false)); + SetPortForwardingRulesVpcCommand cmd = new SetPortForwardingRulesVpcCommand(pfRules); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + assertEquals(cmd.getAnswersCount(), 2); + return cmd; + } + + private void verifyArgs(SetPortForwardingRulesVpcCommand cmd, String script, String args) { + assertTrue(script.equals(VRScripts.VPC_PORTFORWARDING)); + _count ++; + switch (_count) { + case 1: + assertEquals(args, "-A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22-80"); + break; + case 2: + assertEquals(args, "-D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080-8080"); + break; + default: + fail("Failed to recongize the match!"); + } + } + + @Test + public void testSetPortForwardingRulesCommand() { + SetPortForwardingRulesCommand cmd = generateSetPortForwardingRulesCommand(); + // Reset rule check count + _count = 0; + + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer instanceof GroupAnswer); + assertEquals(((GroupAnswer) answer).getResults().length, 2); + assertTrue(answer.getResult()); + } + + protected SetPortForwardingRulesCommand generateSetPortForwardingRulesCommand() { + List pfRules = new ArrayList<>(); + pfRules.add(new PortForwardingRuleTO(1, "64.1.1.10", 22, 80, "10.10.1.10", 22, 80, "TCP", false, false)); + pfRules.add(new PortForwardingRuleTO(2, "64.1.1.11", 8080, 8080, "10.10.1.11", 8080, 8080, "UDP", true, false)); + SetPortForwardingRulesCommand cmd = new SetPortForwardingRulesCommand(pfRules); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + assertEquals(cmd.getAnswersCount(), 2); + return cmd; + } + + private void verifyArgs(SetPortForwardingRulesCommand cmd, String script, String args) { + assertTrue(script.equals(VRScripts.FIREWALL_NAT)); + _count ++; + switch (_count) { + case 1: + assertEquals(args, "-A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22:80"); + break; + case 2: + assertEquals(args, "-D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080:8080"); + break; + default: + fail("Failed to recongize the match!"); + } + } + + @Test + public void testIpAssocCommand() { + IpAssocCommand cmd = generateIpAssocCommand(); + _count = 0; + + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer instanceof GroupAnswer); + assertEquals(((GroupAnswer) answer).getResults().length, 3); + assertTrue(answer.getResult()); + + } + + private ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) { + IpAddressTO[] ips = cmd.getIpAddresses(); + for (IpAddressTO ip : ips) { + ip.setNicDevId(2); + } + return new ExecutionResult(true, null); + } + + protected IpAssocCommand generateIpAssocCommand() { + List ips = new ArrayList<>(); + ips.add(new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false)); + ips.add(new IpAddressTO(2, "64.1.1.11", false, false, false, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false)); + ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false)); + IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]); + IpAssocCommand cmd = new IpAssocCommand(ipArray); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + assertEquals(cmd.getAnswersCount(), 3); + + return cmd; + } + + @Test + public void testIpAssocVpcCommand() { + IpAssocVpcCommand cmd = generateIpAssocVpcCommand(); + _count = 0; + + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer instanceof GroupAnswer); + assertEquals(((GroupAnswer) answer).getResults().length, 6); + assertTrue(answer.getResult()); + + } + + private ExecutionResult prepareNetworkElementCommand(IpAssocVpcCommand cmd) { + IpAddressTO[] ips = cmd.getIpAddresses(); + for (IpAddressTO ip : ips) { + ip.setNicDevId(2); + } + return new ExecutionResult(true, null); + } + + protected IpAssocVpcCommand generateIpAssocVpcCommand() { + List ips = new ArrayList(); + ips.add(new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false)); + ips.add(new IpAddressTO(2, "64.1.1.11", false, false, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false)); + ips.add(new IpAddressTO(3, "65.1.1.11", true, false, false, "vlan://65", "65.1.1.1", "255.255.255.0", "11:23:45:67:89:AB", 1000, false)); + IpAddressTO[] ipArray = ips.toArray(new IpAddressTO[ips.size()]); + IpAssocVpcCommand cmd = new IpAssocVpcCommand(ipArray); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + assertEquals(cmd.getAnswersCount(), 6); + + return cmd; + } + + private void verifyArgs(IpAssocCommand cmd, String script, String args) { + if (cmd instanceof IpAssocVpcCommand) { + _count ++; + switch (_count) { + case 1: + assertEquals(script, VRScripts.VPC_IPASSOC); + assertEquals(args, " -A -l 64.1.1.10 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0"); + break; + case 2: + assertEquals(script, VRScripts.VPC_PRIVATEGW); + assertEquals(args, " -A -l 64.1.1.10 -c eth2"); + break; + case 3: + assertEquals(script, VRScripts.VPC_IPASSOC); + assertEquals(args, " -D -l 64.1.1.11 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0"); + break; + case 4: + assertEquals(script, VRScripts.VPC_PRIVATEGW); + assertEquals(args, " -D -l 64.1.1.11 -c eth2"); + break; + case 5: + assertEquals(script, VRScripts.VPC_IPASSOC); + assertEquals(args, " -A -l 65.1.1.11 -c eth2 -g 65.1.1.1 -m 24 -n 65.1.1.0"); + break; + default: + fail("Failed to recongize the match!"); + } + } else { + assertEquals(script, VRScripts.IPASSOC); + _count ++; + switch (_count) { + case 1: + assertEquals(args, "-A -s -f -l 64.1.1.10/24 -c eth2 -g 64.1.1.1"); + break; + case 2: + assertEquals(args, "-D -l 64.1.1.11/24 -c eth2 -g 64.1.1.1"); + break; + case 3: + assertEquals(args, "-A -l 65.1.1.11/24 -c eth2 -g 65.1.1.1"); + break; + default: + fail("Failed to recongize the match!"); + } + } + } + + @Test + public void testSourceNatCommand() { + SetSourceNatCommand cmd = generateSetSourceNatCommand(); + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + } + + private ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) { + IpAddressTO ip = cmd.getIpAddress(); + ip.setNicDevId(1); + return new ExecutionResult(true, null); + } + + protected SetSourceNatCommand generateSetSourceNatCommand() { + IpAddressTO ip = new IpAddressTO(1, "64.1.1.10", true, true, true, "vlan://64", "64.1.1.1", "255.255.255.0", "01:23:45:67:89:AB", 1000, false); + SetSourceNatCommand cmd = new SetSourceNatCommand(ip, true); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + return cmd; + } + + private void verifyArgs(SetSourceNatCommand cmd, String script, String args) { + assertEquals(script, VRScripts.VPC_SOURCE_NAT); + assertEquals(args, "-A -l 64.1.1.10 -c eth1"); + } + + @Test + public void testNetworkACLCommand() { + SetNetworkACLCommand cmd = generateSetNetworkACLCommand(); + _count = 0; + + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + + cmd.setAccessDetail(NetworkElementCommand.VPC_PRIVATE_GATEWAY, String.valueOf(VpcGateway.Type.Private)); + answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + } + + protected SetNetworkACLCommand generateSetNetworkACLCommand() { + List acls = new ArrayList<>(); + List cidrs = new ArrayList<>(); + cidrs.add("192.168.0.1/24"); + cidrs.add("192.168.0.2/24"); + acls.add(new NetworkACLTO(1, "64", "TCP", 20, 80, false, false, cidrs, 0, 0, TrafficType.Ingress, true, 1)); + acls.add(new NetworkACLTO(2, "64", "ICMP", 0, 0, false, false, cidrs, -1, -1, TrafficType.Ingress, false, 2)); + acls.add(new NetworkACLTO(3, "65", "ALL", 0, 0, false, false, cidrs, -1, -1, TrafficType.Egress, true, 3)); + NicTO nic = new NicTO(); + nic.setMac("01:23:45:67:89:AB"); + nic.setIp("192.168.1.1"); + nic.setNetmask("255.255.255.0"); + SetNetworkACLCommand cmd = new SetNetworkACLCommand(acls, nic); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + + return cmd; + } + + private void verifyArgs(SetNetworkACLCommand cmd, String script, String args) { + _count ++; + switch (_count) { + case 1: + assertEquals(script, VRScripts.VPC_ACL); + assertEquals(args, " -d eth3 -M 01:23:45:67:89:AB -i 192.168.1.1 -m 24 -a Egress:ALL:0:0:192.168.0.1/24-192.168.0.2/24:ACCEPT:," + + "Ingress:ICMP:0:0:192.168.0.1/24-192.168.0.2/24:DROP:,Ingress:TCP:20:80:192.168.0.1/24-192.168.0.2/24:ACCEPT:,"); + break; + case 2: + assertEquals(script, VRScripts.VPC_PRIVATEGW_ACL); + assertEquals(args, " -d eth3 -M 01:23:45:67:89:AB -a Egress:ALL:0:0:192.168.0.1/24-192.168.0.2/24:ACCEPT:," + + "Ingress:ICMP:0:0:192.168.0.1/24-192.168.0.2/24:DROP:,Ingress:TCP:20:80:192.168.0.1/24-192.168.0.2/24:ACCEPT:,"); + break; + default: + fail(); + } + } + + private ExecutionResult prepareNetworkElementCommand(SetNetworkACLCommand cmd) { + NicTO nic = cmd.getNic(); + nic.setDeviceId(3); + return new ExecutionResult(true, null); + } + + @Test + public void testSetupGuestNetworkCommand() { + SetupGuestNetworkCommand cmd = generateSetupGuestNetworkCommand(); + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + } + + private ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cmd) { + NicTO nic = cmd.getNic(); + nic.setDeviceId(4); + return new ExecutionResult(true, null); + } + + protected SetupGuestNetworkCommand generateSetupGuestNetworkCommand() { + NicTO nic = new NicTO(); + nic.setMac("01:23:45:67:89:AB"); + nic.setIp("10.1.1.1"); + nic.setNetmask("255.255.255.0"); + + SetupGuestNetworkCommand cmd = new SetupGuestNetworkCommand("10.1.1.10-10.1.1.20", "cloud.test", false, 0, "8.8.8.8", "8.8.4.4", true, nic); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, "10.1.1.2"); + cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "10.1.1.1"); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + + return cmd; + } + + private void verifyArgs(SetupGuestNetworkCommand cmd, String script, String args) { + assertEquals(script, VRScripts.VPC_GUEST_NETWORK); + assertEquals(args, " -C -M 01:23:45:67:89:AB -d eth4 -i 10.1.1.2 -g 10.1.1.1 -m 24 -n 10.1.1.0 -s 8.8.8.8,8.8.4.4 -e cloud.test"); + } + + @Test + public void testSetMonitorServiceCommand() { + SetMonitorServiceCommand cmd = generateSetMonitorServiceCommand(); + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + } + + protected SetMonitorServiceCommand generateSetMonitorServiceCommand() { + List services = new ArrayList<>(); + services.add(new MonitorServiceTO("service", "process", "name", "path", "file", true)); + services.add(new MonitorServiceTO("service_2", "process_2", "name_2", "path_2", "file_2", false)); + + SetMonitorServiceCommand cmd = new SetMonitorServiceCommand(services); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + + return cmd; + } + + private void verifyArgs(SetMonitorServiceCommand cmd, String script, String args) { + assertEquals(script, VRScripts.MONITOR_SERVICE); + assertEquals(args, " -c [service]:processname=process:servicename=name:pidfile=file:,[service_2]:processname=process_2:servicename=name_2:pidfile=file_2:,"); + } + + @Test + public void testSite2SiteVpnCfgCommand() { + _count = 0; + + Site2SiteVpnCfgCommand cmd = new Site2SiteVpnCfgCommand(true, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), true, false); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + + cmd = new Site2SiteVpnCfgCommand(true, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), false, true); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + + cmd = new Site2SiteVpnCfgCommand(false, "64.10.1.10", "64.10.1.1", "192.168.1.1/16", "124.10.1.10", "192.168.100.1/24", "3des-sha1,aes128-sha1;modp1536", "3des-sha1,aes128-md5", "psk", Long.valueOf(1800), Long.valueOf(1800), false, true); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + } + + private void verifyArgs(Site2SiteVpnCfgCommand cmd, String script, String args) { + _count ++; + + assertEquals(script, VRScripts.S2SVPN_IPSEC); + switch (_count) { + case 1: + assertEquals(args, "-A -l 64.10.1.10 -n 192.168.1.1/16 -g 64.10.1.1 -r 124.10.1.10 -N 192.168.100.1/24 -e \"3des-sha1,aes128-md5\" -i \"3des-sha1,aes128-sha1;modp1536\" -t 1800 -T 1800 -s \"psk\" -d 1"); + break; + case 2: + assertEquals(args, "-A -l 64.10.1.10 -n 192.168.1.1/16 -g 64.10.1.1 -r 124.10.1.10 -N 192.168.100.1/24 -e \"3des-sha1,aes128-md5\" -i \"3des-sha1,aes128-sha1;modp1536\" -t 1800 -T 1800 -s \"psk\" -d 0 -p "); + break; + case 3: + assertEquals(args, "-D -r 124.10.1.10 -n 192.168.1.1/16 -N 192.168.100.1/24"); + break; + default: + fail(); + } + } + + @Test + public void testRemoteAccessVpnCfgCommand() { + _count = 0; + + Answer answer = _resource.executeRequest(generateRemoteAccessVpnCfgCommand1()); + assertTrue(answer.getResult()); + + answer = _resource.executeRequest(generateRemoteAccessVpnCfgCommand2()); + assertTrue(answer.getResult()); + + answer = _resource.executeRequest(generateRemoteAccessVpnCfgCommand3()); + assertTrue(answer.getResult()); + } + + protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand1() { + RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + cmd.setLocalCidr("10.1.1.1/24"); + return cmd; + } + + protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand2() { + RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(false, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", false); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + cmd.setLocalCidr("10.1.1.1/24"); + return cmd; + } + + protected RemoteAccessVpnCfgCommand generateRemoteAccessVpnCfgCommand3() { + RemoteAccessVpnCfgCommand cmd = new RemoteAccessVpnCfgCommand(true, "124.10.10.10", "10.10.1.1", "10.10.1.10-10.10.1.20", "sharedkey", true); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + cmd.setLocalCidr("10.1.1.1/24"); + return cmd; + } + + private void verifyArgs(RemoteAccessVpnCfgCommand cmd, String script, String args) { + _count ++; + + assertEquals(script, VRScripts.VPN_L2TP); + switch (_count) { + case 1: + assertEquals(args, "-r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c -C 10.1.1.1/24 -i eth2"); + break; + case 2: + assertEquals(args, "-d -s 124.10.10.10 -C 10.1.1.1/24 -i eth2"); + break; + case 3: + assertEquals(args, "-r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c -C 10.1.1.1/24 -i eth1"); + break; + default: + fail(); + + } + } + + @Test + public void testFirewallRulesCommand() { + _count = 0; + + Answer answer = _resource.executeRequest(generateSetFirewallRulesCommand()); + assertTrue(answer.getResult()); + assertTrue(answer instanceof GroupAnswer); + assertEquals(((GroupAnswer) answer).getResults().length, 3); + + //TODO Didn't test egress rule because not able to generate FirewallRuleVO object + } + + protected SetFirewallRulesCommand generateSetFirewallRulesCommand() { + List rules = new ArrayList<>(); + List sourceCidrs = new ArrayList<>(); + sourceCidrs.add("10.10.1.1/24"); + sourceCidrs.add("10.10.1.2/24"); + rules.add(new FirewallRuleTO(1, "64.10.10.10", "TCP", 22, 80, false, false, Purpose.Firewall, sourceCidrs, 0, 0)); + rules.add(new FirewallRuleTO(2, "64.10.10.10", "ICMP", 0, 0, false, false, Purpose.Firewall, sourceCidrs, -1, -1)); + rules.add(new FirewallRuleTO(3, "64.10.10.10", "ICMP", 0, 0, true, true, Purpose.Firewall, sourceCidrs, -1, -1)); + SetFirewallRulesCommand cmd = new SetFirewallRulesCommand(rules); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + + return cmd; + } + + private void verifyArgs(SetFirewallRulesCommand cmd, String script, String args) { + assertEquals(script, VRScripts.FIREWALL_INGRESS); + assertEquals(args, " -F -a 64.10.10.10:ICMP:0:0:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:TCP:22:80:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:reverted:0:0:0:,"); + } + + @Test + public void testVmDataCommand() { + Answer answer = _resource.executeRequest(generateVmDataCommand()); + assertTrue(answer.getResult()); + } + + protected VmDataCommand generateVmDataCommand() { + VmDataCommand cmd = new VmDataCommand("10.1.10.4", "i-4-VM", true); + cmd.addVmData("userdata", "user-data", "user-data"); + cmd.addVmData("metadata", "service-offering", "serviceOffering"); + cmd.addVmData("metadata", "availability-zone", "zoneName"); + cmd.addVmData("metadata", "local-ipv4", "10.1.10.4"); + cmd.addVmData("metadata", "local-hostname", "test-vm"); + cmd.addVmData("metadata", "public-ipv4", "110.1.10.4"); + cmd.addVmData("metadata", "public-hostname", "hostname"); + cmd.addVmData("metadata", "instance-id", "i-4-VM"); + cmd.addVmData("metadata", "vm-id", "4"); + cmd.addVmData("metadata", "public-keys", "publickey"); + cmd.addVmData("metadata", "cloud-identifier", "CloudStack-{test}"); + + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + + return cmd; + } + + private void verifyArgs(VmDataCommand cmd, String script, String args) { + assertEquals(script, VRScripts.VMDATA); + assertEquals(args, "-d eyIxMC4xLjEwLjQiOltbInVzZXJkYXRhIiwidXNlci1kYXRhIiwidXNlci1kYXRhIl0sWyJtZXRhZGF0YSIsInN" + + "lcnZpY2Utb2ZmZXJpbmciLCJzZXJ2aWNlT2ZmZXJpbmciXSxbIm1ldGFkYXRhIiwiYXZhaWxhYmlsaXR5LXpvbmUiLCJ6b25lTmFt" + + "ZSJdLFsibWV0YWRhdGEiLCJsb2NhbC1pcHY0IiwiMTAuMS4xMC40Il0sWyJtZXRhZGF0YSIsImxvY2FsLWhvc3RuYW1lIiwidGVzd" + + "C12bSJdLFsibWV0YWRhdGEiLCJwdWJsaWMtaXB2NCIsIjExMC4xLjEwLjQiXSxbIm1ldGFkYXRhIiwicHVibGljLWhvc3RuYW1lIi" + + "wiaG9zdG5hbWUiXSxbIm1ldGFkYXRhIiwiaW5zdGFuY2UtaWQiLCJpLTQtVk0iXSxbIm1ldGFkYXRhIiwidm0taWQiLCI0Il0sWyJ" + + "tZXRhZGF0YSIsInB1YmxpYy1rZXlzIiwicHVibGlja2V5Il0sWyJtZXRhZGF0YSIsImNsb3VkLWlkZW50aWZpZXIiLCJDbG91ZFN0YWNrLXt0ZXN0fSJdXX0="); + } + + @Test + public void testSavePasswordCommand() { + Answer answer = _resource.executeRequest(generateSavePasswordCommand()); + assertTrue(answer.getResult()); + } + + protected SavePasswordCommand generateSavePasswordCommand() { + SavePasswordCommand cmd = new SavePasswordCommand("123pass", "10.1.10.4", "i-4-VM", true); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + return cmd; + } + + private void verifyArgs(SavePasswordCommand cmd, String script, String args) { + assertEquals(script, VRScripts.PASSWORD); + assertEquals(args, "-v 10.1.10.4 -p 123pass"); + } + + @Test + public void testDhcpEntryCommand() { + _count = 0; + + Answer answer = _resource.executeRequest(generateDhcpEntryCommand1()); + assertTrue(answer.getResult()); + + answer = _resource.executeRequest(generateDhcpEntryCommand2()); + assertTrue(answer.getResult()); + + answer = _resource.executeRequest(generateDhcpEntryCommand3()); + assertTrue(answer.getResult()); + } + + protected DhcpEntryCommand generateDhcpEntryCommand1() { + DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", null, true); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + return cmd; + } + + protected DhcpEntryCommand generateDhcpEntryCommand2() { + DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", null, "vm1", "2001:db8:0:0:0:ff00:42:8329", true); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac())); + return cmd; + } + + protected DhcpEntryCommand generateDhcpEntryCommand3() { + DhcpEntryCommand cmd = new DhcpEntryCommand("12:34:56:78:90:AB", "10.1.10.2", "vm1", "2001:db8:0:0:0:ff00:42:8329", true); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + cmd.setDuid(NetUtils.getDuidLL(cmd.getVmMac())); + return cmd; + } + + private void verifyArgs(DhcpEntryCommand cmd, String script, String args) { + _count ++; + assertEquals(script, VRScripts.DHCP); + switch (_count) { + case 1: + assertEquals(args, " -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1"); + break; + case 2: + assertEquals(args, " -m 12:34:56:78:90:AB -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB"); + break; + case 3: + assertEquals(args, " -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB"); + break; + default: + fail(); + } + } + + @Test + public void testCreateIpAliasCommand() { + Answer answer = _resource.executeRequest(generateCreateIpAliasCommand()); + assertTrue(answer.getResult()); + } + + protected CreateIpAliasCommand generateCreateIpAliasCommand() { + List aliases = new ArrayList<>(); + aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1")); + aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2")); + aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3")); + CreateIpAliasCommand cmd = new CreateIpAliasCommand("169.254.3.10", aliases); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + + return cmd; + } + + private void verifyArgs(CreateIpAliasCommand cmd, String script, String args) { + assertEquals(script, VRScripts.IPALIAS_CREATE); + assertEquals(args, "1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-"); + } + + @Test + public void testDeleteIpAliasCommand() { + Answer answer = _resource.executeRequest(generateDeleteIpAliasCommand()); + assertTrue(answer.getResult()); + } + + protected DeleteIpAliasCommand generateDeleteIpAliasCommand() { + List aliases = new ArrayList<>(); + aliases.add(new IpAliasTO("169.254.3.10", "255.255.255.0", "1")); + aliases.add(new IpAliasTO("169.254.3.11", "255.255.255.0", "2")); + aliases.add(new IpAliasTO("169.254.3.12", "255.255.255.0", "3")); + DeleteIpAliasCommand cmd = new DeleteIpAliasCommand("169.254.10.1", aliases, aliases); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + return cmd; + } + + private void verifyArgs(DeleteIpAliasCommand cmd, String script, String args) { + assertEquals(script, VRScripts.IPALIAS_DELETE); + assertEquals(args, "1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-- 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-"); + } + + @Test + public void testDnsMasqConfigCommand() { + Answer answer = _resource.executeRequest(generateDnsMasqConfigCommand()); + assertTrue(answer.getResult()); + } + + protected DnsMasqConfigCommand generateDnsMasqConfigCommand() { + List dhcps = new ArrayList<>(); + dhcps.add(new DhcpTO("10.1.20.2", "10.1.20.1", "255.255.255.0", "10.1.20.5")); + dhcps.add(new DhcpTO("10.1.21.2", "10.1.21.1", "255.255.255.0", "10.1.21.5")); + DnsMasqConfigCommand cmd = new DnsMasqConfigCommand(dhcps); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + return cmd; + } + + private void verifyArgs(DnsMasqConfigCommand cmd, String script, String args) { + assertEquals(script, VRScripts.DNSMASQ_CONFIG); + assertEquals(args, "10.1.20.2:10.1.20.1:255.255.255.0:10.1.20.5-10.1.21.2:10.1.21.1:255.255.255.0:10.1.21.5-"); + } + + @Test + public void testLoadBalancerConfigCommand() { + _count = 0; + _file = ""; + + Answer answer = _resource.executeRequest(generateLoadBalancerConfigCommand1()); + assertTrue(answer.getResult()); + + answer = _resource.executeRequest(generateLoadBalancerConfigCommand2()); + assertTrue(answer.getResult()); + } + + protected LoadBalancerConfigCommand generateLoadBalancerConfigCommand1() { + List lbs = new ArrayList<>(); + List dests = new ArrayList<>(); + dests.add(new LbDestination(80, 8080, "10.1.10.2", false)); + dests.add(new LbDestination(80, 8080, "10.1.10.2", true)); + lbs.add(new LoadBalancerTO(UUID.randomUUID().toString(), "64.10.1.10", 80, "tcp", "algo", false, false, false, dests)); + LoadBalancerTO[] arrayLbs = new LoadBalancerTO[lbs.size()]; + lbs.toArray(arrayLbs); + NicTO nic = new NicTO(); + LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, null, "1000", false); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2"); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + return cmd; + } + + protected LoadBalancerConfigCommand generateLoadBalancerConfigCommand2() { + List lbs = new ArrayList<>(); + List dests = new ArrayList<>(); + dests.add(new LbDestination(80, 8080, "10.1.10.2", false)); + dests.add(new LbDestination(80, 8080, "10.1.10.2", true)); + lbs.add(new LoadBalancerTO(UUID.randomUUID().toString(), "64.10.1.10", 80, "tcp", "algo", false, false, false, dests)); + LoadBalancerTO[] arrayLbs = new LoadBalancerTO[lbs.size()]; + lbs.toArray(arrayLbs); + NicTO nic = new NicTO(); + nic.setIp("10.1.10.2"); + LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(arrayLbs, "64.10.2.10", "10.1.10.2", "192.168.1.2", nic, Long.valueOf(1), "1000", false); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, "10.1.10.2"); + cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, ROUTERNAME); + return cmd; + } + + protected void verifyFile(LoadBalancerConfigCommand cmd, String path, String filename, String content) { + _count ++; + switch (_count) { + case 1: + case 3: + _file = path + filename; + assertEquals(path, "/etc/haproxy/"); + assertTrue(filename.startsWith("haproxy.cfg.new")); + assertEquals(content, "global\n" + + "\tlog 127.0.0.1:3914 local0 warning\n" + + "\tmaxconn 1000\n" + + "\tmaxpipes 250\n" + + "\tchroot /var/lib/haproxy\n" + + "\tuser haproxy\n" + + "\tgroup haproxy\n" + + "\tdaemon\n" + + "\t \n" + + "defaults\n" + + "\tlog global\n" + + "\tmode tcp\n" + + "\toption dontlognull\n" + + "\tretries 3\n" + + "\toption redispatch\n" + + "\toption forwardfor\n" + + "\toption forceclose\n" + + "\ttimeout connect 5000\n" + + "\ttimeout client 50000\n" + + "\ttimeout server 50000\n" + + "\n" + + "listen stats_on_guest 10.1.10.2:8081\n" + + "\tmode http\n" + + "\toption httpclose\n" + + "\tstats enable\n" + + "\tstats uri /admin?stats\n" + + "\tstats realm Haproxy\\ Statistics\n" + + "\tstats auth admin1:AdMiN123\n" + + "\n" + + "\t \n" + + "listen 64_10_1_10-80 64.10.1.10:80\n" + + "\tbalance algo\n" + + "\tserver 64_10_1_10-80_0 10.1.10.2:80 check\n" + + "\tmode http\n" + + "\toption httpclose\n" + + "\t \n" + + "\t \n"); + break; + default: + fail(); + } + } + + private void verifyArgs(LoadBalancerConfigCommand cmd, String script, String args) { + _count ++; + switch (_count) { + case 2: + assertEquals(script, VRScripts.LB); + assertEquals(args, " -i 10.1.10.2 -f " + _file + " -a 64.10.1.10:80:, -s 10.1.10.2:8081:0/0:,,"); + break; + case 4: + assertEquals(script, VRScripts.VPC_LB); + assertEquals(args, " -i 10.1.10.2 -f " + _file + " -a 64.10.1.10:80:, -s 10.1.10.2:8081:0/0:,,"); + break; + default: + fail(); + } + } + + @Test + public void testAggregationCommands() { + List cmds = new LinkedList<>(); + AggregationControlCommand startCmd = new AggregationControlCommand(Action.Start, ROUTERNAME, ROUTERIP, ROUTERGUESTIP); + cmds.add(startCmd); + cmds.add(generateIpAssocCommand()); + cmds.add(generateIpAssocVpcCommand()); + + cmds.add(generateSetFirewallRulesCommand()); + + cmds.add(generateSetPortForwardingRulesCommand()); + cmds.add(generateSetPortForwardingRulesVpcCommand()); + + cmds.add(generateCreateIpAliasCommand()); + cmds.add(generateDeleteIpAliasCommand()); + cmds.add(generateDnsMasqConfigCommand()); + + cmds.add(generateRemoteAccessVpnCfgCommand1()); + cmds.add(generateRemoteAccessVpnCfgCommand2()); + cmds.add(generateRemoteAccessVpnCfgCommand3()); + + //cmds.add(generateLoadBalancerConfigCommand1()); + //cmds.add(generateLoadBalancerConfigCommand2()); + + cmds.add(generateSetPortForwardingRulesCommand()); + cmds.add(generateSetPortForwardingRulesVpcCommand()); + + cmds.add(generateDhcpEntryCommand1()); + cmds.add(generateDhcpEntryCommand2()); + cmds.add(generateDhcpEntryCommand3()); + + cmds.add(generateSavePasswordCommand()); + cmds.add(generateVmDataCommand()); + + AggregationControlCommand finishCmd = new AggregationControlCommand(Action.Finish, ROUTERNAME, ROUTERIP, ROUTERGUESTIP); + cmds.add(finishCmd); + + for (NetworkElementCommand cmd : cmds) { + Answer answer = _resource.executeRequest(cmd); + assertTrue(answer.getResult()); + } + } + + private void verifyArgs(AggregationControlCommand cmd, String script, String args) { + assertEquals(script, VRScripts.VR_CFG); + assertTrue(args.startsWith("-c /var/cache/cloud/VR-")); + assertTrue(args.endsWith(".cfg")); + } + + protected void verifyFile(AggregationControlCommand cmd, String path, String filename, String content) { + assertEquals(path, "/var/cache/cloud/"); + assertTrue(filename.startsWith("VR-")); + assertTrue(filename.endsWith(".cfg")); + assertEquals(content, "#Apache CloudStack Virtual Router Config File\n" + + "\n" + + "1.0\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "" + + "\n"); + } + +} + diff --git a/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java index eaa9b94fee1..33361e87265 100644 --- a/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java +++ b/core/test/org/apache/cloudstack/api/agent/test/BackupSnapshotCommandTest.java @@ -28,6 +28,7 @@ import org.junit.Test; import com.cloud.agent.api.BackupSnapshotCommand; import com.cloud.agent.api.to.SwiftTO; +import com.cloud.hypervisor.Hypervisor; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolStatus; @@ -145,7 +146,14 @@ public class BackupSnapshotCommandTest { public boolean isInMaintenance() { // TODO Auto-generated method stub return false; - }; + } + + @Override + public Hypervisor.HypervisorType getHypervisor() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + ; }; BackupSnapshotCommand bsc = new BackupSnapshotCommand("http://secondary.Storage.Url", 101L, 102L, 103L, 104L, 105L, "vPath", pool, diff --git a/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java b/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java index b0872bfc520..66feaecb5ef 100644 --- a/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java +++ b/core/test/org/apache/cloudstack/api/agent/test/CheckNetworkAnswerTest.java @@ -32,6 +32,7 @@ import com.cloud.agent.api.CheckNetworkAnswer; import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.to.StorageFilerTO; +import com.cloud.hypervisor.Hypervisor; import com.cloud.storage.Storage; import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolStatus; @@ -184,7 +185,14 @@ public class CheckNetworkAnswerTest { public boolean isInMaintenance() { // TODO Auto-generated method stub return false; - }; + } + + @Override + public Hypervisor.HypervisorType getHypervisor() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + ; }; Long newSize = 4194304L; diff --git a/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java b/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java index 8339a98b9f7..114c8854d15 100644 --- a/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java +++ b/core/test/org/apache/cloudstack/api/agent/test/SnapshotCommandTest.java @@ -28,6 +28,7 @@ import org.junit.Before; import org.junit.Test; import com.cloud.agent.api.SnapshotCommand; +import com.cloud.hypervisor.Hypervisor; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolStatus; @@ -146,7 +147,14 @@ public class SnapshotCommandTest { public boolean isInMaintenance() { // TODO Auto-generated method stub return false; - }; + } + + @Override + public Hypervisor.HypervisorType getHypervisor() { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + ; }; SnapshotCommand ssc = new SnapshotCommand(pool, "http://secondary.Storage.Url", "420fa39c-4ef1-a83c-fd93-46dc1ff515ae", "snapshotName", 101L, 102L, 103L); diff --git a/debian/changelog b/debian/changelog index 24306717e2f..28370cca79d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cloudstack (4.5.0-snapshot) unstable; urgency=low + + * Update the version to 4.5.0.snapshot + + -- Hugo Trippaers Thu, 21 Nov 2013 12:00:00 -0400 + cloudstack (4.4.0-snapshot) unstable; urgency=low * Update the version to 4.4.0.snapshot diff --git a/debian/cloudstack-agent.postinst b/debian/cloudstack-agent.postinst index 9bad1380bf0..01aaef60a67 100644 --- a/debian/cloudstack-agent.postinst +++ b/debian/cloudstack-agent.postinst @@ -41,7 +41,6 @@ case "$1" in mkdir /etc/libvirt/hooks fi cp -a /usr/share/cloudstack-agent/lib/libvirtqemuhook /etc/libvirt/hooks/qemu - /etc/init.d/libvirt-bin restart ;; esac diff --git a/debian/control b/debian/control index ab4644badd2..504ef99f317 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,7 @@ Description: A common package which contains files which are shared by several C Package: cloudstack-management Architecture: all -Depends: cloudstack-common (= ${source:Version}), tomcat6, sysvinit-utils, sudo, jsvc, python-mysqldb, python-paramiko, augeas-tools +Depends: cloudstack-common (= ${source:Version}), tomcat6, sysvinit-utils, sudo, jsvc, python-mysqldb, libmysql-java, python-paramiko, augeas-tools Conflicts: cloud-server, cloud-client, cloud-client-ui Description: CloudStack server library The CloudStack management server diff --git a/debian/rules b/debian/rules index 4edf8930605..197e243bcfe 100755 --- a/debian/rules +++ b/debian/rules @@ -35,7 +35,7 @@ build: build-indep build-indep: build-indep-stamp build-indep-stamp: configure - mvn clean package -Pawsapi -DskipTests -Dsystemvm \ + mvn -T C1.5 clean package -Pawsapi -DskipTests -Dsystemvm \ -Dcs.replace.properties=replace.properties.tmp \ ${ACS_BUILD_OPTS} touch $@ diff --git a/deps/XenServerJava/Makefile b/deps/XenServerJava/Makefile deleted file mode 100644 index c78144aa606..00000000000 --- a/deps/XenServerJava/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# Makefile to compile the Xen Java SDK bindings - -BINDINGJAVAFILES := $(wildcard com/xensource/xenapi/*.java) -BINDINGCLASSFILES := $(BINDINGJAVAFILES:.java=.class) -BINDINGJAR := xenserver-5.6.100-1.jar - -CLASSPATH := :../cloud-xmlrpc-client-3.1.3.jar:../cloud-xmlrpc-common-3.1.3.jar:../cloud-ws-commons-util-1.0.2.jar -EXAMPLECLASSPATH := :$(BINDINGJAR)$(CLASSPATH) - -.PHONY: all -all: $(BINDINGJAR) tests - @ : - -# Target to compile the automated tests -.PHONY: tests -tests: $(patsubst %.java,%.class,$(wildcard *.java)) - @ : - -.PHONY: docs -docs: - javadoc -classpath ${CLASSPATH} -d doc -link http://java.sun.com/javase/6/docs/api com/xensource/xenapi/*.java - -%.class: %.java - javac -cp ${CLASSPATH} $^ - -$(BINDINGJAR): $(BINDINGCLASSFILES) - jar -cvf $@ com/xensource/xenapi/*.class - -.PHONY: cleanclass -cleanclass: - rm -f com/xensource/xenapi/*.class - rm -f *.class - -.PHONY: cleanjar -cleanjar: - rm -f $(BINDINGJAR) - -.PHONY: cleandocs -cleandocs: - rm -rf doc - -.PHONY: clean -clean: cleanjar cleanclass cleandocs - @ : diff --git a/deps/XenServerJava/findbugsExcludeFilter.xml b/deps/XenServerJava/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/deps/XenServerJava/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + 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 8d7247d4fc3..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java +++ /dev/null @@ -1,118 +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, 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 deleted file mode 100644 index cffaaaca965..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); - } - -} \ 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 deleted file mode 100644 index 494b9286407..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Blob.java +++ /dev/null @@ -1,445 +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 (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 deleted file mode 100644 index 935fd9847e5..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Bond.java +++ /dev/null @@ -1,565 +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 (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 deleted file mode 100644 index a6524503609..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Connection.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 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 = "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; - - 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 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()), _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 ac2c9a7ce8a..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Console.java +++ /dev/null @@ -1,418 +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 (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 deleted file mode 100644 index be11588cc25..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java +++ /dev/null @@ -1,357 +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 (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 deleted file mode 100644 index 14a5e4064a7..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/DRTask.java +++ /dev/null @@ -1,302 +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; - -/** - * 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 deleted file mode 100644 index 5f777a32197..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/DataSource.java +++ /dev/null @@ -1,163 +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 (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 deleted file mode 100644 index ec438140fe2..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Event.java +++ /dev/null @@ -1,318 +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 (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); - } - - public static Map properFrom(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"); - Map value = (Map)result; - Map from = new HashMap(); - from.put("token", value.get("token")); - from.put("events", Types.toSetOfEventRecord(value.get("events"))); - return from; - } - -} \ 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 deleted file mode 100644 index 90704462703..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/GPUGroup.java +++ /dev/null @@ -1,444 +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 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 deleted file mode 100644 index 21950482123..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Host.java +++ /dev/null @@ -1,2926 +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 (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 deleted file mode 100644 index 15fcfa7113f..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java +++ /dev/null @@ -1,538 +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 (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 deleted file mode 100644 index 02c3bd943f6..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.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; - -/** - * 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 deleted file mode 100644 index b41277aeb05..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java +++ /dev/null @@ -1,373 +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 (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 deleted file mode 100644 index fa77588232a..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java +++ /dev/null @@ -1,555 +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 (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 deleted file mode 100644 index 865bc16af11..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 -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 a3658e38344..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Message.java +++ /dev/null @@ -1,320 +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 (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 deleted file mode 100644 index e9194ef7103..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Network.java +++ /dev/null @@ -1,792 +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 (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 deleted file mode 100644 index d2898247572..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PBD.java +++ /dev/null @@ -1,541 +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 (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 deleted file mode 100644 index e11230a6289..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PCI.java +++ /dev/null @@ -1,417 +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 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 deleted file mode 100644 index 0f5ddb4bdf9..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PGPU.java +++ /dev/null @@ -1,348 +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 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 deleted file mode 100644 index 27618b4105b..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PIF.java +++ /dev/null @@ -1,1397 +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 (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 deleted file mode 100644 index ab6268ee8f7..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java +++ /dev/null @@ -1,532 +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 (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 deleted file mode 100644 index 7ceebb02d56..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Pool.java +++ /dev/null @@ -1,2332 +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 (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 deleted file mode 100644 index 7361bc7da0e..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java +++ /dev/null @@ -1,692 +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 (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 deleted file mode 100644 index 5808b13cdb2..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Role.java +++ /dev/null @@ -1,363 +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 (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 deleted file mode 100644 index 0ec362694b6..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/SM.java +++ /dev/null @@ -1,527 +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 (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 deleted file mode 100644 index db6770fbe8f..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/SR.java +++ /dev/null @@ -1,1670 +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 (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 deleted file mode 100644 index 870725fda50..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Secret.java +++ /dev/null @@ -1,388 +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 (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 deleted file mode 100644 index bdf3b4cf80b..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Session.java +++ /dev/null @@ -1,674 +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 (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 deleted file mode 100644 index a599f237be9..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Subject.java +++ /dev/null @@ -1,395 +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 (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 deleted file mode 100644 index 59d59f6131b..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Task.java +++ /dev/null @@ -1,687 +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 (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 deleted file mode 100644 index 44b236df1b7..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java +++ /dev/null @@ -1,473 +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 (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 deleted file mode 100644 index 777d580e0b1..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/Types.java +++ /dev/null @@ -1,13442 +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("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("VDI_NOT_SPARSE")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - throw new Types.VdiNotSparse(p1); - } - if (ErrorDescription[0].equals("VDI_TOO_SMALL")) - { - String p1 = ErrorDescription.length > 1 ? ErrorDescription[1] : ""; - String p2 = ErrorDescription.length > 2 ? ErrorDescription[2] : ""; - throw new Types.VdiTooSmall(p1, p2); - } - 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 VDI is too small. Please resize it to at least the minimum size. - */ - public static class VdiTooSmall extends XenAPIException { - public final String vdi; - public final String minimumSize; - - /** - * Create a new VdiTooSmall - * - * @param vdi - * @param minimumSize - */ - public VdiTooSmall(String vdi, String minimumSize) { - super("The VDI is too small. Please resize it to at least the minimum size."); - this.vdi = vdi; - this.minimumSize = minimumSize; - } - - } - - /** - * The VDI is not stored using a sparse format. It is not possible to query and manipulate only the changed blocks (or 'block differences' or 'disk deltas') between two VDIs. Please select a VDI which uses a sparse-aware technology such as VHD. - */ - public static class VdiNotSparse extends XenAPIException { - public final String vdi; - - /** - * Create a new VdiNotSparse - * - * @param vdi - */ - public VdiNotSparse(String vdi) { - super("The VDI is not stored using a sparse format. It is not possible to query and manipulate only the changed blocks (or 'block differences' or 'disk deltas') between two VDIs. Please select a VDI which uses a sparse-aware technology such as VHD."); - 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 deleted file mode 100644 index dff27f5b367..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/User.java +++ /dev/null @@ -1,389 +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 (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 deleted file mode 100644 index 56e6f4b3d0e..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VBD.java +++ /dev/null @@ -1,1160 +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 (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 deleted file mode 100644 index 1f678faecdb..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java +++ /dev/null @@ -1,348 +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 (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 deleted file mode 100644 index 992a6a6d898..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VDI.java +++ /dev/null @@ -1,2138 +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 (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; - } - - /** - * Copy either a full VDI or the block differences between two VDIs into either a fresh VDI or an existing VDI. - * - * @param sr The destination SR (only required if the destination VDI is not specified - * @param baseVdi The base VDI (only required if copying only changed blocks, by default all blocks will be copied) - * @param intoVdi The destination VDI to copy blocks into (if omitted then a destination SR must be provided and a fresh VDI will be created) - * @return Task - */ - public Task copyAsync2(Connection c, SR sr, VDI baseVdi, VDI intoVdi) throws - BadServerResponse, - XenAPIException, - XmlRpcException, - Types.VdiReadonly, - Types.VdiTooSmall, - Types.VdiNotSparse { - String method_call = "Async.VDI.copy"; - String session = c.getSessionReference(); - Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr), Marshalling.toXMLRPC(baseVdi), Marshalling.toXMLRPC(intoVdi)}; - 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 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 deleted file mode 100644 index 19c88fd4561..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VGPU.java +++ /dev/null @@ -1,447 +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 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 deleted file mode 100644 index 8302800686d..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VIF.java +++ /dev/null @@ -1,1185 +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 (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 deleted file mode 100644 index 0c17217956d..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java +++ /dev/null @@ -1,348 +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 (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 deleted file mode 100644 index 9bea0399a45..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VLAN.java +++ /dev/null @@ -1,420 +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 (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 deleted file mode 100644 index cfa5e6c97c7..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VM.java +++ /dev/null @@ -1,4916 +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 (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 deleted file mode 100644 index b7e7e36684e..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VMAppliance.java +++ /dev/null @@ -1,654 +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 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 deleted file mode 100644 index 08d88e3641c..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java +++ /dev/null @@ -1,486 +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 (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 deleted file mode 100644 index 5f9a7a42c7c..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java +++ /dev/null @@ -1,509 +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 (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 deleted file mode 100644 index 0ee0b3e7439..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VMPP.java +++ /dev/null @@ -1,1157 +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 (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 deleted file mode 100644 index 25c332081ef..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/VTPM.java +++ /dev/null @@ -1,289 +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 (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 deleted file mode 100644 index b9821ee6b7c..00000000000 --- a/deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 Citrix Systems, Inc. Licensed under the -// Apache License, Version 2.0 (the "License"); you may not use this -// file except in compliance with the License. Citrix Systems, Inc. -// reserves all rights not expressly granted by 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. -// -// Automatically generated by addcopyright.py at 04/03/2012 -package com.xensource.xenapi; - -public abstract class XenAPIObject -{ - public abstract String toWireString(); -} diff --git a/developer/pom.xml b/developer/pom.xml index 3b3ed19a6cf..e8e575e11b9 100644 --- a/developer/pom.xml +++ b/developer/pom.xml @@ -18,15 +18,9 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT - - - mysql - mysql-connector-java - runtime - commons-dbcp commons-dbcp @@ -114,6 +108,14 @@ org.codehaus.mojo exec-maven-plugin 1.2.1 + + + + mysql + mysql-connector-java + ${cs.mysql.version} + + process-resources @@ -125,6 +127,7 @@ com.cloud.upgrade.DatabaseCreator + true ${basedir}/../utils/conf/db.properties @@ -182,6 +185,13 @@ org.codehaus.mojo exec-maven-plugin + + + mysql + mysql-connector-java + ${cs.mysql.version} + + 1.2.1 @@ -194,6 +204,7 @@ com.cloud.upgrade.DatabaseCreator + true ${basedir}/../utils/conf/db.properties diff --git a/engine/api/findbugsExcludeFilter.xml b/engine/api/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/api/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/api/pom.xml b/engine/api/pom.xml index f4746e688f7..3368bd82305 100644 --- a/engine/api/pom.xml +++ b/engine/api/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/engine/api/src/com/cloud/vm/VirtualMachineManager.java b/engine/api/src/com/cloud/vm/VirtualMachineManager.java index ac79860df31..f070210b757 100644 --- a/engine/api/src/com/cloud/vm/VirtualMachineManager.java +++ b/engine/api/src/com/cloud/vm/VirtualMachineManager.java @@ -18,6 +18,7 @@ package com.cloud.vm; import java.net.URI; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import org.apache.cloudstack.framework.config.ConfigKey; @@ -35,12 +36,11 @@ import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.Network; -import com.cloud.offering.DiskOffering; +import com.cloud.offering.DiskOfferingInfo; import com.cloud.offering.ServiceOffering; import com.cloud.storage.StoragePool; import com.cloud.storage.Volume; import com.cloud.template.VirtualMachineTemplate; -import com.cloud.utils.Pair; import com.cloud.utils.component.Manager; import com.cloud.utils.fsm.NoTransitionException; @@ -75,16 +75,16 @@ public interface VirtualMachineManager extends Manager { * @param hyperType Hypervisor type * @throws InsufficientCapacityException If there are insufficient capacity to deploy this vm. */ - void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering, Pair rootDiskOffering, - LinkedHashMap dataDiskOfferings, LinkedHashMap auxiliaryNetworks, DeploymentPlan plan, + void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering, DiskOfferingInfo rootDiskOfferingInfo, + List dataDiskOfferings, LinkedHashMap> auxiliaryNetworks, DeploymentPlan plan, HypervisorType hyperType) throws InsufficientCapacityException; void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering, - LinkedHashMap networkProfiles, DeploymentPlan plan, HypervisorType hyperType) throws InsufficientCapacityException; + LinkedHashMap> networkProfiles, DeploymentPlan plan, HypervisorType hyperType) throws InsufficientCapacityException; void start(String vmUuid, Map params); - void start(String vmUuid, Map params, DeploymentPlan planToDeploy); + void start(String vmUuid, Map params, DeploymentPlan planToDeploy, DeploymentPlanner planner); void stop(String vmUuid) throws ResourceUnavailableException; @@ -109,7 +109,7 @@ public interface VirtualMachineManager extends Manager { void destroy(String vmUuid) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException; - void migrateAway(String vmUuid, long hostId, DeploymentPlanner planner) throws InsufficientServerCapacityException; + void migrateAway(String vmUuid, long hostId) throws InsufficientServerCapacityException; void migrate(String vmUuid, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException; diff --git a/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java b/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java index 773c683ebf5..37501f014d0 100755 --- a/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java +++ b/engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java @@ -30,6 +30,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.cloudstack.engine.entity.api.CloudStackEntity; import com.cloud.deploy.DeploymentPlan; +import com.cloud.deploy.DeploymentPlanner; import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.CloudException; @@ -90,7 +91,7 @@ public interface VirtualMachineEntity extends CloudStackEntity { * @param exclude list of areas to exclude * @return a reservation id */ - String reserve(String plannerToUse, @BeanParam DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException, + String reserve(DeploymentPlanner plannerToUse, @BeanParam DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException, ResourceUnavailableException; /** diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java index a50c184a5e0..1061c4d007a 100755 --- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java +++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java @@ -77,7 +77,7 @@ public interface NetworkOrchestrationService { boolean errorIfAlreadySetup, Long domainId, ACLType aclType, Boolean subdomainAccess, Long vpcId, Boolean isDisplayNetworkEnabled) throws ConcurrentOperationException; - void allocate(VirtualMachineProfile vm, LinkedHashMap networks) throws InsufficientCapacityException, + void allocate(VirtualMachineProfile vm, LinkedHashMap> networks) throws InsufficientCapacityException, ConcurrentOperationException; void prepare(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java index f79d3361b97..df0b5e8e70f 100644 --- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java +++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java @@ -21,6 +21,7 @@ package org.apache.cloudstack.engine.orchestration.service; import java.util.Map; import java.util.Set; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import com.cloud.agent.api.to.VirtualMachineTO; @@ -86,14 +87,16 @@ public interface VolumeOrchestrationService { void destroyVolume(Volume volume); - DiskProfile allocateRawVolume(Type type, String name, DiskOffering offering, Long size, VirtualMachine vm, VirtualMachineTemplate template, Account owner); + DiskProfile allocateRawVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops, VirtualMachine vm, VirtualMachineTemplate template, Account owner); - VolumeInfo createVolumeOnPrimaryStorage(VirtualMachine vm, Volume rootVolumeOfVm, VolumeInfo volume, HypervisorType rootDiskHyperType) throws NoTransitionException; + VolumeInfo createVolumeOnPrimaryStorage(VirtualMachine vm, VolumeInfo volume, HypervisorType rootDiskHyperType, StoragePool storagePool) throws NoTransitionException; void release(VirtualMachineProfile profile); void cleanupVolumes(long vmId) throws ConcurrentOperationException; + void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore); + void disconnectVolumesFromHost(long vmId, long hostId); void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, Map volumeToPool); @@ -106,7 +109,7 @@ public interface VolumeOrchestrationService { boolean canVmRestartOnAnotherServer(long vmId); - DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, VirtualMachineTemplate template, VirtualMachine vm, + DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, Long minIops, Long maxIops, VirtualMachineTemplate template, VirtualMachine vm, Account owner); String getVmNameFromVolumeId(long volumeId); @@ -118,4 +121,5 @@ public interface VolumeOrchestrationService { StoragePool findStoragePool(DiskProfile dskCh, DataCenter dc, Pod pod, Long clusterId, Long hostId, VirtualMachine vm, Set avoid); void updateVolumeDiskChain(long volumeId, String path, String chainInfo); + } diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java index f20e18847fe..a8f8b308539 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionService.java @@ -26,6 +26,8 @@ import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.host.Host; public interface DataMotionService { + void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback callback); + void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback); void copyAsync(Map volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback callback); diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java index 39a257d7262..b5601e9693c 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataMotionStrategy.java @@ -30,6 +30,8 @@ public interface DataMotionStrategy { StrategyPriority canHandle(Map volumeMap, Host srcHost, Host destHost); + Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback callback); + Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback); Void copyAsync(Map volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, AsyncCompletionCallback callback); diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java index 19893d07d1f..f08d9a45509 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java @@ -18,6 +18,8 @@ */ package org.apache.cloudstack.engine.subsystem.api.storage; +import java.util.Map; + import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat; import com.cloud.hypervisor.Hypervisor.HypervisorType; @@ -25,6 +27,17 @@ import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; public interface PrimaryDataStoreInfo extends StoragePool { + static final String MANAGED = "managed"; + static final String STORAGE_HOST= "storageHost"; + static final String STORAGE_PORT = "storagePort"; + static final String MANAGED_STORE_TARGET = "managedStoreTarget"; + static final String MANAGED_STORE_TARGET_ROOT_VOLUME = "managedStoreTargetRootVolume"; + static final String CHAP_INITIATOR_USERNAME = "chapInitiatorUsername"; + static final String CHAP_INITIATOR_SECRET = "chapInitiatorSecret"; + static final String CHAP_TARGET_USERNAME = "chapTargetUsername"; + static final String CHAP_TARGET_SECRET = "chapTargetSecret"; + static final String VOLUME_SIZE = "volumeSize"; + boolean isHypervisorSupported(HypervisorType hypervisor); boolean isLocalStorageSupported(); @@ -37,5 +50,11 @@ public interface PrimaryDataStoreInfo extends StoragePool { @Override StoragePoolType getPoolType(); + boolean isManaged(); + + void setDetails(Map details); + + Map getDetails(); + PrimaryDataStoreLifeCycle getLifeCycle(); } diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java index 4fbb20ed29e..965df84c2dd 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageAction.java @@ -21,5 +21,6 @@ package org.apache.cloudstack.engine.subsystem.api.storage; public enum StorageAction { TAKESNAPSHOT, BACKUPSNAPSHOT, - DELETESNAPSHOT + DELETESNAPSHOT, + MIGRATEVOLUME } diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java index 6d1ac2d62ef..b8aeb5cf751 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/StorageCacheManager.java @@ -21,6 +21,8 @@ package org.apache.cloudstack.engine.subsystem.api.storage; public interface StorageCacheManager { DataStore getCacheStorage(Scope scope); + DataStore getCacheStorage(DataObject data, Scope scope); + DataObject createCacheObject(DataObject data, Scope scope); /** diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java index 801c4427f50..fd22da12e48 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java @@ -25,6 +25,8 @@ import com.cloud.storage.DataStoreRole; public interface TemplateDataFactory { TemplateInfo getTemplate(long templateId, DataStore store); + TemplateInfo getReadyTemplateOnImageStore(long templateId, Long zoneId); + TemplateInfo getTemplate(DataObject obj, DataStore store); TemplateInfo getTemplate(long templateId, DataStoreRole storeRole); diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java index 3f676ae73dc..b6e61069e77 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeService.java @@ -78,7 +78,11 @@ public interface VolumeService { VolumeEntity getVolumeEntity(long volumeId); - AsyncCallFuture createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, TemplateInfo template); + AsyncCallFuture createManagedStorageAndVolumeFromTemplateAsync(VolumeInfo volumeInfo, long destDataStoreId, + TemplateInfo srcTemplateInfo, long destHostId); + + AsyncCallFuture createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, + TemplateInfo template); AsyncCallFuture copyVolume(VolumeInfo srcVolume, DataStore destStore); diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeBase.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeBase.java index 78ac8e23966..1d6a65c6921 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeBase.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeBase.java @@ -17,31 +17,36 @@ package org.apache.cloudstack.engine.subsystem.api.storage.type; public class VolumeTypeBase implements VolumeType { + protected String type = "Unknown"; @Override - public boolean equals(Object that) { - if (this == that) { + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; - } - if (that instanceof String) { - if (this.toString().equalsIgnoreCase((String)that)) { - return true; - } - } else if (that instanceof VolumeTypeBase) { - VolumeTypeBase th = (VolumeTypeBase)that; - if (this.toString().equalsIgnoreCase(th.toString())) { - return true; - } - } else { + if (obj == null) return false; - } - return false; + if (getClass() != obj.getClass()) + return false; + VolumeTypeBase other = (VolumeTypeBase) obj; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + return true; } @Override public String toString() { return type; } - -} +} \ No newline at end of file diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java index 50572033042..6b8437980b6 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java @@ -16,26 +16,33 @@ // under the License. package org.apache.cloudstack.engine.subsystem.api.storage.type; +import java.util.Hashtable; import java.util.List; +import java.util.Map; import javax.inject.Inject; public class VolumeTypeHelper { - static private List types; + private static VolumeType defaultType = new Unknown(); + private List types; + private final Map mapTypes = new Hashtable(); + @Inject public void setTypes(List types) { - VolumeTypeHelper.types = types; + this.types = types; + + mapTypes.clear(); + for (VolumeType ty : this.types) { + mapTypes.put(ty.getClass().getSimpleName().toUpperCase(), ty); + } } - public static VolumeType getType(String type) { - for (VolumeType ty : types) { - if (ty.equals(type)) { - return ty; - } + public VolumeType getType(String type) { + if (mapTypes.containsKey(type.toUpperCase())) { + return mapTypes.get(type.toUpperCase()); } return VolumeTypeHelper.defaultType; } - -} +} \ No newline at end of file diff --git a/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelperTest.java b/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelperTest.java new file mode 100644 index 00000000000..32df84ff984 --- /dev/null +++ b/engine/api/test/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelperTest.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 org.apache.cloudstack.engine.subsystem.api.storage.type; + +import java.util.ArrayList; +import java.util.List; + +import junit.framework.Assert; + +import org.junit.Before; +import org.junit.Test; + +public class VolumeTypeHelperTest { + + private VolumeTypeHelper helper; + + @Before + public void setu() { + helper = new VolumeTypeHelper(); + + List types = new ArrayList(); + types.add(new BaseImage()); + types.add(new DataDisk()); + types.add(new Iso()); + types.add(new Unknown()); + types.add(new RootDisk()); + types.add(new VolumeTypeBase()); + + helper.setTypes(types); + } + + @Test + public void testGetTypeBaseImage() throws Exception { + VolumeType type = helper.getType("BaseImage"); + + Assert.assertTrue(type instanceof BaseImage); + } + + @Test + public void testGetTypeDataDisk() throws Exception { + VolumeType type = helper.getType("DataDisk"); + + Assert.assertTrue(type instanceof DataDisk); + } + + @Test + public void testGetTypeIso() throws Exception { + VolumeType type = helper.getType("Iso"); + + Assert.assertTrue(type instanceof Iso); + } + + @Test + public void testGetTypeUnknown() throws Exception { + VolumeType type = helper.getType("Unknown"); + + Assert.assertTrue(type instanceof Unknown); + } + + @Test + public void testGetTypeRootDisk() throws Exception { + VolumeType type = helper.getType("RootDisk"); + + Assert.assertTrue(type instanceof RootDisk); + } + + @Test + public void testGetTypeVolumeTypeBase() throws Exception { + VolumeType type = helper.getType("VolumeTypeBase"); + + Assert.assertTrue(type instanceof VolumeTypeBase); + } + + @Test + public void testGetTypeVolumeString() throws Exception { + VolumeType type = helper.getType("String"); + + Assert.assertTrue(type instanceof Unknown); + } + + @Test(expected = NullPointerException.class) + public void testGetTypeVolumeNull() throws Exception { + helper.getType(null); + } +} \ No newline at end of file diff --git a/engine/components-api/findbugsExcludeFilter.xml b/engine/components-api/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/components-api/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/components-api/pom.xml b/engine/components-api/pom.xml index a89634b957c..b9d1f9ae358 100644 --- a/engine/components-api/pom.xml +++ b/engine/components-api/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/engine/components-api/src/com/cloud/capacity/CapacityManager.java b/engine/components-api/src/com/cloud/capacity/CapacityManager.java index bd1a61096c0..038a2c05f01 100755 --- a/engine/components-api/src/com/cloud/capacity/CapacityManager.java +++ b/engine/components-api/src/com/cloud/capacity/CapacityManager.java @@ -44,7 +44,7 @@ public interface CapacityManager { "Percentage (as a value between 0 and 1) of storage utilization above which allocators will disable using the pool for low storage available.", true, ConfigKey.Scope.Zone); static final ConfigKey StorageOverprovisioningFactor = new ConfigKey("Storage", Double.class, StorageOverprovisioningFactorCK, "2", - "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", true, ConfigKey.Scope.Zone); + "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", true, ConfigKey.Scope.StoragePool); static final ConfigKey StorageAllocatedCapacityDisableThreshold = new ConfigKey( "Alert", diff --git a/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java b/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java index de2fc0eaf5a..ee6721ab445 100644 --- a/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java +++ b/engine/components-api/src/com/cloud/deploy/DeploymentPlanningManager.java @@ -43,8 +43,10 @@ public interface DeploymentPlanningManager extends Manager { ExcludeList avoids, DeploymentPlanner planner) throws InsufficientServerCapacityException, AffinityConflictException; String finalizeReservation(DeployDestination plannedDestination, - VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids) + VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoids, DeploymentPlanner planner) throws InsufficientServerCapacityException, AffinityConflictException; void cleanupVMReservations(); + + DeploymentPlanner getDeploymentPlannerByName(String plannerName); } diff --git a/engine/components-api/src/com/cloud/event/UsageEventUtils.java b/engine/components-api/src/com/cloud/event/UsageEventUtils.java index 4f32cb32636..f1707bd45db 100644 --- a/engine/components-api/src/com/cloud/event/UsageEventUtils.java +++ b/engine/components-api/src/com/cloud/event/UsageEventUtils.java @@ -70,6 +70,15 @@ public class UsageEventUtils { publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); } + public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, + Long size, String entityType, String entityUUID, boolean displayResource) { + if(displayResource){ + saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size); + } + publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); + + } + public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, Long size, Long virtualSize, String entityType, String entityUUID) { saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, size, virtualSize); @@ -81,6 +90,13 @@ public class UsageEventUtils { publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); } + public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, String entityType, String entityUUID, boolean diplayResource) { + if (diplayResource){ + saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName); + publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); + } + } + public static void publishUsageEvent(String usageType, long accountId, long zoneId, long ipAddressId, String ipAddress, boolean isSourceNat, String guestType, boolean isSystem, String entityType, String entityUUID) { saveUsageEvent(usageType, accountId, zoneId, ipAddressId, ipAddress, isSourceNat, guestType, isSystem); @@ -88,9 +104,12 @@ public class UsageEventUtils { } public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, - String resourceType, String entityType, String entityUUID) { - saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, resourceType); + String resourceType, String entityType, String entityUUID, boolean displayResource) { + if(displayResource){ + saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, resourceType); + } publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); + } public static void publishUsageEvent(String usageType, long accountId, long zoneId, long vmId, long securityGroupId, String entityType, String entityUUID) { @@ -99,9 +118,12 @@ public class UsageEventUtils { } public static void publishUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, - String resourceType, String entityType, String entityUUID, Map details) { - saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, resourceType, details); + String resourceType, String entityType, String entityUUID, Map details, boolean displayResource) { + if(displayResource){ + saveUsageEvent(usageType, accountId, zoneId, resourceId, resourceName, offeringId, templateId, resourceType, details); + } publishUsageEvent(usageType, accountId, zoneId, entityType, entityUUID); + } private static void saveUsageEvent(String usageType, long accountId, long zoneId, long resourceId, String resourceName, Long offeringId, Long templateId, diff --git a/engine/components-api/src/com/cloud/ha/HighAvailabilityManager.java b/engine/components-api/src/com/cloud/ha/HighAvailabilityManager.java index e1b308a1632..ecfb6f65701 100644 --- a/engine/components-api/src/com/cloud/ha/HighAvailabilityManager.java +++ b/engine/components-api/src/com/cloud/ha/HighAvailabilityManager.java @@ -18,6 +18,7 @@ package com.cloud.ha; import java.util.List; +import com.cloud.deploy.DeploymentPlanner; import com.cloud.host.HostVO; import com.cloud.host.Status; import com.cloud.utils.component.Manager; @@ -99,8 +100,12 @@ public interface HighAvailabilityManager extends Manager { void cancelScheduledMigrations(HostVO host); + boolean hasPendingHaWork(long vmId); + /** * @return */ String getHaTag(); + + DeploymentPlanner getHAPlanner(); } diff --git a/engine/components-api/src/com/cloud/network/IpAddressManager.java b/engine/components-api/src/com/cloud/network/IpAddressManager.java index 9ccc9466f70..98ff55cad73 100644 --- a/engine/components-api/src/com/cloud/network/IpAddressManager.java +++ b/engine/components-api/src/com/cloud/network/IpAddressManager.java @@ -160,7 +160,7 @@ public interface IpAddressManager { PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat) throws ConcurrentOperationException, InsufficientAddressCapacityException; - IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone) throws ConcurrentOperationException, + IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerId, DataCenter zone, Boolean displayIp) throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException; PublicIp assignPublicIpAddressFromVlans(long dcId, Long podId, Account owner, VlanType type, List vlanDbIds, Long networkId, String requestedIp, diff --git a/engine/components-api/src/com/cloud/network/addr/PublicIp.java b/engine/components-api/src/com/cloud/network/addr/PublicIp.java index 27c247854e7..ec4a9ee82eb 100644 --- a/engine/components-api/src/com/cloud/network/addr/PublicIp.java +++ b/engine/components-api/src/com/cloud/network/addr/PublicIp.java @@ -196,7 +196,7 @@ public class PublicIp implements PublicIpAddress { @Override public Long getVpcId() { - return _addr.getVpcId(); + return _addr.getVpcId(); } @Override @@ -229,6 +229,16 @@ public class PublicIp implements PublicIpAddress { } public Long getIpMacAddress() { - return _addr.getMacAddress(); + return _addr.getMacAddress(); + } + + @Override + public boolean isDisplay() { + return _addr.isDisplay(); + } + + @Override + public Class getEntityType() { + return PublicIpAddress.class; } } diff --git a/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java b/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java index 6b3ae02da02..945ee9783b5 100644 --- a/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java +++ b/engine/components-api/src/com/cloud/network/lb/LoadBalancingRulesManager.java @@ -34,7 +34,7 @@ import com.cloud.user.Account; public interface LoadBalancingRulesManager { LoadBalancer createPublicLoadBalancer(String xId, String name, String description, int srcPort, int destPort, long sourceIpId, String protocol, String algorithm, - boolean openFirewall, CallContext caller, String lbProtocol) throws NetworkRuleConflictException; + boolean openFirewall, CallContext caller, String lbProtocol, Boolean forDisplay) throws NetworkRuleConflictException; boolean removeAllLoadBalanacersForIp(long ipId, Account caller, long callerUserId); diff --git a/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java b/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java index 1c67047a7eb..9a49db0ca1c 100644 --- a/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java +++ b/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java @@ -31,20 +31,22 @@ public class StaticNatRuleImpl implements StaticNatRule { long networkId; long sourceIpAddressId; String destIpAddress; + boolean forDisplay; public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) { - this.id = rule.getId(); - this.xid = rule.getXid(); - this.uuid = rule.getUuid(); - this.protocol = rule.getProtocol(); - this.portStart = rule.getSourcePortStart(); - this.portEnd = rule.getSourcePortEnd(); - this.state = rule.getState(); - this.accountId = rule.getAccountId(); - this.domainId = rule.getDomainId(); - this.networkId = rule.getNetworkId(); - this.sourceIpAddressId = rule.getSourceIpAddressId(); - this.destIpAddress = dstIp; + id = rule.getId(); + xid = rule.getXid(); + uuid = rule.getUuid(); + protocol = rule.getProtocol(); + portStart = rule.getSourcePortStart(); + portEnd = rule.getSourcePortEnd(); + state = rule.getState(); + accountId = rule.getAccountId(); + domainId = rule.getDomainId(); + networkId = rule.getNetworkId(); + sourceIpAddressId = rule.getSourceIpAddressId(); + destIpAddress = dstIp; + forDisplay = rule.isDisplay(); } @Override @@ -142,4 +144,13 @@ public class StaticNatRuleImpl implements StaticNatRule { return null; } + @Override + public boolean isDisplay() { + return forDisplay; + } + + @Override + public Class getEntityType() { + return FirewallRule.class; + } } diff --git a/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java b/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java index 06952fc2e7d..0377c5f74d8 100644 --- a/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java +++ b/engine/components-api/src/com/cloud/network/vpc/NetworkACLManager.java @@ -28,9 +28,10 @@ public interface NetworkACLManager { * @param name * @param description * @param vpcId + * @param forDisplay TODO * @return */ - NetworkACL createNetworkACL(String name, String description, long vpcId); + NetworkACL createNetworkACL(String name, String description, long vpcId, Boolean forDisplay); /** * Fetches Network ACL with specified Id @@ -74,10 +75,11 @@ public interface NetworkACLManager { * @param aclId * @param action * @param number + * @param forDisplay TODO * @return */ NetworkACLItem createNetworkACLItem(Integer sourcePortStart, Integer sourcePortEnd, String protocol, List sourceCidrList, Integer icmpCode, Integer icmpType, - NetworkACLItem.TrafficType trafficType, Long aclId, String action, Integer number); + NetworkACLItem.TrafficType trafficType, Long aclId, String action, Integer number, Boolean forDisplay); /** * Returns Network ACL Item with specified Id @@ -130,11 +132,13 @@ public interface NetworkACLManager { * @param sourcePortEnd * @param icmpCode * @param icmpType + * @param customId TODO + * @param forDisplay TODO * @return * @throws ResourceUnavailableException */ NetworkACLItem updateNetworkACLItem(Long id, String protocol, List sourceCidrList, NetworkACLItem.TrafficType trafficType, String action, Integer number, - Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType) throws ResourceUnavailableException; + Integer sourcePortStart, Integer sourcePortEnd, Integer icmpCode, Integer icmpType, String customId, Boolean forDisplay) throws ResourceUnavailableException; /** * Associates acl with a network and applies the ACLItems diff --git a/engine/components-api/src/com/cloud/resource/ResourceManager.java b/engine/components-api/src/com/cloud/resource/ResourceManager.java index 95fb3853717..0608cb47401 100755 --- a/engine/components-api/src/com/cloud/resource/ResourceManager.java +++ b/engine/components-api/src/com/cloud/resource/ResourceManager.java @@ -17,15 +17,18 @@ // under the License. package com.cloud.resource; +import java.util.HashMap; import java.util.List; import java.util.Map; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; +import com.cloud.agent.api.to.GPUDeviceTO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.dc.PodCluster; import com.cloud.exception.AgentUnavailableException; +import com.cloud.gpu.HostGpuGroupsVO; import com.cloud.host.Host; import com.cloud.host.Host.Type; import com.cloud.host.HostStats; @@ -137,4 +140,49 @@ public interface ResourceManager extends ResourceService { * @return */ List listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId); + + /** + * Check if host is GPU enabled + * @param hostId the host to be checked + * @return true if host contains GPU card else false + */ + boolean isHostGpuEnabled(long hostId); + + /** + * Check if host has GPU devices available + * @param hostId the host to be checked + * @param vgpuType the VGPU type + * @return true when the host has the capacity with given VGPU type + */ + boolean isGPUDeviceAvailable(long hostId, String vgpuType); + + /** + * Get available GPU device + * @param hostId the host to be checked + * @param vgpuType the VGPU type + * @return GPUDeviceTO[] + */ + GPUDeviceTO getGPUDevice(long hostId, String vgpuType); + + /** + * Return listof available GPU devices + * @param hostId, the host to be checked + * @param vgpuType the VGPU type + * @return List of HostGpuGroupsVO. + */ + List listAvailableGPUDevice(long hostId, String vgpuType); + + /** + * Update GPU device details (post VM deployment) + * @param hostId, the dest host Id + * @param groupDetails, capacity of GPU group. + */ + void updateGPUDetails(long hostId, HashMap> groupDetails); + + /** + * Get GPU details for a host + * @param host, the Host object + * @return Details of groupNames and enabled VGPU type with remaining capacity. + */ + HashMap> getGPUStatistics(HostVO host); } diff --git a/engine/components-api/src/com/cloud/template/TemplateManager.java b/engine/components-api/src/com/cloud/template/TemplateManager.java index 0a07f6b4a3d..5987ac0ee5b 100755 --- a/engine/components-api/src/com/cloud/template/TemplateManager.java +++ b/engine/components-api/src/com/cloud/template/TemplateManager.java @@ -31,6 +31,7 @@ import com.cloud.storage.VMTemplateHostVO; import com.cloud.storage.VMTemplateStoragePoolVO; import com.cloud.storage.VMTemplateVO; import com.cloud.utils.Pair; +import com.cloud.vm.VirtualMachineProfile; /** * TemplateManager manages the templates stored on secondary storage. It is responsible for creating private/public templates. @@ -113,4 +114,15 @@ public interface TemplateManager { TemplateInfo prepareIso(long isoId, long dcId); + + /** + * Adds ISO definition to given vm profile + * + * @param VirtualMachineProfile + */ + void prepareIsoForVmProfile(VirtualMachineProfile profile); + + public static final String MESSAGE_REGISTER_PUBLIC_TEMPLATE_EVENT = "Message.RegisterPublicTemplate.Event"; + public static final String MESSAGE_RESET_TEMPLATE_PERMISSION_EVENT = "Message.ResetTemplatePermission.Event"; + } diff --git a/engine/network/findbugsExcludeFilter.xml b/engine/network/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/network/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/network/pom.xml b/engine/network/pom.xml index e60843a6de7..fdb80110166 100644 --- a/engine/network/pom.xml +++ b/engine/network/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/engine/orchestration/findbugsExcludeFilter.xml b/engine/orchestration/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/orchestration/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/orchestration/pom.xml b/engine/orchestration/pom.xml index d5a35b9e95f..e5250c45b10 100755 --- a/engine/orchestration/pom.xml +++ b/engine/orchestration/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java index 3c31301caa7..fd1531e25a6 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/AgentAttache.java @@ -32,9 +32,8 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.apache.log4j.Logger; - import org.apache.cloudstack.managed.context.ManagedContextRunnable; +import org.apache.log4j.Logger; import com.cloud.agent.Listener; import com.cloud.agent.api.Answer; @@ -72,7 +71,7 @@ public abstract class AgentAttache { protected static final Comparator s_reqComparator = new Comparator() { @Override - public int compare(Request o1, Request o2) { + public int compare(final Request o1, final Request o2) { long seq1 = o1.getSequence(); long seq2 = o2.getSequence(); if (seq1 < seq2) { @@ -87,7 +86,7 @@ public abstract class AgentAttache { protected static final Comparator s_seqComparator = new Comparator() { @Override - public int compare(Object o1, Object o2) { + public int compare(final Object o1, final Object o2) { long seq1 = ((Request)o1).getSequence(); long seq2 = (Long)o2; if (seq1 < seq2) { @@ -122,7 +121,7 @@ public abstract class AgentAttache { Arrays.sort(s_commandsNotAllowedInConnectingMode); } - protected AgentAttache(AgentManagerImpl agentMgr, final long id, final String name, boolean maintenance) { + protected AgentAttache(final AgentManagerImpl agentMgr, final long id, final String name, final boolean maintenance) { _id = id; _name = name; _waitForList = new ConcurrentHashMap(); @@ -130,7 +129,7 @@ public abstract class AgentAttache { _maintenance = maintenance; _requests = new LinkedList(); _agentMgr = agentMgr; - _nextSequence = s_rand.nextInt(Short.MAX_VALUE) << 48; + _nextSequence = new Long(s_rand.nextInt(Short.MAX_VALUE)) << 48; _outstandingTaskCount = new AtomicInteger(0); } @@ -180,13 +179,13 @@ public abstract class AgentAttache { } } - protected synchronized void addRequest(Request req) { + protected synchronized void addRequest(final Request req) { int index = findRequest(req); assert (index < 0) : "How can we get index again? " + index + ":" + req.toString(); _requests.add(-index - 1, req); } - protected void cancel(Request req) { + protected void cancel(final Request req) { long seq = req.getSequence(); cancel(seq); } @@ -205,11 +204,11 @@ public abstract class AgentAttache { } } - protected synchronized int findRequest(Request req) { + protected synchronized int findRequest(final Request req) { return Collections.binarySearch(_requests, req, s_reqComparator); } - protected synchronized int findRequest(long seq) { + protected synchronized int findRequest(final long seq) { return Collections.binarySearch(_requests, seq, s_seqComparator); } @@ -331,17 +330,20 @@ public abstract class AgentAttache { } @Override - public boolean equals(Object obj) { - try { - AgentAttache that = (AgentAttache)obj; - return _id == that._id; - } catch (ClassCastException e) { - assert false : "Who's sending an " + obj.getClass().getSimpleName() + " to AgentAttache.equals()? "; + public boolean equals(final Object obj) { + // Return false straight away. + if (obj == null) { return false; } + // No need to handle a ClassCastException. If the classes are different, then equals can return false straight ahead. + if (this.getClass() != obj.getClass()) { + return false; + } + AgentAttache that = (AgentAttache)obj; + return _id == that._id; } - public void send(Request req, final Listener listener) throws AgentUnavailableException { + public void send(final Request req, final Listener listener) throws AgentUnavailableException { checkAvailability(req.getCommands()); long seq = req.getSequence(); @@ -387,7 +389,7 @@ public abstract class AgentAttache { } } - public Answer[] send(Request req, int wait) throws AgentUnavailableException, OperationTimedoutException { + public Answer[] send(final Request req, final int wait) throws AgentUnavailableException, OperationTimedoutException { SynchronousListener sl = new SynchronousListener(null); long seq = req.getSequence(); @@ -478,7 +480,7 @@ public abstract class AgentAttache { _currentSequence = req.getSequence(); } - public void process(Answer[] answers) { + public void process(final Answer[] answers) { //do nothing } @@ -505,7 +507,7 @@ public abstract class AgentAttache { protected class Alarm extends ManagedContextRunnable { long _seq; - public Alarm(long seq) { + public Alarm(final long seq) { _seq = seq; } diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java index d51df220195..93374ef6dca 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -118,6 +118,12 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl protected static final Logger s_logger = Logger.getLogger(AgentManagerImpl.class); protected static final Logger status_logger = Logger.getLogger(Status.class); + /** + * _agents is a ConcurrentHashMap, but it is used from within a synchronized block. + * This will be reported by findbugs as JLM_JSR166_UTILCONCURRENT_MONITORENTER. + * Maybe a ConcurrentHashMap is not the right thing to use here, but i'm not sure + * so i leave it alone. + */ protected ConcurrentHashMap _agents = new ConcurrentHashMap(10007); protected List> _hostMonitors = new ArrayList>(17); protected List> _cmdMonitors = new ArrayList>(17); @@ -166,21 +172,28 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl @Inject ResourceManager _resourceMgr; - protected final ConfigKey Workers = new ConfigKey(Integer.class, "workers", "Advanced", "5", - "Number of worker threads handling remote agent connections.", false); - protected final ConfigKey Port = new ConfigKey(Integer.class, "port", "Advanced", "8250", "Port to listen on for remote agent connections.", false); - protected final ConfigKey PingInterval = new ConfigKey(Integer.class, "ping.interval", "Advanced", "60", - "Interval to send application level pings to make sure the connection is still working", false); - protected final ConfigKey PingTimeout = new ConfigKey(Float.class, "ping.timeout", "Advanced", "2.5", - "Multiplier to ping.interval before announcing an agent has timed out", true); - protected final ConfigKey AlertWait = new ConfigKey(Integer.class, "alert.wait", "Advanced", "1800", - "Seconds to wait before alerting on a disconnected agent", true); - protected final ConfigKey DirectAgentLoadSize = new ConfigKey(Integer.class, "direct.agent.load.size", "Advanced", "16", - "The number of direct agents to load each time", false); - protected final ConfigKey DirectAgentPoolSize = new ConfigKey(Integer.class, "direct.agent.pool.size", "Advanced", "500", - "Default size for DirectAgentPool", false); - protected final ConfigKey DirectAgentThreadCap = new ConfigKey(Float.class, "direct.agent.thread.cap", "Advanced", "0.1", - "Percentage (as a value between 0 and 1) of direct.agent.pool.size to be used as upper thread cap for a single direct agent to process requests", false); + protected final ConfigKey Workers = new ConfigKey("Advanced", Integer.class, "workers", "5", + "Number of worker threads handling remote agent connections.", false); + protected final ConfigKey Port = new ConfigKey("Advanced", Integer.class, "port", "8250", "Port to listen on for remote agent connections.", false); + protected final ConfigKey PingInterval = new ConfigKey("Advanced", Integer.class, "ping.interval", "60", + "Interval to send application level pings to make sure the connection is still working", false); + protected final ConfigKey PingTimeout = new ConfigKey("Advanced", Float.class, "ping.timeout", "2.5", + "Multiplier to ping.interval before announcing an agent has timed out", true); + protected final ConfigKey AlertWait = new ConfigKey("Advanced", Integer.class, "alert.wait", "1800", + "Seconds to wait before alerting on a disconnected agent", true); + protected final ConfigKey DirectAgentLoadSize = new ConfigKey("Advanced", Integer.class, "direct.agent.load.size", "16", + "The number of direct agents to load each time", false); + protected final ConfigKey DirectAgentPoolSize = new ConfigKey("Advanced", Integer.class, "direct.agent.pool.size", "500", + "Default size for DirectAgentPool", false); + protected final ConfigKey DirectAgentThreadCap = new ConfigKey("Advanced", Float.class, "direct.agent.thread.cap", "0.1", + "Percentage (as a value between 0 and 1) of direct.agent.pool.size to be used as upper thread cap for a single direct agent to process requests", false); + protected final ConfigKey CheckTxnBeforeSending = new ConfigKey( + "Developer", + Boolean.class, + "check.txn.before.sending.agent.commands", + "false", + "This parameter allows developers to enable a check to see if a transaction wraps commands that are sent to the resource. This is not to be enabled on production systems.", + true); @Override public boolean configure(final String name, final Map params) throws ConfigurationException { @@ -372,7 +385,16 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl if (timeout <= 0) { timeout = Wait.value(); } - assert noDbTxn() : "I know, I know. Why are we so strict as to not allow txn across an agent call? ... Why are we so cruel ... Why are we such a dictator .... Too bad... Sorry...but NO AGENT COMMANDS WRAPPED WITHIN DB TRANSACTIONS!"; + + if (CheckTxnBeforeSending.value()) { + if (!noDbTxn()) { + throw new CloudRuntimeException("We do not allow transactions to be wrapped around commands sent to be executed on remote agents. " + + "We cannot predict how long it takes a command to complete. " + + "The transaction may be rolled back because the connection took too long."); + } + } else { + assert noDbTxn() : "I know, I know. Why are we so strict as to not allow txn across an agent call? ... Why are we so cruel ... Why are we such a dictator .... Too bad... Sorry...but NO AGENT COMMANDS WRAPPED WITHIN DB TRANSACTIONS!"; + } Command[] cmds = commands.toCommands(); @@ -495,12 +517,12 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl ConnectionException ce = (ConnectionException)e; if (ce.isSetupError()) { s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + - " due to " + e.getMessage()); + " due to " + e.getMessage()); handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true); throw ce; } else { s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + - " due to " + e.getMessage()); + " due to " + e.getMessage()); handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true); return attache; } @@ -509,7 +531,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl throw new CloudRuntimeException("Unable to connect " + attache.getId(), e); } else { s_logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + - " due to " + e.getMessage(), e); + " due to " + e.getMessage(), e); handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true); throw new CloudRuntimeException("Unable to connect " + attache.getId(), e); } @@ -770,6 +792,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl protected boolean handleDisconnectWithInvestigation(AgentAttache attache, Status.Event event) { long hostId = attache.getId(); HostVO host = _hostDao.findById(hostId); + if (host != null) { Status nextStatus = null; try { @@ -819,7 +842,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); if ((host.getType() != Host.Type.SecondaryStorage) && (host.getType() != Host.Type.ConsoleProxy)) { _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host disconnected, " + hostDesc, - "If the agent for host [" + hostDesc + "] is not restarted within " + AlertWait + " seconds, HA will begin on the VMs"); + "If the agent for host [" + hostDesc + "] is not restarted within " + AlertWait + " seconds, HA will begin on the VMs"); } event = Status.Event.AgentDisconnected; } @@ -829,7 +852,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl HostPodVO podVO = _podDao.findById(host.getPodId()); String hostDesc = "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host in ALERT state, " + hostDesc, - "In availability zone " + host.getDataCenterId() + "In availability zone " + host.getDataCenterId() + ", host is in alert state: " + host.getId() + "-" + host.getName()); } } else { @@ -838,8 +861,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl } handleDisconnectWithoutInvestigation(attache, event, true, true); - host = _hostDao.findById(host.getId()); - if (host.getStatus() == Status.Alert || host.getStatus() == Status.Down) { + host = _hostDao.findById(hostId); // Maybe the host magically reappeared? + if (host != null && (host.getStatus() == Status.Alert || host.getStatus() == Status.Down)) { _haMgr.scheduleRestartForVmsOnHost(host, true); } @@ -1093,7 +1116,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl for (int i = 0; i < cmds.length; i++) { cmd = cmds[i]; if ((cmd instanceof StartupRoutingCommand) || (cmd instanceof StartupProxyCommand) || (cmd instanceof StartupSecondaryStorageCommand) || - (cmd instanceof StartupStorageCommand)) { + (cmd instanceof StartupStorageCommand)) { answers[i] = new StartupAnswer((StartupCommand)cmds[i], 0, getPingInterval()); break; } @@ -1172,7 +1195,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl final ShutdownCommand shutdown = (ShutdownCommand)cmd; final String reason = shutdown.getReason(); s_logger.info("Host " + attache.getId() + " has informed us that it is shutting down with reason " + reason + " and detail " + - shutdown.getDetail()); + shutdown.getDetail()); if (reason.equals(ShutdownCommand.Update)) { //disconnectWithoutInvestigation(attache, Event.UpdateNeeded); throw new CloudRuntimeException("Agent update not implemented"); @@ -1200,17 +1223,17 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId()); HostPodVO podVO = _podDao.findById(host.getPodId()); String hostDesc = - "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); + "name: " + host.getName() + " (id:" + host.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId(), - "Host lost connection to gateway, " + hostDesc, "Host [" + hostDesc + + "Host lost connection to gateway, " + hostDesc, "Host [" + hostDesc + "] lost connection to gateway (default route) and is possibly having network connection issues."); } else { _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId()); } } else { s_logger.debug("Not processing " + PingRoutingCommand.class.getSimpleName() + " for agent id=" + cmdHostId + - "; can't find the host in the DB"); + "; can't find the host in the DB"); } } answer = new PingAnswer((PingCommand)cmd); @@ -1252,9 +1275,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl final AgentAttache attache = (AgentAttache)link.attachment(); if (attache == null) { s_logger.warn("Unable to process: " + response); - } - - if (!attache.processAnswers(response.getSequence(), response)) { + } else if (!attache.processAnswers(response.getSequence(), response)) { s_logger.info("Host " + attache.getId() + " - Seq " + response.getSequence() + ": Response is not processed: " + response); } } @@ -1334,9 +1355,9 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl return _statusStateMachine.transitTo(host, e, host.getId(), _hostDao); } catch (NoTransitionException e1) { status_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", name=" + host.getName() + - ", mangement server id is " + msId); + ", mangement server id is " + msId); throw new CloudRuntimeException("Cannot transit agent status with event " + e + " for host " + host.getId() + ", mangement server id is " + msId + "," + - e1.getMessage()); + e1.getMessage()); } } finally { _agentStatusLock.unlock(); @@ -1464,8 +1485,16 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl status_logger.debug("Ping timeout but host " + agentId + " is in resource state of " + resourceState + ", so no investigation"); disconnectWithoutInvestigation(agentId, Event.ShutdownRequested); } else { - status_logger.debug("Ping timeout for host " + agentId + ", do invstigation"); - disconnectWithInvestigation(agentId, Event.PingTimeout); + HostVO host = _hostDao.findById(agentId); + if (host != null && (host.getType() == Host.Type.ConsoleProxy || host.getType() == Host.Type.SecondaryStorageVM + || host.getType() == Host.Type.SecondaryStorageCmdExecutor)) { + + s_logger.warn("Disconnect agent for CPVM/SSVM due to physical connection close. host: " + host.getId()); + disconnectWithoutInvestigation(agentId, Event.ShutdownRequested); + } else { + status_logger.debug("Ping timeout for host " + agentId + ", do invstigation"); + disconnectWithInvestigation(agentId, Event.PingTimeout); + } } } } @@ -1569,7 +1598,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl @Override public ConfigKey[] getConfigKeys() { - return new ConfigKey[] {Workers, Port, PingInterval, PingTimeout, Wait, AlertWait, DirectAgentLoadSize, DirectAgentPoolSize, DirectAgentThreadCap}; + return new ConfigKey[] {CheckTxnBeforeSending, Workers, Port, PingInterval, PingTimeout, Wait, AlertWait, DirectAgentLoadSize, DirectAgentPoolSize, DirectAgentThreadCap}; } } diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java index 23c3f7694bc..306c47ff60c 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentAttache.java @@ -42,17 +42,17 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout protected final LinkedList _transferRequests; protected boolean _transferMode = false; - static public void initialize(ClusteredAgentManagerImpl agentMgr) { + static public void initialize(final ClusteredAgentManagerImpl agentMgr) { s_clusteredAgentMgr = agentMgr; } - public ClusteredAgentAttache(AgentManagerImpl agentMgr, long id, String name) { + public ClusteredAgentAttache(final AgentManagerImpl agentMgr, final long id, final String name) { super(agentMgr, id, name, null, false); _forward = true; _transferRequests = new LinkedList(); } - public ClusteredAgentAttache(AgentManagerImpl agentMgr, long id, String name, Link link, boolean maintenance) { + public ClusteredAgentAttache(final AgentManagerImpl agentMgr, final long id, final String name, final Link link, final boolean maintenance) { super(agentMgr, id, name, link, maintenance); _forward = link == null; _transferRequests = new LinkedList(); @@ -84,7 +84,7 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout } @Override - public void cancel(long seq) { + public void cancel(final long seq) { if (forForward()) { Listener listener = getListener(seq); if (listener != null && listener instanceof SynchronousListener) { @@ -106,7 +106,7 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout } @Override - public void routeToAgent(byte[] data) throws AgentUnavailableException { + public void routeToAgent(final byte[] data) throws AgentUnavailableException { if (s_logger.isDebugEnabled()) { s_logger.debug(log(Request.getSequence(data), "Routing from " + Request.getManagementServerId(data))); } @@ -136,7 +136,7 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout } @Override - public void send(Request req, Listener listener) throws AgentUnavailableException { + public void send(final Request req, final Listener listener) throws AgentUnavailableException { if (_link != null) { super.send(req, listener); return; @@ -220,7 +220,7 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout _transferMode = transfer; } - public boolean getTransferMode() { + public synchronized boolean getTransferMode() { return _transferMode; } @@ -232,13 +232,13 @@ public class ClusteredAgentAttache extends ConnectedAgentAttache implements Rout } } - protected synchronized void addRequestToTransfer(Request req) { + protected synchronized void addRequestToTransfer(final Request req) { int index = findTransferRequest(req); assert (index < 0) : "How can we get index again? " + index + ":" + req.toString(); _transferRequests.add(-index - 1, req); } - protected synchronized int findTransferRequest(Request req) { + protected synchronized int findTransferRequest(final Request req) { return Collections.binarySearch(_transferRequests, req, s_reqComparator); } diff --git a/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java index 00d54bb2450..f11a105b2a1 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/ConnectedAgentAttache.java @@ -33,13 +33,13 @@ public class ConnectedAgentAttache extends AgentAttache { protected Link _link; - public ConnectedAgentAttache(AgentManagerImpl agentMgr, final long id, final String name, final Link link, boolean maintenance) { + public ConnectedAgentAttache(final AgentManagerImpl agentMgr, final long id, final String name, final Link link, final boolean maintenance) { super(agentMgr, id, name, maintenance); _link = link; } @Override - public synchronized void send(Request req) throws AgentUnavailableException { + public synchronized void send(final Request req) throws AgentUnavailableException { try { _link.send(req.toBytes()); } catch (ClosedChannelException e) { @@ -67,14 +67,31 @@ public class ConnectedAgentAttache extends AgentAttache { } @Override - public boolean equals(Object obj) { - try { - ConnectedAgentAttache that = (ConnectedAgentAttache)obj; - return super.equals(obj) && _link == that._link && _link != null; - } catch (ClassCastException e) { - assert false : "Who's sending an " + obj.getClass().getSimpleName() + " to " + this.getClass().getSimpleName() + ".equals()? "; + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((_link == null) ? 0 : _link.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + // Return false straight away. + if (obj == null) { return false; } + // No need to handle a ClassCastException. If the classes are different, then equals can return false straight ahead. + if (this.getClass() != obj.getClass()) { + return false; + } + // This should not be part of the equals() method, but I'm keeping it because it is expected behaviour based + // on the previous implementation. The link attribute of the other object should be checked here as well + // to verify if it's not null whilst the this is null. + if (_link == null) { + return false; + } + ConnectedAgentAttache that = (ConnectedAgentAttache)obj; + return super.equals(obj) && _link == that._link; } @Override diff --git a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java index ef002d0f3eb..9874ee41932 100755 --- a/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java +++ b/engine/orchestration/src/com/cloud/agent/manager/DirectAgentAttache.java @@ -34,7 +34,6 @@ import com.cloud.agent.transport.Request; import com.cloud.agent.transport.Response; import com.cloud.exception.AgentUnavailableException; import com.cloud.host.Status; -import com.cloud.host.Status.Event; import com.cloud.resource.ServerResource; public class DirectAgentAttache extends AgentAttache { @@ -145,7 +144,6 @@ public class DirectAgentAttache extends AgentAttache { PingCommand cmd = resource.getCurrentStatus(_id); if (cmd == null) { s_logger.warn("Unable to get current status on " + _id + "(" + _name + ")"); - _mgr.disconnectWithInvestigation(DirectAgentAttache.this, Event.AgentDisconnected); return; } if (s_logger.isDebugEnabled()) { @@ -182,7 +180,7 @@ public class DirectAgentAttache extends AgentAttache { Command[] cmds = _req.getCommands(); ArrayList answers = new ArrayList(cmds.length); for (Command cmd : cmds) { - Answer answer = new Answer(cmd, false, "Bailed out as maximum oustanding task limit reached"); + Answer answer = new Answer(cmd, false, "Bailed out as maximum outstanding task limit reached"); answers.add(answer); } Response resp = new Response(_req, answers.toArray(new Answer[answers.size()])); diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java index b71252879fc..c5a7efb6f1a 100755 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1,4 +1,4 @@ -// Licensed to the Apache Software Foundation (ASF) under one +// Licensed to the Apacohe 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 @@ -40,13 +40,12 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.apache.log4j.Logger; - import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigKey; @@ -69,6 +68,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.utils.identity.ManagementServerNode; +import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; @@ -79,6 +79,8 @@ import com.cloud.agent.api.CheckVirtualMachineAnswer; import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.ClusterSyncAnswer; import com.cloud.agent.api.ClusterSyncCommand; +import com.cloud.agent.api.ClusterVMMetaDataSyncAnswer; +import com.cloud.agent.api.ClusterVMMetaDataSyncCommand; import com.cloud.agent.api.Command; import com.cloud.agent.api.MigrateAnswer; import com.cloud.agent.api.MigrateCommand; @@ -100,6 +102,7 @@ import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.UnPlugNicAnswer; import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.to.DiskTO; +import com.cloud.agent.api.to.GPUDeviceTO; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.manager.Commands; @@ -136,6 +139,7 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.StorageUnavailableException; +import com.cloud.gpu.dao.VGPUTypesDao; import com.cloud.ha.HighAvailabilityManager; import com.cloud.ha.HighAvailabilityManager.WorkType; import com.cloud.host.Host; @@ -150,7 +154,7 @@ import com.cloud.network.NetworkModel; import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkVO; import com.cloud.network.rules.RulesManager; -import com.cloud.offering.DiskOffering; +import com.cloud.offering.DiskOfferingInfo; import com.cloud.offering.ServiceOffering; import com.cloud.org.Cluster; import com.cloud.resource.ResourceManager; @@ -272,6 +276,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Inject protected AffinityGroupVMMapDao _affinityGroupVMMapDao; @Inject + protected VGPUTypesDao _vgpuTypesDao; + @Inject protected EntityManager _entityMgr; @Inject @@ -284,7 +290,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } public void setHostAllocators(List hostAllocators) { - this.hostAllocators = hostAllocators; + hostAllocators = hostAllocators; } protected List _storagePoolAllocators; @@ -322,36 +328,38 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac protected StateMachine2 _stateMachine; static final ConfigKey StartRetry = new ConfigKey("Advanced", Integer.class, "start.retry", "10", - "Number of times to retry create and start commands", true); + "Number of times to retry create and start commands", true); static final ConfigKey VmOpWaitInterval = new ConfigKey("Advanced", Integer.class, "vm.op.wait.interval", "120", - "Time (in seconds) to wait before checking if a previous operation has succeeded", true); + "Time (in seconds) to wait before checking if a previous operation has succeeded", true); static final ConfigKey VmOpLockStateRetry = new ConfigKey("Advanced", Integer.class, "vm.op.lock.state.retry", "5", - "Times to retry locking the state of a VM for operations, -1 means forever", true); + "Times to retry locking the state of a VM for operations, -1 means forever", true); static final ConfigKey VmOpCleanupInterval = new ConfigKey("Advanced", Long.class, "vm.op.cleanup.interval", "86400", - "Interval to run the thread that cleans up the vm operations (in seconds)", false); + "Interval to run the thread that cleans up the vm operations (in seconds)", false); static final ConfigKey VmOpCleanupWait = new ConfigKey("Advanced", Long.class, "vm.op.cleanup.wait", "3600", - "Time (in seconds) to wait before cleanuping up any vm work items", true); + "Time (in seconds) to wait before cleanuping up any vm work items", true); static final ConfigKey VmOpCancelInterval = new ConfigKey("Advanced", Long.class, "vm.op.cancel.interval", "3600", - "Time (in seconds) to wait before cancelling a operation", false); + "Time (in seconds) to wait before cancelling a operation", false); static final ConfigKey VmDestroyForcestop = new ConfigKey("Advanced", Boolean.class, "vm.destroy.forcestop", "false", - "On destroy, force-stop takes this value ", true); + "On destroy, force-stop takes this value ", true); static final ConfigKey ClusterDeltaSyncInterval = new ConfigKey("Advanced", Integer.class, "sync.interval", "60", - "Cluster Delta sync interval in seconds", - false); + "Cluster Delta sync interval in seconds", + false); + static final ConfigKey ClusterVMMetaDataSyncInterval = new ConfigKey("Advanced", Integer.class, "vmmetadata.sync.interval", "180", "Cluster VM metadata sync interval in seconds", + false); static final ConfigKey VmJobEnabled = new ConfigKey("Advanced", - Boolean.class, "vm.job.enabled", "false", - "True to enable new VM sync model. false to use the old way", false); + Boolean.class, "vm.job.enabled", "true", + "True to enable new VM sync model. false to use the old way", false); static final ConfigKey VmJobCheckInterval = new ConfigKey("Advanced", - Long.class, "vm.job.check.interval", "3000", - "Interval in milliseconds to check if the job is complete", false); + Long.class, "vm.job.check.interval", "3000", + "Interval in milliseconds to check if the job is complete", false); static final ConfigKey VmJobTimeout = new ConfigKey("Advanced", - Long.class, "vm.job.timeout", "600000", - "Time in milliseconds to wait before attempting to cancel a job", false); + Long.class, "vm.job.timeout", "600000", + "Time in milliseconds to wait before attempting to cancel a job", false); static final ConfigKey VmJobStateReportInterval = new ConfigKey("Advanced", - Integer.class, "vm.job.report.interval", "60", - "Interval to send application level pings to make sure the connection is still working", false); + Integer.class, "vm.job.report.interval", "60", + "Interval to send application level pings to make sure the connection is still working", false); ScheduledExecutorService _executor = null; @@ -367,9 +375,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override @DB public void allocate(String vmInstanceName, final VirtualMachineTemplate template, ServiceOffering serviceOffering, - final Pair rootDiskOffering, LinkedHashMap dataDiskOfferings, - final LinkedHashMap auxiliaryNetworks, DeploymentPlan plan, HypervisorType hyperType) - throws InsufficientCapacityException { + final DiskOfferingInfo rootDiskOfferingInfo, final List dataDiskOfferings, + final LinkedHashMap> auxiliaryNetworks, DeploymentPlan plan, HypervisorType hyperType) + throws InsufficientCapacityException { VMInstanceVO vm = _vmDao.findVMByInstanceName(vmInstanceName); final Account owner = _entityMgr.findById(Account.class, vm.getAccountId()); @@ -384,51 +392,54 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } assert (plan.getClusterId() == null && plan.getPoolId() == null) : "We currently don't support cluster and pool preset yet"; final VMInstanceVO vmFinal = _vmDao.persist(vm); - final LinkedHashMap dataDiskOfferingsFinal = - dataDiskOfferings == null ? new LinkedHashMap() : dataDiskOfferings; - final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmFinal, template, serviceOffering, null, null); + final VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmFinal, template, serviceOffering, null, null); - Transaction.execute(new TransactionCallbackWithExceptionNoReturn() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) throws InsufficientCapacityException { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Allocating nics for " + vmFinal); - } + Transaction.execute(new TransactionCallbackWithExceptionNoReturn() { + @Override + public void doInTransactionWithoutResult(TransactionStatus status) throws InsufficientCapacityException { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Allocating nics for " + vmFinal); + } - try { - _networkMgr.allocate(vmProfile, auxiliaryNetworks); - } catch (ConcurrentOperationException e) { - throw new CloudRuntimeException("Concurrent operation while trying to allocate resources for the VM", e); - } + try { + _networkMgr.allocate(vmProfile, auxiliaryNetworks); + } catch (ConcurrentOperationException e) { + throw new CloudRuntimeException("Concurrent operation while trying to allocate resources for the VM", e); + } + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Allocating disks for " + vmFinal); + } + + if (template.getFormat() == ImageFormat.ISO) { + volumeMgr.allocateRawVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOfferingInfo.getDiskOffering(), rootDiskOfferingInfo.getSize(), + rootDiskOfferingInfo.getMinIops(), rootDiskOfferingInfo.getMaxIops(), vmFinal, template, owner); + } else if (template.getFormat() == ImageFormat.BAREMETAL) { + // Do nothing + } else { + volumeMgr.allocateTemplatedVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOfferingInfo.getDiskOffering(), rootDiskOfferingInfo.getSize(), + rootDiskOfferingInfo.getMinIops(), rootDiskOfferingInfo.getMaxIops(), template, vmFinal, owner); + } + + if (dataDiskOfferings != null) { + for (DiskOfferingInfo dataDiskOfferingInfo : dataDiskOfferings) { + volumeMgr.allocateRawVolume(Type.DATADISK, "DATA-" + vmFinal.getId(), dataDiskOfferingInfo.getDiskOffering(), dataDiskOfferingInfo.getSize(), + dataDiskOfferingInfo.getMinIops(), dataDiskOfferingInfo.getMaxIops(), vmFinal, template, owner); + } + } + } + }); if (s_logger.isDebugEnabled()) { - s_logger.debug("Allocating disks for " + vmFinal); + s_logger.debug("Allocation completed for VM: " + vmFinal); } - - if (template.getFormat() == ImageFormat.ISO) { - volumeMgr.allocateRawVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOffering.first(), rootDiskOffering.second(), vmFinal, template, owner); - } else if (template.getFormat() == ImageFormat.BAREMETAL) { - // Do nothing - } else { - volumeMgr.allocateTemplatedVolume(Type.ROOT, "ROOT-" + vmFinal.getId(), rootDiskOffering.first(), rootDiskOffering.second(), template, vmFinal, owner); - } - - for (Map.Entry offering : dataDiskOfferingsFinal.entrySet()) { - volumeMgr.allocateRawVolume(Type.DATADISK, "DATA-" + vmFinal.getId(), offering.getKey(), offering.getValue(), vmFinal, template, owner); - } - } - }); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("Allocation completed for VM: " + vmFinal); - } } @Override public void allocate(String vmInstanceName, VirtualMachineTemplate template, ServiceOffering serviceOffering, - LinkedHashMap networks, DeploymentPlan plan, HypervisorType hyperType) throws InsufficientCapacityException { - allocate(vmInstanceName, template, serviceOffering, new Pair(serviceOffering, null), null, networks, plan, hyperType); + LinkedHashMap> networks, DeploymentPlan plan, HypervisorType hyperType) throws InsufficientCapacityException { + allocate(vmInstanceName, template, serviceOffering, new DiskOfferingInfo(serviceOffering), new ArrayList(), networks, plan, hyperType); } private VirtualMachineGuru getVmGuru(VirtualMachine vm) { @@ -558,8 +569,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public boolean start() { // TODO, initial delay is hardcoded - _executor.scheduleAtFixedRate(new TransitionTask(), 5000, VmJobStateReportInterval.value(), TimeUnit.SECONDS); - _executor.scheduleAtFixedRate(new CleanupTask(), VmOpCleanupInterval.value(), VmOpCleanupInterval.value(), TimeUnit.SECONDS); + _executor.scheduleAtFixedRate(new CleanupTask(), 5, VmJobStateReportInterval.value(), TimeUnit.SECONDS); + _executor.scheduleAtFixedRate(new TransitionTask(), VmOpCleanupInterval.value(), VmOpCleanupInterval.value(), TimeUnit.SECONDS); cancelWorkItems(_nodeId); // cleanup left over place holder works @@ -576,6 +587,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac public boolean configure(String name, Map xmlParams) throws ConfigurationException { ReservationContextImpl.init(_entityMgr); VirtualMachineProfileImpl.init(_entityMgr); + VmWorkMigrate.init(_entityMgr); _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup")); _nodeId = ManagementServerNode.getManagementServerId(); @@ -595,13 +607,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public void start(String vmUuid, Map params) { - start(vmUuid, params, null); + start(vmUuid, params, null, null); } @Override - public void start(String vmUuid, Map params, DeploymentPlan planToDeploy) { + public void start(String vmUuid, Map params, DeploymentPlan planToDeploy, DeploymentPlanner planner) { try { - advanceStart(vmUuid, params, planToDeploy, null); + advanceStart(vmUuid, params, planToDeploy, planner); } catch (ConcurrentOperationException e) { throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e).add(VirtualMachine.class, vmUuid); } catch (InsufficientCapacityException e) { @@ -634,7 +646,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } try { - Thread.sleep(VmOpWaitInterval.value()); + Thread.sleep(VmOpWaitInterval.value()*1000); } catch (InterruptedException e) { s_logger.info("Waiting for " + vm + " but is interrupted"); throw new ConcurrentOperationException("Waiting for " + vm + " but is interrupted"); @@ -646,7 +658,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @DB protected Ternary changeToStartState(VirtualMachineGuru vmGuru, final VMInstanceVO vm, final User caller, - final Account account) throws ConcurrentOperationException { + final Account account) throws ConcurrentOperationException { long vmId = vm.getId(); ItWorkVO work = new ItWorkVO(UUID.randomUUID().toString(), _nodeId, State.Starting, vm.getType(), vm.getId()); @@ -655,23 +667,23 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac try { final ItWorkVO workFinal = work; Ternary result = - Transaction.execute(new TransactionCallbackWithException, NoTransitionException>() { - @Override - public Ternary doInTransaction(TransactionStatus status) throws NoTransitionException { - Journal journal = new Journal.LogJournal("Creating " + vm, s_logger); - ItWorkVO work = _workDao.persist(workFinal); - ReservationContextImpl context = new ReservationContextImpl(work.getId(), journal, caller, account); + Transaction.execute(new TransactionCallbackWithException, NoTransitionException>() { + @Override + public Ternary doInTransaction(TransactionStatus status) throws NoTransitionException { + Journal journal = new Journal.LogJournal("Creating " + vm, s_logger); + ItWorkVO work = _workDao.persist(workFinal); + ReservationContextImpl context = new ReservationContextImpl(work.getId(), journal, caller, account); - if (stateTransitTo(vm, Event.StartRequested, null, work.getId())) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully transitioned to start state for " + vm + " reservation id = " + work.getId()); + if (stateTransitTo(vm, Event.StartRequested, null, work.getId())) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully transitioned to start state for " + vm + " reservation id = " + work.getId()); + } + return new Ternary(vm, context, work); } - return new Ternary(vm, context, work); - } - return new Ternary(null, null, work); - } - }); + return new Ternary(null, null, work); + } + }); work = result.third(); if (result.first() != null) @@ -743,13 +755,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public void advanceStart(String vmUuid, Map params, DeploymentPlanner planner) - throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { + throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { advanceStart(vmUuid, params, null, planner); } @Override - public void advanceStart(String vmUuid, Map params, DeploymentPlan planToDeploy, DeploymentPlanner planner) throws InsufficientCapacityException, - ConcurrentOperationException, ResourceUnavailableException { + public void advanceStart(String vmUuid, Map params, DeploymentPlan planToDeploy, DeploymentPlanner planner) + throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext(); if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) { @@ -766,7 +778,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac _workJobDao.expunge(placeHolder.getId()); } } else { - Outcome outcome = startVmThroughJobQueue(vmUuid, params, planToDeploy); + Outcome outcome = startVmThroughJobQueue(vmUuid, params, planToDeploy, planner); try { VirtualMachine vm = outcome.get(); @@ -782,6 +794,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw (ConcurrentOperationException)jobResult; else if (jobResult instanceof ResourceUnavailableException) throw (ResourceUnavailableException)jobResult; + else if (jobResult instanceof InsufficientCapacityException) + throw (InsufficientCapacityException)jobResult; + else if (jobResult instanceof RuntimeException) + throw (RuntimeException)jobResult; + else if (jobResult instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobResult); } } } @@ -819,11 +837,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (planToDeploy != null && planToDeploy.getDataCenterId() != 0) { if (s_logger.isDebugEnabled()) { s_logger.debug("advanceStart: DeploymentPlan is provided, using dcId:" + planToDeploy.getDataCenterId() + ", podId: " + planToDeploy.getPodId() + - ", clusterId: " + planToDeploy.getClusterId() + ", hostId: " + planToDeploy.getHostId() + ", poolId: " + planToDeploy.getPoolId()); + ", clusterId: " + planToDeploy.getClusterId() + ", hostId: " + planToDeploy.getHostId() + ", poolId: " + planToDeploy.getPoolId()); } plan = - new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), - planToDeploy.getPoolId(), planToDeploy.getPhysicalNetworkId(), ctx); + new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), planToDeploy.getHostId(), + planToDeploy.getPoolId(), planToDeploy.getPhysicalNetworkId(), ctx); } HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType()); @@ -881,21 +899,21 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // planner if (s_logger.isDebugEnabled()) { s_logger.debug("Cannot satisfy the deployment plan passed in since the ready Root volume is in different cluster. volume's cluster: " + - rootVolClusterId + ", cluster specified: " + clusterIdSpecified); + rootVolClusterId + ", cluster specified: " + clusterIdSpecified); } throw new ResourceUnavailableException( - "Root volume is ready in different cluster, Deployment plan provided cannot be satisfied, unable to create a deployment for " + - vm, Cluster.class, clusterIdSpecified); + "Root volume is ready in different cluster, Deployment plan provided cannot be satisfied, unable to create a deployment for " + + vm, Cluster.class, clusterIdSpecified); } } plan = - new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), - planToDeploy.getHostId(), vol.getPoolId(), null, ctx); + new DataCenterDeployment(planToDeploy.getDataCenterId(), planToDeploy.getPodId(), planToDeploy.getClusterId(), + planToDeploy.getHostId(), vol.getPoolId(), null, ctx); } else { plan = new DataCenterDeployment(rootVolDcId, rootVolPodId, rootVolClusterId, null, vol.getPoolId(), null, ctx); if (s_logger.isDebugEnabled()) { s_logger.debug(vol + " is READY, changing deployment plan to use this pool's dcId: " + rootVolDcId + " , podId: " + rootVolPodId + - " , and clusterId: " + rootVolClusterId); + " , and clusterId: " + rootVolClusterId); } planChangedByVolume = true; } @@ -923,7 +941,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac continue; } throw new InsufficientServerCapacityException("Unable to create a deployment for " + vmProfile, DataCenter.class, plan.getDataCenterId(), - areAffinityGroupsAssociated(vmProfile)); + areAffinityGroupsAssociated(vmProfile)); } if (dest != null) { @@ -938,12 +956,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id, "memoryOvercommitRatio"); //storing the value of overcommit in the vm_details table for doing a capacity check in case the cluster overcommit ratio is changed. if (_uservmDetailsDao.findDetail(vm.getId(), "cpuOvercommitRatio") == null && - ((Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f))) { - _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue()); - _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue()); + ((Float.parseFloat(cluster_detail_cpu.getValue()) > 1f || Float.parseFloat(cluster_detail_ram.getValue()) > 1f))) { + _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue(), true); + _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue(), true); } else if (_uservmDetailsDao.findDetail(vm.getId(), "cpuOvercommitRatio") != null) { - _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue()); - _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue()); + _uservmDetailsDao.addDetail(vm.getId(), "cpuOvercommitRatio", cluster_detail_cpu.getValue(), true); + _uservmDetailsDao.addDetail(vm.getId(), "memoryOvercommitRatio", cluster_detail_ram.getValue(), true); } vmProfile.setCpuOvercommitRatio(Float.parseFloat(cluster_detail_cpu.getValue())); vmProfile.setMemoryOvercommitRatio(Float.parseFloat(cluster_detail_ram.getValue())); @@ -978,7 +996,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac handlePath(vmTO.getDisks(), vm.getHypervisorType()); cmds = new Commands(Command.OnError.Stop); - cmds.addCommand(new StartCommand(vmTO, dest.getHost(), ExecuteInSequence.value())); + + cmds.addCommand(new StartCommand(vmTO, dest.getHost(), getExecuteInSequence(vm.getHypervisorType()))); + vmGuru.finalizeDeployment(cmds, vmProfile, dest, ctx); @@ -1011,6 +1031,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw new ConcurrentOperationException("Unable to transition to a new state."); } + // Update GPU device capacity + GPUDeviceTO gpuDevice = startAnswer.getVirtualMachine().getGpuDevice(); + if (gpuDevice != null) { + _resourceMgr.updateGPUDetails(destHostId, gpuDevice.getGroupDetails()); + } + startedVm = vm; if (s_logger.isDebugEnabled()) { s_logger.debug("Start completed for VM " + vm); @@ -1021,16 +1047,16 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.info("The guru did not like the answers so stopping " + vm); } - StopCommand cmd = new StopCommand(vm, ExecuteInSequence.value()); - StopAnswer answer = (StopAnswer)_agentMgr.easySend(destHostId, cmd); - if (answer != null) { + StopCommand cmd = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType())); + StopAnswer answer = (StopAnswer) _agentMgr.easySend(destHostId, cmd); + if ( answer != null ) { + if (vm.getType() == VirtualMachine.Type.User) { String platform = answer.getPlatform(); if (platform != null) { - UserVmVO userVm = _userVmDao.findById(vm.getId()); - _userVmDao.loadDetails(userVm); - userVm.setDetail("platform", platform); - _userVmDao.saveDetails(userVm); + Map vmmetadata = new HashMap(); + vmmetadata.put(vm.getInstanceName(), platform); + syncVMMetaData(vmmetadata); } } } @@ -1190,9 +1216,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } } + + protected boolean getExecuteInSequence(HypervisorType hypervisorType) { + if (HypervisorType.KVM == hypervisorType) { + return false; + } else { + return ExecuteInSequence.value(); + } + } + protected boolean sendStop(VirtualMachineGuru guru, VirtualMachineProfile profile, boolean force) { VirtualMachine vm = profile.getVirtualMachine(); - StopCommand stop = new StopCommand(vm, ExecuteInSequence.value()); + StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType())); try { StopAnswer answer = (StopAnswer)_agentMgr.send(vm.getHostId(), stop); if (answer != null) { @@ -1205,13 +1240,22 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac _userVmDao.saveDetails(userVm); } } - } - if (!answer.getResult()) { - s_logger.debug("Unable to stop VM due to " + answer.getDetails()); + + GPUDeviceTO gpuDevice = stop.getGpuDevice(); + if (gpuDevice != null) { + _resourceMgr.updateGPUDetails(vm.getHostId(), gpuDevice.getGroupDetails()); + } + if (!answer.getResult()) { + s_logger.debug("Unable to stop VM due to " + answer.getDetails()); + return false; + } + + guru.finalizeStop(profile, answer); + } else { + s_logger.error("Invalid answer received in response to a StopCommand for " + vm.getInstanceName()); return false; } - guru.finalizeStop(profile, answer); } catch (AgentUnavailableException e) { if (!force) { return false; @@ -1327,6 +1371,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw (ConcurrentOperationException)jobResult; else if (jobResult instanceof OperationTimedoutException) throw (OperationTimedoutException)jobResult; + else if (jobResult instanceof RuntimeException) + throw (RuntimeException)jobResult; + else if (jobResult instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobResult); } } } @@ -1338,7 +1386,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } private void advanceStop(VMInstanceVO vm, boolean cleanUpEvenIfUnableToStop) throws AgentUnavailableException, OperationTimedoutException, - ConcurrentOperationException { + ConcurrentOperationException { State state = vm.getState(); if (state == State.Stopped) { if (s_logger.isDebugEnabled()) { @@ -1439,7 +1487,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } vmGuru.prepareStop(profile); - StopCommand stop = new StopCommand(vm, ExecuteInSequence.value()); + + StopCommand stop = new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType())); + boolean stopped = false; StopAnswer answer = null; try { @@ -1454,12 +1504,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac _userVmDao.saveDetails(userVm); } } + stopped = answer.getResult(); + if (!stopped) { + throw new CloudRuntimeException("Unable to stop the virtual machine due to " + answer.getDetails()); + } + vmGuru.finalizeStop(profile, answer); + GPUDeviceTO gpuDevice = stop.getGpuDevice(); + if (gpuDevice != null) { + _resourceMgr.updateGPUDetails(vm.getHostId(), gpuDevice.getGroupDetails()); + } + } else { + throw new CloudRuntimeException("Invalid answer received in response to a StopCommand on " + vm.instanceName); } - stopped = answer.getResult(); - if (!stopped) { - throw new CloudRuntimeException("Unable to stop the virtual machine due to " + answer.getDetails()); - } - vmGuru.finalizeStop(profile, answer); } catch (AgentUnavailableException e) { s_logger.warn("Unable to stop vm, agent unavailable: " + e.toString()); @@ -1525,6 +1581,16 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } protected boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long hostId, String reservationId) throws NoTransitionException { + // if there are active vm snapshots task, state change is not allowed + + // Disable this hacking thing, VM snapshot task need to be managed by its orchestartion flow istelf instead of + // hacking it here at general VM manager + /* + if (_vmSnapshotMgr.hasActiveVMSnapshotTasks(vm.getId())) { + s_logger.error("State transit with event: " + e + " failed due to: " + vm.getInstanceName() + " has active VM snapshots tasks"); + return false; + } + */ vm.setReservationId(reservationId); return _stateMachine.transitTo(vm, e, new Pair(vm.getHostId(), hostId), _vmDao); } @@ -1532,11 +1598,15 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public boolean stateTransitTo(VirtualMachine vm1, VirtualMachine.Event e, Long hostId) throws NoTransitionException { VMInstanceVO vm = (VMInstanceVO)vm1; - // if there are active vm snapshots task, state change is not allowed - if (_vmSnapshotMgr.hasActiveVMSnapshotTasks(vm.getId())) { - s_logger.error("State transit with event: " + e + " failed due to: " + vm.getInstanceName() + " has active VM snapshots tasks"); - return false; - } + + /* + * Remove the hacking logic here. + // if there are active vm snapshots task, state change is not allowed + if (_vmSnapshotMgr.hasActiveVMSnapshotTasks(vm.getId())) { + s_logger.error("State transit with event: " + e + " failed due to: " + vm.getInstanceName() + " has active VM snapshots tasks"); + return false; + } + */ State oldState = vm.getState(); if (oldState == State.Starting) { @@ -1625,6 +1695,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (jobResult != null) { if (jobResult instanceof RuntimeException) throw (RuntimeException)jobResult; + else if (jobResult instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobResult); } } } @@ -1721,6 +1793,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw (ConcurrentOperationException)jobResult; else if (jobResult instanceof RuntimeException) throw (RuntimeException)jobResult; + else if (jobResult instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobResult); + } } } @@ -1864,8 +1939,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac _networkMgr.rollbackNicForMigration(vmSrc, profile); _alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), - "Unable to migrate vm " + vm.getInstanceName() + " from host " + fromHost.getName() + " in zone " + dest.getDataCenter().getName() + " and pod " + - dest.getPod().getName(), "Migrate Command failed. Please check logs."); + "Unable to migrate vm " + vm.getInstanceName() + " from host " + fromHost.getName() + " in zone " + dest.getDataCenter().getName() + " and pod " + + dest.getPod().getName(), "Migrate Command failed. Please check logs."); try { _agentMgr.send(dstHostId, new Commands(cleanup(vm)), null); } catch (AgentUnavailableException ae) { @@ -1898,8 +1973,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (_poolHostDao.findByPoolHost(pool.getId(), host.getId()) == null || pool.isLocal() != diskOffering.getUseLocalStorage()) { // Cannot find a pool for the volume. Throw an exception. throw new CloudRuntimeException("Cannot migrate volume " + volume + " to storage pool " + pool + " while migrating vm to host " + host + - ". Either the pool is not accessible from the " + "host or because of the offering with which the volume is created it cannot be placed on " + - "the given pool."); + ". Either the pool is not accessible from the " + "host or because of the offering with which the volume is created it cannot be placed on " + + "the given pool."); } else if (pool.getId() == currentPool.getId()) { // If the pool to migrate too is the same as current pool, remove the volume from the list of // volumes to be migrated. @@ -1931,7 +2006,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (!currentPoolAvailable && !volumeToPool.containsKey(volume)) { // Cannot find a pool for the volume. Throw an exception. throw new CloudRuntimeException("Cannot find a storage pool which is available for volume " + volume + " while migrating virtual machine " + - profile.getVirtualMachine() + " to host " + host); + profile.getVirtualMachine() + " to host " + host); } } } @@ -2002,12 +2077,16 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw (ResourceUnavailableException)jobException; else if (jobException instanceof ConcurrentOperationException) throw (ConcurrentOperationException)jobException; - } + else if (jobException instanceof RuntimeException) + throw (RuntimeException)jobException; + else if (jobException instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobException); + } } } private void orchestrateMigrateWithStorage(String vmUuid, long srcHostId, long destHostId, Map volumeToPool) throws ResourceUnavailableException, - ConcurrentOperationException { + ConcurrentOperationException { VMInstanceVO vm = _vmDao.findByUuid(vmUuid); @@ -2028,7 +2107,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // a vm and not migrating a vm with storage. if (volumeToPool.isEmpty()) { throw new InvalidParameterValueException("Migration of the vm " + vm + "from host " + srcHost + " to destination host " + destHost + - " doesn't involve migrating the volumes."); + " doesn't involve migrating the volumes."); } AlertManager.AlertType alertType = AlertManager.AlertType.ALERT_TYPE_USERVM_MIGRATE; @@ -2081,8 +2160,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (!migrated) { s_logger.info("Migration was unsuccessful. Cleaning up: " + vm); _alertMgr.sendAlert(alertType, srcHost.getDataCenterId(), srcHost.getPodId(), - "Unable to migrate vm " + vm.getInstanceName() + " from host " + srcHost.getName() + " in zone " + dc.getName() + " and pod " + dc.getName(), - "Migrate Command failed. Please check logs."); + "Unable to migrate vm " + vm.getInstanceName() + " from host " + srcHost.getName() + " in zone " + dc.getName() + " and pod " + dc.getName(), + "Migrate Command failed. Please check logs."); try { _agentMgr.send(destHostId, new Commands(cleanup(vm.getInstanceName())), null); stateTransitTo(vm, Event.OperationFailed, srcHostId); @@ -2120,10 +2199,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (work.getType() == State.Starting) { _haMgr.scheduleRestart(vm, true); work.setManagementServerId(_nodeId); + work.setStep(Step.Done); _workDao.update(work.getId(), work); } else if (work.getType() == State.Stopping) { _haMgr.scheduleStop(vm, vm.getHostId(), WorkType.CheckStop); work.setManagementServerId(_nodeId); + work.setStep(Step.Done); _workDao.update(work.getId(), work); } else if (work.getType() == State.Migrating) { _haMgr.scheduleMigration(vm); @@ -2145,7 +2226,53 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } @Override - public void migrateAway(String vmUuid, long srcHostId, DeploymentPlanner planner) throws InsufficientServerCapacityException { + public void migrateAway(String vmUuid, long srcHostId) throws InsufficientServerCapacityException { + AsyncJobExecutionContext jobContext = AsyncJobExecutionContext.getCurrentExecutionContext(); + if (!VmJobEnabled.value() || jobContext.isJobDispatchedBy(VmWorkConstants.VM_WORK_JOB_DISPATCHER)) { + // avoid re-entrance + + VmWorkJobVO placeHolder = null; + if (VmJobEnabled.value()) { + VirtualMachine vm = _vmDao.findByUuid(vmUuid); + placeHolder = createPlaceHolderWork(vm.getId()); + } + try { + try { + orchestrateMigrateAway(vmUuid, srcHostId, null); + } catch (InsufficientServerCapacityException e) { + s_logger.warn("Failed to deploy vm " + vmUuid + " with original planner, sending HAPlanner"); + orchestrateMigrateAway(vmUuid, srcHostId, _haMgr.getHAPlanner()); + } + } finally { + if (VmJobEnabled.value()) + _workJobDao.expunge(placeHolder.getId()); + } + } else { + Outcome outcome = migrateVmAwayThroughJobQueue(vmUuid, srcHostId); + + try { + VirtualMachine vm = outcome.get(); + } catch (InterruptedException e) { + throw new RuntimeException("Operation is interrupted", e); + } catch (java.util.concurrent.ExecutionException e) { + throw new RuntimeException("Execution excetion", e); + } + + Object jobException = _jobMgr.unmarshallResultObject(outcome.getJob()); + if (jobException != null) { + if (jobException instanceof InsufficientServerCapacityException) + throw (InsufficientServerCapacityException)jobException; + else if (jobException instanceof ConcurrentOperationException) + throw (ConcurrentOperationException)jobException; + else if (jobException instanceof RuntimeException) + throw (RuntimeException)jobException; + else if (jobException instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobException); + } + } + } + + private void orchestrateMigrateAway(String vmUuid, long srcHostId, DeploymentPlanner planner) throws InsufficientServerCapacityException { VMInstanceVO vm = _vmDao.findByUuid(vmUuid); if (vm == null) { s_logger.debug("Unable to find a VM for " + vmUuid); @@ -2297,6 +2424,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw (ConcurrentOperationException)jobResult; else if (jobResult instanceof InsufficientCapacityException) throw (InsufficientCapacityException)jobResult; + else if (jobResult instanceof RuntimeException) + throw (RuntimeException)jobResult; + else if (jobResult instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobResult); } } } @@ -2307,10 +2438,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac DataCenter dc = _entityMgr.findById(DataCenter.class, vm.getDataCenterId()); Host host = _hostDao.findById(vm.getHostId()); - Cluster cluster = null; - if (host != null) { - cluster = _entityMgr.findById(Cluster.class, host.getClusterId()); + if (host == null) { + // Should findById throw an Exception is the host is not found? + throw new CloudRuntimeException("Unable to retrieve host with id " + vm.getHostId()); } + Cluster cluster = _entityMgr.findById(Cluster.class, host.getClusterId()); Pod pod = _entityMgr.findById(Pod.class, host.getPodId()); DeployDestination dest = new DeployDestination(dc, pod, cluster, host); @@ -2332,11 +2464,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } public Command cleanup(VirtualMachine vm) { - return new StopCommand(vm, ExecuteInSequence.value()); + return new StopCommand(vm, getExecuteInSequence(vm.getHypervisorType())); } public Command cleanup(String vmName) { - return new StopCommand(vmName, ExecuteInSequence.value()); + return new StopCommand(vmName, getExecuteInSequence(null)); + } public Commands fullHostSync(final long hostId, StartupRoutingCommand startup) { @@ -2351,7 +2484,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // sync VM Snapshots related transient states List vmSnapshotsInTrasientStates = - _vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging, VMSnapshot.State.Reverting, VMSnapshot.State.Creating); + _vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging, VMSnapshot.State.Reverting, VMSnapshot.State.Creating); if (vmSnapshotsInTrasientStates.size() > 1) { s_logger.info("Found vm " + vm.getInstanceName() + " with VM snapshots in transient states, needs to sync VM snapshot state"); if (!_vmSnapshotMgr.syncVMSnapshot(vm, hostId)) { @@ -2426,7 +2559,46 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac return commands; } - public void deltaSync(Map> newStates) { + // this is XenServer specific + public void syncVMMetaData(Map vmMetadatum) { + if (vmMetadatum == null || vmMetadatum.isEmpty()) { + return; + } + for (Map.Entry entry : vmMetadatum.entrySet()) { + String name = entry.getKey(); + String platform = entry.getValue(); + if (platform == null || platform.isEmpty()) { + continue; + } + VMInstanceVO vm = _vmDao.findVMByInstanceName(name); + if (vm != null && vm.getType() == VirtualMachine.Type.User) { + boolean changed = false; + UserVmVO userVm = _userVmDao.findById(vm.getId()); + _userVmDao.loadDetails(userVm); + if ( userVm.details.containsKey("timeoffset")) { + userVm.details.remove("timeoffset"); + changed = true; + } + if (!userVm.details.containsKey("platform") || !userVm.details.get("platform").equals(platform)) { + userVm.setDetail("platform", platform); + changed = true; + } + String pvdriver = "xenserver56"; + if ( platform.contains("device_id")) { + pvdriver = "xenserver61"; + } + if (!userVm.details.containsKey("hypervisortoolsversion") || !userVm.details.get("hypervisortoolsversion").equals(pvdriver)) { + userVm.setDetail("hypervisortoolsversion", pvdriver); + changed = true; + } + if ( changed ) { + _userVmDao.saveDetails(userVm); + } + } + } + } + + public void deltaSync(Map> newStates) { Map states = convertToInfos(newStates); for (Map.Entry entry : states.entrySet()) { @@ -2461,7 +2633,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } } - public void fullSync(final long clusterId, Map> newStates) { + public void fullSync(final long clusterId, Map> newStates) { if (newStates == null) return; Map infos = convertToInfos(newStates); @@ -2474,7 +2646,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // sync VM Snapshots related transient states List vmSnapshotsInExpungingStates = - _vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging, VMSnapshot.State.Creating, VMSnapshot.State.Reverting); + _vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging, VMSnapshot.State.Creating, VMSnapshot.State.Reverting); if (vmSnapshotsInExpungingStates.size() > 0) { s_logger.info("Found vm " + vm.getInstanceName() + " in state. " + vm.getState() + ", needs to sync VM snapshot state"); Long hostId = null; @@ -2492,9 +2664,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } if ((info == null && (vm.getState() == State.Running || vm.getState() == State.Starting)) || - (info != null && (info.state == State.Running && vm.getState() == State.Starting))) { + (info != null && (info.state == State.Running && vm.getState() == State.Starting))) { s_logger.info("Found vm " + vm.getInstanceName() + " in inconsistent state. " + vm.getState() + " on CS while " + (info == null ? "Stopped" : "Running") + - " on agent"); + " on agent"); info = new AgentVmInfo(vm.getInstanceName(), vm, State.Stopped); // Bug 13850- grab outstanding work item if any for this VM state so that we mark it as DONE after we change VM state, else it will remain pending @@ -2531,7 +2703,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac e.printStackTrace(); } } else if (info != null && - (vm.getState() == State.Stopped || vm.getState() == State.Stopping || vm.isRemoved() || vm.getState() == State.Destroyed || vm.getState() == State.Expunging)) { + (vm.getState() == State.Stopped || vm.getState() == State.Stopping || vm.isRemoved() || vm.getState() == State.Destroyed || vm.getState() == State.Expunging)) { Host host = _hostDao.findByGuid(info.getHostUuid()); if (host != null) { s_logger.warn("Stopping a VM which is stopped/stopping/destroyed/expunging " + info.name); @@ -2550,19 +2722,19 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } } } else - // host id can change - if (info != null && vm.getState() == State.Running) { - // check for host id changes - Host host = _hostDao.findByGuid(info.getHostUuid()); - if (host != null && (vm.getHostId() == null || host.getId() != vm.getHostId())) { - s_logger.info("Found vm " + vm.getInstanceName() + " with inconsistent host in db, new host is " + host.getId()); - try { - stateTransitTo(vm, VirtualMachine.Event.AgentReportMigrated, host.getId()); - } catch (NoTransitionException e) { - s_logger.warn(e.getMessage()); + // host id can change + if (info != null && vm.getState() == State.Running) { + // check for host id changes + Host host = _hostDao.findByGuid(info.getHostUuid()); + if (host != null && (vm.getHostId() == null || host.getId() != vm.getHostId())) { + s_logger.info("Found vm " + vm.getInstanceName() + " with inconsistent host in db, new host is " + host.getId()); + try { + stateTransitTo(vm, VirtualMachine.Event.AgentReportMigrated, host.getId()); + } catch (NoTransitionException e) { + s_logger.warn(e.getMessage()); + } } } - } /* else if(info == null && vm.getState() == State.Stopping) { //Handling CS-13376 s_logger.warn("Marking the VM as Stopped as it was still stopping on the CS" +vm.getName()); vm.setState(State.Stopped); // Setting the VM as stopped on the DB and clearing it from the host @@ -2591,24 +2763,24 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } - protected Map convertToInfos(final Map> newStates) { + protected Map convertToInfos(final Map> newStates) { final HashMap map = new HashMap(); if (newStates == null) { return map; } boolean is_alien_vm = true; long alien_vm_count = -1; - for (Map.Entry> entry : newStates.entrySet()) { + for (Map.Entry> entry : newStates.entrySet()) { is_alien_vm = true; String name = entry.getKey(); VMInstanceVO vm = _vmDao.findVMByInstanceName(name); if (vm != null) { - map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first(), entry.getValue().third())); + map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first())); is_alien_vm = false; } // alien VMs if (is_alien_vm) { - map.put(alien_vm_count--, new AgentVmInfo(entry.getKey(), null, entry.getValue().second(), entry.getValue().first(), entry.getValue().third())); + map.put(alien_vm_count--, new AgentVmInfo(entry.getKey(), null, entry.getValue().second(), entry.getValue().first())); s_logger.warn("Found an alien VM " + entry.getKey()); } } @@ -2686,24 +2858,15 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac String hostDesc = "name: " + hostVO.getName() + " (id:" + hostVO.getId() + "), availability zone: " + dcVO.getName() + ", pod: " + podVO.getName(); _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodIdToDeployIn(), "VM (name: " + vm.getInstanceName() + ", id: " + vm.getId() + - ") stopped on host " + hostDesc + " due to storage failure", "Virtual Machine " + vm.getInstanceName() + " (id: " + vm.getId() + ") running on host [" + - vm.getHostId() + "] stopped due to storage failure."); - } - // track platform info - if (info.platform != null && !info.platform.isEmpty()) { - if (vm.getType() == VirtualMachine.Type.User) { - UserVmVO userVm = _userVmDao.findById(vm.getId()); - _userVmDao.loadDetails(userVm); - userVm.setDetail("platform", info.platform); - _userVmDao.saveDetails(userVm); - } + ") stopped on host " + hostDesc + " due to storage failure", "Virtual Machine " + vm.getInstanceName() + " (id: " + vm.getId() + ") running on host [" + + vm.getHostId() + "] stopped due to storage failure."); } if (trackExternalChange) { if (serverState == State.Starting) { if (vm.getHostId() != null && vm.getHostId() != hostId) { s_logger.info("CloudStack is starting VM on host " + vm.getHostId() + ", but status report comes from a different host " + hostId + - ", skip status sync for vm: " + vm.getInstanceName()); + ", skip status sync for vm: " + vm.getInstanceName()); return null; } } @@ -2728,7 +2891,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (serverState == State.Starting) { if (vm.getHostId() != null && vm.getHostId() != hostId) { s_logger.info("CloudStack is starting VM on host " + vm.getHostId() + ", but status report comes from a different host " + hostId + - ", skip status sync for vm: " + vm.getInstanceName()); + ", skip status sync for vm: " + vm.getInstanceName()); return null; } } @@ -2744,7 +2907,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (vm.getHostId() == null || hostId != vm.getHostId()) { if (s_logger.isDebugEnabled()) { s_logger.debug("detected host change when VM " + vm + " is at running state, VM could be live-migrated externally from host " + - vm.getHostId() + " to host " + hostId); + vm.getHostId() + " to host " + hostId); } stateTransitTo(vm, VirtualMachine.Event.AgentReportMigrated, hostId); @@ -2842,7 +3005,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } private void ensureVmRunningContext(long hostId, VMInstanceVO vm, Event cause) throws OperationTimedoutException, ResourceUnavailableException, - NoTransitionException, InsufficientAddressCapacityException { + NoTransitionException, InsufficientAddressCapacityException { VirtualMachineGuru vmGuru = getVmGuru(vm); s_logger.debug("VM state is starting on full sync so updating it to running"); @@ -2871,8 +3034,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac for (NicVO nic : nics) { Network network = _networkModel.getNetwork(nic.getNetworkId()); NicProfile nicProfile = - new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null, _networkModel.isSecurityGroupSupportedInNetwork(network), - _networkModel.getNetworkTag(profile.getHypervisorType(), network)); + new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null, _networkModel.isSecurityGroupSupportedInNetwork(network), + _networkModel.getNetworkTag(profile.getHypervisorType(), network)); profile.addNic(nicProfile); } @@ -2911,10 +3074,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac public boolean processAnswers(long agentId, long seq, Answer[] answers) { for (final Answer answer : answers) { if (answer instanceof ClusterSyncAnswer) { - ClusterSyncAnswer hs = (ClusterSyncAnswer)answer; - if (!hs.isExceuted()) { - deltaSync(hs.getNewStates()); - hs.setExecuted(); + if (!VmJobEnabled.value()) { + ClusterSyncAnswer hs = (ClusterSyncAnswer)answer; + if (!hs.isExecuted()) { + deltaSync(hs.getNewStates()); + hs.setExecuted(); + } + } + } else if ( answer instanceof ClusterVMMetaDataSyncAnswer) { + ClusterVMMetaDataSyncAnswer cvms = (ClusterVMMetaDataSyncAnswer)answer; + if (!cvms.isExecuted()) { + syncVMMetaData(cvms.getVMMetaDatum()); + cvms.setExecuted(); } } } @@ -2938,18 +3109,19 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac if (cmd instanceof PingRoutingCommand) { PingRoutingCommand ping = (PingRoutingCommand)cmd; if (ping.getNewStates() != null && ping.getNewStates().size() > 0) { - Commands commands = deltaHostSync(agentId, ping.getNewStates()); - if (commands.size() > 0) { - try { - _agentMgr.send(agentId, commands, this); - } catch (final AgentUnavailableException e) { - s_logger.warn("Agent is now unavailable", e); + if (!VmJobEnabled.value()) { + Commands commands = deltaHostSync(agentId, ping.getNewStates()); + if (commands.size() > 0) { + try { + _agentMgr.send(agentId, commands, this); + } catch (final AgentUnavailableException e) { + s_logger.warn("Agent is now unavailable", e); + } } } } - if(VmJobEnabled.value()) { - if (ping.getHostVmStateReport() != null && ping.getHostVmStateReport().size() > 0) { + if (ping.getHostVmStateReport() != null) { _syncMgr.processHostVmStatePingReport(agentId, ping.getHostVmStateReport()); } } @@ -2979,10 +3151,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac return; } - if (s_logger.isDebugEnabled()) + if(s_logger.isDebugEnabled()) s_logger.debug("Received startup command from hypervisor host. host id: " + agent.getId()); - if (VmJobEnabled.value()) { + if(VmJobEnabled.value()) { _syncMgr.resetHostSyncState(agent.getId()); } @@ -3000,48 +3172,58 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac long agentId = agent.getId(); if (agent.getHypervisorType() == HypervisorType.XenServer) { // only for Xen - StartupRoutingCommand startup = (StartupRoutingCommand)cmd; - HashMap> allStates = startup.getClusterVMStateChanges(); - if (allStates != null) { - fullSync(clusterId, allStates); - } - - // initiate the cron job - ClusterSyncCommand syncCmd = new ClusterSyncCommand(ClusterDeltaSyncInterval.value(), clusterId); - try { - long seq_no = _agentMgr.send(agentId, new Commands(syncCmd), this); - s_logger.debug("Cluster VM sync started with jobid " + seq_no); - } catch (AgentUnavailableException e) { - s_logger.fatal("The Cluster VM sync process failed for cluster id " + clusterId + " with ", e); - } - } else { // for others KVM and VMWare - StartupRoutingCommand startup = (StartupRoutingCommand)cmd; - Commands commands = fullHostSync(agentId, startup); - - if (commands.size() > 0) { - s_logger.debug("Sending clean commands to the agent"); - + if (!VmJobEnabled.value()) { + StartupRoutingCommand startup = (StartupRoutingCommand)cmd; + HashMap> allStates = startup.getClusterVMStateChanges(); + if (allStates != null) { + fullSync(clusterId, allStates); + } + // initiate the cron job + ClusterSyncCommand syncCmd = new ClusterSyncCommand(ClusterDeltaSyncInterval.value(), clusterId); try { - boolean error = false; - Answer[] answers = _agentMgr.send(agentId, commands); - for (Answer answer : answers) { - if (!answer.getResult()) { - s_logger.warn("Unable to stop a VM due to " + answer.getDetails()); - error = true; - } - } - if (error) { - throw new ConnectionException(true, "Unable to stop VMs"); - } - } catch (final AgentUnavailableException e) { - s_logger.warn("Agent is unavailable now", e); - throw new ConnectionException(true, "Unable to sync", e); - } catch (final OperationTimedoutException e) { - s_logger.warn("Agent is unavailable now", e); - throw new ConnectionException(true, "Unable to sync", e); + long seq_no = _agentMgr.send(agentId, new Commands(syncCmd), this); + s_logger.debug("Cluster VM sync started with jobid " + seq_no); + } catch (AgentUnavailableException e) { + s_logger.fatal("The Cluster VM sync process failed for cluster id " + clusterId + " with ", e); } } + // initiate the cron job + ClusterVMMetaDataSyncCommand syncVMMetaDataCmd = new ClusterVMMetaDataSyncCommand(ClusterVMMetaDataSyncInterval.value(), clusterId); + try { + long seq_no = _agentMgr.send(agentId, new Commands(syncVMMetaDataCmd), this); + s_logger.debug("Cluster VM metadata sync started with jobid " + seq_no); + } catch (AgentUnavailableException e) { + s_logger.fatal("The Cluster VM metadata sync process failed for cluster id " + clusterId + " with ", e); + } + } else { // for others KVM and VMWare + if (!VmJobEnabled.value()) { + StartupRoutingCommand startup = (StartupRoutingCommand)cmd; + Commands commands = fullHostSync(agentId, startup); + if (commands.size() > 0) { + s_logger.debug("Sending clean commands to the agent"); + + try { + boolean error = false; + Answer[] answers = _agentMgr.send(agentId, commands); + for (Answer answer : answers) { + if (!answer.getResult()) { + s_logger.warn("Unable to stop a VM due to " + answer.getDetails()); + error = true; + } + } + if (error) { + throw new ConnectionException(true, "Unable to stop VMs"); + } + } catch (final AgentUnavailableException e) { + s_logger.warn("Agent is unavailable now", e); + throw new ConnectionException(true, "Unable to sync", e); + } catch (final OperationTimedoutException e) { + s_logger.warn("Agent is unavailable now", e); + throw new ConnectionException(true, "Unable to sync", e); + } + } + } } } @@ -3083,33 +3265,22 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac public State state; public String hostUuid; public VMInstanceVO vm; - public String platform; @SuppressWarnings("unchecked") - public AgentVmInfo(String name, VMInstanceVO vm, State state, String host, String platform) { - this.name = name; - this.state = state; - this.vm = vm; - hostUuid = host; - this.platform = platform; - - } - public AgentVmInfo(String name, VMInstanceVO vm, State state, String host) { - this(name, vm, state, host, null); + name = name; + state = state; + vm = vm; + hostUuid = host; } public AgentVmInfo(String name, VMInstanceVO vm, State state) { - this(name, vm, state, null, null); + this(name, vm, state, null); } public String getHostUuid() { return hostUuid; } - - public String getPlatform() { - return platform; - } } @Override @@ -3120,25 +3291,25 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public void checkIfCanUpgrade(VirtualMachine vmInstance, ServiceOffering newServiceOffering) { if (newServiceOffering == null) { - throw new InvalidParameterValueException("Unable to find a service offering with id " + newServiceOffering.getId()); + throw new InvalidParameterValueException("Invalid parameter, newServiceOffering can't be null"); } // Check that the VM is stopped / running if (!(vmInstance.getState().equals(State.Stopped) || vmInstance.getState().equals(State.Running))) { s_logger.warn("Unable to upgrade virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState()); throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + " " + " in state " + vmInstance.getState() + - "; make sure the virtual machine is stopped/running"); + "; make sure the virtual machine is stopped/running"); } // Check if the service offering being upgraded to is what the VM is already running with if (!newServiceOffering.isDynamic() && vmInstance.getServiceOfferingId() == newServiceOffering.getId()) { if (s_logger.isInfoEnabled()) { s_logger.info("Not upgrading vm " + vmInstance.toString() + " since it already has the requested " + "service offering (" + newServiceOffering.getName() + - ")"); + ")"); } throw new InvalidParameterValueException("Not upgrading vm " + vmInstance.toString() + " since it already " + "has the requested service offering (" + - newServiceOffering.getName() + ")"); + newServiceOffering.getName() + ")"); } ServiceOfferingVO currentServiceOffering = _offeringDao.findByIdIncludingRemoved(vmInstance.getId(), vmInstance.getServiceOfferingId()); @@ -3156,8 +3327,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // offering if (currentServiceOffering.getUseLocalStorage() != newServiceOffering.getUseLocalStorage()) { throw new InvalidParameterValueException("Unable to upgrade virtual machine " + vmInstance.toString() + - ", cannot switch between local storage and shared storage service offerings. Current offering " + "useLocalStorage=" + - currentServiceOffering.getUseLocalStorage() + ", target offering useLocalStorage=" + newServiceOffering.getUseLocalStorage()); + ", cannot switch between local storage and shared storage service offerings. Current offering " + "useLocalStorage=" + + currentServiceOffering.getUseLocalStorage() + ", target offering useLocalStorage=" + newServiceOffering.getUseLocalStorage()); } // if vm is a system vm, check if it is a system service offering, if yes return with error as it cannot be used for user vms @@ -3168,7 +3339,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // Check that there are enough resources to upgrade the service offering if (!isVirtualMachineUpgradable(vmInstance, newServiceOffering)) { throw new InvalidParameterValueException("Unable to upgrade virtual machine, not enough resources available " + "for an offering of " + - newServiceOffering.getCpu() + " cpu(s) at " + newServiceOffering.getSpeed() + " Mhz, and " + newServiceOffering.getRamSize() + " MB of memory"); + newServiceOffering.getCpu() + " cpu(s) at " + newServiceOffering.getSpeed() + " Mhz, and " + newServiceOffering.getRamSize() + " MB of memory"); } // Check that the service offering being upgraded to has all the tags of the current service offering @@ -3176,7 +3347,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac List newTags = StringUtils.csvTagsToList(newServiceOffering.getTags()); if (!newTags.containsAll(currentTags)) { throw new InvalidParameterValueException("Unable to upgrade virtual machine; the new service offering " + "does not have all the tags of the " + - "current service offering. Current service offering tags: " + currentTags + "; " + "new service " + "offering tags: " + newTags); + "current service offering. Current service offering tags: " + currentTags + "; " + "new service " + "offering tags: " + newTags); } } @@ -3229,8 +3400,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw (InsufficientCapacityException)jobException; else if (jobException instanceof RuntimeException) throw (RuntimeException)jobException; - else if (jobException instanceof Long) - return requested; + else if (jobException instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobException); + else if (jobException instanceof NicProfile) + return (NicProfile)jobException; } throw new RuntimeException("Unexpected job execution result"); @@ -3274,7 +3447,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac long isDefault = (nic.isDefaultNic()) ? 1 : 0; // insert nic's Id into DB as resource_name UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vmVO.getAccountId(), vmVO.getDataCenterId(), vmVO.getId(), - Long.toString(nic.getId()), network.getNetworkOfferingId(), null, isDefault, VirtualMachine.class.getName(), vmVO.getUuid()); + Long.toString(nic.getId()), network.getNetworkOfferingId(), null, isDefault, VirtualMachine.class.getName(), vmVO.getUuid(), vm.isDisplay()); return nic; } else { s_logger.warn("Failed to plug nic to the vm " + vm + " in network " + network); @@ -3340,6 +3513,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw (ConcurrentOperationException)jobResult; else if (jobResult instanceof RuntimeException) throw (RuntimeException)jobResult; + else if (jobResult instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobResult); else if (jobResult instanceof Boolean) return (Boolean)jobResult; } @@ -3371,12 +3546,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // if specified nic is associated with PF/LB/Static NAT if (rulesMgr.listAssociatedRulesForGuestNic(nic).size() > 0) { throw new CloudRuntimeException("Failed to remove nic from " + vm + " in " + network + - ", nic has associated Port forwarding or Load balancer or Static NAT rules."); + ", nic has associated Port forwarding or Load balancer or Static NAT rules."); } NicProfile nicProfile = - new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), _networkModel.getNetworkRate(network.getId(), vm.getId()), - _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network)); + new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), _networkModel.getNetworkRate(network.getId(), vm.getId()), + _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network)); //1) Unplug the nic if (vm.getState() == State.Running) { @@ -3387,7 +3562,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.debug("Nic is unplugged successfully for vm " + vm + " in network " + network); long isDefault = (nic.isDefaultNic()) ? 1 : 0; UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_REMOVE, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), - Long.toString(nic.getId()), network.getNetworkOfferingId(), null, isDefault, VirtualMachine.class.getName(), vm.getUuid()); + Long.toString(nic.getId()), network.getNetworkOfferingId(), null, isDefault, VirtualMachine.class.getName(), vm.getUuid(), vm.isDisplay()); } else { s_logger.warn("Failed to unplug nic for the vm " + vm + " from network " + network); return false; @@ -3465,8 +3640,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac try { NicProfile nicProfile = - new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), _networkModel.getNetworkRate(network.getId(), vm.getId()), - _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network)); + new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), _networkModel.getNetworkRate(network.getId(), vm.getId()), + _networkModel.isSecurityGroupSupportedInNetwork(network), _networkModel.getNetworkTag(vmProfile.getVirtualMachine().getHypervisorType(), network)); //1) Unplug the nic if (vm.getState() == State.Running) { @@ -3503,7 +3678,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public void findHostAndMigrate(String vmUuid, Long newSvcOfferingId, ExcludeList excludes) throws InsufficientCapacityException, ConcurrentOperationException, - ResourceUnavailableException { + ResourceUnavailableException { VMInstanceVO vm = _vmDao.findByUuid(vmUuid); if (vm == null) { @@ -3587,6 +3762,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac throw (ResourceUnavailableException)jobResult; else if (jobResult instanceof ConcurrentOperationException) throw (ConcurrentOperationException)jobResult; + else if (jobResult instanceof RuntimeException) + throw (RuntimeException)jobResult; + else if (jobResult instanceof Throwable) + throw new RuntimeException("Unexpected exception", (Throwable)jobResult); } } } @@ -3727,8 +3906,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.info("Migration was unsuccessful. Cleaning up: " + vm); _alertMgr.sendAlert(alertType, fromHost.getDataCenterId(), fromHost.getPodId(), - "Unable to migrate vm " + vm.getInstanceName() + " from host " + fromHost.getName() + " in zone " + dest.getDataCenter().getName() + " and pod " + - dest.getPod().getName(), "Migrate Command failed. Please check logs."); + "Unable to migrate vm " + vm.getInstanceName() + " from host " + fromHost.getName() + " in zone " + dest.getDataCenter().getName() + " and pod " + + dest.getPod().getName(), "Migrate Command failed. Please check logs."); try { _agentMgr.send(dstHostId, new Commands(cleanup(vm.getInstanceName())), null); } catch (AgentUnavailableException ae) { @@ -3748,7 +3927,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm, ReservationContext context, DeployDestination dest) throws ConcurrentOperationException, - ResourceUnavailableException, InsufficientCapacityException { + ResourceUnavailableException, InsufficientCapacityException { boolean result = true; VMInstanceVO router = _vmDao.findById(vm.getId()); @@ -3771,14 +3950,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.warn("Unable to apply PlugNic, vm " + router + " is not in the right state " + router.getState()); throw new ResourceUnavailableException("Unable to apply PlugNic on the backend," + " vm " + vm + " is not in the right state", DataCenter.class, - router.getDataCenterId()); + router.getDataCenterId()); } return result; } public boolean unplugNic(Network network, NicTO nic, VirtualMachineTO vm, ReservationContext context, DeployDestination dest) throws ConcurrentOperationException, - ResourceUnavailableException { + ResourceUnavailableException { boolean result = true; VMInstanceVO router = _vmDao.findById(vm.getId()); @@ -3804,7 +3983,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.warn("Unable to apply unplug nic, Vm " + router + " is not in the right state " + router.getState()); throw new ResourceUnavailableException("Unable to apply unplug nic on the backend," + " vm " + router + " is not in the right state", DataCenter.class, - router.getDataCenterId()); + router.getDataCenterId()); } return result; @@ -3871,8 +4050,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac Float cpuOvercommitRatio = CapacityManager.CpuOverprovisioningFactor.valueIn(hostVo.getClusterId()); long minMemory = (long)(newServiceOffering.getRamSize() / memoryOvercommitRatio); ScaleVmCommand reconfigureCmd = - new ScaleVmCommand(vm.getInstanceName(), newServiceOffering.getCpu(), (int)(newServiceOffering.getSpeed() / cpuOvercommitRatio), - newServiceOffering.getSpeed(), minMemory * 1024L * 1024L, newServiceOffering.getRamSize() * 1024L * 1024L, newServiceOffering.getLimitCpuUse()); + new ScaleVmCommand(vm.getInstanceName(), newServiceOffering.getCpu(), (int)(newServiceOffering.getSpeed() / cpuOvercommitRatio), + newServiceOffering.getSpeed(), minMemory * 1024L * 1024L, newServiceOffering.getRamSize() * 1024L * 1024L, newServiceOffering.getLimitCpuUse()); Long dstHostId = vm.getHostId(); ItWorkVO work = new ItWorkVO(UUID.randomUUID().toString(), _nodeId, State.Running, vm.getType(), vm.getId()); @@ -3922,8 +4101,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public ConfigKey[] getConfigKeys() { return new ConfigKey[] {ClusterDeltaSyncInterval, StartRetry, VmDestroyForcestop, VmOpCancelInterval, VmOpCleanupInterval, VmOpCleanupWait, - VmOpLockStateRetry, - VmOpWaitInterval, ExecuteInSequence, VmJobCheckInterval, VmJobTimeout, VmJobStateReportInterval}; + VmOpLockStateRetry, + VmOpWaitInterval, ExecuteInSequence, VmJobCheckInterval, VmJobTimeout, VmJobStateReportInterval}; } public List getStoragePoolAllocators() { @@ -3946,7 +4125,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac List pendingWorkJobs = _workJobDao.listPendingWorkJobs( VirtualMachine.Type.Instance, vmId); - if (pendingWorkJobs.size() == 0) { + if (pendingWorkJobs.size() == 0 && !_haMgr.hasPendingHaWork(vmId)) { // there is no pending operation job VMInstanceVO vm = _vmDao.findById(vmId); if (vm != null) { @@ -3956,6 +4135,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac break; case PowerOff: + case PowerReportMissing: handlePowerOffReportWithNoPendingJobsOnVM(vm); break; @@ -3970,6 +4150,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.warn("VM " + vmId + " no longer exists when processing VM state report"); } } else { + s_logger.info("There is pending job or HA tasks working on the VM. vm id: " + vmId + ", postpone power-change report by resetting power-change counters"); + // reset VM power state tracking so that we won't lost signal when VM has // been translated to _vmDao.resetVmPowerStateTracking(vmId); @@ -3978,19 +4160,23 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac private void handlePowerOnReportWithNoPendingJobsOnVM(VMInstanceVO vm) { // - // 1) handle left-over transitional VM states + // 1) handle left-over transitional VM states // 2) handle out of band VM live migration // 3) handle out of sync stationary states, marking VM from Stopped to Running with // alert messages // switch (vm.getState()) { case Starting: + s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it"); + try { stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId()); } catch (NoTransitionException e) { s_logger.warn("Unexpected VM state transition exception, race-condition?", e); } + s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor"); + // we need to alert admin or user about this risky state transition _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(), VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() @@ -4005,10 +4191,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } catch (NoTransitionException e) { s_logger.warn("Unexpected VM state transition exception, race-condition?", e); } + break; case Stopping: case Stopped: + s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it"); + try { stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId()); } catch (NoTransitionException e) { @@ -4017,6 +4206,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(), VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState() + " -> Running) from out-of-context transition. VM network environment may need to be reset"); + + s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor"); break; case Destroyed: @@ -4026,11 +4217,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac break; case Migrating: + s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-on report while there is no pending jobs on it"); try { stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOnReport, vm.getPowerHostId()); } catch (NoTransitionException e) { s_logger.warn("Unexpected VM state transition exception, race-condition?", e); } + s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Running state according to power-on report from hypervisor"); break; case Error: @@ -4043,7 +4236,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac private void handlePowerOffReportWithNoPendingJobsOnVM(VMInstanceVO vm) { - // 1) handle left-over transitional VM states + // 1) handle left-over transitional VM states // 2) handle out of sync stationary states, schedule force-stop to release resources // switch (vm.getState()) { @@ -4052,15 +4245,32 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac case Running: case Stopped: case Migrating: + s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-off report while there is no pending jobs on it"); + if(vm.isHaEnabled() && vm.getState() == State.Running && vm.getHypervisorType() != HypervisorType.VMware && vm.getHypervisorType() != HypervisorType.Hyperv) { + s_logger.info("Detected out-of-band stop of a HA enabled VM " + vm.getInstanceName() + ", will schedule restart"); + if(!_haMgr.hasPendingHaWork(vm.getId())) + _haMgr.scheduleRestart(vm, true); + else + s_logger.info("VM " + vm.getInstanceName() + " already has an pending HA task working on it"); + return; + } + + VirtualMachineGuru vmGuru = getVmGuru(vm); + VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); + sendStop(vmGuru, profile, true); + try { - stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOffReport, vm.getPowerHostId()); + stateTransitTo(vm, VirtualMachine.Event.FollowAgentPowerOffReport, null); } catch (NoTransitionException e) { s_logger.warn("Unexpected VM state transition exception, race-condition?", e); } + _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SYNC, vm.getDataCenterId(), vm.getPodIdToDeployIn(), VM_SYNC_ALERT_SUBJECT, "VM " + vm.getHostName() + "(" + vm.getInstanceName() + ") state is sync-ed (" + vm.getState() + " -> Stopped) from out-of-context transition."); - // TODO: we need to forcely release all resource allocation + + s_logger.info("VM " + vm.getInstanceName() + " is sync-ed to at Stopped state according to power-off report from hypervisor"); + break; case Destroyed: @@ -4086,7 +4296,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // however, if VM is missing from the host report (it may happen in out of band changes // or from designed behave of XS/KVM), the VM may not get a chance to run the state-sync logic // - // Therefor, we will scan thoses VMs on UP host based on last update timestamp, if the host is UP + // Therefore, we will scan thoses VMs on UP host based on last update timestamp, if the host is UP // and a VM stalls for status update, we will consider them to be powered off // (which is relatively safe to do so) @@ -4230,8 +4440,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac super(VirtualMachine.class, job, VmJobCheckInterval.value(), new Predicate() { @Override public boolean checkCondition() { - VMInstanceVO instance = _vmDao.findById(vmId); - if (instance.getPowerState() == desiredPowerState && (srcHostIdForMigration != null && instance.getPowerHostId() != srcHostIdForMigration)) + AsyncJobVO jobVo = _entityMgr.findById(AsyncJobVO.class, job.getId()); + assert (jobVo != null); + if (jobVo == null || jobVo.getStatus() != JobInfo.Status.IN_PROGRESS) return true; return false; } @@ -4275,7 +4486,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac // public Outcome startVmThroughJobQueue(final String vmUuid, final Map params, - final DeploymentPlan planToDeploy) { + final DeploymentPlan planToDeploy, final DeploymentPlanner planner) { final CallContext context = CallContext.current(); final User callingUser = context.getCallingUser(); @@ -4288,36 +4499,43 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac public Object[] doInTransaction(TransactionStatus status) { VmWorkJobVO workJob = null; - _vmDao.lockRow(vm.getId(), true); - List pendingWorkJobs = _workJobDao.listPendingWorkJobs(VirtualMachine.Type.Instance, - vm.getId(), VmWorkStart.class.getName()); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs(VirtualMachine.Type.Instance, + vm.getId(), VmWorkStart.class.getName()); - if (pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { - workJob = new VmWorkJobVO(context.getContextId()); + if (pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkStart.class.getName()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkStart.class.getName()); - workJob.setAccountId(callingAccount.getId()); - workJob.setUserId(callingUser.getId()); - workJob.setStep(VmWorkJobVO.Step.Starting); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setAccountId(callingAccount.getId()); + workJob.setUserId(callingUser.getId()); + workJob.setStep(VmWorkJobVO.Step.Starting); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - // save work context info (there are some duplications) - VmWorkStart workInfo = new VmWorkStart(callingUser.getId(), callingAccount.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER); - workInfo.setPlan(planToDeploy); - workInfo.setParams(params); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + // save work context info (there are some duplications) + VmWorkStart workInfo = new VmWorkStart(callingUser.getId(), callingAccount.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER); + workInfo.setPlan(planToDeploy); + if (planner != null) { + workInfo.setDeploymentPlanner(planner.getName()); + } + workInfo.setParams(params); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - - return new Object[] {workJob, workJob.getId()}; } }); @@ -4338,37 +4556,41 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac Object[] result = Transaction.execute(new TransactionCallback() { @Override public Object[] doInTransaction(TransactionStatus status) { - _vmDao.lockRow(vm.getId(), true); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - vm.getType(), vm.getId(), - VmWorkStop.class.getName()); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + vm.getType(), vm.getId(), + VmWorkStop.class.getName()); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { - workJob = new VmWorkJobVO(context.getContextId()); + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkStop.class.getName()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkStop.class.getName()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setStep(VmWorkJobVO.Step.Prepare); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setStep(VmWorkJobVO.Step.Prepare); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - // save work context info (there are some duplications) - VmWorkStop workInfo = new VmWorkStop(user.getId(), account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, cleanup); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + // save work context info (there are some duplications) + VmWorkStop workInfo = new VmWorkStop(user.getId(), account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, cleanup); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - - return new Object[] {workJob, workJob.getId()}; } }); @@ -4391,37 +4613,40 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac Object[] result = Transaction.execute(new TransactionCallback() { @Override public Object[] doInTransaction(TransactionStatus status) { - _vmDao.lockRow(vm.getId(), true); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkReboot.class.getName()); - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkReboot.class.getName()); + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { + workJob = new VmWorkJobVO(context.getContextId()); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { - workJob = new VmWorkJobVO(context.getContextId()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkReboot.class.getName()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkReboot.class.getName()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setStep(VmWorkJobVO.Step.Prepare); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setStep(VmWorkJobVO.Step.Prepare); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + // save work context info (there are some duplications) + VmWorkReboot workInfo = new VmWorkReboot(user.getId(), account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, params); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - // save work context info (there are some duplications) - VmWorkReboot workInfo = new VmWorkReboot(user.getId(), account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, params); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - - return new Object[] {workJob, workJob.getId()}; } }); @@ -4443,34 +4668,91 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public Object[] doInTransaction(TransactionStatus status) { - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkMigrate.class.getName()); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkMigrate.class.getName()); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { - workJob = new VmWorkJobVO(context.getContextId()); + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkMigrate.class.getName()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkMigrate.class.getName()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - // save work context info (there are some duplications) - VmWorkMigrate workInfo = new VmWorkMigrate(user.getId(), account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId, dest); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + // save work context info (there are some duplications) + VmWorkMigrate workInfo = new VmWorkMigrate(user.getId(), account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId, dest); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); + } + } + }); + + final long jobId = (Long)result[1]; + AsyncJobExecutionContext.getCurrentExecutionContext().joinJob(jobId); + + return new VmStateSyncOutcome((VmWorkJobVO)result[0], + VirtualMachine.PowerState.PowerOn, vm.getId(), vm.getPowerHostId()); + } + + public Outcome migrateVmAwayThroughJobQueue(final String vmUuid, final long srcHostId) { + final CallContext context = CallContext.current(); + final User user = context.getCallingUser(); + final Account account = context.getCallingAccount(); + + final VMInstanceVO vm = _vmDao.findByUuid(vmUuid); + + Object[] result = Transaction.execute(new TransactionCallback() { + @Override + public Object[] doInTransaction(TransactionStatus status) { + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkMigrateAway.class.getName()); + + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { + workJob = new VmWorkJobVO(context.getContextId()); + + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkMigrateAway.class.getName()); + + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); + + // save work context info (there are some duplications) + VmWorkMigrateAway workInfo = new VmWorkMigrateAway(user.getId(), account.getId(), vm.getId(), VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - return new Object[] {workJob, workJob.getId()}; } }); @@ -4495,37 +4777,40 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public Object[] doInTransaction(TransactionStatus status) { - _vmDao.lockRow(vm.getId(), true); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkMigrateWithStorage.class.getName()); - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkMigrateWithStorage.class.getName()); + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { + workJob = new VmWorkJobVO(context.getContextId()); - workJob = new VmWorkJobVO(context.getContextId()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkMigrate.class.getName()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkMigrate.class.getName()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + // save work context info (there are some duplications) + VmWorkMigrateWithStorage workInfo = new VmWorkMigrateWithStorage(user.getId(), account.getId(), vm.getId(), + VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId, destHostId, volumeToPool); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - // save work context info (there are some duplications) - VmWorkMigrateWithStorage workInfo = new VmWorkMigrateWithStorage(user.getId(), account.getId(), vm.getId(), - VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId, destHostId, volumeToPool); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - return new Object[] {workJob, workJob.getId()}; } }); @@ -4549,36 +4834,41 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public Object[] doInTransaction(TransactionStatus status) { - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkMigrateForScale.class.getName()); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkMigrateForScale.class.getName()); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { - workJob = new VmWorkJobVO(context.getContextId()); + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkMigrate.class.getName()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkMigrate.class.getName()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - // save work context info (there are some duplications) - VmWorkMigrateForScale workInfo = new VmWorkMigrateForScale(user.getId(), account.getId(), vm.getId(), - VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId, dest, newSvcOfferingId); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + // save work context info (there are some duplications) + VmWorkMigrateForScale workInfo = new VmWorkMigrateForScale(user.getId(), account.getId(), vm.getId(), + VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, srcHostId, dest, newSvcOfferingId); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - - return new Object[] {workJob, workJob.getId()}; } }); @@ -4601,36 +4891,41 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public Object[] doInTransaction(TransactionStatus status) { - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkStorageMigration.class.getName()); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkStorageMigration.class.getName()); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { - workJob = new VmWorkJobVO(context.getContextId()); + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkStorageMigration.class.getName()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkStorageMigration.class.getName()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - // save work context info (there are some duplications) - VmWorkStorageMigration workInfo = new VmWorkStorageMigration(user.getId(), account.getId(), vm.getId(), - VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, destPool); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + // save work context info (there are some duplications) + VmWorkStorageMigration workInfo = new VmWorkStorageMigration(user.getId(), account.getId(), vm.getId(), + VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, destPool.getId()); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - - return new Object[] {workJob, workJob.getId()}; } }); @@ -4651,35 +4946,41 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public Object[] doInTransaction(TransactionStatus status) { - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkAddVmToNetwork.class.getName()); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkAddVmToNetwork.class.getName()); - workJob = new VmWorkJobVO(context.getContextId()); + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkAddVmToNetwork.class.getName()); + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkAddVmToNetwork.class.getName()); - // save work context info (there are some duplications) - VmWorkAddVmToNetwork workInfo = new VmWorkAddVmToNetwork(user.getId(), account.getId(), vm.getId(), - VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, network.getId(), requested); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + // save work context info (there are some duplications) + VmWorkAddVmToNetwork workInfo = new VmWorkAddVmToNetwork(user.getId(), account.getId(), vm.getId(), + VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, network.getId(), requested); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - return new Object[] {workJob, workJob.getId()}; } }); @@ -4700,35 +5001,40 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public Object[] doInTransaction(TransactionStatus status) { - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkRemoveNicFromVm.class.getName()); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkRemoveNicFromVm.class.getName()); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { - workJob = new VmWorkJobVO(context.getContextId()); + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkRemoveNicFromVm.class.getName()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkRemoveNicFromVm.class.getName()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - // save work context info (there are some duplications) - VmWorkRemoveNicFromVm workInfo = new VmWorkRemoveNicFromVm(user.getId(), account.getId(), vm.getId(), - VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, nic.getId()); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + // save work context info (there are some duplications) + VmWorkRemoveNicFromVm workInfo = new VmWorkRemoveNicFromVm(user.getId(), account.getId(), vm.getId(), + VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, nic.getId()); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - return new Object[] {workJob, workJob.getId()}; } }); @@ -4749,35 +5055,40 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public Object[] doInTransaction(TransactionStatus status) { - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkRemoveVmFromNetwork.class.getName()); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkRemoveVmFromNetwork.class.getName()); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { - workJob = new VmWorkJobVO(context.getContextId()); + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkRemoveVmFromNetwork.class.getName()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkRemoveVmFromNetwork.class.getName()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - // save work context info (there are some duplications) - VmWorkRemoveVmFromNetwork workInfo = new VmWorkRemoveVmFromNetwork(user.getId(), account.getId(), vm.getId(), - VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, network, broadcastUri); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + // save work context info (there are some duplications) + VmWorkRemoveVmFromNetwork workInfo = new VmWorkRemoveVmFromNetwork(user.getId(), account.getId(), vm.getId(), + VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, network, broadcastUri); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - return new Object[] {workJob, workJob.getId()}; } }); @@ -4800,35 +5111,40 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac @Override public Object[] doInTransaction(TransactionStatus status) { - List pendingWorkJobs = _workJobDao.listPendingWorkJobs( - VirtualMachine.Type.Instance, vm.getId(), - VmWorkReconfigure.class.getName()); + _vmDao.lockInLockTable(String.valueOf(vm.getId()), Integer.MAX_VALUE); + try { + List pendingWorkJobs = _workJobDao.listPendingWorkJobs( + VirtualMachine.Type.Instance, vm.getId(), + VmWorkReconfigure.class.getName()); - VmWorkJobVO workJob = null; - if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { - assert (pendingWorkJobs.size() == 1); - workJob = pendingWorkJobs.get(0); - } else { + VmWorkJobVO workJob = null; + if (pendingWorkJobs != null && pendingWorkJobs.size() > 0) { + assert (pendingWorkJobs.size() == 1); + workJob = pendingWorkJobs.get(0); + } else { - workJob = new VmWorkJobVO(context.getContextId()); + workJob = new VmWorkJobVO(context.getContextId()); - workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); - workJob.setCmd(VmWorkReconfigure.class.getName()); + workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER); + workJob.setCmd(VmWorkReconfigure.class.getName()); - workJob.setAccountId(account.getId()); - workJob.setUserId(user.getId()); - workJob.setVmType(VirtualMachine.Type.Instance); - workJob.setVmInstanceId(vm.getId()); - workJob.setRelated(AsyncJobExecutionContext.getOriginJobContextId()); + workJob.setAccountId(account.getId()); + workJob.setUserId(user.getId()); + workJob.setVmType(VirtualMachine.Type.Instance); + workJob.setVmInstanceId(vm.getId()); + workJob.setRelated(AsyncJobExecutionContext.getOriginJobId()); - // save work context info (there are some duplications) - VmWorkReconfigure workInfo = new VmWorkReconfigure(user.getId(), account.getId(), vm.getId(), - VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, newServiceOffering.getId(), reconfiguringOnExistingHost); - workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); + // save work context info (there are some duplications) + VmWorkReconfigure workInfo = new VmWorkReconfigure(user.getId(), account.getId(), vm.getId(), + VirtualMachineManagerImpl.VM_WORK_JOB_HANDLER, newServiceOffering.getId(), reconfiguringOnExistingHost); + workJob.setCmdInfo(VmWorkSerializer.serialize(workInfo)); - _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + _jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, vm.getId()); + } + return new Object[] {workJob, new Long(workJob.getId())}; + } finally { + _vmDao.unlockFromLockTable(String.valueOf(vm.getId())); } - return new Object[] {workJob, workJob.getId()}; } }); @@ -4845,7 +5161,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac } assert (vm != null); - orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), null); + orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), _dpMgr.getDeploymentPlannerByName(work.getDeploymentPlanner())); return new Pair(JobInfo.Status.SUCCEEDED, null); } @@ -4871,6 +5187,23 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac return new Pair(JobInfo.Status.SUCCEEDED, null); } + private Pair orchestrateMigrateAway(VmWorkMigrateAway work) throws Exception { + VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); + if (vm == null) { + s_logger.info("Unable to find vm " + work.getVmId()); + } + assert (vm != null); + + try { + orchestrateMigrateAway(vm.getUuid(), work.getSrcHostId(), null); + } catch (InsufficientServerCapacityException e) { + s_logger.warn("Failed to deploy vm " + vm.getId() + " with original planner, sending HAPlanner"); + orchestrateMigrateAway(vm.getUuid(), work.getSrcHostId(), _haMgr.getHAPlanner()); + } + + return new Pair(JobInfo.Status.SUCCEEDED, null); + } + private Pair orchestrateMigrateWithStorage(VmWorkMigrateWithStorage work) throws Exception { VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { @@ -4918,7 +5251,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac NicProfile nic = orchestrateAddVmToNetwork(vm, network, work.getRequestedNicProfile()); - return new Pair(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(nic.getId())); + return new Pair(JobInfo.Status.SUCCEEDED, _jobMgr.marshallResultObject(nic)); } private Pair orchestrateRemoveNicFromVm(VmWorkRemoveNicFromVm work) throws Exception { @@ -4930,7 +5263,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac NicVO nic = _entityMgr.findById(NicVO.class, work.getNicId()); boolean result = orchestrateRemoveNicFromVm(vm, nic); return new Pair(JobInfo.Status.SUCCEEDED, - _jobMgr.marshallResultObject(new Boolean(result))); + _jobMgr.marshallResultObject(result)); } private Pair orchestrateRemoveVmFromNetwork(VmWorkRemoveVmFromNetwork work) throws Exception { @@ -4942,7 +5275,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac boolean result = orchestrateRemoveVmFromNetwork(vm, work.getNetwork(), work.getBroadcastUri()); return new Pair(JobInfo.Status.SUCCEEDED, - _jobMgr.marshallResultObject(new Boolean(result))); + _jobMgr.marshallResultObject(result)); } private Pair orchestrateReconfigure(VmWorkReconfigure work) throws Exception { @@ -4965,7 +5298,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac s_logger.info("Unable to find vm " + work.getVmId()); } assert (vm != null); - orchestrateStorageMigration(vm.getUuid(), work.getDestStoragePool()); + StoragePool pool = (PrimaryDataStoreInfo)dataStoreMgr.getPrimaryDataStore(work.getDestStoragePoolId()); + orchestrateStorageMigration(vm.getUuid(), pool); + return new Pair(JobInfo.Status.SUCCEEDED, null); } diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java index 453890c4279..9edecacf285 100644 --- a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java +++ b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java @@ -16,17 +16,21 @@ // under the License. package com.cloud.vm; +import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.inject.Inject; import org.apache.log4j.Logger; +import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.messagebus.MessageBus; import org.apache.cloudstack.framework.messagebus.PublishScope; import com.cloud.agent.api.HostVmStateReportEntry; +import com.cloud.utils.DateUtil; import com.cloud.vm.dao.VMInstanceDao; public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStateSync { @@ -36,6 +40,9 @@ public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStat @Inject VMInstanceDao _instanceDao; @Inject VirtualMachineManager _vmMgr; + protected final ConfigKey PingInterval = new ConfigKey(Integer.class, "ping.interval", "Advanced", "60", + "Interval to send application level pings to make sure the connection is still working", false); + public VirtualMachinePowerStateSyncImpl() { } @@ -65,6 +72,9 @@ public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStat private void processReport(long hostId, Map translatedInfo) { + if (s_logger.isDebugEnabled()) + s_logger.debug("Process VM state report. host: " + hostId + ", number of records in report: " + translatedInfo.size()); + for (Map.Entry entry : translatedInfo.entrySet()) { if (s_logger.isDebugEnabled()) @@ -80,6 +90,59 @@ public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStat s_logger.debug("VM power state does not change, skip DB writing. vm id: " + entry.getKey()); } } + + // for all running/stopping VMs, we provide monitoring of missing report + List vmsThatAreMissingReport = _instanceDao.findByHostInStates(hostId, VirtualMachine.State.Running, + VirtualMachine.State.Stopping, VirtualMachine.State.Starting); + java.util.Iterator it = vmsThatAreMissingReport.iterator(); + while (it.hasNext()) { + VMInstanceVO instance = it.next(); + if (translatedInfo.get(instance.getId()) != null) + it.remove(); + } + + if (vmsThatAreMissingReport.size() > 0) { + Date currentTime = DateUtil.currentGMTTime(); + if (s_logger.isDebugEnabled()) + s_logger.debug("Run missing VM report. current time: " + currentTime.getTime()); + + // 2 times of sync-update interval for graceful period + long milliSecondsGracefullPeriod = PingInterval.value() * 2000; + + for (VMInstanceVO instance : vmsThatAreMissingReport) { + + Date vmStateUpdateTime = instance.getUpdateTime(); + if (vmStateUpdateTime == null) { + s_logger.warn("VM state was updated but update time is null?! vm id: " + instance.getId()); + vmStateUpdateTime = currentTime; + } + + if (s_logger.isDebugEnabled()) + s_logger.debug("Detected missing VM. host: " + hostId + ", vm id: " + instance.getId() + + ", power state: PowerReportMissing, last state update: " + vmStateUpdateTime.getTime()); + + long milliSecondsSinceLastStateUpdate = currentTime.getTime() - vmStateUpdateTime.getTime(); + + if (milliSecondsSinceLastStateUpdate > milliSecondsGracefullPeriod) { + s_logger.debug("vm id: " + instance.getId() + " - time since last state update(" + milliSecondsSinceLastStateUpdate + "ms) has passed graceful period"); + + if (_instanceDao.updatePowerState(instance.getId(), hostId, VirtualMachine.PowerState.PowerReportMissing)) { + if (s_logger.isDebugEnabled()) + s_logger.debug("VM state report is updated. host: " + hostId + ", vm id: " + instance.getId() + ", power state: PowerReportMissing "); + + _messageBus.publish(null, VirtualMachineManager.Topics.VM_POWER_STATE, PublishScope.GLOBAL, instance.getId()); + } else { + if (s_logger.isDebugEnabled()) + s_logger.debug("VM power state does not change, skip DB writing. vm id: " + instance.getId()); + } + } else { + s_logger.debug("vm id: " + instance.getId() + " - time since last state update(" + milliSecondsSinceLastStateUpdate + "ms) has not passed graceful period yet"); + } + } + } + + if (s_logger.isDebugEnabled()) + s_logger.debug("Done with process of VM state report. host: " + hostId); } @Override diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java b/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java index 31b2d9ca2d2..f3020021840 100644 --- a/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java +++ b/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java @@ -96,10 +96,14 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch return; } - CallContext.register(work.getUserId(), work.getAccountId(), job.getRelated()); + CallContext.register(work.getUserId(), work.getAccountId()); - Pair result = handler.handleVmWorkJob(work); - _asyncJobMgr.completeAsyncJob(job.getId(), result.first(), 0, result.second()); + try { + Pair result = handler.handleVmWorkJob(work); + _asyncJobMgr.completeAsyncJob(job.getId(), result.first(), 0, result.second()); + } finally { + CallContext.unregister(); + } } finally { if (s_logger.isDebugEnabled()) s_logger.debug("Done with run of VM work job: " + cmd + " for VM " + work.getVmId() + ", job origin: " + job.getRelated()); @@ -109,8 +113,6 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch RuntimeException ex = new RuntimeException("Job failed due to exception " + e.getMessage()); _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, _asyncJobMgr.marshallResultObject(ex)); - } finally { - CallContext.unregister(); } } } diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkMigrateAway.java b/engine/orchestration/src/com/cloud/vm/VmWorkMigrateAway.java new file mode 100644 index 00000000000..92189edca4d --- /dev/null +++ b/engine/orchestration/src/com/cloud/vm/VmWorkMigrateAway.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.vm; + +public class VmWorkMigrateAway extends VmWork { + + private static final long serialVersionUID = -5917512239025814373L; + + private long srcHostId; + + public VmWorkMigrateAway(long userId, long accountId, long vmId, String handlerName, + long srcHostId) { + super(userId, accountId, vmId, handlerName); + + this.srcHostId = srcHostId; + } + + public long getSrcHostId() { + return srcHostId; + } +} diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkStart.java b/engine/orchestration/src/com/cloud/vm/VmWorkStart.java index f1b2efdbeac..bb9f375e267 100644 --- a/engine/orchestration/src/com/cloud/vm/VmWorkStart.java +++ b/engine/orchestration/src/com/cloud/vm/VmWorkStart.java @@ -21,10 +21,9 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; -import org.apache.log4j.Logger; - import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.framework.jobs.impl.JobSerializerHelper; +import org.apache.log4j.Logger; import com.cloud.deploy.DataCenterDeployment; import com.cloud.deploy.DeploymentPlan; @@ -46,6 +45,7 @@ public class VmWorkStart extends VmWork { String reservationId; String journalName; + String planner; // use serialization friendly map private Map rawParams; @@ -91,6 +91,14 @@ public class VmWorkStart extends VmWork { } } + public void setDeploymentPlanner(String planner) { + this.planner = planner; + } + + public String getDeploymentPlanner() { + return this.planner; + } + public Map getRawParams() { return rawParams; } diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java b/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java index 2b2f8e841ed..1d7d55ec171 100644 --- a/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java +++ b/engine/orchestration/src/com/cloud/vm/VmWorkStorageMigration.java @@ -16,20 +16,18 @@ // under the License. package com.cloud.vm; -import com.cloud.storage.StoragePool; - public class VmWorkStorageMigration extends VmWork { private static final long serialVersionUID = -8677979691741157474L; - StoragePool destPool; + Long destPoolId; - public VmWorkStorageMigration(long userId, long accountId, long vmId, String handlerName, StoragePool destPool) { + public VmWorkStorageMigration(long userId, long accountId, long vmId, String handlerName, Long destPoolId) { super(userId, accountId, vmId, handlerName); - this.destPool = destPool; + this.destPoolId = destPoolId; } - public StoragePool getDestStoragePool() { - return destPool; + public Long getDestStoragePoolId() { + return destPoolId; } } diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java index 7c533026f99..314531459d6 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManager.java @@ -21,6 +21,7 @@ import java.util.Map; import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; import com.cloud.deploy.DeploymentPlan; +import com.cloud.deploy.DeploymentPlanner; import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.ConcurrentOperationException; @@ -35,7 +36,7 @@ public interface VMEntityManager { void saveVirtualMachine(VMEntityVO vmInstanceVO); - String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException, + String reserveVirtualMachine(VMEntityVO vmEntityVO, DeploymentPlanner plannerToUse, DeploymentPlan plan, ExcludeList exclude) throws InsufficientCapacityException, ResourceUnavailableException; void deployVirtualMachine(String reservationId, VMEntityVO vmEntityVO, String caller, Map params) diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java index 36481ab5a43..b1ac2f85337 100755 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VMEntityManagerImpl.java @@ -22,9 +22,6 @@ import java.util.UUID; import javax.inject.Inject; -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; import org.apache.cloudstack.engine.cloud.entity.api.db.VMReservationVO; @@ -32,6 +29,8 @@ import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMEntityDao; import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMReservationDao; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.dc.DataCenter; import com.cloud.deploy.DataCenterDeployment; @@ -114,6 +113,8 @@ public class VMEntityManagerImpl implements VMEntityManager { @Inject protected AffinityGroupVMMapDao _affinityGroupVMMapDao; + @Inject + DeploymentPlanningManager _planningMgr; @Override public VMEntityVO loadVirtualMachine(String vmId) { @@ -138,7 +139,7 @@ public class VMEntityManagerImpl implements VMEntityManager { } @Override - public String reserveVirtualMachine(VMEntityVO vmEntityVO, String plannerToUse, DeploymentPlan planToDeploy, ExcludeList exclude) + public String reserveVirtualMachine(VMEntityVO vmEntityVO, DeploymentPlanner plannerToUse, DeploymentPlan planToDeploy, ExcludeList exclude) throws InsufficientCapacityException, ResourceUnavailableException { //call planner and get the deployDestination. @@ -189,13 +190,13 @@ public class VMEntityManagerImpl implements VMEntityManager { while (true) { DeployDestination dest = null; try { - dest = _dpMgr.planDeployment(vmProfile, plan, exclude, null); + dest = _dpMgr.planDeployment(vmProfile, plan, exclude, plannerToUse); } catch (AffinityConflictException e) { throw new CloudRuntimeException("Unable to create deployment, affinity rules associted to the VM conflict"); } if (dest != null) { - String reservationId = _dpMgr.finalizeReservation(dest, vmProfile, plan, exclude); + String reservationId = _dpMgr.finalizeReservation(dest, vmProfile, plan, exclude, plannerToUse); if (reservationId != null) { return reservationId; } else { @@ -229,7 +230,7 @@ public class VMEntityManagerImpl implements VMEntityManager { DataCenterDeployment reservedPlan = new DataCenterDeployment(vm.getDataCenterId(), vmReservation.getPodId(), vmReservation.getClusterId(), vmReservation.getHostId(), null, null); try { - _itMgr.start(vm.getUuid(), params, reservedPlan); + _itMgr.start(vm.getUuid(), params, reservedPlan, _planningMgr.getDeploymentPlannerByName(vmReservation.getDeploymentPlanner())); } catch (Exception ex) { // Retry the deployment without using the reservation plan DataCenterDeployment plan = new DataCenterDeployment(0, null, null, null, null, null); @@ -238,11 +239,11 @@ public class VMEntityManagerImpl implements VMEntityManager { plan.setAvoids(reservedPlan.getAvoids()); } - _itMgr.start(vm.getUuid(), params, plan); + _itMgr.start(vm.getUuid(), params, plan, null); } } else { // no reservation found. Let VirtualMachineManager retry - _itMgr.start(vm.getUuid(), params, null); + _itMgr.start(vm.getUuid(), params, null, null); } } diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java index 7f2e4fff240..706748f4f75 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java @@ -24,10 +24,10 @@ import java.util.Map; import javax.inject.Inject; import org.springframework.stereotype.Component; - import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; import com.cloud.deploy.DeploymentPlan; +import com.cloud.deploy.DeploymentPlanner; import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.ConcurrentOperationException; @@ -195,7 +195,7 @@ public class VirtualMachineEntityImpl implements VirtualMachineEntity { } @Override - public String reserve(String plannerToUse, DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException, + public String reserve(DeploymentPlanner plannerToUse, DeploymentPlan plan, ExcludeList exclude, String caller) throws InsufficientCapacityException, ResourceUnavailableException { return manager.reserveVirtualMachine(this.vmEntityVO, plannerToUse, plan, exclude); } diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java index f55f58ce542..2b4995466b5 100755 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/CloudOrchestrator.java @@ -20,14 +20,13 @@ package org.apache.cloudstack.engine.orchestration; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; -import org.springframework.stereotype.Component; - import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity; import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity; import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager; @@ -36,6 +35,7 @@ import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl; import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity; import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; import org.apache.cloudstack.engine.service.api.OrchestrationService; +import org.springframework.stereotype.Component; import com.cloud.deploy.DeploymentPlan; import com.cloud.exception.InsufficientCapacityException; @@ -45,19 +45,19 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.Network; import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkVO; -import com.cloud.offering.DiskOffering; +import com.cloud.offering.DiskOfferingInfo; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.user.dao.AccountDao; -import com.cloud.utils.Pair; import com.cloud.utils.component.ComponentContext; import com.cloud.vm.NicProfile; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachineManager; import com.cloud.vm.dao.UserVmDao; +import com.cloud.vm.dao.UserVmDetailsDao; import com.cloud.vm.dao.VMInstanceDao; @Component @@ -78,6 +78,9 @@ public class CloudOrchestrator implements OrchestrationService { @Inject protected UserVmDao _userVmDao = null; + @Inject + protected UserVmDetailsDao _userVmDetailsDao = null; + @Inject protected ServiceOfferingDao _serviceOfferingDao; @@ -157,11 +160,11 @@ public class CloudOrchestrator implements OrchestrationService { // VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, // vmEntityManager); - LinkedHashMap networkIpMap = new LinkedHashMap(); + LinkedHashMap> networkIpMap = new LinkedHashMap>(); for (String uuid : networkNicMap.keySet()) { NetworkVO network = _networkDao.findByUuid(uuid); - if (network != null) { - networkIpMap.put(network, networkNicMap.get(uuid)); + if(network != null){ + networkIpMap.put(network, new ArrayList(Arrays.asList(networkNicMap.get(uuid)))); } } @@ -176,12 +179,25 @@ public class CloudOrchestrator implements OrchestrationService { // If the template represents an ISO, a disk offering must be passed in, and will be used to create the root disk // Else, a disk offering is optional, and if present will be used to create the data disk - Pair rootDiskOffering = new Pair(null, null); - LinkedHashMap dataDiskOfferings = new LinkedHashMap(); + DiskOfferingInfo rootDiskOfferingInfo = new DiskOfferingInfo(); + List dataDiskOfferings = new ArrayList(); - ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId()); - rootDiskOffering.first(offering); - rootDiskOffering.second(rootDiskSize); + ServiceOfferingVO computeOffering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId()); + + rootDiskOfferingInfo.setDiskOffering(computeOffering); + rootDiskOfferingInfo.setSize(rootDiskSize); + + if (computeOffering.isCustomizedIops() != null && computeOffering.isCustomizedIops()) { + Map userVmDetails = _userVmDetailsDao.listDetailsKeyPairs(vm.getId()); + + if (userVmDetails != null) { + String minIops = userVmDetails.get("minIops"); + String maxIops = userVmDetails.get("maxIops"); + + rootDiskOfferingInfo.setMinIops(minIops != null && minIops.trim().length() > 0 ? Long.parseLong(minIops) : null); + rootDiskOfferingInfo.setMaxIops(maxIops != null && maxIops.trim().length() > 0 ? Long.parseLong(maxIops) : null); + } + } if (vm.getDiskOfferingId() != null) { DiskOfferingVO diskOffering = _diskOfferingDao.findById(vm.getDiskOfferingId()); @@ -196,10 +212,28 @@ public class CloudOrchestrator implements OrchestrationService { } _volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024); } - dataDiskOfferings.put(diskOffering, size); + + DiskOfferingInfo dataDiskOfferingInfo = new DiskOfferingInfo(); + + dataDiskOfferingInfo.setDiskOffering(diskOffering); + dataDiskOfferingInfo.setSize(size); + + if (diskOffering.isCustomizedIops() != null && diskOffering.isCustomizedIops()) { + Map userVmDetails = _userVmDetailsDao.listDetailsKeyPairs(vm.getId()); + + if (userVmDetails != null) { + String minIops = userVmDetails.get("minIopsDo"); + String maxIops = userVmDetails.get("maxIopsDo"); + + dataDiskOfferingInfo.setMinIops(minIops != null && minIops.trim().length() > 0 ? Long.parseLong(minIops) : null); + dataDiskOfferingInfo.setMaxIops(maxIops != null && maxIops.trim().length() > 0 ? Long.parseLong(maxIops) : null); + } + } + + dataDiskOfferings.add(dataDiskOfferingInfo); } - _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, plan, + _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)), computeOffering, rootDiskOfferingInfo, dataDiskOfferings, networkIpMap, plan, hypervisorType); return vmEntity; @@ -217,11 +251,12 @@ public class CloudOrchestrator implements OrchestrationService { //load vm instance and offerings and call virtualMachineManagerImpl VMInstanceVO vm = _vmDao.findByUuid(id); - Pair rootDiskOffering = new Pair(null, null); - ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId()); - rootDiskOffering.first(offering); + ServiceOfferingVO computeOffering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId()); + + DiskOfferingInfo rootDiskOfferingInfo = new DiskOfferingInfo(); + + rootDiskOfferingInfo.setDiskOffering(computeOffering); - LinkedHashMap dataDiskOfferings = new LinkedHashMap(); Long diskOfferingId = vm.getDiskOfferingId(); if (diskOfferingId == null) { throw new InvalidParameterValueException("Installing from ISO requires a disk offering to be specified for the root disk."); @@ -238,20 +273,33 @@ public class CloudOrchestrator implements OrchestrationService { } _volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024); } - rootDiskOffering.first(diskOffering); - rootDiskOffering.second(size); - LinkedHashMap networkIpMap = new LinkedHashMap(); + rootDiskOfferingInfo.setDiskOffering(diskOffering); + rootDiskOfferingInfo.setSize(size); + + if (diskOffering.isCustomizedIops() != null && diskOffering.isCustomizedIops()) { + Map userVmDetails = _userVmDetailsDao.listDetailsKeyPairs(vm.getId()); + + if (userVmDetails != null) { + String minIops = userVmDetails.get("minIopsDo"); + String maxIops = userVmDetails.get("maxIopsDo"); + + rootDiskOfferingInfo.setMinIops(minIops != null && minIops.trim().length() > 0 ? Long.parseLong(minIops) : null); + rootDiskOfferingInfo.setMaxIops(maxIops != null && maxIops.trim().length() > 0 ? Long.parseLong(maxIops) : null); + } + } + + LinkedHashMap> networkIpMap = new LinkedHashMap>(); for (String uuid : networkNicMap.keySet()) { NetworkVO network = _networkDao.findByUuid(uuid); - if (network != null) { - networkIpMap.put(network, networkNicMap.get(uuid)); + if(network != null){ + networkIpMap.put(network, new ArrayList(Arrays.asList(networkNicMap.get(uuid)))); } } HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor); - _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, plan, hypervisorType); + _itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), computeOffering, rootDiskOfferingInfo, new ArrayList(), networkIpMap, plan, hypervisorType); return vmEntity; } diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index 85fa530e820..96dafe947d4 100755 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -16,6 +16,7 @@ // under the License. package org.apache.cloudstack.engine.orchestration; + import java.net.URI; import java.util.ArrayList; import java.util.Arrays; @@ -36,16 +37,20 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; + import org.apache.cloudstack.acl.ControlledEntity.ACLType; +import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.framework.messagebus.MessageBus; +import org.apache.cloudstack.framework.messagebus.PublishScope; import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.cloudstack.region.PortableIpDao; -import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.Listener; @@ -127,6 +132,7 @@ import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; import com.cloud.network.dao.PhysicalNetworkTrafficTypeDao; import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO; import com.cloud.network.dao.PhysicalNetworkVO; +import com.cloud.network.element.AggregatedCommandExecutor; import com.cloud.network.element.DhcpServiceProvider; import com.cloud.network.element.IpDeployer; import com.cloud.network.element.LoadBalancingServiceProvider; @@ -253,6 +259,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra protected IPAddressDao _publicIpAddressDao; @Inject protected IpAddressManager _ipAddrMgr; + @Inject + MessageBus _messageBus; List networkGurus; @@ -659,11 +667,20 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(), relatedFile, name, displayText, predefined .getNetworkDomain(), offering.getGuestType(), plan.getDataCenterId(), plan.getPhysicalNetworkId(), aclType, offering.getSpecifyIpRanges(), vpcId); vo.setDisplayNetwork(isDisplayNetworkEnabled == null ? true : isDisplayNetworkEnabled); + vo.setStrechedL2Network(offering.getSupportsStrechedL2()); networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated, finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId()))); if (domainId != null && aclType == ACLType.Domain) { _networksDao.addDomainToNetwork(id, domainId, subdomainAccess == null ? true : subdomainAccess); + //send event for storing the domain wide resource access + Map params = new HashMap(); + params.put(ApiConstants.ENTITY_TYPE, Network.class); + params.put(ApiConstants.ENTITY_ID, id); + params.put(ApiConstants.DOMAIN_ID, domainId); + params.put(ApiConstants.SUBDOMAIN_ACCESS, subdomainAccess == null ? true : subdomainAccess); + _messageBus.publish(_name, EntityManager.MESSAGE_ADD_DOMAIN_WIDE_ENTITY_EVENT, + PublishScope.LOCAL, params); } } }); @@ -685,24 +702,40 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra @Override @DB - public void allocate(final VirtualMachineProfile vm, final LinkedHashMap networks) throws InsufficientCapacityException, + public void allocate(final VirtualMachineProfile vm, final LinkedHashMap> networks) throws InsufficientCapacityException, ConcurrentOperationException { Transaction.execute(new TransactionCallbackWithExceptionNoReturn() { @Override public void doInTransactionWithoutResult(TransactionStatus status) throws InsufficientCapacityException { int deviceId = 0; + int size = 0; + for (Network ntwk : networks.keySet()) { + List profiles = networks.get(ntwk); + if (profiles != null && !profiles.isEmpty()) { + size = size + profiles.size(); + } else { + size = size + 1; + } + } - boolean[] deviceIds = new boolean[networks.size()]; + boolean[] deviceIds = new boolean[size]; Arrays.fill(deviceIds, false); - List nics = new ArrayList(networks.size()); + List nics = new ArrayList(size); NicProfile defaultNic = null; - for (Map.Entry network : networks.entrySet()) { + for (Map.Entry> network : networks.entrySet()) { Network config = network.getKey(); - NicProfile requested = network.getValue(); + List requestedProfiles = network.getValue(); + if (requestedProfiles == null) { + requestedProfiles = new ArrayList(); + } + if (requestedProfiles.isEmpty()) { + requestedProfiles.add(null); + } + for (NicProfile requested : requestedProfiles) { Boolean isDefaultNic = false; if (vm != null && (requested != null && requested.isDefaultNic())) { isDefaultNic = true; @@ -740,12 +773,11 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra nics.add(vmNic); vm.addNic(vmNic); - } - - if (nics.size() != networks.size()) { - s_logger.warn("Number of nics " + nics.size() + " doesn't match number of requested networks " + networks.size()); - throw new CloudRuntimeException("Number of nics " + nics.size() + " doesn't match number of requested networks " + networks.size()); + } + if (nics.size() != size) { + s_logger.warn("Number of nics " + nics.size() + " doesn't match number of requested nics " + size); + throw new CloudRuntimeException("Number of nics " + nics.size() + " doesn't match number of requested networks " + size); } if (nics.size() == 1) { @@ -768,14 +800,14 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra requested.setMode(network.getMode()); } NicProfile profile = guru.allocate(network, requested, vm); - if (isDefaultNic != null) { - profile.setDefaultNic(isDefaultNic); - } - if (profile == null) { return null; } + if (isDefaultNic != null) { + profile.setDefaultNic(isDefaultNic); + } + if (requested != null && requested.getMode() == null) { profile.setMode(requested.getMode()); } else { @@ -996,11 +1028,6 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra } } - @Override - public boolean equals(Object o) { - return super.equals(o); //To change body of overridden methods use File | Settings | File Templates. - } - @Override public void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, Network network, NetworkOffering offering) throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException { @@ -1058,6 +1085,13 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra } } + for (NetworkElement element : networkElements) { + if ((element instanceof AggregatedCommandExecutor) && (providersToImplement.contains(element.getProvider()))) { + ((AggregatedCommandExecutor)element).prepareAggregatedExecution(network, dest); + } + } + + try { // reapply all the firewall/staticNat/lb rules s_logger.debug("Reprogramming network " + network + " as a part of network implement"); if (!reprogramNetworkRules(network.getId(), CallContext.current().getCallingAccount(), network)) { @@ -1068,6 +1102,25 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra ex.addProxyObject(_entityMgr.findById(DataCenter.class, network.getDataCenterId()).getUuid()); throw ex; } + for (NetworkElement element : networkElements) { + if ((element instanceof AggregatedCommandExecutor) && (providersToImplement.contains(element.getProvider()))) { + if (!((AggregatedCommandExecutor)element).completeAggregatedExecution(network, dest)) { + s_logger.warn("Failed to re-program the network as a part of network " + network + " implement due to aggregated commands execution failure!"); + // see DataCenterVO.java + ResourceUnavailableException ex = new ResourceUnavailableException("Unable to apply network rules as a part of network " + network + " implement", DataCenter.class, + network.getDataCenterId()); + ex.addProxyObject(_entityMgr.findById(DataCenter.class, network.getDataCenterId()).getUuid()); + throw ex; + } + } + } + } finally { + for (NetworkElement element : networkElements) { + if ((element instanceof AggregatedCommandExecutor) && (providersToImplement.contains(element.getProvider()))) { + ((AggregatedCommandExecutor)element).cleanupAggregatedExecution(network, dest); + } + } + } } // This method re-programs the rules/ips for existing network @@ -1538,11 +1591,19 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra } } + if (vm.getType() == Type.User + && _networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp) + && network.getTrafficType() == TrafficType.Guest + && network.getGuestType() == GuestType.Shared + && isLastNicInSubnet(nic)) { // remove the dhcpservice ip if this is the last nic in subnet. - if (vm.getType() == Type.User && isDhcpAccrossMultipleSubnetsSupported(network) && isLastNicInSubnet(nic) && network.getTrafficType() == TrafficType.Guest - && network.getGuestType() == GuestType.Shared) { + DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network); + if (dhcpServiceProvider != null + && isDhcpAccrossMultipleSubnetsSupported(dhcpServiceProvider)) { removeDhcpServiceInSubnet(nic); } + } + NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName()); guru.deallocate(network, profile, vm); _nicDao.remove(nic.getId()); @@ -1553,12 +1614,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra } } - public boolean isDhcpAccrossMultipleSubnetsSupported(Network network) { - if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)) { - return false; - } + public boolean isDhcpAccrossMultipleSubnetsSupported(DhcpServiceProvider dhcpServiceProvider) { - DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network); Map capabilities = dhcpServiceProvider.getCapabilities().get(Network.Service.Dhcp); String supportsMultipleSubnets = capabilities.get(Network.Capability.DhcpAccrossMultipleSubnets); if (supportsMultipleSubnets != null && Boolean.valueOf(supportsMultipleSubnets)) { @@ -2186,6 +2243,10 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra NetworkAccountVO networkAccount = _networkAccountDao.getAccountNetworkMapByNetworkId(networkFinal.getId()); if (networkAccount != null) _networkAccountDao.remove(networkAccount.getId()); + + // remove its related ACL permission + Pair, Long> networkMsg = new Pair, Long>(Network.class, networkFinal.getId()); + _messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, networkMsg); } NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, networkFinal.getNetworkOfferingId()); @@ -2429,8 +2490,12 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra return null; } - return (DhcpServiceProvider)_networkModel.getElementImplementingProvider(DhcpProvider); - + NetworkElement element = _networkModel.getElementImplementingProvider(DhcpProvider); + if ( element instanceof DhcpServiceProvider ) { + return (DhcpServiceProvider)element; + } else { + return null; + } } protected boolean isSharedNetworkWithServices(Network network) { @@ -2475,8 +2540,8 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra if (dc.getNetworkType() == NetworkType.Basic) { List nics = _nicDao.listByVmId(vmInstance.getId()); NetworkVO network = _networksDao.findById(nics.get(0).getNetworkId()); - final LinkedHashMap profiles = new LinkedHashMap(); - profiles.put(network, null); + final LinkedHashMap> profiles = new LinkedHashMap>(); + profiles.put(network, new ArrayList()); Transaction.execute(new TransactionCallbackWithExceptionNoReturn() { @Override diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java index d51ed191b9d..c5e09832227 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java @@ -30,12 +30,13 @@ import java.util.concurrent.ExecutionException; import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.apache.log4j.Logger; - import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; +import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService; @@ -55,6 +56,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; +import org.apache.log4j.Logger; import com.cloud.agent.api.to.DataTO; import com.cloud.agent.api.to.DiskTO; @@ -108,10 +110,12 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.fsm.NoTransitionException; import com.cloud.utils.fsm.StateMachine2; import com.cloud.vm.DiskProfile; +import com.cloud.vm.UserVmVO; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.State; import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.VirtualMachineProfileImpl; +import com.cloud.vm.dao.UserVmDao; public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService, Configurable { private static final Logger s_logger = Logger.getLogger(VolumeOrchestrator.class); @@ -148,6 +152,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati HostDao _hostDao; @Inject SnapshotService _snapshotSrv; + @Inject + protected UserVmDao _userVmDao; private final StateMachine2 _volStateMachine; protected List _storagePoolAllocators; @@ -568,14 +574,17 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati } @Override - public DiskProfile allocateRawVolume(Type type, String name, DiskOffering offering, Long size, VirtualMachine vm, VirtualMachineTemplate template, Account owner) { + public DiskProfile allocateRawVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops, VirtualMachine vm, VirtualMachineTemplate template, Account owner) { if (size == null) { size = offering.getDiskSize(); } else { size = (size * 1024 * 1024 * 1024); } - VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size, offering.getMinIops(), offering.getMaxIops(), - null); + + minIops = minIops != null ? minIops : offering.getMinIops(); + maxIops = maxIops != null ? maxIops : offering.getMaxIops(); + + VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size, minIops, maxIops, null); if (vm != null) { vol.setInstanceId(vm.getId()); } @@ -588,6 +597,11 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati if (template.getFormat() == ImageFormat.ISO) { vol.setIsoId(template.getId()); } + // display flag matters only for the User vms + if (vm.getType() == VirtualMachine.Type.User) { + UserVmVO userVm = _userVmDao.findById(vm.getId()); + vol.setDisplayVolume(userVm.isDisplayVm()); + } vol.setFormat(getSupportedImageFormatForCluster(vm.getHypervisorType())); vol = _volsDao.persist(vol); @@ -595,24 +609,34 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati // Save usage event and update resource count for user vm volumes if (vm.getType() == VirtualMachine.Type.User) { UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), offering.getId(), null, size, - Volume.class.getName(), vol.getUuid()); + Volume.class.getName(), vol.getUuid(), vol.isDisplayVolume()); - _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.volume); - _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.primary_storage, new Long(vol.getSize())); + _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.volume, vol.isDisplayVolume()); + _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.primary_storage, vol.isDisplayVolume(), new Long(vol.getSize())); } return toDiskProfile(vol, offering); } @Override - public DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, VirtualMachineTemplate template, VirtualMachine vm, Account owner) { + public DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offering, Long rootDisksize, Long minIops, Long maxIops, VirtualMachineTemplate template, VirtualMachine vm, Account owner) { assert (template.getFormat() != ImageFormat.ISO) : "ISO is not a template really...."; Long size = _tmpltMgr.getTemplateSize(template.getId(), vm.getDataCenterId()); - if (rootDisksize != null) { - size = (rootDisksize * 1024 * 1024 * 1024); + if (rootDisksize != null ) { + rootDisksize = rootDisksize * 1024 * 1024 * 1024; + if (rootDisksize > size) { + s_logger.debug("Using root disk size of " + rootDisksize + " for volume " + name); + size = rootDisksize; + } else { + s_logger.debug("Using root disk size of " + size + " for volume " + name + "since specified root disk size of " + rootDisksize + " is smaller than template"); + } } - VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size, offering.getMinIops(), offering.getMaxIops(), - null); + + minIops = minIops != null ? minIops : offering.getMinIops(); + maxIops = maxIops != null ? maxIops : offering.getMaxIops(); + + VolumeVO vol = new VolumeVO(type, name, vm.getDataCenterId(), owner.getDomainId(), owner.getId(), offering.getId(), size, minIops, maxIops, null); + vol.setFormat(getSupportedImageFormatForCluster(template.getHypervisorType())); if (vm != null) { vol.setInstanceId(vm.getId()); @@ -628,6 +652,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati vol.setDeviceId(1l); } + if (vm.getType() == VirtualMachine.Type.User) { + UserVmVO userVm = _userVmDao.findById(vm.getId()); + vol.setDisplayVolume(userVm.isDisplayVm()); + } + + vol = _volsDao.persist(vol); // Create event and update resource count for volumes if vm is a user vm @@ -638,10 +668,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati offeringId = offering.getId(); UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_CREATE, vol.getAccountId(), vol.getDataCenterId(), vol.getId(), vol.getName(), offeringId, null, size, - Volume.class.getName(), vol.getUuid()); + Volume.class.getName(), vol.getUuid(), vol.isDisplayVolume()); - _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.volume); - _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.primary_storage, new Long(vol.getSize())); + _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.volume, vol.isDisplayVolume()); + _resourceLimitMgr.incrementResourceCount(vm.getAccountId(), ResourceType.primary_storage, vol.isDisplayVolume(), new Long(vol.getSize())); } return toDiskProfile(vol, offering); } @@ -656,16 +686,29 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati } else if (hyperType == HypervisorType.Ovm) { return ImageFormat.RAW; } else if (hyperType == HypervisorType.Hyperv) { - return ImageFormat.VHD; + return ImageFormat.VHDX; } else { return null; } } + private boolean isSupportedImageFormatForCluster(VolumeInfo volume, HypervisorType rootDiskHyperType) { + ImageFormat volumeFormat = volume.getFormat(); + if (rootDiskHyperType == HypervisorType.Hyperv) { + if (volumeFormat.equals(ImageFormat.VHDX) || volumeFormat.equals(ImageFormat.VHD)) { + return true; + } else { + return false; + } + } else { + return volume.getFormat().equals(getSupportedImageFormatForCluster(rootDiskHyperType)); + } + } + private VolumeInfo copyVolume(StoragePool rootDiskPool, VolumeInfo volume, VirtualMachine vm, VirtualMachineTemplate rootDiskTmplt, DataCenter dcVO, Pod pod, DiskOffering diskVO, ServiceOffering svo, HypervisorType rootDiskHyperType) throws NoTransitionException { - if (!volume.getFormat().equals(getSupportedImageFormatForCluster(rootDiskHyperType))) { + if (!isSupportedImageFormatForCluster(volume, rootDiskHyperType)) { throw new InvalidParameterValueException("Failed to attach volume to VM since volumes format " + volume.getFormat().getFileExtension() + " is not compatible with the vm hypervisor type"); } @@ -677,27 +720,30 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati } @Override - public VolumeInfo createVolumeOnPrimaryStorage(VirtualMachine vm, Volume rootVolumeOfVm, VolumeInfo volume, HypervisorType rootDiskHyperType) throws NoTransitionException { + public VolumeInfo createVolumeOnPrimaryStorage(VirtualMachine vm, VolumeInfo volume, HypervisorType rootDiskHyperType, StoragePool storagePool) throws NoTransitionException { VirtualMachineTemplate rootDiskTmplt = _entityMgr.findById(VirtualMachineTemplate.class, vm.getTemplateId()); DataCenter dcVO = _entityMgr.findById(DataCenter.class, vm.getDataCenterId()); Pod pod = _entityMgr.findById(Pod.class, vm.getPodIdToDeployIn()); - StoragePoolVO rootDiskPool = _storagePoolDao.findById(rootVolumeOfVm.getPoolId()); + ServiceOffering svo = _entityMgr.findById(ServiceOffering.class, vm.getServiceOfferingId()); DiskOffering diskVO = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId()); - Long clusterId = (rootDiskPool == null ? null : rootDiskPool.getClusterId()); + Long clusterId = (storagePool == null ? null : storagePool.getClusterId()); VolumeInfo vol = null; if (volume.getState() == Volume.State.Allocated) { vol = createVolume(volume, vm, rootDiskTmplt, dcVO, pod, clusterId, svo, diskVO, new ArrayList(), volume.getSize(), rootDiskHyperType); } else if (volume.getState() == Volume.State.Uploaded) { - vol = copyVolume(rootDiskPool, volume, vm, rootDiskTmplt, dcVO, pod, diskVO, svo, rootDiskHyperType); + vol = copyVolume(storagePool, volume, vm, rootDiskTmplt, dcVO, pod, diskVO, svo, rootDiskHyperType); if (vol != null) { // Moving of Volume is successful, decrement the volume resource count from secondary for an account and increment it into primary storage under same account. - _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage, new Long(volume.getSize())); - _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, new Long(volume.getSize())); + _resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.secondary_storage, volume.getSize()); + _resourceLimitMgr.incrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, volume.getSize()); } } + if (vol == null) { + throw new CloudRuntimeException("Volume shouldn't be null " + volume.getId()); + } VolumeVO volVO = _volsDao.findById(vol.getId()); volVO.setFormat(getSupportedImageFormatForCluster(rootDiskHyperType)); _volsDao.update(volVO.getId(), volVO); @@ -799,6 +845,15 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati } } + @Override + public void disconnectVolumeFromHost(VolumeInfo volumeInfo, Host host, DataStore dataStore) { + DataStoreDriver dataStoreDriver = dataStore != null ? dataStore.getDriver() : null; + + if (dataStoreDriver instanceof PrimaryDataStoreDriver) { + ((PrimaryDataStoreDriver)dataStoreDriver).disconnectVolumeFromHost(volumeInfo, host, dataStore); + } + } + @Override public void disconnectVolumesFromHost(long vmId, long hostId) { HostVO host = _hostDao.findById(hostId); @@ -943,10 +998,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati vm.addDisk(disk); } - if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat() == ImageFormat.ISO) { - DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image, vm.getVirtualMachine().getDataCenterId()).getTO(); - DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO); - vm.addDisk(iso); + //if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat() == ImageFormat.ISO) { + if (vm.getType() == VirtualMachine.Type.User) { + _tmpltMgr.prepareIsoForVmProfile(vm); + //DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image, vm.getVirtualMachine().getDataCenterId()).getTO(); + //DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO); + //vm.addDisk(iso); } } @@ -1107,8 +1164,29 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati future = volService.createVolumeAsync(volume, destPool); } else { - TemplateInfo templ = tmplFactory.getTemplate(templateId, DataStoreRole.Image); - future = volService.createVolumeFromTemplateAsync(volume, destPool.getId(), templ); + + TemplateInfo templ = tmplFactory.getReadyTemplateOnImageStore(templateId, dest.getDataCenter().getId()); + if (templ == null) { + s_logger.debug("can't find ready template: " + templateId + " for data center " + dest.getDataCenter().getId()); + throw new CloudRuntimeException("can't find ready template: " + templateId + " for data center " + dest.getDataCenter().getId()); + } + + PrimaryDataStore primaryDataStore = (PrimaryDataStore)destPool; + + if (primaryDataStore.isManaged()) { + DiskOffering diskOffering = _entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId()); + HypervisorType hyperType = vm.getVirtualMachine().getHypervisorType(); + + // update the volume's hypervisor_ss_reserve from its disk offering (used for managed storage) + updateHypervisorSnapshotReserveForVolume(diskOffering, volume, hyperType); + + long hostId = vm.getVirtualMachine().getHostId(); + + future = volService.createManagedStorageAndVolumeFromTemplateAsync(volume, destPool.getId(), templ, hostId); + } + else { + future = volService.createVolumeFromTemplateAsync(volume, destPool.getId(), templ); + } } VolumeApiResult result = null; try { @@ -1125,7 +1203,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati StoragePoolVO storagePool = _storagePoolDao.findById(destPool.getId()); - if (newVol.getVolumeType() == Type.DATADISK && storagePool.isManaged()) { + if (storagePool.isManaged()) { long hostId = vm.getVirtualMachine().getHostId(); Host host = _hostDao.findById(hostId); @@ -1155,6 +1233,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati } throw new CloudRuntimeException("Unable to prepare Volume for vm because DeployDestination is null, vm:" + vm); } + + // don't allow to start vm that doesn't have a root volume + if (_volsDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT).isEmpty()) { + throw new CloudRuntimeException("Unable to prepare volumes for vm as ROOT volume is missing"); + } + List vols = _volsDao.findUsableVolumesForInstance(vm.getId()); if (s_logger.isDebugEnabled()) { s_logger.debug("Checking if we need to prepare " + vols.size() + " volumes for " + vm); diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java b/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java index 86eab58ff0b..51e87663919 100644 --- a/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/service/api/ProvisioningServiceImpl.java @@ -25,9 +25,6 @@ import java.util.Map; import javax.inject.Inject; import javax.ws.rs.Path; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; - import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity; import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntityImpl; import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManager; @@ -38,6 +35,8 @@ import org.apache.cloudstack.engine.datacenter.entity.api.PodEntityImpl; import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity; import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntityImpl; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; import com.cloud.host.Host; import com.cloud.host.Status; @@ -52,13 +51,13 @@ public class ProvisioningServiceImpl implements ProvisioningService { DataCenterResourceManager manager; @Override - public StorageEntity registerStorage(String name, List tags, Map details) { + public StorageEntity registerStorage(final String name, final List tags, final Map details) { // TODO Auto-generated method stub return null; } @Override - public ZoneEntity registerZone(String zoneUuid, String name, String owner, List tags, Map details) { + public ZoneEntity registerZone(final String zoneUuid, final String name, final String owner, final List tags, final Map details) { ZoneEntityImpl zoneEntity = new ZoneEntityImpl(zoneUuid, manager); zoneEntity.setName(name); zoneEntity.setOwner(owner); @@ -68,7 +67,7 @@ public class ProvisioningServiceImpl implements ProvisioningService { } @Override - public PodEntity registerPod(String podUuid, String name, String owner, String zoneUuid, List tags, Map details) { + public PodEntity registerPod(final String podUuid, final String name, final String owner, final String zoneUuid, final List tags, final Map details) { PodEntityImpl podEntity = new PodEntityImpl(podUuid, manager); podEntity.setOwner(owner); podEntity.setName(name); @@ -77,7 +76,7 @@ public class ProvisioningServiceImpl implements ProvisioningService { } @Override - public ClusterEntity registerCluster(String clusterUuid, String name, String owner, List tags, Map details) { + public ClusterEntity registerCluster(final String clusterUuid, final String name, final String owner, final List tags, final Map details) { ClusterEntityImpl clusterEntity = new ClusterEntityImpl(clusterUuid, manager); clusterEntity.setOwner(owner); clusterEntity.setName(name); @@ -86,7 +85,7 @@ public class ProvisioningServiceImpl implements ProvisioningService { } @Override - public HostEntity registerHost(String hostUuid, String name, String owner, List tags, Map details) { + public HostEntity registerHost(final String hostUuid, final String name, final String owner, final List tags, final Map details) { HostEntityImpl hostEntity = new HostEntityImpl(hostUuid, manager); hostEntity.setOwner(owner); hostEntity.setName(name); @@ -97,38 +96,38 @@ public class ProvisioningServiceImpl implements ProvisioningService { } @Override - public void deregisterStorage(String uuid) { + public void deregisterStorage(final String uuid) { // TODO Auto-generated method stub } @Override - public void deregisterZone(String uuid) { + public void deregisterZone(final String uuid) { ZoneEntityImpl zoneEntity = new ZoneEntityImpl(uuid, manager); zoneEntity.disable(); } @Override - public void deregisterPod(String uuid) { + public void deregisterPod(final String uuid) { PodEntityImpl podEntity = new PodEntityImpl(uuid, manager); podEntity.disable(); } @Override - public void deregisterCluster(String uuid) { + public void deregisterCluster(final String uuid) { ClusterEntityImpl clusterEntity = new ClusterEntityImpl(uuid, manager); clusterEntity.disable(); } @Override - public void deregisterHost(String uuid) { + public void deregisterHost(final String uuid) { HostEntityImpl hostEntity = new HostEntityImpl(uuid, manager); hostEntity.disable(); } @Override - public void changeState(String type, String entity, Status state) { + public void changeState(final String type, final String entity, final Status state) { // TODO Auto-generated method stub } @@ -141,7 +140,10 @@ public class ProvisioningServiceImpl implements ProvisioningService { @Override public List listPods() { - List pods = new ArrayList(); + /* + * Not in use now, just commented out. + */ + //List pods = new ArrayList(); //pods.add(new PodEntityImpl("pod-uuid-1", "pod1")); //pods.add(new PodEntityImpl("pod-uuid-2", "pod2")); return null; @@ -162,7 +164,7 @@ public class ProvisioningServiceImpl implements ProvisioningService { } @Override - public ZoneEntity getZone(String uuid) { + public ZoneEntity getZone(final String uuid) { ZoneEntityImpl impl = new ZoneEntityImpl(uuid, manager); return impl; } diff --git a/engine/orchestration/test/com/cloud/agent/manager/ConnectedAgentAttacheTest.java b/engine/orchestration/test/com/cloud/agent/manager/ConnectedAgentAttacheTest.java new file mode 100644 index 00000000000..e0e97c51049 --- /dev/null +++ b/engine/orchestration/test/com/cloud/agent/manager/ConnectedAgentAttacheTest.java @@ -0,0 +1,82 @@ +// 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.manager; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import org.junit.Test; + +import com.cloud.utils.nio.Link; + +public class ConnectedAgentAttacheTest { + + @Test + public void testEquals() throws Exception { + + Link link = mock(Link.class); + + ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 0, null, link, false); + ConnectedAgentAttache agentAttache2 = new ConnectedAgentAttache(null, 0, null, link, false); + + assertTrue(agentAttache1.equals(agentAttache2)); + } + + @Test + public void testEqualsFalseNull() throws Exception { + + Link link = mock(Link.class); + + ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 0, null, link, false); + + assertFalse(agentAttache1.equals(null)); + } + + @Test + public void testEqualsFalseDiffLink() throws Exception { + + Link link1 = mock(Link.class); + Link link2 = mock(Link.class); + + ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 0, null, link1, false); + ConnectedAgentAttache agentAttache2 = new ConnectedAgentAttache(null, 0, null, link2, false); + + assertFalse(agentAttache1.equals(agentAttache2)); + } + + @Test + public void testEqualsFalseDiffId() throws Exception { + + Link link1 = mock(Link.class); + + ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 1, null, link1, false); + ConnectedAgentAttache agentAttache2 = new ConnectedAgentAttache(null, 2, null, link1, false); + + assertFalse(agentAttache1.equals(agentAttache2)); + } + + @Test + public void testEqualsFalseDiffClass() throws Exception { + + Link link1 = mock(Link.class); + + ConnectedAgentAttache agentAttache1 = new ConnectedAgentAttache(null, 1, null, link1, false); + + assertFalse(agentAttache1.equals("abc")); + } +} \ No newline at end of file diff --git a/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java b/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java index 997855d2b24..49b2fc5fb11 100644 --- a/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java +++ b/engine/orchestration/test/com/cloud/vm/VirtualMachineManagerImplTest.java @@ -30,6 +30,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import junit.framework.Assert; + import org.junit.Before; import org.junit.Test; import org.mockito.Matchers; @@ -46,9 +48,9 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Answer; import com.cloud.agent.api.CheckVirtualMachineAnswer; import com.cloud.agent.api.CheckVirtualMachineCommand; +import com.cloud.agent.api.Command; import com.cloud.agent.api.MigrateWithStorageAnswer; import com.cloud.agent.api.MigrateWithStorageCommand; import com.cloud.agent.api.MigrateWithStorageCompleteAnswer; @@ -61,6 +63,8 @@ import com.cloud.agent.api.PrepareForMigrationAnswer; import com.cloud.agent.api.PrepareForMigrationCommand; import com.cloud.agent.api.ScaleVmAnswer; import com.cloud.agent.api.ScaleVmCommand; +import com.cloud.agent.api.StopAnswer; +import com.cloud.agent.api.StopCommand; import com.cloud.capacity.CapacityManager; import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.DataCenterDao; @@ -257,9 +261,7 @@ public class VirtualMachineManagerImplTest { @Test(expected = CloudRuntimeException.class) public void testScaleVM2() throws Exception { - DeployDestination dest = new DeployDestination(null, null, null, _host); - long l = 1L; - + new DeployDestination(null, null, null, _host); doReturn(3L).when(_vmInstance).getId(); when(_vmInstanceDao.findById(anyLong())).thenReturn(_vmInstance); ServiceOfferingVO newServiceOffering = getSvcoffering(512); @@ -269,9 +271,9 @@ public class VirtualMachineManagerImplTest { doReturn(1L).when(hostVO).getClusterId(); when(CapacityManager.CpuOverprovisioningFactor.valueIn(1L)).thenReturn(1.0f); ScaleVmCommand reconfigureCmd = - new ScaleVmCommand("myVmName", newServiceOffering.getCpu(), newServiceOffering.getSpeed(), newServiceOffering.getSpeed(), newServiceOffering.getRamSize(), - newServiceOffering.getRamSize(), newServiceOffering.getLimitCpuUse()); - Answer answer = new ScaleVmAnswer(reconfigureCmd, true, "details"); + new ScaleVmCommand("myVmName", newServiceOffering.getCpu(), newServiceOffering.getSpeed(), newServiceOffering.getSpeed(), newServiceOffering.getRamSize(), + newServiceOffering.getRamSize(), newServiceOffering.getLimitCpuUse()); + new ScaleVmAnswer(reconfigureCmd, true, "details"); when(_agentMgr.send(2l, reconfigureCmd)).thenReturn(null); _vmMgr.reConfigureVm(_vmInstance.getUuid(), getSvcoffering(256), false); @@ -298,7 +300,6 @@ public class VirtualMachineManagerImplTest { private ServiceOfferingVO getSvcoffering(int ramSize) { - long id = 4L; String name = "name"; String displayText = "displayText"; int cpu = 1; @@ -309,7 +310,7 @@ public class VirtualMachineManagerImplTest { boolean useLocalStorage = false; ServiceOfferingVO serviceOffering = - new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, ha, displayText, useLocalStorage, false, null, false, null, false); + new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, ha, displayText, useLocalStorage, false, null, false, null, false); return serviceOffering; } @@ -408,7 +409,7 @@ public class VirtualMachineManagerImplTest { // Check migration of a vm with its volumes within a cluster. @Test public void testMigrateWithVolumeWithinCluster() throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, - VirtualMachineMigrationException, OperationTimedoutException { + VirtualMachineMigrationException, OperationTimedoutException { initializeMockConfigForMigratingVmWithVolumes(); when(_srcHostMock.getClusterId()).thenReturn(3L); @@ -420,7 +421,7 @@ public class VirtualMachineManagerImplTest { // Check migration of a vm with its volumes across a cluster. @Test public void testMigrateWithVolumeAcrossCluster() throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, - VirtualMachineMigrationException, OperationTimedoutException { + VirtualMachineMigrationException, OperationTimedoutException { initializeMockConfigForMigratingVmWithVolumes(); when(_srcHostMock.getClusterId()).thenReturn(3L); @@ -433,7 +434,7 @@ public class VirtualMachineManagerImplTest { // other is local. @Test(expected = CloudRuntimeException.class) public void testMigrateWithVolumeFail1() throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, - VirtualMachineMigrationException, OperationTimedoutException { + VirtualMachineMigrationException, OperationTimedoutException { initializeMockConfigForMigratingVmWithVolumes(); when(_srcHostMock.getClusterId()).thenReturn(3L); @@ -448,7 +449,7 @@ public class VirtualMachineManagerImplTest { // Check migration of a vm fails when vm is not in Running state. @Test(expected = ConcurrentOperationException.class) public void testMigrateWithVolumeFail2() throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, - VirtualMachineMigrationException, OperationTimedoutException { + VirtualMachineMigrationException, OperationTimedoutException { initializeMockConfigForMigratingVmWithVolumes(); when(_srcHostMock.getClusterId()).thenReturn(3L); @@ -458,4 +459,48 @@ public class VirtualMachineManagerImplTest { _vmMgr.migrateWithStorage(_vmInstance.getUuid(), _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock); } + + @Test + public void testSendStopWithOkAnswer() throws Exception { + VirtualMachineGuru guru = mock(VirtualMachineGuru.class); + VirtualMachine vm = mock(VirtualMachine.class); + VirtualMachineProfile profile = mock(VirtualMachineProfile.class); + StopAnswer answer = new StopAnswer(new StopCommand(vm, false), "ok", true); + when(profile.getVirtualMachine()).thenReturn(vm); + when(vm.getHostId()).thenReturn(1L); + when(_agentMgr.send(anyLong(), (Command)any())).thenReturn(answer); + + boolean actual = _vmMgr.sendStop(guru, profile, false); + + Assert.assertTrue(actual); + } + + @Test + public void testSendStopWithFailAnswer() throws Exception { + VirtualMachineGuru guru = mock(VirtualMachineGuru.class); + VirtualMachine vm = mock(VirtualMachine.class); + VirtualMachineProfile profile = mock(VirtualMachineProfile.class); + StopAnswer answer = new StopAnswer(new StopCommand(vm, false), "fail", false); + when(profile.getVirtualMachine()).thenReturn(vm); + when(vm.getHostId()).thenReturn(1L); + when(_agentMgr.send(anyLong(), (Command)any())).thenReturn(answer); + + boolean actual = _vmMgr.sendStop(guru, profile, false); + + Assert.assertFalse(actual); + } + + @Test + public void testSendStopWithNullAnswer() throws Exception { + VirtualMachineGuru guru = mock(VirtualMachineGuru.class); + VirtualMachine vm = mock(VirtualMachine.class); + VirtualMachineProfile profile = mock(VirtualMachineProfile.class); + when(profile.getVirtualMachine()).thenReturn(vm); + when(vm.getHostId()).thenReturn(1L); + when(_agentMgr.send(anyLong(), (Command)any())).thenReturn(null); + + boolean actual = _vmMgr.sendStop(guru, profile, false); + + Assert.assertFalse(actual); + } } diff --git a/engine/orchestration/test/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java b/engine/orchestration/test/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java new file mode 100755 index 00000000000..04233df5dbb --- /dev/null +++ b/engine/orchestration/test/org/apache/cloudstack/engine/orchestration/NetworkOrchestratorTest.java @@ -0,0 +1,164 @@ +// 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 org.apache.cloudstack.engine.orchestration; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.when; + +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +import junit.framework.TestCase; + +import org.apache.log4j.Logger; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Matchers; + +import com.cloud.network.Network; + +import com.cloud.network.NetworkModel; +import com.cloud.network.Network.GuestType; +import com.cloud.network.Network.Service; +import com.cloud.network.Networks.TrafficType; +import com.cloud.network.dao.NetworkDao; +import com.cloud.network.dao.NetworkServiceMapDao; +import com.cloud.network.dao.NetworkVO; +import com.cloud.network.element.DhcpServiceProvider; +import com.cloud.network.guru.NetworkGuru; + +import com.cloud.vm.Nic; +import com.cloud.vm.NicVO; +import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachineProfile; +import com.cloud.vm.VirtualMachine.Type; +import com.cloud.vm.dao.NicDao; +import com.cloud.vm.dao.NicIpAliasDao; +import com.cloud.vm.dao.NicSecondaryIpDao; + +/** + * NetworkManagerImpl implements NetworkManager. + */ +public class NetworkOrchestratorTest extends TestCase { + static final Logger s_logger = Logger.getLogger(NetworkOrchestratorTest.class); + + NetworkOrchestrator testOrchastrator = new NetworkOrchestrator(); + + String guruName = "GuestNetworkGuru"; + String dhcpProvider = "VirtualRouter"; + NetworkGuru guru = mock(NetworkGuru.class); + + @Override + @Before + public void setUp() { + // make class-scope mocks + testOrchastrator._nicDao = mock(NicDao.class); + testOrchastrator._networksDao = mock(NetworkDao.class); + testOrchastrator._networkModel = mock(NetworkModel.class); + testOrchastrator._nicSecondaryIpDao = mock(NicSecondaryIpDao.class); + testOrchastrator._ntwkSrvcDao = mock(NetworkServiceMapDao.class); + testOrchastrator._nicIpAliasDao = mock(NicIpAliasDao.class); + DhcpServiceProvider provider = mock(DhcpServiceProvider.class); + + Map capabilities = new HashMap(); + Map> services = new HashMap>(); + services.put(Network.Service.Dhcp,capabilities); + when(provider.getCapabilities()).thenReturn(services); + capabilities.put(Network.Capability.DhcpAccrossMultipleSubnets, "true"); + + when(testOrchastrator._ntwkSrvcDao.getProviderForServiceInNetwork(Matchers.anyLong(), Matchers.eq(Service.Dhcp))).thenReturn(dhcpProvider); + when(testOrchastrator._networkModel.getElementImplementingProvider(dhcpProvider)).thenReturn(provider); + + when(guru.getName()).thenReturn(guruName); + List networkGurus = new ArrayList(); + networkGurus.add(guru); + testOrchastrator.networkGurus = networkGurus; + } + + @Test + public void testRemoveDhcpServiceWithNic() { + // make local mocks + VirtualMachineProfile vm = mock(VirtualMachineProfile.class); + NicVO nic = mock(NicVO.class); + NetworkVO network = mock(NetworkVO.class); + + // make sure that release dhcp will be called + when(vm.getType()).thenReturn(Type.User); + when(testOrchastrator._networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)).thenReturn(true); + when(network.getTrafficType()).thenReturn(TrafficType.Guest); + when(network.getGuestType()).thenReturn(GuestType.Shared); + when(testOrchastrator._nicDao.listByNetworkIdTypeAndGatewayAndBroadcastUri(nic.getNetworkId(), VirtualMachine.Type.User, nic.getGateway(), nic.getBroadcastUri())).thenReturn(new ArrayList()); + + + + when(network.getGuruName()).thenReturn(guruName); + when(testOrchastrator._networksDao.findById(nic.getNetworkId())).thenReturn(network); + + testOrchastrator.removeNic(vm, nic); + + verify(nic, times(1)).setState(Nic.State.Deallocating); + verify(testOrchastrator._networkModel, times(2)).getElementImplementingProvider(dhcpProvider); + verify(testOrchastrator._ntwkSrvcDao, times(2)).getProviderForServiceInNetwork(network.getId(), Service.Dhcp); + verify(testOrchastrator._networksDao, times(2)).findById(nic.getNetworkId()); + } + @Test + public void testDontRemoveDhcpServiceFromDomainRouter() { + // make local mocks + VirtualMachineProfile vm = mock(VirtualMachineProfile.class); + NicVO nic = mock(NicVO.class); + NetworkVO network = mock(NetworkVO.class); + + // make sure that release dhcp won't be called + when(vm.getType()).thenReturn(Type.DomainRouter); + + when(network.getGuruName()).thenReturn(guruName); + when(testOrchastrator._networksDao.findById(nic.getNetworkId())).thenReturn(network); + + testOrchastrator.removeNic(vm, nic); + + verify(nic, times(1)).setState(Nic.State.Deallocating); + verify(testOrchastrator._networkModel, never()).getElementImplementingProvider(dhcpProvider); + verify(testOrchastrator._ntwkSrvcDao, never()).getProviderForServiceInNetwork(network.getId(), Service.Dhcp); + verify(testOrchastrator._networksDao, times(1)).findById(nic.getNetworkId()); + } + @Test + public void testDontRemoveDhcpServiceWhenNotProvided() { + // make local mocks + VirtualMachineProfile vm = mock(VirtualMachineProfile.class); + NicVO nic = mock(NicVO.class); + NetworkVO network = mock(NetworkVO.class); + + // make sure that release dhcp will *not* be called + when(vm.getType()).thenReturn(Type.User); + when(testOrchastrator._networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)).thenReturn(false); + + when(network.getGuruName()).thenReturn(guruName); + when(testOrchastrator._networksDao.findById(nic.getNetworkId())).thenReturn(network); + + testOrchastrator.removeNic(vm, nic); + + verify(nic, times(1)).setState(Nic.State.Deallocating); + verify(testOrchastrator._networkModel, never()).getElementImplementingProvider(dhcpProvider); + verify(testOrchastrator._ntwkSrvcDao, never()).getProviderForServiceInNetwork(network.getId(), Service.Dhcp); + verify(testOrchastrator._networksDao, times(1)).findById(nic.getNetworkId()); + } +} diff --git a/engine/pom.xml b/engine/pom.xml index f95007cae83..4ebb0966822 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -24,11 +24,24 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml install + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + cloudstack-checkstyle + none + false + + + + api diff --git a/engine/schema/findbugsExcludeFilter.xml b/engine/schema/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/schema/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/schema/pom.xml b/engine/schema/pom.xml index 4e2357c8ff5..5eb58a523a4 100644 --- a/engine/schema/pom.xml +++ b/engine/schema/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml index 1a400e049e0..489b37d04b7 100644 --- a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml +++ b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml @@ -36,7 +36,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -72,7 +72,7 @@ - + @@ -81,7 +81,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -157,6 +157,7 @@ + @@ -172,12 +173,12 @@ - - - - + + + + - + @@ -316,6 +317,8 @@ + + @@ -331,6 +334,8 @@ + + diff --git a/engine/schema/src/com/cloud/dc/DataCenterDetailVO.java b/engine/schema/src/com/cloud/dc/DataCenterDetailVO.java index e9bf611d63f..5e08fac58ee 100644 --- a/engine/schema/src/com/cloud/dc/DataCenterDetailVO.java +++ b/engine/schema/src/com/cloud/dc/DataCenterDetailVO.java @@ -43,15 +43,16 @@ public class DataCenterDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; protected DataCenterDetailVO() { } - public DataCenterDetailVO(long dcId, String name, String value) { + public DataCenterDetailVO(long dcId, String name, String value, boolean display) { this.resourceId = dcId; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/DataCenterDaoImpl.java index a355a9ca99f..ea5039fea80 100755 --- a/engine/schema/src/com/cloud/dc/dao/DataCenterDaoImpl.java +++ b/engine/schema/src/com/cloud/dc/dao/DataCenterDaoImpl.java @@ -375,7 +375,7 @@ public class DataCenterDaoImpl extends GenericDaoBase implem List resourceDetails = new ArrayList(); for (String key : details.keySet()) { - resourceDetails.add(new DataCenterDetailVO(zone.getId(), key, details.get(key))); + resourceDetails.add(new DataCenterDetailVO(zone.getId(), key, details.get(key), true)); } _detailsDao.saveDetails(resourceDetails); diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java index 86959889f46..f3b9efe4851 100644 --- a/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java @@ -41,8 +41,8 @@ public class DataCenterDetailsDaoImpl extends ResourceDetailsDaoBase getEntityType() { + return Event.class; + } } diff --git a/engine/schema/src/com/cloud/gpu/HostGpuGroupsVO.java b/engine/schema/src/com/cloud/gpu/HostGpuGroupsVO.java new file mode 100644 index 00000000000..1c186a162e3 --- /dev/null +++ b/engine/schema/src/com/cloud/gpu/HostGpuGroupsVO.java @@ -0,0 +1,70 @@ +// 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.gpu; + +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 org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name="host_gpu_groups") +public class HostGpuGroupsVO implements InternalIdentity { + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + private long id; + + @Column(name="group_name") + private String groupName; + + @Column(name="host_id") + private long hostId; + + protected HostGpuGroupsVO() { + } + + public HostGpuGroupsVO(long hostId, String groupName) { + this.hostId = hostId; + this.groupName = groupName; + } + + public long getHostId() { + return hostId; + } + + public void setHostId(long hostId) { + this.hostId = hostId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + @Override + public long getId() { + return id; + } +} diff --git a/engine/schema/src/com/cloud/gpu/VGPUTypesVO.java b/engine/schema/src/com/cloud/gpu/VGPUTypesVO.java new file mode 100644 index 00000000000..586a0c92798 --- /dev/null +++ b/engine/schema/src/com/cloud/gpu/VGPUTypesVO.java @@ -0,0 +1,82 @@ +// 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.gpu; + +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 org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name="vgpu_types") +public class VGPUTypesVO implements InternalIdentity { + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + private long id; + + @Column(name="vgpu_type") + private String vgpuType; + + @Column(name="gpu_group_id") + private long gpuGroupId; + + @Column(name="remaining_vm_capacity") + private long remainingCapacity; + + protected VGPUTypesVO() { + } + + public VGPUTypesVO(String vgpuType, long gpuGroupId, long remainingCapacity) { + this.vgpuType = vgpuType; + this.gpuGroupId = gpuGroupId; + this.remainingCapacity = remainingCapacity; + } + + public String getVgpuType() { + return vgpuType; + } + + public void setVgpuType(String vgpuType) { + this.vgpuType = vgpuType; + } + + public long getGpuGroupId() { + return gpuGroupId; + } + + public void setGpuGroupId(long gpuGroupId) { + this.gpuGroupId = gpuGroupId; + } + + public long getRemainingCapacity() { + return remainingCapacity; + } + + public void setRemainingCapacity(long remainingCapacity) { + this.remainingCapacity = remainingCapacity; + } + + @Override + public long getId() { + return id; + } +} diff --git a/engine/schema/src/com/cloud/gpu/dao/HostGpuGroupsDao.java b/engine/schema/src/com/cloud/gpu/dao/HostGpuGroupsDao.java new file mode 100644 index 00000000000..58641443972 --- /dev/null +++ b/engine/schema/src/com/cloud/gpu/dao/HostGpuGroupsDao.java @@ -0,0 +1,60 @@ +// 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.gpu.dao; + +import java.util.List; + +import com.cloud.gpu.HostGpuGroupsVO; +import com.cloud.utils.db.GenericDao; + +public interface HostGpuGroupsDao extends GenericDao { + + /** + * Find host device by hostId and PCI ID + * @param hostId the host + * @param groupName GPU group + * @return HostGpuGroupsVO + */ + HostGpuGroupsVO findByHostIdGroupName(long hostId, String groupName); + + /** + * List all the host Ids, that are GPU enabled. + * @return list of hostIds + */ + List listHostIds(); + + /** + * Return a list by hostId. + * @param hostId the host + * @return HostGpuGroupsVO + */ + List listByHostId(long hostId); + + /** + * Delete entries by hostId. + * @param hostId the host + */ + void deleteGpuEntries(long hostId); + + /** + * Save the list of GPU groups belonging to a host + * @param hostId the host + * @param gpuGroups the list of GPU groups to save + */ + void persist(long hostId, List gpuGroups); + +} diff --git a/engine/schema/src/com/cloud/gpu/dao/HostGpuGroupsDaoImpl.java b/engine/schema/src/com/cloud/gpu/dao/HostGpuGroupsDaoImpl.java new file mode 100644 index 00000000000..6bddea262ed --- /dev/null +++ b/engine/schema/src/com/cloud/gpu/dao/HostGpuGroupsDaoImpl.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.gpu.dao; + +import java.util.List; + +import javax.ejb.Local; + +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; + +import com.cloud.gpu.HostGpuGroupsVO; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.GenericSearchBuilder; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; + +@Component +@Local(value = HostGpuGroupsDao.class) +public class HostGpuGroupsDaoImpl extends GenericDaoBase implements HostGpuGroupsDao { + private static final Logger s_logger = Logger.getLogger(HostGpuGroupsDaoImpl.class); + + private final SearchBuilder _hostIdGroupNameSearch; + private final SearchBuilder _searchByHostId; + private final GenericSearchBuilder _searchHostIds; + + public HostGpuGroupsDaoImpl() { + + _hostIdGroupNameSearch = createSearchBuilder(); + _hostIdGroupNameSearch.and("hostId", _hostIdGroupNameSearch.entity().getHostId(), SearchCriteria.Op.EQ); + _hostIdGroupNameSearch.and("groupName", _hostIdGroupNameSearch.entity().getGroupName(), SearchCriteria.Op.EQ); + _hostIdGroupNameSearch.done(); + + _searchByHostId = createSearchBuilder(); + _searchByHostId.and("hostId", _searchByHostId.entity().getHostId(), SearchCriteria.Op.EQ); + _searchByHostId.done(); + + _searchHostIds = createSearchBuilder(Long.class); + _searchHostIds.selectFields(_searchHostIds.entity().getHostId()); + _searchHostIds.done(); + } + + @Override + public HostGpuGroupsVO findByHostIdGroupName(long hostId, String groupName) { + SearchCriteria sc = _hostIdGroupNameSearch.create(); + sc.setParameters("hostId", hostId); + sc.setParameters("groupName", groupName); + return findOneBy(sc); + } + + @Override + public List listHostIds() { + SearchCriteria sc = _searchHostIds.create(); + return customSearch(sc, null); + } + + @Override + public List listByHostId(long hostId) { + SearchCriteria sc = _searchByHostId.create(); + sc.setParameters("hostId", hostId); + return listBy(sc); + } + + @Override + public void persist(long hostId, List gpuGroups) { + for (String groupName : gpuGroups) { + if (findByHostIdGroupName(hostId, groupName) == null) { + HostGpuGroupsVO record = new HostGpuGroupsVO(hostId, groupName); + persist(record); + } + } + } + + @Override + public void deleteGpuEntries(long hostId) { + SearchCriteria sc = _searchByHostId.create(); + sc.setParameters("hostId", hostId); + remove(sc); + } +} diff --git a/engine/schema/src/com/cloud/gpu/dao/VGPUTypesDao.java b/engine/schema/src/com/cloud/gpu/dao/VGPUTypesDao.java new file mode 100644 index 00000000000..2872cfda886 --- /dev/null +++ b/engine/schema/src/com/cloud/gpu/dao/VGPUTypesDao.java @@ -0,0 +1,48 @@ +//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.gpu.dao; + +import java.util.HashMap; +import java.util.List; + +import com.cloud.gpu.VGPUTypesVO; +import com.cloud.utils.db.GenericDao; + +public interface VGPUTypesDao extends GenericDao { + + /** + * Find VGPU types by group Id + * @param groupId of the GPU group + * @return list of VGPUTypesVO + */ + List listByGroupId(long groupId); + + /** + * Find VGPU type by group Id and VGPU type + * @param groupId of the GPU group + * @param vgpuType name of VGPU type + * @return VGPUTypesVO + */ + VGPUTypesVO findByGroupIdVGPUType(long groupId, String vgpuType); + + /** + * Save the list of enabled VGPU types + * @param hostId the host + * @param groupDetails with enabled VGPU types + */ + void persist(long hostId, HashMap> groupDetails); +} diff --git a/engine/schema/src/com/cloud/gpu/dao/VGPUTypesDaoImpl.java b/engine/schema/src/com/cloud/gpu/dao/VGPUTypesDaoImpl.java new file mode 100644 index 00000000000..7cc83cc9eb8 --- /dev/null +++ b/engine/schema/src/com/cloud/gpu/dao/VGPUTypesDaoImpl.java @@ -0,0 +1,95 @@ +//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.gpu.dao; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; + +import javax.ejb.Local; +import javax.inject.Inject; + +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; + +import com.cloud.gpu.HostGpuGroupsVO; +import com.cloud.gpu.VGPUTypesVO; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; + +@Component +@Local(value = VGPUTypesDao.class) +public class VGPUTypesDaoImpl extends GenericDaoBase implements VGPUTypesDao { + private static final Logger s_logger = Logger.getLogger(VGPUTypesDaoImpl.class); + + private final SearchBuilder _searchByGroupId; + private final SearchBuilder _searchByGroupIdVGPUType; + // private final SearchBuilder _searchByHostId; + // private final SearchBuilder _searchForStaleEntries; + + @Inject protected HostGpuGroupsDao _hostGpuGroupsDao; + + public VGPUTypesDaoImpl() { + + _searchByGroupId = createSearchBuilder(); + _searchByGroupId.and("groupId", _searchByGroupId.entity().getGpuGroupId(), SearchCriteria.Op.EQ); + _searchByGroupId.done(); + + _searchByGroupIdVGPUType = createSearchBuilder(); + _searchByGroupIdVGPUType.and("groupId", _searchByGroupIdVGPUType.entity().getGpuGroupId(), SearchCriteria.Op.EQ); + _searchByGroupIdVGPUType.and("vgpuType", _searchByGroupIdVGPUType.entity().getVgpuType(), SearchCriteria.Op.EQ); + _searchByGroupIdVGPUType.done(); + } + + @Override + public List listByGroupId(long groupId) { + SearchCriteria sc = _searchByGroupId.create(); + sc.setParameters("groupId", groupId); + return listBy(sc); + } + + @Override + public VGPUTypesVO findByGroupIdVGPUType(long groupId, String vgpuType) { + SearchCriteria sc = _searchByGroupIdVGPUType.create(); + sc.setParameters("groupId", groupId); + sc.setParameters("vgpuType", vgpuType); + return findOneBy(sc); + } + + @Override + public void persist(long hostId, HashMap> groupDetails) { + Iterator>> it1 = groupDetails.entrySet().iterator(); + while (it1.hasNext()) { + Entry> entry = it1.next(); + HostGpuGroupsVO gpuGroup = _hostGpuGroupsDao.findByHostIdGroupName(hostId, entry.getKey()); + HashMap values = entry.getValue(); + Iterator> it2 = values.entrySet().iterator(); + while (it2.hasNext()) { + Entry record = it2.next(); + VGPUTypesVO vgpuType = null; + if ((vgpuType = findByGroupIdVGPUType(gpuGroup.getId(), record.getKey())) == null) { + persist(new VGPUTypesVO(record.getKey(), gpuGroup.getId(), record.getValue())); + } else { + vgpuType.setRemainingCapacity(record.getValue()); + update(vgpuType.getId(), vgpuType); + } + } + } + } +} diff --git a/engine/schema/src/com/cloud/host/HostVO.java b/engine/schema/src/com/cloud/host/HostVO.java index 56c066b1b72..25cc9544da2 100755 --- a/engine/schema/src/com/cloud/host/HostVO.java +++ b/engine/schema/src/com/cloud/host/HostVO.java @@ -17,6 +17,7 @@ package com.cloud.host; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; @@ -153,6 +154,10 @@ public class HostVO implements Host { @Transient List hostTags; + // This value is only for saving and current cannot be loaded. + @Transient + HashMap> groupDetails = new HashMap>(); + @Override public String getStorageIpAddressDeux() { return storageIpAddressDeux; @@ -313,6 +318,14 @@ public class HostVO implements Host { this.hostTags = hostTags; } + public HashMap> getGpuGroupDetails() { + return groupDetails; + } + + public void setGpuGroups(HashMap> groupDetails) { + this.groupDetails = groupDetails; + } + @Column(name = "data_center_id", nullable = false) private long dataCenterId; diff --git a/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java b/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java index 08a436644ba..3a3bdf67b91 100755 --- a/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java +++ b/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java @@ -38,6 +38,8 @@ import com.cloud.cluster.agentlb.HostTransferMapVO; import com.cloud.cluster.agentlb.dao.HostTransferMapDao; import com.cloud.dc.ClusterVO; import com.cloud.dc.dao.ClusterDao; +import com.cloud.gpu.dao.HostGpuGroupsDao; +import com.cloud.gpu.dao.VGPUTypesDao; import com.cloud.host.Host; import com.cloud.host.Host.Type; import com.cloud.host.HostTagVO; @@ -126,6 +128,10 @@ public class HostDaoImpl extends GenericDaoBase implements HostDao @Inject protected HostDetailsDao _detailsDao; @Inject + protected HostGpuGroupsDao _hostGpuGroupsDao; + @Inject + protected VGPUTypesDao _vgpuTypesDao; + @Inject protected HostTagsDao _hostTagsDao; @Inject protected HostTransferMapDao _hostTransferDao; @@ -775,6 +781,16 @@ public class HostDaoImpl extends GenericDaoBase implements HostDao _hostTagsDao.persist(host.getId(), hostTags); } + protected void saveGpuRecords(HostVO host) { + HashMap> groupDetails = host.getGpuGroupDetails(); + if (groupDetails != null) { + // Create/Update GPU group entries + _hostGpuGroupsDao.persist(host.getId(), new ArrayList(groupDetails.keySet())); + // Create/Update VGPU types entries + _vgpuTypesDao.persist(host.getId(), groupDetails); + } + } + @Override @DB public HostVO persist(HostVO host) { @@ -797,6 +813,7 @@ public class HostDaoImpl extends GenericDaoBase implements HostDao loadDetails(dbHost); saveHostTags(host); loadHostTags(dbHost); + saveGpuRecords(host); txn.commit(); @@ -816,6 +833,7 @@ public class HostDaoImpl extends GenericDaoBase implements HostDao saveDetails(host); saveHostTags(host); + saveGpuRecords(host); txn.commit(); @@ -881,7 +899,8 @@ public class HostDaoImpl extends GenericDaoBase implements HostDao @Override public boolean updateState(Status oldStatus, Event event, Status newStatus, Host vo, Object data) { - HostVO host = findById(vo.getId()); + // lock target row from beginning to avoid lock-promotion caused deadlock + HostVO host = lockRow(vo.getId(), true); if (host == null) { if (event == Event.Remove && newStatus == Status.Removed) { host = findByIdIncludingRemoved(vo.getId()); @@ -935,46 +954,49 @@ public class HostDaoImpl extends GenericDaoBase implements HostDao int result = update(ub, sc, null); assert result <= 1 : "How can this update " + result + " rows? "; - if (status_logger.isDebugEnabled() && result == 0) { + if (result == 0) { HostVO ho = findById(host.getId()); assert ho != null : "How how how? : " + host.getId(); - StringBuilder str = new StringBuilder("Unable to update host for event:").append(event.toString()); - str.append(". Name=").append(host.getName()); - str.append("; New=[status=") - .append(newStatus.toString()) - .append(":msid=") - .append(newStatus.lostConnection() ? "null" : host.getManagementServerId()) - .append(":lastpinged=") - .append(host.getLastPinged()) - .append("]"); - str.append("; Old=[status=") - .append(oldStatus.toString()) - .append(":msid=") - .append(host.getManagementServerId()) - .append(":lastpinged=") - .append(oldPingTime) - .append("]"); - str.append("; DB=[status=") - .append(vo.getStatus().toString()) - .append(":msid=") - .append(vo.getManagementServerId()) - .append(":lastpinged=") - .append(vo.getLastPinged()) - .append(":old update count=") - .append(oldUpdateCount) - .append("]"); - status_logger.debug(str.toString()); - } else { - StringBuilder msg = new StringBuilder("Agent status update: ["); - msg.append("id = " + host.getId()); - msg.append("; name = " + host.getName()); - msg.append("; old status = " + oldStatus); - msg.append("; event = " + event); - msg.append("; new status = " + newStatus); - msg.append("; old update count = " + oldUpdateCount); - msg.append("; new update count = " + newUpdateCount + "]"); - status_logger.debug(msg.toString()); + if (status_logger.isDebugEnabled()) { + + StringBuilder str = new StringBuilder("Unable to update host for event:").append(event.toString()); + str.append(". Name=").append(host.getName()); + str.append("; New=[status=") + .append(newStatus.toString()) + .append(":msid=") + .append(newStatus.lostConnection() ? "null" : host.getManagementServerId()) + .append(":lastpinged=") + .append(host.getLastPinged()) + .append("]"); + str.append("; Old=[status=").append(oldStatus.toString()).append(":msid=").append(host.getManagementServerId()).append(":lastpinged=").append(oldPingTime) + .append("]"); + str.append("; DB=[status=") + .append(vo.getStatus().toString()) + .append(":msid=") + .append(vo.getManagementServerId()) + .append(":lastpinged=") + .append(vo.getLastPinged()) + .append(":old update count=") + .append(oldUpdateCount) + .append("]"); + status_logger.debug(str.toString()); + } else { + StringBuilder msg = new StringBuilder("Agent status update: ["); + msg.append("id = " + host.getId()); + msg.append("; name = " + host.getName()); + msg.append("; old status = " + oldStatus); + msg.append("; event = " + event); + msg.append("; new status = " + newStatus); + msg.append("; old update count = " + oldUpdateCount); + msg.append("; new update count = " + newUpdateCount + "]"); + status_logger.debug(msg.toString()); + } + + if (ho.getState() == newStatus) { + status_logger.debug("Host " + ho.getName() + " state has already been updated to " + newStatus); + return true; + } } return result > 0; diff --git a/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java b/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java index 3098a68c27c..397c7b3b319 100644 --- a/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java +++ b/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java @@ -76,16 +76,16 @@ public class UserIpv6AddressVO implements UserIpv6Address { Date created; protected UserIpv6AddressVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public UserIpv6AddressVO(String address, long dataCenterId, String macAddress, long vlanDbId) { this.address = address; this.dataCenterId = dataCenterId; - this.vlanId = vlanDbId; - this.state = State.Free; - this.setMacAddress(macAddress); - this.uuid = UUID.randomUUID().toString(); + vlanId = vlanDbId; + state = State.Free; + setMacAddress(macAddress); + uuid = UUID.randomUUID().toString(); } @Override @@ -184,4 +184,9 @@ public class UserIpv6AddressVO implements UserIpv6Address { public void setCreated(Date created) { this.created = created; } + + @Override + public Class getEntityType() { + return UserIpv6Address.class; + } } diff --git a/engine/schema/src/com/cloud/network/VpnUserVO.java b/engine/schema/src/com/cloud/network/VpnUserVO.java index 07b6326e768..d6c4b603529 100644 --- a/engine/schema/src/com/cloud/network/VpnUserVO.java +++ b/engine/schema/src/com/cloud/network/VpnUserVO.java @@ -58,16 +58,16 @@ public class VpnUserVO implements VpnUser { private String uuid; public VpnUserVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public VpnUserVO(long accountId, long domainId, String userName, String password) { this.accountId = accountId; this.domainId = domainId; - this.username = userName; + username = userName; this.password = password; - this.state = State.Add; - this.uuid = UUID.randomUUID().toString(); + state = State.Add; + uuid = UUID.randomUUID().toString(); } @Override @@ -86,7 +86,7 @@ public class VpnUserVO implements VpnUser { } public void setUsername(String userName) { - this.username = userName; + username = userName; } @Override @@ -119,10 +119,15 @@ public class VpnUserVO implements VpnUser { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } + + @Override + public Class getEntityType() { + return VpnUser.class; + } } diff --git a/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java b/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java index b69907c51c3..1842533000f 100644 --- a/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java +++ b/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java @@ -77,7 +77,7 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity { public AutoScalePolicyVO(long domainId, long accountId, int duration, int quietTime, Date lastQuiteTime, String action) { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.domainId = domainId; this.accountId = accountId; this.duration = duration; @@ -150,4 +150,10 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity { public void setLastQuiteTime(Date lastQuiteTime) { this.lastQuiteTime = lastQuiteTime; } + + @Override + public Class getEntityType() { + return AutoScalePolicy.class; + } + } diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java index d8612b0da50..d32e7f873a0 100644 --- a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java +++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java @@ -87,6 +87,9 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity { @Column(name = "state") private String state; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public AutoScaleVmGroupVO() { } @@ -94,8 +97,8 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity { long accountId, int minMembers, int maxMembers, int memberPort, int interval, Date lastInterval, long profileId, String state) { - this.uuid = UUID.randomUUID().toString(); - this.loadBalancerId = lbRuleId; + uuid = UUID.randomUUID().toString(); + loadBalancerId = lbRuleId; this.minMembers = minMembers; this.maxMembers = maxMembers; this.memberPort = memberPort; @@ -208,4 +211,22 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity { public String getUuid() { return uuid; } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } + + @Override + public Class getEntityType() { + return AutoScaleVmGroup.class; + } } diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java index ec643b0a139..69e4c8190f4 100644 --- a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java +++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java @@ -86,12 +86,15 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter @Column(name = GenericDao.CREATED_COLUMN) protected Date created; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public AutoScaleVmProfileVO() { } public AutoScaleVmProfileVO(long zoneId, long domainId, long accountId, long serviceOfferingId, long templateId, String otherDeployParams, Map counterParamList, Integer destroyVmGraceperiod, long autoscaleUserId) { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.zoneId = zoneId; this.domainId = domainId; this.accountId = accountId; @@ -146,7 +149,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter } public void setCounterParams(String counterParam) { - this.counterParams = counterParam; + counterParams = counterParam; } public void setCounterParamsForUpdate(Map counterParamList) { @@ -216,4 +219,23 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter public long getAutoScaleUserId() { return autoscaleUserId; } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } + + @Override + public Class getEntityType() { + return AutoScaleVmProfile.class; + } + } diff --git a/engine/schema/src/com/cloud/network/as/ConditionVO.java b/engine/schema/src/com/cloud/network/as/ConditionVO.java index 8d7e776c89f..5035f731b57 100644 --- a/engine/schema/src/com/cloud/network/as/ConditionVO.java +++ b/engine/schema/src/com/cloud/network/as/ConditionVO.java @@ -77,7 +77,7 @@ public class ConditionVO implements Condition, Identity, InternalIdentity { this.relationalOperator = relationalOperator; this.accountId = accountId; this.domainId = domainId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public Date getCreated() { @@ -121,10 +121,16 @@ public class ConditionVO implements Condition, Identity, InternalIdentity { @Override public String getUuid() { - return this.uuid; + return uuid; } public Date getRemoved() { return removed; } + + @Override + public Class getEntityType() { + return Condition.class; + } + } diff --git a/engine/schema/src/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java b/engine/schema/src/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java index 9f288003499..e89536b990c 100644 --- a/engine/schema/src/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java +++ b/engine/schema/src/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java @@ -39,7 +39,6 @@ public class FirewallRulesCidrsDaoImpl extends GenericDaoBase implemen address.setVpcId(null); address.setSystem(false); address.setVmIp(null); + address.setDisplay(true); update(ipAddressId, address); } diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java index d71a90fc4fc..de2d9346306 100644 --- a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java +++ b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java @@ -114,8 +114,11 @@ public class IPAddressVO implements IpAddress { @Column(name = "is_portable") private boolean portable = false; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + protected IPAddressVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -126,26 +129,26 @@ public class IPAddressVO implements IpAddress { public IPAddressVO(Ip address, long dataCenterId, long macAddress, long vlanDbId, boolean sourceNat) { this.address = address; this.dataCenterId = dataCenterId; - this.vlanId = vlanDbId; + vlanId = vlanDbId; this.sourceNat = sourceNat; - this.allocatedInDomainId = null; - this.allocatedToAccountId = null; - this.allocatedTime = null; - this.state = State.Free; + allocatedInDomainId = null; + allocatedToAccountId = null; + allocatedTime = null; + state = State.Free; this.macAddress = macAddress; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public IPAddressVO(Ip address, long dataCenterId, Long networkId, Long vpcId, long physicalNetworkId, long sourceNetworkId, long vlanDbId, boolean portable) { this.address = address; this.dataCenterId = dataCenterId; - this.associatedWithNetworkId = networkId; + associatedWithNetworkId = networkId; this.vpcId = vpcId; this.physicalNetworkId = physicalNetworkId; this.sourceNetworkId = sourceNetworkId; - this.vlanId = vlanDbId; + vlanId = vlanDbId; this.portable = portable; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public long getMacAddress() { @@ -158,7 +161,7 @@ public class IPAddressVO implements IpAddress { } public void setDataCenterId(long dcId) { - this.dataCenterId = dcId; + dataCenterId = dcId; } @Override @@ -182,7 +185,7 @@ public class IPAddressVO implements IpAddress { } public void setAssociatedWithNetworkId(Long networkId) { - this.associatedWithNetworkId = networkId; + associatedWithNetworkId = networkId; } @Override @@ -200,11 +203,11 @@ public class IPAddressVO implements IpAddress { } public void setAllocatedToAccountId(Long accountId) { - this.allocatedToAccountId = accountId; + allocatedToAccountId = accountId; } public void setAllocatedInDomainId(Long domainId) { - this.allocatedInDomainId = domainId; + allocatedInDomainId = domainId; } public void setSourceNat(boolean sourceNat) { @@ -217,16 +220,16 @@ public class IPAddressVO implements IpAddress { } public void setAllocatedTime(Date allocated) { - this.allocatedTime = allocated; + allocatedTime = allocated; } @Override public long getVlanId() { - return this.vlanId; + return vlanId; } public void setVlanId(long vlanDbId) { - this.vlanId = vlanDbId; + vlanId = vlanDbId; } @Override @@ -278,7 +281,7 @@ public class IPAddressVO implements IpAddress { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -300,7 +303,7 @@ public class IPAddressVO implements IpAddress { } public void setSystem(boolean isSystem) { - this.system = isSystem; + system = isSystem; } @Override @@ -334,4 +337,18 @@ public class IPAddressVO implements IpAddress { public Long getNetworkId() { return sourceNetworkId; } + + @Override + public boolean isDisplay() { + return display; + } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public Class getEntityType() { + return IpAddress.class; + } } diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDao.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDao.java index 79eaf8e16ba..a25534b7010 100644 --- a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDao.java +++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDao.java @@ -34,4 +34,12 @@ public interface LoadBalancerVMMapDao extends GenericDao listByInstanceIp(String instanceIp); + + List listByLoadBalancerIdAndVmId(long loadBalancerId, long instanceId); + + LoadBalancerVMMapVO findByLoadBalancerIdAndVmIdVmIp(long loadBalancerId, long instanceId, String instanceIp); + + void remove(long id, long instanceId, String instanceIp, Boolean revoke); } diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java index b0b14fc23c1..cbfda8fadb3 100644 --- a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java +++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapDaoImpl.java @@ -51,6 +51,21 @@ public class LoadBalancerVMMapDaoImpl extends GenericDaoBase sc = createSearchCriteria(); + sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId); + sc.addAnd("instanceId", SearchCriteria.Op.IN, instanceId); + sc.addAnd("instanceIp", SearchCriteria.Op.EQ, instanceIp); + + if (revoke != null) { + sc.addAnd("revoke", SearchCriteria.Op.EQ, revoke); + } + + expunge(sc); + } + + @Override public List listByInstanceId(long instanceId) { SearchCriteria sc = createSearchCriteria(); @@ -59,6 +74,14 @@ public class LoadBalancerVMMapDaoImpl extends GenericDaoBase listByInstanceIp(String instanceIp) { + SearchCriteria sc = createSearchCriteria(); + sc.addAnd("instanceIp", SearchCriteria.Op.EQ, instanceIp); + + return listBy(sc); + } + @Override public List listByLoadBalancerId(long loadBalancerId) { SearchCriteria sc = createSearchCriteria(); @@ -84,6 +107,18 @@ public class LoadBalancerVMMapDaoImpl extends GenericDaoBase sc = createSearchCriteria(); + sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId); + sc.addAnd("instanceId", SearchCriteria.Op.EQ, instanceId); + sc.addAnd("instanceIp", SearchCriteria.Op.EQ, instanceIp); + + return findOneBy(sc); + } + + @Override public boolean isVmAttachedToLoadBalancer(long loadBalancerId) { GenericSearchBuilder CountByAccount = createSearchBuilder(Long.class); @@ -94,4 +129,12 @@ public class LoadBalancerVMMapDaoImpl extends GenericDaoBase 0; } + + @Override + public List listByLoadBalancerIdAndVmId(long loadBalancerId, long instanceId) { + SearchCriteria sc = createSearchCriteria(); + sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId); + sc.addAnd("instanceId", SearchCriteria.Op.EQ, instanceId); + return listBy(sc); + } } diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapVO.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapVO.java index 0a67106dc9b..08b918475c3 100644 --- a/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapVO.java +++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVMMapVO.java @@ -39,6 +39,9 @@ public class LoadBalancerVMMapVO implements InternalIdentity { @Column(name = "instance_id") private long instanceId; + @Column(name = "instance_ip") + private String instanceIp; + @Column(name = "revoke") private boolean revoke = false; @@ -59,6 +62,13 @@ public class LoadBalancerVMMapVO implements InternalIdentity { this.revoke = revoke; } + public LoadBalancerVMMapVO(long loadBalancerId, long instanceId, String vmIp, boolean revoke) { + this.loadBalancerId = loadBalancerId; + this.instanceId = instanceId; + this.instanceIp = vmIp; + this.revoke = revoke; + } + @Override public long getId() { return id; @@ -87,4 +97,13 @@ public class LoadBalancerVMMapVO implements InternalIdentity { public void setState(String state) { this.state = state; } + + public String getInstanceIp() { + return instanceIp; + } + + public void setInstanceIp(String instanceIp) { + this.instanceIp = instanceIp; + } + } diff --git a/engine/schema/src/com/cloud/network/dao/MonitoringServiceDaoImpl.java b/engine/schema/src/com/cloud/network/dao/MonitoringServiceDaoImpl.java index c2292a245ba..fffb42b3f5e 100644 --- a/engine/schema/src/com/cloud/network/dao/MonitoringServiceDaoImpl.java +++ b/engine/schema/src/com/cloud/network/dao/MonitoringServiceDaoImpl.java @@ -37,10 +37,10 @@ public class MonitoringServiceDaoImpl extends GenericDaoBase getEntityType() { + return MonitoringService.class; } } diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDetailVO.java b/engine/schema/src/com/cloud/network/dao/NetworkDetailVO.java index 5228e33c37a..e6cad17210d 100644 --- a/engine/schema/src/com/cloud/network/dao/NetworkDetailVO.java +++ b/engine/schema/src/com/cloud/network/dao/NetworkDetailVO.java @@ -43,15 +43,16 @@ public class NetworkDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public NetworkDetailVO() { } - public NetworkDetailVO(long networkId, String name, String value) { + public NetworkDetailVO(long networkId, String name, String value, boolean display) { this.resourceId = networkId; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java index c4fb4811661..0874a3b22d0 100644 --- a/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/network/dao/NetworkDetailsDaoImpl.java @@ -27,8 +27,8 @@ import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase; public class NetworkDetailsDaoImpl extends ResourceDetailsDaoBase implements NetworkDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new NetworkDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new NetworkDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/com/cloud/network/dao/NetworkVO.java b/engine/schema/src/com/cloud/network/dao/NetworkVO.java index f3776df89b8..f1d7e7efba9 100644 --- a/engine/schema/src/com/cloud/network/dao/NetworkVO.java +++ b/engine/schema/src/com/cloud/network/dao/NetworkVO.java @@ -166,8 +166,11 @@ public class NetworkVO implements Network { @Column(name = "network_acl_id") Long networkACLId; + @Column(name = "streched_l2") + boolean strechedL2Network = false; + public NetworkVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } /** @@ -193,8 +196,8 @@ public class NetworkVO implements Network { } else { this.state = state; } - this.id = -1; - this.uuid = UUID.randomUUID().toString(); + id = -1; + uuid = UUID.randomUUID().toString(); } public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId, long related, String name, String displayText, @@ -216,19 +219,19 @@ public class NetworkVO implements Network { aclType, specifyIpRanges, vpcId); - this.gateway = that.getGateway(); - this.cidr = that.getCidr(); - this.networkCidr = that.getNetworkCidr(); - this.broadcastUri = that.getBroadcastUri(); - this.broadcastDomainType = that.getBroadcastDomainType(); + gateway = that.getGateway(); + cidr = that.getCidr(); + networkCidr = that.getNetworkCidr(); + broadcastUri = that.getBroadcastUri(); + broadcastDomainType = that.getBroadcastDomainType(); this.guruName = guruName; - this.state = that.getState(); + state = that.getState(); if (state == null) { state = State.Allocated; } - this.uuid = UUID.randomUUID().toString(); - this.ip6Gateway = that.getIp6Gateway(); - this.ip6Cidr = that.getIp6Cidr(); + uuid = UUID.randomUUID().toString(); + ip6Gateway = that.getIp6Gateway(); + ip6Cidr = that.getIp6Cidr(); } /** @@ -260,7 +263,7 @@ public class NetworkVO implements Network { this.displayText = displayText; this.aclType = aclType; this.networkDomain = networkDomain; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.guestType = guestType; this.specifyIpRanges = specifyIpRanges; this.vpcId = vpcId; @@ -436,7 +439,7 @@ public class NetworkVO implements Network { } public void setDns1(String dns) { - this.dns1 = dns; + dns1 = dns; } public String getDns2() { @@ -444,7 +447,7 @@ public class NetworkVO implements Network { } public void setDns2(String dns) { - this.dns2 = dns; + dns2 = dns; } @Override @@ -492,19 +495,19 @@ public class NetworkVO implements Network { return false; } NetworkVO that = (NetworkVO)obj; - if (this.trafficType != that.trafficType) { + if (trafficType != that.trafficType) { return false; } - if ((this.cidr == null && that.cidr != null) || (this.cidr != null && that.cidr == null)) { + if ((cidr == null && that.cidr != null) || (cidr != null && that.cidr == null)) { return false; } - if (this.cidr == null && that.cidr == null) { + if (cidr == null && that.cidr == null) { return true; } - return NetUtils.isNetworkAWithinNetworkB(this.cidr, that.cidr); + return NetUtils.isNetworkAWithinNetworkB(cidr, that.cidr); } @Override @@ -516,7 +519,7 @@ public class NetworkVO implements Network { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -583,4 +586,18 @@ public class NetworkVO implements Network { public Long getNetworkACLId() { return networkACLId; } + + @Override + public Class getEntityType() { + return Network.class; + } + + @Override + public boolean isStrechedL2Network() { + return strechedL2Network; + } + + public void setStrechedL2Network(boolean strechedL2Network) { + this.strechedL2Network = strechedL2Network; + } } diff --git a/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceDao.java b/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceDao.java new file mode 100644 index 00000000000..ebc0f1af227 --- /dev/null +++ b/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceDao.java @@ -0,0 +1,25 @@ +// 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.dao; + + +import com.cloud.utils.db.GenericDao; + +public interface OpRouterMonitorServiceDao extends GenericDao { + +} diff --git a/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceDaoImpl.java b/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceDaoImpl.java new file mode 100644 index 00000000000..b92512e6d91 --- /dev/null +++ b/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceDaoImpl.java @@ -0,0 +1,28 @@ +// 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.dao; + +import com.cloud.utils.db.GenericDaoBase; +import org.springframework.stereotype.Component; + +import javax.ejb.Local; + +@Component +@Local(value=OpRouterMonitorServiceDao.class) +public class OpRouterMonitorServiceDaoImpl extends GenericDaoBase implements OpRouterMonitorServiceDao { +} diff --git a/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceVO.java b/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceVO.java new file mode 100644 index 00000000000..c2882fc4eaf --- /dev/null +++ b/engine/schema/src/com/cloud/network/dao/OpRouterMonitorServiceVO.java @@ -0,0 +1,69 @@ +// 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.dao; + +import org.apache.cloudstack.api.InternalIdentity; + +import javax.persistence.Entity; +import javax.persistence.Table; +import javax.persistence.Id; +import javax.persistence.Column; + + +@Entity +@Table(name = "op_router_monitoring_services") +public class OpRouterMonitorServiceVO implements InternalIdentity { + + @Id + @Column(name="vm_id") + Long id; + + @Column(name="router_name") + private String name; + + @Column(name="last_alert_timestamp") + private String lastAlertTimestamp; + + + public OpRouterMonitorServiceVO() {} + + public OpRouterMonitorServiceVO(long vmId, String name, String lastAlertTimestamp) { + this.id = vmId; + this.name = name; + this.lastAlertTimestamp = lastAlertTimestamp; + } + + + @Override + public long getId() { + return id; + } + + public String getName() { + return name; + } + + public String getLastAlertTimestamp() { + return lastAlertTimestamp; + } + + public void setLastAlertTimestamp (String timestamp) { + this.lastAlertTimestamp = timestamp; + } + +} diff --git a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java index 54ae9b2890f..0616939fc27 100644 --- a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java +++ b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java @@ -65,20 +65,23 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn { @Column(name = "vpc_id") private Long vpcId; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public RemoteAccessVpnVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } - public RemoteAccessVpnVO(long accountId, long domainId, Long networkId, long publicIpId, Long vpcId, String localIp, String ipRange, String presharedKey) { + public RemoteAccessVpnVO(long accountId, long domainId, Long networkId, long publicIpId, Long vpcId, String localIp, String ipRange, String presharedKey) { this.accountId = accountId; - this.serverAddressId = publicIpId; + serverAddressId = publicIpId; this.ipRange = ipRange; - this.ipsecPresharedKey = presharedKey; + ipsecPresharedKey = presharedKey; this.localIp = localIp; this.domainId = domainId; this.networkId = networkId; - this.state = State.Added; - this.uuid = UUID.randomUUID().toString(); + state = State.Added; + uuid = UUID.randomUUID().toString(); this.vpcId = vpcId; } @@ -148,4 +151,22 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn { public Long getVpcId() { return vpcId; } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } + + @Override + public Class getEntityType() { + return RemoteAccessVpn.class; + } } diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java index c922855d53d..5bcf361836f 100644 --- a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java +++ b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java @@ -30,6 +30,7 @@ import com.cloud.network.Site2SiteCustomerGateway; import com.cloud.utils.db.Encrypt; import com.cloud.utils.db.GenericDao; + @Entity @Table(name = ("s2s_customer_gateway")) public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway { @@ -92,7 +93,7 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway { this.ikeLifetime = ikeLifetime; this.espLifetime = espLifetime; this.dpd = dpd; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.accountId = accountId; this.domainId = domainId; } @@ -206,4 +207,9 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway { public long getAccountId() { return accountId; } + + @Override + public Class getEntityType() { + return Site2SiteCustomerGateway.class; + } } diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java index 96a4c2d520a..85643fc0437 100644 --- a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java +++ b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java @@ -33,6 +33,7 @@ import org.apache.cloudstack.api.InternalIdentity; import com.cloud.network.Site2SiteVpnConnection; import com.cloud.utils.db.GenericDao; + @Entity @Table(name = ("s2s_vpn_connection")) public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, InternalIdentity { @@ -69,14 +70,17 @@ public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, Interna @Column(name = "passive") private boolean passive; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public Site2SiteVpnConnectionVO() { } public Site2SiteVpnConnectionVO(long accountId, long domainId, long vpnGatewayId, long customerGatewayId, boolean passive) { - this.uuid = UUID.randomUUID().toString(); - this.setVpnGatewayId(vpnGatewayId); - this.setCustomerGatewayId(customerGatewayId); - this.setState(State.Pending); + uuid = UUID.randomUUID().toString(); + setVpnGatewayId(vpnGatewayId); + setCustomerGatewayId(customerGatewayId); + setState(State.Pending); this.accountId = accountId; this.domainId = domainId; this.passive = passive; @@ -155,4 +159,22 @@ public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, Interna public void setPassive(boolean passive) { this.passive = passive; } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } + + @Override + public Class getEntityType() { + return Site2SiteVpnConnection.class; + } } diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java index 3a16bcdf139..260e5fc4c0b 100644 --- a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java +++ b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java @@ -29,6 +29,7 @@ import javax.persistence.Table; import com.cloud.network.Site2SiteVpnGateway; import com.cloud.utils.db.GenericDao; + @Entity @Table(name = ("s2s_vpn_gateway")) public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway { @@ -55,13 +56,16 @@ public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway { @Column(name = GenericDao.REMOVED_COLUMN) private Date removed; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public Site2SiteVpnGatewayVO() { } public Site2SiteVpnGatewayVO(long accountId, long domainId, long addrId, long vpcId) { - this.uuid = UUID.randomUUID().toString(); - this.setAddrId(addrId); - this.setVpcId(vpcId); + uuid = UUID.randomUUID().toString(); + setAddrId(addrId); + setVpcId(vpcId); this.accountId = accountId; this.domainId = domainId; } @@ -112,4 +116,22 @@ public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway { public long getAccountId() { return accountId; } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } + + @Override + public Class getEntityType() { + return Site2SiteVpnGateway.class; + } } diff --git a/engine/schema/src/com/cloud/network/dao/SslCertVO.java b/engine/schema/src/com/cloud/network/dao/SslCertVO.java index 7d73f49daed..2676d611bd7 100644 --- a/engine/schema/src/com/cloud/network/dao/SslCertVO.java +++ b/engine/schema/src/com/cloud/network/dao/SslCertVO.java @@ -61,18 +61,18 @@ public class SslCertVO implements SslCert { String fingerPrint; public SslCertVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public SslCertVO(String cert, String key, String password, String chain, Long accountId, Long domainId, String fingerPrint) { - this.certificate = cert; + certificate = cert; this.key = key; this.chain = chain; this.password = password; this.accountId = accountId; this.domainId = domainId; this.fingerPrint = fingerPrint; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } // Getters @@ -120,4 +120,10 @@ public class SslCertVO implements SslCert { public String getFingerPrint() { return fingerPrint; } + + @Override + public Class getEntityType() { + return SslCert.class; + } + } \ No newline at end of file diff --git a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java index a8aef2c0ef8..169102af8c7 100644 --- a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java +++ b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java @@ -101,6 +101,9 @@ public class FirewallRuleVO implements FirewallRule { @Enumerated(value = EnumType.STRING) TrafficType trafficType; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + // This is a delayed load value. If the value is null, // then this field has not been loaded yet. // Call firewallrules dao to load it. @@ -188,7 +191,7 @@ public class FirewallRuleVO implements FirewallRule { } protected FirewallRuleVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public FirewallRuleVO(String xId, Long ipAddressId, Integer portStart, Integer portEnd, String protocol, long networkId, long accountId, long domainId, @@ -199,13 +202,13 @@ public class FirewallRuleVO implements FirewallRule { } this.accountId = accountId; this.domainId = domainId; - this.sourceIpAddressId = ipAddressId; - this.sourcePortStart = portStart; - this.sourcePortEnd = portEnd; + sourceIpAddressId = ipAddressId; + sourcePortStart = portStart; + sourcePortEnd = portEnd; this.protocol = protocol; this.purpose = purpose; this.networkId = networkId; - this.state = State.Staged; + state = State.Staged; this.icmpCode = icmpCode; this.icmpType = icmpType; this.sourceCidrs = sourceCidrs; @@ -215,8 +218,8 @@ public class FirewallRuleVO implements FirewallRule { } this.related = related; - this.uuid = UUID.randomUUID().toString(); - this.type = FirewallRuleType.User; + uuid = UUID.randomUUID().toString(); + type = FirewallRuleType.User; this.trafficType = trafficType; } @@ -253,7 +256,7 @@ public class FirewallRuleVO implements FirewallRule { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -268,4 +271,19 @@ public class FirewallRuleVO implements FirewallRule { public TrafficType getTrafficType() { return trafficType; } + + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } + + @Override + public Class getEntityType() { + return FirewallRule.class; + } } diff --git a/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java b/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java index df8427c1fbf..4a4c83ae74a 100644 --- a/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java +++ b/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java @@ -49,7 +49,7 @@ public class SecurityGroupVO implements SecurityGroup { private String uuid; public SecurityGroupVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public SecurityGroupVO(String name, String description, long domainId, long accountId) { @@ -57,7 +57,7 @@ public class SecurityGroupVO implements SecurityGroup { this.description = description; this.domainId = domainId; this.accountId = accountId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -87,10 +87,15 @@ public class SecurityGroupVO implements SecurityGroup { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } + + @Override + public Class getEntityType() { + return SecurityGroup.class; + } } diff --git a/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java b/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java index c941055ef8d..90f8349349d 100644 --- a/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java +++ b/engine/schema/src/com/cloud/network/security/dao/VmRulesetLogDaoImpl.java @@ -39,7 +39,7 @@ import com.cloud.utils.db.TransactionLegacy; @Component @Local(value = {VmRulesetLogDao.class}) public class VmRulesetLogDaoImpl extends GenericDaoBase implements VmRulesetLogDao { - protected static Logger s_logger = Logger.getLogger(VmRulesetLogDaoImpl.class); + protected static final Logger s_logger = Logger.getLogger(VmRulesetLogDaoImpl.class); private SearchBuilder VmIdSearch; private String InsertOrUpdateSQl = "INSERT INTO op_vm_ruleset_log (instance_id, created, logsequence) " + " VALUES(?, now(), 1) ON DUPLICATE KEY UPDATE logsequence=logsequence+1"; diff --git a/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java index f45b8c4dd51..8031b001b8a 100644 --- a/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java +++ b/engine/schema/src/com/cloud/network/vpc/NetworkACLItemVO.java @@ -71,7 +71,7 @@ public class NetworkACLItemVO implements NetworkACLItem { @Enumerated(value = EnumType.STRING) TrafficType trafficType; - @Column(name = "cidr") + @Column(name = "cidr", length = 2048) String sourceCidrs; @Column(name = "uuid") @@ -84,21 +84,24 @@ public class NetworkACLItemVO implements NetworkACLItem { @Enumerated(value = EnumType.STRING) Action action; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public NetworkACLItemVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public NetworkACLItemVO(Integer portStart, Integer portEnd, String protocol, long aclId, List sourceCidrs, Integer icmpCode, Integer icmpType, TrafficType trafficType, Action action, int number) { - this.sourcePortStart = portStart; - this.sourcePortEnd = portEnd; + sourcePortStart = portStart; + sourcePortEnd = portEnd; this.protocol = protocol; this.aclId = aclId; - this.state = State.Staged; + state = State.Staged; this.icmpCode = icmpCode; this.icmpType = icmpType; setSourceCidrList(sourceCidrs); - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.trafficType = trafficType; this.action = action; this.number = number; @@ -188,7 +191,7 @@ public class NetworkACLItemVO implements NetworkACLItem { @Override public String getUuid() { - return this.uuid; + return uuid; } @Override @@ -241,4 +244,17 @@ public class NetworkACLItemVO implements NetworkACLItem { public void setAction(Action action) { this.action = action; } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } } diff --git a/engine/schema/src/com/cloud/network/vpc/NetworkACLVO.java b/engine/schema/src/com/cloud/network/vpc/NetworkACLVO.java index 2f813c889ac..b6ed5cbd2cb 100644 --- a/engine/schema/src/com/cloud/network/vpc/NetworkACLVO.java +++ b/engine/schema/src/com/cloud/network/vpc/NetworkACLVO.java @@ -47,6 +47,9 @@ public class NetworkACLVO implements NetworkACL { @Column(name = "description") private String description; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + public NetworkACLVO() { } @@ -82,4 +85,16 @@ public class NetworkACLVO implements NetworkACL { return name; } + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } } diff --git a/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java b/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java index 08e39656c4d..2c2d53edb29 100644 --- a/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java +++ b/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java @@ -64,7 +64,7 @@ public class StaticRouteVO implements StaticRoute { Date created; protected StaticRouteVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } /** @@ -78,11 +78,11 @@ public class StaticRouteVO implements StaticRoute { super(); this.vpcGatewayId = vpcGatewayId; this.cidr = cidr; - this.state = State.Staged; + state = State.Staged; this.vpcId = vpcId; this.accountId = accountId; this.domainId = domainId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -107,7 +107,7 @@ public class StaticRouteVO implements StaticRoute { @Override public String getUuid() { - return this.uuid; + return uuid; } @Override @@ -135,4 +135,9 @@ public class StaticRouteVO implements StaticRoute { buf.append(uuid).append("|").append(cidr).append("|").append(vpcGatewayId).append("]"); return buf.toString(); } + + @Override + public Class getEntityType() { + return StaticRoute.class; + } } \ No newline at end of file diff --git a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java b/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java index 5f156607889..23568b49230 100644 --- a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java +++ b/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java @@ -90,7 +90,7 @@ public class VpcGatewayVO implements VpcGateway { long networkACLId; protected VpcGatewayVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } /** @@ -117,10 +117,10 @@ public class VpcGatewayVO implements VpcGateway { this.broadcastUri = broadcastUri; this.gateway = gateway; this.netmask = netmask; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.accountId = accountId; this.domainId = domainId; - this.state = State.Creating; + state = State.Creating; this.sourceNat = sourceNat; this.networkACLId = networkACLId; @@ -128,7 +128,7 @@ public class VpcGatewayVO implements VpcGateway { @Override public String getUuid() { - return this.uuid; + return uuid; } @Override @@ -204,7 +204,7 @@ public class VpcGatewayVO implements VpcGateway { @Override public boolean getSourceNat() { - return this.sourceNat; + return sourceNat; } public void setNetworkACLId(long networkACLId) { @@ -215,4 +215,9 @@ public class VpcGatewayVO implements VpcGateway { public long getNetworkACLId() { return networkACLId; } + + @Override + public Class getEntityType() { + return VpcGateway.class; + } } diff --git a/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java b/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java index 3a676e6af5e..a7d61b36923 100644 --- a/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java +++ b/engine/schema/src/com/cloud/network/vpc/VpcOfferingVO.java @@ -67,6 +67,12 @@ public class VpcOfferingVO implements VpcOffering { @Column(name = "service_offering_id") Long serviceOfferingId; + @Column(name = "supports_distributed_router") + boolean supportsDistributedRouter=false; + + @Column(name = "supports_region_level_vpc") + boolean offersRegionLevelVPC = false; + public VpcOfferingVO() { this.uuid = UUID.randomUUID().toString(); } @@ -80,9 +86,12 @@ public class VpcOfferingVO implements VpcOffering { this.state = State.Disabled; } - public VpcOfferingVO(String name, String displayText, boolean isDefault, Long serviceOfferingId) { + public VpcOfferingVO(String name, String displayText, boolean isDefault, Long serviceOfferingId, + boolean supportsDistributedRouter, boolean offersRegionLevelVPC) { this(name, displayText, serviceOfferingId); this.isDefault = isDefault; + this.supportsDistributedRouter = supportsDistributedRouter; + this.offersRegionLevelVPC = offersRegionLevelVPC; } @Override @@ -145,4 +154,14 @@ public class VpcOfferingVO implements VpcOffering { public Long getServiceOfferingId() { return serviceOfferingId; } + + @Override + public boolean supportsDistributedRouter() { + return supportsDistributedRouter; + } + + @Override + public boolean offersRegionLevelVPC() { + return offersRegionLevelVPC; + } } diff --git a/engine/schema/src/com/cloud/network/vpc/VpcVO.java b/engine/schema/src/com/cloud/network/vpc/VpcVO.java index 23bcf9353a3..8c124b29c15 100644 --- a/engine/schema/src/com/cloud/network/vpc/VpcVO.java +++ b/engine/schema/src/com/cloud/network/vpc/VpcVO.java @@ -31,6 +31,7 @@ import com.cloud.utils.db.GenericDao; @Entity @Table(name = "vpc") public class VpcVO implements Vpc { + @Id @Column(name = "id") long id; @@ -75,21 +76,33 @@ public class VpcVO implements Vpc { @Column(name = "restart_required") boolean restartRequired = false; + @Column(name = "display", updatable = true, nullable = false) + protected boolean display = true; + + @Column(name="uses_distributed_router") + boolean usesDistributedRouter = false; + + @Column(name = "region_level_vpc") + boolean regionLevelVpc = false; + public VpcVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } - public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr, String networkDomain) { + public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr, + String networkDomain, boolean useDistributedRouter, boolean regionLevelVpc) { this.zoneId = zoneId; this.name = name; this.displayText = displayText; this.accountId = accountId; this.domainId = domainId; this.cidr = cidr; - this.uuid = UUID.randomUUID().toString(); - this.state = State.Enabled; + uuid = UUID.randomUUID().toString(); + state = State.Enabled; this.networkDomain = networkDomain; - this.vpcOfferingId = vpcOffId; + vpcOfferingId = vpcOffId; + this.usesDistributedRouter = useDistributedRouter; + this.regionLevelVpc = regionLevelVpc; } @Override @@ -177,4 +190,33 @@ public class VpcVO implements Vpc { public boolean isRestartRequired() { return restartRequired; } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + @Override + public boolean isRegionLevelVpc() { + return regionLevelVpc; + } + + + public void setDisplay(boolean display) { + this.display = display; + } + + @Override + public boolean isDisplay() { + return display; + } + + @Override + public Class getEntityType() { + return Vpc.class; + } + + @Override + public boolean usesDistributedRouter() { + return usesDistributedRouter; + } } diff --git a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java index bf078074948..c3d849d134c 100755 --- a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java +++ b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java @@ -139,6 +139,9 @@ public class NetworkOfferingVO implements NetworkOffering { @Column(name = "keep_alive_enabled") boolean keepAliveEnabled = false; + @Column(name="supports_streched_l2") + boolean supportsStrechedL2 = false; + @Override public String getDisplayText() { return displayText; @@ -331,7 +334,7 @@ public class NetworkOfferingVO implements NetworkOffering { 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 inline, boolean isPersistent, - boolean associatePublicIP, boolean publicLb, boolean internalLb, boolean egressdefaultpolicy) { + boolean associatePublicIP, boolean publicLb, boolean internalLb, boolean egressdefaultpolicy, boolean supportsStrechedL2) { this(name, displayText, trafficType, @@ -356,6 +359,7 @@ public class NetworkOfferingVO implements NetworkOffering { this.inline = inline; this.eipAssociatePublicIp = associatePublicIP; this.egressdefaultpolicy = egressdefaultpolicy; + this.supportsStrechedL2 = supportsStrechedL2; } public NetworkOfferingVO() { @@ -486,4 +490,9 @@ public class NetworkOfferingVO implements NetworkOffering { public void setPublicLb(boolean publicLb) { this.publicLb = publicLb; } + + @Override + public boolean getSupportsStrechedL2() { + return supportsStrechedL2; + } } diff --git a/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java b/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java index 6136862f25c..9775135beab 100644 --- a/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java +++ b/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java @@ -64,16 +64,16 @@ public class ProjectInvitationVO implements ProjectInvitation { private String uuid; protected ProjectInvitationVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public ProjectInvitationVO(long projectId, Long accountId, Long domainId, String email, String token) { - this.forAccountId = accountId; - this.inDomainId = domainId; + forAccountId = accountId; + inDomainId = domainId; this.projectId = projectId; this.email = email; this.token = token; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -129,7 +129,7 @@ public class ProjectInvitationVO implements ProjectInvitation { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -145,4 +145,9 @@ public class ProjectInvitationVO implements ProjectInvitation { public long getAccountId() { return forAccountId == null ? -1 : forAccountId; } + + @Override + public Class getEntityType() { + return ProjectInvitation.class; + } } diff --git a/engine/schema/src/com/cloud/projects/ProjectVO.java b/engine/schema/src/com/cloud/projects/ProjectVO.java index d49e484dd31..77eed40d7ba 100644 --- a/engine/schema/src/com/cloud/projects/ProjectVO.java +++ b/engine/schema/src/com/cloud/projects/ProjectVO.java @@ -31,6 +31,7 @@ import javax.persistence.Table; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; +import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.GenericDao; @Entity @@ -161,4 +162,8 @@ public class ProjectVO implements Project, Identity, InternalIdentity { this.uuid = uuid; } + @Override + public int hashCode() { + return NumbersUtil.hash(id); + } } diff --git a/engine/schema/src/com/cloud/service/ServiceOfferingDetailsVO.java b/engine/schema/src/com/cloud/service/ServiceOfferingDetailsVO.java index a707955dbcd..8dfe5273b94 100644 --- a/engine/schema/src/com/cloud/service/ServiceOfferingDetailsVO.java +++ b/engine/schema/src/com/cloud/service/ServiceOfferingDetailsVO.java @@ -43,15 +43,16 @@ public class ServiceOfferingDetailsVO implements ResourceDetail { private String value; @Column(name = "display") - boolean display; + private boolean display = true; protected ServiceOfferingDetailsVO() { } - public ServiceOfferingDetailsVO(long serviceOfferingId, String name, String value) { + public ServiceOfferingDetailsVO(long serviceOfferingId, String name, String value, boolean display) { this.resourceId = serviceOfferingId; this.name = name; this.value = value; + this.display = display; } @Override @@ -59,6 +60,10 @@ public class ServiceOfferingDetailsVO implements ResourceDetail { return resourceId; } + public void setResourceId(long serviceOfferingId) { + this.resourceId = serviceOfferingId; + } + @Override public String getName() { return name; diff --git a/engine/schema/src/com/cloud/service/ServiceOfferingVO.java b/engine/schema/src/com/cloud/service/ServiceOfferingVO.java index 3873dd272f4..3be0aaa7745 100755 --- a/engine/schema/src/com/cloud/service/ServiceOfferingVO.java +++ b/engine/schema/src/com/cloud/service/ServiceOfferingVO.java @@ -173,6 +173,7 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering offering.getUseLocalStorage(), offering.getSystemUse(), true, + offering.isCustomizedIops(), offering.getDomainId()); cpu = offering.getCpu(); ramSize = offering.getRamSize(); diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java index 1905d9e41f6..a3ff45ca3ad 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDaoImpl.java @@ -182,7 +182,7 @@ public class ServiceOfferingDaoImpl extends GenericDaoBase resourceDetails = new ArrayList(); for (String key : details.keySet()) { - resourceDetails.add(new ServiceOfferingDetailsVO(serviceOffering.getId(), key, details.get(key))); + resourceDetails.add(new ServiceOfferingDetailsVO(serviceOffering.getId(), key, details.get(key), true)); } detailsDao.saveDetails(resourceDetails); diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java index 59c5e33f955..6e504bce13b 100644 --- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java @@ -29,8 +29,8 @@ import com.cloud.service.ServiceOfferingDetailsVO; public class ServiceOfferingDetailsDaoImpl extends ResourceDetailsDaoBase implements ServiceOfferingDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new ServiceOfferingDetailsVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new ServiceOfferingDetailsVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java index d1a48d20c91..99214b21905 100755 --- a/engine/schema/src/com/cloud/storage/DiskOfferingVO.java +++ b/engine/schema/src/com/cloud/storage/DiskOfferingVO.java @@ -207,7 +207,7 @@ public class DiskOfferingVO implements DiskOffering { } public DiskOfferingVO(long id, String name, String displayText, boolean mirrored, String tags, boolean recreatable, - boolean useLocalStorage, boolean systemUse, boolean customized, Long domainId) { + boolean useLocalStorage, boolean systemUse, boolean customized, boolean customizedIops, Long domainId) { this.id = id; type = Type.Service; this.name = name; @@ -217,6 +217,7 @@ public class DiskOfferingVO implements DiskOffering { this.useLocalStorage = useLocalStorage; this.systemUse = systemUse; this.customized = customized; + this.customizedIops = customizedIops; this.domainId = domainId; uuid = UUID.randomUUID().toString(); state = State.Active; diff --git a/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java b/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java index 8210abf8c3d..1fbc9d7178a 100644 --- a/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java +++ b/engine/schema/src/com/cloud/storage/GuestOSHypervisorVO.java @@ -16,6 +16,9 @@ // under the License. package com.cloud.storage; +import java.util.Date; +import java.util.UUID; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -23,6 +26,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import com.cloud.utils.db.GenericDao; + @Entity @Table(name = "guest_os_hypervisor") public class GuestOSHypervisorVO implements GuestOSHypervisor { @@ -32,7 +37,7 @@ public class GuestOSHypervisorVO implements GuestOSHypervisor { long id; @Column(name = "guest_os_id") - private long guestOsId; + long guestOsId; @Column(name = "guest_os_name") String guestOsName; @@ -40,11 +45,28 @@ public class GuestOSHypervisorVO implements GuestOSHypervisor { @Column(name = "hypervisor_type") String hypervisorType; + @Column(name = "hypervisor_version") + String hypervisorVersion; + + @Column(name = "uuid") + String uuid = UUID.randomUUID().toString(); + + @Column(name = GenericDao.REMOVED_COLUMN) + Date removed; + + @Column(name = GenericDao.CREATED_COLUMN) + Date created; + @Override public long getId() { return id; } + @Override + public String getHypervisorVersion() { + return hypervisorVersion; + } + @Override public String getHypervisorType() { return hypervisorType; @@ -60,4 +82,42 @@ public class GuestOSHypervisorVO implements GuestOSHypervisor { return guestOsId; } + @Override + public String getUuid() { + return uuid; + } + + @Override + public Date getRemoved() { + return removed; + } + + @Override + public Date getCreated() { + return created; + } + + public void setGuestOsId(long guestOsId) { + this.guestOsId = guestOsId; + } + + public void setGuestOsName(String guestOsName) { + this.guestOsName = guestOsName; + } + + public void setHypervisorType(String hypervisorType) { + this.hypervisorType = hypervisorType; + } + + public void setHypervisorVersion(String hypervisorVersion) { + this.hypervisorVersion = hypervisorVersion; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public void setRemoved(Date removed) { + this.removed = removed; + } } diff --git a/engine/schema/src/com/cloud/storage/GuestOSVO.java b/engine/schema/src/com/cloud/storage/GuestOSVO.java index 57b852953a9..a0040beeafe 100644 --- a/engine/schema/src/com/cloud/storage/GuestOSVO.java +++ b/engine/schema/src/com/cloud/storage/GuestOSVO.java @@ -16,6 +16,7 @@ // under the License. package com.cloud.storage; +import java.util.Date; import java.util.UUID; import javax.persistence.Column; @@ -25,6 +26,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import com.cloud.utils.db.GenericDao; + @Entity @Table(name = "guest_os") public class GuestOSVO implements GuestOS { @@ -45,6 +48,12 @@ public class GuestOSVO implements GuestOS { @Column(name = "uuid") String uuid = UUID.randomUUID().toString(); + @Column(name = GenericDao.REMOVED_COLUMN) + private Date removed; + + @Column(name = GenericDao.CREATED_COLUMN) + private Date created; + @Override public long getId() { return id; @@ -79,10 +88,24 @@ public class GuestOSVO implements GuestOS { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } + + @Override + public Date getCreated() { + return created; + } + + public void setRemoved(Date removed) { + this.removed = removed; + } + + @Override + public Date getRemoved() { + return removed; + } } diff --git a/engine/schema/src/com/cloud/storage/SnapshotVO.java b/engine/schema/src/com/cloud/storage/SnapshotVO.java index 85216369c08..dae049f6042 100644 --- a/engine/schema/src/com/cloud/storage/SnapshotVO.java +++ b/engine/schema/src/com/cloud/storage/SnapshotVO.java @@ -93,12 +93,12 @@ public class SnapshotVO implements Snapshot { String uuid; public SnapshotVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType) { - this.dataCenterId = dcId; + dataCenterId = dcId; this.accountId = accountId; this.domainId = domainId; this.volumeId = volumeId; @@ -107,10 +107,10 @@ public class SnapshotVO implements Snapshot { this.snapshotType = snapshotType; this.typeDescription = typeDescription; this.size = size; - this.state = State.Allocated; + state = State.Allocated; this.hypervisorType = hypervisorType; - this.version = "2.2"; - this.uuid = UUID.randomUUID().toString(); + version = "2.2"; + uuid = UUID.randomUUID().toString(); } @Override @@ -229,10 +229,15 @@ public class SnapshotVO implements Snapshot { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } + + @Override + public Class getEntityType() { + return Snapshot.class; + } } diff --git a/engine/schema/src/com/cloud/storage/VMTemplateDetailVO.java b/engine/schema/src/com/cloud/storage/VMTemplateDetailVO.java index 5689e7db5e7..f988abab399 100644 --- a/engine/schema/src/com/cloud/storage/VMTemplateDetailVO.java +++ b/engine/schema/src/com/cloud/storage/VMTemplateDetailVO.java @@ -43,15 +43,16 @@ public class VMTemplateDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public VMTemplateDetailVO() { } - public VMTemplateDetailVO(long templateId, String name, String value) { + public VMTemplateDetailVO(long templateId, String name, String value, boolean display) { this.resourceId = templateId; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/com/cloud/storage/VMTemplateVO.java b/engine/schema/src/com/cloud/storage/VMTemplateVO.java index da9373505c2..9a77cbf873a 100755 --- a/engine/schema/src/com/cloud/storage/VMTemplateVO.java +++ b/engine/schema/src/com/cloud/storage/VMTemplateVO.java @@ -591,7 +591,7 @@ public class VMTemplateVO implements VirtualMachineTemplate { } @Override - public Boolean isDynamicallyScalable() { + public boolean isDynamicallyScalable() { return dynamicallyScalable; } @@ -632,4 +632,8 @@ public class VMTemplateVO implements VirtualMachineTemplate { this.updated = updated; } + @Override + public Class getEntityType() { + return VirtualMachineTemplate.class; + } } diff --git a/engine/schema/src/com/cloud/storage/VolumeDetailVO.java b/engine/schema/src/com/cloud/storage/VolumeDetailVO.java index 598a3505b2b..6723f0b8bc1 100644 --- a/engine/schema/src/com/cloud/storage/VolumeDetailVO.java +++ b/engine/schema/src/com/cloud/storage/VolumeDetailVO.java @@ -43,15 +43,16 @@ public class VolumeDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public VolumeDetailVO() { } - public VolumeDetailVO(long volumeId, String name, String value) { + public VolumeDetailVO(long volumeId, String name, String value, boolean display) { this.resourceId = volumeId; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/com/cloud/storage/VolumeVO.java b/engine/schema/src/com/cloud/storage/VolumeVO.java index 901e07c70ef..9f27c231f0d 100755 --- a/engine/schema/src/com/cloud/storage/VolumeVO.java +++ b/engine/schema/src/com/cloud/storage/VolumeVO.java @@ -164,18 +164,18 @@ public class VolumeVO implements Volume { // Real Constructor public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size, Long minIops, Long maxIops, String iScsiName) { - this.volumeType = type; + volumeType = type; this.name = name; - this.dataCenterId = dcId; + dataCenterId = dcId; this.accountId = accountId; this.domainId = domainId; this.size = size; this.minIops = minIops; this.maxIops = maxIops; - this._iScsiName = iScsiName; + _iScsiName = iScsiName; this.diskOfferingId = diskOfferingId; - this.state = State.Allocated; - this.uuid = UUID.randomUUID().toString(); + state = State.Allocated; + uuid = UUID.randomUUID().toString(); } public VolumeVO(String name, long dcId, Long podId, long accountId, long domainId, Long instanceId, String folder, String path, long size, Long minIops, @@ -189,13 +189,13 @@ public class VolumeVO implements Volume { this.size = size; this.minIops = minIops; this.maxIops = maxIops; - this._iScsiName = iScsiName; + _iScsiName = iScsiName; this.podId = podId; - this.dataCenterId = dcId; - this.volumeType = vType; - this.state = Volume.State.Allocated; - this.recreatable = false; - this.uuid = UUID.randomUUID().toString(); + dataCenterId = dcId; + volumeType = vType; + state = Volume.State.Allocated; + recreatable = false; + uuid = UUID.randomUUID().toString(); } public VolumeVO(String name, long dcId, long podId, long accountId, long domainId, Long instanceId, String folder, String path, long size, Volume.Type vType) { @@ -206,15 +206,15 @@ public class VolumeVO implements Volume { this.folder = folder; this.path = path; this.size = size; - this.minIops = null; - this.maxIops = null; - this._iScsiName = null; + minIops = null; + maxIops = null; + _iScsiName = null; this.podId = podId; - this.dataCenterId = dcId; - this.volumeType = vType; - this.state = Volume.State.Allocated; - this.recreatable = false; - this.uuid = UUID.randomUUID().toString(); + dataCenterId = dcId; + volumeType = vType; + state = Volume.State.Allocated; + recreatable = false; + uuid = UUID.randomUUID().toString(); } // Copy Constructor @@ -232,34 +232,34 @@ public class VolumeVO implements Volume { that.getMaxIops(), that.get_iScsiName(), that.getVolumeType()); - this.recreatable = that.isRecreatable(); - this.state = that.getState(); - this.size = that.getSize(); - this.minIops = that.getMinIops(); - this.maxIops = that.getMaxIops(); - this._iScsiName = that.get_iScsiName(); - this.diskOfferingId = that.getDiskOfferingId(); - this.poolId = that.getPoolId(); - this.attached = that.getAttached(); - this.chainInfo = that.getChainInfo(); - this.templateId = that.getTemplateId(); - this.deviceId = that.getDeviceId(); - this.format = that.getFormat(); - this.uuid = UUID.randomUUID().toString(); + recreatable = that.isRecreatable(); + state = that.getState(); + size = that.getSize(); + minIops = that.getMinIops(); + maxIops = that.getMaxIops(); + _iScsiName = that.get_iScsiName(); + diskOfferingId = that.getDiskOfferingId(); + poolId = that.getPoolId(); + attached = that.getAttached(); + chainInfo = that.getChainInfo(); + templateId = that.getTemplateId(); + deviceId = that.getDeviceId(); + format = that.getFormat(); + uuid = UUID.randomUUID().toString(); } @Override public long getUpdatedCount() { - return this.updatedCount; + return updatedCount; } @Override public void incrUpdatedCount() { - this.updatedCount++; + updatedCount++; } public void decrUpdatedCount() { - this.updatedCount--; + updatedCount--; } @Override @@ -481,7 +481,7 @@ public class VolumeVO implements Volume { @Override public Date getAttached() { - return this.attached; + return attached; } public void setAttached(Date attached) { @@ -490,7 +490,7 @@ public class VolumeVO implements Volume { @Override public String getChainInfo() { - return this.chainInfo; + return chainInfo; } public void setChainInfo(String chainInfo) { @@ -498,11 +498,11 @@ public class VolumeVO implements Volume { } public Long getLastPoolId() { - return this.lastPoolId; + return lastPoolId; } public void setLastPoolId(Long poolId) { - this.lastPoolId = poolId; + lastPoolId = poolId; } @Override @@ -521,17 +521,17 @@ public class VolumeVO implements Volume { @Override public String getReservationId() { - return this.reservationId; + return reservationId; } @Override public void setReservationId(String reserv) { - this.reservationId = reserv; + reservationId = reserv; } @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -540,13 +540,14 @@ public class VolumeVO implements Volume { @Override public String get_iScsiName() { - return this._iScsiName; + return _iScsiName; } public void set_iScsiName(String iScsiName) { - this._iScsiName = iScsiName; + _iScsiName = iScsiName; } + @Override public boolean isDisplayVolume() { return displayVolume; } @@ -570,11 +571,11 @@ public class VolumeVO implements Volume { @Override public Long getVmSnapshotChainSize() { - return this.vmSnapshotChainSize; + return vmSnapshotChainSize; } public Long getIsoId() { - return this.isoId; + return isoId; } public void setIsoId(Long isoId) { @@ -594,5 +595,11 @@ public class VolumeVO implements Volume { @Override public Integer getHypervisorSnapshotReserve() { return hypervisorSnapshotReserve; + + } + + @Override + public Class getEntityType() { + return Volume.class; } } diff --git a/engine/schema/src/com/cloud/storage/dao/GuestOSHypervisorDao.java b/engine/schema/src/com/cloud/storage/dao/GuestOSHypervisorDao.java index 651cfb56700..5b6e7198f0d 100644 --- a/engine/schema/src/com/cloud/storage/dao/GuestOSHypervisorDao.java +++ b/engine/schema/src/com/cloud/storage/dao/GuestOSHypervisorDao.java @@ -24,4 +24,7 @@ public interface GuestOSHypervisorDao extends GenericDao implements GuestOSHypervisorDao { protected final SearchBuilder guestOsSearch; + protected final SearchBuilder mappingSearch; protected GuestOSHypervisorDaoImpl() { guestOsSearch = createSearchBuilder(); guestOsSearch.and("guest_os_id", guestOsSearch.entity().getGuestOsId(), SearchCriteria.Op.EQ); guestOsSearch.done(); + + mappingSearch = createSearchBuilder(); + mappingSearch.and("guest_os_id", mappingSearch.entity().getGuestOsId(), SearchCriteria.Op.EQ); + mappingSearch.and("hypervisor_type", mappingSearch.entity().getHypervisorType(), SearchCriteria.Op.EQ); + mappingSearch.and("hypervisor_version", mappingSearch.entity().getHypervisorVersion(), SearchCriteria.Op.EQ); + mappingSearch.done(); } @Override @@ -46,4 +55,22 @@ public class GuestOSHypervisorDaoImpl extends GenericDaoBase sc = mappingSearch.create(); + sc.setParameters("guest_os_id", guestOsId); + sc.setParameters("hypervisor_type", hypervisorType); + sc.setParameters("hypervisor_version", hypervisorVersion); + return findOneBy(sc); + } + + @Override + public boolean removeGuestOsMapping(Long id) { + GuestOSHypervisorVO guestOsHypervisor = findById(id); + createForUpdate(id); + guestOsHypervisor.setRemoved(new Date()); + update(id, guestOsHypervisor); + return super.remove(id); + } + } diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/SnapshotDetailsDaoImpl.java index f8d3813d64d..e4ae22cd021 100644 --- a/engine/schema/src/com/cloud/storage/dao/SnapshotDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/SnapshotDetailsDaoImpl.java @@ -22,7 +22,7 @@ import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase; public class SnapshotDetailsDaoImpl extends ResourceDetailsDaoBase implements SnapshotDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new SnapshotDetailsVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new SnapshotDetailsVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/com/cloud/storage/dao/SnapshotDetailsVO.java b/engine/schema/src/com/cloud/storage/dao/SnapshotDetailsVO.java index 35a724435e7..f217501a302 100644 --- a/engine/schema/src/com/cloud/storage/dao/SnapshotDetailsVO.java +++ b/engine/schema/src/com/cloud/storage/dao/SnapshotDetailsVO.java @@ -44,14 +44,17 @@ public class SnapshotDetailsVO implements ResourceDetail { @Column(name = "value") String value; - public SnapshotDetailsVO() { + @Column(name = "display") + private boolean display = true; + public SnapshotDetailsVO() { } - public SnapshotDetailsVO(Long resourceId, String name, String value) { + public SnapshotDetailsVO(Long resourceId, String name, String value, boolean display) { this.resourceId = resourceId; this.name = name; this.value = value; + this.display = display; } @Override @@ -71,7 +74,7 @@ public class SnapshotDetailsVO implements ResourceDetail { @Override public boolean isDisplay() { - return false; + return display; } @Override diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java index 9d1214342f5..de7141ffb06 100644 --- a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java @@ -43,7 +43,7 @@ public class StoragePoolDetailsDaoImpl extends ResourceDetailsDaoBase implem sb.and("format", sb.entity().getFormat(), SearchCriteria.Op.EQ); sb.and("type", sb.entity().getTemplateType(), SearchCriteria.Op.EQ); sb.and("bootable", sb.entity().isBootable(), SearchCriteria.Op.EQ); - sb.and("removed", sb.entity().getRemoved(), SearchCriteria.Op.EQ); + sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ); SearchBuilder tagSearch = _tagsDao.createSearchBuilder(); for (int count = 0; count < tags.size(); count++) { @@ -170,7 +170,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem } if (!listRemoved) { - sc.setParameters("removed", (Object)null); + sc.setParameters("state", VirtualMachineTemplate.State.Active); } if (tags != null && !tags.isEmpty()) { @@ -197,7 +197,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem sc.setParameters("type", TemplateType.USER.toString()); if (!listRemoved) { - sc.setParameters("removed", (Object)null); + sc.setParameters("state", VirtualMachineTemplate.State.Active); } return listBy(sc); @@ -217,7 +217,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem String sql = "select * from template_host_ref as thr INNER JOIN vm_template as t ON t.id=thr.template_id " - + "where thr.host_id=? and t.public=0 and t.featured=0 and t.type='USER' and t.removed is NULL"; + + "where thr.host_id=? and t.public=0 and t.featured=0 and t.type='USER' and t.state='Active'"; List l = new ArrayList(); @@ -265,6 +265,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem public List listByAccountId(long accountId) { SearchCriteria sc = AccountIdSearch.create(); sc.setParameters("accountId", accountId); + sc.setParameters("state", VirtualMachineTemplate.State.Active); return listBy(sc); } @@ -312,12 +313,12 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem PublicIsoSearch.and("format", PublicIsoSearch.entity().getFormat(), SearchCriteria.Op.EQ); PublicIsoSearch.and("type", PublicIsoSearch.entity().getTemplateType(), SearchCriteria.Op.EQ); PublicIsoSearch.and("bootable", PublicIsoSearch.entity().isBootable(), SearchCriteria.Op.EQ); - PublicIsoSearch.and("removed", PublicIsoSearch.entity().getRemoved(), SearchCriteria.Op.EQ); + PublicIsoSearch.and("state", PublicIsoSearch.entity().getState(), SearchCriteria.Op.EQ); UserIsoSearch = createSearchBuilder(); UserIsoSearch.and("format", UserIsoSearch.entity().getFormat(), SearchCriteria.Op.EQ); UserIsoSearch.and("type", UserIsoSearch.entity().getTemplateType(), SearchCriteria.Op.EQ); - UserIsoSearch.and("removed", UserIsoSearch.entity().getRemoved(), SearchCriteria.Op.EQ); + UserIsoSearch.and("state", UserIsoSearch.entity().getState(), SearchCriteria.Op.EQ); tmpltTypeHyperSearch = createSearchBuilder(); tmpltTypeHyperSearch.and("templateType", tmpltTypeHyperSearch.entity().getTemplateType(), SearchCriteria.Op.EQ); @@ -332,7 +333,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem tmpltTypeHyperSearch.done(); readySystemTemplateSearch = createSearchBuilder(); - readySystemTemplateSearch.and("removed", readySystemTemplateSearch.entity().getRemoved(), SearchCriteria.Op.NULL); + readySystemTemplateSearch.and("state", readySystemTemplateSearch.entity().getState(), SearchCriteria.Op.EQ); readySystemTemplateSearch.and("templateType", readySystemTemplateSearch.entity().getTemplateType(), SearchCriteria.Op.EQ); SearchBuilder templateDownloadSearch = _templateDataStoreDao.createSearchBuilder(); templateDownloadSearch.and("downloadState", templateDownloadSearch.entity().getDownloadState(), SearchCriteria.Op.EQ); @@ -355,13 +356,13 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem tmpltTypeHyperSearch2.and("templateName", tmpltTypeHyperSearch2.entity().getName(), SearchCriteria.Op.EQ); tmpltTypeSearch = createSearchBuilder(); - tmpltTypeSearch.and("removed", tmpltTypeSearch.entity().getRemoved(), SearchCriteria.Op.NULL); + tmpltTypeSearch.and("state", tmpltTypeSearch.entity().getState(), SearchCriteria.Op.EQ); tmpltTypeSearch.and("templateType", tmpltTypeSearch.entity().getTemplateType(), SearchCriteria.Op.EQ); AccountIdSearch = createSearchBuilder(); AccountIdSearch.and("accountId", AccountIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ); AccountIdSearch.and("publicTemplate", AccountIdSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ); - AccountIdSearch.and("removed", AccountIdSearch.entity().getRemoved(), SearchCriteria.Op.NULL); // only list not removed templates for this account + AccountIdSearch.and("state", AccountIdSearch.entity().getState(), SearchCriteria.Op.EQ); // only list not removed templates for this account AccountIdSearch.done(); SearchBuilder tmpltZoneSearch = _templateZoneDao.createSearchBuilder(); @@ -369,7 +370,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem tmpltZoneSearch.and("zoneId", tmpltZoneSearch.entity().getZoneId(), SearchCriteria.Op.EQ); TmpltsInZoneSearch = createSearchBuilder(); - TmpltsInZoneSearch.and("removed", TmpltsInZoneSearch.entity().getRemoved(), SearchCriteria.Op.NULL); + TmpltsInZoneSearch.and("state", TmpltsInZoneSearch.entity().getState(), SearchCriteria.Op.EQ); TmpltsInZoneSearch.and().op("avoidtype", TmpltsInZoneSearch.entity().getTemplateType(), SearchCriteria.Op.NEQ); TmpltsInZoneSearch.or("templateType", TmpltsInZoneSearch.entity().getTemplateType(), SearchCriteria.Op.NULL); TmpltsInZoneSearch.cp(); @@ -378,12 +379,12 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem TmpltsInZoneSearch.done(); ActiveTmpltSearch = createSearchBuilder(); - ActiveTmpltSearch.and("removed", ActiveTmpltSearch.entity().getRemoved(), SearchCriteria.Op.NULL); + ActiveTmpltSearch.and("state", ActiveTmpltSearch.entity().getState(), SearchCriteria.Op.EQ); CountTemplatesByAccount = createSearchBuilder(Long.class); CountTemplatesByAccount.select(null, Func.COUNT, null); CountTemplatesByAccount.and("account", CountTemplatesByAccount.entity().getAccountId(), SearchCriteria.Op.EQ); - CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NULL); + CountTemplatesByAccount.and("state", CountTemplatesByAccount.entity().getState(), SearchCriteria.Op.EQ); CountTemplatesByAccount.done(); // updateStateSearch = this.createSearchBuilder(); @@ -414,7 +415,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem } List details = new ArrayList(); for (String key : detailsStr.keySet()) { - VMTemplateDetailVO detail = new VMTemplateDetailVO(tmpl.getId(), key, detailsStr.get(key)); + VMTemplateDetailVO detail = new VMTemplateDetailVO(tmpl.getId(), key, detailsStr.get(key), true); details.add(detail); } @@ -750,7 +751,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem if (tmplt.getDetails() != null) { List details = new ArrayList(); for (String key : tmplt.getDetails().keySet()) { - details.add(new VMTemplateDetailVO(tmplt.getId(), key, tmplt.getDetails().get(key))); + details.add(new VMTemplateDetailVO(tmplt.getId(), key, tmplt.getDetails().get(key), true)); } _templateDetailsDao.saveDetails(details); } @@ -774,6 +775,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem public List listAllInZone(long dataCenterId) { SearchCriteria sc = TmpltsInZoneSearch.create(); sc.setParameters("avoidtype", TemplateType.PERHOST.toString()); + sc.setParameters("state", VirtualMachineTemplate.State.Active); sc.setJoinParameters("tmpltzone", "zoneId", dataCenterId); return listBy(sc); } @@ -781,6 +783,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem @Override public List listAllActive() { SearchCriteria sc = ActiveTmpltSearch.create(); + sc.setParameters("state", VirtualMachineTemplate.State.Active.toString()); return listBy(sc); } @@ -788,6 +791,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem public List listDefaultBuiltinTemplates() { SearchCriteria sc = tmpltTypeSearch.create(); sc.setParameters("templateType", Storage.TemplateType.BUILTIN); + sc.setParameters("state", VirtualMachineTemplate.State.Active); return listBy(sc); } @@ -813,6 +817,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem public VMTemplateVO findSystemVMReadyTemplate(long zoneId, HypervisorType hypervisorType) { SearchCriteria sc = readySystemTemplateSearch.create(); sc.setParameters("templateType", Storage.TemplateType.SYSTEM); + sc.setParameters("state", VirtualMachineTemplate.State.Active); sc.setJoinParameters("tmplHyper", "type", Host.Type.Routing); sc.setJoinParameters("tmplHyper", "zoneId", zoneId); sc.setJoinParameters("vmTemplateJoinTemplateStoreRef", "downloadState", VMTemplateStorageResourceAssoc.Status.DOWNLOADED); @@ -873,6 +878,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase implem public Long countTemplatesForAccount(long accountId) { SearchCriteria sc = CountTemplatesByAccount.create(); sc.setParameters("account", accountId); + sc.setParameters("state", VirtualMachineTemplate.State.Active.toString()); return customSearch(sc, null).get(0); } diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java index c1619be8661..456cdc66433 100644 --- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java @@ -29,7 +29,7 @@ import com.cloud.storage.VMTemplateDetailVO; public class VMTemplateDetailsDaoImpl extends ResourceDetailsDaoBase implements VMTemplateDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new VMTemplateDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new VMTemplateDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java index 8dc0328a5ea..da0a5de2d17 100755 --- a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java +++ b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java @@ -105,4 +105,12 @@ public interface VolumeDao extends GenericDao, StateDao implements Vol volume.setDeviceId(deviceId); volume.setUpdated(new Date()); volume.setAttached(new Date()); + if (deviceId == 0L) { + volume.setVolumeType(Type.ROOT); + } update(volumeId, volume); } @@ -235,6 +238,9 @@ public class VolumeDaoImpl extends GenericDaoBase implements Vol volume.setDeviceId(null); volume.setUpdated(new Date()); volume.setAttached(null); + if (findById(volumeId).getVolumeType() == Type.ROOT) { + volume.setVolumeType(Type.DATADISK); + } update(volumeId, volume); } @@ -579,6 +585,26 @@ public class VolumeDaoImpl extends GenericDaoBase implements Vol return result; } + @Override + @DB + public boolean updateUuid(long srcVolId, long destVolId) { + TransactionLegacy txn = TransactionLegacy.currentTxn(); + txn.start(); + try { + VolumeVO srcVol = findById(srcVolId); + VolumeVO destVol = findById(destVolId); + String uuid = srcVol.getUuid(); + srcVol.setUuid(null); + destVol.setUuid(uuid); + update(srcVolId, srcVol); + update(destVolId, destVol); + } catch (Exception e) { + throw new CloudRuntimeException("Unable to persist the sequence number for this host"); + } + txn.commit(); + return true; + } + @Override public ScopeType getVolumeStoragePoolScope(long volumeId) { // finding the storage scope where the volume is present diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java index d045b9b4b29..15c020dacb5 100644 --- a/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java @@ -29,8 +29,8 @@ import com.cloud.storage.VolumeDetailVO; public class VolumeDetailsDaoImpl extends ResourceDetailsDaoBase implements VolumeDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new VolumeDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new VolumeDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/com/cloud/tags/ResourceTagVO.java b/engine/schema/src/com/cloud/tags/ResourceTagVO.java index ca790bd18f3..eadddd1e31e 100644 --- a/engine/schema/src/com/cloud/tags/ResourceTagVO.java +++ b/engine/schema/src/com/cloud/tags/ResourceTagVO.java @@ -29,6 +29,7 @@ import javax.persistence.Table; import com.cloud.server.ResourceTag; + @Entity @Table(name = "resource_tags") public class ResourceTagVO implements ResourceTag { @@ -67,7 +68,7 @@ public class ResourceTagVO implements ResourceTag { String customer; protected ResourceTagVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } /** @@ -88,7 +89,7 @@ public class ResourceTagVO implements ResourceTag { this.accountId = accountId; this.resourceId = resourceId; this.resourceType = resourceType; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.customer = customer; this.resourceUuid = resourceUuid; } @@ -161,4 +162,9 @@ public class ResourceTagVO implements ResourceTag { public String getResourceUuid() { return resourceUuid; } + + @Override + public Class getEntityType() { + return ResourceTag.class; + } } diff --git a/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java b/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java index 0761c9fe61c..f508df2dd5c 100755 --- a/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -66,6 +66,7 @@ import com.cloud.upgrade.dao.Upgrade410to420; import com.cloud.upgrade.dao.Upgrade420to421; import com.cloud.upgrade.dao.Upgrade421to430; import com.cloud.upgrade.dao.Upgrade430to440; +import com.cloud.upgrade.dao.Upgrade440to450; import com.cloud.upgrade.dao.UpgradeSnapshot217to224; import com.cloud.upgrade.dao.UpgradeSnapshot223to224; import com.cloud.upgrade.dao.VersionDao; @@ -91,149 +92,163 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { _dao = new VersionDaoImpl(); _upgradeMap.put("2.1.7", new DbUpgrade[] {new Upgrade217to218(), new Upgrade218to22(), new Upgrade221to222(), - new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade224to225(), new Upgrade225to226(), - new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), - new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), - new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade224to225(), new Upgrade225to226(), + new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), + new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), + new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), + new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.1.8", new DbUpgrade[] {new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(), - new Upgrade222to224(), new Upgrade218to224DomainVlans(), new Upgrade224to225(), new Upgrade225to226(), - new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), - new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), - new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade222to224(), new Upgrade218to224DomainVlans(), new Upgrade224to225(), new Upgrade225to226(), + new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), + new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), + new Upgrade421to430(), new Upgrade430to440(), + new Upgrade440to450()}); _upgradeMap.put("2.1.9", new DbUpgrade[] {new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(), - new Upgrade222to224(), new Upgrade218to224DomainVlans(), new Upgrade224to225(), new Upgrade225to226(), - new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), - new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), - new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade222to224(), new Upgrade218to224DomainVlans(), new Upgrade224to225(), new Upgrade225to226(), + new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), + new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), + new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), + new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), + new Upgrade440to450()}); _upgradeMap.put("2.2.1", new DbUpgrade[] {new Upgrade221to222(), new UpgradeSnapshot223to224(), new Upgrade222to224(), - new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), - new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), - new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), - new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), + new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), + new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), + new Upgrade410to420(), + new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.2", new DbUpgrade[] {new Upgrade222to224(), new UpgradeSnapshot223to224(), new Upgrade224to225(), - new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), - new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), - new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), + new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), + new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.3", new DbUpgrade[] {new Upgrade222to224(), new UpgradeSnapshot223to224(), new Upgrade224to225(), - new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), - new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), - new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), + new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), + new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.4", new DbUpgrade[] {new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), - new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), - new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), - new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), + new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), + new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), + new Upgrade440to450()}); _upgradeMap.put("2.2.5", new DbUpgrade[] {new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), - new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), - new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), - new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), + new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), + new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.6", new DbUpgrade[] {new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), - new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), - new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), + new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.7", new DbUpgrade[] {new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), - new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), - new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), - new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), + new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), + new Upgrade410to420(), + new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.8", new DbUpgrade[] {new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), - new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30() - , new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), - new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade2211to2212(), new Upgrade2212to2213(), + new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), + new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.9", new DbUpgrade[] {new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), - new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), - new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), + new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), + new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.10", new DbUpgrade[] {new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), - new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), - new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), + new Upgrade410to420(), + new Upgrade420to421(), new Upgrade421to430(), + new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.10", new DbUpgrade[] {new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), - new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), + new Upgrade421to430(), + new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.12", new DbUpgrade[] {new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), - new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), - new Upgrade430to440()}); + new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), + new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.13", new DbUpgrade[] {new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), - new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade301to302(), new Upgrade302to40(), + new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.14", new DbUpgrade[] {new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), - new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade302to40(), new Upgrade40to41(), + new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.13", new DbUpgrade[] {new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), - new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430()}); + new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade440to450()}); _upgradeMap.put("2.2.14", new DbUpgrade[] {new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), - new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430()}); + new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade440to450()}); _upgradeMap.put("3.0.0", new DbUpgrade[] {new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("3.0.1", new DbUpgrade[] {new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), - new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("3.0.2", new DbUpgrade[] {new Upgrade302to40(), new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), - new Upgrade430to440()}); + new Upgrade430to440(), new Upgrade440to450()}); - _upgradeMap.put("4.0.0", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + _upgradeMap.put("4.0.0", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), + new Upgrade440to450()}); - _upgradeMap.put("4.0.1", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + _upgradeMap.put("4.0.1", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), + new Upgrade440to450()}); - _upgradeMap.put("4.0.2", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + _upgradeMap.put("4.0.2", new DbUpgrade[] {new Upgrade40to41(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), + new Upgrade440to450()}); - _upgradeMap.put("4.1.0", new DbUpgrade[] {new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + _upgradeMap.put("4.1.0", new DbUpgrade[] {new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); - _upgradeMap.put("4.1.1", new DbUpgrade[] {new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + _upgradeMap.put("4.1.1", new DbUpgrade[] {new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); - _upgradeMap.put("4.2.0", new DbUpgrade[] {new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + _upgradeMap.put("4.2.0", new DbUpgrade[] {new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); - _upgradeMap.put("4.2.1", new DbUpgrade[] {new Upgrade421to430(), new Upgrade430to440()}); + _upgradeMap.put("4.2.1", new DbUpgrade[] {new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); - _upgradeMap.put("4.3.0", new DbUpgrade[] {new Upgrade430to440()}); + _upgradeMap.put("4.3.0", new DbUpgrade[] {new Upgrade430to440(), new Upgrade440to450()}); //CP Upgrades _upgradeMap.put("3.0.3", new DbUpgrade[] {new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), - new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("3.0.4", new DbUpgrade[] {new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("3.0.5", new DbUpgrade[] {new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to421(), - new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade421to430(), new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("3.0.6", new DbUpgrade[] {new Upgrade306to307(), new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), - new Upgrade430to440()}); + new Upgrade430to440(), new Upgrade440to450()}); - _upgradeMap.put("3.0.7", new DbUpgrade[] {new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + _upgradeMap.put("3.0.7", new DbUpgrade[] {new Upgrade307to410(), new Upgrade410to420(), new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440(), + new Upgrade440to450()}); _upgradeMap.put("2.2.15", new DbUpgrade[] {new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), - new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), - new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), + new Upgrade410to420(), + new Upgrade420to421(), new Upgrade421to430(), + new Upgrade430to440(), new Upgrade440to450()}); _upgradeMap.put("2.2.16", new DbUpgrade[] {new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), - new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), - new Upgrade410to420(), - new Upgrade420to421(), new Upgrade421to430(), new Upgrade430to440()}); + new Upgrade302to303(), new Upgrade303to304(), new Upgrade304to305(), new Upgrade305to306(), new Upgrade306to307(), new Upgrade307to410(), + new Upgrade410to420(), + new Upgrade420to421(), new Upgrade421to430(), + new Upgrade430to440(), new Upgrade440to450()}); } protected void runScript(Connection conn, File file) { @@ -267,9 +282,9 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { if (Version.compare(trimmedCurrentVersion, upgrades[upgrades.length - 1].getUpgradedVersion()) != 0) { s_logger.error("The end upgrade version is actually at " + upgrades[upgrades.length - 1].getUpgradedVersion() + - " but our management server code version is at " + currentVersion); + " but our management server code version is at " + currentVersion); throw new CloudRuntimeException("The end upgrade version is actually at " + upgrades[upgrades.length - 1].getUpgradedVersion() + - " but our management server code version is at " + currentVersion); + " but our management server code version is at " + currentVersion); } boolean supportsRollingUpgrade = true; @@ -281,15 +296,15 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { } if (!supportsRollingUpgrade && false) { // FIXME: Needs to detect if there are management servers running - // ClusterManagerImpl.arePeersRunning(null)) { + // ClusterManagerImpl.arePeersRunning(null)) { s_logger.error("Unable to run upgrade because the upgrade sequence does not support rolling update and there are other management server nodes running"); throw new CloudRuntimeException( - "Unable to run upgrade because the upgrade sequence does not support rolling update and there are other management server nodes running"); + "Unable to run upgrade because the upgrade sequence does not support rolling update and there are other management server nodes running"); } for (DbUpgrade upgrade : upgrades) { s_logger.debug("Running upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + - upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion()); + upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion()); TransactionLegacy txn = TransactionLegacy.open("Upgrade"); txn.start(); try { @@ -341,7 +356,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { } if (true) { // FIXME Needs to detect if management servers are running - // !ClusterManagerImpl.arePeersRunning(trimmedCurrentVersion)) { + // !ClusterManagerImpl.arePeersRunning(trimmedCurrentVersion)) { s_logger.info("Cleaning upgrades because all management server are now at the same version"); TreeMap> upgradedVersions = new TreeMap>(); @@ -365,7 +380,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { if (version != null) { for (DbUpgrade upgrade : versionUpgrades) { s_logger.info("Cleanup upgrade " + upgrade.getClass().getSimpleName() + " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + - upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion()); + upgrade.getUpgradableVersionRange()[1] + " to " + upgrade.getUpgradedVersion()); txn.start(); diff --git a/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java b/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java new file mode 100644 index 00000000000..836a5376865 --- /dev/null +++ b/engine/schema/src/com/cloud/upgrade/dao/DatabaseAccessObject.java @@ -0,0 +1,99 @@ +// 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.upgrade.dao; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.apache.log4j.Logger; + +public class DatabaseAccessObject { + + private static Logger s_logger = Logger.getLogger(DatabaseAccessObject.class); + + public void dropKey(Connection conn, String tableName, String key, boolean isForeignKey) { + PreparedStatement pstmt = null; + try { + if (isForeignKey) { + pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP FOREIGN KEY " + key); + } else { + pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP KEY " + key); + } + pstmt.executeUpdate(); + s_logger.debug("Key " + key + " is dropped successfully from the table " + tableName); + } catch (SQLException e) { + s_logger.warn("Ignored SQL Exception when trying to drop " + (isForeignKey ? "foreign " : "") + "key " + key + " on table " + tableName, e); + } finally { + closePreparedStatement(pstmt, "Ignored SQL Exception when trying to close PreparedStatement atfer dropping " + (isForeignKey ? "foreign " : "") + "key " + key + + " on table " + tableName); + } + } + + public void dropPrimaryKey(Connection conn, String tableName) { + PreparedStatement pstmt = null; + try { + pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP PRIMARY KEY "); + pstmt.executeUpdate(); + s_logger.debug("Primary key is dropped successfully from the table " + tableName); + } catch (SQLException e) { + s_logger.warn("Ignored SQL Exception when trying to drop primary key on table " + tableName, e); + } finally { + closePreparedStatement(pstmt, "Ignored SQL Exception when trying to close PreparedStatement atfer dropping primary key on table " + tableName); + } + } + + public void dropColumn(Connection conn, String tableName, String columnName) { + PreparedStatement pstmt = null; + try { + pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP COLUMN " + columnName); + pstmt.executeUpdate(); + s_logger.debug("Column " + columnName + " is dropped successfully from the table " + tableName); + } catch (SQLException e) { + s_logger.warn("Unable to drop columns using query " + pstmt + " due to exception", e); + } finally { + closePreparedStatement(pstmt, "Ignored SQL Exception when trying to close PreparedStatement after dropping column " + columnName + " on table " + tableName); + } + } + + public boolean columnExists(Connection conn, String tableName, String columnName) { + boolean columnExists = false; + PreparedStatement pstmt = null; + try { + pstmt = conn.prepareStatement("SELECT " + columnName + " FROM " + tableName); + pstmt.executeQuery(); + columnExists = true; + } catch (SQLException e) { + s_logger.warn("Field " + columnName + " doesn't exist in " + tableName, e); + } finally { + closePreparedStatement(pstmt, "Ignored SQL Exception when trying to close PreparedStatement atfer checking if column " + columnName + " existed on table " + tableName); + } + + return columnExists; + } + + protected static void closePreparedStatement(PreparedStatement pstmt, String errorMessage) { + try { + if (pstmt != null) { + pstmt.close(); + } + } catch (SQLException e) { + s_logger.warn(errorMessage, e); + } + } + +} diff --git a/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java b/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java index af23b8784a9..38ca5c9c272 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java +++ b/engine/schema/src/com/cloud/upgrade/dao/DbUpgradeUtils.java @@ -17,88 +17,28 @@ package com.cloud.upgrade.dao; import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; import java.util.List; -import org.apache.log4j.Logger; - -import com.cloud.utils.exception.CloudRuntimeException; - public class DbUpgradeUtils { - final static Logger s_logger = Logger.getLogger(DbUpgradeUtils.class); + + private static DatabaseAccessObject dao = new DatabaseAccessObject(); public static void dropKeysIfExist(Connection conn, String tableName, List keys, boolean isForeignKey) { for (String key : keys) { - PreparedStatement pstmt = null; - try { - if (isForeignKey) { - pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP FOREIGN KEY " + key); - } else { - pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP KEY " + key); - } - pstmt.executeUpdate(); - s_logger.debug("Key " + key + " is dropped successfully from the table " + tableName); - } catch (SQLException e) { - // do nothing here - - continue; - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } - } + dao.dropKey(conn, tableName, key, isForeignKey); } } public static void dropPrimaryKeyIfExists(Connection conn, String tableName) { - PreparedStatement pstmt = null; - try { - pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP PRIMARY KEY "); - pstmt.executeUpdate(); - s_logger.debug("Primary key is dropped successfully from the table " + tableName); - } catch (SQLException e) { - // do nothing here - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { - } - } + dao.dropPrimaryKey(conn, tableName); } public static void dropTableColumnsIfExist(Connection conn, String tableName, List columns) { - PreparedStatement pstmt = null; - try { - for (String column : columns) { - try { - pstmt = conn.prepareStatement("SELECT " + column + " FROM " + tableName); - pstmt.executeQuery(); - } catch (SQLException e) { - // if there is an exception, it means that field doesn't exist, so do nothing here - s_logger.trace("Field " + column + " doesn't exist in " + tableName); - continue; - } - - pstmt = conn.prepareStatement("ALTER TABLE " + tableName + " DROP COLUMN " + column); - pstmt.executeUpdate(); - s_logger.debug("Column " + column + " is dropped successfully from the table " + tableName); - } - } catch (SQLException e) { - s_logger.warn("Unable to drop columns using query " + pstmt + " due to exception", e); - throw new CloudRuntimeException("Unable to drop columns due to ", e); - } finally { - try { - if (pstmt != null) { - pstmt.close(); - } - } catch (SQLException e) { + for (String columnName : columns) { + if (dao.columnExists(conn, tableName, columnName)) { + dao.dropColumn(conn, tableName, columnName); } } } + } diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java index 3b967e79dc5..922a892be04 100644 --- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade430to440.java @@ -23,9 +23,9 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import com.cloud.network.Network; import org.apache.log4j.Logger; +import com.cloud.network.Network; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.Script; @@ -59,9 +59,55 @@ public class Upgrade430to440 implements DbUpgrade { @Override public void performDataMigration(Connection conn) { + populateIAMGroupAccountMap(conn); secondaryIpsAccountAndDomainIdsUpdate(conn); } + // populate iam_group_account_map table for existing accounts + private void populateIAMGroupAccountMap(Connection conn) { + PreparedStatement acctInsert = null; + PreparedStatement acctQuery = null; + ResultSet rs = null; + + s_logger.debug("Populating iam_group_account_map table for existing accounts..."); + try { + acctInsert = conn + .prepareStatement("INSERT INTO `cloud`.`iam_group_account_map` (group_id, account_id, created) values(?, ?, Now())"); + acctQuery = conn + .prepareStatement("select id, type from `cloud`.`account` where removed is null"); + rs = acctQuery.executeQuery(); + + while (rs.next()) { + Long acct_id = rs.getLong("id"); + short type = rs.getShort("type"); + + // insert entry in iam_group_account_map table + acctInsert.setLong(1, type + 1); + acctInsert.setLong(2, acct_id); + acctInsert.executeUpdate(); + } + } catch (SQLException e) { + String msg = "Unable to populate iam_group_account_map for existing accounts." + e.getMessage(); + s_logger.error(msg); + throw new CloudRuntimeException(msg, e); + } finally { + try { + if (rs != null) { + rs.close(); + } + + if (acctInsert != null) { + acctInsert.close(); + } + if (acctQuery != null) { + acctQuery.close(); + } + } catch (SQLException e) { + } + } + s_logger.debug("Completed populate iam_group_account_map for existing accounts."); + } + private void secondaryIpsAccountAndDomainIdsUpdate(Connection conn) { @@ -116,7 +162,7 @@ public class Upgrade430to440 implements DbUpgrade { if (networkRs.next()) { String guesttype = networkRs.getString(1); - if (guesttype == Network.GuestType.Shared.toString()) { + if (guesttype.equals(Network.GuestType.Shared.toString())) { pstmtUpdate = conn.prepareStatement("UPDATE `cloud`.`user_ip_address` SET account_id = ?, domain_id= ? WHERE public_ip_address = ?"); pstmtUpdate.setLong(1,vmAccountId); pstmtUpdate.setLong(2,vmDomainId); @@ -126,16 +172,16 @@ public class Upgrade430to440 implements DbUpgrade { } } - networkRs.close(); + networkRs.close(); networkRs = null; - pstmtNw.close(); + pstmtNw.close(); pstmtNw = null; } } //if pstmtVm.close(); pstmtVm = null; - vmRs.close(); + vmRs.close(); vmRs = null; } // while diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade440to450.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade440to450.java new file mode 100644 index 00000000000..c1f853e8179 --- /dev/null +++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade440to450.java @@ -0,0 +1,70 @@ +// 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.upgrade.dao; + +import java.io.File; +import java.sql.Connection; + +import org.apache.log4j.Logger; + +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.utils.script.Script; + +public class Upgrade440to450 implements DbUpgrade { + final static Logger s_logger = Logger.getLogger(Upgrade440to450.class); + + @Override + public String[] getUpgradableVersionRange() { + return new String[] {"4.4.0", "4.5.0"}; + } + + @Override + public String getUpgradedVersion() { + return "4.5.0"; + } + + @Override + public boolean supportsRollingUpgrade() { + return false; + } + + @Override + public File[] getPrepareScripts() { + String script = Script.findScript("", "db/schema-440to450.sql"); + if (script == null) { + throw new CloudRuntimeException("Unable to find db/schema-440to450.sql"); + } + + return new File[] {new File(script)}; + } + + @Override + public void performDataMigration(Connection conn) { + } + + + @Override + public File[] getCleanupScripts() { + String script = Script.findScript("", "db/schema-440to450-cleanup.sql"); + if (script == null) { + throw new CloudRuntimeException("Unable to find db/schema-440to450-cleanup.sql"); + } + + return new File[] {new File(script)}; + } +} diff --git a/engine/schema/src/com/cloud/user/AccountVO.java b/engine/schema/src/com/cloud/user/AccountVO.java index 7fa9fe2e89f..0f5a0446e93 100644 --- a/engine/schema/src/com/cloud/user/AccountVO.java +++ b/engine/schema/src/com/cloud/user/AccountVO.java @@ -70,12 +70,12 @@ public class AccountVO implements Account { boolean isDefault; public AccountVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public AccountVO(long id) { this.id = id; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public AccountVO(String accountName, long domainId, String networkDomain, short type, String uuid) { @@ -83,7 +83,7 @@ public class AccountVO implements Account { this.domainId = domainId; this.networkDomain = networkDomain; this.type = type; - this.state = State.enabled; + state = State.enabled; this.uuid = uuid; } @@ -175,7 +175,7 @@ public class AccountVO implements Account { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -186,4 +186,9 @@ public class AccountVO implements Account { public boolean isDefault() { return isDefault; } + + @Override + public Class getEntityType() { + return Account.class; + } } diff --git a/engine/schema/src/com/cloud/user/SSHKeyPairVO.java b/engine/schema/src/com/cloud/user/SSHKeyPairVO.java index 9fb035d4d1a..fd7173ee7a8 100644 --- a/engine/schema/src/com/cloud/user/SSHKeyPairVO.java +++ b/engine/schema/src/com/cloud/user/SSHKeyPairVO.java @@ -114,4 +114,8 @@ public class SSHKeyPairVO implements SSHKeyPair { this.privateKey = privateKey; } + @Override + public Class getEntityType() { + return SSHKeyPair.class; + } } diff --git a/engine/schema/src/com/cloud/vm/InstanceGroupVO.java b/engine/schema/src/com/cloud/vm/InstanceGroupVO.java index 1089017e151..395751b705e 100644 --- a/engine/schema/src/com/cloud/vm/InstanceGroupVO.java +++ b/engine/schema/src/com/cloud/vm/InstanceGroupVO.java @@ -63,7 +63,7 @@ public class InstanceGroupVO implements InstanceGroup { public InstanceGroupVO(String name, long accountId) { this.name = name; this.accountId = accountId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } protected InstanceGroupVO() { @@ -105,7 +105,7 @@ public class InstanceGroupVO implements InstanceGroup { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -116,4 +116,9 @@ public class InstanceGroupVO implements InstanceGroup { public Short getAccountType() { return accountType; } + + @Override + public Class getEntityType() { + return InstanceGroup.class; + } } diff --git a/engine/schema/src/com/cloud/vm/NicDetailVO.java b/engine/schema/src/com/cloud/vm/NicDetailVO.java index 6df9d577493..7dc72159f3f 100644 --- a/engine/schema/src/com/cloud/vm/NicDetailVO.java +++ b/engine/schema/src/com/cloud/vm/NicDetailVO.java @@ -43,15 +43,16 @@ public class NicDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public NicDetailVO() { } - public NicDetailVO(long nicId, String name, String value) { + public NicDetailVO(long nicId, String name, String value, boolean display) { this.resourceId = nicId; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/com/cloud/vm/UserVmDetailVO.java b/engine/schema/src/com/cloud/vm/UserVmDetailVO.java index 2e199ccd8e8..d1a6e63fbc4 100644 --- a/engine/schema/src/com/cloud/vm/UserVmDetailVO.java +++ b/engine/schema/src/com/cloud/vm/UserVmDetailVO.java @@ -43,15 +43,16 @@ public class UserVmDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public UserVmDetailVO() { } - public UserVmDetailVO(long vmId, String name, String value) { + public UserVmDetailVO(long vmId, String name, String value, boolean display) { this.resourceId = vmId; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/com/cloud/vm/VMInstanceVO.java b/engine/schema/src/com/cloud/vm/VMInstanceVO.java index 48229b8ea7e..3d4337f374d 100644 --- a/engine/schema/src/com/cloud/vm/VMInstanceVO.java +++ b/engine/schema/src/com/cloud/vm/VMInstanceVO.java @@ -53,7 +53,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject getEntityType() { + return VirtualMachine.class; } public VirtualMachine.PowerState getPowerState() { @@ -530,5 +545,4 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject implements NicDao { List results = customSearch(sc, null); return results.get(0); } - } diff --git a/engine/schema/src/com/cloud/vm/dao/NicDetailsDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/NicDetailsDaoImpl.java index 8c95a0e8fb9..2bad56d2625 100644 --- a/engine/schema/src/com/cloud/vm/dao/NicDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/vm/dao/NicDetailsDaoImpl.java @@ -29,7 +29,7 @@ import com.cloud.vm.NicDetailVO; public class NicDetailsDaoImpl extends ResourceDetailsDaoBase implements NicDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new NicDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new NicDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java b/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java index 37aa0e340ad..2f000fde8a4 100644 --- a/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java +++ b/engine/schema/src/com/cloud/vm/dao/NicIpAliasVO.java @@ -34,23 +34,23 @@ import com.cloud.vm.NicIpAlias; @Entity @Table(name = "nic_ip_alias") -public class NicIpAliasVO implements NicIpAlias { +public class NicIpAliasVO implements NicIpAlias { public NicIpAliasVO(Long nicId, String ipaddr, Long vmId, Long accountId, Long domainId, Long networkId, String gateway, String netmask) { this.nicId = nicId; this.vmId = vmId; - this.ip4Address = ipaddr; + ip4Address = ipaddr; this.accountId = accountId; this.domainId = domainId; this.networkId = networkId; this.netmask = netmask; this.gateway = gateway; - this.state = NicIpAlias.state.active; + state = NicIpAlias.state.active; String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, netmask); String[] cidrPair = cidr.split("\\/"); String cidrAddress = cidrPair[0]; long cidrSize = Long.parseLong(cidrPair[1]); - this.startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize); + startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize); } protected NicIpAliasVO() { @@ -199,7 +199,7 @@ public class NicIpAliasVO implements NicIpAlias { } public void setAliasCount(long count) { - this.aliasCount = count; + aliasCount = count; } public void setNetmask(String netmask) { @@ -207,17 +207,17 @@ public class NicIpAliasVO implements NicIpAlias { } @Override - public String getNetmask() { + public String getNetmask() { return netmask; } @Override - public String getGateway() { - return gateway; + public String getGateway() { + return gateway; } public void setGateway(String gateway) { - this.gateway = gateway; + this.gateway = gateway; } public NicIpAlias.state getState() { @@ -232,4 +232,8 @@ public class NicIpAliasVO implements NicIpAlias { return startIpOfSubnet; } + @Override + public Class getEntityType() { + return NicIpAlias.class; + } } diff --git a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java b/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java index 142de8a6935..f8730aac5d2 100644 --- a/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java +++ b/engine/schema/src/com/cloud/vm/dao/NicSecondaryIpVO.java @@ -36,7 +36,7 @@ public class NicSecondaryIpVO implements NicSecondaryIp { public NicSecondaryIpVO(long nicId, String ipaddr, long vmId, long accountId, long domainId, long networkId) { this.nicId = nicId; this.vmId = vmId; - this.ip4Address = ipaddr; + ip4Address = ipaddr; this.accountId = accountId; this.domainId = domainId; this.networkId = networkId; @@ -124,4 +124,9 @@ public class NicSecondaryIpVO implements NicSecondaryIp { public long getVmId() { return vmId; } + + @Override + public Class getEntityType() { + return NicSecondaryIp.class; + } } diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDao.java b/engine/schema/src/com/cloud/vm/dao/UserVmDao.java index 0a4acbbe8b0..884d0a3f049 100755 --- a/engine/schema/src/com/cloud/vm/dao/UserVmDao.java +++ b/engine/schema/src/com/cloud/vm/dao/UserVmDao.java @@ -43,8 +43,9 @@ public interface UserVmDao extends GenericDao { * @param userData updates the userData of the vm * @param displayVm updates the displayvm attribute signifying whether it has to be displayed to the end user or not. * @param customId + * @param hostName TODO */ - void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm, boolean isDynamicallyScalable, String customId); + void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm, boolean isDynamicallyScalable, String customId, String hostName); List findDestroyedVms(Date date); diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java index 812e628e1b2..7a05be8f604 100755 --- a/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java +++ b/engine/schema/src/com/cloud/vm/dao/UserVmDaoImpl.java @@ -216,7 +216,7 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use } @Override - public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm, boolean isDynamicallyScalable, String customId) { + public void updateVM(long id, String displayName, boolean enable, Long osTypeId, String userData, boolean displayVm, boolean isDynamicallyScalable, String customId, String hostName) { UserVmVO vo = createForUpdate(); vo.setDisplayName(displayName); vo.setHaEnabled(enable); @@ -224,6 +224,9 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use vo.setUserData(userData); vo.setDisplayVm(displayVm); vo.setDynamicallyScalable(isDynamicallyScalable); + if (hostName != null) { + vo.setHostName(hostName); + } if (customId != null) { vo.setUuid(customId); } @@ -343,7 +346,7 @@ public class UserVmDaoImpl extends GenericDaoBase implements Use } List details = new ArrayList(); for (String key : detailsStr.keySet()) { - details.add(new UserVmDetailVO(vm.getId(), key, detailsStr.get(key))); + details.add(new UserVmDetailVO(vm.getId(), key, detailsStr.get(key), true)); } _detailsDao.saveDetails(details); diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java index 3f931208417..5800cd5f914 100644 --- a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java @@ -29,8 +29,8 @@ import com.cloud.vm.UserVmDetailVO; public class UserVmDetailsDaoImpl extends ResourceDetailsDaoBase implements UserVmDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new UserVmDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new UserVmDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java index 2f25f577f47..cc05f53605a 100644 --- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java +++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java @@ -437,6 +437,9 @@ public class VMInstanceDaoImpl extends GenericDaoBase implem return true; } + // lock the target row at beginning to avoid lock-promotion caused deadlock + lockRow(vm.getId(), true); + SearchCriteria sc = StateChangeSearch.create(); sc.setParameters("id", vmi.getId()); sc.setParameters("states", oldState); @@ -452,41 +455,29 @@ public class VMInstanceDaoImpl extends GenericDaoBase implem ub.set(vmi, _updateTimeAttr, new Date()); int result = update(vmi, sc); - if (result == 0 && s_logger.isDebugEnabled()) { - + if (result == 0) { VMInstanceVO vo = findByIdIncludingRemoved(vm.getId()); - if (vo != null) { - StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); - str.append(": DB Data={Host=") - .append(vo.getHostId()) - .append("; State=") - .append(vo.getState().toString()) - .append("; updated=") - .append(vo.getUpdated()) - .append("; time=") - .append(vo.getUpdateTime()); - str.append("} New Data: {Host=") - .append(vm.getHostId()) - .append("; State=") - .append(vm.getState().toString()) - .append("; updated=") - .append(vmi.getUpdated()) - .append("; time=") - .append(vo.getUpdateTime()); - str.append("} Stale Data: {Host=") - .append(oldHostId) - .append("; State=") - .append(oldState) - .append("; updated=") - .append(oldUpdated) - .append("; time=") - .append(oldUpdateDate) - .append("}"); - s_logger.debug(str.toString()); + if (s_logger.isDebugEnabled()) { + if (vo != null) { + StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); + str.append(": DB Data={Host=").append(vo.getHostId()).append("; State=").append(vo.getState().toString()).append("; updated=").append(vo.getUpdated()) + .append("; time=").append(vo.getUpdateTime()); + str.append("} New Data: {Host=").append(vm.getHostId()).append("; State=").append(vm.getState().toString()).append("; updated=").append(vmi.getUpdated()) + .append("; time=").append(vo.getUpdateTime()); + str.append("} Stale Data: {Host=").append(oldHostId).append("; State=").append(oldState).append("; updated=").append(oldUpdated).append("; time=") + .append(oldUpdateDate).append("}"); + s_logger.debug(str.toString()); - } else { - s_logger.debug("Unable to update the vm id=" + vm.getId() + "; the vm either doesn't exist or already removed"); + } else { + s_logger.debug("Unable to update the vm id=" + vm.getId() + "; the vm either doesn't exist or already removed"); + } + } + + if (vo != null && vo.getState() == newState) { + // allow for concurrent update if target state has already been matched + s_logger.debug("VM " + vo.getInstanceName() + " state has been already been updated to " + newState); + return true; } } return result > 0; diff --git a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java index 4531393ab52..b7a1c7bd3b1 100644 --- a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java +++ b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java @@ -44,14 +44,17 @@ public class VMSnapshotDetailsVO implements ResourceDetail { @Column(name = "value") String value; - public VMSnapshotDetailsVO() { + @Column(name = "display") + private boolean display = true; + public VMSnapshotDetailsVO() { } - public VMSnapshotDetailsVO(long vmSnapshotId, String name, String value) { + public VMSnapshotDetailsVO(long vmSnapshotId, String name, String value, boolean display) { this.resourceId = vmSnapshotId; this.name = name; this.value = value; + this.display = display; } @Override @@ -76,6 +79,6 @@ public class VMSnapshotDetailsVO implements ResourceDetail { @Override public boolean isDisplay() { - return false; + return display; } } diff --git a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java index 79fd274618b..df2966d45b6 100644 --- a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java +++ b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotVO.java @@ -133,10 +133,10 @@ public class VMSnapshotVO implements VMSnapshot { this.accountId = accountId; this.domainId = domainId; this.vmId = vmId; - this.state = State.Allocated; + state = State.Allocated; this.description = description; - this.name = vmSnapshotName; - this.displayName = vsDisplayName; + name = vmSnapshotName; + displayName = vsDisplayName; this.type = type; this.current = current; } @@ -227,7 +227,7 @@ public class VMSnapshotVO implements VMSnapshot { @Override public void incrUpdatedCount() { - this.updatedCount++; + updatedCount++; } @Override @@ -243,4 +243,9 @@ public class VMSnapshotVO implements VMSnapshot { public void setRemoved(Date removed) { this.removed = removed; } + + @Override + public Class getEntityType() { + return VMSnapshot.class; + } } diff --git a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java index bfa912d0327..a3cba7a94d1 100644 --- a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java +++ b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java @@ -25,7 +25,7 @@ import com.cloud.vm.snapshot.VMSnapshotDetailsVO; public class VMSnapshotDetailsDaoImpl extends ResourceDetailsDaoBase implements VMSnapshotDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new VMSnapshotDetailsVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new VMSnapshotDetailsVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java b/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java index 86a2e6a37fc..03274ad4388 100644 --- a/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java +++ b/engine/schema/src/org/apache/cloudstack/affinity/AffinityGroupVO.java @@ -60,7 +60,7 @@ public class AffinityGroupVO implements AffinityGroup { ControlledEntity.ACLType aclType; public AffinityGroupVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public AffinityGroupVO(String name, String type, String description, long domainId, long accountId, ACLType aclType) { @@ -68,7 +68,7 @@ public class AffinityGroupVO implements AffinityGroup { this.description = description; this.domainId = domainId; this.accountId = accountId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.type = type; this.aclType = aclType; } @@ -100,7 +100,7 @@ public class AffinityGroupVO implements AffinityGroup { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -124,4 +124,9 @@ public class AffinityGroupVO implements AffinityGroup { return buf.toString(); } + @Override + public Class getEntityType() { + return AffinityGroup.class; + } + } diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java index 19d608bbdda..b20cae320eb 100644 --- a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java +++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java @@ -173,34 +173,37 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject getEntityType() { + return VirtualMachine.class; + } + + @Override + public boolean isDisplay() { + return display; + } + + public void setDisplay(boolean display) { + this.display = display; + } } diff --git a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java index dabed151593..b934a5d6118 100644 --- a/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java +++ b/engine/schema/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMReservationVO.java @@ -66,6 +66,9 @@ public class VMReservationVO implements Identity, InternalIdentity { @Column(name = GenericDao.REMOVED_COLUMN) private Date removed; + @Column(name = "deployment_planner") + private String deploymentPlanner; + // VolumeId -> poolId @Transient Map volumeReservationMap; @@ -124,4 +127,12 @@ public class VMReservationVO implements Identity, InternalIdentity { this.volumeReservationMap = volumeReservationMap; } + public void setDeploymentPlanner(String planner) { + this.deploymentPlanner = planner; + } + + public String getDeploymentPlanner() { + return this.deploymentPlanner; + } + } diff --git a/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java b/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java index b7b720d31f0..88cd0003a23 100644 --- a/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java +++ b/engine/schema/src/org/apache/cloudstack/region/gslb/GlobalLoadBalancerRuleVO.java @@ -74,21 +74,21 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule { GlobalLoadBalancerRule.State state; public GlobalLoadBalancerRuleVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public GlobalLoadBalancerRuleVO(String name, String description, String gslbDomain, String algorithm, String persistence, String serviceType, int regionId, long accountId, long domainId, State state) { this.name = name; this.description = description; - this.region = regionId; + region = regionId; this.algorithm = algorithm; this.gslbDomain = gslbDomain; this.persistence = persistence; this.accountId = accountId; this.domainId = domainId; this.serviceType = serviceType; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.state = state; } @@ -163,7 +163,7 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -187,4 +187,9 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule { public GlobalLoadBalancerRule.State getState() { return state; } + + @Override + public Class getEntityType() { + return GlobalLoadBalancerRule.class; + } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/AutoScaleVmGroupDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/AutoScaleVmGroupDetailVO.java new file mode 100644 index 00000000000..9ac195a235d --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/AutoScaleVmGroupDetailVO.java @@ -0,0 +1,82 @@ +// 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 org.apache.cloudstack.resourcedetail; + +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 org.apache.cloudstack.api.ResourceDetail; + +@Entity +@Table(name = "autoscale_vmgroup_details") +public class AutoScaleVmGroupDetailVO implements ResourceDetail { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "autoscale_vmgroup_id") + private long resourceId; + + @Column(name = "name") + private String name; + + @Column(name = "value", length = 1024) + private String value; + + @Column(name = "display") + private boolean display = true; + + public AutoScaleVmGroupDetailVO() { + } + + public AutoScaleVmGroupDetailVO(long id, String name, String value, boolean display) { + this.resourceId = id; + this.name = name; + this.value = value; + this.display = display; + } + + @Override + public long getId() { + return id; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getValue() { + return value; + } + + @Override + public long getResourceId() { + return resourceId; + } + + @Override + public boolean isDisplay() { + return display; + } +} \ No newline at end of file diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/AutoScaleVmProfileDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/AutoScaleVmProfileDetailVO.java new file mode 100644 index 00000000000..d9b81a09f0f --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/AutoScaleVmProfileDetailVO.java @@ -0,0 +1,82 @@ +// 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 org.apache.cloudstack.resourcedetail; + +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 org.apache.cloudstack.api.ResourceDetail; + +@Entity +@Table(name = "autoscale_vmprofile_details") +public class AutoScaleVmProfileDetailVO implements ResourceDetail { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private long id; + + @Column(name = "autoscale_vmprofile_id") + private long resourceId; + + @Column(name = "name") + private String name; + + @Column(name = "value", length = 1024) + private String value; + + @Column(name = "display") + private boolean display = true; + + public AutoScaleVmProfileDetailVO() { + } + + public AutoScaleVmProfileDetailVO(long id, String name, String value, boolean display) { + this.resourceId = id; + this.name = name; + this.value = value; + this.display = display; + } + + @Override + public long getId() { + return id; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getValue() { + return value; + } + + @Override + public long getResourceId() { + return resourceId; + } + + @Override + public boolean isDisplay() { + return display; + } +} \ No newline at end of file diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/DiskOfferingDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/DiskOfferingDetailVO.java index bdee3c14db0..00eb7016763 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/DiskOfferingDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/DiskOfferingDetailVO.java @@ -48,10 +48,11 @@ public class DiskOfferingDetailVO implements ResourceDetail { public DiskOfferingDetailVO() { } - public DiskOfferingDetailVO(long id, String name, String value) { + public DiskOfferingDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/FirewallRuleDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/FirewallRuleDetailVO.java index b8c636a1285..636d889fafe 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/FirewallRuleDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/FirewallRuleDetailVO.java @@ -43,15 +43,16 @@ public class FirewallRuleDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public FirewallRuleDetailVO() { } - public FirewallRuleDetailVO(long id, String name, String value) { + public FirewallRuleDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/NetworkACLItemDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/NetworkACLItemDetailVO.java index 5abf59cc005..d9a74ed233c 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/NetworkACLItemDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/NetworkACLItemDetailVO.java @@ -43,15 +43,16 @@ public class NetworkACLItemDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public NetworkACLItemDetailVO() { } - public NetworkACLItemDetailVO(long id, String name, String value) { + public NetworkACLItemDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/NetworkACLListDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/NetworkACLListDetailVO.java index f60ba8c1270..49fba5ac414 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/NetworkACLListDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/NetworkACLListDetailVO.java @@ -43,15 +43,16 @@ public class NetworkACLListDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public NetworkACLListDetailVO() { } - public NetworkACLListDetailVO(long id, String name, String value) { + public NetworkACLListDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/RemoteAccessVpnDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/RemoteAccessVpnDetailVO.java index 295727f0cb8..5fb01a25c2a 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/RemoteAccessVpnDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/RemoteAccessVpnDetailVO.java @@ -43,15 +43,16 @@ public class RemoteAccessVpnDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public RemoteAccessVpnDetailVO() { } - public RemoteAccessVpnDetailVO(long id, String name, String value) { + public RemoteAccessVpnDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/ResourceDetailsDao.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/ResourceDetailsDao.java index f01665874df..50026837915 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/ResourceDetailsDao.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/ResourceDetailsDao.java @@ -66,6 +66,6 @@ public interface ResourceDetailsDao extends GenericDao public void saveDetails(List details); - public void addDetail(long resourceId, String key, String value); + public void addDetail(long resourceId, String key, String value, boolean display); } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/ResourceDetailsDaoBase.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/ResourceDetailsDaoBase.java index 2d086444213..60d7f162f2f 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/ResourceDetailsDaoBase.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/ResourceDetailsDaoBase.java @@ -34,7 +34,10 @@ public abstract class ResourceDetailsDaoBase extends G AllFieldsSearch = createSearchBuilder(); AllFieldsSearch.and("resourceId", AllFieldsSearch.entity().getResourceId(), SearchCriteria.Op.EQ); AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ); - AllFieldsSearch.and("display", AllFieldsSearch.entity().isDisplay(), SearchCriteria.Op.EQ); + // FIXME SnapshotDetailsVO doesn't have a display field + if (_allAttributes.containsKey("display")) { + AllFieldsSearch.and("display", AllFieldsSearch.entity().isDisplay(), SearchCriteria.Op.EQ); + } AllFieldsSearch.done(); } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteCustomerGatewayDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteCustomerGatewayDetailVO.java index 1a2743cab81..5c4c92d8cbb 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteCustomerGatewayDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteCustomerGatewayDetailVO.java @@ -43,15 +43,16 @@ public class Site2SiteCustomerGatewayDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public Site2SiteCustomerGatewayDetailVO() { } - public Site2SiteCustomerGatewayDetailVO(long id, String name, String value) { + public Site2SiteCustomerGatewayDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteVpnConnectionDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteVpnConnectionDetailVO.java index 9a4b616624b..17e08f21d00 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteVpnConnectionDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteVpnConnectionDetailVO.java @@ -43,15 +43,16 @@ public class Site2SiteVpnConnectionDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public Site2SiteVpnConnectionDetailVO() { } - public Site2SiteVpnConnectionDetailVO(long id, String name, String value) { + public Site2SiteVpnConnectionDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteVpnGatewayDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteVpnGatewayDetailVO.java index 244e218218a..7906655b909 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteVpnGatewayDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/Site2SiteVpnGatewayDetailVO.java @@ -43,15 +43,16 @@ public class Site2SiteVpnGatewayDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public Site2SiteVpnGatewayDetailVO() { } - public Site2SiteVpnGatewayDetailVO(long id, String name, String value) { + public Site2SiteVpnGatewayDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/UserDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/UserDetailVO.java index 69f44739a5e..79115a2a1f3 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/UserDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/UserDetailVO.java @@ -43,7 +43,7 @@ public class UserDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public UserDetailVO() { } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/UserIpAddressDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/UserIpAddressDetailVO.java index 2bbadcb8cc1..80393e083b9 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/UserIpAddressDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/UserIpAddressDetailVO.java @@ -43,15 +43,16 @@ public class UserIpAddressDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public UserIpAddressDetailVO() { } - public UserIpAddressDetailVO(long id, String name, String value) { + public UserIpAddressDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcDetailVO.java index beb38b50d1b..1952e238a08 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcDetailVO.java @@ -43,15 +43,16 @@ public class VpcDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public VpcDetailVO() { } - public VpcDetailVO(long id, String name, String value) { + public VpcDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcGatewayDetailVO.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcGatewayDetailVO.java index b78bfa8b5db..0f4b2aff4fd 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcGatewayDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/VpcGatewayDetailVO.java @@ -43,15 +43,16 @@ public class VpcGatewayDetailVO implements ResourceDetail { private String value; @Column(name = "display") - private boolean display; + private boolean display = true; public VpcGatewayDetailVO() { } - public VpcGatewayDetailVO(long id, String name, String value) { + public VpcGatewayDetailVO(long id, String name, String value, boolean display) { this.resourceId = id; this.name = name; this.value = value; + this.display = display; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmGroupDetailsDao.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmGroupDetailsDao.java new file mode 100644 index 00000000000..6e20e5ae2ca --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmGroupDetailsDao.java @@ -0,0 +1,26 @@ +// 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 org.apache.cloudstack.resourcedetail.dao; + +import org.apache.cloudstack.resourcedetail.AutoScaleVmGroupDetailVO; +import org.apache.cloudstack.resourcedetail.ResourceDetailsDao; + +import com.cloud.utils.db.GenericDao; + +public interface AutoScaleVmGroupDetailsDao extends GenericDao, ResourceDetailsDao { + +} diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmGroupDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmGroupDetailsDaoImpl.java new file mode 100644 index 00000000000..3d32a680cf9 --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmGroupDetailsDaoImpl.java @@ -0,0 +1,33 @@ +// 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 org.apache.cloudstack.resourcedetail.dao; + +import javax.ejb.Local; + +import org.apache.cloudstack.resourcedetail.AutoScaleVmGroupDetailVO; +import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase; +import org.springframework.stereotype.Component; + +@Component +@Local(value = {AutoScaleVmGroupDetailsDao.class}) +public class AutoScaleVmGroupDetailsDaoImpl extends ResourceDetailsDaoBase implements AutoScaleVmGroupDetailsDao { + + @Override + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new AutoScaleVmGroupDetailVO(resourceId, key, value, display)); + } +} \ No newline at end of file diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmProfileDetailsDao.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmProfileDetailsDao.java new file mode 100644 index 00000000000..9da313a85a7 --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmProfileDetailsDao.java @@ -0,0 +1,26 @@ +// 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 org.apache.cloudstack.resourcedetail.dao; + +import org.apache.cloudstack.resourcedetail.AutoScaleVmProfileDetailVO; +import org.apache.cloudstack.resourcedetail.ResourceDetailsDao; + +import com.cloud.utils.db.GenericDao; + +public interface AutoScaleVmProfileDetailsDao extends GenericDao, ResourceDetailsDao { + +} diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmProfileDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmProfileDetailsDaoImpl.java new file mode 100644 index 00000000000..736acefb4b2 --- /dev/null +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/AutoScaleVmProfileDetailsDaoImpl.java @@ -0,0 +1,33 @@ +// 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 org.apache.cloudstack.resourcedetail.dao; + +import javax.ejb.Local; + +import org.apache.cloudstack.resourcedetail.AutoScaleVmProfileDetailVO; +import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase; +import org.springframework.stereotype.Component; + +@Component +@Local(value = {AutoScaleVmProfileDetailsDao.class}) +public class AutoScaleVmProfileDetailsDaoImpl extends ResourceDetailsDaoBase implements AutoScaleVmProfileDetailsDao { + + @Override + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new AutoScaleVmProfileDetailVO(resourceId, key, value, display)); + } +} \ No newline at end of file diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/DiskOfferingDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/DiskOfferingDetailsDaoImpl.java index e2fc26e722a..c7c7e6cadce 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/DiskOfferingDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/DiskOfferingDetailsDaoImpl.java @@ -27,7 +27,7 @@ import org.springframework.stereotype.Component; public class DiskOfferingDetailsDaoImpl extends ResourceDetailsDaoBase implements DiskOfferingDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new DiskOfferingDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new DiskOfferingDetailVO(resourceId, key, value, display)); } } \ No newline at end of file diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/FirewallRuleDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/FirewallRuleDetailsDaoImpl.java index 1c1e83910f2..fa904932530 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/FirewallRuleDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/FirewallRuleDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase; public class FirewallRuleDetailsDaoImpl extends ResourceDetailsDaoBase implements FirewallRuleDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new FirewallRuleDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new FirewallRuleDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/NetworkACLItemDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/NetworkACLItemDetailsDaoImpl.java index 03d12820e32..d8686a21bfb 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/NetworkACLItemDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/NetworkACLItemDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase; public class NetworkACLItemDetailsDaoImpl extends ResourceDetailsDaoBase implements NetworkACLItemDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new NetworkACLItemDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new NetworkACLItemDetailVO(resourceId, key, value, display)); } } \ No newline at end of file diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/NetworkACLListDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/NetworkACLListDetailsDaoImpl.java index e07110f3ab0..b204ce2246f 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/NetworkACLListDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/NetworkACLListDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase; public class NetworkACLListDetailsDaoImpl extends ResourceDetailsDaoBase implements NetworkACLListDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new NetworkACLListDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new NetworkACLListDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/RemoteAccessVpnDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/RemoteAccessVpnDetailsDaoImpl.java index e8f312e054f..125369be6a9 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/RemoteAccessVpnDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/RemoteAccessVpnDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase; public class RemoteAccessVpnDetailsDaoImpl extends ResourceDetailsDaoBase implements RemoteAccessVpnDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new RemoteAccessVpnDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new RemoteAccessVpnDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteCustomerGatewayDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteCustomerGatewayDetailsDaoImpl.java index 71e810ee33d..73650fe48f3 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteCustomerGatewayDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteCustomerGatewayDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.Site2SiteCustomerGatewayDetailVO; public class Site2SiteCustomerGatewayDetailsDaoImpl extends ResourceDetailsDaoBase implements Site2SiteCustomerGatewayDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new Site2SiteCustomerGatewayDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new Site2SiteCustomerGatewayDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteVpnConnectionDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteVpnConnectionDetailsDaoImpl.java index 7261df8ea1f..099977d46b2 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteVpnConnectionDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteVpnConnectionDetailsDaoImpl.java @@ -26,7 +26,7 @@ import org.springframework.stereotype.Component; public class Site2SiteVpnConnectionDetailsDaoImpl extends ResourceDetailsDaoBase implements Site2SiteVpnConnectionDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new Site2SiteVpnConnectionDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new Site2SiteVpnConnectionDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteVpnGatewayDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteVpnGatewayDetailsDaoImpl.java index 1e6b4809ca8..9502b65460b 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteVpnGatewayDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/Site2SiteVpnGatewayDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.Site2SiteVpnGatewayDetailVO; public class Site2SiteVpnGatewayDetailsDaoImpl extends ResourceDetailsDaoBase implements Site2SiteVpnGatewayDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new Site2SiteVpnGatewayDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new Site2SiteVpnGatewayDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/UserDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/UserDetailsDaoImpl.java index 508185297a8..d77ee873d26 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/UserDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/UserDetailsDaoImpl.java @@ -27,7 +27,7 @@ import org.springframework.stereotype.Component; public class UserDetailsDaoImpl extends ResourceDetailsDaoBase implements UserDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { + public void addDetail(long resourceId, String key, String value, boolean display) { super.addDetail(new UserDetailVO(resourceId, key, value)); } } \ No newline at end of file diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/UserIpAddressDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/UserIpAddressDetailsDaoImpl.java index a8d211ec745..4444da0faf9 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/UserIpAddressDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/UserIpAddressDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.UserIpAddressDetailVO; public class UserIpAddressDetailsDaoImpl extends ResourceDetailsDaoBase implements UserIpAddressDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new UserIpAddressDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new UserIpAddressDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDaoImpl.java index fb22c7c18b2..b455656cae3 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.VpcDetailVO; public class VpcDetailsDaoImpl extends ResourceDetailsDaoBase implements VpcDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new VpcDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new VpcDetailVO(resourceId, key, value, display)); } } diff --git a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcGatewayDetailsDaoImpl.java b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcGatewayDetailsDaoImpl.java index 871c3631941..e8d632dd24a 100644 --- a/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcGatewayDetailsDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/resourcedetail/dao/VpcGatewayDetailsDaoImpl.java @@ -28,7 +28,7 @@ import org.apache.cloudstack.resourcedetail.VpcGatewayDetailVO; public class VpcGatewayDetailsDaoImpl extends ResourceDetailsDaoBase implements VpcGatewayDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new VpcGatewayDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new VpcGatewayDetailVO(resourceId, key, value, display)); } } \ No newline at end of file diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java index 77e50bddbf3..2d1a3eddd69 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/ImageStoreVO.java @@ -31,6 +31,7 @@ import javax.persistence.TableGenerator; import com.cloud.storage.DataStoreRole; import com.cloud.storage.ImageStore; import com.cloud.storage.ScopeType; +import com.cloud.utils.UriUtils; import com.cloud.utils.db.GenericDao; @Entity @@ -149,7 +150,11 @@ public class ImageStoreVO implements ImageStore { } public String getUrl() { - return url; + String updatedUrl = url; + if ("cifs".equalsIgnoreCase(this.protocol)) { + updatedUrl = UriUtils.getUpdateUri(updatedUrl, false); + } + return updatedUrl; } public void setUrl(String url) { diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java index 1a5949459ea..57afa16b501 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java @@ -232,7 +232,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase pool = super.persist(pool); if (details != null) { for (Map.Entry detail : details.entrySet()) { - StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue()); + StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(), detail.getValue(), true); _detailsDao.persist(vo); } } @@ -388,7 +388,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase if (details != null) { List detailsVO = new ArrayList(); for (String key : details.keySet()) { - detailsVO.add(new StoragePoolDetailVO(poolId, key, details.get(key))); + detailsVO.add(new StoragePoolDetailVO(poolId, key, details.get(key), true)); } _detailsDao.saveDetails(detailsVO); } diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java index a7998b3145c..5351959ea1a 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java @@ -43,12 +43,13 @@ public class PrimaryDataStoreDetailVO implements ResourceDetail { String value; @Column(name = "display") - private boolean display; + private boolean display = true; - public PrimaryDataStoreDetailVO(long poolId, String name, String value) { + public PrimaryDataStoreDetailVO(long poolId, String name, String value, boolean display) { this.resourceId = poolId; this.name = name; this.value = value; + this.display = display; } protected PrimaryDataStoreDetailVO() { diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java index 8b68d6c9038..75b1d75dd6a 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/SnapshotDataStoreVO.java @@ -29,6 +29,8 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import org.apache.log4j.Logger; + import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State; @@ -44,6 +46,8 @@ import com.cloud.utils.fsm.StateObject; @Entity @Table(name = "snapshot_store_ref") public class SnapshotDataStoreVO implements StateObject, DataObjectInStore { + private static final Logger s_logger = Logger.getLogger(SnapshotDataStoreVO.class); + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id; @@ -272,7 +276,12 @@ public class SnapshotDataStoreVO implements StateObject 0) { + refCnt--; + } + else { + s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded"); + } } public Long getVolumeId() { diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java index f2d209840c2..8a746ff9d1d 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java @@ -43,12 +43,13 @@ public class StoragePoolDetailVO implements ResourceDetail { String value; @Column(name = "display") - private boolean display; + private boolean display = true; - public StoragePoolDetailVO(long poolId, String name, String value) { + public StoragePoolDetailVO(long poolId, String name, String value, boolean display) { this.resourceId = poolId; this.name = name; this.value = value; + this.display = display; } public StoragePoolDetailVO() { diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java index ede2b97f24e..1508ce0b28c 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolVO.java @@ -34,6 +34,7 @@ import com.cloud.storage.ScopeType; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePoolStatus; +import com.cloud.utils.UriUtils; import com.cloud.utils.db.GenericDao; @Entity @@ -141,10 +142,10 @@ public class StoragePoolVO implements StoragePool { this.usedBytes = availableBytes; this.capacityBytes = capacityBytes; this.hostAddress = hostAddress; - this.path = hostPath; this.port = port; this.podId = podId; this.setStatus(StoragePoolStatus.Initial); + this.setPath(hostPath); } public StoragePoolVO(StoragePoolVO that) { @@ -155,9 +156,9 @@ public class StoragePoolVO implements StoragePool { this.poolType = type; this.hostAddress = hostAddress; this.port = port; - this.path = path; this.setStatus(StoragePoolStatus.Initial); this.uuid = UUID.randomUUID().toString(); + this.setPath(path); } @Override @@ -262,7 +263,12 @@ public class StoragePoolVO implements StoragePool { @Override public String getPath() { - return path; + String updatedPath = path; + if (this.poolType == StoragePoolType.SMB) { + updatedPath = UriUtils.getUpdateUri(updatedPath, false); + } + + return updatedPath; } @Override diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java index ab458895e46..271bbcae147 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java @@ -65,6 +65,8 @@ public interface TemplateDataStoreDao extends GenericDao listByTemplate(long templateId); + TemplateDataStoreVO findByTemplateZoneReady(long templateId, Long zoneId); + void duplicateCacheRecordsOnRegionStore(long storeId); TemplateDataStoreVO findReadyOnCache(long templateId); diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java index 897fee0e4de..bb40bf5d11a 100755 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreVO.java @@ -29,6 +29,8 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import org.apache.log4j.Logger; + import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State; @@ -45,6 +47,8 @@ import com.cloud.utils.fsm.StateObject; @Entity @Table(name = "template_store_ref") public class TemplateDataStoreVO implements StateObject, DataObjectInStore { + private static final Logger s_logger = Logger.getLogger(TemplateDataStoreVO.class); + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id; @@ -367,7 +371,12 @@ public class TemplateDataStoreVO implements StateObject 0) { + refCnt--; + } + else{ + s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded"); + } } } diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java index fe6aca4c3d2..588eae8ba57 100755 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreVO.java @@ -29,6 +29,8 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import org.apache.log4j.Logger; + import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State; @@ -44,6 +46,8 @@ import com.cloud.utils.fsm.StateObject; @Entity @Table(name = "volume_store_ref") public class VolumeDataStoreVO implements StateObject, DataObjectInStore { + private static final Logger s_logger = Logger.getLogger(VolumeDataStoreVO.class); + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id; @@ -342,7 +346,12 @@ public class VolumeDataStoreVO implements StateObject 0) { + refCnt--; + } + else { + s_logger.warn("We should not try to decrement a zero reference count even though our code has guarded"); + } } public void incrRefCnt() { diff --git a/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java b/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java new file mode 100644 index 00000000000..5d37fbf326a --- /dev/null +++ b/engine/schema/test/com/cloud/upgrade/dao/DatabaseAccessObjectTest.java @@ -0,0 +1,463 @@ +// 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.upgrade.dao; + +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.contains; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.apache.log4j.Logger; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.internal.util.reflection.Whitebox; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class DatabaseAccessObjectTest { + + @Mock + private PreparedStatement preparedStatementMock; + + @Mock + private Connection connectionMock; + + @Mock + private Logger loggerMock; + + private final DatabaseAccessObject dao = new DatabaseAccessObject(); + + @Before + public void setup() { + Whitebox.setInternalState(dao, "s_logger", loggerMock); + } + + @Test + public void testDropKey() throws Exception { + when(connectionMock.prepareStatement(contains("DROP KEY"))).thenReturn(preparedStatementMock); + + Connection conn = connectionMock; + String tableName = "tableName"; + String key = "key"; + boolean isForeignKey = false; + + dao.dropKey(conn, tableName, key, isForeignKey); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(1)).debug(anyString()); + verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + } + + @Test(expected = NullPointerException.class) + public void testDropKeyWhenConnectionIsNull() throws Exception { + Connection conn = null; + String tableName = "tableName"; + String key = "key"; + boolean isForeignKey = false; + + dao.dropKey(conn, tableName, key, isForeignKey); + } + + @Test + public void testDropKeyWhenTableNameIsNull() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("null DROP KEY"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeUpdate()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = null; + String key = "key"; + boolean isForeignKey = false; + + dao.dropKey(conn, tableName, key, isForeignKey); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropKeyWhenKeyIsNull() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("DROP KEY null"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeUpdate()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = "tableName"; + String key = null; + boolean isForeignKey = false; + + dao.dropKey(conn, tableName, key, isForeignKey); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropKeyWhenKeysAreForeignKeys() throws Exception { + when(connectionMock.prepareStatement(contains("DROP FOREIGN KEY"))).thenReturn(preparedStatementMock); + + Connection conn = connectionMock; + String tableName = "tableName"; + String key = "key"; + boolean isForeignKey = true; + + dao.dropKey(conn, tableName, key, isForeignKey); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(1)).debug(anyString()); + verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + } + + @Test + public void testDropKeyWhenPrepareStatementResultsInException() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(any(String.class))).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = "tableName"; + String key = "key"; + boolean isForeignKey = false; + + dao.dropKey(conn, tableName, key, isForeignKey); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(0)).executeUpdate(); + verify(preparedStatementMock, times(0)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropKeyWhenExecuteUpdateResultsInException() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("DROP KEY"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeUpdate()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = "tableName"; + String key = "key"; + boolean isForeignKey = false; + + dao.dropKey(conn, tableName, key, isForeignKey); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @SuppressWarnings("static-access") + @Test + public void testClosePreparedStatementWhenPreparedStatementIsNull() throws Exception { + PreparedStatement preparedStatement = null; + String errorMessage = "some message"; + + dao.closePreparedStatement(preparedStatement, errorMessage); + + verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + } + + @SuppressWarnings("static-access") + @Test + public void testClosePreparedStatementWhenPreparedStatementIsNotNullAndThereIsNoException() throws Exception { + PreparedStatement preparedStatement = preparedStatementMock; + String errorMessage = "some message"; + + dao.closePreparedStatement(preparedStatement, errorMessage); + + verify(preparedStatement, times(1)).close(); + verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + } + + @SuppressWarnings("static-access") + @Test + public void testClosePreparedStatementWhenPreparedStatementIsNotNullAndThereIsException() throws Exception { + SQLException sqlException = new SQLException(); + doThrow(sqlException).when(preparedStatementMock).close(); + + PreparedStatement preparedStatement = preparedStatementMock; + String errorMessage = "some message"; + + dao.closePreparedStatement(preparedStatement, errorMessage); + + verify(preparedStatement, times(1)).close(); + verify(loggerMock, times(1)).warn(errorMessage, sqlException); + } + + @Test + public void testDropPrimaryKey() throws Exception { + when(connectionMock.prepareStatement(contains("DROP PRIMARY KEY"))).thenReturn(preparedStatementMock); + + Connection conn = connectionMock; + String tableName = "tableName"; + + dao.dropPrimaryKey(conn, tableName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(1)).debug(anyString()); + verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + } + + @Test(expected = NullPointerException.class) + public void testDropPrimaryKeyWhenConnectionIsNull() throws Exception { + Connection conn = null; + String tableName = "tableName"; + + dao.dropPrimaryKey(conn, tableName); + } + + @Test + public void testDropPrimaryKeyWhenTableNameIsNull() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("null DROP PRIMARY KEY"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeUpdate()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = null; + + dao.dropPrimaryKey(conn, tableName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropPrimaryKeyWhenPrepareStatementResultsInException() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("DROP PRIMARY KEY"))).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = null; + + dao.dropPrimaryKey(conn, tableName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(0)).executeUpdate(); + verify(preparedStatementMock, times(0)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropPrimaryKeyWhenExecuteUpdateResultsInException() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("DROP PRIMARY KEY"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeUpdate()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = null; + + dao.dropPrimaryKey(conn, tableName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testColumnExists() throws Exception { + when(connectionMock.prepareStatement(contains("SELECT"))).thenReturn(preparedStatementMock); + + Connection conn = connectionMock; + String tableName = "tableName"; + String columnName = "columnName"; + + dao.columnExists(conn, tableName, columnName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeQuery(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + } + + @Test(expected = NullPointerException.class) + public void testColumnExistsWhenConnectionIsNull() throws Exception { + Connection conn = null; + String tableName = "tableName"; + String columnName = "columnName"; + + dao.columnExists(conn, tableName, columnName); + } + + @Test + public void testColumnExistsWhenTableNameIsNull() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("FROM null"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeQuery()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = null; + String columnName = "columnName"; + + dao.columnExists(conn, tableName, columnName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeQuery(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testColumnExistsWhenColumnNameIsNull() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("SELECT null"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeQuery()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = "tableName"; + String columnName = null; + + dao.columnExists(conn, tableName, columnName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeQuery(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropColumn() throws Exception { + when(connectionMock.prepareStatement(anyString())).thenReturn(preparedStatementMock); + + Connection conn = connectionMock; + String tableName = "tableName"; + String columnName = "columnName"; + + dao.dropColumn(conn, tableName, columnName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(0)).executeQuery(); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(1)).debug(anyString()); + verify(loggerMock, times(0)).warn(anyString(), any(Throwable.class)); + } + + @Test(expected = NullPointerException.class) + public void testDropColumnWhenConnectionIsNull() throws Exception { + + Connection conn = null; + String tableName = "tableName"; + String columnName = "columnName"; + + dao.dropColumn(conn, tableName, columnName); + } + + @Test + public void testDropColumnWhenTableNameIsNull() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("ALTER TABLE null"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeUpdate()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = null; + String columnName = "columnName"; + + dao.dropColumn(conn, tableName, columnName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropColumnWhenColumnNameIsNull() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(contains("DROP COLUMN null"))).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeUpdate()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = "tableName"; + String columnName = null; + + dao.dropColumn(conn, tableName, columnName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropColumnWhenPrepareStatementResultsInException() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(anyString())).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = "tableName"; + String columnName = "columnName"; + + dao.dropColumn(conn, tableName, columnName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(0)).executeUpdate(); + verify(preparedStatementMock, times(0)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + + @Test + public void testDropColumnWhenexecuteUpdateResultsInException() throws Exception { + SQLException sqlException = new SQLException(); + when(connectionMock.prepareStatement(anyString())).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeUpdate()).thenThrow(sqlException); + + Connection conn = connectionMock; + String tableName = "tableName"; + String columnName = "columnName"; + + dao.dropColumn(conn, tableName, columnName); + + verify(connectionMock, times(1)).prepareStatement(anyString()); + verify(preparedStatementMock, times(1)).executeUpdate(); + verify(preparedStatementMock, times(1)).close(); + verify(loggerMock, times(0)).debug(anyString()); + verify(loggerMock, times(1)).warn(anyString(), eq(sqlException)); + } + +} diff --git a/engine/schema/test/com/cloud/upgrade/dao/DbUpgradeUtilsTest.java b/engine/schema/test/com/cloud/upgrade/dao/DbUpgradeUtilsTest.java new file mode 100644 index 00000000000..d248cfb254e --- /dev/null +++ b/engine/schema/test/com/cloud/upgrade/dao/DbUpgradeUtilsTest.java @@ -0,0 +1,162 @@ +// 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.upgrade.dao; + +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.when; + +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; + +@RunWith(PowerMockRunner.class) +public class DbUpgradeUtilsTest { + + @Mock + private Connection connectionMock; + + @Mock + private DatabaseAccessObject daoMock; + + @Before + public void setupClass() { + Whitebox.setInternalState(DbUpgradeUtils.class, "dao", daoMock); + } + + @Test + public void testDropKeyIfExistWhenNoKeysAreSupplied() throws Exception { + Connection conn = connectionMock; + String tableName = "tableName"; + List keys = new ArrayList(); + boolean isForeignKey = false; + + DbUpgradeUtils.dropKeysIfExist(conn, tableName, keys, isForeignKey); + + verify(daoMock, times(0)).dropKey(eq(conn), eq(tableName), anyString(), eq(isForeignKey)); + } + + @Test + public void testDropKeyIfExistWhenOneKeysIsSupplied() throws Exception { + Connection conn = connectionMock; + String tableName = "tableName"; + String key = "key"; + List keys = Arrays.asList(new String[] {key}); + boolean isForeignKey = false; + + DbUpgradeUtils.dropKeysIfExist(conn, tableName, keys, isForeignKey); + + verify(daoMock, times(1)).dropKey(conn, tableName, key, isForeignKey); + } + + @Test + public void testDropKeyIfExistWhenThreeKeysAreSupplied() throws Exception { + Connection conn = connectionMock; + String tableName = "tableName"; + String key1 = "key1"; + String key2 = "key2"; + List keys = Arrays.asList(new String[] {key1, key2}); + boolean isForeignKey = false; + + DbUpgradeUtils.dropKeysIfExist(conn, tableName, keys, isForeignKey); + + verify(daoMock, times(1)).dropKey(conn, tableName, key1, isForeignKey); + verify(daoMock, times(1)).dropKey(conn, tableName, key2, isForeignKey); + } + + @Test + public void testDropPrimaryKey() throws Exception { + Connection conn = connectionMock; + String tableName = "tableName"; + + DbUpgradeUtils.dropPrimaryKeyIfExists(conn, tableName); + + verify(daoMock, times(1)).dropPrimaryKey(conn, tableName); + } + + @Test + public void testDropTableColumnsIfExistWhenNoKeysAreSupplied() throws Exception { + Connection conn = connectionMock; + String tableName = "tableName"; + List columns = new ArrayList(); + + DbUpgradeUtils.dropTableColumnsIfExist(conn, tableName, columns); + + verify(daoMock, times(0)).columnExists(eq(conn), eq(tableName), anyString()); + verify(daoMock, times(0)).dropColumn(eq(conn), eq(tableName), anyString()); + } + + @Test + public void testDropTableColumnsIfExistWhenOneKeysIsSuppliedAndColumnExists() throws Exception { + Connection conn = connectionMock; + String tableName = "tableName"; + String column = "column"; + when(daoMock.columnExists(conn, tableName, column)).thenReturn(true); + List columns = Arrays.asList(new String[] {column}); + + DbUpgradeUtils.dropTableColumnsIfExist(conn, tableName, columns); + + verify(daoMock, times(1)).columnExists(conn, tableName, column); + verify(daoMock, times(1)).dropColumn(conn, tableName, column); + } + + @Test + public void testDropTableColumnsIfExistWhenOneKeysIsSuppliedAndColumnDoesNotExists() throws Exception { + Connection conn = connectionMock; + String tableName = "tableName"; + String column = "column"; + when(daoMock.columnExists(conn, tableName, column)).thenReturn(false); + List columns = Arrays.asList(new String[] {column}); + + DbUpgradeUtils.dropTableColumnsIfExist(conn, tableName, columns); + + verify(daoMock, times(1)).columnExists(conn, tableName, column); + verify(daoMock, times(0)).dropColumn(conn, tableName, column); + } + + @Test + public void testDropTableColumnsIfExistWhenThreeKeysAreSuppliedAnOneDoesnotExist() throws Exception { + Connection conn = connectionMock; + String tableName = "tableName"; + String column1 = "column1"; + String column2 = "column2"; + String column3 = "column3"; + when(daoMock.columnExists(conn, tableName, column1)).thenReturn(true); + when(daoMock.columnExists(conn, tableName, column2)).thenReturn(false); + when(daoMock.columnExists(conn, tableName, column3)).thenReturn(true); + List keys = Arrays.asList(new String[] {column1, column2, column3}); + + DbUpgradeUtils.dropTableColumnsIfExist(conn, tableName, keys); + + verify(daoMock, times(1)).columnExists(conn, tableName, column1); + verify(daoMock, times(1)).dropColumn(conn, tableName, column1); + verify(daoMock, times(1)).columnExists(conn, tableName, column2); + verify(daoMock, times(0)).dropColumn(conn, tableName, column2); + verify(daoMock, times(1)).columnExists(conn, tableName, column3); + verify(daoMock, times(1)).dropColumn(conn, tableName, column3); + } +} diff --git a/engine/service/findbugsExcludeFilter.xml b/engine/service/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/service/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/service/pom.xml b/engine/service/pom.xml index 5033d94da5a..1fc68fac258 100644 --- a/engine/service/pom.xml +++ b/engine/service/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT cloud-engine-service war diff --git a/engine/storage/cache/findbugsExcludeFilter.xml b/engine/storage/cache/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/storage/cache/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/storage/cache/pom.xml b/engine/storage/cache/pom.xml index 91fd000ba14..3493220ddc6 100644 --- a/engine/storage/cache/pom.xml +++ b/engine/storage/cache/pom.xml @@ -15,7 +15,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/allocator/StorageCacheAllocator.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/allocator/StorageCacheAllocator.java index 4259d9ed03f..96251c5bcda 100644 --- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/allocator/StorageCacheAllocator.java +++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/allocator/StorageCacheAllocator.java @@ -18,9 +18,12 @@ */ package org.apache.cloudstack.storage.cache.allocator; +import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.Scope; public interface StorageCacheAllocator { DataStore getCacheStore(Scope scope); + + DataStore getCacheStore(DataObject data, Scope scope); } diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/allocator/StorageCacheRandomAllocator.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/allocator/StorageCacheRandomAllocator.java index 7c115614b08..b4ef595e99f 100644 --- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/allocator/StorageCacheRandomAllocator.java +++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/allocator/StorageCacheRandomAllocator.java @@ -26,9 +26,13 @@ import javax.inject.Inject; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; +import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; +import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; +import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.Scope; +import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager; import com.cloud.storage.ScopeType; @@ -37,6 +41,8 @@ public class StorageCacheRandomAllocator implements StorageCacheAllocator { private static final Logger s_logger = Logger.getLogger(StorageCacheRandomAllocator.class); @Inject DataStoreManager dataStoreMgr; + @Inject + ObjectInDataStoreManager objectInStoreMgr; @Override public DataStore getCacheStore(Scope scope) { @@ -54,4 +60,36 @@ public class StorageCacheRandomAllocator implements StorageCacheAllocator { Collections.shuffle(cacheStores); return cacheStores.get(0); } + + @Override + public DataStore getCacheStore(DataObject data, Scope scope) { + if (scope.getScopeType() != ScopeType.ZONE) { + s_logger.debug("Can only support zone wide cache storage"); + return null; + } + + List cacheStores = dataStoreMgr.getImageCacheStores(scope); + if (cacheStores.size() <= 0) { + s_logger.debug("Can't find staging storage in zone: " + scope.getScopeId()); + return null; + } + + // if there are multiple cache stores, we give priority to the one where data is already there + if (cacheStores.size() > 1) { + for (DataStore store : cacheStores) { + DataObjectInStore obj = objectInStoreMgr.findObject(data, store); + if (obj != null && obj.getState() == ObjectInDataStoreStateMachine.State.Ready) { + s_logger.debug("pick the cache store " + store.getId() + " where data is already there"); + return store; + } + } + + // otherwise, just random pick one + Collections.shuffle(cacheStores); + } + return cacheStores.get(0); + + } + + } diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java index fe2543c96e5..3a502d12ae0 100644 --- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java +++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java @@ -90,6 +90,19 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager { return null; } + + @Override + public DataStore getCacheStorage(DataObject data, Scope scope) { + for (StorageCacheAllocator allocator : storageCacheAllocator) { + DataStore store = allocator.getCacheStore(data, scope); + if (store != null) { + return store; + } + } + return null; + } + + protected List getCacheStores() { QueryBuilder sc = QueryBuilder.create(ImageStoreVO.class); sc.and(sc.entity().getRole(), SearchCriteria.Op.EQ, DataStoreRole.ImageCache); diff --git a/engine/storage/datamotion/findbugsExcludeFilter.xml b/engine/storage/datamotion/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/storage/datamotion/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/storage/datamotion/pom.xml b/engine/storage/datamotion/pom.xml index 51b16a16198..3304c6f9860 100644 --- a/engine/storage/datamotion/pom.xml +++ b/engine/storage/datamotion/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/datamotion/resources/META-INF/cloudstack/storage/spring-engine-storage-datamotion-storage-context.xml b/engine/storage/datamotion/resources/META-INF/cloudstack/storage/spring-engine-storage-datamotion-storage-context.xml index 725f7d35be5..ade22dbc25b 100644 --- a/engine/storage/datamotion/resources/META-INF/cloudstack/storage/spring-engine-storage-datamotion-storage-context.xml +++ b/engine/storage/datamotion/resources/META-INF/cloudstack/storage/spring-engine-storage-datamotion-storage-context.xml @@ -30,5 +30,6 @@ class="org.apache.cloudstack.storage.motion.AncientDataMotionStrategy" /> - + diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java index fa1dce45719..fbdacfa5aa2 100644 --- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java +++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java @@ -46,6 +46,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope; import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.cloudstack.storage.RemoteHostEndPoint; import org.apache.cloudstack.storage.command.CopyCommand; import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity; @@ -94,15 +95,17 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { protected boolean needCacheStorage(DataObject srcData, DataObject destData) { DataTO srcTO = srcData.getTO(); - DataTO destTO = destData.getTO(); DataStoreTO srcStoreTO = srcTO.getDataStore(); - DataStoreTO destStoreTO = destTO.getDataStore(); + if (srcStoreTO instanceof NfsTO || srcStoreTO.getRole() == DataStoreRole.ImageCache) { //|| // (srcStoreTO instanceof PrimaryDataStoreTO && ((PrimaryDataStoreTO)srcStoreTO).getPoolType() == StoragePoolType.NetworkFilesystem)) { return false; } + DataTO destTO = destData.getTO(); + DataStoreTO destStoreTO = destTO.getDataStore(); + if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) { return false; } @@ -147,7 +150,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { return selectedScope; } - protected Answer copyObject(DataObject srcData, DataObject destData) { + protected Answer copyObject(DataObject srcData, DataObject destData, Host destHost) { String value = configDao.getValue(Config.PrimaryStorageDownloadWait.toString()); int _primaryStorageDownloadWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue())); Answer answer = null; @@ -160,7 +163,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { } CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), destData.getTO(), _primaryStorageDownloadWait, VirtualMachineManager.ExecuteInSequence.value()); - EndPoint ep = selector.select(srcForCopy, destData); + EndPoint ep = destHost != null ? RemoteHostEndPoint.getHypervisorHostEndPoint(destHost) : selector.select(srcForCopy, destData); if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; s_logger.error(errMsg); @@ -193,9 +196,13 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { } } + protected Answer copyObject(DataObject srcData, DataObject destData) { + return copyObject(srcData, destData, null); + } + protected DataObject cacheSnapshotChain(SnapshotInfo snapshot, Scope scope) { DataObject leafData = null; - DataStore store = cacheMgr.getCacheStorage(scope); + DataStore store = cacheMgr.getCacheStorage(snapshot, scope); while (snapshot != null) { DataObject cacheData = cacheMgr.createCacheObject(snapshot, store); if (leafData == null) { @@ -242,7 +249,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { if (srcData.getDataStore().getRole() == DataStoreRole.Primary) { ep = selector.select(volObj); } else { - ep = selector.select(snapObj, volObj); + ep = selector.select(srcData, volObj); } CopyCommand cmd = new CopyCommand(srcData.getTO(), volObj.getTO(), _createVolumeFromSnapshotWait, VirtualMachineManager.ExecuteInSequence.value()); @@ -365,7 +372,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { VolumeInfo volume = (VolumeInfo)srcData; StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(destData.getDataStore().getId(), DataStoreRole.Primary); MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool, volume.getAttachedVmName()); - EndPoint ep = selector.select(volume.getDataStore()); + EndPoint ep = selector.select(srcData, StorageAction.MIGRATEVOLUME); Answer answer = null; if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; @@ -392,8 +399,9 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { return answer; } + // Note: destHost is currently only used if the copyObject method is invoked @Override - public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback) { + public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback callback) { Answer answer = null; String errMsg = null; try { @@ -416,7 +424,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { } else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) { answer = copySnapshot(srcData, destData); } else { - answer = copyObject(srcData, destData); + answer = copyObject(srcData, destData, destHost); } if (answer != null && !answer.getResult()) { @@ -432,6 +440,11 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { return null; } + @Override + public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback) { + return copyAsync(srcData, destData, null, callback); + } + @DB protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destData) { diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java index 37e8baabbe9..eed1e08005f 100644 --- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java +++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/DataMotionServiceImpl.java @@ -46,7 +46,7 @@ public class DataMotionServiceImpl implements DataMotionService { StorageStrategyFactory storageStrategyFactory; @Override - public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback) { + public void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback callback) { if (srcData.getDataStore() == null || destData.getDataStore() == null) { throw new CloudRuntimeException("can't find data store"); } @@ -65,7 +65,12 @@ public class DataMotionServiceImpl implements DataMotionService { destData.getType().name() + " '" + destData.getUuid() + "'"); } - strategy.copyAsync(srcData, destData, callback); + strategy.copyAsync(srcData, destData, destHost, callback); + } + + @Override + public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback) { + copyAsync(srcData, destData, null, callback); } @Override diff --git a/engine/storage/findbugsExcludeFilter.xml b/engine/storage/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/storage/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/storage/image/findbugsExcludeFilter.xml b/engine/storage/image/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/storage/image/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/storage/image/pom.xml b/engine/storage/image/pom.xml index 3ed801299e5..94716e5822a 100644 --- a/engine/storage/image/pom.xml +++ b/engine/storage/image/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java index db28a053c1a..134e74d58f6 100644 --- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java +++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java @@ -23,9 +23,6 @@ import java.util.List; import javax.inject.Inject; -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; @@ -34,6 +31,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; import org.apache.cloudstack.storage.image.store.TemplateObject; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.storage.DataStoreRole; import com.cloud.storage.VMTemplateStoragePoolVO; @@ -106,6 +105,17 @@ public class TemplateDataFactoryImpl implements TemplateDataFactory { return this.getTemplate(templateId, store); } + @Override + public TemplateInfo getReadyTemplateOnImageStore(long templateId, Long zoneId) { + TemplateDataStoreVO tmplStore = templateStoreDao.findByTemplateZoneReady(templateId, zoneId); + if (tmplStore != null) { + DataStore store = storeMgr.getDataStore(tmplStore.getDataStoreId(), DataStoreRole.Image); + return this.getTemplate(templateId, store); + } else { + return null; + } + } + @Override public TemplateInfo getTemplate(DataObject obj, DataStore store) { TemplateObject tmpObj = (TemplateObject)this.getTemplate(obj.getId(), store); diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java index 166b523e387..4e6ab6ba300 100644 --- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java +++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java @@ -777,12 +777,21 @@ public class TemplateServiceImpl implements TemplateService { String scheme = "http"; boolean _sslCopy = false; String sslCfg = _configDao.getValue(Config.SecStorageEncryptCopy.toString()); + String _ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain"); if (sslCfg != null) { _sslCopy = Boolean.parseBoolean(sslCfg); } + if(_sslCopy && (_ssvmUrlDomain == null || _ssvmUrlDomain.isEmpty())){ + s_logger.warn("Empty secondary storage url domain, ignoring SSL"); + _sslCopy = false; + } if (_sslCopy) { - hostname = ipAddress.replace(".", "-"); - hostname = hostname + ".realhostip.com"; + if(_ssvmUrlDomain.startsWith("*")) { + hostname = ipAddress.replace(".", "-"); + hostname = hostname + _ssvmUrlDomain.substring(1); + } else { + hostname = _ssvmUrlDomain; + } scheme = "https"; } return scheme + "://" + hostname + "/copy/SecStorage/" + dir + "/" + path; diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java index 503d3722528..7288d454c30 100644 --- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java +++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java @@ -29,6 +29,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event; +import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo; import org.apache.cloudstack.storage.command.CopyCmdAnswer; import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager; @@ -49,6 +50,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplatePoolDao; +import com.cloud.template.VirtualMachineTemplate; import com.cloud.utils.component.ComponentContext; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.fsm.NoTransitionException; @@ -298,6 +300,20 @@ public class TemplateObject implements TemplateInfo { if (dataStore == null) { return null; } + + // managed primary data stores should not have an install path + if (dataStore instanceof PrimaryDataStore) { + PrimaryDataStore primaryDataStore = (PrimaryDataStore)dataStore; + + Map details = primaryDataStore.getDetails(); + + boolean managed = details != null && Boolean.parseBoolean(details.get(PrimaryDataStore.MANAGED)); + + if (managed) { + return null; + } + } + DataObjectInStore obj = objectInStoreMgr.findObject(this, dataStore); return obj.getInstallPath(); } @@ -419,8 +435,8 @@ public class TemplateObject implements TemplateInfo { } @Override - public Boolean isDynamicallyScalable() { - return Boolean.FALSE; + public boolean isDynamicallyScalable() { + return false; } @Override @@ -436,4 +452,8 @@ public class TemplateObject implements TemplateInfo { return true; } + @Override + public Class getEntityType() { + return VirtualMachineTemplate.class; + } } diff --git a/engine/storage/integration-test/pom.xml b/engine/storage/integration-test/pom.xml index 7bb27e060e4..892a7c93a61 100644 --- a/engine/storage/integration-test/pom.xml +++ b/engine/storage/integration-test/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml @@ -121,11 +121,6 @@ httpclient compile - - mysql - mysql-connector-java - provided - org.testng testng diff --git a/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java b/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java index a16a3334d1e..38b4f29a324 100644 --- a/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java +++ b/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java @@ -41,7 +41,7 @@ public class VmSnapshotDaoTest extends CloudStackTestNGBase { @Test public void testVmSnapshotDetails() { - VMSnapshotDetailsVO detailsVO = new VMSnapshotDetailsVO(1L, "test", "foo"); + VMSnapshotDetailsVO detailsVO = new VMSnapshotDetailsVO(1L, "test", "foo", display); vmsnapshotDetailsDao.persist(detailsVO); Map details = vmsnapshotDetailsDao.listDetailsKeyPairs(1L); Assert.assertTrue(details.containsKey("test")); diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java index bb74a3780f0..3c4caee036e 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java @@ -251,7 +251,7 @@ public class StorageAllocatorTest { public void testClusterAllocatorWithTags() { try { createDb(); - StoragePoolDetailVO detailVO = new StoragePoolDetailVO(this.storagePoolId, "high", "true"); + StoragePoolDetailVO detailVO = new StoragePoolDetailVO(this.storagePoolId, "high", "true", true); poolDetailsDao.persist(detailVO); DiskOfferingVO diskOff = this.diskOfferingDao.findById(diskOffering.getId()); List tags = new ArrayList(); @@ -285,7 +285,7 @@ public class StorageAllocatorTest { public void testClusterAllocatorWithWrongTag() { try { createDb(); - StoragePoolDetailVO detailVO = new StoragePoolDetailVO(this.storagePoolId, "high", "true"); + StoragePoolDetailVO detailVO = new StoragePoolDetailVO(this.storagePoolId, "high", "true", true); poolDetailsDao.persist(detailVO); DiskOfferingVO diskOff = this.diskOfferingDao.findById(diskOffering.getId()); List tags = new ArrayList(); diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java index 69d60c26943..3af7df7ecfc 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java @@ -79,7 +79,6 @@ 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.secondary.SecondaryStorageVmManager; import com.cloud.tags.dao.ResourceTagsDaoImpl; import com.cloud.template.TemplateManager; import com.cloud.user.AccountManager; @@ -110,11 +109,6 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDaoImpl; useDefaultFilters = false) public class ChildTestConfiguration extends TestConfiguration { - @Bean - public SecondaryStorageVmManager secondaryStoreageMgr() { - return Mockito.mock(SecondaryStorageVmManager.class); - } - @Bean public HostDao hostDao() { return Mockito.spy(new HostDaoImpl()); diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java index 2a11e1337e6..accfeb5318e 100644 --- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java +++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java @@ -57,6 +57,11 @@ public class MockStorageMotionStrategy implements DataMotionStrategy { return StrategyPriority.HIGHEST; } + @Override + public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback callback) { + throw new UnsupportedOperationException(); + } + @Override public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback) { CopyCmdAnswer answer = null; diff --git a/engine/storage/pom.xml b/engine/storage/pom.xml index 49ff15add0a..0a1504110de 100644 --- a/engine/storage/pom.xml +++ b/engine/storage/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/engine/storage/snapshot/findbugsExcludeFilter.xml b/engine/storage/snapshot/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/storage/snapshot/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/storage/snapshot/pom.xml b/engine/storage/snapshot/pom.xml index e6819a6c42f..1d5b49159dc 100644 --- a/engine/storage/snapshot/pom.xml +++ b/engine/storage/snapshot/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java index 9cac20de95c..da8d341e49b 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java @@ -286,7 +286,10 @@ public class SnapshotObject implements SnapshotInfo { } else if (answer instanceof CopyCmdAnswer) { SnapshotObjectTO snapshotTO = (SnapshotObjectTO)((CopyCmdAnswer)answer).getNewData(); snapshotStore.setInstallPath(snapshotTO.getPath()); + if (snapshotTO.getPhysicalSize() != null) { + // For S3 delta snapshot, physical size is currently not set snapshotStore.setSize(snapshotTO.getPhysicalSize()); + } if (snapshotTO.getParentSnapshotPath() == null) { snapshotStore.setParentSnapshotId(0L); } @@ -377,4 +380,9 @@ public class SnapshotObject implements SnapshotInfo { } return true; } + + @Override + public Class getEntityType() { + return Snapshot.class; + } } diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java index d482e70b464..684b5bd29c9 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java @@ -302,6 +302,10 @@ public class SnapshotServiceImpl implements SnapshotService { if (result.isFailed()) { try { destSnapshot.processEvent(Event.OperationFailed); + //if backup snapshot failed, mark srcSnapshot in snapshot_store_ref as failed also + srcSnapshot.processEvent(Event.DestroyRequested); + srcSnapshot.processEvent(Event.OperationSuccessed); + srcSnapshot.processEvent(Snapshot.Event.OperationFailed); } catch (NoTransitionException e) { s_logger.debug("Failed to update state: " + e.toString()); @@ -442,10 +446,7 @@ public class SnapshotServiceImpl implements SnapshotService { } // push one individual snapshots currently on cache store to region store if it is not there already - private void syncSnapshotToRegionStore(long snapshotId, DataStore store) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("sync snapshot " + snapshotId + " from cache to object store..."); - } + private void syncSnapshotToRegionStore(long snapshotId, DataStore store){ // if snapshot is already on region wide object store, check if it is really downloaded there (by checking install_path). Sync snapshot to region // wide store if it is not there physically. SnapshotInfo snapOnStore = _snapshotFactory.getSnapshot(snapshotId, store); @@ -453,6 +454,9 @@ public class SnapshotServiceImpl implements SnapshotService { throw new CloudRuntimeException("Cannot find an entry in snapshot_store_ref for snapshot " + snapshotId + " on region store: " + store.getName()); } if (snapOnStore.getPath() == null || snapOnStore.getPath().length() == 0) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("sync snapshot " + snapshotId + " from cache to object store..."); + } // snapshot is not on region store yet, sync to region store SnapshotInfo srcSnapshot = _snapshotFactory.getReadySnapshotOnCache(snapshotId); if (srcSnapshot == null) { diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java index ad7e0f3e3d8..8d6886ebfb9 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java @@ -197,6 +197,11 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase { return true; } + if (Snapshot.State.Error.equals(snapshotVO.getState())) { + snapshotDao.remove(snapshotId); + return true; + } + if (snapshotVO.getState() == Snapshot.State.CreatedOnPrimary) { s_logger.debug("delete snapshot on primary storage:"); snapshotVO.setState(Snapshot.State.Destroyed); diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java index aab38769731..ddbb5a467bf 100755 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java @@ -27,12 +27,11 @@ import java.util.Random; import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.apache.log4j.Logger; - import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; +import org.apache.log4j.Logger; import com.cloud.dc.ClusterVO; import com.cloud.dc.dao.ClusterDao; diff --git a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java index af228107811..ea084c75554 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java +++ b/engine/storage/src/org/apache/cloudstack/storage/allocator/ClusterScopeStoragePoolAllocator.java @@ -25,11 +25,10 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlanner.ExcludeList; diff --git a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java index 51c04bf2fc2..304f9595cbf 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java +++ b/engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java @@ -166,10 +166,11 @@ public class DefaultEndPointSelector implements EndPointSelector { poolId = destStore.getId(); } else { // if both are zone scope - selectedScope = srcScope; if (srcStore.getRole() == DataStoreRole.Primary) { + selectedScope = srcScope; poolId = srcStore.getId(); } else if (destStore.getRole() == DataStoreRole.Primary) { + selectedScope = destScope; poolId = destStore.getId(); } } @@ -304,6 +305,15 @@ public class DefaultEndPointSelector implements EndPointSelector { return getEndPointFromHostId(hostId); } } + } else if (action == StorageAction.MIGRATEVOLUME) { + VolumeInfo volume = (VolumeInfo)object; + if (volume.getHypervisorType() == Hypervisor.HypervisorType.Hyperv) { + VirtualMachine vm = volume.getAttachedVM(); + if ((vm != null) && (vm.getState() == VirtualMachine.State.Running)) { + Long hostId = vm.getHostId(); + return getEndPointFromHostId(hostId); + } + } } return select(object); } diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java index ed6b5099a92..c1aa8c2f0d4 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/TemplateEntityImpl.java @@ -30,6 +30,7 @@ import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.TemplateType; +import com.cloud.template.VirtualMachineTemplate; public class TemplateEntityImpl implements TemplateEntity { protected TemplateInfo templateInfo; @@ -107,8 +108,8 @@ public class TemplateEntityImpl implements TemplateEntity { } @Override - public Boolean isDynamicallyScalable() { - return null; //To change body of implemented methods use File | Settings | File Templates. + public boolean isDynamicallyScalable() { + return false; } @Override @@ -285,4 +286,8 @@ public class TemplateEntityImpl implements TemplateEntity { return 0; } + @Override + public Class getEntityType() { + return VirtualMachineTemplate.class; + } } diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java index a4c423c861b..5e29f7136aa 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/datastore/ImageStoreHelper.java @@ -18,6 +18,8 @@ */ package org.apache.cloudstack.storage.image.datastore; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.Iterator; import java.util.Map; import java.util.UUID; @@ -34,6 +36,7 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreDetailsDao; import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao; +import com.cloud.exception.InvalidParameterValueException; import com.cloud.storage.DataStoreRole; import com.cloud.storage.ScopeType; import com.cloud.utils.crypt.DBEncryptionUtil; @@ -95,7 +98,30 @@ public class ImageStoreHelper { if (store.getName() == null) { store.setName(store.getUuid()); } + store.setRole((DataStoreRole)params.get("role")); + + if ("cifs".equalsIgnoreCase((String) params.get("protocol")) && details != null) { + String user = details.get("user"); + String password = details.get("password"); + String domain = details.get("domain"); + String updatedPath = (String) params.get("url"); + + if (user == null || password == null) { + String errMsg = "Missing cifs user and password details. Add them as details parameter."; + throw new InvalidParameterValueException(errMsg); + } else { + try { + password = DBEncryptionUtil.encrypt(URLEncoder.encode(password, "UTF-8")); + details.put("password", password); + updatedPath += "?user=" + user + "&password=" + password + "&domain=" + domain; + } catch (UnsupportedEncodingException e) { + throw new CloudRuntimeException("Error while generating the cifs url. " + e.getMessage()); + } + store.setUrl(updatedPath); + } + } + store = imageStoreDao.persist(store); // persist details diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java index d4b0445be7e..cce7f082446 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java @@ -400,6 +400,22 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase imgStores = null; + imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId)); + if (imgStores != null) { + Collections.shuffle(imgStores); + for (DataStore store : imgStores) { + List sRes = listByTemplateStoreStatus(templateId, store.getId(), State.Ready); + if (sRes != null && sRes.size() > 0) { + return sRes.get(0); + } + } + } + return null; + } + /** * Duplicate all image cache store entries */ diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java b/engine/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java index 9523d24c14e..5a424cb8f22 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/format/ImageFormatHelper.java @@ -36,7 +36,7 @@ public class ImageFormatHelper { public static ImageFormat getFormat(String format) { for (ImageFormat fm : formats) { - if (fm.equals(format)) { + if (fm.toString().equals(format)) { return fm; } } diff --git a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java index fb3ec48d744..a660f412113 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/snapshot/SnapshotEntityImpl.java @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity; import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.storage.Snapshot; public class SnapshotEntityImpl implements SnapshotEntity { @@ -183,4 +184,8 @@ public class SnapshotEntityImpl implements SnapshotEntity { return null; } + @Override + public Class getEntityType() { + return Snapshot.class; + } } diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java index 21cefb7a61e..6b129755009 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java +++ b/engine/storage/src/org/apache/cloudstack/storage/volume/datastore/PrimaryDataStoreHelper.java @@ -18,6 +18,8 @@ */ package org.apache.cloudstack.storage.volume.datastore; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.List; import java.util.Map; @@ -38,12 +40,15 @@ import com.cloud.capacity.Capacity; import com.cloud.capacity.CapacityVO; import com.cloud.capacity.dao.CapacityDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.exception.InvalidParameterValueException; import com.cloud.storage.DataStoreRole; import com.cloud.storage.ScopeType; import com.cloud.storage.StorageManager; import com.cloud.storage.StoragePoolHostVO; import com.cloud.storage.StoragePoolStatus; +import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.dao.StoragePoolHostDao; +import com.cloud.utils.crypt.DBEncryptionUtil; import com.cloud.utils.db.TransactionLegacy; import com.cloud.utils.exception.CloudRuntimeException; @@ -70,8 +75,8 @@ public class PrimaryDataStoreHelper { dataStoreVO = new StoragePoolVO(); dataStoreVO.setStorageProviderName(params.getProviderName()); dataStoreVO.setHostAddress(params.getHost()); - dataStoreVO.setPath(params.getPath()); dataStoreVO.setPoolType(params.getType()); + dataStoreVO.setPath(params.getPath()); dataStoreVO.setPort(params.getPort()); dataStoreVO.setName(params.getName()); dataStoreVO.setUuid(params.getUuid()); @@ -87,6 +92,29 @@ public class PrimaryDataStoreHelper { dataStoreVO.setHypervisor(params.getHypervisorType()); Map details = params.getDetails(); + if (params.getType() == StoragePoolType.SMB && details != null) { + String user = details.get("user"); + String password = details.get("password"); + String domain = details.get("domain"); + String updatedPath = params.getPath(); + + if (user == null || password == null) { + String errMsg = "Missing cifs user and password details. Add them as details parameter."; + s_logger.warn(errMsg); + throw new InvalidParameterValueException(errMsg); + } else { + try { + password = DBEncryptionUtil.encrypt(URLEncoder.encode(password, "UTF-8")); + details.put("password", password); + updatedPath += "?user=" + user + "&password=" + password + "&domain=" + domain; + } catch (UnsupportedEncodingException e) { + throw new CloudRuntimeException("Error while generating the cifs url. " + e.getMessage()); + } + } + + dataStoreVO.setPath(updatedPath); + } + String tags = params.getTags(); if (tags != null) { String[] tokens = tags.split(","); diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java index 8ba3e12a1a0..a520e3216bf 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java +++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java @@ -26,8 +26,8 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDetailsDao; public class PrimaryDataStoreDetailsDaoImpl extends ResourceDetailsDaoBase implements PrimaryDataStoreDetailsDao { @Override - public void addDetail(long resourceId, String key, String value) { - super.addDetail(new PrimaryDataStoreDetailVO(resourceId, key, value)); + public void addDetail(long resourceId, String key, String value, boolean display) { + super.addDetail(new PrimaryDataStoreDetailVO(resourceId, key, value, display)); } } diff --git a/engine/storage/volume/findbugsExcludeFilter.xml b/engine/storage/volume/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/engine/storage/volume/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/engine/storage/volume/pom.xml b/engine/storage/volume/pom.xml index afecb653705..0ea01f3090b 100644 --- a/engine/storage/volume/pom.xml +++ b/engine/storage/volume/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloud-engine - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java index 8591ff676f0..f3c9e790277 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java @@ -20,11 +20,10 @@ import java.io.File; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; import javax.inject.Inject; -import org.apache.log4j.Logger; - import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver; @@ -46,6 +45,7 @@ import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; import org.apache.cloudstack.storage.volume.VolumeObject; +import org.apache.log4j.Logger; import com.cloud.agent.api.to.DataObjectType; import com.cloud.agent.api.to.DataStoreTO; @@ -67,6 +67,7 @@ import com.cloud.utils.storage.encoding.EncodingType; public class PrimaryDataStoreImpl implements PrimaryDataStore { private static final Logger s_logger = Logger.getLogger(PrimaryDataStoreImpl.class); + protected PrimaryDataStoreDriver driver; protected StoragePoolVO pdsv; @Inject @@ -86,6 +87,7 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore { @Inject private VolumeDao volumeDao; + private Map _details; public PrimaryDataStoreImpl() { @@ -135,16 +137,25 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore { return pdsv.getId(); } + @Override + public void setDetails(Map details) { + _details = details; + } + + @Override + public Map getDetails() { + return _details; + } + @Override public String getUri() { - String path = pdsv.getPath(); - path.replaceFirst("/*", ""); + String path = pdsv.getPath().replaceFirst("/*", ""); StringBuilder builder = new StringBuilder(); builder.append(pdsv.getPoolType()); builder.append("://"); builder.append(pdsv.getHostAddress()); builder.append(File.separator); - builder.append(pdsv.getPath()); + builder.append(path); builder.append(File.separator); builder.append("?" + EncodingType.ROLE + "=" + getRole()); builder.append("&" + EncodingType.STOREUUID + "=" + pdsv.getUuid()); @@ -223,10 +234,15 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore { return null; } + @Override + public boolean isManaged() { + return pdsv.isManaged(); + } + @Override public DataObject create(DataObject obj) { // create template on primary storage - if (obj.getType() == DataObjectType.TEMPLATE) { + if (obj.getType() == DataObjectType.TEMPLATE && !isManaged()) { try { String templateIdPoolIdString = "templateId:" + obj.getId() + "poolId:" + getId(); VMTemplateStoragePoolVO templateStoragePoolRef; @@ -374,6 +390,11 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore { getStatus() == StoragePoolStatus.ErrorInMaintenance || getRemoved() != null; } + @Override + public HypervisorType getHypervisor() { + return pdsv.getHypervisor(); + } + @Override public String getStorageProviderName() { return pdsv.getStorageProviderName(); diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java index 4838bf678e0..fffd1e815c4 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java @@ -85,7 +85,7 @@ public class DefaultHostListener implements HypervisorHostListener { poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes()); primaryStoreDao.update(pool.getId(), poolVO); - s_logger.info("Connection established between " + pool + " host + " + hostId); + s_logger.info("Connection established between storage pool " + pool + " and host " + hostId); return true; } diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java index fd0f2c1e19d..385f8e63e96 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java @@ -22,9 +22,6 @@ import javax.inject.Inject; import org.apache.log4j.Logger; -import com.cloud.storage.DiskOfferingVO; -import com.cloud.storage.dao.DiskOfferingDao; -import com.cloud.vm.VirtualMachine; import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; @@ -43,9 +40,11 @@ import com.cloud.agent.api.to.DataTO; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.offering.DiskOffering.DiskCacheMode; import com.cloud.storage.DataStoreRole; +import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Volume; import com.cloud.storage.VolumeVO; +import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.storage.dao.VolumeDao; import com.cloud.utils.component.ComponentContext; import com.cloud.utils.exception.CloudRuntimeException; @@ -53,6 +52,7 @@ import com.cloud.utils.fsm.NoTransitionException; import com.cloud.utils.fsm.StateMachine2; import com.cloud.utils.storage.encoding.EncodingType; import com.cloud.vm.VMInstanceVO; +import com.cloud.vm.VirtualMachine; import com.cloud.vm.dao.VMInstanceDao; public class VolumeObject implements VolumeInfo { @@ -89,7 +89,7 @@ public class VolumeObject implements VolumeInfo { @Override public String getAttachedVmName() { - Long vmId = this.volumeVO.getInstanceId(); + Long vmId = volumeVO.getInstanceId(); if (vmId != null) { VMInstanceVO vm = vmInstanceDao.findById(vmId); @@ -103,7 +103,7 @@ public class VolumeObject implements VolumeInfo { @Override public VirtualMachine getAttachedVM() { - Long vmId = this.volumeVO.getInstanceId(); + Long vmId = volumeVO.getInstanceId(); if (vmId != null) { VMInstanceVO vm = vmInstanceDao.findById(vmId); return vm; @@ -162,6 +162,11 @@ public class VolumeObject implements VolumeInfo { return volumeVO.getHypervisorSnapshotReserve(); } + @Override + public boolean isDisplayVolume() { + return volumeVO.isDisplayVolume(); + } + public long getVolumeId() { return volumeVO.getId(); } @@ -174,7 +179,7 @@ public class VolumeObject implements VolumeInfo { result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao); volumeVO = volumeDao.findById(volumeVO.getId()); } catch (NoTransitionException e) { - String errorMessage = "Failed to transit volume: " + this.getVolumeId() + ", due to: " + e.toString(); + String errorMessage = "Failed to transit volume: " + getVolumeId() + ", due to: " + e.toString(); s_logger.debug(errorMessage); throw new CloudRuntimeException(errorMessage); } @@ -241,25 +246,25 @@ public class VolumeObject implements VolumeInfo { @Override public long getId() { - return this.volumeVO.getId(); + return volumeVO.getId(); } @Override public boolean isAttachedVM() { - return (this.volumeVO.getInstanceId() == null) ? false : true; + return (volumeVO.getInstanceId() == null) ? false : true; } @Override public String getUri() { - if (this.dataStore == null) { + if (dataStore == null) { throw new CloudRuntimeException("datastore must be set before using this object"); } - DataObjectInStore obj = objectInStoreMgr.findObject(this.volumeVO.getId(), DataObjectType.VOLUME, this.dataStore.getId(), this.dataStore.getRole()); + DataObjectInStore obj = objectInStoreMgr.findObject(volumeVO.getId(), DataObjectType.VOLUME, dataStore.getId(), dataStore.getRole()); if (obj.getState() != ObjectInDataStoreStateMachine.State.Ready) { - return this.dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + this.volumeVO.getSize() + "&" + - EncodingType.NAME + "=" + this.volumeVO.getName(); + return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + volumeVO.getSize() + "&" + + EncodingType.NAME + "=" + volumeVO.getName(); } else { - return this.dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.PATH + "=" + obj.getInstallPath(); + return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.PATH + "=" + obj.getInstallPath(); } } @@ -270,19 +275,19 @@ public class VolumeObject implements VolumeInfo { @Override public void processEvent(ObjectInDataStoreStateMachine.Event event) { - if (this.dataStore == null) { + if (dataStore == null) { return; } try { Volume.Event volEvent = null; - if (this.dataStore.getRole() == DataStoreRole.ImageCache) { + if (dataStore.getRole() == DataStoreRole.ImageCache) { objectInStoreMgr.update(this, event); return; } - if (this.dataStore.getRole() == DataStoreRole.Image) { + if (dataStore.getRole() == DataStoreRole.Image) { objectInStoreMgr.update(this, event); - if (this.volumeVO.getState() == Volume.State.Migrating || this.volumeVO.getState() == Volume.State.Copying || - this.volumeVO.getState() == Volume.State.Uploaded || this.volumeVO.getState() == Volume.State.Expunged) { + if (volumeVO.getState() == Volume.State.Migrating || volumeVO.getState() == Volume.State.Copying || + volumeVO.getState() == Volume.State.Uploaded || volumeVO.getState() == Volume.State.Expunged) { return; } if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) { @@ -311,14 +316,14 @@ public class VolumeObject implements VolumeInfo { } else if (event == ObjectInDataStoreStateMachine.Event.ResizeRequested) { volEvent = Volume.Event.ResizeRequested; } - this.stateTransit(volEvent); + stateTransit(volEvent); } catch (Exception e) { s_logger.debug("Failed to update state", e); throw new CloudRuntimeException("Failed to update state:" + e.toString()); } finally { // in case of OperationFailed, expunge the entry if (event == ObjectInDataStoreStateMachine.Event.OperationFailed && - (this.volumeVO.getState() != Volume.State.Copying && this.volumeVO.getState() != Volume.State.Uploaded)) { + (volumeVO.getState() != Volume.State.Copying && volumeVO.getState() != Volume.State.Uploaded)) { objectInStoreMgr.deleteIfNotReady(this); } } @@ -342,25 +347,25 @@ public class VolumeObject implements VolumeInfo { @Override public String getName() { - return this.volumeVO.getName(); + return volumeVO.getName(); } @Override public Long getInstanceId() { - return this.volumeVO.getInstanceId(); + return volumeVO.getInstanceId(); } @Override public String getFolder() { - return this.volumeVO.getFolder(); + return volumeVO.getFolder(); } @Override public String getPath() { - if (this.dataStore.getRole() == DataStoreRole.Primary) { - return this.volumeVO.getPath(); + if (dataStore.getRole() == DataStoreRole.Primary) { + return volumeVO.getPath(); } else { - DataObjectInStore objInStore = this.objectInStoreMgr.findObject(this, dataStore); + DataObjectInStore objInStore = objectInStoreMgr.findObject(this, dataStore); if (objInStore != null) { return objInStore.getInstallPath(); } else { @@ -371,121 +376,121 @@ public class VolumeObject implements VolumeInfo { @Override public Long getPodId() { - return this.volumeVO.getPodId(); + return volumeVO.getPodId(); } @Override public long getDataCenterId() { - return this.volumeVO.getDataCenterId(); + return volumeVO.getDataCenterId(); } @Override public Type getVolumeType() { - return this.volumeVO.getVolumeType(); + return volumeVO.getVolumeType(); } @Override public Long getPoolId() { - return this.volumeVO.getPoolId(); + return volumeVO.getPoolId(); } @Override public Date getAttached() { - return this.volumeVO.getAttached(); + return volumeVO.getAttached(); } @Override public Long getDeviceId() { - return this.volumeVO.getDeviceId(); + return volumeVO.getDeviceId(); } @Override public Date getCreated() { - return this.volumeVO.getCreated(); + return volumeVO.getCreated(); } @Override public Long getDiskOfferingId() { - return this.volumeVO.getDiskOfferingId(); + return volumeVO.getDiskOfferingId(); } @Override public String getChainInfo() { - return this.volumeVO.getChainInfo(); + return volumeVO.getChainInfo(); } @Override public boolean isRecreatable() { - return this.volumeVO.isRecreatable(); + return volumeVO.isRecreatable(); } @Override public long getUpdatedCount() { - return this.volumeVO.getUpdatedCount(); + return volumeVO.getUpdatedCount(); } @Override public void incrUpdatedCount() { - this.volumeVO.incrUpdatedCount(); + volumeVO.incrUpdatedCount(); } @Override public Date getUpdated() { - return this.volumeVO.getUpdated(); + return volumeVO.getUpdated(); } @Override public String getReservationId() { - return this.volumeVO.getReservationId(); + return volumeVO.getReservationId(); } @Override public void setReservationId(String reserv) { - this.volumeVO.setReservationId(reserv); + volumeVO.setReservationId(reserv); } @Override public long getAccountId() { - return this.volumeVO.getAccountId(); + return volumeVO.getAccountId(); } @Override public long getDomainId() { - return this.volumeVO.getDomainId(); + return volumeVO.getDomainId(); } @Override public Long getTemplateId() { - return this.volumeVO.getTemplateId(); + return volumeVO.getTemplateId(); } @Override public void addPayload(Object data) { - this.payload = data; + payload = data; } @Override public Object getpayload() { - return this.payload; + return payload; } public VolumeVO getVolume() { - return this.volumeVO; + return volumeVO; } @Override public HypervisorType getHypervisorType() { - return this.volumeDao.getHypervisorType(this.volumeVO.getId()); + return volumeDao.getHypervisorType(volumeVO.getId()); } @Override public Long getLastPoolId() { - return this.volumeVO.getLastPoolId(); + return volumeVO.getLastPoolId(); } @Override public DataTO getTO() { - DataTO to = this.getDataStore().getDriver().getTO(this); + DataTO to = getDataStore().getDriver().getTO(this); if (to == null) { to = new VolumeObjectTO(this); } @@ -495,10 +500,10 @@ public class VolumeObject implements VolumeInfo { @Override public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) { try { - if (this.dataStore.getRole() == DataStoreRole.Primary) { + if (dataStore.getRole() == DataStoreRole.Primary) { if (answer instanceof CopyCmdAnswer) { CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer; - VolumeVO vol = this.volumeDao.findById(this.getId()); + VolumeVO vol = volumeDao.findById(getId()); VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData(); vol.setPath(newVol.getPath()); if (newVol.getSize() != null) { @@ -507,17 +512,17 @@ public class VolumeObject implements VolumeInfo { if (newVol.getFormat() != null) { vol.setFormat(newVol.getFormat()); } - vol.setPoolId(this.getDataStore().getId()); + vol.setPoolId(getDataStore().getId()); volumeDao.update(vol.getId(), vol); } else if (answer instanceof CreateObjectAnswer) { CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer; VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData(); - VolumeVO vol = this.volumeDao.findById(this.getId()); + VolumeVO vol = volumeDao.findById(getId()); vol.setPath(newVol.getPath()); if (newVol.getSize() != null) { vol.setSize(newVol.getSize()); } - vol.setPoolId(this.getDataStore().getId()); + vol.setPoolId(getDataStore().getId()); if (newVol.getFormat() != null) { vol.setFormat(newVol.getFormat()); } @@ -527,19 +532,19 @@ public class VolumeObject implements VolumeInfo { // image store or imageCache store if (answer instanceof DownloadAnswer) { DownloadAnswer dwdAnswer = (DownloadAnswer)answer; - VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); + VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); volStore.setInstallPath(dwdAnswer.getInstallPath()); volStore.setChecksum(dwdAnswer.getCheckSum()); - this.volumeStoreDao.update(volStore.getId(), volStore); + volumeStoreDao.update(volStore.getId(), volStore); } else if (answer instanceof CopyCmdAnswer) { CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer; - VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); + VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData(); volStore.setInstallPath(newVol.getPath()); if (newVol.getSize() != null) { volStore.setSize(newVol.getSize()); } - this.volumeStoreDao.update(volStore.getId(), volStore); + volumeStoreDao.update(volStore.getId(), volStore); } } } catch (RuntimeException ex) { @@ -554,12 +559,12 @@ public class VolumeObject implements VolumeInfo { @Override public void incRefCount() { - if (this.dataStore == null) { + if (dataStore == null) { return; } - if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) { - VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); + if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { + VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); store.incrRefCnt(); store.setLastUpdated(new Date()); volumeStoreDao.update(store.getId(), store); @@ -568,11 +573,11 @@ public class VolumeObject implements VolumeInfo { @Override public void decRefCount() { - if (this.dataStore == null) { + if (dataStore == null) { return; } - if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) { - VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); + if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { + VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); store.decrRefCnt(); store.setLastUpdated(new Date()); volumeStoreDao.update(store.getId(), store); @@ -581,11 +586,11 @@ public class VolumeObject implements VolumeInfo { @Override public Long getRefCount() { - if (this.dataStore == null) { + if (dataStore == null) { return null; } - if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) { - VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); + if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) { + VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); return store.getRefCnt(); } return null; @@ -594,45 +599,45 @@ public class VolumeObject implements VolumeInfo { @Override public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) { try { - if (this.dataStore.getRole() == DataStoreRole.Primary) { + if (dataStore.getRole() == DataStoreRole.Primary) { if (answer instanceof CopyCmdAnswer) { CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer; - VolumeVO vol = this.volumeDao.findById(this.getId()); + VolumeVO vol = volumeDao.findById(getId()); VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData(); vol.setPath(newVol.getPath()); if (newVol.getSize() != null) { vol.setSize(newVol.getSize()); } - vol.setPoolId(this.getDataStore().getId()); + vol.setPoolId(getDataStore().getId()); volumeDao.update(vol.getId(), vol); } else if (answer instanceof CreateObjectAnswer) { CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer; VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData(); - VolumeVO vol = this.volumeDao.findById(this.getId()); + VolumeVO vol = volumeDao.findById(getId()); vol.setPath(newVol.getPath()); if (newVol.getSize() != null) { vol.setSize(newVol.getSize()); } - vol.setPoolId(this.getDataStore().getId()); + vol.setPoolId(getDataStore().getId()); volumeDao.update(vol.getId(), vol); } } else { // image store or imageCache store if (answer instanceof DownloadAnswer) { DownloadAnswer dwdAnswer = (DownloadAnswer)answer; - VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); + VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); volStore.setInstallPath(dwdAnswer.getInstallPath()); volStore.setChecksum(dwdAnswer.getCheckSum()); - this.volumeStoreDao.update(volStore.getId(), volStore); + volumeStoreDao.update(volStore.getId(), volStore); } else if (answer instanceof CopyCmdAnswer) { CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer; - VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); + VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId()); VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData(); volStore.setInstallPath(newVol.getPath()); if (newVol.getSize() != null) { volStore.setSize(newVol.getSize()); } - this.volumeStoreDao.update(volStore.getId(), volStore); + volumeStoreDao.update(volStore.getId(), volStore); } } } catch (RuntimeException ex) { @@ -647,7 +652,7 @@ public class VolumeObject implements VolumeInfo { @Override public ImageFormat getFormat() { - return this.volumeVO.getFormat(); + return volumeVO.getFormat(); } @Override @@ -660,6 +665,11 @@ public class VolumeObject implements VolumeInfo { @Override public Long getVmSnapshotChainSize() { - return this.volumeVO.getVmSnapshotChainSize(); + return volumeVO.getVmSnapshotChainSize(); + } + + @Override + public Class getEntityType() { + return Volume.class; } } diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java index 3e5a5466fd0..3a71147f8aa 100644 --- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java +++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java @@ -20,14 +20,12 @@ package org.apache.cloudstack.storage.volume; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; import javax.inject.Inject; -import org.apache.log4j.Logger; -import org.springframework.stereotype.Component; - import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity; import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo; import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; @@ -59,7 +57,10 @@ import org.apache.cloudstack.storage.command.DeleteCommand; import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; +import org.apache.cloudstack.storage.to.TemplateObjectTO; import org.apache.cloudstack.storage.to.VolumeObjectTO; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; import com.cloud.agent.api.Answer; import com.cloud.agent.api.storage.ListVolumeAnswer; @@ -73,8 +74,10 @@ import com.cloud.event.UsageEventUtils; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ResourceAllocationException; import com.cloud.host.Host; +import com.cloud.host.dao.HostDao; import com.cloud.storage.DataStoreRole; import com.cloud.storage.ScopeType; +import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StoragePool; import com.cloud.storage.VMTemplateStoragePoolVO; import com.cloud.storage.VMTemplateStorageResourceAssoc; @@ -122,6 +125,8 @@ public class VolumeServiceImpl implements VolumeService { VolumeDao _volumeDao; @Inject EndPointSelector _epSelector; + @Inject + HostDao _hostDao; public VolumeServiceImpl() { } @@ -349,6 +354,39 @@ public class VolumeServiceImpl implements VolumeService { return null; } + private class ManagedCreateBaseImageContext extends AsyncRpcContext { + private final VolumeInfo _volumeInfo; + private final PrimaryDataStore _primaryDataStore; + private final TemplateInfo _templateInfo; + private final AsyncCallFuture _future; + + public ManagedCreateBaseImageContext(AsyncCompletionCallback callback, VolumeInfo volumeInfo, + PrimaryDataStore primaryDatastore, TemplateInfo templateInfo, AsyncCallFuture future) { + super(callback); + + _volumeInfo = volumeInfo; + _primaryDataStore = primaryDatastore; + _templateInfo = templateInfo; + _future = future; + } + + public VolumeInfo getVolumeInfo() { + return _volumeInfo; + } + + public PrimaryDataStore getPrimaryDataStore() { + return _primaryDataStore; + } + + public TemplateInfo getTemplateInfo() { + return _templateInfo; + } + + public AsyncCallFuture getFuture() { + return _future; + } + } + class CreateBaseImageContext extends AsyncRpcContext { private final VolumeInfo volume; private final PrimaryDataStore dataStore; @@ -411,7 +449,6 @@ public class VolumeServiceImpl implements VolumeService { @DB protected void createBaseImageAsync(VolumeInfo volume, PrimaryDataStore dataStore, TemplateInfo template, AsyncCallFuture future) { - DataObject templateOnPrimaryStoreObj = dataStore.create(template); VMTemplateStoragePoolVO templatePoolRef = _tmpltPoolDao.findByPoolTemplate(dataStore.getId(), template.getId()); @@ -420,12 +457,12 @@ public class VolumeServiceImpl implements VolumeService { } else { if (s_logger.isDebugEnabled()) { s_logger.debug("Found template " + template.getUniqueName() + " in storage pool " + dataStore.getId() + " with VMTemplateStoragePool id: " + - templatePoolRef.getId()); + templatePoolRef.getId()); } } long templatePoolRefId = templatePoolRef.getId(); CreateBaseImageContext context = - new CreateBaseImageContext(null, volume, dataStore, template, future, templateOnPrimaryStoreObj, templatePoolRefId); + new CreateBaseImageContext(null, volume, dataStore, template, future, templateOnPrimaryStoreObj, templatePoolRefId); AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().copyBaseImageCallback(null, null)).setContext(context); @@ -440,9 +477,9 @@ public class VolumeServiceImpl implements VolumeService { s_logger.info("Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId); } templatePoolRef = _tmpltPoolDao.findByPoolTemplate(dataStore.getId(), template.getId()); - if (templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) { + if (templatePoolRef != null && templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) { s_logger.info("Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId + ", But Template " + template.getUniqueName() + - " is already copied to primary storage, skip copying"); + " is already copied to primary storage, skip copying"); createVolumeFromBaseImageAsync(volume, templateOnPrimaryStoreObj, dataStore, future); return; } @@ -476,6 +513,40 @@ public class VolumeServiceImpl implements VolumeService { return; } + protected Void managedCopyBaseImageCallback(AsyncCallbackDispatcher callback, + ManagedCreateBaseImageContext context) { + CopyCommandResult result = callback.getResult(); + VolumeInfo volumeInfo = context.getVolumeInfo(); + VolumeApiResult res = new VolumeApiResult(volumeInfo); + + if (result.isSuccess()) { + // volumeInfo.processEvent(Event.OperationSuccessed, result.getAnswer()); + + VolumeVO volume = volDao.findById(volumeInfo.getId()); + CopyCmdAnswer answer = (CopyCmdAnswer)result.getAnswer(); + TemplateObjectTO templateObjectTo = (TemplateObjectTO)answer.getNewData(); + + volume.setPath(templateObjectTo.getPath()); + + if (templateObjectTo.getFormat() != null) { + volume.setFormat(templateObjectTo.getFormat()); + } + + volDao.update(volume.getId(), volume); + } + else { + volumeInfo.processEvent(Event.DestroyRequested); + + res.setResult(result.getResult()); + } + + AsyncCallFuture future = context.getFuture(); + + future.complete(res); + + return null; + } + @DB protected Void copyBaseImageCallback(AsyncCallbackDispatcher callback, CreateBaseImageContext context) { CopyCommandResult result = callback.getResult(); @@ -523,7 +594,7 @@ public class VolumeServiceImpl implements VolumeService { volumeOnPrimaryStorage.processEvent(Event.CreateOnlyRequested); CreateVolumeFromBaseImageContext context = - new CreateVolumeFromBaseImageContext(null, volumeOnPrimaryStorage, pd, templateOnPrimaryStore, future, null); + new CreateVolumeFromBaseImageContext(null, volumeOnPrimaryStorage, pd, templateOnPrimaryStore, future, null); AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().createVolumeFromBaseImageCallBack(null, null)); caller.setContext(context); @@ -534,7 +605,7 @@ public class VolumeServiceImpl implements VolumeService { @DB protected Void createVolumeFromBaseImageCallBack(AsyncCallbackDispatcher callback, - CreateVolumeFromBaseImageContext context) { + CreateVolumeFromBaseImageContext context) { DataObject vo = context.vo; DataObject tmplOnPrimary = context.templateOnStore; CopyCommandResult result = callback.getResult(); @@ -556,15 +627,15 @@ public class VolumeServiceImpl implements VolumeService { if (templatePoolRef != null) { long templatePoolRefId = templatePoolRef.getId(); templatePoolRef = _tmpltPoolDao.acquireInLockTable(templatePoolRefId, 1200); - if (templatePoolRef == null) { - s_logger.warn("Reset Template State On Pool failed - unable to lock TemplatePoolRef " + templatePoolRefId); - } - try { - templatePoolRef.setDownloadState(VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED); - templatePoolRef.setState(ObjectInDataStoreStateMachine.State.Allocated); - _tmpltPoolDao.update(templatePoolRefId, templatePoolRef); - } finally { + if (templatePoolRef == null) { + s_logger.warn("Reset Template State On Pool failed - unable to lock TemplatePoolRef " + templatePoolRefId); + } else { + templatePoolRef.setDownloadState(VMTemplateStorageResourceAssoc.Status.NOT_DOWNLOADED); + templatePoolRef.setState(ObjectInDataStoreStateMachine.State.Allocated); + _tmpltPoolDao.update(templatePoolRefId, templatePoolRef); + } + }finally { _tmpltPoolDao.releaseFromLockTable(templatePoolRefId); } } @@ -577,6 +648,92 @@ public class VolumeServiceImpl implements VolumeService { return null; } + @Override + public AsyncCallFuture createManagedStorageAndVolumeFromTemplateAsync(VolumeInfo volumeInfo, long destDataStoreId, + TemplateInfo srcTemplateInfo, long destHostId) { + PrimaryDataStore destPrimaryDataStore = dataStoreMgr.getPrimaryDataStore(destDataStoreId); + TemplateInfo destTemplateInfo = (TemplateInfo)destPrimaryDataStore.create(srcTemplateInfo); + Host destHost = _hostDao.findById(destHostId); + + if (destHost == null) { + throw new CloudRuntimeException("Destinatin host should not be null."); + } + + AsyncCallFuture future = new AsyncCallFuture(); + + try { + // must call driver to have a volume created + AsyncCallFuture createVolumeFuture = createVolumeAsync(volumeInfo, destPrimaryDataStore); + + VolumeApiResult createVolumeResult = createVolumeFuture.get(); + + if (createVolumeResult.isFailed()) { + throw new CloudRuntimeException("Creation of a volume failed: " + createVolumeResult.getResult()); + } + + // refresh the volume from the DB + volumeInfo = volFactory.getVolume(volumeInfo.getId(), destPrimaryDataStore); + + connectVolumeToHost(volumeInfo, destHost, destPrimaryDataStore); + + ManagedCreateBaseImageContext context = new ManagedCreateBaseImageContext(null, volumeInfo, + destPrimaryDataStore, srcTemplateInfo, future); + AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); + caller.setCallback(caller.getTarget().managedCopyBaseImageCallback(null, null)).setContext(context); + + Map details = new HashMap(); + + details.put(PrimaryDataStore.MANAGED, Boolean.TRUE.toString()); + details.put(PrimaryDataStore.STORAGE_HOST, destPrimaryDataStore.getHostAddress()); + details.put(PrimaryDataStore.STORAGE_PORT, String.valueOf(destPrimaryDataStore.getPort())); + // for managed storage, the storage repository (XenServer) or datastore (ESX) name is based off of the iScsiName property of a volume + details.put(PrimaryDataStore.MANAGED_STORE_TARGET, volumeInfo.get_iScsiName()); + details.put(PrimaryDataStore.MANAGED_STORE_TARGET_ROOT_VOLUME, volumeInfo.getName()); + details.put(PrimaryDataStore.VOLUME_SIZE, String.valueOf(volumeInfo.getSize())); + + ChapInfo chapInfo = getChapInfo(volumeInfo, destPrimaryDataStore); + + if (chapInfo != null) { + details.put(PrimaryDataStore.CHAP_INITIATOR_USERNAME, chapInfo.getInitiatorUsername()); + details.put(PrimaryDataStore.CHAP_INITIATOR_SECRET, chapInfo.getInitiatorSecret()); + details.put(PrimaryDataStore.CHAP_TARGET_USERNAME, chapInfo.getTargetUsername()); + details.put(PrimaryDataStore.CHAP_TARGET_SECRET, chapInfo.getTargetSecret()); + } + + destPrimaryDataStore.setDetails(details); + + motionSrv.copyAsync(srcTemplateInfo, destTemplateInfo, destHost, caller); + } + catch (Throwable t) { + String errMsg = t.toString(); + + volumeInfo.processEvent(Event.DestroyRequested); + + disconnectVolumeFromHost(volumeInfo, destHost, destPrimaryDataStore); + + try { + AsyncCallFuture expungeVolumeFuture = expungeVolumeAsync(volumeInfo); + + VolumeApiResult expungeVolumeResult = expungeVolumeFuture.get(); + + if (expungeVolumeResult.isFailed()) { + errMsg += " : Failed to expunge a volume that was created"; + } + } + catch (Exception ex) { + errMsg += " : " + ex.getMessage(); + } + + VolumeApiResult result = new VolumeApiResult(volumeInfo); + + result.setResult(errMsg); + + future.complete(result); + } + + return future; + } + @DB @Override public AsyncCallFuture createVolumeFromTemplateAsync(VolumeInfo volume, long dataStoreId, TemplateInfo template) { @@ -615,7 +772,7 @@ public class VolumeServiceImpl implements VolumeService { volumeOnStore.processEvent(Event.CreateOnlyRequested); snapshot.processEvent(Event.CopyingRequested); CreateVolumeFromBaseImageContext context = - new CreateVolumeFromBaseImageContext(null, volume, store, volumeOnStore, future, snapshot); + new CreateVolumeFromBaseImageContext(null, volume, store, volumeOnStore, future, snapshot); AsyncCallbackDispatcher caller = AsyncCallbackDispatcher.create(this); caller.setCallback(caller.getTarget().createVolumeFromSnapshotCallback(null, null)).setContext(context); motionSrv.copyAsync(snapshot, volumeOnStore, caller); @@ -630,7 +787,7 @@ public class VolumeServiceImpl implements VolumeService { } protected Void createVolumeFromSnapshotCallback(AsyncCallbackDispatcher callback, - CreateVolumeFromBaseImageContext context) { + CreateVolumeFromBaseImageContext context) { CopyCommandResult result = callback.getResult(); VolumeInfo volume = (VolumeInfo)context.templateOnStore; SnapshotInfo snapshot = context.snapshot; @@ -662,9 +819,16 @@ public class VolumeServiceImpl implements VolumeService { protected VolumeVO duplicateVolumeOnAnotherStorage(Volume volume, StoragePool pool) { Long lastPoolId = volume.getPoolId(); + String folder = pool.getPath(); + // For SMB, pool credentials are also stored in the uri query string. We trim the query string + // part here to make sure the credentials do not get stored in the db unencrypted. + if (pool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) { + folder = folder.substring(0, folder.indexOf("?")); + } + VolumeVO newVol = new VolumeVO(volume); newVol.setPoolId(pool.getId()); - newVol.setFolder(pool.getPath()); + newVol.setFolder(folder); newVol.setPodId(pool.getPodId()); newVol.setPoolId(pool.getId()); newVol.setLastPoolId(lastPoolId); @@ -716,7 +880,7 @@ public class VolumeServiceImpl implements VolumeService { } protected Void - copyVolumeFromImageToPrimaryCallback(AsyncCallbackDispatcher callback, CopyVolumeContext context) { + copyVolumeFromImageToPrimaryCallback(AsyncCallbackDispatcher callback, CopyVolumeContext context) { VolumeInfo srcVolume = context.srcVolume; VolumeInfo destVolume = context.destVolume; CopyCommandResult result = callback.getResult(); @@ -770,7 +934,7 @@ public class VolumeServiceImpl implements VolumeService { } protected Void - copyVolumeFromPrimaryToImageCallback(AsyncCallbackDispatcher callback, CopyVolumeContext context) { + copyVolumeFromPrimaryToImageCallback(AsyncCallbackDispatcher callback, CopyVolumeContext context) { VolumeInfo srcVolume = context.srcVolume; VolumeInfo destVolume = context.destVolume; CopyCommandResult result = callback.getResult(); @@ -853,6 +1017,7 @@ public class VolumeServiceImpl implements VolumeService { } srcVolume.processEvent(Event.OperationSuccessed); destVolume.processEvent(Event.OperationSuccessed, result.getAnswer()); + _volumeDao.updateUuid(srcVolume.getId(), destVolume.getId()); destroyVolume(srcVolume.getId()); srcVolume = volFactory.getVolume(srcVolume.getId()); AsyncCallFuture destroyFuture = expungeVolumeAsync(srcVolume); @@ -988,7 +1153,7 @@ public class VolumeServiceImpl implements VolumeService { } protected Void - migrateVmWithVolumesCallBack(AsyncCallbackDispatcher callback, MigrateVmWithVolumesContext context) { + migrateVmWithVolumesCallBack(AsyncCallbackDispatcher callback, MigrateVmWithVolumesContext context) { Map volumeToPool = context.volumeToPool; CopyCommandResult result = callback.getResult(); AsyncCallFuture future = context.future; @@ -1065,20 +1230,20 @@ public class VolumeServiceImpl implements VolumeService { physicalSize = volStore.getPhysicalSize(); } else { s_logger.warn("No entry found in volume_store_ref for volume id: " + vo.getId() + " and image store id: " + ds.getId() + - " at the end of uploading volume!"); + " at the end of uploading volume!"); } Scope dsScope = ds.getScope(); if (dsScope.getScopeType() == ScopeType.ZONE) { if (dsScope.getScopeId() != null) { UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_UPLOAD, vo.getAccountId(), dsScope.getScopeId(), vo.getId(), vo.getName(), null, - null, physicalSize, vo.getSize(), Volume.class.getName(), vo.getUuid()); + null, physicalSize, vo.getSize(), Volume.class.getName(), vo.getUuid()); } else { s_logger.warn("Zone scope image store " + ds.getId() + " has a null scope id"); } } else if (dsScope.getScopeType() == ScopeType.REGION) { // publish usage event for region-wide image store using a -1 zoneId for 4.2, need to revisit post-4.2 UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_UPLOAD, vo.getAccountId(), -1, vo.getId(), vo.getName(), null, null, physicalSize, - vo.getSize(), Volume.class.getName(), vo.getUuid()); + vo.getSize(), Volume.class.getName(), vo.getUuid()); _resourceLimitMgr.incrementResourceCount(vo.getAccountId(), ResourceType.secondary_storage, vo.getSize()); } @@ -1173,7 +1338,7 @@ public class VolumeServiceImpl implements VolumeService { VolumeVO volume = _volumeDao.findById(volumeStore.getVolumeId()); if (volume == null) { s_logger.warn("Volume_store_ref shows that volume " + volumeStore.getVolumeId() + " is on image store " + storeId + - ", but the volume is not found in volumes table, potentially some bugs in deleteVolume, so we just treat this volume to be deleted and mark it as destroyed"); + ", but the volume is not found in volumes table, potentially some bugs in deleteVolume, so we just treat this volume to be deleted and mark it as destroyed"); volumeStore.setDestroyed(true); _volumeStoreDao.update(volumeStore.getId(), volumeStore); continue; @@ -1193,7 +1358,7 @@ public class VolumeServiceImpl implements VolumeService { s_logger.info("msg"); if (volumeStore.getDownloadUrl() == null) { msg = - "Volume (" + volume.getUuid() + ") with install path " + volInfo.getInstallPath() + + "Volume (" + volume.getUuid() + ") with install path " + volInfo.getInstallPath() + "is corrupted, please check in image store: " + volumeStore.getDataStoreId(); s_logger.warn(msg); } else { @@ -1221,15 +1386,15 @@ public class VolumeServiceImpl implements VolumeService { if (volInfo.getSize() > 0) { try { _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(volume.getAccountId()), - com.cloud.configuration.Resource.ResourceType.secondary_storage, volInfo.getSize() - volInfo.getPhysicalSize()); + com.cloud.configuration.Resource.ResourceType.secondary_storage, volInfo.getSize() - volInfo.getPhysicalSize()); } catch (ResourceAllocationException e) { s_logger.warn(e.getMessage()); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED, volume.getDataCenterId(), volume.getPodId(), - e.getMessage(), - e.getMessage()); + e.getMessage(), + e.getMessage()); } finally { _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(), - com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal()); + com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal()); } } } @@ -1238,7 +1403,7 @@ public class VolumeServiceImpl implements VolumeService { // Volume is not on secondary but we should download. if (volumeStore.getDownloadState() != Status.DOWNLOADED) { s_logger.info("Volume Sync did not find " + volume.getName() + " ready on image store " + storeId + - ", will request download to start/resume shortly"); + ", will request download to start/resume shortly"); toBeDownloaded.add(volumeStore); } } diff --git a/framework/cluster/findbugsExcludeFilter.xml b/framework/cluster/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/cluster/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/cluster/pom.xml b/framework/cluster/pom.xml index da9f3f2daaa..c058695a940 100644 --- a/framework/cluster/pom.xml +++ b/framework/cluster/pom.xml @@ -15,7 +15,7 @@ org.apache.cloudstack cloudstack-framework - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/framework/config/findbugsExcludeFilter.xml b/framework/config/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/config/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/config/pom.xml b/framework/config/pom.xml index 10980aff897..992574a8226 100644 --- a/framework/config/pom.xml +++ b/framework/config/pom.xml @@ -15,7 +15,7 @@ org.apache.cloudstack cloudstack-framework - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/framework/db/findbugsExcludeFilter.xml b/framework/db/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/db/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/db/pom.xml b/framework/db/pom.xml index a0edf20abfe..d1fc65fd506 100644 --- a/framework/db/pom.xml +++ b/framework/db/pom.xml @@ -15,7 +15,7 @@ org.apache.cloudstack cloudstack-framework - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml @@ -48,11 +48,6 @@ cloud-utils ${project.version} - - mysql - mysql-connector-java - compile - diff --git a/framework/db/src/com/cloud/dao/EntityManagerImpl.java b/framework/db/src/com/cloud/dao/EntityManagerImpl.java index 499ee3e6405..b531d1a646c 100644 --- a/framework/db/src/com/cloud/dao/EntityManagerImpl.java +++ b/framework/db/src/com/cloud/dao/EntityManagerImpl.java @@ -45,6 +45,7 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager { return dao.findById(id); } + @Override public T findByIdIncludingRemoved(Class entityType, K id) { GenericDao dao = (GenericDao)GenericDaoBase.getDao(entityType); return dao.findByIdIncludingRemoved(id); diff --git a/framework/db/src/com/cloud/utils/db/Filter.java b/framework/db/src/com/cloud/utils/db/Filter.java index b2482fdb3a2..fdcad9c3e54 100755 --- a/framework/db/src/com/cloud/utils/db/Filter.java +++ b/framework/db/src/com/cloud/utils/db/Filter.java @@ -79,7 +79,7 @@ public class Filter { String name = column != null ? column.name() : field; StringBuilder order = new StringBuilder(); - if (column.table() == null || column.table().length() == 0) { + if (column == null || column.table() == null || column.table().length() == 0) { order.append(DbUtil.getTableName(clazz)); } else { order.append(column.table()); diff --git a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java index f282428b8de..2052aadffdd 100755 --- a/framework/db/src/com/cloud/utils/db/GenericDaoBase.java +++ b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java @@ -396,10 +396,10 @@ public abstract class GenericDaoBase extends Compone final List result = new ArrayList(); try { pstmt = txn.prepareAutoCloseStatement(sql); - int i = 0; + int i = 1; if (clause != null) { for (final Pair value : sc.getValues()) { - prepareAttribute(++i, pstmt, value.first(), value.second()); + prepareAttribute(i++, pstmt, value.first(), value.second()); } } @@ -431,10 +431,13 @@ public abstract class GenericDaoBase extends Compone @Override @SuppressWarnings("unchecked") public List customSearchIncludingRemoved(SearchCriteria sc, final Filter filter) { + if (sc == null) { + throw new CloudRuntimeException("Call to customSearchIncludingRemoved with null search Criteria"); + } if (sc.isSelectAll()) { return (List)searchIncludingRemoved((SearchCriteria)sc, filter, null, false); } - String clause = sc != null ? sc.getWhereClause() : null; + String clause = sc.getWhereClause(); if (clause != null && clause.length() == 0) { clause = null; } @@ -445,11 +448,9 @@ public abstract class GenericDaoBase extends Compone } Collection>> joins = null; - if (sc != null) { - joins = sc.getJoins(); - if (joins != null) { - addJoins(str, joins); - } + joins = sc.getJoins(); + if (joins != null) { + addJoins(str, joins); } List groupByValues = addGroupBy(str, sc); @@ -461,10 +462,10 @@ public abstract class GenericDaoBase extends Compone PreparedStatement pstmt = null; try { pstmt = txn.prepareAutoCloseStatement(sql); - int i = 0; + int i = 1; if (clause != null) { for (final Pair value : sc.getValues()) { - prepareAttribute(++i, pstmt, value.first(), value.second()); + prepareAttribute(i++, pstmt, value.first(), value.second()); } } @@ -553,7 +554,7 @@ public abstract class GenericDaoBase extends Compone final Enum[] enums = (Enum[])field.getType().getEnumConstants(); for (final Enum e : enums) { if ((enumType == EnumType.STRING && e.name().equalsIgnoreCase(rs.getString(index))) || - (enumType == EnumType.ORDINAL && e.ordinal() == rs.getInt(index))) { + (enumType == EnumType.ORDINAL && e.ordinal() == rs.getInt(index))) { field.set(entity, e); return; } @@ -685,12 +686,12 @@ public abstract class GenericDaoBase extends Compone return null; } } else if (type == int.class) { - return (M)new Integer(rs.getInt(index)); + return (M) (Integer) rs.getInt(index); } else if (type == Integer.class) { if (rs.getObject(index) == null) { return null; } else { - return (M)new Integer(rs.getInt(index)); + return (M) (Integer) rs.getInt(index); } } else if (type == long.class) { return (M) (Long) rs.getLong(index); @@ -767,7 +768,7 @@ public abstract class GenericDaoBase extends Compone protected int addJoinAttributes(int count, PreparedStatement pstmt, Collection>> joins) throws SQLException { for (JoinBuilder> join : joins) { for (final Pair value : join.getT().getValues()) { - prepareAttribute(++count, pstmt, value.first(), value.second()); + prepareAttribute(count++, pstmt, value.first(), value.second()); } } @@ -1070,6 +1071,8 @@ public abstract class GenericDaoBase extends Compone @DB() protected List addGroupBy(final StringBuilder sql, SearchCriteria sc) { + if (sc == null) + return null; Pair, List> groupBys = sc.getGroupBy(); if (groupBys != null) { groupBys.first().toSql(sql); @@ -1179,6 +1182,10 @@ public abstract class GenericDaoBase extends Compone // FIXME: Does not work for joins. @Override public int expunge(final SearchCriteria sc) { + if (sc == null) { + throw new CloudRuntimeException("Call to throw new expunge with null search Criteria"); + } + final StringBuilder str = new StringBuilder("DELETE FROM "); str.append(_table); str.append(" WHERE "); @@ -1248,18 +1255,18 @@ public abstract class GenericDaoBase extends Compone for (JoinBuilder> join : joins) { StringBuilder onClause = new StringBuilder(); onClause.append(" ") - .append(join.getType().getName()) - .append(" ") - .append(join.getSecondAttribute().table) - .append(" ON ") - .append(join.getFirstAttribute().table) - .append(".") - .append(join.getFirstAttribute().columnName) - .append("=") - .append(join.getSecondAttribute().table) - .append(".") - .append(join.getSecondAttribute().columnName) - .append(" "); + .append(join.getType().getName()) + .append(" ") + .append(join.getSecondAttribute().table) + .append(" ON ") + .append(join.getFirstAttribute().table) + .append(".") + .append(join.getFirstAttribute().columnName) + .append("=") + .append(join.getSecondAttribute().table) + .append(".") + .append(join.getSecondAttribute().columnName) + .append(" "); str.insert(fromIndex, onClause); String whereClause = join.getT().getWhereClause(); if ((whereClause != null) && !"".equals(whereClause)) { @@ -1871,10 +1878,10 @@ public abstract class GenericDaoBase extends Compone PreparedStatement pstmt = null; try { pstmt = txn.prepareAutoCloseStatement(sql); - int i = 0; + int i = 1; if (clause != null) { for (final Pair value : sc.getValues()) { - prepareAttribute(++i, pstmt, value.first(), value.second()); + prepareAttribute(i++, pstmt, value.first(), value.second()); } } diff --git a/framework/db/src/com/cloud/utils/db/GroupBy.java b/framework/db/src/com/cloud/utils/db/GroupBy.java index 716b585ada1..00c0acbe48b 100644 --- a/framework/db/src/com/cloud/utils/db/GroupBy.java +++ b/framework/db/src/com/cloud/utils/db/GroupBy.java @@ -28,31 +28,35 @@ public class GroupBy, T, R> { List> _groupBys; Having _having; - public GroupBy(J builder) { + public GroupBy(final J builder) { + init(builder); + } + + protected void init(final J builder) { _builder = builder; _groupBys = new ArrayList>(); _having = null; - for (Attribute attr : _builder.getSpecifiedAttributes()) { + for (final Attribute attr : _builder.getSpecifiedAttributes()) { _groupBys.add(new Pair(null, attr)); } _builder.getSpecifiedAttributes().clear(); } - public GroupBy group(Object useless) { + public GroupBy group(final Object useless) { _groupBys.add(new Pair(null, _builder.getSpecifiedAttributes().get(0))); _builder.getSpecifiedAttributes().clear(); return this; } - public GroupBy group(Func func, Object useless) { + public GroupBy group(final Func func, final Object useless) { _groupBys.add(new Pair(func, _builder.getSpecifiedAttributes().get(0))); _builder.getSpecifiedAttributes().clear(); return this; } - public J having(Func func, Object obj, Op op, Object value) { + public J having(final Func func, final Object obj, final Op op, final Object value) { assert (_having == null) : "You can only specify one having in a group by"; - List attrs = _builder.getSpecifiedAttributes(); + final List attrs = _builder.getSpecifiedAttributes(); assert attrs.size() == 1 : "You didn't specified an attribute"; _having = new Having(func, attrs.get(0), op, value); @@ -60,12 +64,12 @@ public class GroupBy, T, R> { return _builder; } - public void toSql(StringBuilder builder) { + public void toSql(final StringBuilder builder) { builder.append(" GROUP BY "); - for (Pair groupBy : _groupBys) { + for (final Pair groupBy : _groupBys) { if (groupBy.first() != null) { String func = groupBy.first().toString(); - func.replaceFirst("@", groupBy.second().table + "." + groupBy.second().columnName); + func = func.replaceFirst("@", groupBy.second().table + "." + groupBy.second().columnName); builder.append(func); } else { builder.append(groupBy.second().table + "." + groupBy.second().columnName); @@ -86,18 +90,19 @@ public class GroupBy, T, R> { public Op op; public Object value; - public Having(Func func, Attribute attr, Op op, Object value) { + public Having(final Func func, final Attribute attr, final Op op, final Object value) { this.func = func; this.attr = attr; this.op = op; this.value = value; } - public void toSql(StringBuilder builder) { + public void toSql(final StringBuilder builder) { + builder.append(" HAVING "); if (func != null) { String f = func.toString(); - f.replaceFirst("@", attr.toString()); - builder.append(func); + f = f.replaceFirst("@", attr.toString()); + builder.append(f); } else { builder.append(attr.toString()); } diff --git a/framework/db/src/com/cloud/utils/db/SearchBase.java b/framework/db/src/com/cloud/utils/db/SearchBase.java index 3f123bed25b..4ec9a41fd48 100644 --- a/framework/db/src/com/cloud/utils/db/SearchBase.java +++ b/framework/db/src/com/cloud/utils/db/SearchBase.java @@ -52,13 +52,13 @@ import com.cloud.utils.exception.CloudRuntimeException; */ public abstract class SearchBase, T, K> { - final Map _attrs; - final Class _entityBeanType; - final Class _resultType; - final GenericDaoBase _dao; + Map _attrs; + Class _entityBeanType; + Class _resultType; + GenericDaoBase _dao; - final ArrayList _conditions; - final ArrayList _specifiedAttrs; + ArrayList _conditions; + ArrayList _specifiedAttrs; protected HashMap>> _joins; protected ArrayList(); } - for (Attribute attr : _specifiedAttrs) { + for (final Attribute attr : _specifiedAttrs) { Field field = null; try { field = _resultType.getDeclaredField(attr.field.getName()); field.setAccessible(true); - } catch (SecurityException e) { - } catch (NoSuchFieldException e) { + } catch (final SecurityException e) { + } catch (final NoSuchFieldException e) { } _selects.add(new Select(Func.NATIVE, attr, field, null)); } @@ -192,14 +195,14 @@ public abstract class SearchBase, T, K> { * @return itself */ @SuppressWarnings("unchecked") - public J join(String name, SearchBase builder, Object joinField1, Object joinField2, JoinBuilder.JoinType joinType) { + public J join(final String name, final SearchBase builder, final Object joinField1, final Object joinField2, final JoinBuilder.JoinType joinType) { assert _entity != null : "SearchBuilder cannot be modified once it has been setup"; assert _specifiedAttrs.size() == 1 : "You didn't select the attribute."; assert builder._entity != null : "SearchBuilder cannot be modified once it has been setup"; assert builder._specifiedAttrs.size() == 1 : "You didn't select the attribute."; assert builder != this : "You can't add yourself, can you? Really think about it!"; - JoinBuilder> t = new JoinBuilder>(builder, _specifiedAttrs.get(0), builder._specifiedAttrs.get(0), joinType); + final JoinBuilder> t = new JoinBuilder>(builder, _specifiedAttrs.get(0), builder._specifiedAttrs.get(0), joinType); if (_joins == null) { _joins = new HashMap>>(); } @@ -214,8 +217,8 @@ public abstract class SearchBase, T, K> { return _selectType; } - protected void set(String name) { - Attribute attr = _attrs.get(name); + protected void set(final String name) { + final Attribute attr = _attrs.get(name); assert (attr != null) : "Searching for a field that's not there: " + name; _specifiedAttrs.add(attr); } @@ -232,19 +235,29 @@ public abstract class SearchBase, T, K> { if (_entity == null || _specifiedAttrs == null || _specifiedAttrs.size() != 1) { throw new RuntimeException("Now now, better specify an attribute or else we can't help you"); } - return _specifiedAttrs.get(0); + if (_specifiedAttrs.size() > 0) { + return _specifiedAttrs.get(0); + } + // look for attributes from joins + for (JoinBuilder> join : _joins.values()) { + SearchBase sb = join.getT(); + if (sb.getSpecifiedAttribute() != null) { + return sb.getSpecifiedAttribute(); + } + } + throw new CloudRuntimeException("Unable to find any specified attributes. You sure you know what you're doing?"); } protected List getSpecifiedAttributes() { return _specifiedAttrs; } - protected Condition constructCondition(String conditionName, String cond, Attribute attr, Op op) { + protected Condition constructCondition(final String conditionName, final String cond, final Attribute attr, final Op op) { assert _entity != null : "SearchBuilder cannot be modified once it has been setup"; assert op == null || _specifiedAttrs.size() == 1 : "You didn't select the attribute."; assert op != Op.SC : "Call join"; - Condition condition = new Condition(conditionName, cond, attr, op); + final Condition condition = new Condition(conditionName, cond, attr, op); _conditions.add(condition); _specifiedAttrs.clear(); return condition; @@ -304,7 +317,7 @@ public abstract class SearchBase, T, K> { */ @SuppressWarnings("unchecked") public J cp() { - Condition condition = new Condition(null, " ) ", null, Op.RP); + final Condition condition = new Condition(null, " ) ", null, Op.RP); _conditions.add(condition); return (J)this; } @@ -315,7 +328,7 @@ public abstract class SearchBase, T, K> { */ @SuppressWarnings("unchecked") public J op() { - Condition condition = new Condition(null, " ( ", null, Op.RP); + final Condition condition = new Condition(null, " ( ", null, Op.RP); _conditions.add(condition); return (J)this; } @@ -326,13 +339,13 @@ public abstract class SearchBase, T, K> { @Override protected synchronized void finalize() { if (_entity != null) { - Factory factory = (Factory)_entity; + final Factory factory = (Factory)_entity; factory.setCallback(0, null); _entity = null; } if (_joins != null) { - for (JoinBuilder> join : _joins.values()) { + for (final JoinBuilder> join : _joins.values()) { join.getT().finalize(); } } @@ -343,7 +356,7 @@ public abstract class SearchBase, T, K> { return; } - for (Select select : _selects) { + for (final Select select : _selects) { if (select.field == null) { assert (_selects.size() == 1) : "You didn't specify any fields to put the result in but you're specifying more than one select so where should I put the selects?"; _selectType = SelectType.Single; @@ -365,11 +378,11 @@ public abstract class SearchBase, T, K> { protected final Attribute attr; protected Object[] presets; - protected Condition(String name) { + protected Condition(final String name) { this(name, null, null, null); } - public Condition(String name, String cond, Attribute attr, Op op) { + public Condition(final String name, final String cond, final Attribute attr, final Op op) { this.name = name; this.attr = attr; this.cond = cond; @@ -381,7 +394,7 @@ public abstract class SearchBase, T, K> { return presets != null; } - public void setPresets(Object... presets) { + public void setPresets(final Object... presets) { this.presets = presets; } @@ -389,7 +402,7 @@ public abstract class SearchBase, T, K> { return presets; } - public void toSql(StringBuilder sql, Object[] params, int count) { + public void toSql(final StringBuilder sql, final Object[] params, final int count) { if (count > 0) { sql.append(cond); } @@ -438,12 +451,12 @@ public abstract class SearchBase, T, K> { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (!(obj instanceof Condition)) { return false; } - Condition condition = (Condition)obj; + final Condition condition = (Condition)obj; return name.equals(condition.name); } } @@ -457,7 +470,7 @@ public abstract class SearchBase, T, K> { protected Select() { } - public Select(Func func, Attribute attr, Field field, Object[] params) { + public Select(final Func func, final Attribute attr, final Field field, final Object[] params) { this.func = func; this.attr = attr; this.params = params; @@ -467,22 +480,22 @@ public abstract class SearchBase, T, K> { protected class Interceptor implements MethodInterceptor { @Override - public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { - String name = method.getName(); + public Object intercept(final Object object, final Method method, final Object[] args, final MethodProxy methodProxy) throws Throwable { + final String name = method.getName(); if (method.getAnnotation(Transient.class) == null) { if (name.startsWith("get")) { - String fieldName = Character.toLowerCase(name.charAt(3)) + name.substring(4); + final String fieldName = Character.toLowerCase(name.charAt(3)) + name.substring(4); set(fieldName); return null; } else if (name.startsWith("is")) { - String fieldName = Character.toLowerCase(name.charAt(2)) + name.substring(3); + final String fieldName = Character.toLowerCase(name.charAt(2)) + name.substring(3); set(fieldName); return null; } else { - Column ann = method.getAnnotation(Column.class); + final Column ann = method.getAnnotation(Column.class); if (ann != null) { - String colName = ann.name(); - for (Map.Entry attr : _attrs.entrySet()) { + final String colName = ann.name(); + for (final Map.Entry attr : _attrs.entrySet()) { if (colName.equals(attr.getValue().columnName)) { set(attr.getKey()); return null; diff --git a/framework/db/test/com/cloud/utils/db/GenericDaoBaseTest.java b/framework/db/test/com/cloud/utils/db/GenericDaoBaseTest.java index b7febcb8994..aef0c699032 100644 --- a/framework/db/test/com/cloud/utils/db/GenericDaoBaseTest.java +++ b/framework/db/test/com/cloud/utils/db/GenericDaoBaseTest.java @@ -19,8 +19,7 @@ package com.cloud.utils.db; import java.sql.ResultSet; import java.sql.SQLException; -import junit.framework.Assert; - +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -73,7 +72,7 @@ public class GenericDaoBaseTest { Mockito.when(resultSet.getObject(1)).thenReturn(0.1f); Mockito.when(resultSet.getFloat(1)).thenReturn(0.1f); Assert.assertEquals(0.1f, - GenericDaoBase.getObject(Float.class, resultSet, 1)); + GenericDaoBase.getObject(Float.class, resultSet, 1), 0.1); Mockito.verify(resultSet).getFloat(1); } @@ -82,7 +81,7 @@ public class GenericDaoBaseTest { Mockito.when(resultSet.getObject(1)).thenReturn(0.1f); Mockito.when(resultSet.getFloat(1)).thenReturn(0.1f); Assert.assertEquals(0.1f, - GenericDaoBase.getObject(float.class, resultSet, 1)); + GenericDaoBase.getObject(float.class, resultSet, 1), 0.1); Mockito.verify(resultSet).getFloat(1); } @@ -91,7 +90,7 @@ public class GenericDaoBaseTest { Mockito.when(resultSet.getObject(1)).thenReturn(0.1d); Mockito.when(resultSet.getDouble(1)).thenReturn(0.1d); Assert.assertEquals(0.1d, - GenericDaoBase.getObject(double.class, resultSet, 1)); + GenericDaoBase.getObject(double.class, resultSet, 1), 0.1); Mockito.verify(resultSet).getDouble(1); } @@ -100,7 +99,7 @@ public class GenericDaoBaseTest { Mockito.when(resultSet.getObject(1)).thenReturn(0.1d); Mockito.when(resultSet.getDouble(1)).thenReturn(0.1d); Assert.assertEquals(0.1d, - GenericDaoBase.getObject(Double.class, resultSet, 1)); + GenericDaoBase.getObject(Double.class, resultSet, 1), 0.1); Mockito.verify(resultSet).getDouble(1); } @@ -122,6 +121,24 @@ public class GenericDaoBaseTest { Mockito.verify(resultSet).getLong(1); } + @Test + public void getObjectPrimitiveInt() throws SQLException { + Mockito.when(resultSet.getObject(1)).thenReturn(1l); + Mockito.when(resultSet.getInt(1)).thenReturn(1); + Assert.assertEquals((Integer) 1, + GenericDaoBase.getObject(int.class, resultSet, 1)); + Mockito.verify(resultSet).getInt(1); + } + + @Test + public void getObjectInteger() throws SQLException { + Mockito.when(resultSet.getObject(1)).thenReturn(1l); + Mockito.when(resultSet.getInt(1)).thenReturn(1); + Assert.assertEquals((Integer) 1, + GenericDaoBase.getObject(Integer.class, resultSet, 1)); + Mockito.verify(resultSet).getInt(1); + } + @Test public void getObjectPrimitiveByte() throws SQLException { Mockito.when(resultSet.getObject(1)).thenReturn((byte) 1); diff --git a/framework/db/test/com/cloud/utils/db/GroupByTest.java b/framework/db/test/com/cloud/utils/db/GroupByTest.java new file mode 100644 index 00000000000..d394c73c3fa --- /dev/null +++ b/framework/db/test/com/cloud/utils/db/GroupByTest.java @@ -0,0 +1,81 @@ +// 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.utils.db; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; + +import org.junit.Test; + +import com.cloud.utils.Pair; +import com.cloud.utils.db.SearchCriteria.Func; +import com.cloud.utils.db.SearchCriteria.Op; + + +public class GroupByTest { + + protected static final String EXPECTED_QUERY = "BASE GROUP BY FIRST(TEST_TABLE.TEST_COLUMN), MAX(TEST_TABLE.TEST_COLUMN) HAVING COUNT(TEST_TABLE2.TEST_COLUMN2) > ? "; + @Test + public void testToSql() { + // Prepare + final StringBuilder sb = new StringBuilder("BASE"); + final GroupByExtension groupBy = new GroupByExtension(new SearchBaseExtension(String.class, String.class)); + + final Attribute att = new Attribute("TEST_TABLE", "TEST_COLUMN"); + final Pair pair1 = new Pair(SearchCriteria.Func.FIRST, att); + final Pair pair2 = new Pair(SearchCriteria.Func.MAX, att); + groupBy._groupBys = new ArrayList>(); + groupBy._groupBys.add(pair1); + groupBy._groupBys.add(pair2); + groupBy.having(SearchCriteria.Func.COUNT, att, Op.GT, "SOME_VALUE"); + + // Execute + groupBy.toSql(sb); + + // Assert + assertTrue("It didn't create the expected SQL query.", sb.toString().equals(EXPECTED_QUERY)); + } +} + +class GroupByExtension extends GroupBy { + + public GroupByExtension(final SearchBaseExtension builder) { + super(builder); + _builder = builder; + } + + @Override + protected void init(final SearchBaseExtension builder) { + } +} + +@SuppressWarnings({"rawtypes", "unchecked"}) +class SearchBaseExtension extends SearchBase{ + + SearchBaseExtension(final Class entityType, final Class resultType) { + super(entityType, resultType); + _specifiedAttrs = new ArrayList(); + _specifiedAttrs.add(new Attribute("TEST_TABLE2", "TEST_COLUMN2")); + } + + @Override + protected void init(final Class entityType, final Class resultType) { + } +} diff --git a/framework/events/findbugsExcludeFilter.xml b/framework/events/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/events/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/events/pom.xml b/framework/events/pom.xml index a033ef7a664..f54386d8a32 100644 --- a/framework/events/pom.xml +++ b/framework/events/pom.xml @@ -15,7 +15,7 @@ org.apache.cloudstack cloudstack-framework - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/framework/ipc/findbugsExcludeFilter.xml b/framework/ipc/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/ipc/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/ipc/pom.xml b/framework/ipc/pom.xml index 79de63fb492..12b4a3d295a 100644 --- a/framework/ipc/pom.xml +++ b/framework/ipc/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloudstack-framework - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messagebus/MessageBusBase.java b/framework/ipc/src/org/apache/cloudstack/framework/messagebus/MessageBusBase.java index a9c433c62cd..9432da0a723 100644 --- a/framework/ipc/src/org/apache/cloudstack/framework/messagebus/MessageBusBase.java +++ b/framework/ipc/src/org/apache/cloudstack/framework/messagebus/MessageBusBase.java @@ -58,10 +58,13 @@ public class MessageBusBase implements MessageBus { assert (subject != null); assert (subscriber != null); if (_gate.enter()) { - SubscriptionNode current = locate(subject, null, true); - assert (current != null); - current.addSubscriber(subscriber); - _gate.leave(); + try { + SubscriptionNode current = locate(subject, null, true); + assert (current != null); + current.addSubscriber(subscriber); + } finally { + _gate.leave(); + } } else { synchronized (_pendingActions) { _pendingActions.add(new ActionRecord(ActionType.Subscribe, subject, subscriber)); @@ -72,14 +75,17 @@ public class MessageBusBase implements MessageBus { @Override public void unsubscribe(String subject, MessageSubscriber subscriber) { if (_gate.enter()) { - if (subject != null) { - SubscriptionNode current = locate(subject, null, false); - if (current != null) - current.removeSubscriber(subscriber, false); - } else { - _subscriberRoot.removeSubscriber(subscriber, true); + try { + if (subject != null) { + SubscriptionNode current = locate(subject, null, false); + if (current != null) + current.removeSubscriber(subscriber, false); + } else { + _subscriberRoot.removeSubscriber(subscriber, true); + } + } finally { + _gate.leave(); } - _gate.leave(); } else { synchronized (_pendingActions) { _pendingActions.add(new ActionRecord(ActionType.Unsubscribe, subject, subscriber)); @@ -90,9 +96,12 @@ public class MessageBusBase implements MessageBus { @Override public void clearAll() { if (_gate.enter()) { - _subscriberRoot.clearAll(); - doPrune(); - _gate.leave(); + try { + _subscriberRoot.clearAll(); + doPrune(); + } finally { + _gate.leave(); + } } else { synchronized (_pendingActions) { _pendingActions.add(new ActionRecord(ActionType.ClearAll, null, null)); @@ -103,8 +112,11 @@ public class MessageBusBase implements MessageBus { @Override public void prune() { if (_gate.enter()) { - doPrune(); - _gate.leave(); + try { + doPrune(); + } finally { + _gate.leave(); + } } else { synchronized (_pendingActions) { _pendingActions.add(new ActionRecord(ActionType.Prune, null, null)); @@ -132,18 +144,19 @@ public class MessageBusBase implements MessageBus { public void publish(String senderAddress, String subject, PublishScope scope, Object args) { if (_gate.enter(true)) { + try { + List chainFromTop = new ArrayList(); + SubscriptionNode current = locate(subject, chainFromTop, false); - List chainFromTop = new ArrayList(); - SubscriptionNode current = locate(subject, chainFromTop, false); + if (current != null) + current.notifySubscribers(senderAddress, subject, args); - if (current != null) - current.notifySubscribers(senderAddress, subject, args); - - Collections.reverse(chainFromTop); - for (SubscriptionNode node : chainFromTop) - node.notifySubscribers(senderAddress, subject, args); - - _gate.leave(); + Collections.reverse(chainFromTop); + for (SubscriptionNode node : chainFromTop) + node.notifySubscribers(senderAddress, subject, args); + } finally { + _gate.leave(); + } } } diff --git a/framework/ipc/src/org/apache/cloudstack/framework/messagebus/MessageDetector.java b/framework/ipc/src/org/apache/cloudstack/framework/messagebus/MessageDetector.java index 3fb620c1b3e..fae9bf31209 100644 --- a/framework/ipc/src/org/apache/cloudstack/framework/messagebus/MessageDetector.java +++ b/framework/ipc/src/org/apache/cloudstack/framework/messagebus/MessageDetector.java @@ -31,8 +31,10 @@ public class MessageDetector implements MessageSubscriber { } public boolean waitAny(long timeoutInMiliseconds) { - _signalled = false; synchronized (this) { + if (_signalled) + return true; + try { wait(timeoutInMiliseconds); } catch (InterruptedException e) { diff --git a/framework/jobs/findbugsExcludeFilter.xml b/framework/jobs/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/jobs/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/jobs/pom.xml b/framework/jobs/pom.xml index 529eebc8763..ecde92bd62a 100644 --- a/framework/jobs/pom.xml +++ b/framework/jobs/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-framework - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java index 20125f43e66..86c65421fde 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobExecutionContext.java @@ -29,6 +29,8 @@ import org.apache.cloudstack.managed.threadlocal.ManagedThreadLocal; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceUnavailableException; +import com.cloud.user.Account; +import com.cloud.user.User; public class AsyncJobExecutionContext { private static final Logger s_logger = Logger.getLogger(AsyncJobExecutionContext.class); @@ -167,10 +169,15 @@ public class AsyncJobExecutionContext { public static AsyncJobExecutionContext getCurrentExecutionContext() { AsyncJobExecutionContext context = s_currentExectionContext.get(); if (context == null) { - // TODO, this has security implicitions + // TODO, this has security implications, operations carried from API layer should always + // set its context, otherwise, the fall-back here will use system security context + // s_logger.warn("Job is executed without a context, setup psudo job for the executing thread"); - context = registerPseudoExecutionContext(CallContext.current().getCallingAccountId(), - CallContext.current().getCallingUserId()); + if (CallContext.current() != null) + context = registerPseudoExecutionContext(CallContext.current().getCallingAccountId(), + CallContext.current().getCallingUserId()); + else + context = registerPseudoExecutionContext(Account.ACCOUNT_ID_SYSTEM, User.UID_SYSTEM); } return context; } @@ -197,7 +204,11 @@ public class AsyncJobExecutionContext { s_currentExectionContext.set(currentContext); } - public static String getOriginJobContextId() { - return String.valueOf(CallContext.current().getContextId()); + public static String getOriginJobId() { + AsyncJobExecutionContext context = AsyncJobExecutionContext.getCurrentExecutionContext(); + if (context != null && context.getJob() != null) + return "" + context.getJob().getId(); + + return ""; } } diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java index 67733ed1c90..fe5c067ddc2 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java @@ -27,7 +27,8 @@ import com.cloud.utils.component.Manager; public interface AsyncJobManager extends Manager { - public static final String JOB_POOL_THREAD_PREFIX = "Job-Executor"; + public static final String API_JOB_POOL_THREAD_PREFIX = "API-Job-Executor"; + public static final String WORK_JOB_POOL_THREAD_PREFIX = "Work-Job-Executor"; AsyncJobVO getAsyncJob(long jobId); diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDao.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDao.java index f5ac7b12a9f..7b6eed75a00 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDao.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDao.java @@ -24,6 +24,7 @@ import com.cloud.utils.db.GenericDao; public interface SyncQueueItemDao extends GenericDao { public SyncQueueItemVO getNextQueueItem(long queueId); + public int getActiveQueueItemCount(long queueId); public List getNextQueueItems(int maxItems); diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java index 73637634589..41f14190f36 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java @@ -36,6 +36,7 @@ import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.GenericSearchBuilder; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; +import com.cloud.utils.db.SearchCriteria.Func; import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.TransactionLegacy; @@ -43,6 +44,7 @@ import com.cloud.utils.db.TransactionLegacy; public class SyncQueueItemDaoImpl extends GenericDaoBase implements SyncQueueItemDao { private static final Logger s_logger = Logger.getLogger(SyncQueueItemDaoImpl.class); final GenericSearchBuilder queueIdSearch; + final GenericSearchBuilder queueActiveItemSearch; public SyncQueueItemDaoImpl() { super(); @@ -51,6 +53,12 @@ public class SyncQueueItemDaoImpl extends GenericDaoBase queueIdSearch.and("contentType", queueIdSearch.entity().getContentType(), Op.EQ); queueIdSearch.selectFields(queueIdSearch.entity().getId()); queueIdSearch.done(); + + queueActiveItemSearch = createSearchBuilder(Integer.class); + queueActiveItemSearch.and("queueId", queueActiveItemSearch.entity().getQueueId(), Op.EQ); + queueActiveItemSearch.and("processNumber", queueActiveItemSearch.entity().getLastProcessNumber(), Op.NNULL); + queueActiveItemSearch.select(null, Func.COUNT, queueActiveItemSearch.entity().getId()); + queueActiveItemSearch.done(); } @Override @@ -66,19 +74,31 @@ public class SyncQueueItemDaoImpl extends GenericDaoBase Filter filter = new Filter(SyncQueueItemVO.class, "created", true, 0L, 1L); List l = listBy(sc, filter); - if (l != null && l.size() > 0) + if(l != null && l.size() > 0) return l.get(0); return null; } + @Override + public int getActiveQueueItemCount(long queueId) { + SearchCriteria sc = queueActiveItemSearch.create(); + sc.setParameters("queueId", queueId); + + List count = customSearch(sc, null); + return count.get(0); + } + @Override public List getNextQueueItems(int maxItems) { List l = new ArrayList(); - String sql = - "SELECT i.id, i.queue_id, i.content_type, i.content_id, i.created " + " FROM sync_queue AS q JOIN sync_queue_item AS i ON q.id = i.queue_id " - + " WHERE i.queue_proc_number IS NULL " + " GROUP BY q.id " + " ORDER BY i.id " + " LIMIT 0, ?"; + String sql = "SELECT i.id, i.queue_id, i.content_type, i.content_id, i.created " + + " FROM sync_queue AS q JOIN sync_queue_item AS i ON q.id = i.queue_id " + + " WHERE i.queue_proc_number IS NULL " + + " GROUP BY q.id " + + " ORDER BY i.id " + + " LIMIT 0, ?"; TransactionLegacy txn = TransactionLegacy.currentTxn(); PreparedStatement pstmt = null; @@ -86,7 +106,7 @@ public class SyncQueueItemDaoImpl extends GenericDaoBase pstmt = txn.prepareAutoCloseStatement(sql); pstmt.setInt(1, maxItems); ResultSet rs = pstmt.executeQuery(); - while (rs.next()) { + while(rs.next()) { SyncQueueItemVO item = new SyncQueueItemVO(); item.setId(rs.getLong(1)); item.setQueueId(rs.getLong(2)); @@ -106,7 +126,8 @@ public class SyncQueueItemDaoImpl extends GenericDaoBase @Override public List getActiveQueueItems(Long msid, boolean exclusive) { SearchBuilder sb = createSearchBuilder(); - sb.and("lastProcessMsid", sb.entity().getLastProcessMsid(), SearchCriteria.Op.EQ); + sb.and("lastProcessMsid", sb.entity().getLastProcessMsid(), + SearchCriteria.Op.EQ); sb.done(); SearchCriteria sc = sb.create(); @@ -134,7 +155,7 @@ public class SyncQueueItemDaoImpl extends GenericDaoBase SearchCriteria sc = sbItem.create(); sc.setParameters("lastProcessTime2", new Date(cutTime.getTime() - thresholdMs)); - if (exclusive) + if(exclusive) return lockRows(sc, null, true); return listBy(sc, null); } diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/VmWorkJobDaoImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/VmWorkJobDaoImpl.java index cf3e17392b5..ee8748adee0 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/VmWorkJobDaoImpl.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/VmWorkJobDaoImpl.java @@ -20,9 +20,10 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Date; import java.util.List; -import java.util.TimeZone; - import javax.annotation.PostConstruct; +import javax.inject.Inject; + +import org.apache.log4j.Logger; import org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO; import org.apache.cloudstack.framework.jobs.impl.VmWorkJobVO.Step; @@ -41,9 +42,14 @@ import com.cloud.utils.db.TransactionStatus; import com.cloud.vm.VirtualMachine; public class VmWorkJobDaoImpl extends GenericDaoBase implements VmWorkJobDao { + private static final Logger s_logger = Logger.getLogger(VmWorkJobDaoImpl.class); protected SearchBuilder PendingWorkJobSearch; protected SearchBuilder PendingWorkJobByCommandSearch; + protected SearchBuilder ExpungingWorkJobSearch; + + @Inject + protected AsyncJobDao _baseJobDao; public VmWorkJobDaoImpl() { } @@ -63,6 +69,12 @@ public class VmWorkJobDaoImpl extends GenericDaoBase implemen PendingWorkJobByCommandSearch.and("step", PendingWorkJobByCommandSearch.entity().getStep(), Op.NEQ); PendingWorkJobByCommandSearch.and("cmd", PendingWorkJobByCommandSearch.entity().getCmd(), Op.EQ); PendingWorkJobByCommandSearch.done(); + + ExpungingWorkJobSearch = createSearchBuilder(); + ExpungingWorkJobSearch.and("jobStatus", ExpungingWorkJobSearch.entity().getStatus(), Op.NEQ); + ExpungingWorkJobSearch.and("cutDate", ExpungingWorkJobSearch.entity().getLastUpdated(), Op.LT); + ExpungingWorkJobSearch.and("dispatcher", ExpungingWorkJobSearch.entity().getDispatcher(), Op.EQ); + ExpungingWorkJobSearch.done(); } @Override @@ -124,33 +136,19 @@ public class VmWorkJobDaoImpl extends GenericDaoBase implemen expunge(sc); */ - Transaction.execute(new TransactionCallbackNoReturn() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - TransactionLegacy txn = TransactionLegacy.currentTxn(); - PreparedStatement pstmt = null; - try { - pstmt = txn.prepareAutoCloseStatement( - "DELETE FROM vm_work_job WHERE id IN (SELECT id FROM async_job WHERE job_dispatcher='VmWorkJobDispatcher' AND job_status != 0 AND last_updated < ?)"); - pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); - - pstmt.execute(); - } catch (SQLException e) { - } catch (Throwable e) { - } - - try { - pstmt = txn.prepareAutoCloseStatement( - "DELETE FROM async_job WHERE job_dispatcher='VmWorkJobDispatcher' AND job_status != 0 AND last_updated < ?"); - pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cutDate)); - - pstmt.execute(); - } catch (SQLException e) { - } catch (Throwable e) { - } - } - }); + // loop at application level to avoid mysql deadlock issues + SearchCriteria sc = ExpungingWorkJobSearch.create(); + sc.setParameters("jobStatus", JobInfo.Status.IN_PROGRESS); + sc.setParameters("lastUpdated", cutDate); + sc.setParameters("dispatcher", "VmWorkJobDispatcher"); + List expungeList = listBy(sc); + for (VmWorkJobVO job : expungeList) { + if (s_logger.isDebugEnabled()) + s_logger.debug("Expunge completed work job-" + job.getId()); + expunge(job.getId()); + _baseJobDao.expunge(job.getId()); + } } @Override diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java index c3ac0e67b8f..42148bebaed 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java @@ -24,7 +24,6 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Random; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.RejectedExecutionException; @@ -35,8 +34,10 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import org.apache.log4j.Logger; +import org.apache.log4j.NDC; import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.framework.config.ConfigDepot; import org.apache.cloudstack.framework.config.ConfigKey; import org.apache.cloudstack.framework.config.Configurable; @@ -84,12 +85,11 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, private static final ConfigKey JobExpireMinutes = new ConfigKey(Long.class, "job.expire.minutes", "Advanced", "1440", "Time (in minutes) for async-jobs to be kept in system", true, ConfigKey.Scope.Global, 60l); private static final ConfigKey JobCancelThresholdMinutes = new ConfigKey(Long.class, "job.cancel.threshold.minutes", "Advanced", "60", - "Time (in minutes) for async-jobs to be forcely cancelled if it has been in process for long", true, ConfigKey.Scope.Global, 60l); + "Time (in minutes) for async-jobs to be forcely cancelled if it has been in process for long", true, ConfigKey.Scope.Global, 240l); private static final Logger s_logger = Logger.getLogger(AsyncJobManagerImpl.class); private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 3; // 3 seconds - private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC = 60; // 60 seconds private static final int MAX_ONETIME_SCHEDULE_SIZE = 50; private static final int HEARTBEAT_INTERVAL = 2000; @@ -117,7 +117,8 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, private volatile long _executionRunNumber = 1; private final ScheduledExecutorService _heartbeatScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory("AsyncJobMgr-Heartbeat")); - private ExecutorService _executor; + private ExecutorService _apiJobExecutor; + private ExecutorService _workerJobExecutor; @Override public String getConfigComponentName() { @@ -255,13 +256,17 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, } }); - for (Long id : wakeupList) { - // TODO, we assume that all jobs in this category is API job only - AsyncJobVO jobToWakeup = _jobDao.findById(id); - if (jobToWakeup != null && (jobToWakeup.getPendingSignals() & AsyncJob.Constants.SIGNAL_MASK_WAKEUP) != 0) - scheduleExecution(jobToWakeup, false); - } - + // + // disable wakeup scheduling now, since all API jobs are currently using block-waiting for sub-jobs + // + /* + for (Long id : wakeupList) { + // TODO, we assume that all jobs in this category is API job only + AsyncJobVO jobToWakeup = _jobDao.findById(id); + if (jobToWakeup != null && (jobToWakeup.getPendingSignals() & AsyncJob.Constants.SIGNAL_MASK_WAKEUP) != 0) + scheduleExecution(jobToWakeup, false); + } + */ _messageBus.publish(null, AsyncJob.Topics.JOB_STATE, PublishScope.GLOBAL, jobId); } @@ -365,23 +370,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, } SyncQueueVO queue = null; - - // to deal with temporary DB exceptions like DB deadlock/Lock-wait time out cased rollbacks - // we retry five times until we throw an exception - Random random = new Random(); - - for (int i = 0; i < 5; i++) { - queue = _queueMgr.queue(syncObjType, syncObjId, SyncQueueItem.AsyncJobContentType, job.getId(), queueSizeLimit); - if (queue != null) { - break; - } - - try { - Thread.sleep(1000 + random.nextInt(5000)); - } catch (InterruptedException e) { - } - } - + queue = _queueMgr.queue(syncObjType, syncObjId, SyncQueueItem.AsyncJobContentType, job.getId(), queueSizeLimit); if (queue == null) throw new CloudRuntimeException("Unable to insert queue item into database, DB is full?"); } @@ -406,7 +395,10 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, if (executeInContext) { runnable.run(); } else { - _executor.submit(runnable); + if (job.getDispatcher() == null || job.getDispatcher().equalsIgnoreCase("ApiAsyncJobDispatcher")) + _apiJobExecutor.submit(runnable); + else + _workerJobExecutor.submit(runnable); } } @@ -445,6 +437,24 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, private Runnable getExecutorRunnable(final AsyncJob job) { return new ManagedContextRunnable() { + + @Override + public void run() { + // register place-holder context to avoid installing system account call context + if (CallContext.current() == null) + CallContext.registerPlaceHolderContext(); + + if (job.getRelated() != null && !job.getRelated().isEmpty()) + NDC.push("job-" + job.getRelated() + "/" + "job-" + job.getId()); + else + NDC.push("job-" + job.getId()); + try { + super.run(); + } finally { + NDC.pop(); + } + } + @Override protected void runInContext() { long runNumber = getJobRunNumber(); @@ -550,17 +560,41 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, job.setSyncSource(item); - job.setExecutingMsid(getMsid()); - _jobDao.update(job.getId(), job); + // + // TODO: a temporary solution to work-around DB deadlock situation + // + // to live with DB deadlocks, we will give a chance for job to be rescheduled + // in case of exceptions (most-likely DB deadlock exceptions) + try { + job.setExecutingMsid(getMsid()); + _jobDao.update(job.getId(), job); + } catch (Exception e) { + s_logger.warn("Unexpected exception while dispatching job-" + item.getContentId(), e); + + try { + _queueMgr.returnItem(item.getId()); + } catch (Throwable thr) { + s_logger.error("Unexpected exception while returning job-" + item.getContentId() + " to queue", thr); + } + } try { scheduleExecution(job); } catch (RejectedExecutionException e) { s_logger.warn("Execution for job-" + job.getId() + " is rejected, return it to the queue for next turn"); - _queueMgr.returnItem(item.getId()); - job.setExecutingMsid(null); - _jobDao.update(job.getId(), job); + try { + _queueMgr.returnItem(item.getId()); + } catch (Exception e2) { + s_logger.error("Unexpected exception while returning job-" + item.getContentId() + " to queue", e2); + } + + try { + job.setExecutingMsid(null); + _jobDao.update(job.getId(), job); + } catch (Exception e3) { + s_logger.warn("Unexpected exception while update job-" + item.getContentId() + " msid for bookkeeping"); + } } } else { @@ -653,8 +687,24 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, private Runnable getHeartbeatTask() { return new ManagedContextRunnable() { + @Override protected void runInContext() { + GlobalLock scanLock = GlobalLock.getInternLock("AsyncJobManagerHeartbeat"); + try { + if (scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) { + try { + reallyRun(); + } finally { + scanLock.unlock(); + } + } + } finally { + scanLock.releaseRef(); + } + } + + protected void reallyRun() { try { List l = _queueMgr.dequeueFromAny(getMsid(), MAX_ONETIME_SCHEDULE_SIZE); if (l != null && l.size() > 0) { @@ -703,14 +753,16 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, try { s_logger.trace("Begin cleanup expired async-jobs"); - Date cutTime = new Date(DateUtil.currentGMTTime().getTime() - JobExpireMinutes.value() * 1000); + Date cutTime = new Date(DateUtil.currentGMTTime().getTime() - JobExpireMinutes.value() * 60000); // limit to 100 jobs per turn, this gives cleanup throughput as 600 jobs per minute // hopefully this will be fast enough to balance potential growth of job table //1) Expire unfinished jobs that weren't processed yet List l = _jobDao.getExpiredUnfinishedJobs(cutTime, 100); for (AsyncJobVO job : l) { - s_logger.trace("Expunging unfinished job " + job); + s_logger.info("Expunging unfinished job " + job); + + _jobMonitor.unregisterByJobId(job.getId()); expungeAsyncJob(job); } @@ -718,15 +770,19 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, List completedJobs = _jobDao.getExpiredCompletedJobs(cutTime, 100); for (AsyncJobVO job : completedJobs) { s_logger.trace("Expunging completed job " + job); + expungeAsyncJob(job); } // forcefully cancel blocking queue items if they've been staying there for too long - List blockItems = _queueMgr.getBlockedQueueItems(JobCancelThresholdMinutes.value() * 1000, false); + List blockItems = _queueMgr.getBlockedQueueItems(JobCancelThresholdMinutes.value() * 60000, false); if (blockItems != null && blockItems.size() > 0) { for (SyncQueueItemVO item : blockItems) { if (item.getContentType().equalsIgnoreCase(SyncQueueItem.AsyncJobContentType)) { + s_logger.info("Remove Job-" + item.getContentId() + " from Queue-" + item.getId() + " since it has been blocked for too long"); completeAsyncJob(item.getContentId(), JobInfo.Status.FAILED, 0, "Job is cancelled as it has been blocking others for too long"); + + _jobMonitor.unregisterByJobId(item.getContentId()); } // purge the item and resume queue processing @@ -847,10 +903,14 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, final Properties dbProps = DbProperties.getDbProperties(); final int cloudMaxActive = Integer.parseInt(dbProps.getProperty("db.cloud.maxActive")); - int poolSize = (cloudMaxActive * 2) / 3; + int apiPoolSize = cloudMaxActive / 2; + int workPoolSize = (cloudMaxActive * 2) / 3; - s_logger.info("Start AsyncJobManager thread pool in size " + poolSize); - _executor = Executors.newFixedThreadPool(poolSize, new NamedThreadFactory(AsyncJobManager.JOB_POOL_THREAD_PREFIX)); + s_logger.info("Start AsyncJobManager API executor thread pool in size " + apiPoolSize); + _apiJobExecutor = Executors.newFixedThreadPool(apiPoolSize, new NamedThreadFactory(AsyncJobManager.API_JOB_POOL_THREAD_PREFIX)); + + s_logger.info("Start AsyncJobManager Work executor thread pool in size " + workPoolSize); + _workerJobExecutor = Executors.newFixedThreadPool(workPoolSize, new NamedThreadFactory(AsyncJobManager.WORK_JOB_POOL_THREAD_PREFIX)); } catch (final Exception e) { throw new ConfigurationException("Unable to load db.properties to configure AsyncJobManagerImpl"); } @@ -933,7 +993,8 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, @Override public boolean stop() { _heartbeatScheduler.shutdown(); - _executor.shutdown(); + _apiJobExecutor.shutdown(); + _workerJobExecutor.shutdown(); return true; } diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java index 671818130f9..b1cac3e79a5 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java @@ -17,6 +17,7 @@ package org.apache.cloudstack.framework.jobs.impl; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.Timer; import java.util.concurrent.atomic.AtomicInteger; @@ -38,8 +39,7 @@ import com.cloud.utils.component.ManagerBase; public class AsyncJobMonitor extends ManagerBase { public static final Logger s_logger = Logger.getLogger(AsyncJobMonitor.class); - @Inject - private MessageBus _messageBus; + @Inject private MessageBus _messageBus; private final Map _activeTasks = new HashMap(); private final Timer _timer = new Timer(); @@ -86,15 +86,16 @@ public class AsyncJobMonitor extends ManagerBase { synchronized (this) { for (Map.Entry entry : _activeTasks.entrySet()) { if (entry.getValue().millisSinceLastJobHeartbeat() > _inactivityWarningThresholdMs) { - s_logger.warn("Task (job-" + entry.getValue().getJobId() + ") has been pending for " + entry.getValue().millisSinceLastJobHeartbeat() / 1000 + - " seconds"); + s_logger.warn("Task (job-" + entry.getValue().getJobId() + ") has been pending for " + + entry.getValue().millisSinceLastJobHeartbeat() / 1000 + " seconds"); } } } } @Override - public boolean configure(String name, Map params) throws ConfigurationException { + public boolean configure(String name, Map params) + throws ConfigurationException { _messageBus.subscribe(AsyncJob.Topics.JOB_HEARTBEAT, MessageDispatcher.getDispatcher(this)); _timer.scheduleAtFixedRate(new ManagedContextTimerTask() { @@ -114,7 +115,7 @@ public class AsyncJobMonitor extends ManagerBase { assert (_activeTasks.get(runNumber) == null); long threadId = Thread.currentThread().getId(); - boolean fromPoolThread = Thread.currentThread().getName().contains(AsyncJobManager.JOB_POOL_THREAD_PREFIX); + boolean fromPoolThread = Thread.currentThread().getName().contains(AsyncJobManager.API_JOB_POOL_THREAD_PREFIX); ActiveTaskRecord record = new ActiveTaskRecord(jobId, threadId, fromPoolThread); _activeTasks.put(runNumber, record); if (fromPoolThread) @@ -141,6 +142,25 @@ public class AsyncJobMonitor extends ManagerBase { } } + public void unregisterByJobId(long jobId) { + synchronized (this) { + Iterator> it = _activeTasks.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + if (entry.getValue().getJobId() == jobId) { + s_logger.info("Remove Job-" + entry.getValue().getJobId() + " from job monitoring due to job cancelling"); + + if (entry.getValue().isPoolThread()) + _activePoolThreads.decrementAndGet(); + else + _activeInplaceThreads.decrementAndGet(); + + it.remove(); + } + } + } + } + public int getActivePoolThreads() { return _activePoolThreads.get(); } diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java index 24af392f0f4..d1ee2df7598 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobVO.java @@ -132,7 +132,7 @@ public class AsyncJobVO implements AsyncJob, JobInfo { public AsyncJobVO() { uuid = UUID.randomUUID().toString(); - related = UUID.randomUUID().toString(); + related = ""; status = Status.IN_PROGRESS; } diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java index 67c4b867afe..735d7cf73e2 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/JobSerializerHelper.java @@ -29,6 +29,7 @@ import java.lang.reflect.Type; import org.apache.commons.codec.binary.Base64; import org.apache.log4j.Logger; +import com.cloud.utils.exception.CloudRuntimeException; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonDeserializationContext; @@ -40,14 +41,12 @@ import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import com.cloud.utils.exception.CloudRuntimeException; - /** * Note: toPairList and appendPairList only support simple POJO objects currently */ public class JobSerializerHelper { private static final Logger s_logger = Logger.getLogger(JobSerializerHelper.class); - public static String token = "/"; + public static final String token = "/"; private static Gson s_gson; static { diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java index 09974a1c133..5160e05db77 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java @@ -83,8 +83,8 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage return Transaction.execute(new TransactionCallback() { @Override public SyncQueueItemVO doInTransaction(TransactionStatus status) { - SyncQueueVO queueVO = _syncQueueDao.lockRow(queueId, true); - if (queueVO == null) { + SyncQueueVO queueVO = _syncQueueDao.findById(queueId); + if(queueVO == null) { s_logger.error("Sync queue(id: " + queueId + ") does not exist"); return null; } @@ -139,11 +139,11 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage @Override public void doInTransactionWithoutResult(TransactionStatus status) { List l = _syncQueueItemDao.getNextQueueItems(maxItems); - if (l != null && l.size() > 0) { - for (SyncQueueItemVO item : l) { - SyncQueueVO queueVO = _syncQueueDao.lockRow(item.getQueueId(), true); - SyncQueueItemVO itemVO = _syncQueueItemDao.lockRow(item.getId(), true); - if (queueReadyToProcess(queueVO) && itemVO.getLastProcessNumber() == null) { + if(l != null && l.size() > 0) { + for(SyncQueueItemVO item : l) { + SyncQueueVO queueVO = _syncQueueDao.findById(item.getQueueId()); + SyncQueueItemVO itemVO = _syncQueueItemDao.findById(item.getId()); + if(queueReadyToProcess(queueVO) && itemVO.getLastProcessNumber() == null) { Long processNumber = queueVO.getLastProcessNumber(); if (processNumber == null) processNumber = new Long(1); @@ -184,8 +184,8 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage @Override public void doInTransactionWithoutResult(TransactionStatus status) { SyncQueueItemVO itemVO = _syncQueueItemDao.findById(queueItemId); - if (itemVO != null) { - SyncQueueVO queueVO = _syncQueueDao.lockRow(itemVO.getQueueId(), true); + if(itemVO != null) { + SyncQueueVO queueVO = _syncQueueDao.findById(itemVO.getQueueId()); _syncQueueItemDao.expunge(itemVO.getId()); @@ -213,8 +213,8 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage @Override public void doInTransactionWithoutResult(TransactionStatus status) { SyncQueueItemVO itemVO = _syncQueueItemDao.findById(queueItemId); - if (itemVO != null) { - SyncQueueVO queueVO = _syncQueueDao.lockRow(itemVO.getQueueId(), true); + if(itemVO != null) { + SyncQueueVO queueVO = _syncQueueDao.findById(itemVO.getQueueId()); itemVO.setLastProcessMsid(null); itemVO.setLastProcessNumber(null); @@ -242,18 +242,15 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage } private boolean queueReadyToProcess(SyncQueueVO queueVO) { - return true; + int nActiveItems = _syncQueueItemDao.getActiveQueueItemCount(queueVO.getId()); + if (nActiveItems < queueVO.getQueueSizeLimit()) + return true; - // - // TODO - // - // Need to disable concurrency disable at queue level due to the need to support - // job wake-up dispatching task - // - // Concurrency control is better done at higher level and leave the job scheduling/serializing simpler - // - - // return queueVO.getQueueSize() < queueVO.getQueueSizeLimit(); + if (s_logger.isDebugEnabled()) + s_logger.debug("Queue (queue id, sync type, sync id) - (" + queueVO.getId() + + "," + queueVO.getSyncObjType() + ", " + queueVO.getSyncObjId() + + ") is reaching concurrency limit " + queueVO.getQueueSizeLimit()); + return false; } @Override diff --git a/framework/managed-context/findbugsExcludeFilter.xml b/framework/managed-context/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/framework/managed-context/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/framework/managed-context/pom.xml b/framework/managed-context/pom.xml index 1b7cda3b2e0..2bb0a181d9d 100644 --- a/framework/managed-context/pom.xml +++ b/framework/managed-context/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-maven-standard - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../maven-standard/pom.xml diff --git a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java index d33521501f4..b4a9758420b 100644 --- a/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java +++ b/framework/managed-context/src/main/java/org/apache/cloudstack/managed/context/ManagedContextRunnable.java @@ -42,7 +42,7 @@ public abstract class ManagedContextRunnable implements Runnable { } @Override - final public void run() { + public void run() { getContext().runWithContext(new Runnable() { @Override public void run() { diff --git a/framework/pom.xml b/framework/pom.xml index 505c49e99c4..97731bc833d 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -24,10 +24,23 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT install + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + cloudstack-checkstyle + none + false + + + + ipc diff --git a/framework/rest/findbugsExcludeFilter.xml b/framework/rest/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/rest/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/rest/pom.xml b/framework/rest/pom.xml index e263d7513e2..cdbee8e8f6e 100644 --- a/framework/rest/pom.xml +++ b/framework/rest/pom.xml @@ -22,7 +22,7 @@ org.apache.cloudstack cloudstack-framework - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml cloud-framework-rest diff --git a/framework/security/findbugsExcludeFilter.xml b/framework/security/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/security/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/security/pom.xml b/framework/security/pom.xml index 42627f524a8..13e89b8f22d 100644 --- a/framework/security/pom.xml +++ b/framework/security/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-framework - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/framework/spring/lifecycle/findbugsExcludeFilter.xml b/framework/spring/lifecycle/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/spring/lifecycle/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/spring/lifecycle/pom.xml b/framework/spring/lifecycle/pom.xml index d3ea121b532..ac01c8201c7 100644 --- a/framework/spring/lifecycle/pom.xml +++ b/framework/spring/lifecycle/pom.xml @@ -16,7 +16,7 @@ org.apache.cloudstack cloud-maven-standard - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../../maven-standard/pom.xml diff --git a/framework/spring/module/findbugsExcludeFilter.xml b/framework/spring/module/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..ef75dbd300d --- /dev/null +++ b/framework/spring/module/findbugsExcludeFilter.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/framework/spring/module/pom.xml b/framework/spring/module/pom.xml index 33196a73ec2..b03703ea98f 100644 --- a/framework/spring/module/pom.xml +++ b/framework/spring/module/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloud-maven-standard - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../../maven-standard/pom.xml diff --git a/maven-standard/pom.xml b/maven-standard/pom.xml index cf10d297970..ea545a7eac1 100644 --- a/maven-standard/pom.xml +++ b/maven-standard/pom.xml @@ -25,7 +25,7 @@ org.apache.cloudstack cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/packaging/centos63/cloud-agent.rc b/packaging/centos63/cloud-agent.rc index ab49524af4b..ece4c2732f8 100755 --- a/packaging/centos63/cloud-agent.rc +++ b/packaging/centos63/cloud-agent.rc @@ -24,12 +24,10 @@ . /etc/rc.d/init.d/functions -whatami=cloudstack-agent - # set environment variables -SHORTNAME="$whatami" -PIDFILE=/var/run/"$whatami".pid +SHORTNAME=`basename $0` +PIDFILE=/var/run/"$SHORTNAME".pid LOCKFILE=/var/lock/subsys/"$SHORTNAME" LOGDIR=/var/log/cloudstack/agent LOGFILE=${LOGDIR}/agent.log @@ -112,7 +110,7 @@ case "$1" in fi ;; *) - echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}" + echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}" RETVAL=3 esac diff --git a/packaging/centos63/cloud-ipallocator.rc b/packaging/centos63/cloud-ipallocator.rc index 08cf9c88a0f..d26287dcb3c 100755 --- a/packaging/centos63/cloud-ipallocator.rc +++ b/packaging/centos63/cloud-ipallocator.rc @@ -23,12 +23,10 @@ . /etc/rc.d/init.d/functions -whatami=cloud-external-ipallocator - # set environment variables -SHORTNAME="$whatami" -PIDFILE=/var/run/"$whatami".pid +SHORTNAME=`basename $0` +PIDFILE=/var/run/"$SHORTNAME".pid LOCKFILE=/var/lock/subsys/"$SHORTNAME" LOGFILE=/var/log/cloudstack/ipallocator/ipallocator.log PROGNAME="External IPAllocator" @@ -90,7 +88,7 @@ case "$1" in fi ;; *) - echo $"Usage: $whatami {start|stop|restart|condrestart|status|help}" + echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}" RETVAL=3 esac diff --git a/packaging/centos63/package.sh b/packaging/centos63/package.sh index 04b92586514..fa004afff33 100755 --- a/packaging/centos63/package.sh +++ b/packaging/centos63/package.sh @@ -17,101 +17,93 @@ # under the License. function usage() { - echo "" - echo "usage: ./package.sh [-p|--pack] [-h|--help] [ARGS]" - echo "" - echo "The commonly used Arguments are:" - echo "oss|OSS To package with only redistributable libraries (default)" - echo "noredist|NOREDIST To package with non-redistributable libraries" - echo "" - echo "Examples: ./package.sh -p|--pack oss|OSS" - echo " ./package.sh -p|--pack noredist|NOREDIST" - echo " ./package.sh (Default OSS)" - exit 1 + echo "" + echo "usage: ./package.sh [-p|--pack] [-h|--help] [ARGS]" + echo "" + echo "The commonly used Arguments are:" + echo "oss|OSS To package with only redistributable libraries (default)" + echo "noredist|NOREDIST To package with non-redistributable libraries" + echo "" + echo "Examples: ./package.sh -p|--pack oss|OSS" + echo " ./package.sh -p|--pack noredist|NOREDIST" + echo " ./package.sh (Default OSS)" + exit 1 } function packaging() { - -CWD=`pwd` -RPMDIR=$CWD/../../dist/rpmbuild -PACK_PROJECT=cloudstack -if [ -n "$1" ] ; then - DEFOSSNOSS="-D_ossnoss $packageval" -fi + CWD=`pwd` + RPMDIR=$CWD/../../dist/rpmbuild + PACK_PROJECT=cloudstack + if [ -n "$1" ] ; then + DEFOSSNOSS="-D_ossnoss $packageval" + fi + VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep --color=none '^[0-9]\.'` + if echo $VERSION | grep SNAPSHOT ; then + REALVER=`echo $VERSION | cut -d '-' -f 1` + DEFVER="-D_ver $REALVER" + DEFPRE="-D_prerelease 1" + DEFREL="-D_rel SNAPSHOT" + else + REALVER=`echo $VERSION` + DEFVER="-D_ver $REALVER" + DEFREL="-D_rel 1" + fi -VERSION=`(cd ../../; mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep '^[0-9]\.'` -if echo $VERSION | grep SNAPSHOT ; then - REALVER=`echo $VERSION | cut -d '-' -f 1` - DEFVER="-D_ver $REALVER" - DEFPRE="-D_prerelease 1" - DEFREL="-D_rel SNAPSHOT" -else - REALVER=`echo $VERSION` - DEFVER="-D_ver $REALVER" - DEFREL="-D_rel 1" -fi + mkdir -p $RPMDIR/SPECS + mkdir -p $RPMDIR/BUILD + mkdir -p $RPMDIR/RPMS + mkdir -p $RPMDIR/SRPMS + mkdir -p $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -mkdir -p $RPMDIR/SPECS -mkdir -p $RPMDIR/BUILD -mkdir -p $RPMDIR/RPMS -mkdir -p $RPMDIR/SRPMS -mkdir -p $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION + (cd ../../; tar -c --exclude .git --exclude dist . | tar -C $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -x ) + (cd $RPMDIR/SOURCES/; tar -czf $PACK_PROJECT-$VERSION.tgz $PACK_PROJECT-$VERSION) + cp cloud.spec $RPMDIR/SPECS -(cd ../../; tar -c --exclude .git --exclude dist . | tar -C $RPMDIR/SOURCES/$PACK_PROJECT-$VERSION -x ) -(cd $RPMDIR/SOURCES/; tar -czf $PACK_PROJECT-$VERSION.tgz $PACK_PROJECT-$VERSION) + (cd $RPMDIR; rpmbuild --define "_topdir $RPMDIR" "${DEFVER}" "${DEFREL}" ${DEFPRE+"${DEFPRE}"} ${DEFOSSNOSS+"$DEFOSSNOSS"} -bb SPECS/cloud.spec) -cp cloud.spec $RPMDIR/SPECS - -(cd $RPMDIR; rpmbuild --define "_topdir $RPMDIR" "${DEFVER}" "${DEFREL}" ${DEFPRE+"${DEFPRE}"} ${DEFOSSNOSS+"$DEFOSSNOSS"} -bb SPECS/cloud.spec) - -exit + exit } - if [ $# -lt 1 ] ; then - - packaging - + packaging elif [ $# -gt 0 ] ; then + SHORTOPTS="hp:" + LONGOPTS="help,pack:" - SHORTOPTS="hp:" - LONGOPTS="help,pack:" - - ARGS=$(getopt -s bash -u -a --options $SHORTOPTS --longoptions $LONGOPTS --name $0 -- "$@" ) - eval set -- "$ARGS" - - while [ $# -gt 0 ] ; do - case "$1" in - -h | --help) - usage - exit 0 - ;; - -p | --pack) - echo "Doing CloudStack Packaging ....." - packageval=$2 - if [ "$packageval" == "oss" -o "$packageval" == "OSS" ] ; then - packaging - elif [ "$packageval" == "noredist" -o "$packageval" == "NOREDIST" ] ; then - packaging noredist - else - echo "Error: Incorrect value provided in package.sh script, Please see help ./package.sh --help|-h for more details." - exit 1 - fi - ;; - -) - echo "Unrecognized option..." - usage - exit 1 - ;; - *) - shift - ;; - esac - done + ARGS=$(getopt -s bash -u -a --options $SHORTOPTS --longoptions $LONGOPTS --name $0 -- "$@" ) + eval set -- "$ARGS" + while [ $# -gt 0 ] ; do + case "$1" in + -h | --help) + usage + exit 0 + ;; + -p | --pack) + echo "Doing CloudStack Packaging ....." + packageval=$2 + if [ "$packageval" == "oss" -o "$packageval" == "OSS" ] ; then + packaging + elif [ "$packageval" == "noredist" -o "$packageval" == "NOREDIST" ] ; then + packaging noredist + else + echo "Error: Incorrect value provided in package.sh script, Please see help ./package.sh --help|-h for more details." + exit 1 + fi + ;; + -) + echo "Unrecognized option..." + usage + exit 1 + ;; + *) + shift + ;; + esac + done else - echo "Incorrect choice. Nothing to do." >&2 - echo "Please, execute ./package.sh --help for more help" + echo "Incorrect choice. Nothing to do." >&2 + echo "Please, execute ./package.sh --help for more help" fi diff --git a/packaging/debian/init/cloud-agent b/packaging/debian/init/cloud-agent index e7338752f3e..ff550bb8f66 100755 --- a/packaging/debian/init/cloud-agent +++ b/packaging/debian/init/cloud-agent @@ -96,7 +96,7 @@ start() { wait_for_network - if start_daemon -p $PIDFILE $DAEMON -cp "$CLASSPATH" -pidfile "$PIDFILE" -errfile SYSLOG $CLASS + if start_daemon -p $PIDFILE $DAEMON -cp "$CLASSPATH" -Djna.nosys=true -pidfile "$PIDFILE" -errfile SYSLOG $CLASS RETVAL=$? then rc=0 diff --git a/plugins/acl/static-role-based/findbugsExcludeFilter.xml b/plugins/acl/static-role-based/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/acl/static-role-based/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/acl/static-role-based/pom.xml b/plugins/acl/static-role-based/pom.xml index eca6d2fe3ba..670f22ecc6f 100644 --- a/plugins/acl/static-role-based/pom.xml +++ b/plugins/acl/static-role-based/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/affinity-group-processors/explicit-dedication/findbugsExcludeFilter.xml b/plugins/affinity-group-processors/explicit-dedication/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/affinity-group-processors/explicit-dedication/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/affinity-group-processors/explicit-dedication/pom.xml b/plugins/affinity-group-processors/explicit-dedication/pom.xml index 909e1a7120f..f1d2e7100b6 100644 --- a/plugins/affinity-group-processors/explicit-dedication/pom.xml +++ b/plugins/affinity-group-processors/explicit-dedication/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java index 8c253ee1d31..9aad5f49972 100644 --- a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java +++ b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java @@ -23,10 +23,9 @@ import java.util.Set; import javax.ejb.Local; import javax.inject.Inject; -import org.apache.log4j.Logger; - import org.apache.cloudstack.affinity.dao.AffinityGroupDao; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; +import org.apache.log4j.Logger; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; @@ -120,10 +119,10 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement DataCenterVO zoneOfHost = _dcDao.findById(host.getDataCenterId()); if (resourceList != null && resourceList.size() != 0) { for (DedicatedResourceVO resource : resourceList) { - if ((resource.getHostId() != null && resource.getHostId() == plan.getHostId()) || - (resource.getClusterId() != null && resource.getClusterId() == clusterofHost.getId()) || - (resource.getPodId() != null && resource.getPodId() == podOfHost.getId()) || - (resource.getDataCenterId() != null && resource.getDataCenterId() == zoneOfHost.getId())) { + if ((resource.getHostId() != null && resource.getHostId().longValue() == plan.getHostId().longValue()) || + (resource.getClusterId() != null && resource.getClusterId().longValue() == clusterofHost.getId()) || + (resource.getPodId() != null && resource.getPodId().longValue() == podOfHost.getId()) || + (resource.getDataCenterId() != null && resource.getDataCenterId().longValue() == zoneOfHost.getId())) { canUse = true; } } diff --git a/plugins/affinity-group-processors/host-anti-affinity/findbugsExcludeFilter.xml b/plugins/affinity-group-processors/host-anti-affinity/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/affinity-group-processors/host-anti-affinity/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/affinity-group-processors/host-anti-affinity/pom.xml b/plugins/affinity-group-processors/host-anti-affinity/pom.xml index 99795a05ee7..9eca722fef6 100644 --- a/plugins/affinity-group-processors/host-anti-affinity/pom.xml +++ b/plugins/affinity-group-processors/host-anti-affinity/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/alert-handlers/snmp-alerts/findbugsExcludeFilter.xml b/plugins/alert-handlers/snmp-alerts/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/alert-handlers/snmp-alerts/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/alert-handlers/snmp-alerts/pom.xml b/plugins/alert-handlers/snmp-alerts/pom.xml index c03b3ba4162..cd3ab0f664c 100644 --- a/plugins/alert-handlers/snmp-alerts/pom.xml +++ b/plugins/alert-handlers/snmp-alerts/pom.xml @@ -22,7 +22,7 @@ cloudstack-plugins org.apache.cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/plugins/alert-handlers/syslog-alerts/findbugsExcludeFilter.xml b/plugins/alert-handlers/syslog-alerts/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/alert-handlers/syslog-alerts/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/alert-handlers/syslog-alerts/pom.xml b/plugins/alert-handlers/syslog-alerts/pom.xml index bf56f37194d..96172ef627b 100644 --- a/plugins/alert-handlers/syslog-alerts/pom.xml +++ b/plugins/alert-handlers/syslog-alerts/pom.xml @@ -22,7 +22,7 @@ cloudstack-plugins org.apache.cloudstack - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/plugins/api/discovery/findbugsExcludeFilter.xml b/plugins/api/discovery/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/api/discovery/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/api/discovery/pom.xml b/plugins/api/discovery/pom.xml index 6a2a78e1e71..5eded130fd4 100644 --- a/plugins/api/discovery/pom.xml +++ b/plugins/api/discovery/pom.xml @@ -26,7 +26,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java b/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java index 206d79322f3..be0d5d53260 100644 --- a/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/api/command/user/discovery/ListApisCmd.java @@ -36,7 +36,9 @@ import com.cloud.user.User; @APICommand(name = "listApis", responseObject = ApiDiscoveryResponse.class, description = "lists all available apis on the server, provided by the Api Discovery plugin", - since = "4.1.0") + since = "4.1.0", + requestHasSensitiveInfo = false, + responseHasSensitiveInfo = false) public class ListApisCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ListApisCmd.class.getName()); diff --git a/plugins/api/rate-limit/findbugsExcludeFilter.xml b/plugins/api/rate-limit/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/api/rate-limit/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/api/rate-limit/pom.xml b/plugins/api/rate-limit/pom.xml index f7258821360..7007b35aa59 100644 --- a/plugins/api/rate-limit/pom.xml +++ b/plugins/api/rate-limit/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java b/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java index 9e415e64510..fab68e3856c 100644 --- a/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java +++ b/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/admin/ratelimit/ResetApiLimitCmd.java @@ -37,7 +37,8 @@ import org.apache.cloudstack.ratelimit.ApiRateLimitService; import com.cloud.configuration.Config; import com.cloud.user.Account; -@APICommand(name = "resetApiLimit", responseObject = ApiLimitResponse.class, description = "Reset api count") +@APICommand(name = "resetApiLimit", responseObject = ApiLimitResponse.class, description = "Reset api count", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ResetApiLimitCmd extends BaseCmd { private static final Logger s_logger = Logger.getLogger(ResetApiLimitCmd.class.getName()); diff --git a/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java b/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java index 24288957563..51b2064fa90 100644 --- a/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java +++ b/plugins/api/rate-limit/src/org/apache/cloudstack/api/command/user/ratelimit/GetApiLimitCmd.java @@ -32,7 +32,8 @@ import org.apache.cloudstack.ratelimit.ApiRateLimitService; import com.cloud.configuration.Config; import com.cloud.user.Account; -@APICommand(name = "getApiLimit", responseObject = ApiLimitResponse.class, description = "Get API limit count for the caller") +@APICommand(name = "getApiLimit", responseObject = ApiLimitResponse.class, description = "Get API limit count for the caller", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class GetApiLimitCmd extends BaseCmd { private static final Logger s_logger = Logger.getLogger(GetApiLimitCmd.class.getName()); diff --git a/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java b/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java index d7c6a551431..b46dc15b7e4 100644 --- a/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java +++ b/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java @@ -149,7 +149,7 @@ public class ApiRateLimitServiceImpl extends AdapterBase implements APIChecker, } Long accountId = user.getAccountId(); Account account = _accountService.getAccount(accountId); - if (_accountService.isRootAdmin(account.getType())) { + if (_accountService.isRootAdmin(account.getId())) { // no API throttling on root admin return true; } @@ -191,7 +191,7 @@ public class ApiRateLimitServiceImpl extends AdapterBase implements APIChecker, @Override public void setMaxAllowed(int max) { - this.maxAllowed = max; + maxAllowed = max; } diff --git a/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java b/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java index 0091b15b10d..a16179eed51 100644 --- a/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java +++ b/plugins/api/rate-limit/test/org/apache/cloudstack/ratelimit/ApiRateLimitTest.java @@ -53,7 +53,7 @@ public class ApiRateLimitTest { private static Account s_testAccount; @BeforeClass - public static void setUp() throws ConfigurationException { +public static void setUp() throws ConfigurationException { when(s_configDao.getValue(Config.ApiLimitInterval.key())).thenReturn(null); when(s_configDao.getValue(Config.ApiLimitMax.key())).thenReturn(null); @@ -72,7 +72,7 @@ public class ApiRateLimitTest { s_testAccount = acct; when(s_accountService.getAccount(5L)).thenReturn(s_testAccount); - when(s_accountService.isRootAdmin(Account.ACCOUNT_TYPE_NORMAL)).thenReturn(false); + when(s_accountService.isRootAdmin(5L)).thenReturn(false); } @Before @@ -183,7 +183,7 @@ public class ApiRateLimitTest { s_limitService.setMaxAllowed(allowedRequests); s_limitService.setTimeToLive(1); - User key = this.createFakeUser(); + User key = createFakeUser(); assertTrue("The first request should be allowed", isUnderLimit(key)); @@ -199,7 +199,7 @@ public class ApiRateLimitTest { s_limitService.setMaxAllowed(allowedRequests); s_limitService.setTimeToLive(1); - User key = this.createFakeUser(); + User key = createFakeUser(); assertTrue("The first request should be allowed", isUnderLimit(key)); @@ -216,7 +216,7 @@ public class ApiRateLimitTest { s_limitService.setMaxAllowed(allowedRequests); s_limitService.setTimeToLive(1); - User key = this.createFakeUser(); + User key = createFakeUser(); for (int i = 0; i < 5; i++) { assertTrue("Issued 5 requests", isUnderLimit(key)); diff --git a/plugins/database/mysql-ha/pom.xml b/plugins/database/mysql-ha/pom.xml new file mode 100644 index 00000000000..be7f976c102 --- /dev/null +++ b/plugins/database/mysql-ha/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + cloud-plugin-database-mysqlha + Apache CloudStack Plugin - MySQL HA Strategy + + org.apache.cloudstack + cloudstack-plugins + 4.5.0-SNAPSHOT + ../../pom.xml + + + + mysql + mysql-connector-java + provided + + + diff --git a/framework/db/src/com/cloud/utils/db/StaticStrategy.java b/plugins/database/mysql-ha/src/com/cloud/utils/db/StaticStrategy.java similarity index 100% rename from framework/db/src/com/cloud/utils/db/StaticStrategy.java rename to plugins/database/mysql-ha/src/com/cloud/utils/db/StaticStrategy.java diff --git a/plugins/dedicated-resources/findbugsExcludeFilter.xml b/plugins/dedicated-resources/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/dedicated-resources/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/dedicated-resources/pom.xml b/plugins/dedicated-resources/pom.xml index 823a58ed62c..341f1fe2fe2 100644 --- a/plugins/dedicated-resources/pom.xml +++ b/plugins/dedicated-resources/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../pom.xml diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java index 4f8cd8ca570..9ef642e8d31 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateClusterCmd.java @@ -39,7 +39,8 @@ import com.cloud.dc.DedicatedResources; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "dedicateCluster", description = "Dedicate an existing cluster", responseObject = DedicateClusterResponse.class) +@APICommand(name = "dedicateCluster", description = "Dedicate an existing cluster", responseObject = DedicateClusterResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DedicateClusterCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DedicateClusterCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateHostCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateHostCmd.java index d3cce5ae5e7..978821a1f0c 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateHostCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateHostCmd.java @@ -39,7 +39,8 @@ import com.cloud.dc.DedicatedResources; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "dedicateHost", description = "Dedicates a host.", responseObject = DedicateHostResponse.class) +@APICommand(name = "dedicateHost", description = "Dedicates a host.", responseObject = DedicateHostResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DedicateHostCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DedicateHostCmd.class.getName()); private static final String s_name = "dedicatehostresponse"; diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicatePodCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicatePodCmd.java index e823fd55491..d18f02d686f 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicatePodCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicatePodCmd.java @@ -39,7 +39,8 @@ import com.cloud.dc.DedicatedResources; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "dedicatePod", description = "Dedicates a Pod.", responseObject = DedicatePodResponse.class) +@APICommand(name = "dedicatePod", description = "Dedicates a Pod.", responseObject = DedicatePodResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DedicatePodCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DedicatePodCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateZoneCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateZoneCmd.java index 0e427aaa26d..ee71dfecc41 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateZoneCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/DedicateZoneCmd.java @@ -39,7 +39,8 @@ import com.cloud.dc.DedicatedResources; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "dedicateZone", description = "Dedicates a zones.", responseObject = DedicateZoneResponse.class) +@APICommand(name = "dedicateZone", description = "Dedicates a zones.", responseObject = DedicateZoneResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DedicateZoneCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(DedicateZoneCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedClustersCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedClustersCmd.java index a2022a53e0b..a8c192dcd8e 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedClustersCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedClustersCmd.java @@ -40,7 +40,8 @@ import com.cloud.dc.DedicatedResourceVO; import com.cloud.dc.DedicatedResources; import com.cloud.utils.Pair; -@APICommand(name = "listDedicatedClusters", description = "Lists dedicated clusters.", responseObject = DedicateClusterResponse.class) +@APICommand(name = "listDedicatedClusters", description = "Lists dedicated clusters.", responseObject = DedicateClusterResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListDedicatedClustersCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListDedicatedClustersCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedHostsCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedHostsCmd.java index d3b326d5a29..3c167e8966a 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedHostsCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedHostsCmd.java @@ -40,7 +40,8 @@ import com.cloud.dc.DedicatedResourceVO; import com.cloud.dc.DedicatedResources; import com.cloud.utils.Pair; -@APICommand(name = "listDedicatedHosts", description = "Lists dedicated hosts.", responseObject = DedicateHostResponse.class) +@APICommand(name = "listDedicatedHosts", description = "Lists dedicated hosts.", responseObject = DedicateHostResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListDedicatedHostsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListDedicatedHostsCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedPodsCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedPodsCmd.java index d7cd4c26f16..5198e49e7a3 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedPodsCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedPodsCmd.java @@ -40,7 +40,8 @@ import com.cloud.dc.DedicatedResourceVO; import com.cloud.dc.DedicatedResources; import com.cloud.utils.Pair; -@APICommand(name = "listDedicatedPods", description = "Lists dedicated pods.", responseObject = DedicatePodResponse.class) +@APICommand(name = "listDedicatedPods", description = "Lists dedicated pods.", responseObject = DedicatePodResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListDedicatedPodsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListDedicatedPodsCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedZonesCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedZonesCmd.java index 07b8b19bb75..e75b73b2e4b 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedZonesCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ListDedicatedZonesCmd.java @@ -40,7 +40,8 @@ import com.cloud.dc.DedicatedResourceVO; import com.cloud.dc.DedicatedResources; import com.cloud.utils.Pair; -@APICommand(name = "listDedicatedZones", description = "List dedicated zones.", responseObject = DedicateZoneResponse.class) +@APICommand(name = "listDedicatedZones", description = "List dedicated zones.", responseObject = DedicateZoneResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListDedicatedZonesCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListDedicatedZonesCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedClusterCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedClusterCmd.java index e065da2c0c2..b1ec3605da5 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedClusterCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedClusterCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.dedicated.DedicatedService; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "releaseDedicatedCluster", description = "Release the dedication for cluster", responseObject = SuccessResponse.class) +@APICommand(name = "releaseDedicatedCluster", description = "Release the dedication for cluster", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReleaseDedicatedClusterCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedClusterCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedHostCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedHostCmd.java index 41e668c0e41..bddef135688 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedHostCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedHostCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.dedicated.DedicatedService; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "releaseDedicatedHost", description = "Release the dedication for host", responseObject = SuccessResponse.class) +@APICommand(name = "releaseDedicatedHost", description = "Release the dedication for host", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReleaseDedicatedHostCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedHostCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedPodCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedPodCmd.java index 47ea475e0fc..f764e8abed1 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedPodCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedPodCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.dedicated.DedicatedService; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "releaseDedicatedPod", description = "Release the dedication for the pod", responseObject = SuccessResponse.class) +@APICommand(name = "releaseDedicatedPod", description = "Release the dedication for the pod", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReleaseDedicatedPodCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedPodCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedZoneCmd.java b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedZoneCmd.java index 69185d62dc9..df04491e2c7 100644 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedZoneCmd.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/api/commands/ReleaseDedicatedZoneCmd.java @@ -33,7 +33,8 @@ import org.apache.cloudstack.dedicated.DedicatedService; import com.cloud.event.EventTypes; import com.cloud.user.Account; -@APICommand(name = "releaseDedicatedZone", description = "Release dedication of zone", responseObject = SuccessResponse.class) +@APICommand(name = "releaseDedicatedZone", description = "Release dedication of zone", responseObject = SuccessResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ReleaseDedicatedZoneCmd extends BaseAsyncCmd { public static final Logger s_logger = Logger.getLogger(ReleaseDedicatedZoneCmd.class.getName()); diff --git a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java index b82b361f7e8..1e584c38bd6 100755 --- a/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java +++ b/plugins/dedicated-resources/src/org/apache/cloudstack/dedicated/DedicatedResourceManagerImpl.java @@ -158,14 +158,14 @@ public class DedicatedResourceManagerImpl implements DedicatedService { throw new CloudRuntimeException("Pod " + pod.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain"); } if (accountId != null) { - if (dPod.getAccountId() == accountId) { + if (dPod.getAccountId().equals(accountId)) { podsToRelease.add(dPod); } else { s_logger.error("Pod " + pod.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain"); throw new CloudRuntimeException("Pod " + pod.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain"); } } else { - if (dPod.getAccountId() == null && dPod.getDomainId() == domainId) { + if (dPod.getAccountId() == null && dPod.getDomainId().equals(domainId)) { podsToRelease.add(dPod); } } @@ -184,7 +184,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { throw new CloudRuntimeException("Cluster " + cluster.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain"); } if (accountId != null) { - if (dCluster.getAccountId() == accountId) { + if (dCluster.getAccountId().equals(accountId)) { clustersToRelease.add(dCluster); } else { s_logger.error("Cluster " + cluster.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain"); @@ -192,7 +192,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { " is dedicated to different account/domain"); } } else { - if (dCluster.getAccountId() == null && dCluster.getDomainId() == domainId) { + if (dCluster.getAccountId() == null && dCluster.getDomainId().equals(domainId)) { clustersToRelease.add(dCluster); } } @@ -211,14 +211,14 @@ public class DedicatedResourceManagerImpl implements DedicatedService { throw new CloudRuntimeException("Host " + host.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain"); } if (accountId != null) { - if (dHost.getAccountId() == accountId) { + if (dHost.getAccountId().equals(accountId)) { hostsToRelease.add(dHost); } else { s_logger.error("Host " + host.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain"); throw new CloudRuntimeException("Host " + host.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain"); } } else { - if (dHost.getAccountId() == null && dHost.getDomainId() == domainId) { + if (dHost.getAccountId() == null && dHost.getDomainId().equals(domainId)) { hostsToRelease.add(dHost); } } @@ -300,7 +300,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { boolean domainIdInChildreanList = getDomainChildIds(dedicatedZoneOfPod.getDomainId()).contains(domainId); //can dedicate a pod to an account/domain if zone is dedicated to parent-domain if (dedicatedZoneOfPod.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || - (accountId != null && !(dedicatedZoneOfPod.getDomainId() == domainId || domainIdInChildreanList))) { + (accountId != null && !(dedicatedZoneOfPod.getDomainId().equals(domainId) || domainIdInChildreanList))) { DataCenterVO zone = _zoneDao.findById(pod.getDataCenterId()); s_logger.error("Cannot dedicate Pod. Its zone is already dedicated"); throw new CloudRuntimeException("Pod's Zone " + zone.getName() + " is already dedicated"); @@ -320,7 +320,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { /*if all dedicated resources belongs to same account and domain then we should release dedication and make new entry for this Pod*/ if (accountId != null) { - if (dCluster.getAccountId() == accountId) { + if (dCluster.getAccountId().equals(accountId)) { clustersToRelease.add(dCluster); } else { s_logger.error("Cluster " + cluster.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain"); @@ -328,7 +328,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { " is dedicated to different account/domain"); } } else { - if (dCluster.getAccountId() == null && dCluster.getDomainId() == domainId) { + if (dCluster.getAccountId() == null && dCluster.getDomainId().equals(domainId)) { clustersToRelease.add(dCluster); } } @@ -347,14 +347,14 @@ public class DedicatedResourceManagerImpl implements DedicatedService { throw new CloudRuntimeException("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain"); } if (accountId != null) { - if (dHost.getAccountId() == accountId) { + if (dHost.getAccountId().equals(accountId)) { hostsToRelease.add(dHost); } else { s_logger.error("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain"); throw new CloudRuntimeException("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain"); } } else { - if (dHost.getAccountId() == null && dHost.getDomainId() == domainId) { + if (dHost.getAccountId() == null && dHost.getDomainId().equals(domainId)) { hostsToRelease.add(dHost); } } @@ -429,7 +429,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { boolean domainIdInChildreanList = getDomainChildIds(dedicatedPodOfCluster.getDomainId()).contains(domainId); //can dedicate a cluster to an account/domain if pod is dedicated to parent-domain if (dedicatedPodOfCluster.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || - (accountId != null && !(dedicatedPodOfCluster.getDomainId() == domainId || domainIdInChildreanList))) { + (accountId != null && !(dedicatedPodOfCluster.getDomainId().equals(domainId) || domainIdInChildreanList))) { s_logger.error("Cannot dedicate Cluster. Its Pod is already dedicated"); HostPodVO pod = _podDao.findById(cluster.getPodId()); throw new CloudRuntimeException("Cluster's Pod " + pod.getName() + " is already dedicated"); @@ -440,7 +440,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { boolean domainIdInChildreanList = getDomainChildIds(dedicatedZoneOfCluster.getDomainId()).contains(domainId); //can dedicate a cluster to an account/domain if zone is dedicated to parent-domain if (dedicatedZoneOfCluster.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || - (accountId != null && !(dedicatedZoneOfCluster.getDomainId() == domainId || domainIdInChildreanList))) { + (accountId != null && !(dedicatedZoneOfCluster.getDomainId().equals(domainId) || domainIdInChildreanList))) { s_logger.error("Cannot dedicate Cluster. Its zone is already dedicated"); DataCenterVO zone = _zoneDao.findById(cluster.getDataCenterId()); throw new CloudRuntimeException("Cluster's Zone " + zone.getName() + " is already dedicated"); @@ -460,14 +460,14 @@ public class DedicatedResourceManagerImpl implements DedicatedService { /*if all dedicated resources belongs to same account and domain then we should release dedication and make new entry for this cluster */ if (accountId != null) { - if (dHost.getAccountId() == accountId) { + if (dHost.getAccountId().equals(accountId)) { hostsToRelease.add(dHost); } else { s_logger.error("Cannot dedicate Cluster " + cluster.getName() + " to account" + accountName); throw new CloudRuntimeException("Cannot dedicate Cluster " + cluster.getName() + " to account" + accountName); } } else { - if (dHost.getAccountId() == null && dHost.getDomainId() == domainId) { + if (dHost.getAccountId() == null && dHost.getDomainId().equals(domainId)) { hostsToRelease.add(dHost); } } @@ -544,7 +544,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { boolean domainIdInChildreanList = getDomainChildIds(dedicatedClusterOfHost.getDomainId()).contains(domainId); //can dedicate a host to an account/domain if cluster is dedicated to parent-domain if (dedicatedClusterOfHost.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || - (accountId != null && !(dedicatedClusterOfHost.getDomainId() == domainId || domainIdInChildreanList))) { + (accountId != null && !(dedicatedClusterOfHost.getDomainId().equals(domainId) || domainIdInChildreanList))) { ClusterVO cluster = _clusterDao.findById(host.getClusterId()); s_logger.error("Host's Cluster " + cluster.getName() + " is already dedicated"); throw new CloudRuntimeException("Host's Cluster " + cluster.getName() + " is already dedicated"); @@ -555,7 +555,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { boolean domainIdInChildreanList = getDomainChildIds(dedicatedPodOfHost.getDomainId()).contains(domainId); //can dedicate a host to an account/domain if pod is dedicated to parent-domain if (dedicatedPodOfHost.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || - (accountId != null && !(dedicatedPodOfHost.getDomainId() == domainId || domainIdInChildreanList))) { + (accountId != null && !(dedicatedPodOfHost.getDomainId().equals(domainId) || domainIdInChildreanList))) { HostPodVO pod = _podDao.findById(host.getPodId()); s_logger.error("Host's Pod " + pod.getName() + " is already dedicated"); throw new CloudRuntimeException("Host's Pod " + pod.getName() + " is already dedicated"); @@ -566,7 +566,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { boolean domainIdInChildreanList = getDomainChildIds(dedicatedZoneOfHost.getDomainId()).contains(domainId); //can dedicate a host to an account/domain if zone is dedicated to parent-domain if (dedicatedZoneOfHost.getAccountId() != null || (accountId == null && !domainIdInChildreanList) || - (accountId != null && !(dedicatedZoneOfHost.getDomainId() == domainId || domainIdInChildreanList))) { + (accountId != null && !(dedicatedZoneOfHost.getDomainId().equals(domainId) || domainIdInChildreanList))) { DataCenterVO zone = _zoneDao.findById(host.getDataCenterId()); s_logger.error("Host's Data Center " + zone.getName() + " is already dedicated"); throw new CloudRuntimeException("Host's Data Center " + zone.getName() + " is already dedicated"); @@ -701,7 +701,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService { if (accountId != null) { AccountVO account = _accountDao.findById(accountId); if (account == null || domainId != account.getDomainId()) { - throw new InvalidParameterValueException("Please specify the domain id of the account: " + account.getAccountName()); + throw new InvalidParameterValueException("Please specify the domain id of the account id " + accountId); } } } diff --git a/plugins/deployment-planners/implicit-dedication/findbugsExcludeFilter.xml b/plugins/deployment-planners/implicit-dedication/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/deployment-planners/implicit-dedication/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/deployment-planners/implicit-dedication/pom.xml b/plugins/deployment-planners/implicit-dedication/pom.xml index 363c3f1e995..9cf5f46d3e7 100644 --- a/plugins/deployment-planners/implicit-dedication/pom.xml +++ b/plugins/deployment-planners/implicit-dedication/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/deployment-planners/user-concentrated-pod/findbugsExcludeFilter.xml b/plugins/deployment-planners/user-concentrated-pod/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/deployment-planners/user-concentrated-pod/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/deployment-planners/user-concentrated-pod/pom.xml b/plugins/deployment-planners/user-concentrated-pod/pom.xml index d9ff0390e9d..d7631463471 100644 --- a/plugins/deployment-planners/user-concentrated-pod/pom.xml +++ b/plugins/deployment-planners/user-concentrated-pod/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/deployment-planners/user-dispersing/findbugsExcludeFilter.xml b/plugins/deployment-planners/user-dispersing/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/deployment-planners/user-dispersing/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/deployment-planners/user-dispersing/pom.xml b/plugins/deployment-planners/user-dispersing/pom.xml index c292ee37f32..a13ef081e11 100644 --- a/plugins/deployment-planners/user-dispersing/pom.xml +++ b/plugins/deployment-planners/user-dispersing/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/inmemory/findbugsExcludeFilter.xml b/plugins/event-bus/inmemory/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/event-bus/inmemory/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/event-bus/inmemory/pom.xml b/plugins/event-bus/inmemory/pom.xml index 1bde8b8d843..dcbef831296 100644 --- a/plugins/event-bus/inmemory/pom.xml +++ b/plugins/event-bus/inmemory/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java b/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java index 99d0a12eb3b..9a57ff067bf 100644 --- a/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java +++ b/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java @@ -26,33 +26,36 @@ import java.util.concurrent.ConcurrentHashMap; import javax.ejb.Local; import javax.naming.ConfigurationException; -import com.cloud.utils.Pair; -import org.apache.log4j.Logger; - import org.apache.cloudstack.framework.events.Event; import org.apache.cloudstack.framework.events.EventBus; import org.apache.cloudstack.framework.events.EventBusException; import org.apache.cloudstack.framework.events.EventSubscriber; import org.apache.cloudstack.framework.events.EventTopic; +import org.apache.log4j.Logger; +import com.cloud.utils.Pair; import com.cloud.utils.component.ManagerBase; @Local(value = EventBus.class) public class InMemoryEventBus extends ManagerBase implements EventBus { - private String name; private static final Logger s_logger = Logger.getLogger(InMemoryEventBus.class); - private static ConcurrentHashMap> s_subscribers; + + private final static ConcurrentHashMap> subscribers; + + static { + subscribers = new ConcurrentHashMap>(); + } @Override public boolean configure(String name, Map params) throws ConfigurationException { - s_subscribers = new ConcurrentHashMap>(); + _name = name; return true; } @Override public void setName(String name) { - this.name = name; + _name = name; } @Override @@ -62,29 +65,35 @@ public class InMemoryEventBus extends ManagerBase implements EventBus { } UUID subscriberId = UUID.randomUUID(); - s_subscribers.put(subscriberId, new Pair(topic, subscriber)); + subscribers.put(subscriberId, new Pair(topic, subscriber)); return subscriberId; } @Override public void unsubscribe(UUID subscriberId, EventSubscriber subscriber) throws EventBusException { - if (s_subscribers != null && s_subscribers.isEmpty()) { + if (subscriberId == null) { + throw new EventBusException("Cannot unregister a null subscriberId."); + } + + if (subscribers.isEmpty()) { throw new EventBusException("There are no registered subscribers to unregister."); } - if (s_subscribers.get(subscriberId) == null) { + + if (!subscribers.containsKey(subscriberId)) { throw new EventBusException("No subscriber found with subscriber id " + subscriberId); + } else { + subscribers.remove(subscriberId); } - s_subscribers.remove(subscriberId); } @Override public void publish(Event event) throws EventBusException { - if (s_subscribers == null || s_subscribers.isEmpty()) { + if (subscribers == null || subscribers.isEmpty()) { return; // no subscriber to publish to, so just return } - for (UUID subscriberId : s_subscribers.keySet()) { - Pair subscriberDetails = s_subscribers.get(subscriberId); + for (UUID subscriberId : subscribers.keySet()) { + Pair subscriberDetails = subscribers.get(subscriberId); // if the event matches subscribers interested event topic then call back the subscriber with the event if (isEventMatchesTopic(event, subscriberDetails.first())) { EventSubscriber subscriber = subscriberDetails.second(); @@ -108,6 +117,10 @@ public class InMemoryEventBus extends ManagerBase implements EventBus { return true; } + public int totalSubscribers() { + return subscribers.size(); + } + private String replaceNullWithWildcard(String key) { if (key == null || key.isEmpty()) { return "*"; @@ -122,7 +135,7 @@ public class InMemoryEventBus extends ManagerBase implements EventBus { eventTopicSource = eventTopicSource.replace(".", "-"); String eventSource = replaceNullWithWildcard(event.getEventSource()); eventSource = eventSource.replace(".", "-"); - if (eventTopicSource != "*" && eventSource != "*" && !eventTopicSource.equalsIgnoreCase(eventSource)) { + if (!eventTopicSource.equals("*") && !eventSource.equals("*") && !eventTopicSource.equalsIgnoreCase(eventSource)) { return false; } @@ -130,7 +143,7 @@ public class InMemoryEventBus extends ManagerBase implements EventBus { eventTopicCategory = eventTopicCategory.replace(".", "-"); String eventCategory = replaceNullWithWildcard(event.getEventCategory()); eventCategory = eventCategory.replace(".", "-"); - if (eventTopicCategory != "*" && eventCategory != "*" && !eventTopicCategory.equalsIgnoreCase(eventCategory)) { + if (!eventTopicCategory.equals("*") && !eventCategory.equals("*") && !eventTopicCategory.equalsIgnoreCase(eventCategory)) { return false; } @@ -138,7 +151,7 @@ public class InMemoryEventBus extends ManagerBase implements EventBus { eventTopicType = eventTopicType.replace(".", "-"); String eventType = replaceNullWithWildcard(event.getEventType()); eventType = eventType.replace(".", "-"); - if (eventTopicType != "*" && eventType != "*" && !eventTopicType.equalsIgnoreCase(eventType)) { + if (!eventTopicType.equals("*") && !eventType.equals("*") && !eventTopicType.equalsIgnoreCase(eventType)) { return false; } @@ -146,7 +159,7 @@ public class InMemoryEventBus extends ManagerBase implements EventBus { eventTopicResourceType = eventTopicResourceType.replace(".", "-"); String resourceType = replaceNullWithWildcard(event.getResourceType()); resourceType = resourceType.replace(".", "-"); - if (eventTopicResourceType != "*" && resourceType != "*" && !eventTopicResourceType.equalsIgnoreCase(resourceType)) { + if (!eventTopicResourceType.equals("*") && !resourceType.equals("*") && !eventTopicResourceType.equalsIgnoreCase(resourceType)) { return false; } @@ -154,10 +167,10 @@ public class InMemoryEventBus extends ManagerBase implements EventBus { resourceUuid = resourceUuid.replace(".", "-"); String eventTopicresourceUuid = replaceNullWithWildcard(topic.getResourceUUID()); eventTopicresourceUuid = eventTopicresourceUuid.replace(".", "-"); - if (resourceUuid != "*" && eventTopicresourceUuid != "*" && !resourceUuid.equalsIgnoreCase(eventTopicresourceUuid)) { + if (!resourceUuid.equals("*") && !eventTopicresourceUuid.equals("*") && !resourceUuid.equalsIgnoreCase(eventTopicresourceUuid)) { return false; } return true; } -} +} \ No newline at end of file diff --git a/plugins/event-bus/inmemory/test/org/apache/cloudstack/mom/inmemory/InMemoryEventBusTest.java b/plugins/event-bus/inmemory/test/org/apache/cloudstack/mom/inmemory/InMemoryEventBusTest.java new file mode 100644 index 00000000000..a967f8934ef --- /dev/null +++ b/plugins/event-bus/inmemory/test/org/apache/cloudstack/mom/inmemory/InMemoryEventBusTest.java @@ -0,0 +1,162 @@ +/* + * 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 org.apache.cloudstack.mom.inmemory; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.UUID; + +import org.apache.cloudstack.framework.events.Event; +import org.apache.cloudstack.framework.events.EventBusException; +import org.apache.cloudstack.framework.events.EventSubscriber; +import org.apache.cloudstack.framework.events.EventTopic; +import org.junit.Test; + +import com.cloud.utils.UuidUtils; + +public class InMemoryEventBusTest { + + @Test + public void testConfigure() throws Exception { + String name = "test001"; + + InMemoryEventBus bus = new InMemoryEventBus(); + boolean success = bus.configure(name, null); + + assertTrue(success); + assertTrue(name.equals(bus.getName())); + } + + @Test + public void testSubscribe() throws Exception { + EventTopic topic = mock(EventTopic.class); + EventSubscriber subscriber = mock(EventSubscriber.class); + + InMemoryEventBus bus = new InMemoryEventBus(); + + UUID uuid = bus.subscribe(topic, subscriber); + assertNotNull(uuid); + + String uuidStr = uuid.toString(); + assertTrue(UuidUtils.validateUUID(uuidStr)); + assertTrue(bus.totalSubscribers() == 1); + + bus.unsubscribe(uuid, subscriber); + assertTrue(bus.totalSubscribers() == 0); + } + + @Test(expected = EventBusException.class) + public void testSubscribeFailTopic() throws Exception { + EventSubscriber subscriber = mock(EventSubscriber.class); + + InMemoryEventBus bus = new InMemoryEventBus(); + + bus.subscribe(null, subscriber); + } + + @Test(expected = EventBusException.class) + public void testSubscribeFailSubscriber() throws Exception { + EventTopic topic = mock(EventTopic.class); + + InMemoryEventBus bus = new InMemoryEventBus(); + + bus.subscribe(topic, null); + } + + @Test + public void testUnsubscribe() throws Exception { + EventTopic topic = mock(EventTopic.class); + EventSubscriber subscriber = mock(EventSubscriber.class); + + InMemoryEventBus bus = new InMemoryEventBus(); + + UUID uuid = bus.subscribe(topic, subscriber); + assertNotNull(uuid); + + String uuidStr = uuid.toString(); + + assertTrue(UuidUtils.validateUUID(uuidStr)); + assertTrue(bus.totalSubscribers() == 1); + // + bus.unsubscribe(uuid, subscriber); + assertTrue(bus.totalSubscribers() == 0); + } + + @Test(expected = EventBusException.class) + public void testUnsubscribeFailEmpty() throws Exception { + UUID uuid = UUID.randomUUID(); + + InMemoryEventBus bus = new InMemoryEventBus(); + bus.unsubscribe(uuid, null); + } + + @Test(expected = EventBusException.class) + public void testUnsubscribeFailNull() throws Exception { + InMemoryEventBus bus = new InMemoryEventBus(); + bus.unsubscribe(null, null); + } + + @Test(expected = EventBusException.class) + public void testUnsubscribeFailWrongUUID() throws Exception { + EventSubscriber subscriber = mock(EventSubscriber.class); + InMemoryEventBus bus = new InMemoryEventBus(); + UUID uuid = UUID.randomUUID(); + + bus.unsubscribe(uuid, subscriber); + } + + @Test + public void testPublish() throws Exception { + EventTopic topic = mock(EventTopic.class); + EventSubscriber subscriber = mock(EventSubscriber.class); + Event event = mock(Event.class); + + InMemoryEventBus bus = new InMemoryEventBus(); + + UUID uuid = bus.subscribe(topic, subscriber); + assertNotNull(uuid); + + String uuidStr = uuid.toString(); + assertTrue(UuidUtils.validateUUID(uuidStr)); + assertTrue(bus.totalSubscribers() == 1); + + bus.publish(event); + + verify(subscriber, times(1)).onEvent(event); + + bus.unsubscribe(uuid, subscriber); + assertTrue(bus.totalSubscribers() == 0); + } + + @Test + public void testPublishEmpty() throws Exception { + EventSubscriber subscriber = mock(EventSubscriber.class); + Event event = mock(Event.class); + + InMemoryEventBus bus = new InMemoryEventBus(); + bus.publish(event); + + verify(subscriber, times(0)).onEvent(event); + } +} \ No newline at end of file diff --git a/plugins/event-bus/rabbitmq/findbugsExcludeFilter.xml b/plugins/event-bus/rabbitmq/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/event-bus/rabbitmq/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/event-bus/rabbitmq/pom.xml b/plugins/event-bus/rabbitmq/pom.xml index 86adf11312a..8002e231144 100644 --- a/plugins/event-bus/rabbitmq/pom.xml +++ b/plugins/event-bus/rabbitmq/pom.xml @@ -24,7 +24,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java index 8ad7033400b..8403271af8d 100644 --- a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java +++ b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java @@ -30,8 +30,16 @@ import java.util.concurrent.Executors; import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.cloudstack.framework.events.Event; +import org.apache.cloudstack.framework.events.EventBus; +import org.apache.cloudstack.framework.events.EventBusException; +import org.apache.cloudstack.framework.events.EventSubscriber; +import org.apache.cloudstack.framework.events.EventTopic; +import org.apache.cloudstack.managed.context.ManagedContextRunnable; import org.apache.log4j.Logger; +import com.cloud.utils.Ternary; +import com.cloud.utils.component.ManagerBase; import com.rabbitmq.client.AMQP; import com.rabbitmq.client.AlreadyClosedException; import com.rabbitmq.client.Channel; @@ -43,16 +51,6 @@ import com.rabbitmq.client.MessageProperties; import com.rabbitmq.client.ShutdownListener; import com.rabbitmq.client.ShutdownSignalException; -import org.apache.cloudstack.framework.events.Event; -import org.apache.cloudstack.framework.events.EventBus; -import org.apache.cloudstack.framework.events.EventBusException; -import org.apache.cloudstack.framework.events.EventSubscriber; -import org.apache.cloudstack.framework.events.EventTopic; -import org.apache.cloudstack.managed.context.ManagedContextRunnable; - -import com.cloud.utils.Ternary; -import com.cloud.utils.component.ManagerBase; - @Local(value = EventBus.class) public class RabbitMQEventBus extends ManagerBase implements EventBus { diff --git a/plugins/file-systems/netapp/findbugsExcludeFilter.xml b/plugins/file-systems/netapp/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/file-systems/netapp/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/file-systems/netapp/pom.xml b/plugins/file-systems/netapp/pom.xml index fbfc27bb23b..6f43836d93b 100644 --- a/plugins/file-systems/netapp/pom.xml +++ b/plugins/file-systems/netapp/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/AssociateLunCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/AssociateLunCmd.java index b698daa876f..dadfe44eb9d 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/AssociateLunCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/AssociateLunCmd.java @@ -33,7 +33,8 @@ import com.cloud.exception.InvalidParameterValueException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.AssociateLunCmdResponse; -@APICommand(name = "associateLun", description = "Associate a LUN with a guest IQN", responseObject = AssociateLunCmdResponse.class) +@APICommand(name = "associateLun", description = "Associate a LUN with a guest IQN", responseObject = AssociateLunCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AssociateLunCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(AssociateLunCmd.class.getName()); private static final String s_name = "associatelunresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateLunCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateLunCmd.java index 86b2497f942..67004792f63 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateLunCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateLunCmd.java @@ -37,7 +37,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.CreateLunCmdResponse; -@APICommand(name = "createLunOnFiler", description = "Create a LUN from a pool", responseObject = CreateLunCmdResponse.class) +@APICommand(name = "createLunOnFiler", description = "Create a LUN from a pool", responseObject = CreateLunCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateLunCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateLunCmd.class.getName()); private static final String s_name = "createlunresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateVolumeOnFilerCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateVolumeOnFilerCmd.java index e79aa14dbf7..b1e6a299fed 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateVolumeOnFilerCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateVolumeOnFilerCmd.java @@ -36,7 +36,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.CreateVolumeOnFilerCmdResponse; -@APICommand(name = "createVolumeOnFiler", description = "Create a volume", responseObject = CreateVolumeOnFilerCmdResponse.class) +@APICommand(name = "createVolumeOnFiler", description = "Create a volume", responseObject = CreateVolumeOnFilerCmdResponse.class, + requestHasSensitiveInfo = true, responseHasSensitiveInfo = false) public class CreateVolumeOnFilerCmd extends BaseCmd { private static final String s_name = "createvolumeresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateVolumePoolCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateVolumePoolCmd.java index ba7493305c7..d2eeb875a74 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateVolumePoolCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/CreateVolumePoolCmd.java @@ -35,7 +35,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.CreateVolumePoolCmdResponse; -@APICommand(name = "createPool", description = "Create a pool", responseObject = CreateVolumePoolCmdResponse.class) +@APICommand(name = "createPool", description = "Create a pool", responseObject = CreateVolumePoolCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class CreateVolumePoolCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateVolumePoolCmd.class.getName()); private static final String s_name = "createpoolresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DeleteVolumePoolCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DeleteVolumePoolCmd.java index 1d221e9ebc6..6f51cc6e2a7 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DeleteVolumePoolCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DeleteVolumePoolCmd.java @@ -36,7 +36,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.DeleteVolumePoolCmdResponse; -@APICommand(name = "deletePool", description = "Delete a pool", responseObject = DeleteVolumePoolCmdResponse.class) +@APICommand(name = "deletePool", description = "Delete a pool", responseObject = DeleteVolumePoolCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DeleteVolumePoolCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DeleteVolumePoolCmd.class.getName()); private static final String s_name = "deletepoolresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DestroyLunCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DestroyLunCmd.java index e0c0eb7f064..cfdc1dacd88 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DestroyLunCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DestroyLunCmd.java @@ -37,7 +37,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.DeleteLUNCmdResponse; -@APICommand(name = "destroyLunOnFiler", description = "Destroy a LUN", responseObject = DeleteLUNCmdResponse.class) +@APICommand(name = "destroyLunOnFiler", description = "Destroy a LUN", responseObject = DeleteLUNCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DestroyLunCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DestroyLunCmd.class.getName()); diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DestroyVolumeOnFilerCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DestroyVolumeOnFilerCmd.java index 680c4e51147..500a84c50db 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DestroyVolumeOnFilerCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DestroyVolumeOnFilerCmd.java @@ -38,7 +38,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.DeleteVolumeOnFilerCmdResponse; -@APICommand(name = "destroyVolumeOnFiler", description = "Destroy a Volume", responseObject = DeleteVolumeOnFilerCmdResponse.class) +@APICommand(name = "destroyVolumeOnFiler", description = "Destroy a Volume", responseObject = DeleteVolumeOnFilerCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DestroyVolumeOnFilerCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DestroyVolumeOnFilerCmd.class.getName()); private static final String s_name = "destroyvolumeresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DissociateLunCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DissociateLunCmd.java index 4ea9684f0a1..d5c53a18739 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DissociateLunCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/DissociateLunCmd.java @@ -37,7 +37,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.DissociateLunCmdResponse; -@APICommand(name = "dissociateLun", description = "Dissociate a LUN", responseObject = DissociateLunCmdResponse.class) +@APICommand(name = "dissociateLun", description = "Dissociate a LUN", responseObject = DissociateLunCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class DissociateLunCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(DissociateLunCmd.class.getName()); private static final String s_name = "dissociatelunresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListLunsCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListLunsCmd.java index 04e64f38514..c1e1fb87b76 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListLunsCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListLunsCmd.java @@ -40,7 +40,8 @@ import com.cloud.netapp.LunVO; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.ListLunsCmdResponse; -@APICommand(name = "listLunsOnFiler", description = "List LUN", responseObject = ListLunsCmdResponse.class) +@APICommand(name = "listLunsOnFiler", description = "List LUN", responseObject = ListLunsCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListLunsCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ListLunsCmd.class.getName()); private static final String s_name = "listlunresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListVolumePoolsCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListVolumePoolsCmd.java index 9e650e035ee..f6d17c06e60 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListVolumePoolsCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListVolumePoolsCmd.java @@ -38,7 +38,8 @@ import com.cloud.netapp.NetappManager; import com.cloud.netapp.PoolVO; import com.cloud.server.api.response.netapp.ListVolumePoolsCmdResponse; -@APICommand(name = "listPools", description = "List Pool", responseObject = ListVolumePoolsCmdResponse.class) +@APICommand(name = "listPools", description = "List Pool", responseObject = ListVolumePoolsCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVolumePoolsCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ListVolumePoolsCmd.class.getName()); private static final String s_name = "listpoolresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListVolumesOnFilerCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListVolumesOnFilerCmd.java index 38c91b75819..bf72b3afbec 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListVolumesOnFilerCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ListVolumesOnFilerCmd.java @@ -40,7 +40,8 @@ import com.cloud.netapp.NetappManager; import com.cloud.netapp.NetappVolumeVO; import com.cloud.server.api.response.netapp.ListVolumesOnFilerCmdResponse; -@APICommand(name = "listVolumesOnFiler", description = "List Volumes", responseObject = ListVolumesOnFilerCmdResponse.class) +@APICommand(name = "listVolumesOnFiler", description = "List Volumes", responseObject = ListVolumesOnFilerCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListVolumesOnFilerCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ListVolumesOnFilerCmd.class.getName()); private static final String s_name = "listvolumesresponse"; diff --git a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ModifyVolumePoolCmd.java b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ModifyVolumePoolCmd.java index 94d5de593d7..a5849df3492 100644 --- a/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ModifyVolumePoolCmd.java +++ b/plugins/file-systems/netapp/src/com/cloud/api/commands/netapp/ModifyVolumePoolCmd.java @@ -33,7 +33,8 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.netapp.NetappManager; import com.cloud.server.api.response.netapp.ModifyVolumePoolCmdResponse; -@APICommand(name = "modifyPool", description = "Modify pool", responseObject = ModifyVolumePoolCmdResponse.class) +@APICommand(name = "modifyPool", description = "Modify pool", responseObject = ModifyVolumePoolCmdResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ModifyVolumePoolCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(ModifyVolumePoolCmd.class.getName()); private static final String s_name = "modifypoolresponse"; diff --git a/plugins/ha-planners/skip-heurestics/findbugsExcludeFilter.xml b/plugins/ha-planners/skip-heurestics/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/ha-planners/skip-heurestics/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/ha-planners/skip-heurestics/pom.xml b/plugins/ha-planners/skip-heurestics/pom.xml index 223789a287f..bd2fd84d809 100644 --- a/plugins/ha-planners/skip-heurestics/pom.xml +++ b/plugins/ha-planners/skip-heurestics/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/host-allocators/random/findbugsExcludeFilter.xml b/plugins/host-allocators/random/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/host-allocators/random/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/host-allocators/random/pom.xml b/plugins/host-allocators/random/pom.xml index e31919d14c3..e16e294d1f4 100644 --- a/plugins/host-allocators/random/pom.xml +++ b/plugins/host-allocators/random/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/baremetal/findbugsExcludeFilter.xml b/plugins/hypervisors/baremetal/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/hypervisors/baremetal/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/hypervisors/baremetal/pom.xml b/plugins/hypervisors/baremetal/pom.xml index eb2a0d1870e..b75619557c2 100755 --- a/plugins/hypervisors/baremetal/pom.xml +++ b/plugins/hypervisors/baremetal/pom.xml @@ -21,7 +21,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml cloud-plugin-hypervisor-baremetal diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java index 76897f26d34..c312df7b79e 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java @@ -33,10 +33,8 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.apache.log4j.Logger; - import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.log4j.Logger; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; @@ -44,18 +42,14 @@ import com.cloud.baremetal.networkservice.BareMetalResourceBase; import com.cloud.configuration.Config; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterVO; -import com.cloud.dc.dao.ClusterDao; -import com.cloud.dc.dao.DataCenterDao; import com.cloud.exception.DiscoveryException; import com.cloud.host.Host; import com.cloud.host.HostVO; -import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.network.Network; import com.cloud.resource.Discoverer; import com.cloud.resource.DiscovererBase; -import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; @@ -71,17 +65,7 @@ import com.cloud.vm.dao.VMInstanceDao; public class BareMetalDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter { protected static final Logger s_logger = Logger.getLogger(BareMetalDiscoverer.class); @Inject - protected ClusterDao _clusterDao; - @Inject - protected HostDao _hostDao; - @Inject - protected DataCenterDao _dcDao; - @Inject protected VMInstanceDao _vmDao = null; - @Inject - protected ResourceManager _resourceMgr; - @Inject - protected ConfigurationDao _configDao; @Override public boolean configure(String name, Map params) throws ConfigurationException { diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java index 70bdb6f62df..b729d9bb3eb 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java @@ -340,8 +340,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource vmDao = ComponentContext.getComponent(VMInstanceDao.class); final List vms = vmDao.listByHostId(hostId); for (VMInstanceVO vm : vms) { - states.put(vm.getInstanceName(), new HostVmStateReportEntry(vm.getState() == State.Running ? PowerState.PowerOn : PowerState.PowerOff, "host-" + hostId, - null)); + states.put(vm.getInstanceName(), new HostVmStateReportEntry(vm.getState() == State.Running ? PowerState.PowerOn : PowerState.PowerOff, "host-" + hostId)); } } /* diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalDhcpCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalDhcpCmd.java index 529f988b519..ab014d09809 100755 --- a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalDhcpCmd.java +++ b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalDhcpCmd.java @@ -35,7 +35,8 @@ import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; -@APICommand(name = "addBaremetalDhcp", description = "adds a baremetal dhcp server", responseObject = BaremetalDhcpResponse.class) +@APICommand(name = "addBaremetalDhcp", description = "adds a baremetal dhcp server", responseObject = BaremetalDhcpResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddBaremetalDhcpCmd extends BaseAsyncCmd { private static final String s_name = "addbaremetaldhcpresponse"; public static final Logger s_logger = Logger.getLogger(AddBaremetalDhcpCmd.class); diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalHostCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalHostCmd.java index 40ee6ded923..b876c68f53b 100755 --- a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalHostCmd.java +++ b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalHostCmd.java @@ -23,7 +23,8 @@ import org.apache.cloudstack.api.response.HostResponse; import com.cloud.baremetal.manager.BareMetalDiscoverer; -@APICommand(name = "addBaremetalHost", description = "add a baremetal host", responseObject = HostResponse.class) +@APICommand(name = "addBaremetalHost", description = "add a baremetal host", responseObject = HostResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddBaremetalHostCmd extends AddHostCmd { @Parameter(name = ApiConstants.IP_ADDRESS, type = CommandType.STRING, description = "ip address intentionally allocated to this host after provisioning") diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalKickStartPxeCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalKickStartPxeCmd.java index ac8d9c7c0cc..2c3a68cd5ac 100755 --- a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalKickStartPxeCmd.java +++ b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalKickStartPxeCmd.java @@ -20,7 +20,8 @@ package org.apache.cloudstack.api; import com.cloud.baremetal.networkservice.BaremetalPxeKickStartResponse; -@APICommand(name = "addBaremetalPxeKickStartServer", description = "add a baremetal pxe server", responseObject = BaremetalPxeKickStartResponse.class) +@APICommand(name = "addBaremetalPxeKickStartServer", description = "add a baremetal pxe server", responseObject = BaremetalPxeKickStartResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class AddBaremetalKickStartPxeCmd extends AddBaremetalPxeCmd { @Parameter(name = ApiConstants.TFTP_DIR, type = CommandType.STRING, required = true, description = "Tftp root directory of PXE server") private String tftpDir; diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalPxePingServerCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalPxePingServerCmd.java index b128a62410d..32f6faea0a9 100755 --- a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalPxePingServerCmd.java +++ b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/AddBaremetalPxePingServerCmd.java @@ -20,7 +20,8 @@ package org.apache.cloudstack.api; import com.cloud.baremetal.networkservice.BaremetalPxePingResponse; -@APICommand(name = "addBaremetalPxePingServer", description = "add a baremetal ping pxe server", responseObject = BaremetalPxePingResponse.class) +@APICommand(name = "addBaremetalPxePingServer", description = "add a baremetal ping pxe server", responseObject = BaremetalPxePingResponse.class, + requestHasSensitiveInfo = true, responseHasSensitiveInfo = false) public class AddBaremetalPxePingServerCmd extends AddBaremetalPxeCmd { @Parameter(name = ApiConstants.PING_STORAGE_SERVER_IP, type = CommandType.STRING, required = true, description = "PING storage server ip") diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/ListBaremetalDhcpCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/ListBaremetalDhcpCmd.java index 7d0aba387d4..b159810ec6a 100755 --- a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/ListBaremetalDhcpCmd.java +++ b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/ListBaremetalDhcpCmd.java @@ -34,7 +34,8 @@ import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; -@APICommand(name = "listBaremetalDhcp", description = "list baremetal dhcp servers", responseObject = BaremetalDhcpResponse.class) +@APICommand(name = "listBaremetalDhcp", description = "list baremetal dhcp servers", responseObject = BaremetalDhcpResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListBaremetalDhcpCmd extends BaseListCmd { private static final Logger s_logger = Logger.getLogger(ListBaremetalDhcpCmd.class); private static final String s_name = "listbaremetaldhcpresponse"; diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/ListBaremetalPxeServersCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/ListBaremetalPxeServersCmd.java index 437fa3f2cd8..166366303da 100755 --- a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/ListBaremetalPxeServersCmd.java +++ b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/ListBaremetalPxeServersCmd.java @@ -34,7 +34,8 @@ import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; -@APICommand(name = "listBaremetalPxeServers", description = "list baremetal pxe server", responseObject = BaremetalPxeResponse.class) +@APICommand(name = "listBaremetalPxeServers", description = "list baremetal pxe server", responseObject = BaremetalPxeResponse.class, + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class ListBaremetalPxeServersCmd extends BaseListCmd { private static final Logger s_logger = Logger.getLogger(ListBaremetalPxeServersCmd.class); private static final String s_name = "listbaremetalpxeserversresponse"; diff --git a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj index a4c6b1fc073..f804ef6f670 100644 --- a/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj +++ b/plugins/hypervisors/hyperv/DotNet/ServerResource/AgentShell/AgentShell.csproj @@ -137,6 +137,10 @@ + + + + + + + + diff --git a/plugins/hypervisors/hyperv/pom.xml b/plugins/hypervisors/hyperv/pom.xml index fca7cd93680..6b8e196288f 100644 --- a/plugins/hypervisors/hyperv/pom.xml +++ b/plugins/hypervisors/hyperv/pom.xml @@ -23,7 +23,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java b/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java index cebfb7ac70c..01d75fa64ce 100644 --- a/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java +++ b/plugins/hypervisors/hyperv/src/com/cloud/ha/HypervInvestigator.java @@ -45,9 +45,9 @@ public class HypervInvestigator extends AdapterBase implements Investigator { public Boolean isVmAlive(com.cloud.vm.VirtualMachine vm, Host host) { Status status = isAgentAlive(host); if (status == null) { - return null; + return false; } - return status == Status.Up ? true : null; + return status == Status.Up ? true : false; } @Override diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java index 371a6187407..f4c15f62ce2 100644 --- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java +++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/discoverer/HypervServerDiscoverer.java @@ -19,6 +19,7 @@ package com.cloud.hypervisor.hyperv.discoverer; import java.net.InetAddress; import java.net.URI; import java.net.UnknownHostException; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,12 +44,9 @@ import com.cloud.agent.api.SetupCommand; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; import com.cloud.alert.AlertManager; -import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; -import com.cloud.dc.dao.ClusterDao; -import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.HostPodDao; import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.ConnectionException; @@ -58,13 +56,11 @@ import com.cloud.host.Host; import com.cloud.host.HostEnvironment; import com.cloud.host.HostVO; import com.cloud.host.Status; -import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.hyperv.resource.HypervDirectConnectResource; import com.cloud.resource.Discoverer; import com.cloud.resource.DiscovererBase; -import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceStateAdapter; import com.cloud.resource.ServerResource; import com.cloud.resource.UnableDeleteHostException; @@ -78,27 +74,14 @@ import com.cloud.storage.StorageLayer; @Local(value = Discoverer.class) public class HypervServerDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter { private static final Logger s_logger = Logger.getLogger(HypervServerDiscoverer.class); - - private String _instance; - private String _mountParent; - private int _timeout; Random _rand = new Random(System.currentTimeMillis()); Map _storageMounts = new HashMap(); StorageLayer _storage; - @Inject - private HostDao _hostDao = null; - @Inject - private ClusterDao _clusterDao; - @Inject - private ClusterDetailsDao _clusterDetailsDao; - @Inject - private ResourceManager _resourceMgr; @Inject private HostPodDao _podDao; - @Inject - private DataCenterDao _dcDao; + // TODO: AgentManager and AlertManager not being used to transmit info, // may want to reconsider. @@ -272,7 +255,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer // pool in the database // This GUID may change. if (cluster.getGuid() == null) { - cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes()).toString()); + cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes(Charset.forName("UTF-8"))).toString()); _clusterDao.update(clusterId, cluster); } @@ -336,7 +319,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer * @return GUID in form of a string. */ public static String calcServerResourceGuid(final String uuidSeed) { - String guid = UUID.nameUUIDFromBytes(uuidSeed.getBytes()).toString(); + String guid = UUID.nameUUIDFromBytes(uuidSeed.getBytes(Charset.forName("UTF-8"))).toString(); return guid; } diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/guru/HypervGuru.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/guru/HypervGuru.java index 1d9e7f619f9..4e8d3d5524c 100644 --- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/guru/HypervGuru.java +++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/guru/HypervGuru.java @@ -34,6 +34,7 @@ import com.cloud.storage.dao.GuestOSDao; import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.hypervisor.hyperv.manager.HypervManager; import com.cloud.network.NetworkModel; +import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.TrafficType; import com.cloud.network.dao.NetworkDao; import com.cloud.network.dao.NetworkVO; @@ -53,7 +54,7 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru { @Inject HypervManager _hypervMgr; @Inject NetworkDao _networkDao; @Inject NetworkModel _networkMgr; - + int MaxNicSupported = 8; @Override public final HypervisorType getHypervisorType() { return HypervisorType.Hyperv; @@ -74,18 +75,22 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru { if(vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) { NicProfile publicNicProfile = null; + NicProfile controlNicProfile = null; + NicProfile profile = null; for(NicProfile nicProfile : nicProfiles) { if(nicProfile.getTrafficType() == TrafficType.Public) { publicNicProfile = nicProfile; break; } + else if (nicProfile.getTrafficType() == TrafficType.Control) { + controlNicProfile = nicProfile; + } } - if(publicNicProfile != null) { + if(publicNicProfile != null || controlNicProfile != null) { NicTO[] nics = to.getNics(); - // reserve extra NICs - NicTO[] expandedNics = new NicTO[nics.length + _hypervMgr.getRouterExtraPublicNics()]; + NicTO[] expandedNics = new NicTO[MaxNicSupported]; int i = 0; int deviceId = -1; for(i = 0; i < nics.length; i++) { @@ -95,17 +100,27 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru { } deviceId++; - long networkId = publicNicProfile.getNetworkId(); - NetworkVO network = _networkDao.findById(networkId); + long networkId = 0; + if(publicNicProfile != null ) { + networkId= publicNicProfile.getNetworkId(); + profile = publicNicProfile; + } + else { + networkId = controlNicProfile.getNetworkId(); + profile = controlNicProfile; + } - for(; i < nics.length + _hypervMgr.getRouterExtraPublicNics(); i++) { + NetworkVO network = _networkDao.findById(networkId); + // for Hyperv Hot Nic plug is not supported and it will support upto 8 nics. + // creating the VR with extra nics (actual nics(3) + extra nics) will be 8 + for(; i < MaxNicSupported; i++) { NicTO nicTo = new NicTO(); nicTo.setDeviceId(deviceId++); - nicTo.setBroadcastType(publicNicProfile.getBroadcastType()); - nicTo.setType(publicNicProfile.getTrafficType()); + nicTo.setBroadcastType(BroadcastDomainType.Vlan); + nicTo.setType(TrafficType.Public); nicTo.setIp("0.0.0.0"); nicTo.setNetmask("255.255.255.255"); - nicTo.setName(publicNicProfile.getName()); + nicTo.setName(profile.getName()); try { String mac = _networkMgr.getNextAvailableMacAddressInNetwork(networkId); @@ -113,16 +128,16 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru { } catch (InsufficientAddressCapacityException e) { throw new CloudRuntimeException("unable to allocate mac address on network: " + networkId); } - nicTo.setDns1(publicNicProfile.getDns1()); - nicTo.setDns2(publicNicProfile.getDns2()); - if (publicNicProfile.getGateway() != null) { + nicTo.setDns1(profile.getDns1()); + nicTo.setDns2(profile.getDns2()); + if (publicNicProfile != null && publicNicProfile.getGateway() != null) { nicTo.setGateway(publicNicProfile.getGateway()); } else { nicTo.setGateway(network.getGateway()); } nicTo.setDefaultNic(false); - nicTo.setBroadcastUri(publicNicProfile.getBroadCastUri()); - nicTo.setIsolationuri(publicNicProfile.getIsolationUri()); + nicTo.setBroadcastUri(profile.getBroadCastUri()); + nicTo.setIsolationuri(profile.getIsolationUri()); Integer networkRate = _networkMgr.getNetworkRate(network.getId(), null); nicTo.setNetworkRateMbps(networkRate); @@ -136,9 +151,12 @@ public class HypervGuru extends HypervisorGuruBase implements HypervisorGuru { for(NicTO nicTo : sortNicsByDeviceId(to.getNics())) { sbMacSequence.append(nicTo.getMac()).append("|"); } - sbMacSequence.deleteCharAt(sbMacSequence.length() - 1); - String bootArgs = to.getBootArgs(); - to.setBootArgs(bootArgs + " nic_macs=" + sbMacSequence.toString()); + + if (!sbMacSequence.toString().isEmpty()) { + sbMacSequence.deleteCharAt(sbMacSequence.length() - 1); + String bootArgs = to.getBootArgs(); + to.setBootArgs(bootArgs + " nic_macs=" + sbMacSequence.toString()); + } } diff --git a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java index 2f645906317..12fc39d1973 100644 --- a/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java +++ b/plugins/hypervisors/hyperv/src/com/cloud/hypervisor/hyperv/resource/HypervDirectConnectResource.java @@ -24,6 +24,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.channels.SocketChannel; +import java.nio.charset.Charset; import java.rmi.RemoteException; import java.security.KeyManagementException; import java.security.KeyStoreException; @@ -62,6 +63,7 @@ import org.apache.http.util.EntityUtils; import org.apache.log4j.Logger; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.cloud.agent.api.Answer; import com.cloud.agent.api.CheckRouterAnswer; @@ -82,9 +84,14 @@ import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingTestCommand; +import com.cloud.agent.api.PlugNicAnswer; +import com.cloud.agent.api.PlugNicCommand; +import com.cloud.agent.api.SetupGuestNetworkCommand; import com.cloud.agent.api.StartCommand; import com.cloud.agent.api.StartupCommand; import com.cloud.agent.api.StartupRoutingCommand; +import com.cloud.agent.api.UnPlugNicAnswer; +import com.cloud.agent.api.UnPlugNicCommand; import com.cloud.agent.api.StartupRoutingCommand.VmState; import com.cloud.agent.api.StartupStorageCommand; import com.cloud.agent.api.UnsupportedAnswer; @@ -97,6 +104,7 @@ import com.cloud.agent.api.routing.DnsMasqConfigCommand; import com.cloud.agent.api.routing.IpAliasTO; import com.cloud.agent.api.routing.IpAssocAnswer; import com.cloud.agent.api.routing.IpAssocCommand; +import com.cloud.agent.api.routing.IpAssocVpcCommand; import com.cloud.agent.api.routing.LoadBalancerConfigCommand; import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand; @@ -104,6 +112,7 @@ import com.cloud.agent.api.routing.SavePasswordCommand; import com.cloud.agent.api.routing.SetFirewallRulesAnswer; import com.cloud.agent.api.routing.SetFirewallRulesCommand; import com.cloud.agent.api.routing.SetMonitorServiceCommand; +import com.cloud.agent.api.routing.SetNetworkACLCommand; import com.cloud.agent.api.routing.SetPortForwardingRulesAnswer; import com.cloud.agent.api.routing.SetPortForwardingRulesCommand; import com.cloud.agent.api.routing.SetSourceNatAnswer; @@ -118,9 +127,12 @@ import com.cloud.agent.api.routing.VpnUsersCfgCommand; import com.cloud.agent.api.to.DhcpTO; import com.cloud.agent.api.to.FirewallRuleTO; 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.StaticNatRuleTO; import com.cloud.agent.api.to.VirtualMachineTO; +import com.cloud.agent.resource.virtualnetwork.VirtualRouterDeployer; +import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource; import com.cloud.dc.DataCenter.NetworkType; import com.cloud.exception.InternalErrorException; import com.cloud.host.Host.Type; @@ -134,11 +146,13 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.resource.ServerResource; import com.cloud.resource.ServerResourceBase; import com.cloud.serializer.GsonHelper; +import com.cloud.utils.ExecutionResult; import com.cloud.utils.Pair; import com.cloud.utils.StringUtils; import com.cloud.utils.net.NetUtils; import com.cloud.utils.ssh.SshHelper; import com.cloud.vm.VirtualMachine; +import com.cloud.vm.VirtualMachine.PowerState; import com.cloud.vm.VirtualMachineName; @@ -146,8 +160,9 @@ import com.cloud.vm.VirtualMachineName; * Implementation of dummy resource to be returned from discoverer. **/ @Local(value = ServerResource.class) -public class HypervDirectConnectResource extends ServerResourceBase implements ServerResource { +public class HypervDirectConnectResource extends ServerResourceBase implements ServerResource, VirtualRouterDeployer { public static final int DEFAULT_AGENT_PORT = 8250; + public static final String HOST_VM_STATE_REPORT_COMMAND = "org.apache.cloudstack.HostVmStateReportCommand"; private static final Logger s_logger = Logger.getLogger(HypervDirectConnectResource.class.getName()); private static final Gson s_gson = GsonHelper.getGson(); @@ -162,7 +177,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S protected final int _retry = 24; protected final int _sleep = 10000; protected static final int DEFAULT_DOMR_SSHPORT = 3922; - + private final int maxid = 4094; private String _clusterGuid; // Used by initialize to assert object configured before @@ -175,6 +190,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S private static HypervManager s_hypervMgr; @Inject HypervManager _hypervMgr; + protected VirtualRoutingResource _vrResource; @PostConstruct void init() { @@ -209,6 +225,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S defaultStartRoutCmd.setPrivateIpAddress(_agentIp); defaultStartRoutCmd.setStorageIpAddress(_agentIp); defaultStartRoutCmd.setPool(_clusterGuid); + defaultStartRoutCmd.setHostVmStateReport(getHostVmStateReport()); s_logger.debug("Generated StartupRoutingCommand for _agentIp \"" + _agentIp + "\""); @@ -300,8 +317,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S @Override public final PingCommand getCurrentStatus(final long id) { - // TODO, need to report VM states on host - PingCommand pingCmd = new PingRoutingCommand(getType(), id, null, null); + PingCommand pingCmd = new PingRoutingCommand(getType(), id, null, getHostVmStateReport()); if (s_logger.isDebugEnabled()) { s_logger.debug("Ping host " + _name + " (IP " + _agentIp + ")"); @@ -316,6 +332,50 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S return pingCmd; } + public final ArrayList> requestHostVmStateReport() { + URI agentUri = null; + try { + agentUri = new URI("https", null, _agentIp, _port, "/api/HypervResource/" + HOST_VM_STATE_REPORT_COMMAND, null, null); + } catch (URISyntaxException e) { + String errMsg = "Could not generate URI for Hyper-V agent"; + s_logger.error(errMsg, e); + return null; + } + String incomingCmd = postHttpRequest("{}", agentUri); + + if (incomingCmd == null) { + return null; + } + ArrayList> result = null; + try { + result = s_gson.fromJson(incomingCmd, new TypeToken>>() { + }.getType()); + } catch (Exception ex) { + String errMsg = "Failed to deserialize Command[] " + incomingCmd; + s_logger.error(errMsg, ex); + } + s_logger.debug("HostVmStateReportCommand received response " + + s_gson.toJson(result)); + if (!result.isEmpty()) { + return result; + } + return null; + } + + protected HashMap getHostVmStateReport() { + final HashMap vmStates = new HashMap(); + ArrayList> vmList = requestHostVmStateReport(); + if (vmList == null || vmList.isEmpty()) { + return null; + } + + for (Map vmMap : vmList) { + String name = (String)vmMap.keySet().toArray()[0]; + vmStates.put(name, new HostVmStateReportEntry(PowerState.valueOf(vmMap.get(name)), _guid)); + } + return vmStates; + } + // TODO: Is it valid to return NULL, or should we throw on error? // Returns StartupCommand with fields revised with values known only to the // host @@ -374,8 +434,9 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S s_logger.error(errMsg, e); return null; } - - if (clazz == CheckSshCommand.class) { + if (cmd instanceof NetworkElementCommand) { + return _vrResource.executeRequest((NetworkElementCommand)cmd); + }if (clazz == CheckSshCommand.class) { answer = execute((CheckSshCommand)cmd); } else if (clazz == GetDomRVersionCmd.class) { answer = execute((GetDomRVersionCmd)cmd); @@ -421,7 +482,12 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S answer = execute((SetStaticRouteCommand) cmd); } else if (clazz == SetMonitorServiceCommand.class) { answer = execute((SetMonitorServiceCommand) cmd); - } else { + } else if (clazz == PlugNicCommand.class) { + answer = execute((PlugNicCommand)cmd); + } else if (clazz == UnPlugNicCommand.class) { + answer = execute((UnPlugNicCommand)cmd); + } + else { if (clazz == StartCommand.class) { VirtualMachineTO vmSpec = ((StartCommand)cmd).getVirtualMachine(); if (vmSpec.getType() != VirtualMachine.Type.User) { @@ -452,6 +518,279 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S } return answer; } + + + private PlugNicAnswer execute(PlugNicCommand cmd) { + if (s_logger.isInfoEnabled()) { + s_logger.info("Executing resource PlugNicCommand " + s_gson.toJson(cmd)); + } + + try { + + String vmName = cmd.getVmName(); + NicTO nic = cmd.getNic(); + URI broadcastUri = nic.getBroadcastUri(); + if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) { + throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + nic.getBroadcastUri()); + } + int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri)); + int publicNicInfo = -1; + publicNicInfo = getVmNics(vmName, maxid); + if (publicNicInfo > 0) { + modifyNicVlan(vmName, vlanId, publicNicInfo); + } + return new PlugNicAnswer(cmd, true, "success"); + } catch (Exception e) { + s_logger.error("Unexpected exception: ", e); + return new PlugNicAnswer(cmd, false, "Unable to execute PlugNicCommand due to " + e.toString()); + } + } + + + private UnPlugNicAnswer execute(UnPlugNicCommand cmd) { + if (s_logger.isInfoEnabled()) { + s_logger.info("Executing resource UnPlugNicCommand " + s_gson.toJson(cmd)); + } + + try { + String vmName = cmd.getVmName(); + NicTO nic = cmd.getNic(); + URI broadcastUri = nic.getBroadcastUri(); + if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) { + throw new InternalErrorException("Unable to unassign a public IP to a VIF on network " + nic.getBroadcastUri()); + } + int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri)); + int publicNicInfo = -1; + publicNicInfo = getVmNics(vmName, vlanId); + if (publicNicInfo > 0) { + modifyNicVlan(vmName, maxid, publicNicInfo); + } + return new UnPlugNicAnswer(cmd, true, "success"); + } catch (Exception e) { + s_logger.error("Unexpected exception: ", e); + return new UnPlugNicAnswer(cmd, false, "Unable to execute unPlugNicCommand due to " + e.toString()); + } + } + + @Override + public ExecutionResult executeInVR(String routerIP, String script, String args) { + return executeInVR(routerIP, script, args, 120); + } + + @Override + public ExecutionResult executeInVR(String routerIP, String script, String args, int timeout) { + Pair result; + + //TODO: Password should be masked, cannot output to log directly + if (s_logger.isDebugEnabled()) { + s_logger.debug("Run command on VR: " + routerIP + ", script: " + script + " with args: " + args); + } + + try { + result = SshHelper.sshExecute(routerIP, DEFAULT_DOMR_SSHPORT, "root", getSystemVMKeyFile(), null, "/opt/cloud/bin/" + script + " " + args, + 60000, 60000, timeout * 1000); + } catch (Exception e) { + String msg = "Command failed due to " + e ; + s_logger.error(msg); + result = new Pair(false, msg); + } + if (s_logger.isDebugEnabled()) { + s_logger.debug(script + " execution result: " + result.first().toString()); + } + return new ExecutionResult(result.first(), result.second()); + } + + @Override + public ExecutionResult createFileInVR(String routerIp, String filePath, String fileName, String content) { + File keyFile = getSystemVMKeyFile(); + try { + SshHelper.scpTo(routerIp, 3922, "root", keyFile, null, filePath, content.getBytes(Charset.forName("UTF-8")), fileName, null); + } catch (Exception e) { + s_logger.warn("Fail to create file " + filePath + fileName + " in VR " + routerIp, e); + return new ExecutionResult(false, e.getMessage()); + } + return new ExecutionResult(true, null); + } + + @Override + public ExecutionResult prepareCommand(NetworkElementCommand cmd) { + //Update IP used to access router + cmd.setRouterAccessIp(getRouterSshControlIp(cmd)); + assert cmd.getRouterAccessIp() != null; + + if (cmd instanceof IpAssocVpcCommand) { + return prepareNetworkElementCommand((IpAssocVpcCommand)cmd); + } else if (cmd instanceof IpAssocCommand) { + return prepareNetworkElementCommand((IpAssocCommand)cmd); + } else if (cmd instanceof SetSourceNatCommand) { + return prepareNetworkElementCommand((SetSourceNatCommand)cmd); + } else if (cmd instanceof SetupGuestNetworkCommand) { + return prepareNetworkElementCommand((SetupGuestNetworkCommand)cmd); + } else if (cmd instanceof SetNetworkACLCommand) { + return prepareNetworkElementCommand((SetNetworkACLCommand)cmd); + } + return new ExecutionResult(true, null); + } + + private ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) { + try { + + IpAddressTO[] ips = cmd.getIpAddresses(); + String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + String controlIp = getRouterSshControlIp(cmd); + + for (IpAddressTO ip : ips) { + /** + * TODO support other networks + */ + URI broadcastUri = BroadcastDomainType.fromString(ip.getBroadcastUri()); + if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) { + throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + ip.getBroadcastUri()); + } + int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri)); + int publicNicInfo = -1; + publicNicInfo = getVmNics(routerName, vlanId); + + boolean addVif = false; + if (ip.isAdd() && publicNicInfo == -1) { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Plug new NIC to associate" + controlIp + " to " + ip.getPublicIp()); + } + addVif = true; + } + + if (addVif) { + Pair nicdevice = findRouterFreeEthDeviceIndex(controlIp); + publicNicInfo = nicdevice.first(); + if (publicNicInfo > 0) { + modifyNicVlan(routerName, vlanId, nicdevice.second()); + // After modifying the vnic on VR, check the VR VNics config in the host and get the device position + publicNicInfo = getVmNics(routerName, vlanId); + // As a new nic got activated in the VR. add the entry in the NIC's table. + networkUsage(controlIp, "addVif", "eth" + publicNicInfo); + } + else { + // we didn't find any eth device available in VR to configure the ip range with new VLAN + String msg = "No Nic is available on DomR VIF to associate/disassociate IP with."; + s_logger.error(msg); + throw new InternalErrorException(msg); + } + ip.setNicDevId(publicNicInfo); + ip.setNewNic(addVif); + } else { + ip.setNicDevId(publicNicInfo); + } + } + } catch (Throwable e) { + s_logger.error("Unexpected exception: " + e.toString() + " will shortcut rest of IPAssoc commands", e); + return new ExecutionResult(false, e.toString()); + } + return new ExecutionResult(true, null); + } + + protected ExecutionResult prepareNetworkElementCommand(SetupGuestNetworkCommand cmd) { + NicTO nic = cmd.getNic(); + String domrName = + cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + + try { + URI broadcastUri = nic.getBroadcastUri(); + int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri)); + int ethDeviceNum = getVmNics(domrName, vlanId); + if (ethDeviceNum > 0) { + nic.setDeviceId(ethDeviceNum); + } else { + return new ExecutionResult(false, "Prepare SetupGuestNetwork failed due to unable to find the nic"); + } + } catch (Exception e) { + String msg = "Prepare SetupGuestNetwork failed due to " + e.toString(); + s_logger.warn(msg, e); + return new ExecutionResult(false, msg); + } + return new ExecutionResult(true, null); + } + + + private ExecutionResult prepareNetworkElementCommand(IpAssocVpcCommand cmd) { + String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + + try { + IpAddressTO[] ips = cmd.getIpAddresses(); + for (IpAddressTO ip : ips) { + URI broadcastUri = BroadcastDomainType.fromString(ip.getBroadcastUri()); + if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) { + throw new InternalErrorException("Invalid Broadcast URI " + ip.getBroadcastUri()); + } + int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri)); + int publicNicInfo = -1; + publicNicInfo = getVmNics(routerName, vlanId); + if (publicNicInfo < 0) { + if (ip.isAdd()) { + throw new InternalErrorException("Failed to find DomR VIF to associate/disassociate IP with."); + } else { + s_logger.debug("VIF to deassociate IP with does not exist, return success"); + continue; + } + } + + ip.setNicDevId(publicNicInfo); + } + } catch (Exception e) { + s_logger.error("Prepare Ip Assoc failure on applying one ip due to exception: ", e); + return new ExecutionResult(false, e.toString()); + } + + return new ExecutionResult(true, null); + } + + protected ExecutionResult prepareNetworkElementCommand(SetSourceNatCommand cmd) { + String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + IpAddressTO pubIp = cmd.getIpAddress(); + + try { + String broadcastUri = pubIp.getBroadcastUri(); + int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri)); + int ethDeviceNum = getVmNics(routerName, vlanId); + if (ethDeviceNum > 0) { + pubIp.setNicDevId(ethDeviceNum); + } else { + return new ExecutionResult(false, "Prepare Ip SNAT failed due to unable to find the nic"); + } + } catch (Exception e) { + String msg = "Prepare Ip SNAT failure due to " + e.toString(); + s_logger.error(msg, e); + return new ExecutionResult(false, e.toString()); + } + return new ExecutionResult(true, null); + } + + private ExecutionResult prepareNetworkElementCommand(SetNetworkACLCommand cmd) { + NicTO nic = cmd.getNic(); + String routerName = + cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + + try { + URI broadcastUri = nic.getBroadcastUri(); + int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri)); + int ethDeviceNum = getVmNics(routerName, vlanId); + if (ethDeviceNum > 0) { + nic.setDeviceId(ethDeviceNum); + } else { + return new ExecutionResult(false, "Prepare SetNetworkACL failed due to unable to find the nic"); + } + } catch (Exception e) { + String msg = "Prepare SetNetworkACL failed due to " + e.toString(); + s_logger.error(msg, e); + return new ExecutionResult(false, msg); + } + return new ExecutionResult(true, null); + } + + @Override + public ExecutionResult cleanupCommand(NetworkElementCommand cmd) { + return new ExecutionResult(true, null); + } + protected Answer execute(final RemoteAccessVpnCfgCommand cmd) { String controlIp = getRouterSshControlIp(cmd); StringBuffer argsBuf = new StringBuffer(); @@ -930,7 +1269,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S } try { - SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", keyFile, null, "/tmp/", tmpCfgFileContents.toString().getBytes(), routerIp.replace('.', '_') + + SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", keyFile, null, "/tmp/", tmpCfgFileContents.toString().getBytes(Charset.forName("UTF-8")), routerIp.replace('.', '_') + ".cfg", null); try { @@ -1127,7 +1466,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S String json = new Gson().toJson(data); s_logger.debug("VM data JSON IS:" + json); - json = Base64.encodeBase64String(json.getBytes()); + json = Base64.encodeBase64String(json.getBytes(Charset.forName("UTF-8"))); String args = "-d " + json; @@ -1477,6 +1816,27 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S } } + protected void modifyNicVlan(String vmName, int vlanId, int pos) { + ModifyVmNicConfigCommand modifynic = new ModifyVmNicConfigCommand(vmName, vlanId, pos); + URI agentUri = null; + try { + String cmdName = ModifyVmNicConfigCommand.class.getName(); + agentUri = + new URI("https", null, _agentIp, _port, + "/api/HypervResource/" + cmdName, null, null); + } catch (URISyntaxException e) { + String errMsg = "Could not generate URI for Hyper-V agent"; + s_logger.error(errMsg, e); + } + String ansStr = postHttpRequest(s_gson.toJson(modifynic), agentUri); + Answer[] result = s_gson.fromJson(ansStr, Answer[].class); + s_logger.debug("executeRequest received response " + + s_gson.toJson(result)); + if (result.length > 0) { + ModifyVmNicConfigAnswer ans = ((ModifyVmNicConfigAnswer)result[0]); + } + } + protected void assignPublicIpAddress(final String vmName, final String privateIpAddress, final String publicIpAddress, final boolean add, final boolean firstIP, final boolean sourceNat, final String broadcastId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception { @@ -1879,6 +2239,10 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S _configureCalled = true; } + _vrResource = new VirtualRoutingResource(this); + if (!_vrResource.configure(name, new HashMap())) { + throw new ConfigurationException("Unable to configure VirtualRoutingResource"); + } return true; } diff --git a/plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java b/plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java new file mode 100644 index 00000000000..011bd1292c7 --- /dev/null +++ b/plugins/hypervisors/hyperv/src/org/apache/cloudstack/storage/motion/HypervStorageMotionStrategy.java @@ -0,0 +1,179 @@ +/* + * 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 org.apache.cloudstack.storage.motion; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.inject.Inject; + +import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; +import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy; +import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; +import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority; +import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; +import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; +import org.apache.cloudstack.framework.async.AsyncCompletionCallback; +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; +import org.apache.cloudstack.storage.to.VolumeObjectTO; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; + +import com.cloud.agent.AgentManager; +import com.cloud.agent.api.Answer; +import com.cloud.agent.api.MigrateWithStorageAnswer; +import com.cloud.agent.api.MigrateWithStorageCommand; +import com.cloud.agent.api.to.StorageFilerTO; +import com.cloud.agent.api.to.VirtualMachineTO; +import com.cloud.agent.api.to.VolumeTO; +import com.cloud.exception.AgentUnavailableException; +import com.cloud.exception.OperationTimedoutException; +import com.cloud.host.Host; +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.storage.StoragePool; +import com.cloud.storage.VolumeVO; +import com.cloud.storage.dao.VolumeDao; +import com.cloud.utils.Pair; +import com.cloud.utils.exception.CloudRuntimeException; +import com.cloud.vm.VMInstanceVO; +import com.cloud.vm.dao.VMInstanceDao; + +@Component +public class HypervStorageMotionStrategy implements DataMotionStrategy { + private static final Logger s_logger = Logger.getLogger(HypervStorageMotionStrategy.class); + @Inject AgentManager agentMgr; + @Inject VolumeDao volDao; + @Inject VolumeDataFactory volFactory; + @Inject PrimaryDataStoreDao storagePoolDao; + @Inject VMInstanceDao instanceDao; + + @Override + public StrategyPriority canHandle(DataObject srcData, DataObject destData) { + return StrategyPriority.CANT_HANDLE; + } + + @Override + public StrategyPriority canHandle(Map volumeMap, Host srcHost, Host destHost) { + if (srcHost.getHypervisorType() == HypervisorType.Hyperv && + destHost.getHypervisorType() == HypervisorType.Hyperv) { + return StrategyPriority.HYPERVISOR; + } + + return StrategyPriority.CANT_HANDLE; + } + + @Override + public Void copyAsync(DataObject srcData, DataObject destData, Host destHost, AsyncCompletionCallback callback) { + throw new UnsupportedOperationException(); + } + + @Override + public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback callback) { + CopyCommandResult result = new CopyCommandResult(null, null); + result.setResult("Unsupported operation requested for copying data."); + callback.complete(result); + + return null; + } + + @Override + public Void copyAsync(Map volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, + AsyncCompletionCallback callback) { + Answer answer = null; + String errMsg = null; + try { + VMInstanceVO instance = instanceDao.findById(vmTo.getId()); + if (instance != null) { + answer = migrateVmWithVolumes(instance, vmTo, srcHost, destHost, volumeMap); + } else { + throw new CloudRuntimeException("Unsupported operation requested for moving data."); + } + } catch (Exception e) { + s_logger.error("copy failed", e); + errMsg = e.toString(); + } + + CopyCommandResult result = new CopyCommandResult(null, answer); + result.setResult(errMsg); + callback.complete(result); + return null; + } + + private Answer migrateVmWithVolumes(VMInstanceVO vm, VirtualMachineTO to, Host srcHost, + Host destHost, Map volumeToPool) throws AgentUnavailableException { + + // Initiate migration of a virtual machine with it's volumes. + try { + List> volumeToFilerto = new ArrayList>(); + for (Map.Entry entry : volumeToPool.entrySet()) { + VolumeInfo volume = entry.getKey(); + VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId())); + StorageFilerTO filerTo = new StorageFilerTO((StoragePool)entry.getValue()); + volumeToFilerto.add(new Pair(volumeTo, filerTo)); + } + + MigrateWithStorageCommand command = new MigrateWithStorageCommand(to, volumeToFilerto, destHost.getPrivateIpAddress()); + MigrateWithStorageAnswer answer = (MigrateWithStorageAnswer) agentMgr.send(srcHost.getId(), command); + if (answer == null) { + s_logger.error("Migration with storage of vm " + vm + " failed."); + throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost); + } else if (!answer.getResult()) { + s_logger.error("Migration with storage of vm " + vm+ " failed. Details: " + answer.getDetails()); + throw new CloudRuntimeException("Error while migrating the vm " + vm + " to host " + destHost + + ". " + answer.getDetails()); + } else { + // Update the volume details after migration. + updateVolumePathsAfterMigration(volumeToPool, answer.getVolumeTos()); + } + + return answer; + } catch (OperationTimedoutException e) { + s_logger.error("Error while migrating vm " + vm + " to host " + destHost, e); + throw new AgentUnavailableException("Operation timed out on storage motion for " + vm, destHost.getId()); + } + } + + private void updateVolumePathsAfterMigration(Map volumeToPool, List volumeTos) { + for (Map.Entry entry : volumeToPool.entrySet()) { + boolean updated = false; + VolumeInfo volume = entry.getKey(); + StoragePool pool = (StoragePool)entry.getValue(); + for (VolumeObjectTO volumeTo : volumeTos) { + if (volume.getId() == volumeTo.getId()) { + VolumeVO volumeVO = volDao.findById(volume.getId()); + Long oldPoolId = volumeVO.getPoolId(); + volumeVO.setPath(volumeTo.getPath()); + volumeVO.setFolder(pool.getPath()); + volumeVO.setPodId(pool.getPodId()); + volumeVO.setPoolId(pool.getId()); + volumeVO.setLastPoolId(oldPoolId); + volDao.update(volume.getId(), volumeVO); + updated = true; + break; + } + } + + if (!updated) { + s_logger.error("Volume path wasn't updated for volume " + volume + " after it was migrated."); + } + } + } +} diff --git a/plugins/hypervisors/kvm/findbugsExcludeFilter.xml b/plugins/hypervisors/kvm/findbugsExcludeFilter.xml new file mode 100644 index 00000000000..d37285017e8 --- /dev/null +++ b/plugins/hypervisors/kvm/findbugsExcludeFilter.xml @@ -0,0 +1,25 @@ + + + + + + diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml index 5eba1e08f83..c6858f701a2 100644 --- a/plugins/hypervisors/kvm/pom.xml +++ b/plugins/hypervisors/kvm/pom.xml @@ -15,7 +15,7 @@ org.apache.cloudstack cloudstack-plugins - 4.4.0-SNAPSHOT + 4.5.0-SNAPSHOT ../../pom.xml diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMGuestOsMapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMGuestOsMapper.java index f76b8a725f1..11d1e166f05 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMGuestOsMapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMGuestOsMapper.java @@ -126,6 +126,8 @@ public class KVMGuestOsMapper { s_mapper.put("Windows NT 4", "Windows NT"); s_mapper.put("Windows 3.1", "Windows 3.1"); s_mapper.put("Windows PV", "Other PV"); + s_mapper.put("FreeBSD 10 (32-bit)", "FreeBSD 10"); + s_mapper.put("FreeBSD 10 (64-bits", "FreeBSD 10"); s_mapper.put("Other PV (32-bit)", "Other PV"); s_mapper.put("Other PV (64-bit)", "Other PV"); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java index fdaaeb31c45..b829f78f625 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/KVMHABase.java @@ -48,11 +48,11 @@ public class KVMHABase { PoolType _type; public NfsStoragePool(String poolUUID, String poolIp, String poolSourcePath, String mountDestPath, PoolType type) { - this._poolUUID = poolUUID; - this._poolIp = poolIp; - this._poolMountSourcePath = poolSourcePath; - this._mountDestPath = mountDestPath; - this._type = type; + _poolUUID = poolUUID; + _poolIp = poolIp; + _poolMountSourcePath = poolSourcePath; + _mountDestPath = mountDestPath; + _type = type; } } @@ -115,8 +115,9 @@ public class KVMHABase { * the storage pool still running */ } + poolName = pool.getName(); } - poolName = pool.getName(); + } catch (LibvirtException e) { s_logger.debug("Ignoring libvirt error.", e); } finally { 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 fd0078c6970..beb5e10fd34 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 @@ -78,6 +78,8 @@ import com.cloud.agent.api.OvsDestroyTunnelCommand; import com.cloud.agent.api.OvsFetchInterfaceAnswer; import com.cloud.agent.api.OvsFetchInterfaceCommand; import com.cloud.agent.api.OvsSetupBridgeCommand; +import com.cloud.agent.api.OvsVpcPhysicalTopologyConfigCommand; +import com.cloud.agent.api.OvsVpcRoutingPolicyConfigCommand; import com.cloud.agent.api.PingCommand; import com.cloud.agent.api.PingRoutingCommand; import com.cloud.agent.api.PingRoutingWithNwGroupsCommand; @@ -199,6 +201,7 @@ import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.PowerState; import com.cloud.vm.VirtualMachine.State; + import org.apache.cloudstack.storage.command.StorageSubSystemCommand; import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; import org.apache.cloudstack.storage.to.VolumeObjectTO; @@ -207,6 +210,7 @@ import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat; import org.apache.cloudstack.utils.qemu.QemuImgException; import org.apache.cloudstack.utils.qemu.QemuImgFile; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.log4j.Logger; import org.libvirt.Connect; import org.libvirt.Domain; @@ -216,9 +220,11 @@ import org.libvirt.DomainInterfaceStats; import org.libvirt.DomainSnapshot; import org.libvirt.LibvirtException; import org.libvirt.NodeInfo; +import org.libvirt.StorageVol; import javax.ejb.Local; import javax.naming.ConfigurationException; + import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; @@ -228,6 +234,7 @@ import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.Reader; import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; @@ -249,11 +256,14 @@ import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.UUID; +import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -301,6 +311,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private String _pod; private String _clusterId; private int _migrateSpeed; + private int _migrateDowntime; + private int _migratePauseAfter; private long _hvVersion; private long _kernelVersion; @@ -319,7 +331,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv @Override public ExecutionResult executeInVR(String routerIp, String script, String args) { - final Script command = new Script(_routerProxyPath, _timeout, s_logger); + return executeInVR(routerIp, script, args, _timeout / 1000); + } + + @Override + public ExecutionResult executeInVR(String routerIp, String script, String args, int timeout) { + final Script command = new Script(_routerProxyPath, timeout * 1000, s_logger); final AllLinesParser parser = new AllLinesParser(); command.add(script); command.add(routerIp); @@ -367,6 +384,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv @Override public ExecutionResult cleanupCommand(NetworkElementCommand cmd) { + if (cmd instanceof IpAssocCommand && !(cmd instanceof IpAssocVpcCommand)) { + return cleanupNetworkElementCommand((IpAssocCommand)cmd); + } return new ExecutionResult(true, null); } @@ -436,7 +456,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv protected int _stopTimeout; // TODO vmsync { - protected static HashMap s_statesTable; + protected static final HashMap s_statesTable; static { s_statesTable = new HashMap(); s_statesTable.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF, State.Stopped); @@ -448,7 +468,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } // TODO vmsync } - protected static HashMap s_powerStatesTable; + protected static final HashMap s_powerStatesTable; static { s_powerStatesTable = new HashMap(); s_powerStatesTable.put(DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF, PowerState.PowerOff); @@ -881,6 +901,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv _mountPoint = "/mnt"; } + value = (String) params.get("vm.migrate.downtime"); + _migrateDowntime = NumbersUtil.parseInt(value, -1); + + value = (String) params.get("vm.migrate.pauseafter"); + _migratePauseAfter = NumbersUtil.parseInt(value, -1); + value = (String)params.get("vm.migrate.speed"); _migrateSpeed = NumbersUtil.parseInt(value, -1); if (_migrateSpeed == -1) { @@ -1151,12 +1177,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv Script command = new Script("/bin/sh", _timeout); command.add("-c"); command.add("ovs-vsctl br-exists " + networkName); - String result = command.execute(null); - if ("0".equals(result)) { - return true; - } else { - return false; - } + return "0".equals(command.execute(null)); } private boolean passCmdLine(String vmName, String cmdLine) throws InternalErrorException { @@ -1313,7 +1334,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } else if (cmd instanceof UnPlugNicCommand) { return execute((UnPlugNicCommand)cmd); } else if (cmd instanceof NetworkElementCommand) { - return _virtRouterResource.executeRequest(cmd); + return _virtRouterResource.executeRequest((NetworkElementCommand)cmd); } else if (cmd instanceof CheckSshCommand) { return execute((CheckSshCommand)cmd); } else if (cmd instanceof NetworkUsageCommand) { @@ -1346,6 +1367,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return execute((OvsCreateTunnelCommand)cmd); } else if (cmd instanceof OvsDestroyTunnelCommand) { return execute((OvsDestroyTunnelCommand)cmd); + } else if (cmd instanceof OvsVpcPhysicalTopologyConfigCommand) { + return execute((OvsVpcPhysicalTopologyConfigCommand) cmd); + } else if (cmd instanceof OvsVpcRoutingPolicyConfigCommand) { + return execute((OvsVpcRoutingPolicyConfigCommand) cmd); } else { s_logger.warn("Unsupported command "); return Answer.createUnsupportedCommandAnswer(cmd); @@ -1374,23 +1399,63 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } private Answer execute(OvsSetupBridgeCommand cmd) { - findOrCreateTunnelNetwork(cmd.getKey()); + findOrCreateTunnelNetwork(cmd.getBridgeName()); configureTunnelNetwork(cmd.getNetworkId(), cmd.getHostId(), - cmd.getKey()); + cmd.getBridgeName()); s_logger.debug("OVS Bridge configured"); return new Answer(cmd, true, null); } private Answer execute(OvsDestroyBridgeCommand cmd) { - destroyTunnelNetwork(cmd.getKey()); + destroyTunnelNetwork(cmd.getBridgeName()); s_logger.debug("OVS Bridge destroyed"); return new Answer(cmd, true, null); } - private synchronized void destroyTunnelNetwork(int key) { + public Answer execute(OvsVpcPhysicalTopologyConfigCommand cmd) { + + String bridge = cmd.getBridgeName(); try { - findOrCreateTunnelNetwork(key); - String bridge = "OVSTunnel" + key; + Script command = new Script(_ovsTunnelPath, _timeout, s_logger); + command.add("configure_ovs_bridge_for_network_topology"); + command.add("--bridge", bridge); + command.add("--config", cmd.getVpcConfigInJson()); + + String result = command.execute(); + if (result.equalsIgnoreCase("SUCCESS")) { + return new Answer(cmd, true, result); + } else { + return new Answer(cmd, false, result); + } + } catch (Exception e) { + s_logger.warn("caught exception while updating host with latest routing polcies", e); + return new Answer(cmd, false, e.getMessage()); + } + } + + public Answer execute(OvsVpcRoutingPolicyConfigCommand cmd) { + + try { + Script command = new Script(_ovsTunnelPath, _timeout, s_logger); + command.add("configure_ovs_bridge_for_routing_policies"); + command.add("--bridge", cmd.getBridgeName()); + command.add("--config", cmd.getVpcConfigInJson()); + + String result = command.execute(); + if (result.equalsIgnoreCase("SUCCESS")) { + return new Answer(cmd, true, result); + } else { + return new Answer(cmd, false, result); + } + } catch (Exception e) { + s_logger.warn("caught exception while updating host with latest VPC topology", e); + return new Answer(cmd, false, e.getMessage()); + } + } + + private synchronized void destroyTunnelNetwork(String bridge) { + try { + findOrCreateTunnelNetwork(bridge); Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger); cmd.add("destroy_ovs_bridge"); cmd.add("--bridge", bridge); @@ -1409,9 +1474,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } } - private synchronized boolean findOrCreateTunnelNetwork(long key) { + private synchronized boolean findOrCreateTunnelNetwork(String nwName) { try { - String nwName = "OVSTunnel" + key; if (checkNetwork(nwName)) { return true; } @@ -1429,10 +1493,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } private synchronized boolean configureTunnelNetwork(long networkId, - long hostId, int key) { + long hostId, String nwName) { try { - findOrCreateTunnelNetwork(key); - String nwName = "OVSTunnel" + key; + findOrCreateTunnelNetwork(nwName); String configuredHosts = Script .runSimpleBashScript("ovs-vsctl get bridge " + nwName + " other_config:ovs_host_setup"); @@ -1449,7 +1512,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (!configured) { Script cmd = new Script(_ovsTunnelPath, _timeout, s_logger); cmd.add("setup_ovs_bridge"); - cmd.add("--key", String.valueOf(key)); + cmd.add("--key", nwName); cmd.add("--cs_host_id", ((Long)hostId).toString()); cmd.add("--bridge", nwName); String result = cmd.execute(); @@ -1467,16 +1530,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } private OvsCreateTunnelAnswer execute(OvsCreateTunnelCommand cmd) { - String bridge = "OVSTunnel" + cmd.getKey(); + String bridge = cmd.getNetworkName(); try { - if (!findOrCreateTunnelNetwork(cmd.getKey())) { + if (!findOrCreateTunnelNetwork(bridge)) { s_logger.debug("Error during bridge setup"); return new OvsCreateTunnelAnswer(cmd, false, "Cannot create network", bridge); } configureTunnelNetwork(cmd.getNetworkId(), cmd.getFrom(), - cmd.getKey()); + cmd.getNetworkName()); Script command = new Script(_ovsTunnelPath, _timeout, s_logger); command.add("create_tunnel"); command.add("--bridge", bridge); @@ -1501,16 +1564,15 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private Answer execute(OvsDestroyTunnelCommand cmd) { try { - if (!findOrCreateTunnelNetwork(cmd.getKey())) { + if (!findOrCreateTunnelNetwork(cmd.getBridgeName())) { s_logger.warn("Unable to find tunnel network for GRE key:" - + cmd.getKey()); + + cmd.getBridgeName()); return new Answer(cmd, false, "No network found"); } - String bridge = "OVSTunnel" + cmd.getKey(); Script command = new Script(_ovsTunnelPath, _timeout, s_logger); command.add("destroy_tunnel"); - command.add("--bridge", bridge); + command.add("--bridge", cmd.getBridgeName()); command.add("--iface_name", cmd.getInPortName()); String result = command.execute(); if (result == null) { @@ -1750,8 +1812,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv if (pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) { return "CLVM"; - } else if ((poolType == StoragePoolType.NetworkFilesystem || poolType == StoragePoolType.SharedMountPoint || poolType == StoragePoolType.Filesystem) && - volFormat == PhysicalDiskFormat.QCOW2) { + } else if ((poolType == StoragePoolType.NetworkFilesystem + || poolType == StoragePoolType.SharedMountPoint + || poolType == StoragePoolType.Filesystem + || poolType == StoragePoolType.Gluster) + && volFormat == PhysicalDiskFormat.QCOW2 ) { return "QCOW2"; } return null; @@ -1767,51 +1832,47 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv boolean shrinkOk = cmd.getShrinkOk(); StorageFilerTO spool = cmd.getPool(); + if ( currentSize == newSize) { + // nothing to do + s_logger.info("No need to resize volume: current size " + currentSize + " is same as new size " + newSize); + return new ResizeVolumeAnswer(cmd, true, "success", currentSize); + } + try { KVMStoragePool pool = _storagePoolMgr.getStoragePool(spool.getType(), spool.getUuid()); KVMPhysicalDisk vol = pool.getPhysicalDisk(volid); String path = vol.getPath(); String type = getResizeScriptType(pool, vol); - /** - * RBD volumes can't be resized via a Bash script or via libvirt - * - * libvirt-java doesn't implemented resizing volumes, so we have to do this manually - * - * Future fix would be to hand this over to libvirt - */ - if (pool.getType() == StoragePoolType.RBD) { + if (type == null) { + return new ResizeVolumeAnswer(cmd, false, "Unsupported volume format: pool type '" + pool.getType() + "' and volume format '" + vol.getFormat() + "'"); + } else if (type.equals("QCOW2") && shrinkOk) { + return new ResizeVolumeAnswer(cmd, false, "Unable to shrink volumes of type " + type); + } + + s_logger.debug("Resizing volume: " + path + "," + currentSize + "," + newSize + "," + type + "," + vmInstanceName + "," + shrinkOk); + + /* libvirt doesn't support resizing (C)LVM devices, so we have to do that via a Bash script */ + if (pool.getType() != StoragePoolType.CLVM) { + s_logger.debug("Volume " + path + " can be resized by libvirt. Asking libvirt to resize the volume."); try { - Rados r = new Rados(pool.getAuthUserName()); - r.confSet("mon_host", pool.getSourceHost() + ":" + pool.getSourcePort()); - r.confSet("key", pool.getAuthSecret()); - r.connect(); - s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); + Connect conn = LibvirtConnection.getConnection(); + StorageVol v = conn.storageVolLookupByPath(path); + int flags = 0; - IoCTX io = r.ioCtxCreate(pool.getSourceDir()); - Rbd rbd = new Rbd(io); - RbdImage image = rbd.open(vol.getName()); + if (conn.getLibVirVersion() > 1001000 && vol.getFormat() == PhysicalDiskFormat.RAW) { + flags = 1; + } + if (shrinkOk) { + flags = 4; + } - s_logger.debug("Resizing RBD volume " + vol.getName() + " to " + newSize + " bytes"); - image.resize(newSize); - rbd.close(image); - - r.ioCtxDestroy(io); - s_logger.debug("Succesfully resized RBD volume " + vol.getName() + " to " + newSize + " bytes"); - } catch (RadosException e) { - return new ResizeVolumeAnswer(cmd, false, e.toString()); - } catch (RbdException e) { + v.resize(newSize, flags); + } catch (LibvirtException e) { return new ResizeVolumeAnswer(cmd, false, e.toString()); } } else { - if (type == null) { - return new ResizeVolumeAnswer(cmd, false, "Unsupported volume format: pool type '" + pool.getType() + "' and volume format '" + vol.getFormat() + "'"); - } else if (type.equals("QCOW2") && shrinkOk) { - return new ResizeVolumeAnswer(cmd, false, "Unable to shrink volumes of type " + type); - } - - s_logger.debug("got to the stage where we execute the volume resize, params:" + path + "," + currentSize + "," + newSize + "," + type + "," + - vmInstanceName + "," + shrinkOk); + s_logger.debug("Volume " + path + " is of the type LVM and can not be resized using libvirt. Invoking resize script."); final Script resizecmd = new Script(_resizeVolumePath, _cmdsTimeout, s_logger); resizecmd.add("-s", String.valueOf(newSize)); resizecmd.add("-c", String.valueOf(currentSize)); @@ -1948,6 +2009,24 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv vm.attachDevice(getVifDriver(nicTO.getType()).plug(nicTO, "Other PV (32-bit)").toString()); } + + private void vifHotUnPlug (Connect conn, String vmName, String macAddr) throws InternalErrorException, LibvirtException { + + Domain vm = null; + vm = getDomain(conn, vmName); + List pluggedNics = getInterfaces(conn, vmName); + for (InterfaceDef pluggedNic : pluggedNics) { + if (pluggedNic.getMacAddress().equalsIgnoreCase(macAddr)) { + vm.detachDevice(pluggedNic.toString()); + // We don't know which "traffic type" is associated with + // each interface at this point, so inform all vif drivers + for (VifDriver vifDriver : getAllVifDrivers()) { + vifDriver.unplug(pluggedNic); + } + } + } + } + private PlugNicAnswer execute(PlugNicCommand cmd) { NicTO nic = cmd.getNic(); String vmName = cmd.getVmName(); @@ -2174,6 +2253,65 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } } + protected ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) { + + String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); + String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); + Connect conn; + + + try{ + conn = LibvirtConnection.getConnectionByVmName(routerName); + List nics = getInterfaces(conn, routerName); + Map broadcastUriAllocatedToVM = new HashMap(); + + Integer nicPos = 0; + for (InterfaceDef nic : nics) { + if (nic.getBrName().equalsIgnoreCase(_linkLocalBridgeName)) { + broadcastUriAllocatedToVM.put("LinkLocal", nicPos); + } else { + if (nic.getBrName().equalsIgnoreCase(_publicBridgeName) || nic.getBrName().equalsIgnoreCase(_privBridgeName) || + nic.getBrName().equalsIgnoreCase(_guestBridgeName)) { + broadcastUriAllocatedToVM.put(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString(), nicPos); + } else { + String broadcastUri = getBroadcastUriFromBridge(nic.getBrName()); + broadcastUriAllocatedToVM.put(broadcastUri, nicPos); + } + } + nicPos++; + } + + IpAddressTO[] ips = cmd.getIpAddresses(); + int numOfIps = ips.length; + int nicNum = 0; + for (IpAddressTO ip : ips) { + + boolean newNic = false; + if (!broadcastUriAllocatedToVM.containsKey(ip.getBroadcastUri())) { + /* plug a vif into router */ + VifHotPlug(conn, routerName, ip.getBroadcastUri(), ip.getVifMacAddress()); + broadcastUriAllocatedToVM.put(ip.getBroadcastUri(), nicPos++); + newNic = true; + } + nicNum = broadcastUriAllocatedToVM.get(ip.getBroadcastUri()); + + if (numOfIps == 1 && !ip.isAdd()) { + vifHotUnPlug(conn, routerName, ip.getVifMacAddress()); + networkUsage(routerIp, "deleteVif", "eth" + nicNum); + } + } + + } catch (LibvirtException e) { + s_logger.error("ipassoccmd failed", e); + return new ExecutionResult(false, e.getMessage()); + } catch (InternalErrorException e) { + s_logger.error("ipassoccmd failed", e); + return new ExecutionResult(false, e.getMessage()); + } + + return new ExecutionResult(true, null); + } + protected ManageSnapshotAnswer execute(final ManageSnapshotCommand cmd) { String snapshotName = cmd.getSnapshotName(); String snapshotPath = cmd.getSnapshotPath(); @@ -2234,6 +2372,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv Rados r = new Rados(primaryPool.getAuthUserName()); r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); r.confSet("key", primaryPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); @@ -2316,6 +2455,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv Rados r = new Rados(primaryPool.getAuthUserName()); r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); r.confSet("key", primaryPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); @@ -2906,6 +3046,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } List ifaces = null; + List disks = null; Domain dm = null; Connect dconn = null; @@ -2913,8 +3054,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv Connect conn = null; String xmlDesc = null; try { - conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); + conn = LibvirtConnection.getConnectionByVmName(vmName); ifaces = getInterfaces(conn, vmName); + disks = getDisks(conn, vmName); dm = conn.domainLookupByName(vmName); /* We replace the private IP address with the address of the destination host. @@ -2932,15 +3074,65 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv xmlDesc = dm.getXMLDesc(0).replace(_privateIp, cmd.getDestinationIp()); dconn = new Connect("qemu+tcp://" + cmd.getDestinationIp() + "/system"); - /* - * Hard code lm flag: VIR_MIGRATE_LIVE(1<<0) - */ - destDomain = dm.migrate(dconn, (1 << 0), xmlDesc, vmName, "tcp:" + cmd.getDestinationIp(), _migrateSpeed); - _storagePoolMgr.disconnectPhysicalDisksViaVmSpec(cmd.getVirtualMachine()); + //run migration in thread so we can monitor it + s_logger.info("Live migration of instance " + vmName + " initiated"); + ExecutorService executor = Executors.newFixedThreadPool(1); + Callable worker = new MigrateKVMAsync(dm, dconn, xmlDesc, vmName, cmd.getDestinationIp()); + Future migrateThread = executor.submit(worker); + executor.shutdown(); + long sleeptime = 0; + while (!executor.isTerminated()) { + Thread.sleep(100); + sleeptime += 100; + if (sleeptime == 1000) { // wait 1s before attempting to set downtime on migration, since I don't know of a VIR_DOMAIN_MIGRATING state + if (_migrateDowntime > 0 ) { + try { + int setDowntime = dm.migrateSetMaxDowntime(_migrateDowntime); + if (setDowntime == 0 ) { + s_logger.debug("Set max downtime for migration of " + vmName + " to " + String.valueOf(_migrateDowntime) + "ms"); + } + } catch (LibvirtException e) { + s_logger.debug("Failed to set max downtime for migration, perhaps migration completed? Error: " + e.getMessage()); + } + } + } + if ((sleeptime % 1000) == 0) { + s_logger.info("Waiting for migration of " + vmName + " to complete, waited " + sleeptime + "ms"); + } + + // pause vm if we meet the vm.migrate.pauseafter threshold and not already paused + if (_migratePauseAfter > 0 && sleeptime > _migratePauseAfter && dm.getInfo().state == DomainInfo.DomainState.VIR_DOMAIN_RUNNING ) { + s_logger.info("Pausing VM " + vmName + " due to property vm.migrate.pauseafter setting to " + _migratePauseAfter+ "ms to complete migration"); + try { + dm.suspend(); + } catch (LibvirtException e) { + // pause could be racy if it attempts to pause right when vm is finished, simply warn + s_logger.info("Failed to pause vm " + vmName + " : " + e.getMessage()); + } + } + } + s_logger.info("Migration thread for " + vmName + " is done"); + + destDomain = migrateThread.get(10, TimeUnit.SECONDS); + + if (destDomain != null) { + for (DiskDef disk : disks) { + cleanupDisk(disk); + } + } } catch (LibvirtException e) { s_logger.debug("Can't migrate domain: " + e.getMessage()); result = e.getMessage(); + } catch (InterruptedException e) { + s_logger.debug("Interrupted while migrating domain: " + e.getMessage()); + result = e.getMessage(); + } catch (ExecutionException e) { + s_logger.debug("Failed to execute while migrating domain: " + e.getMessage()); + result = e.getMessage(); + } catch (TimeoutException e) { + s_logger.debug("Timed out while migrating domain: " + e.getMessage()); + result = e.getMessage(); } finally { try { if (dm != null) { @@ -2978,6 +3170,32 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return new MigrateAnswer(cmd, result == null, result, null); } + private class MigrateKVMAsync implements Callable { + Domain dm = null; + Connect dconn = null; + String dxml = ""; + String vmName = ""; + String destIp = ""; + + MigrateKVMAsync(Domain dm, Connect dconn, String dxml, String vmName, String destIp) { + this.dm = dm; + this.dconn = dconn; + this.dxml = dxml; + this.vmName = vmName; + this.destIp = destIp; + } + + @Override + public Domain call() throws LibvirtException { + // set compression flag for migration if libvirt version supports it + if (dconn.getLibVirVersion() < 1003000) { + return dm.migrate(dconn, (1 << 0), dxml, vmName, "tcp:" + destIp, _migrateSpeed); + } else { + return dm.migrate(dconn, (1 << 0)|(1 << 11), dxml, vmName, "tcp:" + destIp, _migrateSpeed); + } + } + } + private synchronized Answer execute(PrepareForMigrationCommand cmd) { VirtualMachineTO vm = cmd.getVirtualMachine(); @@ -2987,7 +3205,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv NicTO[] nics = vm.getNics(); - boolean success = false; + boolean skipDisconnect = false; try { Connect conn = LibvirtConnection.getConnectionByVmName(vm.getName()); @@ -3003,13 +3221,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } } - _storagePoolMgr.connectPhysicalDisksViaVmSpec(vm); + if (!_storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) { + skipDisconnect = true; + return new PrepareForMigrationAnswer(cmd, "failed to connect physical disks to host"); + } synchronized (_vms) { _vms.put(vm.getName(), State.Migrating); } - success = true; + skipDisconnect = true; return new PrepareForMigrationAnswer(cmd); } catch (LibvirtException e) { @@ -3019,7 +3240,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } catch (URISyntaxException e) { return new PrepareForMigrationAnswer(cmd, e.toString()); } finally { - if (!success) { + if (!skipDisconnect) { _storagePoolMgr.disconnectPhysicalDisksViaVmSpec(vm); } } @@ -3330,13 +3551,11 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } if (pubKeyFile.exists()) { - String pubKey = cmd.getPubKey(); - try { - FileOutputStream pubkStream = new FileOutputStream(pubKeyFile); - pubkStream.write(pubKey.getBytes()); - pubkStream.close(); + try (FileOutputStream pubkStream = new FileOutputStream(pubKeyFile)) { + pubkStream.write(cmd.getPubKey().getBytes()); } catch (FileNotFoundException e) { - result = "File" + SSHPUBKEYPATH + "is not found:" + e.toString(); + result = "File" + SSHPUBKEYPATH + "is not found:" + + e.toString(); s_logger.debug(result); } catch (IOException e) { result = "Write file " + SSHPUBKEYPATH + ":" + e.toString(); @@ -3554,7 +3773,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv createVbd(conn, vmSpec, vmName, vm); - _storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec); + if (!_storagePoolMgr.connectPhysicalDisksViaVmSpec(vmSpec)) { + return new StartAnswer(cmd, "Failed to connect physical disks to host"); + } createVifs(vmSpec, vm); @@ -3710,7 +3931,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv we pass the pool's UUID as the authSecret */ disk.defNetworkBasedDisk(physicalDisk.getPath().replace("rbd:", ""), pool.getSourceHost(), pool.getSourcePort(), pool.getAuthUserName(), - pool.getUuid(), devId, diskBusType, diskProtocol.RBD); + pool.getUuid(), devId, diskBusType, diskProtocol.RBD, DiskDef.diskFmtType.RAW); + } else if (pool.getType() == StoragePoolType.Gluster) { + String mountpoint = pool.getLocalPath(); + String path = physicalDisk.getPath(); + String glusterVolume = pool.getSourceDir().replace("/", ""); + disk.defNetworkBasedDisk(glusterVolume + path.replace(mountpoint, ""), pool.getSourceHost(), pool.getSourcePort(), null, + null, devId, diskBusType, diskProtocol.GLUSTER, DiskDef.diskFmtType.QCOW2); } else if (pool.getType() == StoragePoolType.CLVM || physicalDisk.getFormat() == PhysicalDiskFormat.RAW) { disk.defBlockBasedDisk(physicalDisk.getPath(), devId, diskBusType); } else { @@ -3867,7 +4094,10 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv diskdef = new DiskDef(); if (attachingPool.getType() == StoragePoolType.RBD) { diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), attachingPool.getAuthUserName(), - attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD); + attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD, DiskDef.diskFmtType.RAW); + } else if (attachingPool.getType() == StoragePoolType.Gluster) { + diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), null, + null, devId, DiskDef.diskBus.VIRTIO, diskProtocol.GLUSTER, DiskDef.diskFmtType.QCOW2); } else if (attachingDisk.getFormat() == PhysicalDiskFormat.QCOW2) { diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, DiskDef.diskBus.VIRTIO, DiskDef.diskFmtType.QCOW2); } else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) { @@ -4210,6 +4440,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv try { conn = LibvirtConnection.getConnectionByType(HypervisorType.LXC.toString()); vmStates.putAll(getAllVms(conn)); + conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString()); + vmStates.putAll(getAllVms(conn)); } catch (LibvirtException e) { s_logger.debug("Failed to get connection: " + e.getMessage()); } @@ -4306,6 +4538,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv try { conn = LibvirtConnection.getConnectionByType(HypervisorType.LXC.toString()); vmStates.putAll(getHostVmStateReport(conn)); + conn = LibvirtConnection.getConnectionByType(HypervisorType.KVM.toString()); + vmStates.putAll(getHostVmStateReport(conn)); } catch (LibvirtException e) { s_logger.debug("Failed to get connection: " + e.getMessage()); } @@ -4353,7 +4587,13 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv s_logger.trace("VM " + dm.getName() + ": powerstate = " + ps + "; vm state=" + state.toString()); String vmName = dm.getName(); - vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName(), null)); + + // TODO : for XS/KVM (host-based resource), we require to remove + // VM completely from host, for some reason, KVM seems to still keep + // Stopped VM around, to work-around that, reporting only powered-on VM + // + if (state == PowerState.PowerOn) + vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName())); } catch (final LibvirtException e) { s_logger.warn("Unable to get vms", e); } finally { @@ -4377,7 +4617,12 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv String vmName = dm.getName(); s_logger.trace("VM " + vmName + ": powerstate = " + ps + "; vm state=" + state.toString()); - vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName(), null)); + // TODO : for XS/KVM (host-based resource), we require to remove + // VM completely from host, for some reason, KVM seems to still keep + // Stopped VM around, to work-around that, reporting only powered-on VM + // + if (state == PowerState.PowerOn) + vmStates.put(vmName, new HostVmStateReportEntry(state, conn.getHostName())); } catch (final LibvirtException e) { s_logger.warn("Unable to get vms", e); } finally { @@ -4402,24 +4647,9 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv int cpuSockets = 0; String cap = null; try { - Connect conn = LibvirtConnection.getConnection(); + final Connect conn = LibvirtConnection.getConnection(); final NodeInfo hosts = conn.nodeInfo(); - boolean result = false; - try { - BufferedReader in = new BufferedReader(new FileReader("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq")); - speed = Long.parseLong(in.readLine()) / 1000; - result = true; - } catch (FileNotFoundException e) { - - } catch (IOException e) { - - } catch (NumberFormatException e) { - - } - - if (!result) { - speed = hosts.mhz; - } + speed = getCpuSpeed(hosts); cpuSockets = hosts.sockets; cpus = hosts.cpus; @@ -4460,6 +4690,16 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return info; } + protected static long getCpuSpeed(final NodeInfo nodeInfo) { + try (final Reader reader = new FileReader( + "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq")) { + return Long.parseLong(IOUtils.toString(reader).trim()) / 1000; + } catch (IOException | NumberFormatException e) { + s_logger.warn("Could not read cpuinfo_max_freq"); + return nodeInfo.mhz; + } + } + protected String rebootVM(Connect conn, String vmName) { Domain dm = null; String msg = null; @@ -4696,7 +4936,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv guestOSName.startsWith("CentOS 5.5") || guestOS.startsWith("CentOS") || guestOS.startsWith("Fedora") || guestOSName.startsWith("Red Hat Enterprise Linux 5.3") || guestOSName.startsWith("Red Hat Enterprise Linux 5.4") || guestOSName.startsWith("Red Hat Enterprise Linux 5.5") || guestOSName.startsWith("Red Hat Enterprise Linux 6") || guestOS.startsWith("Debian GNU/Linux") || - guestOSName.startsWith("Other PV")) { + guestOSName.startsWith("FreeBSD 10") || guestOSName.startsWith("Other PV")) { return true; } else { return false; @@ -5220,4 +5460,8 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } + public HypervisorType getHypervisorType(){ + return _hypervisorType; + } + } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java index 127f648c92f..fabe9a881db 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParser.java @@ -64,6 +64,7 @@ public class LibvirtDomainXMLParser { String type = disk.getAttribute("type"); DiskDef def = new DiskDef(); if (type.equalsIgnoreCase("network")) { + String diskFmtType = getAttrValue("driver", "type", disk); String diskCacheMode = getAttrValue("driver", "cache", disk); String diskPath = getAttrValue("source", "name", disk); String protocol = getAttrValue("source", "protocol", disk); @@ -73,10 +74,16 @@ public class LibvirtDomainXMLParser { int port = Integer.parseInt(getAttrValue("host", "port", disk)); String diskLabel = getAttrValue("target", "dev", disk); String bus = getAttrValue("target", "bus", disk); + + DiskDef.diskFmtType fmt = null; + if (diskFmtType != null) { + fmt = DiskDef.diskFmtType.valueOf(diskFmtType.toUpperCase()); + } + def.defNetworkBasedDisk(diskPath, host, port, authUserName, poolUuid, diskLabel, DiskDef.diskBus.valueOf(bus.toUpperCase()), - DiskDef.diskProtocol.valueOf(protocol.toUpperCase())); - def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode)); + DiskDef.diskProtocol.valueOf(protocol.toUpperCase()), fmt); + def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode.toUpperCase())); } else { String diskFmtType = getAttrValue("driver", "type", disk); String diskCacheMode = getAttrValue("driver", "cache", disk); @@ -100,8 +107,8 @@ public class LibvirtDomainXMLParser { } else if (type.equalsIgnoreCase("block")) { def.defBlockBasedDisk(diskDev, diskLabel, DiskDef.diskBus.valueOf(bus.toUpperCase())); - def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode)); } + def.setCacheMode(DiskDef.diskCacheMode.valueOf(diskCacheMode.toUpperCase())); } NodeList iotune = disk.getElementsByTagName("iotune"); @@ -145,8 +152,9 @@ public class LibvirtDomainXMLParser { if ((bandwidth != null) && (bandwidth.getLength() != 0)) { Integer inbound = Integer.valueOf(getAttrValue("inbound", "average", (Element)bandwidth.item(0))); Integer outbound = Integer.valueOf(getAttrValue("outbound", "average", (Element)bandwidth.item(0))); - if (inbound == outbound) + if (inbound.equals(outbound)) { networkRateKBps = inbound; + } } if (type.equalsIgnoreCase("network")) { String network = getAttrValue("source", "network", nic); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java index dbe5d4b7835..7631169f2b5 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolDef.java @@ -18,7 +18,7 @@ package com.cloud.hypervisor.kvm.resource; public class LibvirtStoragePoolDef { public enum poolType { - ISCSI("iscsi"), NETFS("netfs"), LOGICAL("logical"), DIR("dir"), RBD("rbd"); + ISCSI("iscsi"), NETFS("netfs"), LOGICAL("logical"), DIR("dir"), RBD("rbd"), GLUSTERFS("glusterfs"); String _poolType; poolType(String poolType) { @@ -127,7 +127,15 @@ public class LibvirtStoragePoolDef { @Override public String toString() { StringBuilder storagePoolBuilder = new StringBuilder(); - storagePoolBuilder.append("\n"); + if (_poolType == poolType.GLUSTERFS) { + /* libvirt mounts a Gluster volume, similar to NFS */ + storagePoolBuilder.append("\n"); + } else { + storagePoolBuilder.append("\n"); + } + storagePoolBuilder.append("" + _poolName + "\n"); if (_uuid != null) storagePoolBuilder.append("" + _uuid + "\n"); @@ -148,6 +156,23 @@ public class LibvirtStoragePoolDef { } storagePoolBuilder.append("\n"); } + if (_poolType == poolType.GLUSTERFS) { + storagePoolBuilder.append("\n"); + storagePoolBuilder.append("\n"); + storagePoolBuilder.append("\n"); + storagePoolBuilder.append("\n"); + storagePoolBuilder.append("\n"); + } if (_poolType != poolType.RBD) { storagePoolBuilder.append("\n"); storagePoolBuilder.append("" + _targetPath + "\n"); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java index a6186f6ba69..6199e5da2c8 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtStoragePoolXMLParser.java @@ -52,6 +52,7 @@ public class LibvirtStoragePoolXMLParser { Element source = (Element)rootElement.getElementsByTagName("source").item(0); String host = getAttrValue("host", "name", source); + String format = getAttrValue("format", "type", source); if (type.equalsIgnoreCase("rbd")) { int port = Integer.parseInt(getAttrValue("host", "port", source)); @@ -63,10 +64,27 @@ public class LibvirtStoragePoolXMLParser { String authUsername = auth.getAttribute("username"); String authType = auth.getAttribute("type"); return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(type.toUpperCase()), poolName, uuid, host, port, pool, authUsername, - LibvirtStoragePoolDef.authType.valueOf(authType.toUpperCase()), uuid); + LibvirtStoragePoolDef.authType.valueOf(authType.toUpperCase()), uuid); } else { return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(type.toUpperCase()), poolName, uuid, host, port, pool, ""); } + /* Gluster is a sub-type of LibvirtStoragePoolDef.poolType.NETFS, need to check format */ + } else if (format != null && format.equalsIgnoreCase("glusterfs")) { + /* libvirt does not return the default port, but requires it for a disk-definition */ + int port = 24007; + + String path = getAttrValue("dir", "path", source); + + Element target = (Element) rootElement.getElementsByTagName( + "target").item(0); + String targetPath = getTagValue("path", target); + + String portValue = getAttrValue("host", "port", source); + if (portValue != null && !portValue.isEmpty()) + port = Integer.parseInt(portValue); + + return new LibvirtStoragePoolDef(LibvirtStoragePoolDef.poolType.valueOf(format.toUpperCase()), + poolName, uuid, host, port, path, targetPath); } else { String path = getAttrValue("dir", "path", source); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index 5aeacdafae0..4032305b032 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -378,7 +378,7 @@ public class LibvirtVMDef { } public enum diskProtocol { - RBD("rbd"), SHEEPDOG("sheepdog"); + RBD("rbd"), SHEEPDOG("sheepdog"), GLUSTER("gluster"); String _diskProtocol; diskProtocol(String protocol) { @@ -530,10 +530,10 @@ public class LibvirtVMDef { } public void defNetworkBasedDisk(String diskName, String sourceHost, int sourcePort, String authUserName, String authSecretUUID, int devId, diskBus bus, - diskProtocol protocol) { + diskProtocol protocol, diskFmtType diskFmtType) { _diskType = diskType.NETWORK; _deviceType = deviceType.DISK; - _diskFmtType = diskFmtType.RAW; + _diskFmtType = diskFmtType; _diskCacheMode = diskCacheMode.NONE; _sourcePath = diskName; _sourceHost = sourceHost; @@ -546,10 +546,10 @@ public class LibvirtVMDef { } public void defNetworkBasedDisk(String diskName, String sourceHost, int sourcePort, String authUserName, String authSecretUUID, String diskLabel, diskBus bus, - diskProtocol protocol) { + diskProtocol protocol, diskFmtType diskFmtType) { _diskType = diskType.NETWORK; _deviceType = deviceType.DISK; - _diskFmtType = diskFmtType.RAW; + _diskFmtType = diskFmtType; _diskCacheMode = diskCacheMode.NONE; _sourcePath = diskName; _sourceHost = sourceHost; @@ -585,6 +585,10 @@ public class LibvirtVMDef { return _diskLabel; } + public diskType getDiskType() { + return _diskType; + } + public deviceType getDeviceType() { return _deviceType; } @@ -597,6 +601,10 @@ public class LibvirtVMDef { return _bus; } + public diskFmtType getDiskFormatType() { + return _diskFmtType; + } + public int getDiskSeq() { char suffix = _diskLabel.charAt(_diskLabel.length() - 1); return suffix - 'a'; @@ -622,6 +630,10 @@ public class LibvirtVMDef { _diskCacheMode = cacheMode; } + public diskCacheMode getCacheMode() { + return _diskCacheMode; + } + @Override public String toString() { StringBuilder diskBuilder = new StringBuilder(); @@ -652,7 +664,13 @@ public class LibvirtVMDef { diskBuilder.append(" protocol='" + _diskProtocol + "'"); diskBuilder.append(" name='" + _sourcePath + "'"); diskBuilder.append(">\n"); - diskBuilder.append("\n"); + diskBuilder.append("\n"); diskBuilder.append("\n"); if (_authUserName != null) { diskBuilder.append("\n"); @@ -824,6 +842,10 @@ public class LibvirtVMDef { return _macAddr; } + public nicModel getModel() { + return _model; + } + public void setVirtualPortType(String virtualPortType) { _virtualPortType = virtualPortType; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtXMLParser.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtXMLParser.java index c8793f1c2b4..9d347816d86 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtXMLParser.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtXMLParser.java @@ -30,8 +30,7 @@ import org.xml.sax.helpers.DefaultHandler; public class LibvirtXMLParser extends DefaultHandler { private static final Logger s_logger = Logger.getLogger(LibvirtXMLParser.class); - protected static SAXParserFactory s_spf; - + protected static final SAXParserFactory s_spf; static { s_spf = SAXParserFactory.newInstance(); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java index 7726727e993..669bd0bad3f 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java @@ -39,6 +39,10 @@ public class KVMPhysicalDisk { rbdOpts += ":id=" + authUserName; rbdOpts += ":key=" + authSecret; } + + rbdOpts += ":rbd_default_format=2"; + rbdOpts += ":client_mount_timeout=30"; + return rbdOpts; } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java index 9e07e4bea29..583d48af524 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java @@ -302,17 +302,21 @@ public class KVMStoragePoolManager { } public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template, String name, KVMStoragePool destPool, int timeout) { + return createDiskFromTemplate(template, name, destPool, template.getSize(), timeout); + } + + public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template, String name, KVMStoragePool destPool, long size, int timeout) { StorageAdaptor adaptor = getStorageAdaptor(destPool.getType()); // LibvirtStorageAdaptor-specific statement if (destPool.getType() == StoragePoolType.RBD) { - return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.RAW, template.getSize(), destPool, timeout); + return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.RAW, size, destPool, timeout); } else if (destPool.getType() == StoragePoolType.CLVM) { - return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.RAW, template.getSize(), destPool, timeout); + return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.RAW, size, destPool, timeout); } else if (template.getFormat() == PhysicalDiskFormat.DIR) { - return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.DIR, template.getSize(), destPool, timeout); + return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.DIR, size, destPool, timeout); } else { - return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.QCOW2, template.getSize(), destPool, timeout); + return adaptor.createDiskFromTemplate(template, name, PhysicalDiskFormat.QCOW2, size, destPool, timeout); } } diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java index 7d5d3351220..604bdae0511 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java @@ -18,6 +18,7 @@ */ package com.cloud.hypervisor.kvm.storage; +import static com.cloud.utils.S3Utils.mputFile; import static com.cloud.utils.S3Utils.putFile; import java.io.BufferedOutputStream; @@ -37,6 +38,7 @@ import java.util.UUID; import javax.naming.ConfigurationException; +import com.cloud.hypervisor.Hypervisor; import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.libvirt.Connect; @@ -181,13 +183,14 @@ public class KVMStorageProcessor implements StorageProcessor { break; } } - if (tmplVol == null) { - return new PrimaryStorageDownloadAnswer("Failed to get template from pool: " + secondaryPool.getUuid()); - } } else { tmplVol = secondaryPool.getPhysicalDisk(tmpltname); } + if (tmplVol == null) { + return new PrimaryStorageDownloadAnswer("Failed to get template from pool: " + secondaryPool.getUuid()); + } + /* Copy volume to primary storage */ s_logger.debug("Copying template to primary storage, template format is " + tmplVol.getFormat() ); KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid()); @@ -195,6 +198,14 @@ public class KVMStorageProcessor implements StorageProcessor { KVMPhysicalDisk primaryVol = null; if (destData instanceof VolumeObjectTO) { VolumeObjectTO volume = (VolumeObjectTO)destData; + // pass along volume's target size if it's bigger than template's size, for storage types that copy template rather than cloning on deploy + if (volume.getSize() != null && volume.getSize() > tmplVol.getVirtualSize()) { + s_logger.debug("Using configured size of " + volume.getSize()); + tmplVol.setSize(volume.getSize()); + tmplVol.setVirtualSize(volume.getSize()); + } else { + s_logger.debug("Using template's size of " + tmplVol.getVirtualSize()); + } primaryVol = storagePoolMgr.copyPhysicalDisk(tmplVol, volume.getUuid(), primaryPool, cmd.getWaitInMillSeconds()); } else if (destData instanceof TemplateObjectTO) { TemplateObjectTO destTempl = (TemplateObjectTO)destData; @@ -231,14 +242,18 @@ public class KVMStorageProcessor implements StorageProcessor { } catch (CloudRuntimeException e) { return new CopyCmdAnswer(e.toString()); } finally { - if (secondaryPool != null) { - secondaryPool.delete(); + try { + if (secondaryPool != null) { + secondaryPool.delete(); + } + } catch(Exception e) { + s_logger.debug("Failed to clean up secondary storage", e); } } } // this is much like PrimaryStorageDownloadCommand, but keeping it separate. copies template direct to root disk - private KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool, String volUuid, int timeout) { + private KVMPhysicalDisk templateToPrimaryDownload(String templateUrl, KVMStoragePool primaryPool, String volUuid, Long size, int timeout) { int index = templateUrl.lastIndexOf("/"); String mountpoint = templateUrl.substring(0, index); String templateName = null; @@ -274,6 +289,14 @@ public class KVMStorageProcessor implements StorageProcessor { /* Copy volume to primary storage */ + if (size > templateVol.getSize()) { + s_logger.debug("Overriding provided template's size with new size " + size); + templateVol.setSize(size); + templateVol.setVirtualSize(size); + } else { + s_logger.debug("Using templates disk size of " + templateVol.getVirtualSize() + "since size passed was " + size); + } + KVMPhysicalDisk primaryVol = storagePoolMgr.copyPhysicalDisk(templateVol, volUuid, primaryPool, timeout); return primaryVol; } catch (CloudRuntimeException e) { @@ -305,14 +328,14 @@ public class KVMStorageProcessor implements StorageProcessor { if (primaryPool.getType() == StoragePoolType.CLVM) { templatePath = ((NfsTO)imageStore).getUrl() + File.separator + templatePath; - vol = templateToPrimaryDownload(templatePath, primaryPool, volume.getUuid(), cmd.getWaitInMillSeconds()); + vol = templateToPrimaryDownload(templatePath, primaryPool, volume.getUuid(), volume.getSize(), cmd.getWaitInMillSeconds()); } else { if (templatePath.contains("/mnt")) { //upgrade issue, if the path contains path, need to extract the volume uuid from path templatePath = templatePath.substring(templatePath.lastIndexOf(File.separator) + 1); } BaseVol = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), templatePath); - vol = storagePoolMgr.createDiskFromTemplate(BaseVol, volume.getUuid(), BaseVol.getPool(), cmd.getWaitInMillSeconds()); + vol = storagePoolMgr.createDiskFromTemplate(BaseVol, volume.getUuid(), BaseVol.getPool(), volume.getSize(), cmd.getWaitInMillSeconds()); } if (vol == null) { return new CopyCmdAnswer(" Can't create storage volume on storage pool"); @@ -547,18 +570,22 @@ public class KVMStorageProcessor implements StorageProcessor { return null; //To change body of implemented methods use File | Settings | File Templates. } - protected String copyToS3(File srcFile, S3TO destStore, String destPath) { + protected String copyToS3(File srcFile, S3TO destStore, String destPath) throws InterruptedException { final String bucket = destStore.getBucketName(); + long srcSize = srcFile.length(); String key = destPath + S3Utils.SEPARATOR + srcFile.getName(); - putFile(destStore, srcFile, bucket, key); + if (!destStore.getSingleUpload(srcSize)) { + mputFile(destStore, srcFile, bucket, key); + } else { + putFile(destStore, srcFile, bucket, key); + } return key; } protected Answer copyToObjectStore(CopyCommand cmd) { DataTO srcData = cmd.getSrcTO(); DataTO destData = cmd.getDestTO(); - SnapshotObjectTO snapshot = (SnapshotObjectTO)srcData; DataStoreTO imageStore = destData.getDataStore(); NfsTO srcStore = (NfsTO)srcData.getDataStore(); String srcPath = srcData.getPath(); @@ -585,6 +612,9 @@ public class KVMStorageProcessor implements StorageProcessor { SnapshotObjectTO newSnapshot = new SnapshotObjectTO(); newSnapshot.setPath(destPath); return new CopyCmdAnswer(newSnapshot); + } catch (Exception e) { + s_logger.error("failed to upload" + srcPath, e); + return new CopyCmdAnswer("failed to upload" + srcPath + e.toString()); } finally { try { if (srcFile != null) { @@ -600,9 +630,7 @@ public class KVMStorageProcessor implements StorageProcessor { } protected Answer backupSnapshotForObjectStore(CopyCommand cmd) { - DataTO srcData = cmd.getSrcTO(); DataTO destData = cmd.getDestTO(); - SnapshotObjectTO snapshot = (SnapshotObjectTO)srcData; DataStoreTO imageStore = destData.getDataStore(); DataTO cacheData = cmd.getCacheTO(); if (cacheData == null) { @@ -675,6 +703,7 @@ public class KVMStorageProcessor implements StorageProcessor { Rados r = new Rados(primaryPool.getAuthUserName()); r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); r.confSet("key", primaryPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); @@ -682,8 +711,6 @@ public class KVMStorageProcessor implements StorageProcessor { Rbd rbd = new Rbd(io); RbdImage image = rbd.open(snapshotDisk.getName(), snapshotName); - long startTime = System.currentTimeMillis() / 1000; - File snapDir = new File(snapshotDestPath); s_logger.debug("Attempting to create " + snapDir.getAbsolutePath() + " recursively"); FileUtils.forceMkdir(snapDir); @@ -789,8 +816,13 @@ public class KVMStorageProcessor implements StorageProcessor { } catch (Exception ex) { s_logger.debug("Failed to delete snapshots on primary", ex); } - if (secondaryStoragePool != null) { - secondaryStoragePool.delete(); + + try { + if (secondaryStoragePool != null) { + secondaryStoragePool.delete(); + } + } catch (Exception ex) { + s_logger.debug("Failed to delete secondary storage", ex); } } } @@ -933,8 +965,29 @@ public class KVMStorageProcessor implements StorageProcessor { } else { diskdef = new DiskDef(); if (attachingPool.getType() == StoragePoolType.RBD) { - diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), attachingPool.getAuthUserName(), - attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD); + if(resource.getHypervisorType() == Hypervisor.HypervisorType.LXC){ + // For LXC, map image to host and then attach to Vm + String mapRbd = Script.runSimpleBashScript("rbd map " + attachingDisk.getPath() + " --id "+attachingPool.getAuthUserName()); + //Split pool and image details from disk path + String[] splitPoolImage = attachingDisk.getPath().split("/"); + //ToDo: rbd showmapped supports json and xml output. Use json/xml to get device + String device = Script.runSimpleBashScript("rbd showmapped | grep \""+splitPoolImage[0]+" "+splitPoolImage[1]+"\" | cut -d \" \" -f10"); + if (device != null) { + s_logger.debug("RBD device on host is: "+device); + diskdef.defBlockBasedDisk(device, devId, DiskDef.diskBus.VIRTIO); + } else { + throw new InternalErrorException("Error while mapping disk "+attachingDisk.getPath()+" on host"); + } + } else { + diskdef.defNetworkBasedDisk(attachingDisk.getPath(), attachingPool.getSourceHost(), attachingPool.getSourcePort(), attachingPool.getAuthUserName(), + attachingPool.getUuid(), devId, DiskDef.diskBus.VIRTIO, diskProtocol.RBD, DiskDef.diskFmtType.RAW); + } + } else if (attachingPool.getType() == StoragePoolType.Gluster) { + String mountpoint = attachingPool.getLocalPath(); + String path = attachingDisk.getPath(); + String glusterVolume = attachingPool.getSourceDir().replace("/", ""); + diskdef.defNetworkBasedDisk(glusterVolume + path.replace(mountpoint, ""), attachingPool.getSourceHost(), attachingPool.getSourcePort(), null, + null, devId, DiskDef.diskBus.VIRTIO, diskProtocol.GLUSTER, DiskDef.diskFmtType.QCOW2); } else if (attachingDisk.getFormat() == PhysicalDiskFormat.QCOW2) { diskdef.defFileBasedDisk(attachingDisk.getPath(), devId, DiskDef.diskBus.VIRTIO, DiskDef.diskFmtType.QCOW2); } else if (attachingDisk.getFormat() == PhysicalDiskFormat.RAW) { @@ -969,6 +1022,7 @@ public class KVMStorageProcessor implements StorageProcessor { return new AttachAnswer(disk); } catch (LibvirtException e) { s_logger.debug("Failed to attach volume: " + vol.getPath() + ", due to " + e.toString()); + storagePoolMgr.disconnectPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), vol.getPath()); return new AttachAnswer(e.toString()); } catch (InternalErrorException e) { s_logger.debug("Failed to attach volume: " + vol.getPath() + ", due to " + e.toString()); @@ -1095,6 +1149,7 @@ public class KVMStorageProcessor implements StorageProcessor { Rados r = new Rados(primaryPool.getAuthUserName()); r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); r.confSet("key", primaryPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); 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 bbd1c24ac99..61d90e9b15d 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 @@ -16,10 +16,7 @@ // under the License. package com.cloud.hypervisor.kvm.storage; -import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -129,9 +126,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } } - private StoragePool createNfsStoragePool(Connect conn, String uuid, String host, String path) throws LibvirtException { + private StoragePool createNetfsStoragePool(poolType fsType, Connect conn, String uuid, String host, String path) throws LibvirtException { String targetPath = _mountPoint + File.separator + uuid; - LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(poolType.NETFS, uuid, uuid, host, path, targetPath); + LibvirtStoragePoolDef spd = new LibvirtStoragePoolDef(fsType, uuid, uuid, host, path, targetPath); _storageLayer.mkdir(targetPath); StoragePool sp = null; try { @@ -170,7 +167,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } sp.free(); } catch (LibvirtException l) { - s_logger.debug("Failed to undefine nfs storage pool with: " + l.toString()); + s_logger.debug("Failed to undefine " + fsType.toString() + " storage pool with: " + l.toString()); } } return null; @@ -244,13 +241,12 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { LibvirtStoragePoolDef spd; StoragePool sp = null; + Secret s = null; String[] userInfoTemp = userInfo.split(":"); if (userInfoTemp.length == 2) { LibvirtSecretDef sd = new LibvirtSecretDef(usage.CEPH, uuid); - Secret s = null; - sd.setCephName(userInfoTemp[0] + "@" + host + ":" + port + "/" + path); try { @@ -258,15 +254,16 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { s = conn.secretDefineXML(sd.toString()); s.setValue(Base64.decodeBase64(userInfoTemp[1])); } catch (LibvirtException e) { - s_logger.error(e.toString()); + s_logger.error("Failed to define the libvirt secret: " + e.toString()); if (s != null) { try { s.undefine(); s.free(); } catch (LibvirtException l) { - s_logger.debug("Failed to define secret with: " + l.toString()); + s_logger.debug("Failed to undefine the libvirt secret: " + l.toString()); } } + return null; } spd = new LibvirtStoragePoolDef(poolType.RBD, uuid, uuid, host, port, path, userInfoTemp[0], authType.CEPH, uuid); } else { @@ -278,7 +275,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { sp = conn.storagePoolCreateXML(spd.toString(), 0); return sp; } catch (LibvirtException e) { - s_logger.debug(e.toString()); + s_logger.debug("Failed to create RBD storage pool: " + e.toString()); if (sp != null) { try { if (sp.isPersistent() == 1) { @@ -289,9 +286,20 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } sp.free(); } catch (LibvirtException l) { - s_logger.debug("Failed to define RBD storage pool with: " + l.toString()); + s_logger.debug("Failed to undefine RBD storage pool: " + l.toString()); } } + + if (s != null) { + try { + s_logger.debug("Failed to create the RBD storage pool, cleaning up the libvirt secret"); + s.undefine(); + s.free(); + } catch (LibvirtException se) { + s_logger.debug("Failed to remove the libvirt secret: " + se.toString()); + } + } + return null; } } @@ -310,11 +318,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { throw new InternalErrorException("volume:" + srcPath + " is not exits"); } String result = Script.runSimpleBashScript("cp " + srcPath + " " + destPath + File.separator + volumeName, timeout); - if (result != null) { - return false; - } else { - return true; - } + return result == null; } public LibvirtStoragePoolDef getStoragePoolDef(Connect conn, StoragePool pool) throws LibvirtException { @@ -349,14 +353,19 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { type = StoragePoolType.RBD; } else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.LOGICAL) { type = StoragePoolType.CLVM; + } else if (spd.getPoolType() == LibvirtStoragePoolDef.poolType.GLUSTERFS) { + type = StoragePoolType.Gluster; } LibvirtStoragePool pool = new LibvirtStoragePool(uuid, storage.getName(), type, this, storage); - if (pool.getType() != StoragePoolType.RBD) { + if (pool.getType() != StoragePoolType.RBD) pool.setLocalPath(spd.getTargetPath()); - } else { + else pool.setLocalPath(""); + + if (pool.getType() == StoragePoolType.RBD + || pool.getType() == StoragePoolType.Gluster) { pool.setSourceHost(spd.getSourceHost()); pool.setSourcePort(spd.getSourcePort()); pool.setSourceDir(spd.getSourceDir()); @@ -488,9 +497,17 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { if (type == StoragePoolType.NetworkFilesystem) { try { - sp = createNfsStoragePool(conn, name, host, path); + sp = createNetfsStoragePool(poolType.NETFS, conn, name, host, path); } catch (LibvirtException e) { - s_logger.error("Failed to create mount"); + s_logger.error("Failed to create netfs mount: " + host + ":" + path , e); + s_logger.error(e.getStackTrace()); + throw new CloudRuntimeException(e.toString()); + } + } else if (type == StoragePoolType.Gluster) { + try { + sp = createNetfsStoragePool(poolType.GLUSTERFS, conn, name, host, path); + } catch (LibvirtException e) { + s_logger.error("Failed to create glusterfs mount: " + host + ":" + path , e); s_logger.error(e.getStackTrace()); throw new CloudRuntimeException(e.toString()); } @@ -503,6 +520,10 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } } + if (sp == null) { + throw new CloudRuntimeException("Failed to create storage pool: " + name); + } + try { if (sp.isActive() == 0) { s_logger.debug("attempting to activate pool " + name); @@ -588,7 +609,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } s_logger.error("failed in umount retry"); } - throw new CloudRuntimeException(e.toString()); + throw new CloudRuntimeException(e.toString(), e); } } @@ -619,6 +640,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { Rados r = new Rados(pool.getAuthUserName()); r.confSet("mon_host", pool.getSourceHost() + ":" + pool.getSourcePort()); r.confSet("key", pool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); @@ -725,20 +747,24 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { */ if (pool.getType() == StoragePoolType.RBD) { try { - s_logger.info("Unprotecting and Removing RBD snapshots of image " + pool.getSourcePort() + "/" + uuid + " prior to removing the image"); + s_logger.info("Unprotecting and Removing RBD snapshots of image " + pool.getSourceDir() + "/" + uuid + " prior to removing the image"); Rados r = new Rados(pool.getAuthUserName()); r.confSet("mon_host", pool.getSourceHost() + ":" + pool.getSourcePort()); r.confSet("key", pool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); IoCTX io = r.ioCtxCreate(pool.getSourceDir()); Rbd rbd = new Rbd(io); RbdImage image = rbd.open(uuid); + s_logger.debug("Fetching list of snapshots of RBD image " + pool.getSourceDir() + "/" + uuid); List snaps = image.snapList(); for (RbdSnapInfo snap : snaps) { + s_logger.debug("Unprotecting snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name); image.snapUnprotect(snap.name); + s_logger.debug("Removing snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name); image.snapRemove(snap.name); } @@ -797,11 +823,21 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } else if (format == PhysicalDiskFormat.QCOW2) { QemuImgFile backingFile = new QemuImgFile(template.getPath(), template.getFormat()); QemuImgFile destFile = new QemuImgFile(disk.getPath()); + if (size > template.getVirtualSize()) { + destFile.setSize(size); + } else { + destFile.setSize(template.getVirtualSize()); + } QemuImg qemu = new QemuImg(timeout); qemu.create(destFile, backingFile); } else if (format == PhysicalDiskFormat.RAW) { QemuImgFile sourceFile = new QemuImgFile(template.getPath(), template.getFormat()); QemuImgFile destFile = new QemuImgFile(disk.getPath(), PhysicalDiskFormat.RAW); + if (size > template.getVirtualSize()) { + destFile.setSize(size); + } else { + destFile.setSize(template.getVirtualSize()); + } QemuImg qemu = new QemuImg(timeout); qemu.convert(sourceFile, destFile); } @@ -809,8 +845,14 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { format = PhysicalDiskFormat.RAW; disk = new KVMPhysicalDisk(destPool.getSourceDir() + "/" + newUuid, newUuid, destPool); disk.setFormat(format); - disk.setSize(template.getVirtualSize()); - disk.setVirtualSize(disk.getSize()); + if (size > template.getVirtualSize()) { + disk.setSize(size); + disk.setVirtualSize(size); + } else { + // leave these as they were if size isn't applicable + disk.setSize(template.getVirtualSize()); + disk.setVirtualSize(disk.getSize()); + } QemuImg qemu = new QemuImg(timeout); QemuImgFile srcFile; @@ -818,6 +860,11 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { new QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(), destPool.getSourcePort(), destPool.getAuthUserName(), destPool.getAuthSecret(), disk.getPath())); destFile.setFormat(format); + if (size > template.getVirtualSize()) { + destFile.setSize(size); + } else { + destFile.setSize(template.getVirtualSize()); + } if (srcPool.getType() != StoragePoolType.RBD) { srcFile = new QemuImgFile(template.getPath(), template.getFormat()); @@ -840,6 +887,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { Rados r = new Rados(srcPool.getAuthUserName()); r.confSet("mon_host", srcPool.getSourceHost() + ":" + srcPool.getSourcePort()); r.confSet("key", srcPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); @@ -850,9 +898,9 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { if (srcImage.isOldFormat()) { /* The source image is RBD format 1, we have to do a regular copy */ s_logger.debug("The source image " + srcPool.getSourceDir() + "/" + template.getName() + - " is RBD format 1. We have to perform a regular copy (" + template.getVirtualSize() + " bytes)"); + " is RBD format 1. We have to perform a regular copy (" + disk.getVirtualSize() + " bytes)"); - rbd.create(disk.getName(), template.getVirtualSize(), rbdFeatures, rbdOrder); + rbd.create(disk.getName(), disk.getVirtualSize(), rbdFeatures, rbdOrder); RbdImage destImage = rbd.open(disk.getName()); s_logger.debug("Starting to copy " + srcImage.getName() + " to " + destImage.getName() + " in Ceph pool " + srcPool.getSourceDir()); @@ -877,12 +925,14 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { Rados rSrc = new Rados(srcPool.getAuthUserName()); rSrc.confSet("mon_host", srcPool.getSourceHost() + ":" + srcPool.getSourcePort()); rSrc.confSet("key", srcPool.getAuthSecret()); + rSrc.confSet("client_mount_timeout", "30"); rSrc.connect(); s_logger.debug("Succesfully connected to source Ceph cluster at " + rSrc.confGet("mon_host")); Rados rDest = new Rados(destPool.getAuthUserName()); rDest.confSet("mon_host", destPool.getSourceHost() + ":" + destPool.getSourcePort()); rDest.confSet("key", destPool.getAuthSecret()); + rDest.confSet("client_mount_timeout", "30"); rDest.connect(); s_logger.debug("Succesfully connected to source Ceph cluster at " + rDest.confGet("mon_host")); @@ -894,7 +944,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { s_logger.debug("Creating " + disk.getName() + " on the destination cluster " + rDest.confGet("mon_host") + " in pool " + destPool.getSourceDir()); - dRbd.create(disk.getName(), template.getVirtualSize(), rbdFeatures, rbdOrder); + dRbd.create(disk.getName(), disk.getVirtualSize(), rbdFeatures, rbdOrder); RbdImage srcImage = sRbd.open(template.getName()); RbdImage destImage = dRbd.open(disk.getName()); @@ -1046,57 +1096,31 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { boolean useTmpFile = false; try { - if (sourceFormat != destFormat) { - srcFile = new QemuImgFile(sourcePath, sourceFormat); - destFile = new QemuImgFile("/tmp/" + name); - s_logger.debug("Converting " + srcFile.getFileName() + " to " + destFile.getFileName() + " as a temporary file for RBD conversion"); - qemu.convert(srcFile, destFile); - sourceFile = destFile.getFileName(); - useTmpFile = true; - } else { - // Source file is RAW, we can write directly to RBD - sourceFile = sourcePath; - } + srcFile = new QemuImgFile(sourcePath, sourceFormat); + String rbdDestFile = KVMPhysicalDisk.RBDStringBuilder(destPool.getSourceHost(), + destPool.getSourcePort(), + destPool.getAuthUserName(), + destPool.getAuthSecret(), + destPool.getSourceDir() + "/" + name); + destFile = new QemuImgFile(rbdDestFile, destFormat); - // We now convert the temporary file to a RBD image with format 2 + s_logger.debug("Starting copy from source image " + srcFile.getFileName() + " to RBD image " + destPool.getSourceDir() + "/" + name); + qemu.convert(srcFile, destFile); + s_logger.debug("Succesfully converted source image " + srcFile.getFileName() + " to RBD image " + destPool.getSourceDir() + "/" + name); + + /* We still have to create and protect a RBD snapshot in order to do cloning */ Rados r = new Rados(destPool.getAuthUserName()); r.confSet("mon_host", destPool.getSourceHost() + ":" + destPool.getSourcePort()); r.confSet("key", destPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); r.connect(); s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); IoCTX io = r.ioCtxCreate(destPool.getSourceDir()); Rbd rbd = new Rbd(io); - s_logger.debug("Creating RBD image " + name + " in Ceph pool " + destPool.getSourceDir() + " with RBD format 2"); - rbd.create(name, disk.getVirtualSize(), rbdFeatures, rbdOrder); - RbdImage image = rbd.open(name); - File fh = new File(sourceFile); - BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fh)); - - int chunkSize = 4194304; - long offset = 0; - s_logger.debug("Reading file " + sourceFile + " (" + fh.length() + " bytes) into RBD image " + name + " in chunks of " + chunkSize + " bytes"); - while (true) { - byte[] buf = new byte[chunkSize]; - - int bytes = bis.read(buf); - if (bytes <= 0) { - break; - } - image.write(buf, offset, bytes); - offset += bytes; - } - s_logger.debug("Completed writing " + sourceFile + " to RBD image " + name + ". Bytes written: " + offset); - bis.close(); - - if (useTmpFile) { - s_logger.debug("Removing temporary file " + sourceFile); - fh.delete(); - } - /* Snapshot the image and protect that snapshot so we can clone (layer) from it */ s_logger.debug("Creating RBD snapshot " + rbdTemplateSnapName + " on image " + name); image.snapCreate(rbdTemplateSnapName); @@ -1106,7 +1130,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { rbd.close(image); r.ioCtxDestroy(io); } catch (QemuImgException e) { - s_logger.error("Failed to do a temp convert from " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + e.getMessage()); + s_logger.error("Failed to convert from " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + e.getMessage()); newDisk = null; } catch (RadosException e) { s_logger.error("A Ceph RADOS operation failed (" + e.getReturnValue() + "). The error was: " + e.getMessage()); @@ -1114,11 +1138,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } catch (RbdException e) { s_logger.error("A Ceph RBD operation failed (" + e.getReturnValue() + "). The error was: " + e.getMessage()); newDisk = null; - } catch (IOException e) { - s_logger.error("Failed reading the temporary file during the conversion to RBD: " + e.getMessage()); - newDisk = null; } - } else { /** We let Qemu-Img do the work here. Although we could work with librbd and have that do the cloning diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java index 550bd0148a3..936ccf771ba 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStoragePool.java @@ -178,11 +178,10 @@ public class LibvirtStoragePool implements KVMStoragePool { @Override public boolean isExternalSnapshot() { - if (this.type == StoragePoolType.Filesystem) { - return false; + if (this.type == StoragePoolType.CLVM || type == StoragePoolType.RBD) { + return true; } - - return true; + return false; } @Override @@ -250,7 +249,12 @@ public class LibvirtStoragePool implements KVMStoragePool { @Override public boolean delete() { - return this._storageAdaptor.deleteStoragePool(this); + try { + return this._storageAdaptor.deleteStoragePool(this); + } catch (Exception e) { + s_logger.debug("Failed to delete storage pool", e); + } + return false; } @Override diff --git a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java index a948ca1899f..4bec37535e2 100644 --- a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java +++ b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImg.java @@ -90,11 +90,11 @@ public class QemuImg { if (options != null && !options.isEmpty()) { s.add("-o"); - String optionsStr = ""; + final StringBuilder optionsStr = new StringBuilder(); for (Map.Entry option : options.entrySet()) { - optionsStr += option.getKey() + "=" + option.getValue() + ","; + optionsStr.append(option.getKey()).append('=').append(option.getValue()).append(','); } - s.add(optionsStr); + s.add(optionsStr.toString()); } /* @@ -111,10 +111,12 @@ public class QemuImg { } s.add(file.getFileName()); - - if (backingFile == null) { + if (file.getSize() != 0L) { s.add(Long.toString(file.getSize())); + } else if (backingFile == null) { + throw new QemuImgException("No size was passed, and no backing file was passed"); } + String result = s.execute(); if (result != null) { throw new QemuImgException(result); @@ -206,6 +208,10 @@ public class QemuImg { if (result != null) { throw new QemuImgException(result); } + + if (srcFile.getSize() < destFile.getSize()) { + this.resize(destFile, destFile.getSize()); + } } /** diff --git a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImgFile.java b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImgFile.java index 90d925dd085..034c31bde5f 100644 --- a/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImgFile.java +++ b/plugins/hypervisors/kvm/src/org/apache/cloudstack/utils/qemu/QemuImgFile.java @@ -41,7 +41,6 @@ public class QemuImgFile { public QemuImgFile(String fileName, PhysicalDiskFormat format) { this.fileName = fileName; - this.size = size; this.format = format; } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java index c8af7f8b82b..bf4546c63d1 100644 --- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java @@ -447,4 +447,11 @@ public class LibvirtComputingResourceTest { Assert.assertTrue(vmStat.getDiskReadKBs() > 0); Assert.assertTrue(vmStat.getDiskWriteKBs() > 0); } + + @Test + public void getCpuSpeed() { + Assume.assumeTrue(SystemUtils.IS_OS_LINUX); + NodeInfo nodeInfo = Mockito.mock(NodeInfo.class); + LibvirtComputingResource.getCpuSpeed(nodeInfo); + } } diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParserTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParserTest.java new file mode 100644 index 00000000000..c24a8d3abdd --- /dev/null +++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtDomainXMLParserTest.java @@ -0,0 +1,194 @@ +/* + * 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.kvm.resource; + +import junit.framework.TestCase; +import java.util.List; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.DiskDef; +import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef; + +public class LibvirtDomainXMLParserTest extends TestCase { + + public void testDomainXMLParser() { + int vncPort = 5900; + + DiskDef.diskBus diskBus = DiskDef.diskBus.VIRTIO; + DiskDef.diskType diskType = DiskDef.diskType.FILE; + DiskDef.deviceType deviceType = DiskDef.deviceType.DISK; + DiskDef.diskFmtType diskFormat = DiskDef.diskFmtType.QCOW2; + DiskDef.diskCacheMode diskCache = DiskDef.diskCacheMode.NONE; + + InterfaceDef.nicModel ifModel = InterfaceDef.nicModel.VIRTIO; + InterfaceDef.guestNetType ifType = InterfaceDef.guestNetType.BRIDGE; + + String diskLabel ="vda"; + String diskPath = "/var/lib/libvirt/images/my-test-image.qcow2"; + + String xml = "" + + "s-2970-VM" + + "4d2c1526-865d-4fc9-a1ac-dbd1801a22d0" + + "Debian GNU/Linux 6(64-bit)" + + "262144" + + "262144" + + "1" + + "" + + "250" + + "" + + "" + + "/machine" + + "" + + "" + + "hvm" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "destroy" + + "restart" + + "destroy" + + "" + + "/usr/bin/kvm-spice" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "