diff --git a/agent/pom.xml b/agent/pom.xml
index dbd3a3c6a470..ee1924a2b68c 100644
--- a/agent/pom.xml
+++ b/agent/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
diff --git a/api/pom.xml b/api/pom.xml
index 01b7b6698c61..6c0907065e1c 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
diff --git a/api/src/main/java/com/cloud/event/EventTypes.java b/api/src/main/java/com/cloud/event/EventTypes.java
index a30518aaf176..59c4d689af1c 100644
--- a/api/src/main/java/com/cloud/event/EventTypes.java
+++ b/api/src/main/java/com/cloud/event/EventTypes.java
@@ -19,6 +19,13 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.cloudstack.acl.Role;
+import org.apache.cloudstack.acl.RolePermission;
+import org.apache.cloudstack.annotation.Annotation;
+import org.apache.cloudstack.config.Configuration;
+import org.apache.cloudstack.ha.HAConfig;
+import org.apache.cloudstack.usage.Usage;
+
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
import com.cloud.dc.StorageNetworkIpRange;
@@ -69,12 +76,6 @@
import com.cloud.vm.Nic;
import com.cloud.vm.NicSecondaryIp;
import com.cloud.vm.VirtualMachine;
-import org.apache.cloudstack.acl.Role;
-import org.apache.cloudstack.acl.RolePermission;
-import org.apache.cloudstack.annotation.Annotation;
-import org.apache.cloudstack.config.Configuration;
-import org.apache.cloudstack.ha.HAConfig;
-import org.apache.cloudstack.usage.Usage;
public class EventTypes {
@@ -96,6 +97,7 @@ public class EventTypes {
public static final String EVENT_VM_MOVE = "VM.MOVE";
public static final String EVENT_VM_RESTORE = "VM.RESTORE";
public static final String EVENT_VM_EXPUNGE = "VM.EXPUNGE";
+ public static final String EVENT_VM_IMPORT = "VM.IMPORT";
// Domain Router
public static final String EVENT_ROUTER_CREATE = "ROUTER.CREATE";
@@ -594,6 +596,7 @@ public class EventTypes {
entityEventDetails.put(EVENT_VM_MOVE, VirtualMachine.class);
entityEventDetails.put(EVENT_VM_RESTORE, VirtualMachine.class);
entityEventDetails.put(EVENT_VM_EXPUNGE, VirtualMachine.class);
+ entityEventDetails.put(EVENT_VM_IMPORT, VirtualMachine.class);
entityEventDetails.put(EVENT_ROUTER_CREATE, VirtualRouter.class);
entityEventDetails.put(EVENT_ROUTER_DESTROY, VirtualRouter.class);
diff --git a/api/src/main/java/com/cloud/vm/UserVmService.java b/api/src/main/java/com/cloud/vm/UserVmService.java
index 99eb827c1227..8349e00d7054 100644
--- a/api/src/main/java/com/cloud/vm/UserVmService.java
+++ b/api/src/main/java/com/cloud/vm/UserVmService.java
@@ -513,4 +513,8 @@ UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException
void collectVmNetworkStatistics (UserVm userVm);
+ UserVm importVM(final DataCenter zone, final Host host, final VirtualMachineTemplate template, final String instanceName, final String displayName, final Account owner, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
+ final long accountId, final long userId, final ServiceOffering serviceOffering, final DiskOffering rootDiskOffering, final String sshPublicKey,
+ final String hostName, final HypervisorType hypervisorType, final Map customParameters, final VirtualMachine.PowerState powerState) throws InsufficientCapacityException;
+
}
diff --git a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
index fb44a8a11f48..c34734c04cd7 100644
--- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
@@ -43,6 +43,7 @@ public class ApiConstants {
public static final String BYTES_WRITE_RATE_MAX = "byteswriteratemax";
public static final String BYTES_WRITE_RATE_MAX_LENGTH = "byteswriteratemaxlength";
public static final String BYPASS_VLAN_OVERLAP_CHECK = "bypassvlanoverlapcheck";
+ public static final String CAPACITY = "capacity";
public static final String CATEGORY = "category";
public static final String CAN_REVERT = "canrevert";
public static final String CA_CERTIFICATES = "cacertificates";
@@ -50,6 +51,8 @@ public class ApiConstants {
public static final String CERTIFICATE_CHAIN = "certchain";
public static final String CERTIFICATE_FINGERPRINT = "fingerprint";
public static final String CERTIFICATE_ID = "certid";
+ public static final String CONTROLLER = "controller";
+ public static final String CONTROLLER_UNIT = "controllerunit";
public static final String COPY_IMAGE_TAGS = "copyimagetags";
public static final String CSR = "csr";
public static final String PRIVATE_KEY = "privatekey";
@@ -69,6 +72,7 @@ public class ApiConstants {
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_CORE_PER_SOCKET = "cpucorepersocket";
public static final String CPU_NUMBER = "cpunumber";
public static final String CPU_SPEED = "cpuspeed";
public static final String CREATED = "created";
@@ -90,6 +94,7 @@ public class ApiConstants {
public static final String DETAILS = "details";
public static final String DEVICE_ID = "deviceid";
public static final String DIRECT_DOWNLOAD = "directdownload";
+ public static final String DISK = "disk";
public static final String DISK_OFFERING_ID = "diskofferingid";
public static final String NEW_DISK_OFFERING_ID = "newdiskofferingid";
public static final String DISK_KBS_READ = "diskkbsread";
@@ -169,6 +174,7 @@ public class ApiConstants {
public static final String PREVIOUS_ACL_RULE_ID = "previousaclruleid";
public static final String NEXT_ACL_RULE_ID = "nextaclruleid";
public static final String MOVE_ACL_CONSISTENCY_HASH = "aclconsistencyhash";
+ public static final String IMAGE_PATH = "imagepath";
public static final String INTERNAL_DNS1 = "internaldns1";
public static final String INTERNAL_DNS2 = "internaldns2";
public static final String INTERVAL_TYPE = "intervaltype";
@@ -222,6 +228,9 @@ public class ApiConstants {
public static final String NETWORK_DOMAIN = "networkdomain";
public static final String NETMASK = "netmask";
public static final String NEW_NAME = "newname";
+ public static final String NIC = "nic";
+ public static final String NIC_NETWORK_LIST = "nicnetworklist";
+ public static final String NIC_IP_ADDRESS_LIST = "nicipaddresslist";
public static final String NUM_RETRIES = "numretries";
public static final String OFFER_HA = "offerha";
public static final String IS_SYSTEM_OFFERING = "issystem";
@@ -253,6 +262,7 @@ public class ApiConstants {
public static final String PORTAL = "portal";
public static final String PORTABLE_IP_ADDRESS = "portableipaddress";
public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid";
+ public static final String POSITION = "position";
public static final String POST_URL = "postURL";
public static final String POWER_STATE = "powerstate";
public static final String PRIVATE_INTERFACE = "privateinterface";
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/ingestion/ImportUnmanageInstanceCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/ingestion/ImportUnmanageInstanceCmd.java
new file mode 100644
index 000000000000..07615a653a3b
--- /dev/null
+++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/ingestion/ImportUnmanageInstanceCmd.java
@@ -0,0 +1,328 @@
+// 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.ingestion;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.ACL;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.DiskOfferingResponse;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.response.ServiceOfferingResponse;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.vm.VmImportService;
+import org.apache.log4j.Logger;
+
+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.Network;
+import com.cloud.offering.DiskOffering;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.org.Cluster;
+import com.cloud.user.Account;
+import com.cloud.utils.net.NetUtils;
+import com.google.common.base.Strings;
+
+@APICommand(name = ImportUnmanageInstanceCmd.API_NAME,
+ description = "Import unmanaged virtual machine from a given cluster.",
+ responseObject = UserVmResponse.class,
+ responseView = ResponseObject.ResponseView.Full,
+ requestHasSensitiveInfo = false,
+ responseHasSensitiveInfo = true,
+ authorized = {RoleType.Admin})
+public class ImportUnmanageInstanceCmd extends BaseAsyncCmd {
+ public static final Logger s_logger = Logger.getLogger(ImportUnmanageInstanceCmd.class);
+ public static final String API_NAME = "importUnmanagedInstance";
+
+ @Inject
+ public VmImportService vmImportService;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.CLUSTER_ID,
+ type = CommandType.UUID,
+ entityType = ClusterResponse.class,
+ required = true,
+ description = "the cluster ID")
+ private Long clusterId;
+
+ @Parameter(name = ApiConstants.NAME,
+ type = CommandType.STRING,
+ required = true,
+ description = "the hypervisor name of the instance")
+ private String name;
+
+ @Parameter(name = ApiConstants.DISPLAY_NAME,
+ type = CommandType.STRING,
+ description = "the display name of the instance")
+ private String displayName;
+
+ @Parameter(name = ApiConstants.HOST_NAME,
+ type = CommandType.STRING,
+ description = "the host name of the instance")
+ private String hostName;
+
+ @Parameter(name = ApiConstants.ACCOUNT,
+ type = CommandType.STRING,
+ description = "an optional account for the virtual machine. Must be used with domainId.")
+ private String accountName;
+
+ @Parameter(name = ApiConstants.DOMAIN_ID,
+ type = CommandType.UUID,
+ entityType = DomainResponse.class,
+ description = "import instance to the domain specified")
+ private Long domainId;
+
+ @Parameter(name = ApiConstants.PROJECT_ID,
+ type = CommandType.UUID,
+ entityType = ProjectResponse.class,
+ description = "import instance for the project")
+ private Long projectId;
+
+ @ACL
+ @Parameter(name = ApiConstants.TEMPLATE_ID,
+ type = CommandType.UUID,
+ entityType = TemplateResponse.class,
+ required = true,
+ description = "the ID of the template for the virtual machine")
+ private Long templateId;
+
+ @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")
+ private Long serviceOfferingId;
+
+ @ACL
+ @Parameter(name = ApiConstants.DISK_OFFERING_ID,
+ type = CommandType.UUID,
+ entityType = DiskOfferingResponse.class,
+ required = true,
+ description = "the ID of the root disk offering for the virtual machine")
+ private Long diskOfferingId;
+
+ @Parameter(name = ApiConstants.NIC_NETWORK_LIST,
+ type = CommandType.MAP,
+ description = "VM nic to network id mapping")
+ private Map nicNetworkList;
+
+ @Parameter(name = ApiConstants.NIC_IP_ADDRESS_LIST,
+ type = CommandType.MAP,
+ description = "VM nic to ip address mapping")
+ private Map nicIpAddressList;
+
+ @Parameter(name = ApiConstants.DATADISK_OFFERING_LIST,
+ type = CommandType.MAP,
+ description = "datadisk template to disk-offering mapping")
+ private Map dataDiskToDiskOfferingList;
+
+ @Parameter(name = ApiConstants.DETAILS,
+ type = CommandType.MAP,
+ description = "used to specify the custom parameters.")
+ private Map details;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public String getAccountName() {
+ return accountName;
+ }
+
+ public Long getDomainId() {
+ return domainId;
+ }
+
+ public Long getTemplateId() {
+ return templateId;
+ }
+
+ public Long getProjectId() {
+ return projectId;
+ }
+
+ public Long getServiceOfferingId() {
+ return serviceOfferingId;
+ }
+
+ public Long getDiskOfferingId() {
+ return diskOfferingId;
+ }
+
+ public Map getNicNetworkList() {
+ Map nicNetworkMap = new HashMap<>();
+ if (nicNetworkList != null && !nicNetworkList.isEmpty()) {
+ Collection parameterCollection = nicNetworkList.values();
+ Iterator iter = parameterCollection.iterator();
+ while (iter.hasNext()) {
+ HashMap value = (HashMap)iter.next();
+ String nic = value.get("nic");
+ String networkUuid = value.get("network");
+ if (_entityMgr.findByUuid(Network.class, networkUuid) != null) {
+ nicNetworkMap.put(nic, _entityMgr.findByUuid(Network.class, networkUuid).getId());
+ } else {
+ throw new InvalidParameterValueException(String.format("Unable to find network ID: %s for NIC ID: %s", networkUuid, nic));
+ }
+ }
+ }
+ return nicNetworkMap;
+ }
+
+ public Map getNicIpAddressList() {
+ Map nicIpAddressMap = new HashMap<>();
+ if (nicIpAddressList != null && !nicIpAddressList.isEmpty()) {
+ Collection parameterCollection = nicIpAddressList.values();
+ Iterator iter = parameterCollection.iterator();
+ while (iter.hasNext()) {
+ HashMap value = (HashMap)iter.next();
+ String nic = value.get("nic");
+ String ipAddress = value.get("ipAddress");
+ if (!Strings.isNullOrEmpty(ipAddress) && NetUtils.isValidIp4(ipAddress)) {
+ nicIpAddressMap.put(nic, ipAddress);
+ } else {
+ throw new InvalidParameterValueException(String.format("IP Address: %s for NIC ID: %s is invalid", ipAddress, nic));
+ }
+ }
+ }
+ return nicIpAddressMap;
+ }
+
+ public Map getDataDiskToDiskOfferingList() {
+ Map dataDiskToDiskOfferingMap = new HashMap<>();
+ if (dataDiskToDiskOfferingList != null && !dataDiskToDiskOfferingList.isEmpty()) {
+ Collection parameterCollection = dataDiskToDiskOfferingList.values();
+ Iterator iter = parameterCollection.iterator();
+ while (iter.hasNext()) {
+ HashMap value = (HashMap)iter.next();
+ String disk = value.get("disk");
+ String offeringUuid = value.get("diskOffering");
+ if (_entityMgr.findByUuid(DiskOffering.class, offeringUuid) != null) {
+ dataDiskToDiskOfferingMap.put(disk, _entityMgr.findByUuid(DiskOffering.class, offeringUuid).getId());
+ } else {
+ throw new InvalidParameterValueException(String.format("Unable to find disk offering ID: %s for data disk ID: %s", offeringUuid, disk));
+ }
+ }
+ }
+ return dataDiskToDiskOfferingMap;
+ }
+
+ public Map getDetails() {
+ Map customParameterMap = new HashMap();
+ if (details != null && details.size() != 0) {
+ Collection parameterCollection = details.values();
+ Iterator iter = parameterCollection.iterator();
+ while (iter.hasNext()) {
+ HashMap value = (HashMap)iter.next();
+ for (Map.Entry entry: value.entrySet()) {
+ customParameterMap.put(entry.getKey(),entry.getValue());
+ }
+ }
+ }
+ return customParameterMap;
+ }
+
+ @Override
+ public String getEventType() {
+ return EventTypes.EVENT_VM_IMPORT;
+ }
+
+ @Override
+ public String getEventDescription() {
+ return "Importing unmanaged VM";
+ }
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+
+ private void validateInput() {
+ if (_entityMgr.findById(Cluster.class, clusterId) == null) {
+ throw new InvalidParameterValueException(String.format("Unable to find cluster with ID: %d", clusterId));
+ }
+ if (_entityMgr.findById(ServiceOffering.class, serviceOfferingId) == null) {
+ throw new InvalidParameterValueException(String.format("Unable to find service offering with ID: %d", serviceOfferingId));
+ }
+ }
+
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+ validateInput();
+ UserVmResponse response = vmImportService.importUnmanagedInstance(this);
+ response.setResponseName(getCommandName());
+ setResponseObject(response);
+ }
+
+ @Override
+ public String getCommandName() {
+ return API_NAME.toLowerCase() + BaseAsyncCmd.RESPONSE_SUFFIX;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Long accountId = _accountService.finalyzeAccountId(accountName, domainId, projectId, true);
+ if (accountId == null) {
+ Account account = CallContext.current().getCallingAccount();
+ if (account != null) {
+ accountId = account.getId();
+ } else {
+ accountId = Account.ACCOUNT_ID_SYSTEM;
+ }
+ }
+ return accountId;
+ }
+}
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/ingestion/ListUnmanagedInstancesCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/ingestion/ListUnmanagedInstancesCmd.java
new file mode 100644
index 000000000000..1626e1275106
--- /dev/null
+++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/ingestion/ListUnmanagedInstancesCmd.java
@@ -0,0 +1,112 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.api.command.admin.ingestion;
+
+import javax.inject.Inject;
+
+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.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.UnmanagedInstanceResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.vm.UnmanagedInstance;
+import org.apache.cloudstack.vm.VmImportService;
+import org.apache.log4j.Logger;
+
+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.user.Account;
+
+@APICommand(name = ListUnmanagedInstancesCmd.API_NAME,
+ description = "Lists unmanaged virtual machines for a given cluster.",
+ responseObject = UnmanagedInstanceResponse.class,
+ responseView = ResponseObject.ResponseView.Full,
+ entityType = {UnmanagedInstance.class},
+ requestHasSensitiveInfo = false,
+ responseHasSensitiveInfo = true,
+ authorized = {RoleType.Admin})
+public class ListUnmanagedInstancesCmd extends BaseListCmd {
+ public static final Logger s_logger = Logger.getLogger(ListUnmanagedInstancesCmd.class.getName());
+ public static final String API_NAME = "listUnmanagedInstances";
+
+ @Inject
+ public VmImportService vmIngestionService;
+
+ /////////////////////////////////////////////////////
+ //////////////// API parameters /////////////////////
+ /////////////////////////////////////////////////////
+
+ @Parameter(name = ApiConstants.CLUSTER_ID,
+ type = CommandType.UUID,
+ entityType = ClusterResponse.class,
+ required = true,
+ description = "the cluster ID")
+ private Long clusterId;
+
+ @Parameter(name = ApiConstants.NAME,
+ type = CommandType.UUID,
+ description = "the hypervisor name of the instance")
+ private String name;
+
+ /////////////////////////////////////////////////////
+ /////////////////// Accessors ///////////////////////
+ /////////////////////////////////////////////////////
+
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+
+ /////////////////////////////////////////////////////
+ /////////////// API Implementation///////////////////
+ /////////////////////////////////////////////////////
+ @Override
+ public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+ ListResponse response = vmIngestionService.listUnmanagedInstances(this);
+ response.setResponseName(getCommandName());
+ setResponseObject(response);
+ }
+
+ @Override
+ public String getCommandName() {
+ return API_NAME.toLowerCase() + BaseAsyncCmd.RESPONSE_SUFFIX;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ Account account = CallContext.current().getCallingAccount();
+ if (account != null) {
+ return account.getId();
+ }
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+}
diff --git a/api/src/main/java/org/apache/cloudstack/api/response/DomainRouterResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/DomainRouterResponse.java
index 131e3e1de7ed..f69f0153dae3 100644
--- a/api/src/main/java/org/apache/cloudstack/api/response/DomainRouterResponse.java
+++ b/api/src/main/java/org/apache/cloudstack/api/response/DomainRouterResponse.java
@@ -20,8 +20,6 @@
import java.util.LinkedHashSet;
import java.util.Set;
-import com.google.gson.annotations.SerializedName;
-
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
@@ -29,6 +27,7 @@
import com.cloud.serializer.Param;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State;
+import com.google.gson.annotations.SerializedName;
@EntityReference(value = VirtualMachine.class)
@SuppressWarnings("unused")
@@ -258,6 +257,10 @@ public void setGateway(String gateway) {
this.gateway = gateway;
}
+ public String getName() {
+ return name;
+ }
+
public void setName(String name) {
this.name = name;
}
diff --git a/api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java
index 5c3fd7a75a67..e9cf952d942c 100644
--- a/api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java
+++ b/api/src/main/java/org/apache/cloudstack/api/response/NicResponse.java
@@ -16,14 +16,15 @@
// under the License.
package org.apache.cloudstack.api.response;
-import com.cloud.serializer.Param;
-import com.cloud.vm.Nic;
-import com.google.gson.annotations.SerializedName;
+import java.util.List;
+
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;
-import java.util.List;
+import com.cloud.serializer.Param;
+import com.cloud.vm.Nic;
+import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
@EntityReference(value = Nic.class)
@@ -113,6 +114,10 @@ public class NicResponse extends BaseResponse {
@Param(description = "Id of the NSX Logical Switch Port (if NSX based), null otherwise", since="4.6.0")
private String nsxLogicalSwitchPort;
+ @SerializedName(ApiConstants.VLAN_ID)
+ @Param(description = "ID of the VLAN/VNI if available", since="4.14.0")
+ private Integer vlanId;
+
public void setVmId(String vmId) {
this.vmId = vmId;
}
@@ -303,4 +308,12 @@ public String getNsxLogicalSwitch() {
public String getNsxLogicalSwitchPort() {
return nsxLogicalSwitchPort;
}
+
+ public Integer getVlanId() {
+ return vlanId;
+ }
+
+ public void setVlanId(Integer vlanId) {
+ this.vlanId = vlanId;
+ }
}
diff --git a/api/src/main/java/org/apache/cloudstack/api/response/UnmanagedInstanceDiskResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/UnmanagedInstanceDiskResponse.java
new file mode 100644
index 000000000000..f9b506a6fcb4
--- /dev/null
+++ b/api/src/main/java/org/apache/cloudstack/api/response/UnmanagedInstanceDiskResponse.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.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+public class UnmanagedInstanceDiskResponse extends BaseResponse {
+
+ @SerializedName(ApiConstants.ID)
+ @Param(description = "the ID of the disk")
+ private String diskId;
+
+ @SerializedName(ApiConstants.LABEL)
+ @Param(description = "the label of the disk")
+ private String label;
+
+ @SerializedName(ApiConstants.CAPACITY)
+ @Param(description = "the capacity in KB of the disk")
+ private Long capacity;
+
+ @SerializedName(ApiConstants.IMAGE_PATH)
+ @Param(description = "the file path of the disk image")
+ private String imagePath;
+
+ @SerializedName(ApiConstants.CONTROLLER)
+ @Param(description = "the controller of the disk")
+ private String controller;
+
+ @SerializedName(ApiConstants.CONTROLLER_UNIT)
+ @Param(description = "the controller unit of the disk")
+ private Integer controllerUnit;
+
+ @SerializedName(ApiConstants.POSITION)
+ @Param(description = "the position of the disk")
+ private Integer position;
+
+ public String getDiskId() {
+ return diskId;
+ }
+
+ public void setDiskId(String diskId) {
+ this.diskId = diskId;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public Long getCapacity() {
+ return capacity;
+ }
+
+ public void setCapacity(Long capacity) {
+ this.capacity = capacity;
+ }
+
+ public String getImagePath() {
+ return imagePath;
+ }
+
+ public void setImagePath(String imagePath) {
+ this.imagePath = imagePath;
+ }
+
+ public String getController() {
+ return controller;
+ }
+
+ public void setController(String controller) {
+ this.controller = controller;
+ }
+
+ public Integer getControllerUnit() {
+ return controllerUnit;
+ }
+
+ public void setControllerUnit(Integer controllerUnit) {
+ this.controllerUnit = controllerUnit;
+ }
+
+ public Integer getPosition() {
+ return position;
+ }
+
+ public void setPosition(Integer position) {
+ this.position = position;
+ }
+}
diff --git a/api/src/main/java/org/apache/cloudstack/api/response/UnmanagedInstanceResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/UnmanagedInstanceResponse.java
new file mode 100644
index 000000000000..cd3f7a8f8259
--- /dev/null
+++ b/api/src/main/java/org/apache/cloudstack/api/response/UnmanagedInstanceResponse.java
@@ -0,0 +1,178 @@
+// 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.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+import org.apache.cloudstack.vm.UnmanagedInstance;
+
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value = UnmanagedInstance.class)
+public class UnmanagedInstanceResponse extends BaseResponse {
+
+ @SerializedName(ApiConstants.NAME)
+ @Param(description = "the name of the virtual machine")
+ private String name;
+
+ @SerializedName(ApiConstants.CLUSTER_ID)
+ @Param(description = "the ID of the cluster to which virtual machine belongs")
+ private String clusterId;
+
+ @SerializedName(ApiConstants.HOST_ID)
+ @Param(description = "the ID of the host to which virtual machine belongs")
+ private String hostId;
+
+ @SerializedName(ApiConstants.POWER_STATE)
+ @Param(description = "the power state of the virtual machine")
+ private String powerState;
+
+ @SerializedName(ApiConstants.CPU_NUMBER)
+ @Param(description = "the CPU cores of the virtual machine")
+ private Integer cpuCores;
+
+ @SerializedName(ApiConstants.CPU_CORE_PER_SOCKET)
+ @Param(description = "the CPU cores per socket for the virtual machine. VMware specific")
+ private Integer cpuCoresPerSocket;
+
+ @SerializedName(ApiConstants.CPU_SPEED)
+ @Param(description = "the CPU speed of the virtual machine")
+ private Integer cpuSpeed;
+
+ @SerializedName(ApiConstants.MEMORY)
+ @Param(description = "the memory of the virtual machine in MB")
+ private Integer memory;
+
+ @SerializedName(ApiConstants.OS_DISPLAY_NAME)
+ @Param(description = "the operating system of the virtual machine")
+ private String operatingSystem;
+
+ @SerializedName(ApiConstants.DISK)
+ @Param(description = "the list of disks associated with the virtual machine", responseObject = UnmanagedInstanceDiskResponse.class)
+ private Set disks;
+
+ @SerializedName(ApiConstants.NIC)
+ @Param(description = "the list of nics associated with the virtual machine", responseObject = NicResponse.class)
+ private Set nics;
+
+ public UnmanagedInstanceResponse() {
+ disks = new LinkedHashSet();
+ nics = new LinkedHashSet();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getClusterId() {
+ return clusterId;
+ }
+
+ public void setClusterId(String clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public String getHostId() {
+ return hostId;
+ }
+
+ public void setHostId(String hostId) {
+ this.hostId = hostId;
+ }
+
+ public String getPowerState() {
+ return powerState;
+ }
+
+ public void setPowerState(String powerState) {
+ this.powerState = powerState;
+ }
+
+ public Integer getCpuCores() {
+ return cpuCores;
+ }
+
+ public void setCpuCores(Integer cpuCores) {
+ this.cpuCores = cpuCores;
+ }
+
+ public Integer getCpuCoresPerSocket() {
+ return cpuCoresPerSocket;
+ }
+
+ public void setCpuCoresPerSocket(Integer cpuCoresPerSocket) {
+ this.cpuCoresPerSocket = cpuCoresPerSocket;
+ }
+
+ public Integer getCpuSpeed() {
+ return cpuSpeed;
+ }
+
+ public void setCpuSpeed(Integer cpuSpeed) {
+ this.cpuSpeed = cpuSpeed;
+ }
+
+ public Integer getMemory() {
+ return memory;
+ }
+
+ public void setMemory(Integer memory) {
+ this.memory = memory;
+ }
+
+ public String getOperatingSystem() {
+ return operatingSystem;
+ }
+
+ public void setOperatingSystem(String operatingSystem) {
+ this.operatingSystem = operatingSystem;
+ }
+
+ public Set getDisks() {
+ return disks;
+ }
+
+ public void setDisks(Set disks) {
+ this.disks = disks;
+ }
+
+ public void addDisk(UnmanagedInstanceDiskResponse disk) {
+ this.disks.add(disk);
+ }
+
+ public Set getNics() {
+ return nics;
+ }
+
+ public void setNics(Set nics) {
+ this.nics = nics;
+ }
+
+ public void addNic(NicResponse nic) {
+ this.nics.add(nic);
+ }
+}
diff --git a/api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstance.java b/api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstance.java
new file mode 100644
index 000000000000..ca8e2b6479b1
--- /dev/null
+++ b/api/src/main/java/org/apache/cloudstack/vm/UnmanagedInstance.java
@@ -0,0 +1,257 @@
+// 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.vm;
+
+import java.util.List;
+
+public class UnmanagedInstance {
+
+ private String name;
+
+ private String powerState;
+
+ private Integer cpuCores;
+
+ private Integer cpuCoresPerSocket;
+
+ private Integer memory;
+
+ private Integer cpuSpeed;
+
+ private String operatingSystem;
+
+ private List disks;
+
+ private List nics;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getPowerState() {
+ return powerState;
+ }
+
+ public void setPowerState(String powerState) {
+ this.powerState = powerState;
+ }
+
+ public Integer getCpuCores() {
+ return cpuCores;
+ }
+
+ public void setCpuCores(Integer cpuCores) {
+ this.cpuCores = cpuCores;
+ }
+
+ public Integer getCpuCoresPerSocket() {
+ return cpuCoresPerSocket;
+ }
+
+ public void setCpuCoresPerSocket(Integer cpuCoresPerSocket) {
+ this.cpuCoresPerSocket = cpuCoresPerSocket;
+ }
+
+ public Integer getMemory() {
+ return memory;
+ }
+
+ public void setMemory(Integer memory) {
+ this.memory = memory;
+ }
+
+ public Integer getCpuSpeed() {
+ return cpuSpeed;
+ }
+
+ public void setCpuSpeed(Integer cpuSpeed) {
+ this.cpuSpeed = cpuSpeed;
+ }
+
+ public String getOperatingSystem() {
+ return operatingSystem;
+ }
+
+ public void setOperatingSystem(String operatingSystem) {
+ this.operatingSystem = operatingSystem;
+ }
+
+ public List getDisks() {
+ return disks;
+ }
+
+ public void setDisks(List disks) {
+ this.disks = disks;
+ }
+
+ public List getNics() {
+ return nics;
+ }
+
+ public void setNics(List nics) {
+ this.nics = nics;
+ }
+
+ public static class Disk {
+ private String diskId;
+
+ private String label;
+
+ private Long capacity;
+
+ private String imagePath;
+
+ private String controller;
+
+ private Integer controllerUnit;
+
+ private Integer position;
+
+ public String getDiskId() {
+ return diskId;
+ }
+
+ public void setDiskId(String diskId) {
+ this.diskId = diskId;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public Long getCapacity() {
+ return capacity;
+ }
+
+ public void setCapacity(Long capacity) {
+ this.capacity = capacity;
+ }
+
+ public String getImagePath() {
+ return imagePath;
+ }
+
+ public void setImagePath(String imagePath) {
+ this.imagePath = imagePath;
+ }
+
+ public String getController() {
+ return controller;
+ }
+
+ public void setController(String controller) {
+ this.controller = controller;
+ }
+
+ public Integer getControllerUnit() {
+ return controllerUnit;
+ }
+
+ public void setControllerUnit(Integer controllerUnit) {
+ this.controllerUnit = controllerUnit;
+ }
+
+ public Integer getPosition() {
+ return position;
+ }
+
+ public void setPosition(Integer position) {
+ this.position = position;
+ }
+ }
+
+ public static class Nic {
+ private String nicId;
+
+ private String adapterType;
+
+ private String macAddress;
+
+ private String network;
+
+ private Integer vlan;
+
+ private String ipAddress;
+
+ private String pciSlot;
+
+ public String getNicId() {
+ return nicId;
+ }
+
+ public void setNicId(String nicId) {
+ this.nicId = nicId;
+ }
+
+ public String getAdapterType() {
+ return adapterType;
+ }
+
+ public void setAdapterType(String adapterType) {
+ this.adapterType = adapterType;
+ }
+
+ public String getMacAddress() {
+ return macAddress;
+ }
+
+ public void setMacAddress(String macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ public String getNetwork() {
+ return network;
+ }
+
+ public void setNetwork(String network) {
+ this.network = network;
+ }
+
+ public Integer getVlan() {
+ return vlan;
+ }
+
+ public void setVlan(Integer vlan) {
+ this.vlan = vlan;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public String getPciSlot() {
+ return pciSlot;
+ }
+
+ public void setPciSlot(String pciSlot) {
+ this.pciSlot = pciSlot;
+ }
+ }
+}
diff --git a/api/src/main/java/org/apache/cloudstack/vm/VmImportService.java b/api/src/main/java/org/apache/cloudstack/vm/VmImportService.java
new file mode 100644
index 000000000000..456d38e4b81e
--- /dev/null
+++ b/api/src/main/java/org/apache/cloudstack/vm/VmImportService.java
@@ -0,0 +1,31 @@
+// 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.vm;
+
+import org.apache.cloudstack.api.command.admin.ingestion.ImportUnmanageInstanceCmd;
+import org.apache.cloudstack.api.command.admin.ingestion.ListUnmanagedInstancesCmd;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.UnmanagedInstanceResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+
+import com.cloud.utils.component.PluggableService;
+
+public interface VmImportService extends PluggableService {
+ ListResponse listUnmanagedInstances(ListUnmanagedInstancesCmd cmd);
+ UserVmResponse importUnmanagedInstance(ImportUnmanageInstanceCmd cmd);
+}
diff --git a/client/pom.xml b/client/pom.xml
index d48645883b7d..f1cb06907653 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -25,7 +25,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
diff --git a/core/pom.xml b/core/pom.xml
index bbbd8877f3e4..dc4a8c7c6d6d 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
diff --git a/core/src/main/java/com/cloud/agent/api/GetUnmanagedInstancesAnswer.java b/core/src/main/java/com/cloud/agent/api/GetUnmanagedInstancesAnswer.java
new file mode 100644
index 000000000000..682af8479c6e
--- /dev/null
+++ b/core/src/main/java/com/cloud/agent/api/GetUnmanagedInstancesAnswer.java
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.agent.api;
+
+import java.util.HashMap;
+
+import org.apache.cloudstack.vm.UnmanagedInstance;
+
+@LogLevel(LogLevel.Log4jLevel.Trace)
+public class GetUnmanagedInstancesAnswer extends Answer {
+
+ private String instanceName;
+ private HashMap unmanagedInstances;
+
+ GetUnmanagedInstancesAnswer() {
+ }
+
+ public GetUnmanagedInstancesAnswer(GetUnmanagedInstancesCommand cmd, String details, HashMap unmanagedInstances) {
+ super(cmd, true, details);
+ this.instanceName = cmd.getInstanceName();
+ this.unmanagedInstances = unmanagedInstances;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ public HashMap getUnmanagedInstances() {
+ return unmanagedInstances;
+ }
+
+ public void setUnmanagedInstances(HashMap unmanagedInstances) {
+ this.unmanagedInstances = unmanagedInstances;
+ }
+
+ public String getString() {
+ return "GetUnmanagedInstancesAnswer [instanceName=" + instanceName + "]";
+ }
+}
diff --git a/core/src/main/java/com/cloud/agent/api/GetUnmanagedInstancesCommand.java b/core/src/main/java/com/cloud/agent/api/GetUnmanagedInstancesCommand.java
new file mode 100644
index 000000000000..68b136dd196a
--- /dev/null
+++ b/core/src/main/java/com/cloud/agent/api/GetUnmanagedInstancesCommand.java
@@ -0,0 +1,67 @@
+// 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.List;
+
+@LogLevel(LogLevel.Log4jLevel.Trace)
+public class GetUnmanagedInstancesCommand extends Command {
+
+ String instanceName;
+
+ List managedInstancesNames;
+
+ public GetUnmanagedInstancesCommand() {
+ }
+
+ public GetUnmanagedInstancesCommand(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ public String getInstanceName() {
+ return instanceName;
+ }
+
+ public void setInstanceName(String instanceName) {
+ this.instanceName = instanceName;
+ }
+
+ public List getManagedInstancesNames() {
+ return managedInstancesNames;
+ }
+
+ public void setManagedInstancesNames(List managedInstancesNames) {
+ this.managedInstancesNames = managedInstancesNames;
+ }
+
+ public boolean hasManagedInstance(String name) {
+ if (managedInstancesNames!=null && !managedInstancesNames.isEmpty()) {
+ return managedInstancesNames.contains(name);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+ public String getString() {
+ return "GetUnmanagedInstancesCommand [instanceName=" + instanceName + "]";
+ }
+}
diff --git a/debian/changelog b/debian/changelog
index 45c1418b9f5c..d4d4f424e36b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+cloudstack (4.13.0.0) unstable; urgency=low
+
+ * Update the version to 4.13.0.0
+
+ -- the Apache CloudStack project Wed, 28 Aug 2019 19:58:13 +0100
+
cloudstack (4.13.0.0-SNAPSHOT) unstable; urgency=low
* Update the version to 4.13.0.0-SNAPSHOT
diff --git a/developer/pom.xml b/developer/pom.xml
index 47bb9c659799..cd0053d5d54d 100644
--- a/developer/pom.xml
+++ b/developer/pom.xml
@@ -25,7 +25,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
diff --git a/engine/api/pom.xml b/engine/api/pom.xml
index 127402429077..016a5dd75842 100644
--- a/engine/api/pom.xml
+++ b/engine/api/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
index 94a4259a6897..c0c82ea70f64 100644
--- a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
+++ b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/NetworkOrchestrationService.java
@@ -313,4 +313,6 @@ void implementNetworkElementsAndResources(DeployDestination dest, ReservationCon
* Remove entry from /etc/dhcphosts and /etc/hosts on virtual routers
*/
void cleanupNicDhcpDnsEntry(Network network, VirtualMachineProfile vmProfile, NicProfile nicProfile);
+
+ Pair importNic(final String macAddress, int deviceId, final Network network, final Boolean isDefaultNic, final VirtualMachine vm, final String ipAddress);
}
diff --git a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
index fa6f2c6fb9d4..f21b0f0c574e 100644
--- a/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
+++ b/engine/api/src/main/java/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
@@ -127,4 +127,24 @@ DiskProfile allocateTemplatedVolume(Type type, String name, DiskOffering offerin
StoragePool findStoragePool(DiskProfile dskCh, DataCenter dc, Pod pod, Long clusterId, Long hostId, VirtualMachine vm, Set avoid);
void updateVolumeDiskChain(long volumeId, String path, String chainInfo);
+
+ /**
+ * Imports an existing volume for a VM into database. Useful while ingesting an unmanaged VM.
+ * @param type Type of the volume - ROOT, DATADISK, etc
+ * @param name Name of the volume
+ * @param offering DiskOffering for the volume
+ * @param size DiskOffering for the volume
+ * @param minIops minimum IOPS for the disk, if not passed DiskOffering value will be used
+ * @param maxIops maximum IOPS for the disk, if not passed DiskOffering value will be used
+ * @param vm VirtualMachine this volume is attached to
+ * @param template Template of the VM of the volume
+ * @param owner owner Account for the volume
+ * @param deviceId device ID of the virtual disk
+ * @param poolId ID of pool in which volume is stored
+ * @param path image path of the volume
+ * @param chainInfo chain info for the volume. Hypervisor specific.
+ * @return DiskProfile of imported volume
+ */
+ DiskProfile importVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops, VirtualMachine vm, VirtualMachineTemplate template,
+ Account owner, Long deviceId, Long poolId, String path, String chainInfo);
}
diff --git a/engine/components-api/pom.xml b/engine/components-api/pom.xml
index 38bdfbe4b05f..d9f32e8bcd7d 100644
--- a/engine/components-api/pom.xml
+++ b/engine/components-api/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/engine/network/pom.xml b/engine/network/pom.xml
index 4d5b3553656e..774bc48d2caa 100644
--- a/engine/network/pom.xml
+++ b/engine/network/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/engine/orchestration/pom.xml b/engine/orchestration/pom.xml
index 14ccb5b259c3..85326a371513 100755
--- a/engine/orchestration/pom.xml
+++ b/engine/orchestration/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
index 51b71d911ce9..fa2f74a5dcae 100644
--- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
+++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
@@ -3941,6 +3941,40 @@ public NicVO savePlaceholderNic(final Network network, final String ip4Address,
return _nicDao.persist(nic);
}
+ @DB
+ @Override
+ public Pair importNic(final String macAddress, int deviceId, final Network network, final Boolean isDefaultNic, final VirtualMachine vm, final String ipAddress)
+ throws ConcurrentOperationException {
+ s_logger.debug("Allocating nic for vm " + vm.getUuid() + " in network " + network + " during ingestion");
+
+ NicVO vo = Transaction.execute(new TransactionCallback() {
+ @Override
+ public NicVO doInTransaction(TransactionStatus status) {
+ NicVO vo = new NicVO(network.getGuruName(), vm.getId(), network.getId(), vm.getType());
+ vo.setMacAddress(macAddress);
+ vo.setAddressFormat(Networks.AddressFormat.Ip4);
+ vo.setIPv4Address(ipAddress);
+ vo.setBroadcastUri(network.getBroadcastUri());
+ vo.setMode(network.getMode());
+ vo.setState(Nic.State.Reserved);
+ vo.setReservationStrategy(ReservationStrategy.Start);
+ vo.setReservationId(UUID.randomUUID().toString());
+ vo.setDeviceId(deviceId);
+ vo.setIsolationUri(network.getBroadcastUri());
+ vo.setDeviceId(deviceId);
+ vo.setDefaultNic(isDefaultNic);
+ vo = _nicDao.persist(vo);
+ return vo;
+ }
+ });
+
+ final Integer networkRate = _networkModel.getNetworkRate(network.getId(), vm.getId());
+ final NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate, _networkModel.isSecurityGroupSupportedInNetwork(network),
+ _networkModel.getNetworkTag(vm.getHypervisorType(), network));
+
+ return new Pair(vmNic, Integer.valueOf(deviceId));
+ }
+
@Override
public String getConfigComponentName() {
return NetworkOrchestrationService.class.getSimpleName();
diff --git a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 6e71864c4473..e055590db5ac 100644
--- a/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -30,7 +30,6 @@
import javax.inject.Inject;
import javax.naming.ConfigurationException;
-import com.cloud.storage.VolumeApiService;
import org.apache.cloudstack.api.command.admin.vm.MigrateVMCmd;
import org.apache.cloudstack.api.command.admin.volume.MigrateVolumeCmdByAdmin;
import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
@@ -106,6 +105,7 @@
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.Volume;
import com.cloud.storage.Volume.Type;
+import com.cloud.storage.VolumeApiService;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.VolumeDao;
@@ -1626,4 +1626,58 @@ public void updateVolumeDiskChain(long volumeId, String path, String chainInfo)
_volsDao.update(volumeId, vol);
}
}
+
+ @Override
+ public DiskProfile importVolume(Type type, String name, DiskOffering offering, Long size, Long minIops, Long maxIops,
+ VirtualMachine vm, VirtualMachineTemplate template, Account owner,
+ Long deviceId, Long poolId, String path, String chainInfo) {
+ if (size == null) {
+ size = offering.getDiskSize();
+ } else {
+ size = (size * 1024 * 1024 * 1024);
+ }
+
+ 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(), offering.getProvisioningType(), size, minIops, maxIops, null);
+ if (vm != null) {
+ vol.setInstanceId(vm.getId());
+ }
+
+ if (deviceId != null) {
+ vol.setDeviceId(deviceId);
+ } else if (type.equals(Type.ROOT)) {
+ vol.setDeviceId(0l);
+ } else {
+ vol.setDeviceId(1l);
+ }
+ if (template.getFormat() == ImageFormat.ISO) {
+ vol.setIsoId(template.getId());
+ } else if (template.getTemplateType().equals(Storage.TemplateType.DATADISK)) {
+ vol.setTemplateId(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.setPoolId(poolId);
+ vol.setPath(path);
+ vol.setChainInfo(chainInfo);
+ vol.setState(Volume.State.Ready);
+ vol = _volsDao.persist(vol);
+
+ // 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(), vol.isDisplayVolume());
+
+ _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);
+ }
}
diff --git a/engine/pom.xml b/engine/pom.xml
index e10490406470..590029e87f7f 100644
--- a/engine/pom.xml
+++ b/engine/pom.xml
@@ -25,7 +25,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/engine/schema/pom.xml b/engine/schema/pom.xml
index 3ac9df9fd96f..534bad2ad20d 100644
--- a/engine/schema/pom.xml
+++ b/engine/schema/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/engine/service/pom.xml b/engine/service/pom.xml
index 83481f8eaeb1..0121b7a8d098 100644
--- a/engine/service/pom.xml
+++ b/engine/service/pom.xml
@@ -22,7 +22,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
cloud-engine-service
war
diff --git a/engine/storage/cache/pom.xml b/engine/storage/cache/pom.xml
index 32b52320e5b8..abe68d3c9337 100644
--- a/engine/storage/cache/pom.xml
+++ b/engine/storage/cache/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/engine/storage/configdrive/pom.xml b/engine/storage/configdrive/pom.xml
index 1bb1d54b0e99..917e6a785e33 100644
--- a/engine/storage/configdrive/pom.xml
+++ b/engine/storage/configdrive/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/engine/storage/datamotion/pom.xml b/engine/storage/datamotion/pom.xml
index aff5bdb1cca5..dbac2d0428e6 100644
--- a/engine/storage/datamotion/pom.xml
+++ b/engine/storage/datamotion/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/engine/storage/image/pom.xml b/engine/storage/image/pom.xml
index 96dd41fd466f..8a8951ca315f 100644
--- a/engine/storage/image/pom.xml
+++ b/engine/storage/image/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/engine/storage/integration-test/pom.xml b/engine/storage/integration-test/pom.xml
index f30e0c97390c..fdc19400f387 100644
--- a/engine/storage/integration-test/pom.xml
+++ b/engine/storage/integration-test/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/engine/storage/pom.xml b/engine/storage/pom.xml
index 4b46b040352d..aa64ac009bdb 100644
--- a/engine/storage/pom.xml
+++ b/engine/storage/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/engine/storage/snapshot/pom.xml b/engine/storage/snapshot/pom.xml
index f82be48f0e3e..e616b684207f 100644
--- a/engine/storage/snapshot/pom.xml
+++ b/engine/storage/snapshot/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/engine/storage/volume/pom.xml b/engine/storage/volume/pom.xml
index 99ca8647a494..b67871fb2ba4 100644
--- a/engine/storage/volume/pom.xml
+++ b/engine/storage/volume/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloud-engine
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/framework/agent-lb/pom.xml b/framework/agent-lb/pom.xml
index 9b665f86343c..4238ad205cb7 100644
--- a/framework/agent-lb/pom.xml
+++ b/framework/agent-lb/pom.xml
@@ -24,7 +24,7 @@
cloudstack-framework
org.apache.cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/ca/pom.xml b/framework/ca/pom.xml
index 4dac4166929b..7508b97fbf89 100644
--- a/framework/ca/pom.xml
+++ b/framework/ca/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/cluster/pom.xml b/framework/cluster/pom.xml
index c8a8d8d4fddb..d8f86be89c1c 100644
--- a/framework/cluster/pom.xml
+++ b/framework/cluster/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/config/pom.xml b/framework/config/pom.xml
index 696bc2233e05..9a3880b32e2a 100644
--- a/framework/config/pom.xml
+++ b/framework/config/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/db/pom.xml b/framework/db/pom.xml
index 2e4cac76399f..5c9a226f6a56 100644
--- a/framework/db/pom.xml
+++ b/framework/db/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/direct-download/pom.xml b/framework/direct-download/pom.xml
index 0a91e69b2565..b6d355ba439e 100644
--- a/framework/direct-download/pom.xml
+++ b/framework/direct-download/pom.xml
@@ -24,7 +24,7 @@
cloudstack-framework
org.apache.cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
\ No newline at end of file
diff --git a/framework/events/pom.xml b/framework/events/pom.xml
index 008ecbac455a..861f735550c9 100644
--- a/framework/events/pom.xml
+++ b/framework/events/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/ipc/pom.xml b/framework/ipc/pom.xml
index 0e9b4e598ddc..ffb9f294f266 100644
--- a/framework/ipc/pom.xml
+++ b/framework/ipc/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/jobs/pom.xml b/framework/jobs/pom.xml
index 351d181ab115..d0b95f025505 100644
--- a/framework/jobs/pom.xml
+++ b/framework/jobs/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/managed-context/pom.xml b/framework/managed-context/pom.xml
index 367bf49f384e..4075b81cddb0 100644
--- a/framework/managed-context/pom.xml
+++ b/framework/managed-context/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/framework/pom.xml b/framework/pom.xml
index c42bb3c24c75..bb100a02b082 100644
--- a/framework/pom.xml
+++ b/framework/pom.xml
@@ -25,7 +25,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
diff --git a/framework/quota/pom.xml b/framework/quota/pom.xml
index f0d4743eab4c..e5e97ec643e8 100644
--- a/framework/quota/pom.xml
+++ b/framework/quota/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/rest/pom.xml b/framework/rest/pom.xml
index 1fd6edfd1ae5..70ee3f23c7fb 100644
--- a/framework/rest/pom.xml
+++ b/framework/rest/pom.xml
@@ -22,7 +22,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
cloud-framework-rest
diff --git a/framework/security/pom.xml b/framework/security/pom.xml
index d56a0924af54..1aa528bddc02 100644
--- a/framework/security/pom.xml
+++ b/framework/security/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-framework
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/framework/spring/lifecycle/pom.xml b/framework/spring/lifecycle/pom.xml
index 0d8abf3273e7..94af4c44c3a7 100644
--- a/framework/spring/lifecycle/pom.xml
+++ b/framework/spring/lifecycle/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/framework/spring/module/pom.xml b/framework/spring/module/pom.xml
index 120a1aeef5f9..ff482d257a40 100644
--- a/framework/spring/module/pom.xml
+++ b/framework/spring/module/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/acl/dynamic-role-based/pom.xml b/plugins/acl/dynamic-role-based/pom.xml
index ffc20cdac413..4707813a8d30 100644
--- a/plugins/acl/dynamic-role-based/pom.xml
+++ b/plugins/acl/dynamic-role-based/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/acl/static-role-based/pom.xml b/plugins/acl/static-role-based/pom.xml
index 978373714c6d..b42db4598413 100644
--- a/plugins/acl/static-role-based/pom.xml
+++ b/plugins/acl/static-role-based/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/affinity-group-processors/explicit-dedication/pom.xml b/plugins/affinity-group-processors/explicit-dedication/pom.xml
index f3c1c2116b07..b4786d42357b 100644
--- a/plugins/affinity-group-processors/explicit-dedication/pom.xml
+++ b/plugins/affinity-group-processors/explicit-dedication/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/affinity-group-processors/host-affinity/pom.xml b/plugins/affinity-group-processors/host-affinity/pom.xml
index e738b2ae6773..e7c78b4a9e05 100644
--- a/plugins/affinity-group-processors/host-affinity/pom.xml
+++ b/plugins/affinity-group-processors/host-affinity/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/affinity-group-processors/host-anti-affinity/pom.xml b/plugins/affinity-group-processors/host-anti-affinity/pom.xml
index ac4b91800348..e89037cda917 100644
--- a/plugins/affinity-group-processors/host-anti-affinity/pom.xml
+++ b/plugins/affinity-group-processors/host-anti-affinity/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/alert-handlers/snmp-alerts/pom.xml b/plugins/alert-handlers/snmp-alerts/pom.xml
index d8085deac5d4..14a91b889e3c 100644
--- a/plugins/alert-handlers/snmp-alerts/pom.xml
+++ b/plugins/alert-handlers/snmp-alerts/pom.xml
@@ -24,7 +24,7 @@
cloudstack-plugins
org.apache.cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/alert-handlers/syslog-alerts/pom.xml b/plugins/alert-handlers/syslog-alerts/pom.xml
index 0367d2bc5ca4..2ba4dbf53d0f 100644
--- a/plugins/alert-handlers/syslog-alerts/pom.xml
+++ b/plugins/alert-handlers/syslog-alerts/pom.xml
@@ -24,7 +24,7 @@
cloudstack-plugins
org.apache.cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/api/discovery/pom.xml b/plugins/api/discovery/pom.xml
index 4857efe054f9..9df6a40955fb 100644
--- a/plugins/api/discovery/pom.xml
+++ b/plugins/api/discovery/pom.xml
@@ -25,7 +25,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/api/rate-limit/pom.xml b/plugins/api/rate-limit/pom.xml
index 5a8f57f94028..6611a50dfa89 100644
--- a/plugins/api/rate-limit/pom.xml
+++ b/plugins/api/rate-limit/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/api/solidfire-intg-test/pom.xml b/plugins/api/solidfire-intg-test/pom.xml
index b01dde22cd3d..31112cc56720 100644
--- a/plugins/api/solidfire-intg-test/pom.xml
+++ b/plugins/api/solidfire-intg-test/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/api/vmware-sioc/pom.xml b/plugins/api/vmware-sioc/pom.xml
index 9adde582a3e8..75eeb89dd20b 100644
--- a/plugins/api/vmware-sioc/pom.xml
+++ b/plugins/api/vmware-sioc/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/ca/root-ca/pom.xml b/plugins/ca/root-ca/pom.xml
index 32cde1c17e5e..0a23c24bf267 100644
--- a/plugins/ca/root-ca/pom.xml
+++ b/plugins/ca/root-ca/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/database/mysql-ha/pom.xml b/plugins/database/mysql-ha/pom.xml
index d973d9aa1dc6..5321ddde6246 100644
--- a/plugins/database/mysql-ha/pom.xml
+++ b/plugins/database/mysql-ha/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/database/quota/pom.xml b/plugins/database/quota/pom.xml
index b0b80c806b01..9daee6e6cd23 100644
--- a/plugins/database/quota/pom.xml
+++ b/plugins/database/quota/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/dedicated-resources/pom.xml b/plugins/dedicated-resources/pom.xml
index f84e69d589a8..91871226058e 100644
--- a/plugins/dedicated-resources/pom.xml
+++ b/plugins/dedicated-resources/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/plugins/deployment-planners/implicit-dedication/pom.xml b/plugins/deployment-planners/implicit-dedication/pom.xml
index 544773836dbf..216fba490f68 100644
--- a/plugins/deployment-planners/implicit-dedication/pom.xml
+++ b/plugins/deployment-planners/implicit-dedication/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/deployment-planners/user-concentrated-pod/pom.xml b/plugins/deployment-planners/user-concentrated-pod/pom.xml
index ff27869a8d3b..519ffe781c28 100644
--- a/plugins/deployment-planners/user-concentrated-pod/pom.xml
+++ b/plugins/deployment-planners/user-concentrated-pod/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/deployment-planners/user-dispersing/pom.xml b/plugins/deployment-planners/user-dispersing/pom.xml
index 4c1605f1cb94..219f58755f49 100644
--- a/plugins/deployment-planners/user-dispersing/pom.xml
+++ b/plugins/deployment-planners/user-dispersing/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/event-bus/inmemory/pom.xml b/plugins/event-bus/inmemory/pom.xml
index ae9656e38674..b0d4c4c1ee6c 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.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/event-bus/kafka/pom.xml b/plugins/event-bus/kafka/pom.xml
index 753e59c7eb9d..4050f3ef993c 100644
--- a/plugins/event-bus/kafka/pom.xml
+++ b/plugins/event-bus/kafka/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/event-bus/rabbitmq/pom.xml b/plugins/event-bus/rabbitmq/pom.xml
index e4f4790d3e54..e17dfd1ba82e 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.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/ha-planners/skip-heurestics/pom.xml b/plugins/ha-planners/skip-heurestics/pom.xml
index 31ac89e40bbd..c2d31cb9fce0 100644
--- a/plugins/ha-planners/skip-heurestics/pom.xml
+++ b/plugins/ha-planners/skip-heurestics/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/host-allocators/random/pom.xml b/plugins/host-allocators/random/pom.xml
index 1642253c1dc3..0efdbbd039b1 100644
--- a/plugins/host-allocators/random/pom.xml
+++ b/plugins/host-allocators/random/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/hypervisors/baremetal/pom.xml b/plugins/hypervisors/baremetal/pom.xml
index c4bb428c9ee5..37001ec02d8e 100755
--- a/plugins/hypervisors/baremetal/pom.xml
+++ b/plugins/hypervisors/baremetal/pom.xml
@@ -22,7 +22,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
cloud-plugin-hypervisor-baremetal
diff --git a/plugins/hypervisors/hyperv/pom.xml b/plugins/hypervisors/hyperv/pom.xml
index 25c12eca567f..37eb13775727 100644
--- a/plugins/hypervisors/hyperv/pom.xml
+++ b/plugins/hypervisors/hyperv/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/hypervisors/kvm/pom.xml b/plugins/hypervisors/kvm/pom.xml
index c9408e272578..ddcbf78a9402 100644
--- a/plugins/hypervisors/kvm/pom.xml
+++ b/plugins/hypervisors/kvm/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/hypervisors/ovm/pom.xml b/plugins/hypervisors/ovm/pom.xml
index 679e37e755b8..c6fb7670c5c3 100644
--- a/plugins/hypervisors/ovm/pom.xml
+++ b/plugins/hypervisors/ovm/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/hypervisors/ovm3/pom.xml b/plugins/hypervisors/ovm3/pom.xml
index a42196c8c543..9fcd80a6e497 100644
--- a/plugins/hypervisors/ovm3/pom.xml
+++ b/plugins/hypervisors/ovm3/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/hypervisors/simulator/pom.xml b/plugins/hypervisors/simulator/pom.xml
index 909746e2bc50..2800ca1c3359 100644
--- a/plugins/hypervisors/simulator/pom.xml
+++ b/plugins/hypervisors/simulator/pom.xml
@@ -22,7 +22,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
cloud-plugin-hypervisor-simulator
diff --git a/plugins/hypervisors/ucs/pom.xml b/plugins/hypervisors/ucs/pom.xml
index 13cf50c0d45d..a481e3258c12 100644
--- a/plugins/hypervisors/ucs/pom.xml
+++ b/plugins/hypervisors/ucs/pom.xml
@@ -23,7 +23,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
cloud-plugin-hypervisor-ucs
diff --git a/plugins/hypervisors/vmware/pom.xml b/plugins/hypervisors/vmware/pom.xml
index d4b08600d339..622591c8f065 100644
--- a/plugins/hypervisors/vmware/pom.xml
+++ b/plugins/hypervisors/vmware/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 02f758ba844b..fc4f858f4ec7 100644
--- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -44,20 +44,8 @@
import javax.naming.ConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar;
-import com.cloud.agent.api.storage.OVFPropertyTO;
-import com.cloud.utils.crypt.DBEncryptionUtil;
-import com.vmware.vim25.ArrayUpdateOperation;
-import com.vmware.vim25.VAppOvfSectionInfo;
-import com.vmware.vim25.VAppOvfSectionSpec;
-import com.vmware.vim25.VAppProductInfo;
-import com.vmware.vim25.VAppProductSpec;
-import com.vmware.vim25.VAppPropertyInfo;
-import com.vmware.vim25.VAppPropertySpec;
-import com.vmware.vim25.VmConfigInfo;
-import com.vmware.vim25.VmConfigSpec;
-import org.apache.commons.collections.CollectionUtils;
-
import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.vm.UnmanagedInstance;
import org.apache.cloudstack.storage.command.CopyCommand;
import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
import org.apache.cloudstack.storage.configdrive.ConfigDrive;
@@ -66,6 +54,7 @@
import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.apache.cloudstack.storage.to.VolumeObjectTO;
import org.apache.cloudstack.utils.volume.VirtualMachineDiskInfo;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.log4j.Logger;
@@ -101,6 +90,8 @@
import com.cloud.agent.api.GetHostStatsCommand;
import com.cloud.agent.api.GetStorageStatsAnswer;
import com.cloud.agent.api.GetStorageStatsCommand;
+import com.cloud.agent.api.GetUnmanagedInstancesAnswer;
+import com.cloud.agent.api.GetUnmanagedInstancesCommand;
import com.cloud.agent.api.GetVmDiskStatsAnswer;
import com.cloud.agent.api.GetVmDiskStatsCommand;
import com.cloud.agent.api.GetVmIpAddressCommand;
@@ -184,6 +175,7 @@
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.MigrateVolumeAnswer;
import com.cloud.agent.api.storage.MigrateVolumeCommand;
+import com.cloud.agent.api.storage.OVFPropertyTO;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
import com.cloud.agent.api.storage.ResizeVolumeAnswer;
@@ -255,6 +247,7 @@
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
+import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.utils.db.DB;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.exception.ExceptionUtil;
@@ -268,8 +261,10 @@
import com.cloud.vm.VirtualMachine.PowerState;
import com.cloud.vm.VirtualMachineName;
import com.cloud.vm.VmDetailConstants;
+import com.google.common.base.Strings;
import com.google.gson.Gson;
import com.vmware.vim25.AboutInfo;
+import com.vmware.vim25.ArrayUpdateOperation;
import com.vmware.vim25.BoolPolicy;
import com.vmware.vim25.ComputeResourceSummary;
import com.vmware.vim25.CustomFieldStringValue;
@@ -282,9 +277,11 @@
import com.vmware.vim25.DistributedVirtualSwitchPortCriteria;
import com.vmware.vim25.DynamicProperty;
import com.vmware.vim25.GuestInfo;
+import com.vmware.vim25.GuestNicInfo;
import com.vmware.vim25.HostCapability;
import com.vmware.vim25.HostHostBusAdapter;
import com.vmware.vim25.HostInternetScsiHba;
+import com.vmware.vim25.HostPortGroupSpec;
import com.vmware.vim25.ManagedObjectReference;
import com.vmware.vim25.ObjectContent;
import com.vmware.vim25.OptionValue;
@@ -297,6 +294,12 @@
import com.vmware.vim25.PerfQuerySpec;
import com.vmware.vim25.RuntimeFaultFaultMsg;
import com.vmware.vim25.ToolsUnavailableFaultMsg;
+import com.vmware.vim25.VAppOvfSectionInfo;
+import com.vmware.vim25.VAppOvfSectionSpec;
+import com.vmware.vim25.VAppProductInfo;
+import com.vmware.vim25.VAppProductSpec;
+import com.vmware.vim25.VAppPropertyInfo;
+import com.vmware.vim25.VAppPropertySpec;
import com.vmware.vim25.VMwareDVSPortSetting;
import com.vmware.vim25.VimPortType;
import com.vmware.vim25.VirtualDevice;
@@ -309,6 +312,7 @@
import com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo;
import com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo;
import com.vmware.vim25.VirtualEthernetCardOpaqueNetworkBackingInfo;
+import com.vmware.vim25.VirtualIDEController;
import com.vmware.vim25.VirtualMachineConfigSpec;
import com.vmware.vim25.VirtualMachineFileInfo;
import com.vmware.vim25.VirtualMachineFileLayoutEx;
@@ -320,7 +324,10 @@
import com.vmware.vim25.VirtualMachineRuntimeInfo;
import com.vmware.vim25.VirtualMachineToolsStatus;
import com.vmware.vim25.VirtualMachineVideoCard;
+import com.vmware.vim25.VirtualSCSIController;
import com.vmware.vim25.VirtualUSBController;
+import com.vmware.vim25.VmConfigInfo;
+import com.vmware.vim25.VmConfigSpec;
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
public class VmwareResource implements StoragePoolResource, ServerResource, VmwareHostService, VirtualRouterDeployer {
@@ -378,6 +385,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
protected VirtualRoutingResource _vrResource;
protected final static HashMap s_powerStatesTable = new HashMap();
+
static {
s_powerStatesTable.put(VirtualMachinePowerState.POWERED_ON, PowerState.PowerOn);
s_powerStatesTable.put(VirtualMachinePowerState.POWERED_OFF, PowerState.PowerOff);
@@ -430,118 +438,120 @@ public Answer executeRequest(Command cmd) {
Class extends Command> clz = cmd.getClass();
if (cmd instanceof NetworkElementCommand) {
- return _vrResource.executeRequest((NetworkElementCommand)cmd);
+ return _vrResource.executeRequest((NetworkElementCommand) cmd);
} else if (clz == ReadyCommand.class) {
- answer = execute((ReadyCommand)cmd);
+ answer = execute((ReadyCommand) cmd);
} else if (clz == GetHostStatsCommand.class) {
- answer = execute((GetHostStatsCommand)cmd);
+ answer = execute((GetHostStatsCommand) cmd);
} else if (clz == GetVmStatsCommand.class) {
- answer = execute((GetVmStatsCommand)cmd);
+ answer = execute((GetVmStatsCommand) cmd);
} else if (clz == GetVmNetworkStatsCommand.class) {
answer = execute((GetVmNetworkStatsCommand) cmd);
} else if (clz == GetVmDiskStatsCommand.class) {
- answer = execute((GetVmDiskStatsCommand)cmd);
+ answer = execute((GetVmDiskStatsCommand) cmd);
} else if (cmd instanceof GetVolumeStatsCommand) {
- return execute((GetVolumeStatsCommand)cmd);
+ return execute((GetVolumeStatsCommand) cmd);
} else if (clz == CheckHealthCommand.class) {
- answer = execute((CheckHealthCommand)cmd);
+ answer = execute((CheckHealthCommand) cmd);
} else if (clz == StopCommand.class) {
- answer = execute((StopCommand)cmd);
+ answer = execute((StopCommand) cmd);
} else if (clz == RebootRouterCommand.class) {
- answer = execute((RebootRouterCommand)cmd);
+ answer = execute((RebootRouterCommand) cmd);
} else if (clz == RebootCommand.class) {
- answer = execute((RebootCommand)cmd);
+ answer = execute((RebootCommand) cmd);
} else if (clz == CheckVirtualMachineCommand.class) {
- answer = execute((CheckVirtualMachineCommand)cmd);
+ answer = execute((CheckVirtualMachineCommand) cmd);
} else if (clz == PrepareForMigrationCommand.class) {
- answer = execute((PrepareForMigrationCommand)cmd);
+ answer = execute((PrepareForMigrationCommand) cmd);
} else if (clz == MigrateCommand.class) {
- answer = execute((MigrateCommand)cmd);
+ answer = execute((MigrateCommand) cmd);
} else if (clz == MigrateVmToPoolCommand.class) {
- answer = execute((MigrateVmToPoolCommand)cmd);
+ answer = execute((MigrateVmToPoolCommand) cmd);
} else if (clz == MigrateWithStorageCommand.class) {
- answer = execute((MigrateWithStorageCommand)cmd);
+ answer = execute((MigrateWithStorageCommand) cmd);
} else if (clz == MigrateVolumeCommand.class) {
- answer = execute((MigrateVolumeCommand)cmd);
+ answer = execute((MigrateVolumeCommand) cmd);
} else if (clz == DestroyCommand.class) {
- answer = execute((DestroyCommand)cmd);
+ answer = execute((DestroyCommand) cmd);
} else if (clz == CreateStoragePoolCommand.class) {
- return execute((CreateStoragePoolCommand)cmd);
+ return execute((CreateStoragePoolCommand) cmd);
} else if (clz == ModifyTargetsCommand.class) {
- answer = execute((ModifyTargetsCommand)cmd);
+ answer = execute((ModifyTargetsCommand) cmd);
} else if (clz == ModifyStoragePoolCommand.class) {
- answer = execute((ModifyStoragePoolCommand)cmd);
+ answer = execute((ModifyStoragePoolCommand) cmd);
} else if (clz == DeleteStoragePoolCommand.class) {
- answer = execute((DeleteStoragePoolCommand)cmd);
+ answer = execute((DeleteStoragePoolCommand) cmd);
} else if (clz == CopyVolumeCommand.class) {
- answer = execute((CopyVolumeCommand)cmd);
+ answer = execute((CopyVolumeCommand) cmd);
} else if (clz == AttachIsoCommand.class) {
- answer = execute((AttachIsoCommand)cmd);
+ answer = execute((AttachIsoCommand) cmd);
} else if (clz == ValidateSnapshotCommand.class) {
- answer = execute((ValidateSnapshotCommand)cmd);
+ answer = execute((ValidateSnapshotCommand) cmd);
} else if (clz == ManageSnapshotCommand.class) {
- answer = execute((ManageSnapshotCommand)cmd);
+ answer = execute((ManageSnapshotCommand) cmd);
} else if (clz == BackupSnapshotCommand.class) {
- answer = execute((BackupSnapshotCommand)cmd);
+ answer = execute((BackupSnapshotCommand) cmd);
} else if (clz == CreateVolumeFromSnapshotCommand.class) {
- answer = execute((CreateVolumeFromSnapshotCommand)cmd);
+ answer = execute((CreateVolumeFromSnapshotCommand) cmd);
} else if (clz == CreatePrivateTemplateFromVolumeCommand.class) {
- answer = execute((CreatePrivateTemplateFromVolumeCommand)cmd);
+ answer = execute((CreatePrivateTemplateFromVolumeCommand) cmd);
} else if (clz == CreatePrivateTemplateFromSnapshotCommand.class) {
- answer = execute((CreatePrivateTemplateFromSnapshotCommand)cmd);
+ answer = execute((CreatePrivateTemplateFromSnapshotCommand) cmd);
} else if (clz == UpgradeSnapshotCommand.class) {
- answer = execute((UpgradeSnapshotCommand)cmd);
+ answer = execute((UpgradeSnapshotCommand) cmd);
} else if (clz == GetStorageStatsCommand.class) {
- answer = execute((GetStorageStatsCommand)cmd);
+ answer = execute((GetStorageStatsCommand) cmd);
} else if (clz == PrimaryStorageDownloadCommand.class) {
- answer = execute((PrimaryStorageDownloadCommand)cmd);
+ answer = execute((PrimaryStorageDownloadCommand) cmd);
} else if (clz == GetVncPortCommand.class) {
- answer = execute((GetVncPortCommand)cmd);
+ answer = execute((GetVncPortCommand) cmd);
} else if (clz == SetupCommand.class) {
- answer = execute((SetupCommand)cmd);
+ answer = execute((SetupCommand) cmd);
} else if (clz == MaintainCommand.class) {
- answer = execute((MaintainCommand)cmd);
+ answer = execute((MaintainCommand) cmd);
} else if (clz == PingTestCommand.class) {
- answer = execute((PingTestCommand)cmd);
+ answer = execute((PingTestCommand) cmd);
} else if (clz == CheckOnHostCommand.class) {
- answer = execute((CheckOnHostCommand)cmd);
+ answer = execute((CheckOnHostCommand) cmd);
} else if (clz == ModifySshKeysCommand.class) {
- answer = execute((ModifySshKeysCommand)cmd);
+ answer = execute((ModifySshKeysCommand) cmd);
} else if (clz == NetworkUsageCommand.class) {
- answer = execute((NetworkUsageCommand)cmd);
+ answer = execute((NetworkUsageCommand) cmd);
} else if (clz == StartCommand.class) {
- answer = execute((StartCommand)cmd);
+ answer = execute((StartCommand) cmd);
} else if (clz == CheckSshCommand.class) {
- answer = execute((CheckSshCommand)cmd);
+ answer = execute((CheckSshCommand) cmd);
} else if (clz == CheckNetworkCommand.class) {
- answer = execute((CheckNetworkCommand)cmd);
+ answer = execute((CheckNetworkCommand) cmd);
} else if (clz == PlugNicCommand.class) {
- answer = execute((PlugNicCommand)cmd);
+ answer = execute((PlugNicCommand) cmd);
} else if (clz == ReplugNicCommand.class) {
- answer = execute((ReplugNicCommand)cmd);
+ answer = execute((ReplugNicCommand) cmd);
} else if (clz == UnPlugNicCommand.class) {
- answer = execute((UnPlugNicCommand)cmd);
+ answer = execute((UnPlugNicCommand) cmd);
} else if (cmd instanceof CreateVMSnapshotCommand) {
- return execute((CreateVMSnapshotCommand)cmd);
+ return execute((CreateVMSnapshotCommand) cmd);
} else if (cmd instanceof DeleteVMSnapshotCommand) {
- return execute((DeleteVMSnapshotCommand)cmd);
+ return execute((DeleteVMSnapshotCommand) cmd);
} else if (cmd instanceof RevertToVMSnapshotCommand) {
- return execute((RevertToVMSnapshotCommand)cmd);
+ return execute((RevertToVMSnapshotCommand) cmd);
} else if (clz == ResizeVolumeCommand.class) {
- return execute((ResizeVolumeCommand)cmd);
+ return execute((ResizeVolumeCommand) cmd);
} else if (clz == UnregisterVMCommand.class) {
- return execute((UnregisterVMCommand)cmd);
+ return execute((UnregisterVMCommand) cmd);
} else if (cmd instanceof StorageSubSystemCommand) {
- checkStorageProcessorAndHandlerNfsVersionAttribute((StorageSubSystemCommand)cmd);
- return storageHandler.handleStorageCommands((StorageSubSystemCommand)cmd);
+ checkStorageProcessorAndHandlerNfsVersionAttribute((StorageSubSystemCommand) cmd);
+ return storageHandler.handleStorageCommands((StorageSubSystemCommand) cmd);
} else if (clz == ScaleVmCommand.class) {
- return execute((ScaleVmCommand)cmd);
+ return execute((ScaleVmCommand) cmd);
} else if (clz == PvlanSetupCommand.class) {
- return execute((PvlanSetupCommand)cmd);
+ return execute((PvlanSetupCommand) cmd);
} else if (clz == GetVmIpAddressCommand.class) {
- return execute((GetVmIpAddressCommand)cmd);
+ return execute((GetVmIpAddressCommand) cmd);
} else if (clz == UnregisterNicCommand.class) {
- answer = execute((UnregisterNicCommand)cmd);
+ answer = execute((UnregisterNicCommand) cmd);
+ } else if (clz == GetUnmanagedInstancesCommand.class) {
+ answer = execute((GetUnmanagedInstancesCommand) cmd);
} else {
answer = Answer.createUnsupportedCommandAnswer(cmd);
}
@@ -587,6 +597,7 @@ public Answer executeRequest(Command cmd) {
* If _storageNfsVersion is not null -> nothing to do, version already set.
* If _storageNfsVersion is null -> examine StorageSubSystemCommand to get NFS version and set it
* to the storage processor and storage handler.
+ *
* @param cmd command to execute
*/
protected void checkStorageProcessorAndHandlerNfsVersionAttribute(StorageSubSystemCommand cmd) {
@@ -595,18 +606,19 @@ protected void checkStorageProcessorAndHandlerNfsVersionAttribute(StorageSubSyst
if (cmd instanceof CopyCommand) {
EnumMap params = new EnumMap(
VmwareStorageProcessorConfigurableFields.class);
- examineStorageSubSystemCommandNfsVersion((CopyCommand)cmd, params);
- params = examineStorageSubSystemCommandFullCloneFlagForVmware((CopyCommand)cmd, params);
+ examineStorageSubSystemCommandNfsVersion((CopyCommand) cmd, params);
+ params = examineStorageSubSystemCommandFullCloneFlagForVmware((CopyCommand) cmd, params);
reconfigureProcessorByHandler(params);
}
}
/**
* Reconfigure processor by handler
+ *
* @param params params
*/
protected void reconfigureProcessorByHandler(EnumMap params) {
- VmwareStorageSubsystemCommandHandler handler = (VmwareStorageSubsystemCommandHandler)storageHandler;
+ VmwareStorageSubsystemCommandHandler handler = (VmwareStorageSubsystemCommandHandler) storageHandler;
boolean success = handler.reconfigureStorageProcessor(params);
if (success) {
s_logger.info("VmwareStorageProcessor and VmwareStorageSubsystemCommandHandler successfully reconfigured");
@@ -617,18 +629,19 @@ protected void reconfigureProcessorByHandler(EnumMap examineStorageSubSystemCommandFullCloneFlagForVmware(CopyCommand cmd,
- EnumMap params) {
+ EnumMap params) {
EnumMap paramsCopy = new EnumMap(params);
HypervisorType hypervisor = cmd.getDestTO().getHypervisorType();
if (hypervisor != null && hypervisor.equals(HypervisorType.VMware)) {
DataStoreTO destDataStore = cmd.getDestTO().getDataStore();
if (destDataStore instanceof PrimaryDataStoreTO) {
- PrimaryDataStoreTO dest = (PrimaryDataStoreTO)destDataStore;
+ PrimaryDataStoreTO dest = (PrimaryDataStoreTO) destDataStore;
if (dest.isFullCloneFlag() != null) {
paramsCopy.put(VmwareStorageProcessorConfigurableFields.FULL_CLONE_FLAG, dest.isFullCloneFlag().booleanValue());
}
@@ -639,7 +652,8 @@ protected EnumMap examineStora
/**
* Examine StorageSubSystem command to get storage NFS version, if provided
- * @param cmd command to execute
+ *
+ * @param cmd command to execute
* @param params params
*/
protected void examineStorageSubSystemCommandNfsVersion(CopyCommand cmd, EnumMap params) {
@@ -647,7 +661,7 @@ protected void examineStorageSubSystemCommandNfsVersion(CopyCommand cmd, EnumMap
boolean nfsVersionFound = false;
if (srcDataStore instanceof NfsTO) {
- nfsVersionFound = getStorageNfsVersionFromNfsTO((NfsTO)srcDataStore);
+ nfsVersionFound = getStorageNfsVersionFromNfsTO((NfsTO) srcDataStore);
}
if (nfsVersionFound) {
@@ -657,6 +671,7 @@ protected void examineStorageSubSystemCommandNfsVersion(CopyCommand cmd, EnumMap
/**
* Get storage NFS version from NfsTO
+ *
* @param nfsTO nfsTO
* @return true if NFS version was found and not null, false in other case
*/
@@ -743,7 +758,7 @@ private Answer execute(ResizeVolumeCommand cmd) {
// OfflineVmwareMigration: 3. attach the disk to the worker
vmdkDataStorePath = VmwareStorageLayoutHelper.getLegacyDatastorePathFromVmdkFileName(dsMo, path + VMDK_EXTENSION);
- vmMo.attachDisk(new String[] { vmdkDataStorePath }, morDS);
+ vmMo.attachDisk(new String[]{vmdkDataStorePath}, morDS);
}
}
@@ -773,7 +788,7 @@ private Answer execute(ResizeVolumeCommand cmd) {
// IDE virtual disk cannot be re-sized if VM is running
if (vdisk.second() != null && vdisk.second().contains("ide")) {
throw new Exception("Re-sizing a virtual disk over an IDE controller is not supported in the VMware hypervisor. " +
- "Please re-try when virtual disk is attached to a VM using a SCSI controller.");
+ "Please re-try when virtual disk is attached to a VM using a SCSI controller.");
}
if (cmd.isManaged()) {
@@ -799,16 +814,14 @@ private Answer execute(ResizeVolumeCommand cmd) {
_storageProcessor.expandDatastore(hostDatastoreSystem, dsMo);
}
- if (vdisk.second() != null && !vdisk.second().toLowerCase().startsWith("scsi"))
- {
- s_logger.error("Unsupported disk device bus "+ vdisk.second());
- throw new Exception("Unsupported disk device bus "+ vdisk.second());
+ if (vdisk.second() != null && !vdisk.second().toLowerCase().startsWith("scsi")) {
+ s_logger.error("Unsupported disk device bus " + vdisk.second());
+ throw new Exception("Unsupported disk device bus " + vdisk.second());
}
VirtualDisk disk = vdisk.first();
- if ((VirtualDiskFlatVer2BackingInfo)disk.getBacking() != null && ((VirtualDiskFlatVer2BackingInfo)disk.getBacking()).getParent() != null)
- {
- s_logger.error("Resize is not supported because Disk device has Parent "+ ((VirtualDiskFlatVer2BackingInfo)disk.getBacking()).getParent().getUuid());
- throw new Exception("Resize is not supported because Disk device has Parent "+ ((VirtualDiskFlatVer2BackingInfo)disk.getBacking()).getParent().getUuid());
+ if ((VirtualDiskFlatVer2BackingInfo) disk.getBacking() != null && ((VirtualDiskFlatVer2BackingInfo) disk.getBacking()).getParent() != null) {
+ s_logger.error("Resize is not supported because Disk device has Parent " + ((VirtualDiskFlatVer2BackingInfo) disk.getBacking()).getParent().getUuid());
+ throw new Exception("Resize is not supported because Disk device has Parent " + ((VirtualDiskFlatVer2BackingInfo) disk.getBacking()).getParent().getUuid());
}
String vmdkAbsFile = getAbsoluteVmdkFile(disk);
@@ -946,15 +959,15 @@ public ExecutionResult prepareCommand(NetworkElementCommand cmd) {
assert cmd.getRouterAccessIp() != null;
if (cmd instanceof IpAssocVpcCommand) {
- return prepareNetworkElementCommand((IpAssocVpcCommand)cmd);
+ return prepareNetworkElementCommand((IpAssocVpcCommand) cmd);
} else if (cmd instanceof IpAssocCommand) {
- return prepareNetworkElementCommand((IpAssocCommand)cmd);
+ return prepareNetworkElementCommand((IpAssocCommand) cmd);
} else if (cmd instanceof SetSourceNatCommand) {
- return prepareNetworkElementCommand((SetSourceNatCommand)cmd);
+ return prepareNetworkElementCommand((SetSourceNatCommand) cmd);
} else if (cmd instanceof SetupGuestNetworkCommand) {
- return prepareNetworkElementCommand((SetupGuestNetworkCommand)cmd);
+ return prepareNetworkElementCommand((SetupGuestNetworkCommand) cmd);
} else if (cmd instanceof SetNetworkACLCommand) {
- return prepareNetworkElementCommand((SetNetworkACLCommand)cmd);
+ return prepareNetworkElementCommand((SetNetworkACLCommand) cmd);
}
return new ExecutionResult(true, null);
}
@@ -1027,7 +1040,7 @@ private VirtualDevice findVirtualNicDevice(VirtualMachineMO vmMo, String mac) th
VirtualDevice[] nics = vmMo.getNicDevices();
for (VirtualDevice nic : nics) {
if (nic instanceof VirtualEthernetCard) {
- if (((VirtualEthernetCard)nic).getMacAddress().equals(mac))
+ if (((VirtualEthernetCard) nic).getMacAddress().equals(mac))
return nic;
}
}
@@ -1125,7 +1138,7 @@ private PlugNicAnswer execute(PlugNicCommand cmd) {
if (vmMo == null) {
if (hyperHost instanceof HostMO) {
- ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), ((HostMO)hyperHost).getParentMor());
+ ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), ((HostMO) hyperHost).getParentMor());
vmMo = clusterMo.findVmOnHyperHost(vmName);
}
}
@@ -1147,7 +1160,7 @@ private PlugNicAnswer execute(PlugNicCommand cmd) {
VirtualEthernetCardType nicDeviceType = VirtualEthernetCardType.E1000;
Map details = cmd.getDetails();
if (details != null) {
- nicDeviceType = VirtualEthernetCardType.valueOf((String)details.get("nicAdapter"));
+ nicDeviceType = VirtualEthernetCardType.valueOf((String) details.get("nicAdapter"));
}
// find a usable device number in VMware environment
@@ -1209,7 +1222,7 @@ private ReplugNicAnswer execute(ReplugNicCommand cmd) {
if (vmMo == null) {
if (hyperHost instanceof HostMO) {
- ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), ((HostMO)hyperHost).getParentMor());
+ ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), ((HostMO) hyperHost).getParentMor());
vmMo = clusterMo.findVmOnHyperHost(vmName);
}
}
@@ -1288,7 +1301,7 @@ private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
if (vmMo == null) {
if (hyperHost instanceof HostMO) {
- ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), ((HostMO)hyperHost).getParentMor());
+ ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), ((HostMO) hyperHost).getParentMor());
vmMo = clusterMo.findVmOnHyperHost(vmName);
}
}
@@ -1353,7 +1366,7 @@ private void plugPublicNic(VirtualMachineMO vmMo, final String vlanId, final IpA
try {
VirtualDevice[] nicDevices = vmMo.getNicDevices();
- VirtualEthernetCard device = (VirtualEthernetCard)nicDevices[nicIndex];
+ VirtualEthernetCard device = (VirtualEthernetCard) nicDevices[nicIndex];
if (VirtualSwitchType.StandardVirtualSwitch == vSwitchType) {
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
@@ -1423,7 +1436,7 @@ private ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) {
// the check and will try to find it within cluster
if (vmMo == null) {
if (hyperHost instanceof HostMO) {
- ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), ((HostMO)hyperHost).getParentMor());
+ ClusterMO clusterMo = new ClusterMO(hyperHost.getContext(), ((HostMO) hyperHost).getParentMor());
vmMo = clusterMo.findVmOnHyperHost(routerName);
}
}
@@ -1549,13 +1562,13 @@ private DiskTO[] validateDisks(DiskTO[] disks) {
for (DiskTO vol : disks) {
if (vol.getType() != Volume.Type.ISO) {
- VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
+ VolumeObjectTO volumeTO = (VolumeObjectTO) vol.getData();
DataStoreTO primaryStore = volumeTO.getDataStore();
if (primaryStore.getUuid() != null && !primaryStore.getUuid().isEmpty()) {
validatedDisks.add(vol);
}
} else if (vol.getType() == Volume.Type.ISO) {
- TemplateObjectTO templateTO = (TemplateObjectTO)vol.getData();
+ TemplateObjectTO templateTO = (TemplateObjectTO) vol.getData();
if (templateTO.getPath() != null && !templateTO.getPath().isEmpty()) {
validatedDisks.add(vol);
}
@@ -1612,7 +1625,7 @@ protected ScaleVmAnswer execute(ScaleVmCommand cmd) {
// Check if license supports the feature
VmwareHelper.isFeatureLicensed(hyperHost, FeatureKeyConstants.HOTPLUG);
- VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), vmSpec.getMinSpeed(), (int)requestedMaxMemoryInMb, ramMb,
+ VmwareHelper.setVmScaleUpConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), vmSpec.getMinSpeed(), (int) requestedMaxMemoryInMb, ramMb,
vmSpec.getLimitCpuUse());
if (!vmMo.configureVm(vmConfigSpec)) {
@@ -1772,9 +1785,9 @@ protected StartAnswer execute(StartCommand cmd) {
diskInfoBuilder = vmMo.getDiskInfoBuilder();
hasSnapshot = vmMo.hasSnapshot();
if (!hasSnapshot)
- vmMo.tearDownDevices(new Class>[] {VirtualDisk.class, VirtualEthernetCard.class});
+ vmMo.tearDownDevices(new Class>[]{VirtualDisk.class, VirtualEthernetCard.class});
else
- vmMo.tearDownDevices(new Class>[] {VirtualEthernetCard.class});
+ vmMo.tearDownDevices(new Class>[]{VirtualEthernetCard.class});
if (systemVm) {
ensureScsiDiskControllers(vmMo, systemVmScsiControllerType.toString(), numScsiControllerForSystemVm, firstScsiControllerBusNum);
} else {
@@ -1798,9 +1811,9 @@ protected StartAnswer execute(StartCommand cmd) {
diskInfoBuilder = vmMo.getDiskInfoBuilder();
hasSnapshot = vmMo.hasSnapshot();
if (!hasSnapshot)
- vmMo.tearDownDevices(new Class>[] {VirtualDisk.class, VirtualEthernetCard.class});
+ vmMo.tearDownDevices(new Class>[]{VirtualDisk.class, VirtualEthernetCard.class});
else
- vmMo.tearDownDevices(new Class>[] {VirtualEthernetCard.class});
+ vmMo.tearDownDevices(new Class>[]{VirtualEthernetCard.class});
if (systemVm) {
// System volumes doesn't require more than 1 SCSI controller as there is no requirement for data volumes.
@@ -1855,7 +1868,7 @@ protected StartAnswer execute(StartCommand cmd) {
}
tearDownVm(vmMo);
} else if (!hyperHost.createBlankVm(vmNameOnVcenter, vmInternalCSName, vmSpec.getCpus(), vmSpec.getMaxSpeed().intValue(), getReservedCpuMHZ(vmSpec),
- vmSpec.getLimitCpuUse(), (int)(vmSpec.getMaxRam() / ResourceType.bytesToMiB), getReservedMemoryMb(vmSpec), guestOsId, rootDiskDataStoreDetails.first(), false,
+ vmSpec.getLimitCpuUse(), (int) (vmSpec.getMaxRam() / ResourceType.bytesToMiB), getReservedMemoryMb(vmSpec), guestOsId, rootDiskDataStoreDetails.first(), false,
controllerInfo, systemVm)) {
throw new Exception("Failed to create VM. vmName: " + vmInternalCSName);
}
@@ -1881,7 +1894,7 @@ protected StartAnswer execute(StartCommand cmd) {
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
- VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int)(vmSpec.getMaxRam() / (1024 * 1024)),
+ VmwareHelper.setBasicVmConfig(vmConfigSpec, vmSpec.getCpus(), vmSpec.getMaxSpeed(), getReservedCpuMHZ(vmSpec), (int) (vmSpec.getMaxRam() / (1024 * 1024)),
getReservedMemoryMb(vmSpec), guestOsId, vmSpec.getLimitCpuUse());
// Check for multi-cores per socket settings
@@ -1899,7 +1912,7 @@ protected StartAnswer execute(StartCommand cmd) {
// Check for hotadd settings
vmConfigSpec.setMemoryHotAddEnabled(vmMo.isMemoryHotAddSupported(guestOsId));
- String hostApiVersion = ((HostMO)hyperHost).getHostAboutInfo().getApiVersion();
+ String hostApiVersion = ((HostMO) hyperHost).getHostAboutInfo().getApiVersion();
if (numCoresPerSocket > 1 && hostApiVersion.compareTo("5.0") < 0) {
s_logger.warn("Dynamic scaling of CPU is not supported for Virtual Machines with multi-core vCPUs in case of ESXi hosts 4.1 and prior. Hence CpuHotAdd will not be"
+ " enabled for Virtual Machine: " + vmInternalCSName);
@@ -2012,7 +2025,6 @@ protected StartAnswer execute(StartCommand cmd) {
}
-
//
// Setup ROOT/DATA disk devices
//
@@ -2051,7 +2063,7 @@ protected StartAnswer execute(StartCommand cmd) {
if (!hasSnapshot) {
deviceConfigSpecArray[i] = new VirtualDeviceConfigSpec();
- VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
+ VolumeObjectTO volumeTO = (VolumeObjectTO) vol.getData();
DataStoreTO primaryStore = volumeTO.getDataStore();
Map details = vol.getDetails();
boolean managed = false;
@@ -2097,7 +2109,7 @@ protected StartAnswer execute(StartCommand cmd) {
// Setup USB devices
//
if (guestOsId.startsWith("darwin")) { //Mac OS
- VirtualDevice[] devices = vmMo.getMatchedDevices(new Class>[] {VirtualUSBController.class});
+ VirtualDevice[] devices = vmMo.getMatchedDevices(new Class>[]{VirtualUSBController.class});
if (devices.length == 0) {
s_logger.debug("No USB Controller device on VM Start. Add USB Controller device for Mac OS VM " + vmInternalCSName);
@@ -2140,7 +2152,7 @@ protected StartAnswer execute(StartCommand cmd) {
for (int nicIndex = nics.length - extraPublicNics; nicIndex < nics.length; nicIndex++) {
VirtualDevice nicDevice = peerVmMo.getNicDeviceByIndex(nics[nicIndex].getDeviceId());
if (nicDevice != null) {
- String mac = ((VirtualEthernetCard)nicDevice).getMacAddress();
+ String mac = ((VirtualEthernetCard) nicDevice).getMacAddress();
if (mac != null) {
s_logger.info("Use same MAC as previous RvR, the MAC is " + mac + " for extra NIC with device id: " + nics[nicIndex].getDeviceId());
nics[nicIndex].setMac(mac);
@@ -2413,8 +2425,8 @@ protected List copyVAppConfigProductSectionFromOVF(VmConfigInfo
* and seting properties values from ovfProperties
*/
protected void copyVAppConfigsFromTemplate(VmConfigInfo vAppConfig,
- List ovfProperties,
- VirtualMachineConfigSpec vmConfig) throws Exception {
+ List ovfProperties,
+ VirtualMachineConfigSpec vmConfig) throws Exception {
VmConfigSpec vmConfigSpec = new VmConfigSpec();
vmConfigSpec.getEula().addAll(vAppConfig.getEula());
vmConfigSpec.setInstallBootStopDelay(vAppConfig.getInstallBootStopDelay());
@@ -2437,10 +2449,10 @@ private String appendFileType(String path, String fileType) {
private void resizeRootDiskOnVMStart(VirtualMachineMO vmMo, DiskTO rootDiskTO, VmwareHypervisorHost hyperHost, VmwareContext context) throws Exception {
final Pair vdisk = getVirtualDiskInfo(vmMo, appendFileType(rootDiskTO.getPath(), VMDK_EXTENSION));
- assert(vdisk != null);
+ assert (vdisk != null);
Long reqSize = 0L;
- final VolumeObjectTO volumeTO = ((VolumeObjectTO)rootDiskTO.getData());
+ final VolumeObjectTO volumeTO = ((VolumeObjectTO) rootDiskTO.getData());
if (volumeTO != null) {
reqSize = volumeTO.getSize() / 1024;
}
@@ -2452,7 +2464,7 @@ private void resizeRootDiskOnVMStart(VirtualMachineMO vmMo, DiskTO rootDiskTO, V
if (diskChain != null && diskChain.length > 1) {
s_logger.warn("Disk chain length for the VM is greater than one, this is not supported");
- throw new CloudRuntimeException("Unsupported VM disk chain length: "+ diskChain.length);
+ throw new CloudRuntimeException("Unsupported VM disk chain length: " + diskChain.length);
}
boolean resizingSupported = false;
@@ -2462,7 +2474,7 @@ private void resizeRootDiskOnVMStart(VirtualMachineMO vmMo, DiskTO rootDiskTO, V
}
if (!resizingSupported) {
s_logger.warn("Resizing of root disk is only support for scsi device/bus, the provide VM's disk device bus name is " + diskInfo.getDiskDeviceBusName());
- throw new CloudRuntimeException("Unsupported VM root disk device bus: "+ diskInfo.getDiskDeviceBusName());
+ throw new CloudRuntimeException("Unsupported VM root disk device bus: " + diskInfo.getDiskDeviceBusName());
}
disk.setCapacityInKB(reqSize);
@@ -2512,8 +2524,9 @@ protected String replaceNicsMacSequenceInBootArgs(String oldMacSequence, String
* Sets video card memory to the one provided in detail svga.vramSize (if provided) on {@code vmConfigSpec}.
* 64MB was always set before.
* Size must be in KB.
- * @param vmMo virtual machine mo
- * @param vmSpec virtual machine specs
+ *
+ * @param vmMo virtual machine mo
+ * @param vmSpec virtual machine specs
* @param vmConfigSpec virtual machine config spec
* @throws Exception exception
*/
@@ -2531,14 +2544,15 @@ protected void configureVideoCard(VirtualMachineMO vmMo, VirtualMachineTO vmSpec
/**
* Search for vm video card iterating through vm device list
- * @param vmMo virtual machine mo
+ *
+ * @param vmMo virtual machine mo
* @param svgaVmramSize new svga vram size (in KB)
- * @param vmConfigSpec virtual machine config spec
+ * @param vmConfigSpec virtual machine config spec
*/
protected void setNewVRamSizeVmVideoCard(VirtualMachineMO vmMo, long svgaVmramSize, VirtualMachineConfigSpec vmConfigSpec) throws Exception {
for (VirtualDevice device : vmMo.getAllDeviceList()) {
if (device instanceof VirtualMachineVideoCard) {
- VirtualMachineVideoCard videoCard = (VirtualMachineVideoCard)device;
+ VirtualMachineVideoCard videoCard = (VirtualMachineVideoCard) device;
modifyVmVideoCardVRamSize(videoCard, vmMo, svgaVmramSize, vmConfigSpec);
}
}
@@ -2546,10 +2560,11 @@ protected void setNewVRamSizeVmVideoCard(VirtualMachineMO vmMo, long svgaVmramSi
/**
* Modifies vm vram size if it was set to a different size to the one provided in svga.vramSize (user_vm_details or template_vm_details) on {@code vmConfigSpec}
- * @param videoCard vm's video card device
- * @param vmMo virtual machine mo
+ *
+ * @param videoCard vm's video card device
+ * @param vmMo virtual machine mo
* @param svgaVmramSize new svga vram size (in KB)
- * @param vmConfigSpec virtual machine config spec
+ * @param vmConfigSpec virtual machine config spec
*/
protected void modifyVmVideoCardVRamSize(VirtualMachineVideoCard videoCard, VirtualMachineMO vmMo, long svgaVmramSize, VirtualMachineConfigSpec vmConfigSpec) {
if (videoCard.getVideoRamSizeInKB().longValue() != svgaVmramSize) {
@@ -2560,9 +2575,10 @@ protected void modifyVmVideoCardVRamSize(VirtualMachineVideoCard videoCard, Virt
/**
* Add edit spec on {@code vmConfigSpec} to modify svga vram size
- * @param videoCard video card device to edit providing the svga vram size
+ *
+ * @param videoCard video card device to edit providing the svga vram size
* @param svgaVmramSize new svga vram size (in KB)
- * @param vmConfigSpec virtual machine spec
+ * @param vmConfigSpec virtual machine spec
*/
protected void configureSpecVideoCardNewVRamSize(VirtualMachineVideoCard videoCard, long svgaVmramSize, VirtualMachineConfigSpec vmConfigSpec) {
videoCard.setVideoRamSizeInKB(svgaVmramSize);
@@ -2583,15 +2599,15 @@ private void tearDownVm(VirtualMachineMO vmMo) throws Exception {
boolean hasSnapshot = false;
hasSnapshot = vmMo.hasSnapshot();
if (!hasSnapshot)
- vmMo.tearDownDevices(new Class>[] {VirtualDisk.class, VirtualEthernetCard.class});
+ vmMo.tearDownDevices(new Class>[]{VirtualDisk.class, VirtualEthernetCard.class});
else
- vmMo.tearDownDevices(new Class>[] {VirtualEthernetCard.class});
+ vmMo.tearDownDevices(new Class>[]{VirtualEthernetCard.class});
vmMo.ensureScsiDeviceController();
}
int getReservedMemoryMb(VirtualMachineTO vmSpec) {
if (vmSpec.getDetails().get(VMwareGuru.VmwareReserveMemory.key()).equalsIgnoreCase("true")) {
- return (int)(vmSpec.getMinRam() / ResourceType.bytesToMiB);
+ return (int) (vmSpec.getMinRam() / ResourceType.bytesToMiB);
}
return 0;
}
@@ -2605,9 +2621,9 @@ int getReservedCpuMHZ(VirtualMachineTO vmSpec) {
// return the finalized disk chain for startup, from top to bottom
private String[] syncDiskChain(DatacenterMO dcMo, VirtualMachineMO vmMo, VirtualMachineTO vmSpec, DiskTO vol, VirtualMachineDiskInfo diskInfo,
- HashMap> dataStoresDetails) throws Exception {
+ HashMap> dataStoresDetails) throws Exception {
- VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
+ VolumeObjectTO volumeTO = (VolumeObjectTO) vol.getData();
DataStoreTO primaryStore = volumeTO.getDataStore();
Map details = vol.getDetails();
boolean isManaged = false;
@@ -2653,8 +2669,7 @@ private String[] syncDiskChain(DatacenterMO dcMo, VirtualMachineMO vmMo, Virtual
}
datastoreDiskPath = VmwareStorageLayoutHelper.syncVolumeToVmDefaultFolder(dcMo, vmMo.getName(), dsMo, vmdkPath);
- }
- else {
+ } else {
if (vmdkPath == null) {
vmdkPath = dsMo.getName();
}
@@ -2669,7 +2684,7 @@ private String[] syncDiskChain(DatacenterMO dcMo, VirtualMachineMO vmMo, Virtual
s_logger.warn("Volume " + volumeTO.getId() + " does not seem to exist on datastore, out of sync? path: " + datastoreDiskPath);
}
- return new String[] {datastoreDiskPath};
+ return new String[]{datastoreDiskPath};
}
// Pair
@@ -2773,7 +2788,7 @@ private static void postNvpConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachi
VirtualDeviceBackingInfo backing = nicVirtualDevice.getBacking();
if (backing instanceof VirtualEthernetCardDistributedVirtualPortBackingInfo) {
// This NIC is connected to a Distributed Virtual Switch
- VirtualEthernetCardDistributedVirtualPortBackingInfo portInfo = (VirtualEthernetCardDistributedVirtualPortBackingInfo)backing;
+ VirtualEthernetCardDistributedVirtualPortBackingInfo portInfo = (VirtualEthernetCardDistributedVirtualPortBackingInfo) backing;
DistributedVirtualSwitchPortConnection port = portInfo.getPort();
String portKey = port.getPortKey();
String portGroupKey = port.getPortgroupKey();
@@ -2797,8 +2812,8 @@ private static void postNvpConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachi
if (portKey.equals(dvPort.getKey())) {
vmDvPort = dvPort;
}
- VMwareDVSPortSetting settings = (VMwareDVSPortSetting)dvPort.getConfig().getSetting();
- VmwareDistributedVirtualSwitchVlanIdSpec vlanId = (VmwareDistributedVirtualSwitchVlanIdSpec)settings.getVlan();
+ VMwareDVSPortSetting settings = (VMwareDVSPortSetting) dvPort.getConfig().getSetting();
+ VmwareDistributedVirtualSwitchVlanIdSpec vlanId = (VmwareDistributedVirtualSwitchVlanIdSpec) settings.getVlan();
s_logger.trace("Found port " + dvPort.getKey() + " with vlan " + vlanId.getVlanId());
if (vlanId.getVlanId() > 0 && vlanId.getVlanId() < 4095) {
usedVlans.add(vlanId.getVlanId());
@@ -2810,9 +2825,9 @@ private static void postNvpConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachi
}
DVPortConfigInfo dvPortConfigInfo = vmDvPort.getConfig();
- VMwareDVSPortSetting settings = (VMwareDVSPortSetting)dvPortConfigInfo.getSetting();
+ VMwareDVSPortSetting settings = (VMwareDVSPortSetting) dvPortConfigInfo.getSetting();
- VmwareDistributedVirtualSwitchVlanIdSpec vlanId = (VmwareDistributedVirtualSwitchVlanIdSpec)settings.getVlan();
+ VmwareDistributedVirtualSwitchVlanIdSpec vlanId = (VmwareDistributedVirtualSwitchVlanIdSpec) settings.getVlan();
BoolPolicy blocked = settings.getBlocked();
if (blocked.isValue() == Boolean.TRUE) {
s_logger.trace("Port is blocked, set a vlanid and unblock");
@@ -2864,7 +2879,7 @@ private static void postNvpConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachi
private VirtualMachineDiskInfo getMatchingExistingDisk(VirtualMachineDiskInfoBuilder diskInfoBuilder, DiskTO vol, VmwareHypervisorHost hyperHost, VmwareContext context)
throws Exception {
if (diskInfoBuilder != null) {
- VolumeObjectTO volume = (VolumeObjectTO)vol.getData();
+ VolumeObjectTO volume = (VolumeObjectTO) vol.getData();
String dsName = null;
String diskBackingFileBaseName = null;
@@ -2993,14 +3008,14 @@ private String getDiskController(VirtualMachineMO vmMo, VirtualMachineDiskInfo m
}
private void postDiskConfigBeforeStart(VirtualMachineMO vmMo, VirtualMachineTO vmSpec, DiskTO[] sortedDisks, int ideControllerKey,
- int scsiControllerKey, Map> iqnToData, VmwareHypervisorHost hyperHost, VmwareContext context) throws Exception {
+ int scsiControllerKey, Map> iqnToData, VmwareHypervisorHost hyperHost, VmwareContext context) throws Exception {
VirtualMachineDiskInfoBuilder diskInfoBuilder = vmMo.getDiskInfoBuilder();
for (DiskTO vol : sortedDisks) {
if (vol.getType() == Volume.Type.ISO)
continue;
- VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
+ VolumeObjectTO volumeTO = (VolumeObjectTO) vol.getData();
VirtualMachineDiskInfo diskInfo = getMatchingExistingDisk(diskInfoBuilder, vol, hyperHost, context);
assert (diskInfo != null);
@@ -3185,14 +3200,14 @@ public String getVmdkPath(String path) {
}
private HashMap> inferDatastoreDetailsFromDiskInfo(VmwareHypervisorHost hyperHost, VmwareContext context,
- DiskTO[] disks, Command cmd) throws Exception {
+ DiskTO[] disks, Command cmd) throws Exception {
HashMap> mapIdToMors = new HashMap<>();
assert (hyperHost != null) && (context != null);
for (DiskTO vol : disks) {
if (vol.getType() != Volume.Type.ISO) {
- VolumeObjectTO volumeTO = (VolumeObjectTO)vol.getData();
+ VolumeObjectTO volumeTO = (VolumeObjectTO) vol.getData();
DataStoreTO primaryStore = volumeTO.getDataStore();
String poolUuid = primaryStore.getUuid();
@@ -3227,8 +3242,7 @@ private HashMap> inferDatastor
if (vmdkPath != null) {
datastoreVolumePath = dsMo.getDatastorePath(vmdkPath + VMDK_EXTENSION);
- }
- else {
+ } else {
datastoreVolumePath = dsMo.getDatastorePath(dsMo.getName() + VMDK_EXTENSION);
}
@@ -3237,8 +3251,7 @@ private HashMap> inferDatastor
}
mapIdToMors.put(datastoreName, new Pair<>(morDatastore, new DatastoreMO(context, morDatastore)));
- }
- else {
+ } else {
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolUuid);
if (morDatastore == null) {
@@ -3350,8 +3363,7 @@ private Pair prepareNetworkFromNicInfo(HostMO ho
networkInfo = HypervisorHostHelper.prepareNetwork(switchName, namePrefix, hostMo,
getVlanInfo(nicTo, vlanToken), nicTo.getNetworkRateMbps(), nicTo.getNetworkRateMulticastMbps(),
_opsTimeout, true, nicTo.getBroadcastType(), nicTo.getUuid(), nicTo.getDetails());
- }
- else {
+ } else {
String vlanId = getVlanInfo(nicTo, vlanToken);
String svlanId = null;
boolean pvlannetwork = (getPvlanInfo(nicTo) == null) ? false : true;
@@ -3372,7 +3384,7 @@ private Pair prepareNetworkFromNicInfo(HostMO ho
// return Ternary
private Ternary getTargetSwitch(NicTO nicTo) throws CloudException {
- TrafficType[] supportedTrafficTypes = new TrafficType[] {TrafficType.Guest, TrafficType.Public, TrafficType.Control, TrafficType.Management, TrafficType.Storage};
+ TrafficType[] supportedTrafficTypes = new TrafficType[]{TrafficType.Guest, TrafficType.Public, TrafficType.Control, TrafficType.Management, TrafficType.Storage};
TrafficType trafficType = nicTo.getType();
if (!Arrays.asList(supportedTrafficTypes).contains(trafficType)) {
@@ -3471,7 +3483,7 @@ private Pair getIsoDatastoreInfo(VmwareHyperviso
int templateRootPos = isoUrl.indexOf("template/tmpl");
templateRootPos = (templateRootPos < 0 ? isoUrl.indexOf(ConfigDrive.CONFIGDRIVEDIR) : templateRootPos);
- if (templateRootPos < 0 ) {
+ if (templateRootPos < 0) {
throw new Exception("Invalid ISO path info");
}
@@ -3653,7 +3665,7 @@ protected Answer execute(GetVmDiskStatsCommand cmd) {
if (!(perfValue instanceof PerfEntityMetric)) {
continue;
}
- final List values = ((PerfEntityMetric)perfValue).getValue();
+ final List values = ((PerfEntityMetric) perfValue).getValue();
if (values == null || values.isEmpty()) {
continue;
}
@@ -3661,7 +3673,7 @@ protected Answer execute(GetVmDiskStatsCommand cmd) {
if (!(value instanceof PerfMetricIntSeries) || !value.getId().getInstance().equals(diskBusName)) {
continue;
}
- final List perfStats = ((PerfMetricIntSeries)value).getValue();
+ final List perfStats = ((PerfMetricIntSeries) value).getValue();
if (perfStats.size() > 0) {
long sum = 0;
for (long val : perfStats) {
@@ -3711,7 +3723,7 @@ protected GetVolumeStatsAnswer execute(GetVolumeStatsCommand cmd) {
DatacenterMO dcMo = new DatacenterMO(getServiceContext(), dcMor);
HashMap statEntry = new HashMap();
- for (String chainInfo : cmd.getVolumeUuids()){
+ for (String chainInfo : cmd.getVolumeUuids()) {
if (chainInfo != null) {
VirtualMachineDiskInfo infoInChain = _gson.fromJson(chainInfo, VirtualMachineDiskInfo.class);
if (infoInChain != null) {
@@ -3838,7 +3850,7 @@ protected Answer execute(RebootRouterCommand cmd) {
s_logger.info("Executing resource RebootRouterCommand: " + _gson.toJson(cmd));
}
- RebootAnswer answer = (RebootAnswer)execute((RebootCommand)cmd);
+ RebootAnswer answer = (RebootAnswer) execute((RebootCommand) cmd);
if (answer.getResult()) {
String connectResult = connect(cmd.getVmName(), cmd.getPrivateIpAddress());
@@ -4037,7 +4049,7 @@ protected Answer execute(MigrateVmToPoolCommand cmd) {
return new Answer(cmd, (Exception) e);
}
if (s_logger.isDebugEnabled()) {
- s_logger.debug("problem" , e);
+ s_logger.debug("problem", e);
}
s_logger.error(e.getLocalizedMessage());
return new Answer(cmd, false, "unknown problem: " + e.getLocalizedMessage());
@@ -4051,7 +4063,7 @@ private Answer migrateAndAnswer(VirtualMachineMO vmMo, String poolUuid, VmwareHy
// OfflineVmwareMigration: getVolumesFromCommand(cmd);
Map volumeDeviceKey = getVolumesFromCommand(vmMo, cmd);
if (s_logger.isTraceEnabled()) {
- for (Integer diskId: volumeDeviceKey.keySet()) {
+ for (Integer diskId : volumeDeviceKey.keySet()) {
s_logger.trace(String.format("disk to migrate has disk id %d and volumeId %d", diskId, volumeDeviceKey.get(diskId)));
}
}
@@ -4071,12 +4083,12 @@ private Answer migrateAndAnswer(VirtualMachineMO vmMo, String poolUuid, VmwareHy
} catch (Exception e) {
String msg = "change data store for VM " + vmMo.getVmName() + " failed";
s_logger.error(msg + ": " + e.getLocalizedMessage());
- throw new CloudRuntimeException(msg,e);
+ throw new CloudRuntimeException(msg, e);
}
}
Answer createAnswerForCmd(VirtualMachineMO vmMo, String poolUuid, Command cmd, Map volumeDeviceKey) throws Exception {
- List volumeToList = new ArrayList<>();
+ List volumeToList = new ArrayList<>();
VirtualMachineDiskInfoBuilder diskInfoBuilder = vmMo.getDiskInfoBuilder();
VirtualDisk[] disks = vmMo.getAllDiskDevice();
Answer answer;
@@ -4099,7 +4111,7 @@ Answer createAnswerForCmd(VirtualMachineMO vmMo, String poolUuid, Command cmd, M
newVol.setChainInfo(_gson.toJson(diskInfo));
volumeToList.add(newVol);
}
- return new MigrateVmToPoolAnswer((MigrateVmToPoolCommand)cmd, volumeToList);
+ return new MigrateVmToPoolAnswer((MigrateVmToPoolCommand) cmd, volumeToList);
}
return new Answer(cmd, false, null);
}
@@ -4107,12 +4119,12 @@ Answer createAnswerForCmd(VirtualMachineMO vmMo, String poolUuid, Command cmd, M
private Map getVolumesFromCommand(VirtualMachineMO vmMo, Command cmd) throws Exception {
Map volumeDeviceKey = new HashMap();
if (cmd instanceof MigrateVmToPoolCommand) {
- MigrateVmToPoolCommand mcmd = (MigrateVmToPoolCommand)cmd;
+ MigrateVmToPoolCommand mcmd = (MigrateVmToPoolCommand) cmd;
for (VolumeTO volume : mcmd.getVolumes()) {
addVolumeDiskmapping(vmMo, volumeDeviceKey, volume.getPath(), volume.getId());
}
} else if (cmd instanceof MigrateVolumeCommand) {
- MigrateVolumeCommand mcmd = (MigrateVolumeCommand)cmd;
+ MigrateVolumeCommand mcmd = (MigrateVolumeCommand) cmd;
addVolumeDiskmapping(vmMo, volumeDeviceKey, mcmd.getVolumePath(), mcmd.getVolumeId());
}
return volumeDeviceKey;
@@ -4134,7 +4146,7 @@ private void addVolumeDiskmapping(VirtualMachineMO vmMo, Map volu
private ManagedObjectReference getTargetDatastoreMOReference(String destinationPool, VmwareHypervisorHost hyperHost) {
ManagedObjectReference morDs;
try {
- if(s_logger.isDebugEnabled()) {
+ if (s_logger.isDebugEnabled()) {
s_logger.debug(String.format("finding datastore %s", destinationPool));
}
morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, destinationPool);
@@ -4262,7 +4274,7 @@ protected Answer execute(MigrateWithStorageCommand cmd) {
throw new CloudRuntimeException(msg);
}
VmwareManager mgr = tgtHyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- String srcHostApiVersion = ((HostMO)srcHyperHost).getHostAboutInfo().getApiVersion();
+ String srcHostApiVersion = ((HostMO) srcHyperHost).getHostAboutInfo().getApiVersion();
// find VM through datacenter (VM is not at the target host yet)
vmMo = srcHyperHost.findVmOnPeerHyperHost(vmName);
@@ -4449,7 +4461,7 @@ protected Answer execute(MigrateWithStorageCommand cmd) {
String msg = "MigrationCommand failed due to " + VmwareHelper.getExceptionMessage(e);
s_logger.warn(msg, e);
- return new MigrateWithStorageAnswer(cmd, (Exception)e);
+ return new MigrateWithStorageAnswer(cmd, (Exception) e);
} finally {
// Cleanup datastores mounted on source host
for (String mountedDatastore : mountedDatastoresAtSource) {
@@ -4482,15 +4494,15 @@ private Answer migrateVolume(MigrateVolumeCommand cmd) {
// we need to spawn a worker VM to attach the volume to and move it
vmName = getWorkerName(getServiceContext(), cmd, 0);
- // OfflineVmwareMigration: refactor for re-use
- // OfflineVmwareMigration: 1. find data(store)
+ // OfflineVmwareMigration: refactor for re-use
+ // OfflineVmwareMigration: 1. find data(store)
// OfflineVmwareMigration: more robust would be to find the store given the volume as it might have been moved out of band or due to error
// example: DatastoreMO existingVmDsMo = new DatastoreMO(dcMo.getContext(), dcMo.findDatastore(fileInDatastore.getDatastoreName()));
morSourceDS = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getSourcePool().getUuid());
dsMo = new DatastoreMO(hyperHost.getContext(), morSourceDS);
s_logger.info("Create worker VM " + vmName);
- // OfflineVmwareMigration: 2. create the worker with access to the data(store)
+ // OfflineVmwareMigration: 2. create the worker with access to the data(store)
vmMo = HypervisorHostHelper.createWorkerVM(hyperHost, dsMo, vmName);
if (vmMo == null) {
// OfflineVmwareMigration: don't throw a general Exception but think of a specific one
@@ -4502,21 +4514,21 @@ private Answer migrateVolume(MigrateVolumeCommand cmd) {
String vmdkFileName = path + VMDK_EXTENSION;
vmdkDataStorePath = VmwareStorageLayoutHelper.getLegacyDatastorePathFromVmdkFileName(dsMo, vmdkFileName);
if (!dsMo.fileExists(vmdkDataStorePath)) {
- if(s_logger.isDebugEnabled()) {
+ if (s_logger.isDebugEnabled()) {
s_logger.debug(String.format("path not found (%s), trying under '%s'", vmdkFileName, path));
}
vmdkDataStorePath = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(dsMo, path, vmdkFileName);
}
if (!dsMo.fileExists(vmdkDataStorePath)) {
- if(s_logger.isDebugEnabled()) {
+ if (s_logger.isDebugEnabled()) {
s_logger.debug(String.format("path not found (%s), trying under '%s'", vmdkFileName, vmName));
}
vmdkDataStorePath = VmwareStorageLayoutHelper.getVmwareDatastorePathFromVmdkFileName(dsMo, vmName, vmdkFileName);
}
- if(s_logger.isDebugEnabled()) {
+ if (s_logger.isDebugEnabled()) {
s_logger.debug(String.format("attaching %s to %s for migration", vmdkDataStorePath, vmMo.getVmName()));
}
- vmMo.attachDisk(new String[] { vmdkDataStorePath }, morSourceDS);
+ vmMo.attachDisk(new String[]{vmdkDataStorePath}, morSourceDS);
}
// OfflineVmwareMigration: 4. find the (worker-) VM
@@ -4532,7 +4544,7 @@ private Answer migrateVolume(MigrateVolumeCommand cmd) {
VirtualDisk[] disks = vmMo.getAllDiskDevice();
String format = "disk %d is attached as %s";
for (VirtualDisk disk : disks) {
- s_logger.trace(String.format(format,disk.getKey(),vmMo.getVmdkFileBaseName(disk)));
+ s_logger.trace(String.format(format, disk.getKey(), vmMo.getVmdkFileBaseName(disk)));
}
}
@@ -4579,7 +4591,7 @@ private Answer migrateVolume(MigrateVolumeCommand cmd) {
}
}
if (answer instanceof MigrateVolumeAnswer) {
- String newPath = ((MigrateVolumeAnswer)answer).getVolumePath();
+ String newPath = ((MigrateVolumeAnswer) answer).getVolumePath();
String vmdkFileName = newPath + VMDK_EXTENSION;
try {
VmwareStorageLayoutHelper.syncVolumeToRootFolder(dsMo.getOwnerDatacenter().first(), dsMo, newPath, vmName);
@@ -4726,7 +4738,7 @@ private VmwareHypervisorHost getTargetHyperHost(DatacenterMO dcMo, String destIp
VmwareManager mgr = dcMo.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- List ocs = dcMo.getHostPropertiesOnDatacenterHostFolder(new String[] {"name", "parent"});
+ List ocs = dcMo.getHostPropertiesOnDatacenterHostFolder(new String[]{"name", "parent"});
if (ocs != null && ocs.size() > 0) {
for (ObjectContent oc : ocs) {
HostMO hostMo = new HostMO(dcMo.getContext(), oc.getObj());
@@ -4774,15 +4786,13 @@ protected Answer execute(ModifyTargetsCommand cmd) {
hostMOs.add(hostMO);
}
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
s_logger.error(ex.getMessage(), ex);
throw new CloudRuntimeException(ex.getMessage(), ex);
}
- }
- else {
- hostMOs.add((HostMO)hyperHost);
+ } else {
+ hostMOs.add((HostMO) hyperHost);
}
handleTargets(cmd.getAdd(), cmd.getTargetTypeToRemove(), cmd.isRemoveAsync(), cmd.getTargets(), hostMOs);
@@ -4844,8 +4854,7 @@ private void handleTargets(boolean add, ModifyTargetsCommand.TargetTypeToRemove
if (targets != null && targets.size() > 0) {
try {
_storageProcessor.handleTargets(add, targetTypeToRemove, isRemoveAsync, targets, hosts);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
s_logger.warn(ex.getMessage());
}
}
@@ -5262,7 +5271,7 @@ protected Answer execute(GetVncPortCommand cmd) {
}
}
- Pair portInfo = vmMo.getVncPort(mgr.getManagementPortGroupByHost((HostMO)hyperHost));
+ Pair portInfo = vmMo.getVncPort(mgr.getManagementPortGroupByHost((HostMO) hyperHost));
if (s_logger.isTraceEnabled()) {
s_logger.trace("Found vnc port info. vm: " + cmd.getName() + " host: " + portInfo.first() + ", vnc port: " + portInfo.second());
@@ -5317,7 +5326,7 @@ protected Answer execute(PingTestCommand cmd) {
VmwareHypervisorHost hyperHost = getHyperHost(context);
try {
- HostMO hostMo = (HostMO)hyperHost;
+ HostMO hostMo = (HostMO) hyperHost;
ClusterMO clusterMo = new ClusterMO(context, hostMo.getHyperHostCluster());
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
@@ -5419,7 +5428,7 @@ public PrimaryStorageDownloadAnswer execute(PrimaryStorageDownloadCommand cmd) {
try {
VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- return (PrimaryStorageDownloadAnswer)mgr.getStorageManager().execute(this, cmd);
+ return (PrimaryStorageDownloadAnswer) mgr.getStorageManager().execute(this, cmd);
} catch (Throwable e) {
if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
@@ -5512,7 +5521,7 @@ protected Answer execute(UnregisterNicCommand cmd) {
// Get a list of all the hosts in this cluster
@SuppressWarnings("unchecked")
- List hosts = (List)context.getVimClient().getDynamicProperty(clusterMO, "host");
+ List hosts = (List) context.getVimClient().getDynamicProperty(clusterMO, "host");
if (hosts == null) {
return new Answer(cmd, false, "No hosts in cluster, which is pretty weird");
}
@@ -5557,7 +5566,7 @@ public CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
try {
VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- return (CopyVolumeAnswer)mgr.getStorageManager().execute(this, cmd);
+ return (CopyVolumeAnswer) mgr.getStorageManager().execute(this, cmd);
} catch (Throwable e) {
if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
@@ -5611,13 +5620,13 @@ private void gcAndKillHungWorkerVMs() {
s_logger.info("Scan hung worker VM to recycle");
- int workerKey = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_WORKER);
- int workerTagKey = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_WORKER_TAG);
+ int workerKey = ((HostMO) hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_WORKER);
+ int workerTagKey = ((HostMO) hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_WORKER_TAG);
String workerPropName = String.format("value[%d]", workerKey);
String workerTagPropName = String.format("value[%d]", workerTagKey);
// GC worker that has been running for too long
- ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] {"name", "config.template", workerPropName, workerTagPropName,});
+ ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[]{"name", "config.template", workerPropName, workerTagPropName,});
if (ocs != null) {
for (ObjectContent oc : ocs) {
List props = oc.getPropSet();
@@ -5628,13 +5637,13 @@ private void gcAndKillHungWorkerVMs() {
for (DynamicProperty prop : props) {
if (prop.getName().equals("config.template")) {
- template = (Boolean)prop.getVal();
+ template = (Boolean) prop.getVal();
} else if (prop.getName().equals(workerPropName)) {
- CustomFieldStringValue val = (CustomFieldStringValue)prop.getVal();
+ CustomFieldStringValue val = (CustomFieldStringValue) prop.getVal();
if (val != null && val.getValue() != null && val.getValue().equalsIgnoreCase("true"))
isWorker = true;
} else if (prop.getName().equals(workerTagPropName)) {
- CustomFieldStringValue val = (CustomFieldStringValue)prop.getVal();
+ CustomFieldStringValue val = (CustomFieldStringValue) prop.getVal();
workerTag = val.getValue();
}
}
@@ -5680,14 +5689,14 @@ public StartupCommand[] initialize() {
try {
VmwareHypervisorHost hyperHost = getHyperHost(context);
assert (hyperHost instanceof HostMO);
- if (!((HostMO)hyperHost).isHyperHostConnected()) {
+ if (!((HostMO) hyperHost).isHyperHostConnected()) {
s_logger.info("Host " + hyperHost.getHyperHostName() + " is not in connected state");
return null;
}
- ((HostMO)hyperHost).enableVncOnHostFirewall();
+ ((HostMO) hyperHost).enableVncOnHostFirewall();
- AboutInfo aboutInfo = ((HostMO)hyperHost).getHostAboutInfo();
+ AboutInfo aboutInfo = ((HostMO) hyperHost).getHostAboutInfo();
hostApiVersion = aboutInfo.getApiVersion();
} catch (Exception e) {
@@ -5723,7 +5732,7 @@ private List initializeLocalStorage() {
try {
VmwareHypervisorHost hyperHost = getHyperHost(context);
if (hyperHost instanceof HostMO) {
- HostMO hostMo = (HostMO)hyperHost;
+ HostMO hostMo = (HostMO) hyperHost;
List> dsList = hostMo.getLocalDatastoreOnHost();
for (Pair dsPair : dsList) {
@@ -5804,15 +5813,15 @@ private String getIqn() {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
if (hyperHost instanceof HostMO) {
- HostMO host = (HostMO)hyperHost;
+ HostMO host = (HostMO) hyperHost;
HostStorageSystemMO hostStorageSystem = host.getHostStorageSystemMO();
for (HostHostBusAdapter hba : hostStorageSystem.getStorageDeviceInfo().getHostBusAdapter()) {
if (hba instanceof HostInternetScsiHba) {
- HostInternetScsiHba hostInternetScsiHba = (HostInternetScsiHba)hba;
+ HostInternetScsiHba hostInternetScsiHba = (HostInternetScsiHba) hba;
if (hostInternetScsiHba.isIsSoftwareBased()) {
- return ((HostInternetScsiHba)hba).getIScsiName();
+ return ((HostInternetScsiHba) hba).getIScsiName();
}
}
}
@@ -5837,7 +5846,7 @@ private void fillHostHardwareInfo(VmwareContext serviceContext, StartupRoutingCo
cmd.setDom0MinMemory(0);
cmd.setSpeed(summary.getCpuSpeed());
cmd.setCpuSockets(summary.getCpuSockets());
- cmd.setCpus((int)summary.getCpuCount());
+ cmd.setCpus((int) summary.getCpuCount());
cmd.setMemory(summary.getMemoryBytes());
}
@@ -5849,7 +5858,7 @@ private void fillHostNetworkInfo(VmwareContext serviceContext, StartupRoutingCom
assert (hyperHost instanceof HostMO);
VmwareManager mgr = hyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
- VmwareHypervisorHostNetworkSummary summary = hyperHost.getHyperHostNetworkSummary(mgr.getManagementPortGroupByHost((HostMO)hyperHost));
+ VmwareHypervisorHostNetworkSummary summary = hyperHost.getHyperHostNetworkSummary(mgr.getManagementPortGroupByHost((HostMO) hyperHost));
if (summary == null) {
throw new Exception("No ESX(i) host found");
}
@@ -5994,7 +6003,7 @@ private VirtualMachineGuestOsIdentifier translateGuestOsIdentifier(String cpuArc
private HashMap getHostVmStateReport() throws Exception {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
- int key = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+ int key = ((HostMO) hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
if (key == 0) {
s_logger.warn("Custom field " + CustomFieldConstants.CLOUD_VM_INTERNAL_NAME + " is not registered ?!");
}
@@ -6002,7 +6011,7 @@ private HashMap getHostVmStateReport() throws Ex
// CLOUD_VM_INTERNAL_NAME stores the internal CS generated vm name. This was earlier stored in name. Now, name can be either the hostname or
// the internal CS name, but the custom field CLOUD_VM_INTERNAL_NAME always stores the internal CS name.
- ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] {"name", "runtime.powerState", "config.template", instanceNameCustomField});
+ ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[]{"name", "runtime.powerState", "config.template", instanceNameCustomField});
HashMap newStates = new HashMap();
if (ocs != null && ocs.length > 0) {
@@ -6020,12 +6029,12 @@ private HashMap getHostVmStateReport() throws Ex
isTemplate = true;
}
} else if (objProp.getName().equals("runtime.powerState")) {
- powerState = (VirtualMachinePowerState)objProp.getVal();
+ powerState = (VirtualMachinePowerState) objProp.getVal();
} else if (objProp.getName().equals("name")) {
- name = (String)objProp.getVal();
+ name = (String) objProp.getVal();
} else if (objProp.getName().contains(instanceNameCustomField)) {
if (objProp.getVal() != null)
- VMInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue();
+ VMInternalCSName = ((CustomFieldStringValue) objProp.getVal()).getValue();
} else {
assert (false);
}
@@ -6046,7 +6055,7 @@ private HashMap getHostVmStateReport() throws Ex
private HashMap getVmStates() throws Exception {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
- int key = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+ int key = ((HostMO) hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
if (key == 0) {
s_logger.warn("Custom field " + CustomFieldConstants.CLOUD_VM_INTERNAL_NAME + " is not registered ?!");
}
@@ -6054,7 +6063,7 @@ private HashMap getVmStates() throws Exception {
// CLOUD_VM_INTERNAL_NAME stores the internal CS generated vm name. This was earlier stored in name. Now, name can be either the hostname or
// the internal CS name, but the custom field CLOUD_VM_INTERNAL_NAME always stores the internal CS name.
- ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] {"name", "runtime.powerState", "config.template", instanceNameCustomField});
+ ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[]{"name", "runtime.powerState", "config.template", instanceNameCustomField});
HashMap newStates = new HashMap();
if (ocs != null && ocs.length > 0) {
@@ -6072,12 +6081,12 @@ private HashMap getVmStates() throws Exception {
isTemplate = true;
}
} else if (objProp.getName().equals("runtime.powerState")) {
- powerState = (VirtualMachinePowerState)objProp.getVal();
+ powerState = (VirtualMachinePowerState) objProp.getVal();
} else if (objProp.getName().equals("name")) {
- name = (String)objProp.getVal();
+ name = (String) objProp.getVal();
} else if (objProp.getName().contains(instanceNameCustomField)) {
if (objProp.getVal() != null)
- VMInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue();
+ VMInternalCSName = ((CustomFieldStringValue) objProp.getVal()).getValue();
} else {
assert (false);
}
@@ -6138,7 +6147,7 @@ private HashMap getVmStats(List vmNames) throws Ex
}
}
- int key = ((HostMO)hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
+ int key = ((HostMO) hyperHost).getCustomFieldKey("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
if (key == 0) {
s_logger.warn("Custom field " + CustomFieldConstants.CLOUD_VM_INTERNAL_NAME + " is not registered ?!");
}
@@ -6151,8 +6160,8 @@ private HashMap getVmStats(List vmNames) throws Ex
final String memMbStr = "config.hardware.memoryMB";
final String allocatedCpuStr = "summary.runtime.maxCpuUsage";
- ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[] {
- "name", numCpuStr, cpuUseStr, guestMemUseStr, memLimitStr, memMbStr,allocatedCpuStr, instanceNameCustomField
+ ObjectContent[] ocs = hyperHost.getVmPropertiesOnHyperHost(new String[]{
+ "name", numCpuStr, cpuUseStr, guestMemUseStr, memLimitStr, memMbStr, allocatedCpuStr, instanceNameCustomField
});
if (ocs != null && ocs.length > 0) {
@@ -6173,7 +6182,7 @@ private HashMap getVmStats(List vmNames) throws Ex
vmNameOnVcenter = objProp.getVal().toString();
} else if (objProp.getName().contains(instanceNameCustomField)) {
if (objProp.getVal() != null)
- vmInternalCSName = ((CustomFieldStringValue)objProp.getVal()).getValue();
+ vmInternalCSName = ((CustomFieldStringValue) objProp.getVal()).getValue();
} else if (objProp.getName().equals(guestMemUseStr)) {
guestMemusage = objProp.getVal().toString();
} else if (objProp.getName().equals(numCpuStr)) {
@@ -6184,12 +6193,12 @@ private HashMap getVmStats(List vmNames) throws Ex
memlimit = objProp.getVal().toString();
} else if (objProp.getName().equals(memMbStr)) {
memkb = objProp.getVal().toString();
- } else if (objProp.getName().equals(allocatedCpuStr)){
- allocatedCpu = NumberUtils.toDouble(objProp.getVal().toString());
+ } else if (objProp.getName().equals(allocatedCpuStr)) {
+ allocatedCpu = NumberUtils.toDouble(objProp.getVal().toString());
}
}
- maxCpuUsage = (maxCpuUsage/allocatedCpu)*100;
+ maxCpuUsage = (maxCpuUsage / allocatedCpu) * 100;
if (vmInternalCSName != null) {
name = vmInternalCSName;
} else {
@@ -6276,7 +6285,7 @@ private HashMap getVmStats(List vmNames) throws Ex
}
}
- final VmStatsEntry vmStats = new VmStatsEntry( NumberUtils.toDouble(memkb)*1024,NumberUtils.toDouble(guestMemusage)*1024,NumberUtils.toDouble(memlimit)*1024,
+ final VmStatsEntry vmStats = new VmStatsEntry(NumberUtils.toDouble(memkb) * 1024, NumberUtils.toDouble(guestMemusage) * 1024, NumberUtils.toDouble(memlimit) * 1024,
maxCpuUsage, networkReadKBs, networkWriteKBs, NumberUtils.toInt(numberCPUs), "vm");
vmStats.setDiskReadIOs(diskReadIops);
vmStats.setDiskWriteIOs(diskWriteIops);
@@ -6401,7 +6410,7 @@ private static HostStatsEntry getHyperHostStats(VmwareHypervisorHost hyperHost)
HostStatsEntry entry = new HostStatsEntry();
entry.setEntityType("host");
- double cpuUtilization = ((double)(hardwareSummary.getTotalCpu() - hardwareSummary.getEffectiveCpu()) / (double)hardwareSummary.getTotalCpu() * 100);
+ double cpuUtilization = ((double) (hardwareSummary.getTotalCpu() - hardwareSummary.getEffectiveCpu()) / (double) hardwareSummary.getTotalCpu() * 100);
entry.setCpuUtilization(cpuUtilization);
entry.setTotalMemoryKBs(hardwareSummary.getTotalMemory() / 1024);
entry.setFreeMemoryKBs(hardwareSummary.getEffectiveMemory() * 1024);
@@ -6435,14 +6444,14 @@ public boolean configure(String name, Map params) throws Configu
try {
_name = name;
- _url = (String)params.get("url");
- _username = (String)params.get("username");
- _password = (String)params.get("password");
- _dcId = (String)params.get("zone");
- _pod = (String)params.get("pod");
- _cluster = (String)params.get("cluster");
+ _url = (String) params.get("url");
+ _username = (String) params.get("username");
+ _password = (String) params.get("password");
+ _dcId = (String) params.get("zone");
+ _pod = (String) params.get("pod");
+ _cluster = (String) params.get("cluster");
- _guid = (String)params.get("guid");
+ _guid = (String) params.get("guid");
String[] tokens = _guid.split("@");
_vCenterAddress = tokens[1];
_morHyperHost = new ManagedObjectReference();
@@ -6450,8 +6459,8 @@ public boolean configure(String name, Map params) throws Configu
_morHyperHost.setType(hostTokens[0]);
_morHyperHost.setValue(hostTokens[1]);
- _guestTrafficInfo = (VmwareTrafficLabel)params.get("guestTrafficInfo");
- _publicTrafficInfo = (VmwareTrafficLabel)params.get("publicTrafficInfo");
+ _guestTrafficInfo = (VmwareTrafficLabel) params.get("guestTrafficInfo");
+ _publicTrafficInfo = (VmwareTrafficLabel) params.get("publicTrafficInfo");
VmwareContext context = getServiceContext();
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
if (mgr == null) {
@@ -6482,14 +6491,14 @@ public boolean configure(String name, Map params) throws Configu
}
if (_privateNetworkVSwitchName == null) {
- _privateNetworkVSwitchName = (String)params.get("private.network.vswitch.name");
+ _privateNetworkVSwitchName = (String) params.get("private.network.vswitch.name");
}
- String value = (String)params.get("vmware.recycle.hung.wokervm");
+ String value = (String) params.get("vmware.recycle.hung.wokervm");
if (value != null && value.equalsIgnoreCase("true"))
_recycleHungWorker = true;
- value = (String)params.get("vmware.root.disk.controller");
+ value = (String) params.get("vmware.root.disk.controller");
if (value != null && value.equalsIgnoreCase("scsi"))
_rootDiskController = DiskControllerType.scsi;
else if (value != null && value.equalsIgnoreCase("ide"))
@@ -6497,7 +6506,7 @@ else if (value != null && value.equalsIgnoreCase("ide"))
else
_rootDiskController = DiskControllerType.osdefault;
- Integer intObj = (Integer)params.get("ports.per.dvportgroup");
+ Integer intObj = (Integer) params.get("ports.per.dvportgroup");
if (intObj != null)
_portsPerDvPortGroup = intObj.intValue();
@@ -6505,25 +6514,25 @@ else if (value != null && value.equalsIgnoreCase("ide"))
+ _publicTrafficInfo.getVirtualSwitchType() + " : " + _publicTrafficInfo.getVirtualSwitchName() + ", guest traffic over "
+ _guestTrafficInfo.getVirtualSwitchType() + " : " + _guestTrafficInfo.getVirtualSwitchName());
- Boolean boolObj = (Boolean)params.get("vmware.create.full.clone");
+ Boolean boolObj = (Boolean) params.get("vmware.create.full.clone");
if (boolObj != null && boolObj.booleanValue()) {
_fullCloneFlag = true;
} else {
_fullCloneFlag = false;
}
- boolObj = (Boolean)params.get("vm.instancename.flag");
+ boolObj = (Boolean) params.get("vm.instancename.flag");
if (boolObj != null && boolObj.booleanValue()) {
_instanceNameFlag = true;
} else {
_instanceNameFlag = false;
}
- value = (String)params.get("scripts.timeout");
+ value = (String) params.get("scripts.timeout");
int timeout = NumbersUtil.parseInt(value, 1440) * 1000;
storageNfsVersion = NfsSecondaryStorageResource.retrieveNfsVersionFromParams(params);
- _storageProcessor = new VmwareStorageProcessor((VmwareHostService)this, _fullCloneFlag, (VmwareStorageMount)mgr, timeout, this, _shutdownWaitMs, null,
+ _storageProcessor = new VmwareStorageProcessor((VmwareHostService) this, _fullCloneFlag, (VmwareStorageMount) mgr, timeout, this, _shutdownWaitMs, null,
storageNfsVersion);
storageHandler = new VmwareStorageSubsystemCommandHandler(_storageProcessor, storageNfsVersion);
@@ -6717,11 +6726,12 @@ public Answer execute(DestroyCommand cmd) {
/**
* Use data center to look for vm, instead of randomly picking up a cluster
* (in multiple cluster environments vm could not be found if wrong cluster was chosen)
- * @param context vmware context
+ *
+ * @param context vmware context
* @param hyperHost vmware hv host
- * @param vol volume
+ * @param vol volume
* @return a virtualmachinemo if could be found on datacenter.
- * @throws Exception if there is an error while finding vm
+ * @throws Exception if there is an error while finding vm
* @throws CloudRuntimeException if datacenter cannot be found
*/
protected VirtualMachineMO findVmOnDatacenter(VmwareContext context, VmwareHypervisorHost hyperHost, VolumeTO vol) throws Exception {
@@ -6738,7 +6748,7 @@ public String getAbsoluteVmdkFile(VirtualDisk disk) {
String vmdkAbsFile = null;
VirtualDeviceBackingInfo backingInfo = disk.getBacking();
if (backingInfo instanceof VirtualDiskFlatVer2BackingInfo) {
- VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo)backingInfo;
+ VirtualDiskFlatVer2BackingInfo diskBackingInfo = (VirtualDiskFlatVer2BackingInfo) backingInfo;
vmdkAbsFile = diskBackingInfo.getFileName();
}
return vmdkAbsFile;
@@ -6777,4 +6787,220 @@ private static File fetchSystemVmKeyFile() {
}
return keyFile;
}
+
+ private List getUnmanageInstanceDisks(VirtualMachineMO vmMo) {
+ List instanceDisks = new ArrayList<>();
+ VirtualDisk[] disks = null;
+ try {
+ disks = vmMo.getAllDiskDevice();
+ } catch (Exception e) {
+ s_logger.info("Unable to retrieve unmanaged instance disks! " + e.getMessage());
+ }
+ if (disks != null) {
+ for (VirtualDevice diskDevice : disks) {
+ try {
+ if (diskDevice instanceof VirtualDisk) {
+ UnmanagedInstance.Disk instanceDisk = new UnmanagedInstance.Disk();
+ VirtualDisk disk = (VirtualDisk) diskDevice;
+ instanceDisk.setDiskId(disk.getDiskObjectId());
+ instanceDisk.setLabel(disk.getDeviceInfo() != null ? disk.getDeviceInfo().getLabel() : "");
+ instanceDisk.setImagePath(getAbsoluteVmdkFile(disk));
+ instanceDisk.setCapacity(disk.getCapacityInKB());
+ for (VirtualDevice device : vmMo.getAllDeviceList()) {
+ if (diskDevice.getControllerKey() == device.getKey()) {
+ if (device instanceof VirtualIDEController) {
+ instanceDisk.setController(DiskControllerType.getType(device.getClass().getSimpleName()).toString());
+ instanceDisk.setControllerUnit(((VirtualIDEController) device).getBusNumber());
+ } else if (device instanceof VirtualSCSIController) {
+ instanceDisk.setController("scsi");
+ instanceDisk.setControllerUnit(((VirtualSCSIController) device).getBusNumber());
+ } else {
+ instanceDisk.setController(DiskControllerType.none.toString());
+ }
+ instanceDisk.setPosition(diskDevice.getUnitNumber());
+ break;
+ }
+ }
+ s_logger.info(vmMo.getName() + " " + disk.getDeviceInfo().getLabel() + " " + disk.getDeviceInfo().getSummary() + " " + disk.getDiskObjectId() + " " + disk.getCapacityInKB() + " " + instanceDisk.getController());
+ instanceDisks.add(instanceDisk);
+ }
+ } catch (Exception e) {
+ s_logger.info("Unable to retrieve unmanaged instance disk info! " + e.getMessage());
+ }
+ }
+ Collections.sort(instanceDisks, new Comparator() {
+ @Override
+ public int compare(final UnmanagedInstance.Disk disk1, final UnmanagedInstance.Disk disk2) {
+ return extractInt(disk1) - extractInt(disk2);
+ }
+
+ int extractInt(UnmanagedInstance.Disk disk) {
+ String num = disk.getLabel().replaceAll("\\D", "");
+ // return 0 if no digits found
+ return num.isEmpty() ? 0 : Integer.parseInt(num);
+ }
+ });
+ }
+ return instanceDisks;
+ }
+
+ private List getUnmanageInstanceNics(VmwareHypervisorHost hyperHost, VirtualMachineMO vmMo) {
+ List instanceNics = new ArrayList<>();
+ boolean guestInfoAvailable = false;
+
+ HashMap guestNicMacIPAddressMap = new HashMap<>();
+ try {
+ GuestInfo guestInfo = vmMo.getGuestInfo();
+ VirtualMachineToolsStatus toolsStatus = guestInfo.getToolsStatus();
+ if (toolsStatus == VirtualMachineToolsStatus.TOOLS_NOT_INSTALLED) {
+ for (GuestNicInfo nicInfo: guestInfo.getNet()) {
+ if (!nicInfo.getIpAddress().isEmpty()) {
+ guestNicMacIPAddressMap.put(nicInfo.getMacAddress(), nicInfo.getIpAddress().get(0));
+ }
+ }
+ }
+ } catch (Exception e) {
+ s_logger.info("Unable to retrieve guest nics for instance VM tools! " + e.getMessage());
+ }
+ VirtualDevice[] nics = null;
+ try {
+ nics = vmMo.getNicDevices();
+ } catch (Exception e) {
+ s_logger.info("Unable to retrieve unmanaged instance nics! " + e.getMessage());
+ }
+ if (nics != null) {
+ for (VirtualDevice nic : nics) {
+ try {
+ VirtualEthernetCard ethCardDevice = (VirtualEthernetCard) nic;
+ s_logger.error(nic.getClass().getCanonicalName() + " " + nic.getBacking().getClass().getCanonicalName() + " " + ethCardDevice.getMacAddress());
+ UnmanagedInstance.Nic instanceNic = new UnmanagedInstance.Nic();
+ instanceNic.setNicId(ethCardDevice.getDeviceInfo().getLabel());
+ instanceNic.setAdapterType(nic.getClass().getSimpleName());
+ instanceNic.setMacAddress(ethCardDevice.getMacAddress());
+ instanceNic.setIpAddress(guestNicMacIPAddressMap.get(instanceNic.getMacAddress()));
+ if (ethCardDevice.getSlotInfo() != null) {
+ instanceNic.setPciSlot(ethCardDevice.getSlotInfo().toString());
+ }
+ VirtualDeviceBackingInfo backing = ethCardDevice.getBacking();
+ if (backing instanceof VirtualEthernetCardDistributedVirtualPortBackingInfo) {
+ VirtualEthernetCardDistributedVirtualPortBackingInfo backingInfo = (VirtualEthernetCardDistributedVirtualPortBackingInfo) backing;
+ DistributedVirtualSwitchPortConnection port = backingInfo.getPort();
+ String portKey = port.getPortKey();
+ String portGroupKey = port.getPortgroupKey();
+ String dvSwitchUuid = port.getSwitchUuid();
+
+ s_logger.debug("NIC " + nic.toString() + " is connected to dvSwitch " + dvSwitchUuid + " pg " + portGroupKey + " port " + portKey);
+
+ ManagedObjectReference dvSwitchManager = vmMo.getContext().getVimClient().getServiceContent().getDvSwitchManager();
+ ManagedObjectReference dvSwitch = vmMo.getContext().getVimClient().getService().queryDvsByUuid(dvSwitchManager, dvSwitchUuid);
+
+ // Get all ports
+ DistributedVirtualSwitchPortCriteria criteria = new DistributedVirtualSwitchPortCriteria();
+ criteria.setInside(true);
+ criteria.getPortgroupKey().add(portGroupKey);
+ List dvPorts = vmMo.getContext().getVimClient().getService().fetchDVPorts(dvSwitch, criteria);
+
+ for (DistributedVirtualPort dvPort : dvPorts) {
+ // Find the port for this NIC by portkey
+ if (portKey.equals(dvPort.getKey())) {
+ VMwareDVSPortSetting settings = (VMwareDVSPortSetting) dvPort.getConfig().getSetting();
+ VmwareDistributedVirtualSwitchVlanIdSpec vlanId = (VmwareDistributedVirtualSwitchVlanIdSpec) settings.getVlan();
+ s_logger.trace("Found port " + dvPort.getKey() + " with vlan " + vlanId.getVlanId());
+ if (vlanId.getVlanId() > 0 && vlanId.getVlanId() < 4095) {
+ instanceNic.setVlan(vlanId.getVlanId());
+ }
+ break;
+ }
+ }
+ } else if (backing instanceof VirtualEthernetCardNetworkBackingInfo) {
+ VirtualEthernetCardNetworkBackingInfo backingInfo = (VirtualEthernetCardNetworkBackingInfo) backing;
+ instanceNic.setNetwork(backingInfo.getDeviceName());
+ ManagedObjectReference mor = backingInfo.getNetwork();
+ if (hyperHost instanceof HostMO) {
+ HostMO hostMo = (HostMO) hyperHost;
+ HostPortGroupSpec portGroupSpec = hostMo.getHostPortGroupSpec(backingInfo.getDeviceName());
+ instanceNic.setVlan(portGroupSpec.getVlanId());
+ }
+ }
+ instanceNics.add(instanceNic);
+ } catch (Exception e) {
+ s_logger.info("Unable to retrieve unmanaged instance nic info! " + e.getMessage());
+ }
+ }
+ Collections.sort(instanceNics, new Comparator() {
+ @Override
+ public int compare(final UnmanagedInstance.Nic nic1, final UnmanagedInstance.Nic nic2) {
+ return extractInt(nic1) - extractInt(nic2);
+ }
+
+ int extractInt(UnmanagedInstance.Nic nic) {
+ String num = nic.getNicId().replaceAll("\\D", "");
+ // return 0 if no digits found
+ return num.isEmpty() ? 0 : Integer.parseInt(num);
+ }
+ });
+ }
+ return instanceNics;
+ }
+
+ private UnmanagedInstance getUnmanagedInstance(VmwareHypervisorHost hyperHost, VirtualMachineMO vmMo) {
+ UnmanagedInstance instance = null;
+ try {
+ instance = new UnmanagedInstance();
+ instance.setName(vmMo.getVmName());
+ instance.setCpuCores(vmMo.getConfigSummary().getNumCpu());
+ instance.setCpuCoresPerSocket(vmMo.getCoresPerSocket());
+ instance.setCpuSpeed(vmMo.getConfigSummary().getCpuReservation());
+ instance.setMemory(vmMo.getConfigSummary().getMemorySizeMB());
+ instance.setOperatingSystem(vmMo.getVmGuestInfo().getGuestFullName());
+ if (Strings.isNullOrEmpty(instance.getOperatingSystem())) {
+ instance.setOperatingSystem(vmMo.getConfigSummary().getGuestFullName());
+ }
+ instance.setPowerState(vmMo.getPowerState().toString());
+ instance.setDisks(getUnmanageInstanceDisks(vmMo));
+ instance.setNics(getUnmanageInstanceNics(hyperHost, vmMo));
+ } catch (Exception e) {
+ s_logger.info("Unable to retrieve unmanaged instance info! " + e.getMessage());
+ }
+
+ return instance;
+ }
+
+ private Answer execute(GetUnmanagedInstancesCommand cmd) {
+ if (s_logger.isInfoEnabled()) {
+ s_logger.info("Executing resource GetUnmanagedInstancesCommand " + _gson.toJson(cmd));
+ }
+
+ VmwareContext context = getServiceContext();
+ HashMap unmanagedInstances = new HashMap<>();
+ try {
+ VmwareHypervisorHost hyperHost = getHyperHost(context);
+
+ String vmName = cmd.getInstanceName();
+ List vmMos = hyperHost.listVmsOnHyperHost(vmName);
+
+ if (vmMos != null && !vmMos.isEmpty()) {
+ for (VirtualMachineMO vmMo : vmMos) {
+ if (vmMo != null && !vmMo.isTemplate()) {
+ // Filter managed instances
+ if (cmd.hasManagedInstance(vmMo.getName())) {
+ continue;
+ }
+ // Filter instance if answer is requested for a particular instance name
+ if (!Strings.isNullOrEmpty(cmd.getInstanceName()) &&
+ cmd.getInstanceName().equals(vmMo.getVmName())) {
+ continue;
+ }
+ UnmanagedInstance instance = getUnmanagedInstance(hyperHost, vmMo);
+ if (instance != null) {
+ unmanagedInstances.put(instance.getName(), instance);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ s_logger.info("GetUnmanagedInstancesCommand failed due to " + VmwareHelper.getExceptionMessage(e));
+ }
+ return new GetUnmanagedInstancesAnswer(cmd, "", unmanagedInstances);
+ }
}
diff --git a/plugins/hypervisors/xenserver/pom.xml b/plugins/hypervisors/xenserver/pom.xml
index 39146587c4fb..36cd62c55348 100644
--- a/plugins/hypervisors/xenserver/pom.xml
+++ b/plugins/hypervisors/xenserver/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/integrations/cloudian/pom.xml b/plugins/integrations/cloudian/pom.xml
index 5701fafc3966..7ed23e4a29f6 100644
--- a/plugins/integrations/cloudian/pom.xml
+++ b/plugins/integrations/cloudian/pom.xml
@@ -25,7 +25,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/integrations/prometheus/pom.xml b/plugins/integrations/prometheus/pom.xml
index 5e51a281cedc..ed66867dcb4f 100644
--- a/plugins/integrations/prometheus/pom.xml
+++ b/plugins/integrations/prometheus/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/metrics/pom.xml b/plugins/metrics/pom.xml
index fd7019c74f9b..85e2ae0aa0d9 100644
--- a/plugins/metrics/pom.xml
+++ b/plugins/metrics/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/plugins/network-elements/bigswitch/pom.xml b/plugins/network-elements/bigswitch/pom.xml
index e897b8571340..4b5237eb6571 100644
--- a/plugins/network-elements/bigswitch/pom.xml
+++ b/plugins/network-elements/bigswitch/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/brocade-vcs/pom.xml b/plugins/network-elements/brocade-vcs/pom.xml
index c1bf62681df3..52242f58a027 100644
--- a/plugins/network-elements/brocade-vcs/pom.xml
+++ b/plugins/network-elements/brocade-vcs/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/cisco-vnmc/pom.xml b/plugins/network-elements/cisco-vnmc/pom.xml
index 08e84177d69e..664e9ea9b414 100644
--- a/plugins/network-elements/cisco-vnmc/pom.xml
+++ b/plugins/network-elements/cisco-vnmc/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/dns-notifier/pom.xml b/plugins/network-elements/dns-notifier/pom.xml
index ff9b17d59767..d6b031de457a 100644
--- a/plugins/network-elements/dns-notifier/pom.xml
+++ b/plugins/network-elements/dns-notifier/pom.xml
@@ -22,7 +22,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
cloud-plugin-example-dns-notifier
diff --git a/plugins/network-elements/elastic-loadbalancer/pom.xml b/plugins/network-elements/elastic-loadbalancer/pom.xml
index 57851d429b8c..345d5f77d89c 100644
--- a/plugins/network-elements/elastic-loadbalancer/pom.xml
+++ b/plugins/network-elements/elastic-loadbalancer/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/f5/pom.xml b/plugins/network-elements/f5/pom.xml
index aa5120a090c7..9936417eb9d6 100644
--- a/plugins/network-elements/f5/pom.xml
+++ b/plugins/network-elements/f5/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/globodns/pom.xml b/plugins/network-elements/globodns/pom.xml
index e70ef23a05f0..ff0ad34ec103 100644
--- a/plugins/network-elements/globodns/pom.xml
+++ b/plugins/network-elements/globodns/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/internal-loadbalancer/pom.xml b/plugins/network-elements/internal-loadbalancer/pom.xml
index c2ae58895287..5385c84b445b 100644
--- a/plugins/network-elements/internal-loadbalancer/pom.xml
+++ b/plugins/network-elements/internal-loadbalancer/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/juniper-contrail/pom.xml b/plugins/network-elements/juniper-contrail/pom.xml
index ff8c592587d8..dc25f0f597fb 100644
--- a/plugins/network-elements/juniper-contrail/pom.xml
+++ b/plugins/network-elements/juniper-contrail/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/juniper-srx/pom.xml b/plugins/network-elements/juniper-srx/pom.xml
index 5a4b68978523..f9ae966a3a4c 100644
--- a/plugins/network-elements/juniper-srx/pom.xml
+++ b/plugins/network-elements/juniper-srx/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/netscaler/pom.xml b/plugins/network-elements/netscaler/pom.xml
index 6814eee9e426..236c0cded75e 100644
--- a/plugins/network-elements/netscaler/pom.xml
+++ b/plugins/network-elements/netscaler/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/nicira-nvp/pom.xml b/plugins/network-elements/nicira-nvp/pom.xml
index 5a13e75d0f34..440a890bfdb9 100644
--- a/plugins/network-elements/nicira-nvp/pom.xml
+++ b/plugins/network-elements/nicira-nvp/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/opendaylight/pom.xml b/plugins/network-elements/opendaylight/pom.xml
index 90a5eaffc2d1..2c1ea5eb1048 100644
--- a/plugins/network-elements/opendaylight/pom.xml
+++ b/plugins/network-elements/opendaylight/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/ovs/pom.xml b/plugins/network-elements/ovs/pom.xml
index 42e14d27d84d..e4ded35cce40 100644
--- a/plugins/network-elements/ovs/pom.xml
+++ b/plugins/network-elements/ovs/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/palo-alto/pom.xml b/plugins/network-elements/palo-alto/pom.xml
index 2122abf59d4b..b024eae21692 100644
--- a/plugins/network-elements/palo-alto/pom.xml
+++ b/plugins/network-elements/palo-alto/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/stratosphere-ssp/pom.xml b/plugins/network-elements/stratosphere-ssp/pom.xml
index 8c9467b5320b..5db1f8c6d339 100644
--- a/plugins/network-elements/stratosphere-ssp/pom.xml
+++ b/plugins/network-elements/stratosphere-ssp/pom.xml
@@ -25,7 +25,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/network-elements/vxlan/pom.xml b/plugins/network-elements/vxlan/pom.xml
index 029b2cf7f43c..b6b16fa44138 100644
--- a/plugins/network-elements/vxlan/pom.xml
+++ b/plugins/network-elements/vxlan/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/outofbandmanagement-drivers/ipmitool/pom.xml b/plugins/outofbandmanagement-drivers/ipmitool/pom.xml
index 6bb1889613c0..09b6f1c51a43 100644
--- a/plugins/outofbandmanagement-drivers/ipmitool/pom.xml
+++ b/plugins/outofbandmanagement-drivers/ipmitool/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/outofbandmanagement-drivers/nested-cloudstack/pom.xml b/plugins/outofbandmanagement-drivers/nested-cloudstack/pom.xml
index 409a337eedf0..cf5e95377616 100644
--- a/plugins/outofbandmanagement-drivers/nested-cloudstack/pom.xml
+++ b/plugins/outofbandmanagement-drivers/nested-cloudstack/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/pom.xml b/plugins/pom.xml
index cea6899db6d2..a2cb339e7fb1 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -25,7 +25,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
diff --git a/plugins/storage-allocators/random/pom.xml b/plugins/storage-allocators/random/pom.xml
index 0f389bd8db19..0048cde842f5 100644
--- a/plugins/storage-allocators/random/pom.xml
+++ b/plugins/storage-allocators/random/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/storage/image/default/pom.xml b/plugins/storage/image/default/pom.xml
index 4bc118bd860a..02a6e3a26479 100644
--- a/plugins/storage/image/default/pom.xml
+++ b/plugins/storage/image/default/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/image/s3/pom.xml b/plugins/storage/image/s3/pom.xml
index d476e371f465..13582c2b48af 100644
--- a/plugins/storage/image/s3/pom.xml
+++ b/plugins/storage/image/s3/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/image/sample/pom.xml b/plugins/storage/image/sample/pom.xml
index 53a92364373f..b0efaa2fd3db 100644
--- a/plugins/storage/image/sample/pom.xml
+++ b/plugins/storage/image/sample/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/image/swift/pom.xml b/plugins/storage/image/swift/pom.xml
index 7610eee4af5d..03962aacee2c 100644
--- a/plugins/storage/image/swift/pom.xml
+++ b/plugins/storage/image/swift/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/volume/cloudbyte/pom.xml b/plugins/storage/volume/cloudbyte/pom.xml
index a34ae465cd8d..630a32b6f36d 100644
--- a/plugins/storage/volume/cloudbyte/pom.xml
+++ b/plugins/storage/volume/cloudbyte/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/volume/datera/pom.xml b/plugins/storage/volume/datera/pom.xml
index ccd1f0c30077..53e7cc937ba8 100644
--- a/plugins/storage/volume/datera/pom.xml
+++ b/plugins/storage/volume/datera/pom.xml
@@ -16,7 +16,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/volume/default/pom.xml b/plugins/storage/volume/default/pom.xml
index d78488b064de..c20a0d40a753 100644
--- a/plugins/storage/volume/default/pom.xml
+++ b/plugins/storage/volume/default/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/volume/nexenta/pom.xml b/plugins/storage/volume/nexenta/pom.xml
index 5a87c287bc2b..798d5475baf6 100644
--- a/plugins/storage/volume/nexenta/pom.xml
+++ b/plugins/storage/volume/nexenta/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/volume/sample/pom.xml b/plugins/storage/volume/sample/pom.xml
index 915d30fe6806..5d371256863a 100644
--- a/plugins/storage/volume/sample/pom.xml
+++ b/plugins/storage/volume/sample/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/storage/volume/solidfire/pom.xml b/plugins/storage/volume/solidfire/pom.xml
index eede640a771e..1a95c1624a93 100644
--- a/plugins/storage/volume/solidfire/pom.xml
+++ b/plugins/storage/volume/solidfire/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../../pom.xml
diff --git a/plugins/user-authenticators/ldap/pom.xml b/plugins/user-authenticators/ldap/pom.xml
index 97e0d7537f6f..89cde4d6bef7 100644
--- a/plugins/user-authenticators/ldap/pom.xml
+++ b/plugins/user-authenticators/ldap/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/user-authenticators/md5/pom.xml b/plugins/user-authenticators/md5/pom.xml
index aded875419a8..0acd2786ef63 100644
--- a/plugins/user-authenticators/md5/pom.xml
+++ b/plugins/user-authenticators/md5/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/user-authenticators/pbkdf2/pom.xml b/plugins/user-authenticators/pbkdf2/pom.xml
index 898ba47a5a35..9b97a30504ea 100644
--- a/plugins/user-authenticators/pbkdf2/pom.xml
+++ b/plugins/user-authenticators/pbkdf2/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/user-authenticators/plain-text/pom.xml b/plugins/user-authenticators/plain-text/pom.xml
index 07f29cd346bc..e2ea6ba7ac93 100644
--- a/plugins/user-authenticators/plain-text/pom.xml
+++ b/plugins/user-authenticators/plain-text/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/user-authenticators/saml2/pom.xml b/plugins/user-authenticators/saml2/pom.xml
index 86644391582e..1115660272e0 100644
--- a/plugins/user-authenticators/saml2/pom.xml
+++ b/plugins/user-authenticators/saml2/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/plugins/user-authenticators/sha256salted/pom.xml b/plugins/user-authenticators/sha256salted/pom.xml
index 2fada05a6fac..7d14a74eac74 100644
--- a/plugins/user-authenticators/sha256salted/pom.xml
+++ b/plugins/user-authenticators/sha256salted/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack-plugins
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../../pom.xml
diff --git a/pom.xml b/pom.xml
index 1794f5a6b76e..29bb41ee4693 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
pom
Apache CloudStack
Apache CloudStack is an IaaS ("Infrastructure as a Service") cloud orchestration platform.
diff --git a/quickcloud/pom.xml b/quickcloud/pom.xml
index 664b7681402b..0dde23b0de6c 100644
--- a/quickcloud/pom.xml
+++ b/quickcloud/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
../pom.xml
diff --git a/server/pom.xml b/server/pom.xml
index c0ee1197dcb1..3155218f5609 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -24,7 +24,7 @@
org.apache.cloudstack
cloudstack
- 4.13.0.0-SNAPSHOT
+ 4.13.0.0
diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
index 4cb409245ac8..dd59b65051b7 100644
--- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
@@ -40,8 +40,6 @@
import javax.inject.Inject;
import javax.naming.ConfigurationException;
-import com.cloud.storage.TemplateOVFPropertyVO;
-import com.cloud.storage.dao.TemplateOVFPropertiesDao;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.affinity.AffinityGroupService;
@@ -101,7 +99,6 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
-import com.cloud.hypervisor.kvm.dpdk.DpdkHelper;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
@@ -186,6 +183,7 @@
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorCapabilitiesVO;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
+import com.cloud.hypervisor.kvm.dpdk.DpdkHelper;
import com.cloud.network.IpAddressManager;
import com.cloud.network.Network;
import com.cloud.network.Network.IpAddresses;
@@ -243,6 +241,7 @@
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolStatus;
+import com.cloud.storage.TemplateOVFPropertyVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VMTemplateZoneVO;
@@ -253,6 +252,7 @@
import com.cloud.storage.dao.GuestOSCategoryDao;
import com.cloud.storage.dao.GuestOSDao;
import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.TemplateOVFPropertiesDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplateZoneDao;
import com.cloud.storage.dao.VolumeDao;
@@ -313,6 +313,7 @@
import com.cloud.vm.snapshot.VMSnapshotVO;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
import com.google.common.base.Strings;
+import com.google.gson.Gson;
public class UserVmManagerImpl extends ManagerBase implements UserVmManager, VirtualMachineGuru, UserVmService, Configurable {
private static final Logger s_logger = Logger.getLogger(UserVmManagerImpl.class);
@@ -489,6 +490,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
@Inject
private TemplateOVFPropertiesDao templateOVFPropertiesDao;
+ protected Gson gson;
+
private ScheduledExecutorService _executor = null;
private ScheduledExecutorService _vmIpFetchExecutor = null;
private int _expungeInterval;
@@ -3822,12 +3825,12 @@ private String generateHostName(String uuidName) {
return _instance + "-" + uuidName;
}
- private UserVmVO commitUserVm(final DataCenter zone, final VirtualMachineTemplate template, final String hostName, final String displayName, final Account owner,
- final Long diskOfferingId, final Long diskSize, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
- final long accountId, final long userId, final ServiceOfferingVO offering, final boolean isIso, final String sshPublicKey, final LinkedHashMap networkNicMap,
- final long id, final String instanceName, final String uuidName, final HypervisorType hypervisorType, final Map customParameters, final Map networkNicMap,
+ final long id, final String instanceName, final String uuidName, final HypervisorType hypervisorType, final Map customParameters, final Map> extraDhcpOptionMap, final Map dataDiskTemplateToDiskOfferingMap,
- Map userVmOVFPropertiesMap) throws InsufficientCapacityException {
+ Map userVmOVFPropertiesMap) throws InsufficientCapacityException {
return Transaction.execute(new TransactionCallbackWithException() {
@Override
public UserVmVO doInTransaction(TransactionStatus status) throws InsufficientCapacityException {
@@ -3903,7 +3906,7 @@ public UserVmVO doInTransaction(TransactionStatus status) throws InsufficientCap
_vmDao.persist(vm);
for (String key : customParameters.keySet()) {
- if( key.equalsIgnoreCase(VmDetailConstants.CPU_NUMBER) ||
+ if (key.equalsIgnoreCase(VmDetailConstants.CPU_NUMBER) ||
key.equalsIgnoreCase(VmDetailConstants.CPU_SPEED) ||
key.equalsIgnoreCase(VmDetailConstants.MEMORY)) {
// handle double byte strings.
@@ -3937,27 +3940,28 @@ public UserVmVO doInTransaction(TransactionStatus status) throws InsufficientCap
}
_vmDao.saveDetails(vm);
+ if (!isImport) {
+ s_logger.debug("Allocating in the DB for vm");
+ DataCenterDeployment plan = new DataCenterDeployment(zone.getId());
- s_logger.debug("Allocating in the DB for vm");
- DataCenterDeployment plan = new DataCenterDeployment(zone.getId());
-
- List computeTags = new ArrayList();
- computeTags.add(offering.getHostTag());
+ List computeTags = new ArrayList();
+ computeTags.add(offering.getHostTag());
- List rootDiskTags = new ArrayList();
- rootDiskTags.add(offering.getTags());
+ List rootDiskTags = new ArrayList();
+ rootDiskTags.add(offering.getTags());
- if (isIso) {
- _orchSrvc.createVirtualMachineFromScratch(vm.getUuid(), Long.toString(owner.getAccountId()), vm.getIsoId().toString(), hostName, displayName,
- hypervisorType.name(), guestOSCategory.getName(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags,
- networkNicMap, plan, extraDhcpOptionMap);
- } else {
- _orchSrvc.createVirtualMachine(vm.getUuid(), Long.toString(owner.getAccountId()), Long.toString(template.getId()), hostName, displayName, hypervisorType.name(),
- offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkNicMap, plan, rootDiskSize, extraDhcpOptionMap, dataDiskTemplateToDiskOfferingMap);
- }
+ if (isIso) {
+ _orchSrvc.createVirtualMachineFromScratch(vm.getUuid(), Long.toString(owner.getAccountId()), vm.getIsoId().toString(), hostName, displayName,
+ hypervisorType.name(), guestOSCategory.getName(), offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags,
+ networkNicMap, plan, extraDhcpOptionMap);
+ } else {
+ _orchSrvc.createVirtualMachine(vm.getUuid(), Long.toString(owner.getAccountId()), Long.toString(template.getId()), hostName, displayName, hypervisorType.name(),
+ offering.getCpu(), offering.getSpeed(), offering.getRamSize(), diskSize, computeTags, rootDiskTags, networkNicMap, plan, rootDiskSize, extraDhcpOptionMap, dataDiskTemplateToDiskOfferingMap);
+ }
- if (s_logger.isDebugEnabled()) {
- s_logger.debug("Successfully allocated DB entry for " + vm);
+ if (s_logger.isDebugEnabled()) {
+ s_logger.debug("Successfully allocated DB entry for " + vm);
+ }
}
CallContext.current().setEventDetails("Vm Id: " + vm.getUuid());
@@ -3976,6 +3980,20 @@ public UserVmVO doInTransaction(TransactionStatus status) throws InsufficientCap
});
}
+ private UserVmVO commitUserVm(final DataCenter zone, final VirtualMachineTemplate template, final String hostName, final String displayName, final Account owner,
+ final Long diskOfferingId, final Long diskSize, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
+ final long accountId, final long userId, final ServiceOfferingVO offering, final boolean isIso, final String sshPublicKey, final LinkedHashMap networkNicMap,
+ final long id, final String instanceName, final String uuidName, final HypervisorType hypervisorType, final Map customParameters, final Map> extraDhcpOptionMap, final Map dataDiskTemplateToDiskOfferingMap,
+ Map userVmOVFPropertiesMap) throws InsufficientCapacityException {
+ return commitUserVm(false, zone, template, hostName, displayName, owner,
+ diskOfferingId, diskSize, userData, caller, isDisplayVm, keyboard,
+ accountId, userId, offering, isIso, sshPublicKey, networkNicMap,
+ id, instanceName, uuidName, hypervisorType, customParameters,
+ extraDhcpOptionMap, dataDiskTemplateToDiskOfferingMap,
+ userVmOVFPropertiesMap);
+ }
+
public void validateRootDiskResize(final HypervisorType hypervisorType, Long rootDiskSize, VMTemplateVO templateVO, UserVmVO vm, final Map customParameters) throws InvalidParameterValueException
{
// rootdisksize must be larger than template.
@@ -6835,4 +6853,26 @@ private void deleteVolumesFromVm(List volumes) {
}
}
}
-}
+
+ @Override
+ public UserVm importVM(final DataCenter zone, final Host host, final VirtualMachineTemplate template, final String instanceName, final String displayName,
+ final Account owner, final String userData, final Account caller, final Boolean isDisplayVm, final String keyboard,
+ final long accountId, final long userId, final ServiceOffering serviceOffering, final DiskOffering rootDiskOffering, final String sshPublicKey,
+ final String hostName, final HypervisorType hypervisorType, final Map customParameters, final VirtualMachine.PowerState powerState) throws InsufficientCapacityException {
+
+
+ final long id = _vmDao.getNextInSequence(Long.class, "id");
+
+ if (hostName != null) {
+ // Check is hostName is RFC compliant
+ checkNameForRFCCompliance(hostName);
+ }
+
+ final String uuidName = _uuidMgr.generateUuid(UserVm.class, null);
+ return commitUserVm(true, zone, template, hostName, displayName, owner,
+ rootDiskOffering.getId(), null, userData, caller, isDisplayVm, keyboard,
+ accountId, userId, serviceOffering, false, sshPublicKey, null,
+ id, instanceName, uuidName, hypervisorType, customParameters,
+ null, null, null);
+ }
+}
\ No newline at end of file
diff --git a/server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java b/server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
new file mode 100644
index 000000000000..f9c2e4fe7f59
--- /dev/null
+++ b/server/src/main/java/org/apache/cloudstack/vm/VmImportManagerImpl.java
@@ -0,0 +1,472 @@
+// 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.vm;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ResponseGenerator;
+import org.apache.cloudstack.api.ResponseObject;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.admin.ingestion.ImportUnmanageInstanceCmd;
+import org.apache.cloudstack.api.command.admin.ingestion.ListUnmanagedInstancesCmd;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.NicResponse;
+import org.apache.cloudstack.api.response.UnmanagedInstanceDiskResponse;
+import org.apache.cloudstack.api.response.UnmanagedInstanceResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+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.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.utils.volume.VirtualMachineDiskInfo;
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.GetUnmanagedInstancesAnswer;
+import com.cloud.agent.api.GetUnmanagedInstancesCommand;
+import com.cloud.dc.DataCenter;
+import com.cloud.dc.dao.ClusterDao;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.dc.dao.VlanDao;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.host.Host;
+import com.cloud.host.HostVO;
+import com.cloud.host.Status;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.network.Network;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.offering.DiskOffering;
+import com.cloud.offering.ServiceOffering;
+import com.cloud.org.Cluster;
+import com.cloud.resource.ResourceManager;
+import com.cloud.serializer.GsonHelper;
+import com.cloud.service.dao.ServiceOfferingDao;
+import com.cloud.storage.StoragePool;
+import com.cloud.storage.VMTemplateStoragePoolVO;
+import com.cloud.storage.Volume;
+import com.cloud.storage.dao.DiskOfferingDao;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VMTemplatePoolDao;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.Account;
+import com.cloud.user.AccountService;
+import com.cloud.user.UserVO;
+import com.cloud.user.dao.UserDao;
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.Pair;
+import com.cloud.utils.net.NetUtils;
+import com.cloud.vm.DiskProfile;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.UserVmService;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.dao.VMInstanceDao;
+import com.google.common.base.Strings;
+import com.google.gson.Gson;
+
+public class VmImportManagerImpl implements VmImportService {
+ private static final Logger LOGGER = Logger.getLogger(VmImportManagerImpl.class);
+
+ @Inject
+ private AgentManager agentManager;
+ @Inject
+ private DataCenterDao dataCenterDao;
+ @Inject
+ private ClusterDao clusterDao;
+ @Inject
+ private AccountService accountService;
+ @Inject
+ private UserDao userDao;
+ @Inject
+ private VMTemplateDao templateDao;
+ @Inject
+ private VMTemplatePoolDao templatePoolDao;
+ @Inject
+ private ServiceOfferingDao serviceOfferingDao;
+ @Inject
+ private DiskOfferingDao diskOfferingDao;
+ @Inject
+ private ResourceManager resourceManager;
+ @Inject
+ private UserVmService userVmService;
+ @Inject
+ public ResponseGenerator responseGenerator;
+ @Inject
+ private VolumeOrchestrationService volumeManager;
+ @Inject
+ private PrimaryDataStoreDao primaryDataStoreDao;
+ @Inject
+ private NetworkDao networkDao;
+ @Inject
+ private NetworkOrchestrationService networkOrchestrationService;
+ @Inject
+ protected VMInstanceDao _vmDao;
+ @Inject
+ protected VlanDao vlanDao;
+
+ protected Gson gson;
+
+ public VmImportManagerImpl() {
+ gson = GsonHelper.getGsonLogger();
+ }
+
+ private UnmanagedInstanceResponse createUnmanagedInstanceResponse(UnmanagedInstance instance, Cluster cluster, Host host) {
+ UnmanagedInstanceResponse response = new UnmanagedInstanceResponse();
+ response.setName(instance.getName());
+ if (cluster != null) {
+ response.setClusterId(cluster.getUuid());
+ }
+ if (host != null) {
+ response.setHostId(host.getUuid());
+ }
+ response.setPowerState(instance.getPowerState());
+ response.setCpuCores(instance.getCpuCores());
+ response.setCpuSpeed(instance.getCpuSpeed());
+ response.setCpuCoresPerSocket(instance.getCpuCoresPerSocket());
+ response.setMemory(instance.getMemory());
+ response.setOperatingSystem(instance.getOperatingSystem());
+ response.setObjectName(UnmanagedInstance.class.getSimpleName().toLowerCase());
+
+ if (instance.getDisks() != null) {
+ for (UnmanagedInstance.Disk disk : instance.getDisks()) {
+ UnmanagedInstanceDiskResponse diskResponse = new UnmanagedInstanceDiskResponse();
+ diskResponse.setDiskId(disk.getDiskId());
+ if (!Strings.isNullOrEmpty(disk.getLabel())) {
+ diskResponse.setLabel(disk.getLabel());
+ }
+ diskResponse.setCapacity(disk.getCapacity());
+ diskResponse.setController(disk.getController());
+ diskResponse.setControllerUnit(disk.getControllerUnit());
+ diskResponse.setPosition(disk.getPosition());
+ diskResponse.setImagePath(disk.getImagePath());
+ response.addDisk(diskResponse);
+ }
+ }
+
+ if (instance.getNics() != null) {
+ for (UnmanagedInstance.Nic nic : instance.getNics()) {
+ NicResponse nicResponse = new NicResponse();
+ nicResponse.setId(nic.getNicId());
+ nicResponse.setNetworkName(nic.getNetwork());
+ nicResponse.setMacAddress(nic.getMacAddress());
+ //nicResponse.setIpaddress(nic.getIpAddress());
+ nicResponse.setVlanId(nic.getVlan());
+ response.addNic(nicResponse);
+ }
+ }
+ return response;
+ }
+
+ private List getHostManagedVms(Host host) {
+ List