mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Get rid of compiler warnings in vmware-base
This commit is contained in:
parent
86124138a1
commit
b20add810e
@ -125,7 +125,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
|
public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.getValue() + ", properties: " +
|
s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.getValue() + ", properties: " +
|
||||||
new Gson().toJson(propertyPaths));
|
new Gson().toJson(propertyPaths));
|
||||||
|
|
||||||
PropertySpec pSpec = new PropertySpec();
|
PropertySpec pSpec = new PropertySpec();
|
||||||
pSpec.setType("VirtualMachine");
|
pSpec.setType("VirtualMachine");
|
||||||
@ -164,7 +164,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
|
public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.getValue() + ", properties: " +
|
s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.getValue() + ", properties: " +
|
||||||
new Gson().toJson(propertyPaths));
|
new Gson().toJson(propertyPaths));
|
||||||
|
|
||||||
PropertySpec pSpec = new PropertySpec();
|
PropertySpec pSpec = new PropertySpec();
|
||||||
pSpec.setType("Datastore");
|
pSpec.setType("Datastore");
|
||||||
@ -196,7 +196,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
private ObjectContent[] getHostPropertiesOnCluster(String[] propertyPaths) throws Exception {
|
private ObjectContent[] getHostPropertiesOnCluster(String[] propertyPaths) throws Exception {
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - retrieveProperties() on Host properties. target MOR: " + _mor.getValue() + ", properties: " +
|
s_logger.trace("vCenter API trace - retrieveProperties() on Host properties. target MOR: " + _mor.getValue() + ", properties: " +
|
||||||
new Gson().toJson(propertyPaths));
|
new Gson().toJson(propertyPaths));
|
||||||
|
|
||||||
PropertySpec pSpec = new PropertySpec();
|
PropertySpec pSpec = new PropertySpec();
|
||||||
pSpec.setType("HostSystem");
|
pSpec.setType("HostSystem");
|
||||||
@ -257,7 +257,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
public void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception {
|
public void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception {
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getValue() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName +
|
s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getValue() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName +
|
||||||
", datastore: " + dsMo.getMor().getValue() + ", diskOption: " + diskOption);
|
", datastore: " + dsMo.getMor().getValue() + ", diskOption: " + diskOption);
|
||||||
|
|
||||||
ManagedObjectReference morRp = getHyperHostOwnerResourcePool();
|
ManagedObjectReference morRp = getHyperHostOwnerResourcePool();
|
||||||
assert (morRp != null);
|
assert (morRp != null);
|
||||||
@ -273,16 +273,16 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
|
public boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
|
||||||
int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - createBlankVm(). target MOR: " + _mor.getValue() + ", vmName: " + vmName + ", cpuCount: " + cpuCount + ", cpuSpeedMhz: " +
|
s_logger.trace("vCenter API trace - createBlankVm(). target MOR: " + _mor.getValue() + ", vmName: " + vmName + ", cpuCount: " + cpuCount + ", cpuSpeedMhz: " +
|
||||||
cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB + ", guestOS: " + guestOsIdentifier +
|
cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB + ", guestOS: " + guestOsIdentifier +
|
||||||
", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
|
", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
|
||||||
|
|
||||||
boolean result =
|
boolean result =
|
||||||
HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse, memoryMB, memoryReserveMB,
|
HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse, memoryMB, memoryReserveMB,
|
||||||
guestOsIdentifier, morDs, snapshotDirToParent);
|
guestOsIdentifier, morDs, snapshotDirToParent);
|
||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - createBlankVm() done");
|
s_logger.trace("vCenter API trace - createBlankVm() done");
|
||||||
@ -295,11 +295,11 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
|
s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
|
||||||
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
|
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
|
||||||
|
|
||||||
ManagedObjectReference morDs = null;
|
ManagedObjectReference morDs = null;
|
||||||
ManagedObjectReference morDsFirst = null;
|
ManagedObjectReference morDsFirst = null;
|
||||||
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
|
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
|
||||||
if (hosts != null && hosts.size() > 0) {
|
if (hosts != null && hosts.size() > 0) {
|
||||||
for (ManagedObjectReference morHost : hosts) {
|
for (ManagedObjectReference morHost : hosts) {
|
||||||
HostMO hostMo = new HostMO(_context, morHost);
|
HostMO hostMo = new HostMO(_context, morHost);
|
||||||
@ -332,7 +332,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getValue() + ", poolUuid: " + poolUuid);
|
s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getValue() + ", poolUuid: " + poolUuid);
|
||||||
|
|
||||||
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
|
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
|
||||||
if (hosts != null && hosts.size() > 0) {
|
if (hosts != null && hosts.size() > 0) {
|
||||||
for (ManagedObjectReference morHost : hosts) {
|
for (ManagedObjectReference morHost : hosts) {
|
||||||
HostMO hostMo = new HostMO(_context, morHost);
|
HostMO hostMo = new HostMO(_context, morHost);
|
||||||
@ -480,7 +480,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
|
|
||||||
// TODO, need to use traversal to optimize retrieve of
|
// TODO, need to use traversal to optimize retrieve of
|
||||||
int cpuNumInCpuThreads = 1;
|
int cpuNumInCpuThreads = 1;
|
||||||
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
|
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
|
||||||
if (hosts != null && hosts.size() > 0) {
|
if (hosts != null && hosts.size() > 0) {
|
||||||
for (ManagedObjectReference morHost : hosts) {
|
for (ManagedObjectReference morHost : hosts) {
|
||||||
HostMO hostMo = new HostMO(_context, morHost);
|
HostMO hostMo = new HostMO(_context, morHost);
|
||||||
@ -505,7 +505,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getValue() + ", mgmtPortgroup: " + esxServiceConsolePort);
|
s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getValue() + ", mgmtPortgroup: " + esxServiceConsolePort);
|
||||||
|
|
||||||
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
|
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
|
||||||
if (hosts != null && hosts.size() > 0) {
|
if (hosts != null && hosts.size() > 0) {
|
||||||
VmwareHypervisorHostNetworkSummary summary = new HostMO(_context, hosts.get(0)).getHyperHostNetworkSummary(esxServiceConsolePort);
|
VmwareHypervisorHostNetworkSummary summary = new HostMO(_context, hosts.get(0)).getHyperHostNetworkSummary(esxServiceConsolePort);
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ public class CustomFieldsManagerMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<CustomFieldDef> getFields() throws Exception {
|
public List<CustomFieldDef> getFields() throws Exception {
|
||||||
return (List<CustomFieldDef>)_context.getVimClient().getDynamicProperty(getMor(), "field");
|
return _context.getVimClient().getDynamicProperty(getMor(), "field");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -34,6 +34,7 @@ import com.vmware.vim25.VMwareDVSPvlanMapEntry;
|
|||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
|
|
||||||
public class DistributedVirtualSwitchMO extends BaseMO {
|
public class DistributedVirtualSwitchMO extends BaseMO {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static final Logger s_logger = Logger.getLogger(DistributedVirtualSwitchMO.class);
|
private static final Logger s_logger = Logger.getLogger(DistributedVirtualSwitchMO.class);
|
||||||
|
|
||||||
public DistributedVirtualSwitchMO(VmwareContext context, ManagedObjectReference morDvs) {
|
public DistributedVirtualSwitchMO(VmwareContext context, ManagedObjectReference morDvs) {
|
||||||
@ -62,7 +63,7 @@ public class DistributedVirtualSwitchMO extends BaseMO {
|
|||||||
public TaskInfo updateVMWareDVSwitchGetTask(ManagedObjectReference dvSwitchMor, VMwareDVSConfigSpec dvsSpec) throws Exception {
|
public TaskInfo updateVMWareDVSwitchGetTask(ManagedObjectReference dvSwitchMor, VMwareDVSConfigSpec dvsSpec) throws Exception {
|
||||||
ManagedObjectReference task = _context.getService().reconfigureDvsTask(dvSwitchMor, dvsSpec);
|
ManagedObjectReference task = _context.getService().reconfigureDvsTask(dvSwitchMor, dvsSpec);
|
||||||
TaskInfo info = (TaskInfo)(_context.getVimClient().getDynamicProperty(task, "info"));
|
TaskInfo info = (TaskInfo)(_context.getVimClient().getDynamicProperty(task, "info"));
|
||||||
boolean waitvalue = _context.getVimClient().waitForTask(task);
|
_context.getVimClient().waitForTask(task);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -181,7 +181,7 @@ public class HostDatastoreSystemMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ManagedObjectReference> getDatastores() throws Exception {
|
public List<ManagedObjectReference> getDatastores() throws Exception {
|
||||||
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "datastore");
|
return _context.getVimClient().getDynamicProperty(_mor, "datastore");
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatastoreInfo getDatastoreInfo(ManagedObjectReference morDatastore) throws Exception {
|
public DatastoreInfo getDatastoreInfo(ManagedObjectReference morDatastore) throws Exception {
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import com.vmware.vim25.ManagedObjectReference;
|
|||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
|
|
||||||
public class HostFirewallSystemMO extends BaseMO {
|
public class HostFirewallSystemMO extends BaseMO {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static final Logger s_logger = Logger.getLogger(HostFirewallSystemMO.class);
|
private static final Logger s_logger = Logger.getLogger(HostFirewallSystemMO.class);
|
||||||
|
|
||||||
public HostFirewallSystemMO(VmwareContext context, ManagedObjectReference morFirewallSystem) {
|
public HostFirewallSystemMO(VmwareContext context, ManagedObjectReference morFirewallSystem) {
|
||||||
|
|||||||
@ -91,11 +91,11 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<VirtualNicManagerNetConfig> getHostVirtualNicManagerNetConfig() throws Exception {
|
public List<VirtualNicManagerNetConfig> getHostVirtualNicManagerNetConfig() throws Exception {
|
||||||
return (List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
|
return _context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HostIpRouteEntry> getHostIpRouteEntries() throws Exception {
|
public List<HostIpRouteEntry> getHostIpRouteEntries() throws Exception {
|
||||||
return (List<HostIpRouteEntry>)_context.getVimClient().getDynamicProperty(_mor, "config.network.routeTableInfo.ipRoute");
|
return _context.getVimClient().getDynamicProperty(_mor, "config.network.routeTableInfo.ipRoute");
|
||||||
}
|
}
|
||||||
|
|
||||||
public HostListSummaryQuickStats getHostQuickStats() throws Exception {
|
public HostListSummaryQuickStats getHostQuickStats() throws Exception {
|
||||||
@ -222,7 +222,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ManagedObjectReference[] getHostLocalDatastore() throws Exception {
|
public ManagedObjectReference[] getHostLocalDatastore() throws Exception {
|
||||||
List<ManagedObjectReference> datastores = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "datastore");
|
List<ManagedObjectReference> datastores = _context.getVimClient().getDynamicProperty(_mor, "datastore");
|
||||||
List<ManagedObjectReference> l = new ArrayList<ManagedObjectReference>();
|
List<ManagedObjectReference> l = new ArrayList<ManagedObjectReference>();
|
||||||
if (datastores != null) {
|
if (datastores != null) {
|
||||||
for (ManagedObjectReference mor : datastores) {
|
for (ManagedObjectReference mor : datastores) {
|
||||||
@ -235,7 +235,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HostVirtualSwitch getHostVirtualSwitchByName(String name) throws Exception {
|
public HostVirtualSwitch getHostVirtualSwitchByName(String name) throws Exception {
|
||||||
List<HostVirtualSwitch> switches = (List<HostVirtualSwitch>)_context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
|
List<HostVirtualSwitch> switches = _context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
|
||||||
|
|
||||||
if (switches != null) {
|
if (switches != null) {
|
||||||
for (HostVirtualSwitch vswitch : switches) {
|
for (HostVirtualSwitch vswitch : switches) {
|
||||||
@ -247,7 +247,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<HostVirtualSwitch> getHostVirtualSwitch() throws Exception {
|
public List<HostVirtualSwitch> getHostVirtualSwitch() throws Exception {
|
||||||
return (List<HostVirtualSwitch>)_context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
|
return _context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
|
||||||
}
|
}
|
||||||
|
|
||||||
public AboutInfo getHostAboutInfo() throws Exception {
|
public AboutInfo getHostAboutInfo() throws Exception {
|
||||||
@ -326,7 +326,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
assert (nicType != null);
|
assert (nicType != null);
|
||||||
|
|
||||||
List<VirtualNicManagerNetConfig> netConfigs =
|
List<VirtualNicManagerNetConfig> netConfigs =
|
||||||
(List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
|
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
|
||||||
|
|
||||||
if (netConfigs != null) {
|
if (netConfigs != null) {
|
||||||
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
|
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
|
||||||
@ -364,7 +364,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createPortGroup(HostVirtualSwitch vSwitch, String portGroupName, Integer vlanId, HostNetworkSecurityPolicy secPolicy,
|
public void createPortGroup(HostVirtualSwitch vSwitch, String portGroupName, Integer vlanId, HostNetworkSecurityPolicy secPolicy,
|
||||||
HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
|
HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
|
||||||
assert (portGroupName != null);
|
assert (portGroupName != null);
|
||||||
HostNetworkSystemMO hostNetMo = getHostNetworkSystemMO();
|
HostNetworkSystemMO hostNetMo = getHostNetworkSystemMO();
|
||||||
assert (hostNetMo != null);
|
assert (hostNetMo != null);
|
||||||
@ -384,7 +384,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updatePortGroup(HostVirtualSwitch vSwitch, String portGroupName, Integer vlanId, HostNetworkSecurityPolicy secPolicy,
|
public void updatePortGroup(HostVirtualSwitch vSwitch, String portGroupName, Integer vlanId, HostNetworkSecurityPolicy secPolicy,
|
||||||
HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
|
HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
|
||||||
assert (portGroupName != null);
|
assert (portGroupName != null);
|
||||||
HostNetworkSystemMO hostNetMo = getHostNetworkSystemMO();
|
HostNetworkSystemMO hostNetMo = getHostNetworkSystemMO();
|
||||||
assert (hostNetMo != null);
|
assert (hostNetMo != null);
|
||||||
@ -450,7 +450,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
public List<ManagedObjectReference> getVmMorsOnNetwork(String portGroupName) throws Exception {
|
public List<ManagedObjectReference> getVmMorsOnNetwork(String portGroupName) throws Exception {
|
||||||
ManagedObjectReference morNetwork = getNetworkMor(portGroupName);
|
ManagedObjectReference morNetwork = getNetworkMor(portGroupName);
|
||||||
if (morNetwork != null)
|
if (morNetwork != null)
|
||||||
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(morNetwork, "vm");
|
return _context.getVimClient().getDynamicProperty(morNetwork, "vm");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,7 +612,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
|
public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.getValue() + ", properties: " +
|
s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.getValue() + ", properties: " +
|
||||||
new Gson().toJson(propertyPaths));
|
new Gson().toJson(propertyPaths));
|
||||||
|
|
||||||
PropertySpec pSpec = new PropertySpec();
|
PropertySpec pSpec = new PropertySpec();
|
||||||
pSpec.setType("VirtualMachine");
|
pSpec.setType("VirtualMachine");
|
||||||
@ -645,7 +645,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
|
public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.getValue() + ", properties: " +
|
s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.getValue() + ", properties: " +
|
||||||
new Gson().toJson(propertyPaths));
|
new Gson().toJson(propertyPaths));
|
||||||
|
|
||||||
PropertySpec pSpec = new PropertySpec();
|
PropertySpec pSpec = new PropertySpec();
|
||||||
pSpec.setType("Datastore");
|
pSpec.setType("Datastore");
|
||||||
@ -710,7 +710,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
public void importVmFromOVF(String ovfFilePath, String vmName, String datastoreName, String diskOption) throws Exception {
|
public void importVmFromOVF(String ovfFilePath, String vmName, String datastoreName, String diskOption) throws Exception {
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getValue() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName +
|
s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getValue() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName +
|
||||||
",datastoreName: " + datastoreName + ", diskOption: " + diskOption);
|
",datastoreName: " + datastoreName + ", diskOption: " + diskOption);
|
||||||
|
|
||||||
DatastoreMO dsMo = getHostDatastoreMO(datastoreName);
|
DatastoreMO dsMo = getHostDatastoreMO(datastoreName);
|
||||||
if (dsMo == null)
|
if (dsMo == null)
|
||||||
@ -733,16 +733,16 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
|
public boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
|
||||||
int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - createBlankVm(). target MOR: " + _mor.getValue() + ", vmName: " + vmName + ", cpuCount: " + cpuCount + ", cpuSpeedMhz: " +
|
s_logger.trace("vCenter API trace - createBlankVm(). target MOR: " + _mor.getValue() + ", vmName: " + vmName + ", cpuCount: " + cpuCount + ", cpuSpeedMhz: " +
|
||||||
cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB + ", guestOS: " + guestOsIdentifier +
|
cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB + ", guestOS: " + guestOsIdentifier +
|
||||||
", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
|
", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
|
||||||
|
|
||||||
boolean result =
|
boolean result =
|
||||||
HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse, memoryMB, memoryReserveMB,
|
HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse, memoryMB, memoryReserveMB,
|
||||||
guestOsIdentifier, morDs, snapshotDirToParent);
|
guestOsIdentifier, morDs, snapshotDirToParent);
|
||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - createBlankVm() done");
|
s_logger.trace("vCenter API trace - createBlankVm() done");
|
||||||
@ -750,7 +750,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ManagedObjectReference getExistingDataStoreOnHost(boolean vmfsDatastore, String hostAddress, int hostPort, String path, String uuid,
|
public ManagedObjectReference getExistingDataStoreOnHost(boolean vmfsDatastore, String hostAddress, int hostPort, String path, String uuid,
|
||||||
HostDatastoreSystemMO hostDatastoreSystemMo) {
|
HostDatastoreSystemMO hostDatastoreSystemMo) {
|
||||||
// First retrieve the list of Datastores on the host.
|
// First retrieve the list of Datastores on the host.
|
||||||
List<ManagedObjectReference> morArray;
|
List<ManagedObjectReference> morArray;
|
||||||
try {
|
try {
|
||||||
@ -786,7 +786,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
|
s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
|
||||||
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
|
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
|
||||||
|
|
||||||
HostDatastoreSystemMO hostDatastoreSystemMo = getHostDatastoreSystemMO();
|
HostDatastoreSystemMO hostDatastoreSystemMo = getHostDatastoreSystemMO();
|
||||||
ManagedObjectReference morDatastore = hostDatastoreSystemMo.findDatastore(poolUuid);
|
ManagedObjectReference morDatastore = hostDatastoreSystemMo.findDatastore(poolUuid);
|
||||||
@ -796,14 +796,14 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
morDatastore = hostDatastoreSystemMo.createNfsDatastore(poolHostAddress, poolHostPort, poolPath, poolUuid);
|
morDatastore = hostDatastoreSystemMo.createNfsDatastore(poolHostAddress, poolHostPort, poolPath, poolUuid);
|
||||||
} catch (AlreadyExistsFaultMsg e) {
|
} catch (AlreadyExistsFaultMsg e) {
|
||||||
s_logger.info("Creation of NFS datastore on vCenter failed since datastore already exists." +
|
s_logger.info("Creation of NFS datastore on vCenter failed since datastore already exists." +
|
||||||
" Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
|
" Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
|
||||||
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
|
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
|
||||||
// Retrieve the morDatastore and return it.
|
// Retrieve the morDatastore and return it.
|
||||||
return (getExistingDataStoreOnHost(vmfsDatastore, poolHostAddress, poolHostPort, poolPath, poolUuid, hostDatastoreSystemMo));
|
return (getExistingDataStoreOnHost(vmfsDatastore, poolHostAddress, poolHostPort, poolPath, poolUuid, hostDatastoreSystemMo));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.info("Creation of NFS datastore on vCenter failed. " + " Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() +
|
s_logger.info("Creation of NFS datastore on vCenter failed. " + " Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() +
|
||||||
", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress + ", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " +
|
", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress + ", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " +
|
||||||
poolUuid + ". Exception mesg: " + e.getMessage());
|
poolUuid + ". Exception mesg: " + e.getMessage());
|
||||||
throw new Exception("Creation of NFS datastore on vCenter failed.");
|
throw new Exception("Creation of NFS datastore on vCenter failed.");
|
||||||
}
|
}
|
||||||
if (morDatastore == null) {
|
if (morDatastore == null) {
|
||||||
@ -905,9 +905,9 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
|
|
||||||
VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
|
VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
|
||||||
|
|
||||||
if (this.getHostType() == VmwareHostType.ESXi) {
|
if (getHostType() == VmwareHostType.ESXi) {
|
||||||
List<VirtualNicManagerNetConfig> netConfigs =
|
List<VirtualNicManagerNetConfig> netConfigs =
|
||||||
(List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
|
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
|
||||||
assert (netConfigs != null);
|
assert (netConfigs != null);
|
||||||
|
|
||||||
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
|
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
|
||||||
@ -927,7 +927,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// try with ESX path
|
// try with ESX path
|
||||||
List<HostVirtualNic> hostVNics = (List<HostVirtualNic>)_context.getVimClient().getDynamicProperty(_mor, "config.network.consoleVnic");
|
List<HostVirtualNic> hostVNics = _context.getVimClient().getDynamicProperty(_mor, "config.network.consoleVnic");
|
||||||
|
|
||||||
if (hostVNics != null) {
|
if (hostVNics != null) {
|
||||||
for (HostVirtualNic vnic : hostVNics) {
|
for (HostVirtualNic vnic : hostVNics) {
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import com.vmware.vim25.ManagedObjectReference;
|
|||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
|
|
||||||
public class HostNetworkSystemMO extends BaseMO {
|
public class HostNetworkSystemMO extends BaseMO {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static final Logger s_logger = Logger.getLogger(HostNetworkSystemMO.class);
|
private static final Logger s_logger = Logger.getLogger(HostNetworkSystemMO.class);
|
||||||
|
|
||||||
public HostNetworkSystemMO(VmwareContext context, ManagedObjectReference morNetworkSystem) {
|
public HostNetworkSystemMO(VmwareContext context, ManagedObjectReference morNetworkSystem) {
|
||||||
|
|||||||
@ -195,7 +195,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName, Integer vlanId, Integer networkRateMbps,
|
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName, Integer vlanId, Integer networkRateMbps,
|
||||||
long peakBandwidth, long burstSize, String gateway, boolean configureVServiceInNexus) throws Exception {
|
long peakBandwidth, long burstSize, String gateway, boolean configureVServiceInNexus) throws Exception {
|
||||||
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
||||||
String vsmIp = vsmCredentials.get("vsmip");
|
String vsmIp = vsmCredentials.get("vsmip");
|
||||||
String vsmUserName = vsmCredentials.get("vsmusername");
|
String vsmUserName = vsmCredentials.get("vsmusername");
|
||||||
@ -229,7 +229,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
} catch (CloudRuntimeException e) {
|
} catch (CloudRuntimeException e) {
|
||||||
msg =
|
msg =
|
||||||
"Failed to add policy map of " + policyName + " with parameters " + "committed rate = " + averageBandwidth + "peak bandwidth = " + peakBandwidth +
|
"Failed to add policy map of " + policyName + " with parameters " + "committed rate = " + averageBandwidth + "peak bandwidth = " + peakBandwidth +
|
||||||
"burst size = " + burstSize + ". Exception: " + e.toString();
|
"burst size = " + burstSize + ". Exception: " + e.toString();
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
if (netconfClient != null) {
|
if (netconfClient != null) {
|
||||||
@ -274,7 +274,7 @@ public class HypervisorHostHelper {
|
|||||||
netconfClient.addVServiceNode(vlanId.toString(), gateway);
|
netconfClient.addVServiceNode(vlanId.toString(), gateway);
|
||||||
s_logger.info("Adding port profile with vservice details configured over VLAN : " + vlanId.toString());
|
s_logger.info("Adding port profile with vservice details configured over VLAN : " + vlanId.toString());
|
||||||
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue(), vdc,
|
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue(), vdc,
|
||||||
esp);
|
esp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CloudRuntimeException e) {
|
} catch (CloudRuntimeException e) {
|
||||||
@ -305,7 +305,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updatePortProfile(VmwareContext context, String ethPortProfileName, String vethPortProfileName, Integer vlanId, Integer networkRateMbps,
|
public static void updatePortProfile(VmwareContext context, String ethPortProfileName, String vethPortProfileName, Integer vlanId, Integer networkRateMbps,
|
||||||
long peakBandwidth, long burstRate) throws Exception {
|
long peakBandwidth, long burstRate) throws Exception {
|
||||||
NetconfHelper netconfClient = null;
|
NetconfHelper netconfClient = null;
|
||||||
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
|
||||||
String vsmIp = vsmCredentials.get("vsmip");
|
String vsmIp = vsmCredentials.get("vsmip");
|
||||||
@ -346,7 +346,7 @@ public class HypervisorHostHelper {
|
|||||||
netconfClient.addPolicyMap(policyName, averageBandwidth, (int)peakBandwidth, (int)burstRate);
|
netconfClient.addPolicyMap(policyName, averageBandwidth, (int)peakBandwidth, (int)burstRate);
|
||||||
} catch (CloudRuntimeException e) {
|
} catch (CloudRuntimeException e) {
|
||||||
msg =
|
msg =
|
||||||
"Failed to add policy map of " + policyName + " with parameters " + "committed rate = " + averageBandwidth + "peak bandwidth = " + peakBandwidth +
|
"Failed to add policy map of " + policyName + " with parameters " + "committed rate = " + averageBandwidth + "peak bandwidth = " + peakBandwidth +
|
||||||
"burst size = " + burstRate + ". Exception: " + e.toString();
|
"burst size = " + burstRate + ". Exception: " + e.toString();
|
||||||
s_logger.error(msg);
|
s_logger.error(msg);
|
||||||
if (netconfClient != null) {
|
if (netconfClient != null) {
|
||||||
@ -433,8 +433,8 @@ public class HypervisorHostHelper {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public static Pair<ManagedObjectReference, String> prepareNetwork(String physicalNetwork, String namePrefix, HostMO hostMo, String vlanId, String secondaryvlanId,
|
public static Pair<ManagedObjectReference, String> prepareNetwork(String physicalNetwork, String namePrefix, HostMO hostMo, String vlanId, String secondaryvlanId,
|
||||||
Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs, VirtualSwitchType vSwitchType, int numPorts, String gateway,
|
Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs, VirtualSwitchType vSwitchType, int numPorts, String gateway,
|
||||||
boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType) throws Exception {
|
boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType) throws Exception {
|
||||||
ManagedObjectReference morNetwork = null;
|
ManagedObjectReference morNetwork = null;
|
||||||
VmwareContext context = hostMo.getContext();
|
VmwareContext context = hostMo.getContext();
|
||||||
ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
|
ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
|
||||||
@ -457,7 +457,7 @@ public class HypervisorHostHelper {
|
|||||||
* prepare networks for in this function.
|
* prepare networks for in this function.
|
||||||
*/
|
*/
|
||||||
BroadcastDomainType[] supportedBroadcastTypes =
|
BroadcastDomainType[] supportedBroadcastTypes =
|
||||||
new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan,
|
new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan,
|
||||||
BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan};
|
BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan};
|
||||||
|
|
||||||
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
|
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
|
||||||
@ -664,8 +664,8 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo,
|
private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo,
|
||||||
DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DistributedVirtualSwitchMO dvSwitchMo, int numPorts, boolean autoExpandSupported)
|
DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DistributedVirtualSwitchMO dvSwitchMo, int numPorts, boolean autoExpandSupported)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
VmwareDistributedVirtualSwitchVlanSpec vlanSpec = null;
|
VmwareDistributedVirtualSwitchVlanSpec vlanSpec = null;
|
||||||
VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
|
VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
|
||||||
VMwareDVSPortSetting dvsPortSetting = null;
|
VMwareDVSPortSetting dvsPortSetting = null;
|
||||||
@ -784,7 +784,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static VMwareDVSPortSetting createVmwareDVPortSettingSpec(DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy,
|
public static VMwareDVSPortSetting createVmwareDVPortSettingSpec(DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy,
|
||||||
VmwareDistributedVirtualSwitchVlanSpec vlanSpec) {
|
VmwareDistributedVirtualSwitchVlanSpec vlanSpec) {
|
||||||
VMwareDVSPortSetting dvsPortSetting = new VMwareDVSPortSetting();
|
VMwareDVSPortSetting dvsPortSetting = new VMwareDVSPortSetting();
|
||||||
dvsPortSetting.setVlan(vlanSpec);
|
dvsPortSetting.setVlan(vlanSpec);
|
||||||
dvsPortSetting.setSecurityPolicy(secPolicy);
|
dvsPortSetting.setSecurityPolicy(secPolicy);
|
||||||
@ -864,7 +864,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<ManagedObjectReference, String> prepareNetwork(String vSwitchName, String namePrefix, HostMO hostMo, String vlanId, Integer networkRateMbps,
|
public static Pair<ManagedObjectReference, String> prepareNetwork(String vSwitchName, String namePrefix, HostMO hostMo, String vlanId, Integer networkRateMbps,
|
||||||
Integer networkRateMulticastMbps, long timeOutMs, boolean syncPeerHosts, BroadcastDomainType broadcastDomainType, String nicUuid) throws Exception {
|
Integer networkRateMulticastMbps, long timeOutMs, boolean syncPeerHosts, BroadcastDomainType broadcastDomainType, String nicUuid) throws Exception {
|
||||||
|
|
||||||
HostVirtualSwitch vSwitch;
|
HostVirtualSwitch vSwitch;
|
||||||
if (vSwitchName == null) {
|
if (vSwitchName == null) {
|
||||||
@ -887,7 +887,7 @@ public class HypervisorHostHelper {
|
|||||||
* prepare networks for in this function.
|
* prepare networks for in this function.
|
||||||
*/
|
*/
|
||||||
BroadcastDomainType[] supportedBroadcastTypes =
|
BroadcastDomainType[] supportedBroadcastTypes =
|
||||||
new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan,
|
new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan,
|
||||||
BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan};
|
BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan};
|
||||||
|
|
||||||
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
|
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
|
||||||
@ -981,7 +981,7 @@ public class HypervisorHostHelper {
|
|||||||
try {
|
try {
|
||||||
if (lock.lock(DEFAULT_LOCK_TIMEOUT_SECONDS)) {
|
if (lock.lock(DEFAULT_LOCK_TIMEOUT_SECONDS)) {
|
||||||
try {
|
try {
|
||||||
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host");
|
List<ManagedObjectReference> hosts = hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host");
|
||||||
if (hosts != null) {
|
if (hosts != null) {
|
||||||
for (ManagedObjectReference otherHost : hosts) {
|
for (ManagedObjectReference otherHost : hosts) {
|
||||||
if (!otherHost.getValue().equals(hostMo.getMor().getValue())) {
|
if (!otherHost.getValue().equals(hostMo.getMor().getValue())) {
|
||||||
@ -990,7 +990,7 @@ public class HypervisorHostHelper {
|
|||||||
if (s_logger.isDebugEnabled())
|
if (s_logger.isDebugEnabled())
|
||||||
s_logger.debug("Prepare network on other host, vlan: " + vlanId + ", host: " + otherHostMo.getHostName());
|
s_logger.debug("Prepare network on other host, vlan: " + vlanId + ", host: " + otherHostMo.getHostName());
|
||||||
prepareNetwork(vSwitchName, namePrefix, otherHostMo, vlanId, networkRateMbps, networkRateMulticastMbps, timeOutMs, false,
|
prepareNetwork(vSwitchName, namePrefix, otherHostMo, vlanId, networkRateMbps, networkRateMulticastMbps, timeOutMs, false,
|
||||||
broadcastDomainType, nicUuid);
|
broadcastDomainType, nicUuid);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Unable to prepare network on other host, vlan: " + vlanId + ", host: " + otherHostMo.getHostName());
|
s_logger.warn("Unable to prepare network on other host, vlan: " + vlanId + ", host: " + otherHostMo.getHostName());
|
||||||
}
|
}
|
||||||
@ -1109,7 +1109,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean createBlankVm(VmwareHypervisorHost host, String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz,
|
public static boolean createBlankVm(VmwareHypervisorHost host, String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz,
|
||||||
boolean limitCpuUse, int memoryMB, int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
boolean limitCpuUse, int memoryMB, int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
|
||||||
|
|
||||||
if (s_logger.isInfoEnabled())
|
if (s_logger.isInfoEnabled())
|
||||||
s_logger.info("Create blank VM. cpuCount: " + cpuCount + ", cpuSpeed(MHz): " + cpuSpeedMHz + ", mem(Mb): " + memoryMB);
|
s_logger.info("Create blank VM. cpuCount: " + cpuCount + ", cpuSpeed(MHz): " + cpuSpeedMHz + ", mem(Mb): " + memoryMB);
|
||||||
@ -1274,7 +1274,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void importVmFromOVF(VmwareHypervisorHost host, String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption, ManagedObjectReference morRp,
|
public static void importVmFromOVF(VmwareHypervisorHost host, String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption, ManagedObjectReference morRp,
|
||||||
ManagedObjectReference morHost) throws Exception {
|
ManagedObjectReference morHost) throws Exception {
|
||||||
|
|
||||||
assert (morRp != null);
|
assert (morRp != null);
|
||||||
|
|
||||||
@ -1289,7 +1289,7 @@ public class HypervisorHostHelper {
|
|||||||
String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
|
String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
|
||||||
VmwareContext context = host.getContext();
|
VmwareContext context = host.getContext();
|
||||||
OvfCreateImportSpecResult ovfImportResult =
|
OvfCreateImportSpecResult ovfImportResult =
|
||||||
context.getService().createImportSpec(context.getServiceContent().getOvfManager(), ovfDescriptor, morRp, dsMo.getMor(), importSpecParams);
|
context.getService().createImportSpec(context.getServiceContent().getOvfManager(), ovfDescriptor, morRp, dsMo.getMor(), importSpecParams);
|
||||||
|
|
||||||
if (ovfImportResult == null) {
|
if (ovfImportResult == null) {
|
||||||
String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: " + vmName + ", diskOption: " + diskOption;
|
String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: " + vmName + ", diskOption: " + diskOption;
|
||||||
|
|||||||
@ -30,10 +30,8 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
|
|||||||
|
|
||||||
public class LicenseAssignmentManagerMO extends BaseMO {
|
public class LicenseAssignmentManagerMO extends BaseMO {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static final Logger s_logger = Logger.getLogger(LicenseAssignmentManagerMO.class);
|
private static final Logger s_logger = Logger.getLogger(LicenseAssignmentManagerMO.class);
|
||||||
private static final String LICENSE_INFO_PRODUCT_VERSION = "ProductVersion";
|
|
||||||
private static final String LICENSE_INFO_PRODUCT_NAME = "ProductName";
|
|
||||||
private static final String LICENSE_INFO_NAME = "Name";
|
|
||||||
private static final String LICENSE_INFO_FEATURE = "feature";
|
private static final String LICENSE_INFO_FEATURE = "feature";
|
||||||
|
|
||||||
public LicenseAssignmentManagerMO(VmwareContext context, ManagedObjectReference mor) {
|
public LicenseAssignmentManagerMO(VmwareContext context, ManagedObjectReference mor) {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
|
|||||||
|
|
||||||
public class LicenseManagerMO extends BaseMO {
|
public class LicenseManagerMO extends BaseMO {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static final Logger s_logger = Logger.getLogger(LicenseManagerMO.class);
|
private static final Logger s_logger = Logger.getLogger(LicenseManagerMO.class);
|
||||||
private ManagedObjectReference _licenseAssignmentManager = null;
|
private ManagedObjectReference _licenseAssignmentManager = null;
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,6 @@ public class NetworkMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ManagedObjectReference> getVMsOnNetwork() throws Exception {
|
public List<ManagedObjectReference> getVMsOnNetwork() throws Exception {
|
||||||
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "vm");
|
return _context.getVimClient().getDynamicProperty(_mor, "vm");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public class PerfManagerMO extends BaseMO {
|
|||||||
public List<PerfMetricId> queryAvailablePerfMetric(ManagedObjectReference morEntity, Calendar beginTime, Calendar endTime, Integer intervalId) throws Exception {
|
public List<PerfMetricId> queryAvailablePerfMetric(ManagedObjectReference morEntity, Calendar beginTime, Calendar endTime, Integer intervalId) throws Exception {
|
||||||
|
|
||||||
return _context.getService().queryAvailablePerfMetric(_mor, morEntity, calendarToXMLGregorianCalendar(beginTime), calendarToXMLGregorianCalendar(endTime),
|
return _context.getService().queryAvailablePerfMetric(_mor, morEntity, calendarToXMLGregorianCalendar(beginTime), calendarToXMLGregorianCalendar(endTime),
|
||||||
intervalId);
|
intervalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PerfCompositeMetric queryPerfComposite(PerfQuerySpec spec) throws Exception {
|
public PerfCompositeMetric queryPerfComposite(PerfQuerySpec spec) throws Exception {
|
||||||
@ -114,10 +114,10 @@ public class PerfManagerMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<PerfCounterInfo> getCounterInfo() throws Exception {
|
public List<PerfCounterInfo> getCounterInfo() throws Exception {
|
||||||
return (List<PerfCounterInfo>)_context.getVimClient().getDynamicProperty(_mor, "perfCounter");
|
return _context.getVimClient().getDynamicProperty(_mor, "perfCounter");
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PerfInterval> getIntervalInfo() throws Exception {
|
public List<PerfInterval> getIntervalInfo() throws Exception {
|
||||||
return (List<PerfInterval>)_context.getVimClient().getDynamicProperty(_mor, "historicalInterval");
|
return _context.getVimClient().getDynamicProperty(_mor, "historicalInterval");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import com.vmware.vim25.VirtualDiskSpec;
|
|||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
|
|
||||||
public class VirtualDiskManagerMO extends BaseMO {
|
public class VirtualDiskManagerMO extends BaseMO {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static final Logger s_logger = Logger.getLogger(VirtualDiskManagerMO.class);
|
private static final Logger s_logger = Logger.getLogger(VirtualDiskManagerMO.class);
|
||||||
|
|
||||||
public VirtualDiskManagerMO(VmwareContext context) {
|
public VirtualDiskManagerMO(VmwareContext context) {
|
||||||
@ -40,7 +41,7 @@ public class VirtualDiskManagerMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void copyVirtualDisk(String srcName, ManagedObjectReference morSrcDc, String destName, ManagedObjectReference morDestDc, VirtualDiskSpec diskSpec,
|
public void copyVirtualDisk(String srcName, ManagedObjectReference morSrcDc, String destName, ManagedObjectReference morDestDc, VirtualDiskSpec diskSpec,
|
||||||
boolean force) throws Exception {
|
boolean force) throws Exception {
|
||||||
|
|
||||||
ManagedObjectReference morTask = _context.getService().copyVirtualDiskTask(_mor, srcName, morSrcDc, destName, morDestDc, diskSpec, force);
|
ManagedObjectReference morTask = _context.getService().copyVirtualDiskTask(_mor, srcName, morSrcDc, destName, morDestDc, diskSpec, force);
|
||||||
|
|
||||||
|
|||||||
@ -489,7 +489,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String
|
public String
|
||||||
getSnapshotDiskFileDatastorePath(VirtualMachineFileInfo vmFileInfo, List<Pair<ManagedObjectReference, String>> datastoreMounts, String snapshotDiskFile)
|
getSnapshotDiskFileDatastorePath(VirtualMachineFileInfo vmFileInfo, List<Pair<ManagedObjectReference, String>> datastoreMounts, String snapshotDiskFile)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
// if file path start with "/", need to search all datastore mounts on the host in order
|
// if file path start with "/", need to search all datastore mounts on the host in order
|
||||||
@ -597,7 +597,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean createFullClone(String cloneName, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool, ManagedObjectReference morDs)
|
public boolean createFullClone(String cloneName, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool, ManagedObjectReference morDs)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
|
VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
|
||||||
VirtualMachineRelocateSpec relocSpec = new VirtualMachineRelocateSpec();
|
VirtualMachineRelocateSpec relocSpec = new VirtualMachineRelocateSpec();
|
||||||
@ -621,7 +621,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean createLinkedClone(String cloneName, ManagedObjectReference morBaseSnapshot, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool,
|
public boolean createLinkedClone(String cloneName, ManagedObjectReference morBaseSnapshot, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool,
|
||||||
ManagedObjectReference morDs) throws Exception {
|
ManagedObjectReference morDs) throws Exception {
|
||||||
|
|
||||||
assert (morBaseSnapshot != null);
|
assert (morBaseSnapshot != null);
|
||||||
assert (morFolder != null);
|
assert (morFolder != null);
|
||||||
@ -772,8 +772,8 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NetworkDetails details =
|
NetworkDetails details =
|
||||||
new NetworkDetails(name, oc.getObj(), (morVms != null ? morVms.getManagedObjectReference().toArray(
|
new NetworkDetails(name, oc.getObj(), (morVms != null ? morVms.getManagedObjectReference().toArray(
|
||||||
new ManagedObjectReference[morVms.getManagedObjectReference().size()]) : null), gcTagValue);
|
new ManagedObjectReference[morVms.getManagedObjectReference().size()]) : null), gcTagValue);
|
||||||
|
|
||||||
networks.add(details);
|
networks.add(details);
|
||||||
}
|
}
|
||||||
@ -811,13 +811,13 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
String vmxPathTokens[] = vmxFilePath.split("\\[|\\]|/");
|
String vmxPathTokens[] = vmxFilePath.split("\\[|\\]|/");
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer("https://" + _context.getServerAddress() + "/folder/");
|
StringBuffer sb = new StringBuffer("https://" + _context.getServerAddress() + "/folder/");
|
||||||
sb.append(URLEncoder.encode(vmxPathTokens[2].trim()));
|
sb.append(URLEncoder.encode(vmxPathTokens[2].trim(), "UTF-8"));
|
||||||
sb.append("/");
|
sb.append("/");
|
||||||
sb.append(URLEncoder.encode(vmxPathTokens[3].trim()));
|
sb.append(URLEncoder.encode(vmxPathTokens[3].trim(), "UTF-8"));
|
||||||
sb.append("?dcPath=");
|
sb.append("?dcPath=");
|
||||||
sb.append(URLEncoder.encode(dcInfo.second()));
|
sb.append(URLEncoder.encode(dcInfo.second(), "UTF-8"));
|
||||||
sb.append("&dsName=");
|
sb.append("&dsName=");
|
||||||
sb.append(URLEncoder.encode(vmxPathTokens[1].trim()));
|
sb.append(URLEncoder.encode(vmxPathTokens[1].trim(), "UTF-8"));
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@ -906,12 +906,12 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
||||||
public void createDisk(String vmdkDatastorePath, VirtualDiskType diskType, VirtualDiskMode diskMode, String rdmDeviceName, int sizeInMb,
|
public void createDisk(String vmdkDatastorePath, VirtualDiskType diskType, VirtualDiskMode diskMode, String rdmDeviceName, int sizeInMb,
|
||||||
ManagedObjectReference morDs, int controllerKey) throws Exception {
|
ManagedObjectReference morDs, int controllerKey) throws Exception {
|
||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - createDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + vmdkDatastorePath + ", sizeInMb: " + sizeInMb +
|
s_logger.trace("vCenter API trace - createDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + vmdkDatastorePath + ", sizeInMb: " + sizeInMb +
|
||||||
", diskType: " + diskType + ", diskMode: " + diskMode + ", rdmDeviceName: " + rdmDeviceName + ", datastore: " + morDs.getValue() + ", controllerKey: " +
|
", diskType: " + diskType + ", diskMode: " + diskMode + ", rdmDeviceName: " + rdmDeviceName + ", datastore: " + morDs.getValue() + ", controllerKey: " +
|
||||||
controllerKey);
|
controllerKey);
|
||||||
|
|
||||||
assert (vmdkDatastorePath != null);
|
assert (vmdkDatastorePath != null);
|
||||||
assert (morDs != null);
|
assert (morDs != null);
|
||||||
@ -995,7 +995,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - attachDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + new Gson().toJson(vmdkDatastorePathChain) +
|
s_logger.trace("vCenter API trace - attachDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + new Gson().toJson(vmdkDatastorePathChain) +
|
||||||
", datastore: " + morDs.getValue());
|
", datastore: " + morDs.getValue());
|
||||||
|
|
||||||
VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, null, getScsiDeviceControllerKey(), vmdkDatastorePathChain, morDs, -1, 1);
|
VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, null, getScsiDeviceControllerKey(), vmdkDatastorePathChain, morDs, -1, 1);
|
||||||
VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
|
VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
|
||||||
@ -1055,7 +1055,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - detachDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + vmdkDatastorePath + ", deleteBacking: " +
|
s_logger.trace("vCenter API trace - detachDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + vmdkDatastorePath + ", deleteBacking: " +
|
||||||
deleteBackingFile);
|
deleteBackingFile);
|
||||||
|
|
||||||
// Note: if VM has been taken snapshot, original backing file will be renamed, therefore, when we try to find the matching
|
// Note: if VM has been taken snapshot, original backing file will be renamed, therefore, when we try to find the matching
|
||||||
// VirtualDisk, we only perform prefix matching
|
// VirtualDisk, we only perform prefix matching
|
||||||
@ -1152,7 +1152,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
if (s_logger.isTraceEnabled())
|
||||||
s_logger.trace("vCenter API trace - attachIso(). target MOR: " + _mor.getValue() + ", isoDatastorePath: " + isoDatastorePath + ", datastore: " +
|
s_logger.trace("vCenter API trace - attachIso(). target MOR: " + _mor.getValue() + ", isoDatastorePath: " + isoDatastorePath + ", datastore: " +
|
||||||
morDs.getValue() + ", connect: " + connect + ", connectAtBoot: " + connectAtBoot);
|
morDs.getValue() + ", connect: " + connect + ", connectAtBoot: " + connectAtBoot);
|
||||||
|
|
||||||
assert (isoDatastorePath != null);
|
assert (isoDatastorePath != null);
|
||||||
assert (morDs != null);
|
assert (morDs != null);
|
||||||
@ -1260,7 +1260,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msg.getId())) {
|
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msg.getId())) {
|
||||||
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId() +
|
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId() +
|
||||||
", for safe operation we will automatically decline it");
|
", for safe operation we will automatically decline it");
|
||||||
vmMo.answerVM(question.getId(), "1");
|
vmMo.answerVM(question.getId(), "1");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1277,7 +1277,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
msgText = tokens[1];
|
msgText = tokens[1];
|
||||||
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msgId)) {
|
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msgId)) {
|
||||||
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + question.getId() +
|
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + question.getId() +
|
||||||
". Message id : " + msgId + ". Message text : " + msgText + ", for safe operation we will automatically decline it.");
|
". Message id : " + msgId + ". Message text : " + msgText + ", for safe operation we will automatically decline it.");
|
||||||
vmMo.answerVM(question.getId(), "1");
|
vmMo.answerVM(question.getId(), "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1609,7 +1609,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
// return the disk chain (VMDK datastore paths) for cloned snapshot
|
// return the disk chain (VMDK datastore paths) for cloned snapshot
|
||||||
public Pair<VirtualMachineMO, String[]> cloneFromCurrentSnapshot(String clonedVmName, int cpuSpeedMHz, int memoryMb, String diskDevice, ManagedObjectReference morDs)
|
public Pair<VirtualMachineMO, String[]> cloneFromCurrentSnapshot(String clonedVmName, int cpuSpeedMHz, int memoryMb, String diskDevice, ManagedObjectReference morDs)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
assert (morDs != null);
|
assert (morDs != null);
|
||||||
String[] disks = getCurrentSnapshotDiskChainDatastorePaths(diskDevice);
|
String[] disks = getCurrentSnapshotDiskChainDatastorePaths(diskDevice);
|
||||||
VirtualMachineMO clonedVm = cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs);
|
VirtualMachineMO clonedVm = cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs);
|
||||||
@ -1796,7 +1796,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getScsiDeviceControllerKey() throws Exception {
|
public int getScsiDeviceControllerKey() throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
@ -1811,7 +1811,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getScsiDeviceControllerKeyNoException() throws Exception {
|
public int getScsiDeviceControllerKeyNoException() throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
@ -1847,7 +1847,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
// return pair of VirtualDisk and disk device bus name(ide0:0, etc)
|
// return pair of VirtualDisk and disk device bus name(ide0:0, etc)
|
||||||
public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly) throws Exception {
|
public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly) throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath);
|
s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath);
|
||||||
DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
|
DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
|
||||||
@ -1893,7 +1893,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDiskCurrentTopBackingFileInChain(String deviceBusName) throws Exception {
|
public String getDiskCurrentTopBackingFileInChain(String deviceBusName) throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
if (device instanceof VirtualDisk) {
|
if (device instanceof VirtualDisk) {
|
||||||
@ -1915,7 +1915,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public VirtualDisk getDiskDeviceByDeviceBusName(String deviceBusName) throws Exception {
|
public VirtualDisk getDiskDeviceByDeviceBusName(String deviceBusName) throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
@ -1933,7 +1933,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
public VirtualMachineDiskInfoBuilder getDiskInfoBuilder() throws Exception {
|
public VirtualMachineDiskInfoBuilder getDiskInfoBuilder() throws Exception {
|
||||||
VirtualMachineDiskInfoBuilder builder = new VirtualMachineDiskInfoBuilder();
|
VirtualMachineDiskInfoBuilder builder = new VirtualMachineDiskInfoBuilder();
|
||||||
|
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
@ -2049,7 +2049,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
public List<VirtualDisk> getVirtualDisks() throws Exception {
|
public List<VirtualDisk> getVirtualDisks() throws Exception {
|
||||||
List<VirtualDisk> virtualDisks = new ArrayList<VirtualDisk>();
|
List<VirtualDisk> virtualDisks = new ArrayList<VirtualDisk>();
|
||||||
|
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
if (device instanceof VirtualDisk) {
|
if (device instanceof VirtualDisk) {
|
||||||
@ -2061,7 +2061,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> detachAllDisksExcept(String vmdkBaseName, String deviceBusName) throws Exception {
|
public List<String> detachAllDisksExcept(String vmdkBaseName, String deviceBusName) throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
|
VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
|
||||||
List<String> detachedDiskFiles = new ArrayList<String>();
|
List<String> detachedDiskFiles = new ArrayList<String>();
|
||||||
@ -2105,12 +2105,12 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<VirtualDevice> getAllDeviceList() throws Exception {
|
public List<VirtualDevice> getAllDeviceList() throws Exception {
|
||||||
return (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
return _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualDisk[] getAllDiskDevice() throws Exception {
|
public VirtualDisk[] getAllDiskDevice() throws Exception {
|
||||||
List<VirtualDisk> deviceList = new ArrayList<VirtualDisk>();
|
List<VirtualDisk> deviceList = new ArrayList<VirtualDisk>();
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
if (device instanceof VirtualDisk) {
|
if (device instanceof VirtualDisk) {
|
||||||
@ -2163,7 +2163,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int tryGetIDEDeviceControllerKey() throws Exception {
|
public int tryGetIDEDeviceControllerKey() throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
@ -2177,7 +2177,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getIDEDeviceControllerKey() throws Exception {
|
public int getIDEDeviceControllerKey() throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
@ -2197,7 +2197,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public VirtualDevice getIsoDevice() throws Exception {
|
public VirtualDevice getIsoDevice() throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
if (device instanceof VirtualCdrom) {
|
if (device instanceof VirtualCdrom) {
|
||||||
@ -2209,7 +2209,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getPCIDeviceControllerKey() throws Exception {
|
public int getPCIDeviceControllerKey() throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
@ -2229,7 +2229,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getNextDeviceNumber(int controllerKey) throws Exception {
|
public int getNextDeviceNumber(int controllerKey) throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
int deviceNumber = -1;
|
int deviceNumber = -1;
|
||||||
if (devices != null && devices.size() > 0) {
|
if (devices != null && devices.size() > 0) {
|
||||||
@ -2245,7 +2245,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<VirtualDevice> getNicDevices(boolean sorted) throws Exception {
|
private List<VirtualDevice> getNicDevices(boolean sorted) throws Exception {
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
List<VirtualDevice> nics = new ArrayList<VirtualDevice>();
|
List<VirtualDevice> nics = new ArrayList<VirtualDevice>();
|
||||||
if (devices != null) {
|
if (devices != null) {
|
||||||
@ -2325,7 +2325,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
|
|
||||||
List<VirtualDevice> returnList = new ArrayList<VirtualDevice>();
|
List<VirtualDevice> returnList = new ArrayList<VirtualDevice>();
|
||||||
|
|
||||||
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
|
||||||
|
|
||||||
if (devices != null) {
|
if (devices != null) {
|
||||||
for (VirtualDevice device : devices) {
|
for (VirtualDevice device : devices) {
|
||||||
@ -2346,7 +2346,6 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean unmountToolsInstaller() throws Exception {
|
public boolean unmountToolsInstaller() throws Exception {
|
||||||
int i = 1;
|
|
||||||
// Monitor VM questions
|
// Monitor VM questions
|
||||||
final Boolean[] flags = {false};
|
final Boolean[] flags = {false};
|
||||||
final VirtualMachineMO vmMo = this;
|
final VirtualMachineMO vmMo = this;
|
||||||
@ -2376,7 +2375,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
}
|
}
|
||||||
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msg.getId())) {
|
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msg.getId())) {
|
||||||
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId() +
|
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId() +
|
||||||
", for safe operation we will automatically decline it");
|
", for safe operation we will automatically decline it");
|
||||||
vmMo.answerVM(question.getId(), "1");
|
vmMo.answerVM(question.getId(), "1");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2393,7 +2392,7 @@ public class VirtualMachineMO extends BaseMO {
|
|||||||
msgText = tokens[1];
|
msgText = tokens[1];
|
||||||
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msgId)) {
|
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msgId)) {
|
||||||
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + question.getId() +
|
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + question.getId() +
|
||||||
". Message id : " + msgId + ". Message text : " + msgText + ", for safe operation we will automatically decline it.");
|
". Message id : " + msgId + ". Message text : " + msgText + ", for safe operation we will automatically decline it.");
|
||||||
vmMo.answerVM(question.getId(), "1");
|
vmMo.answerVM(question.getId(), "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,8 +27,8 @@ import javax.net.ssl.HostnameVerifier;
|
|||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLSession;
|
import javax.net.ssl.SSLSession;
|
||||||
import javax.xml.ws.BindingProvider;
|
import javax.xml.ws.BindingProvider;
|
||||||
import javax.xml.ws.handler.MessageContext;
|
|
||||||
import javax.xml.ws.WebServiceException;
|
import javax.xml.ws.WebServiceException;
|
||||||
|
import javax.xml.ws.handler.MessageContext;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
@ -144,6 +144,7 @@ public class VmwareClient {
|
|||||||
ServiceContent serviceContent = vimPort.retrieveServiceContent(svcInstRef);
|
ServiceContent serviceContent = vimPort.retrieveServiceContent(svcInstRef);
|
||||||
|
|
||||||
// Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
|
// Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, List<String>> headers = (Map<String, List<String>>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
|
Map<String, List<String>> headers = (Map<String, List<String>>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
|
||||||
List<String> cookies = headers.get("Set-cookie");
|
List<String> cookies = headers.get("Set-cookie");
|
||||||
String cookieValue = cookies.get(0);
|
String cookieValue = cookies.get(0);
|
||||||
@ -256,17 +257,18 @@ public class VmwareClient {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
* in case of error.
|
* in case of error.
|
||||||
*/
|
*/
|
||||||
public Object getDynamicProperty(ManagedObjectReference mor, String propertyName) throws Exception {
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T> T getDynamicProperty(ManagedObjectReference mor, String propertyName) throws Exception {
|
||||||
List<String> props = new ArrayList<String>();
|
List<String> props = new ArrayList<String>();
|
||||||
props.add(propertyName);
|
props.add(propertyName);
|
||||||
List<ObjectContent> objContent = retrieveMoRefProperties(mor, props);
|
List<ObjectContent> objContent = retrieveMoRefProperties(mor, props);
|
||||||
|
|
||||||
Object propertyValue = null;
|
T propertyValue = null;
|
||||||
if (objContent != null && objContent.size() > 0) {
|
if (objContent != null && objContent.size() > 0) {
|
||||||
List<DynamicProperty> dynamicProperty = objContent.get(0).getPropSet();
|
List<DynamicProperty> dynamicProperty = objContent.get(0).getPropSet();
|
||||||
if (dynamicProperty != null && dynamicProperty.size() > 0) {
|
if (dynamicProperty != null && dynamicProperty.size() > 0) {
|
||||||
DynamicProperty dp = dynamicProperty.get(0);
|
DynamicProperty dp = dynamicProperty.get(0);
|
||||||
propertyValue = dp.getVal();
|
propertyValue = (T)dp.getVal();
|
||||||
/*
|
/*
|
||||||
* If object is ArrayOfXXX object, then get the XXX[] by
|
* If object is ArrayOfXXX object, then get the XXX[] by
|
||||||
* invoking getXXX() on the object.
|
* invoking getXXX() on the object.
|
||||||
@ -274,13 +276,13 @@ public class VmwareClient {
|
|||||||
* ArrayOfManagedObjectReference.getManagedObjectReference()
|
* ArrayOfManagedObjectReference.getManagedObjectReference()
|
||||||
* returns ManagedObjectReference[] array.
|
* returns ManagedObjectReference[] array.
|
||||||
*/
|
*/
|
||||||
Class dpCls = propertyValue.getClass();
|
Class<? extends Object> dpCls = propertyValue.getClass();
|
||||||
String dynamicPropertyName = dpCls.getName();
|
String dynamicPropertyName = dpCls.getName();
|
||||||
if (dynamicPropertyName.indexOf("ArrayOf") != -1) {
|
if (dynamicPropertyName.indexOf("ArrayOf") != -1) {
|
||||||
String methodName = "get" + dynamicPropertyName.substring(dynamicPropertyName.indexOf("ArrayOf") + "ArrayOf".length(), dynamicPropertyName.length());
|
String methodName = "get" + dynamicPropertyName.substring(dynamicPropertyName.indexOf("ArrayOf") + "ArrayOf".length(), dynamicPropertyName.length());
|
||||||
|
|
||||||
Method getMorMethod = dpCls.getDeclaredMethod(methodName, null);
|
Method getMorMethod = dpCls.getDeclaredMethod(methodName, (Class<?>)null);
|
||||||
propertyValue = getMorMethod.invoke(propertyValue, (Object[])null);
|
propertyValue = (T)getMorMethod.invoke(propertyValue, (Object[])null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -359,7 +361,7 @@ public class VmwareClient {
|
|||||||
* @throws InvalidCollectorVersionFaultMsg
|
* @throws InvalidCollectorVersionFaultMsg
|
||||||
*/
|
*/
|
||||||
private Object[] waitForValues(ManagedObjectReference objmor, String[] filterProps, String[] endWaitProps, Object[][] expectedVals) throws InvalidPropertyFaultMsg,
|
private Object[] waitForValues(ManagedObjectReference objmor, String[] filterProps, String[] endWaitProps, Object[][] expectedVals) throws InvalidPropertyFaultMsg,
|
||||||
RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {
|
RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {
|
||||||
// version string is initially null
|
// version string is initially null
|
||||||
String version = "";
|
String version = "";
|
||||||
Object[] endVals = new Object[endWaitProps.length];
|
Object[] endVals = new Object[endWaitProps.length];
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
@ -375,7 +376,7 @@ public class VmwareContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uploadVmdkFile(String httpMethod, String urlString, String localFileName, long totalBytesUpdated, ActionDelegate progressUpdater) throws Exception {
|
public void uploadVmdkFile(String httpMethod, String urlString, String localFileName, long totalBytesUpdated, ActionDelegate<Long> progressUpdater) throws Exception {
|
||||||
|
|
||||||
HttpURLConnection conn = getRawHTTPConnection(urlString);
|
HttpURLConnection conn = getRawHTTPConnection(urlString);
|
||||||
|
|
||||||
@ -418,7 +419,7 @@ public class VmwareContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long downloadVmdkFile(String urlString, String localFileName, long totalBytesDownloaded, ActionDelegate progressUpdater) throws Exception {
|
public long downloadVmdkFile(String urlString, String localFileName, long totalBytesDownloaded, ActionDelegate<Long> progressUpdater) throws Exception {
|
||||||
HttpURLConnection conn = getRawHTTPConnection(urlString);
|
HttpURLConnection conn = getRawHTTPConnection(urlString);
|
||||||
|
|
||||||
String cookie = _vimClient.getServiceCookie();
|
String cookie = _vimClient.getServiceCookie();
|
||||||
@ -547,7 +548,7 @@ public class VmwareContext {
|
|||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
*/
|
*/
|
||||||
public String[] listDatastoreDirContent(String urlString) throws Exception {
|
public String[] listDatastoreDirContent(String urlString) throws Exception {
|
||||||
List<String> fileList = new ArrayList<String>();
|
List<String> fileList = new ArrayList<String>();
|
||||||
String content = new String(getResourceContent(urlString));
|
String content = new String(getResourceContent(urlString));
|
||||||
@ -583,8 +584,12 @@ public class VmwareContext {
|
|||||||
sb.append(_serverAddress);
|
sb.append(_serverAddress);
|
||||||
sb.append("/folder/");
|
sb.append("/folder/");
|
||||||
sb.append(relativePath);
|
sb.append(relativePath);
|
||||||
sb.append("?dcPath=").append(URLEncoder.encode(dcName)).append("&dsName=");
|
try {
|
||||||
sb.append(URLEncoder.encode(datastoreName));
|
sb.append("?dcPath=").append(URLEncoder.encode(dcName, "UTF-8"));
|
||||||
|
sb.append("&dsName=").append(URLEncoder.encode(datastoreName, "UTF-8"));
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
s_logger.error("Unable to encode URL. dcPath : " + dcName + ", dsName :" + datastoreName, e);
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -134,41 +134,6 @@ public class VmwareContextPool {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getIdleCheckContexts(List<VmwareContext> l, int batchSize) {
|
|
||||||
synchronized (this) {
|
|
||||||
for (Map.Entry<String, List<VmwareContext>> entry : _pool.entrySet()) {
|
|
||||||
if (entry.getValue() != null) {
|
|
||||||
int count = 0;
|
|
||||||
while (entry.getValue().size() > 0 && count < batchSize) {
|
|
||||||
VmwareContext context = entry.getValue().remove(0);
|
|
||||||
context.setPoolInfo(this, entry.getKey());
|
|
||||||
l.add(context);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doIdleCheck() {
|
|
||||||
List<VmwareContext> l = new ArrayList<VmwareContext>();
|
|
||||||
int batchSize = (int)(_idleCheckIntervalMs / 1000); // calculate batch size at 1 request/sec rate
|
|
||||||
getIdleCheckContexts(l, batchSize);
|
|
||||||
|
|
||||||
for (VmwareContext context : l) {
|
|
||||||
try {
|
|
||||||
context.idleCheck();
|
|
||||||
|
|
||||||
if (s_logger.isTraceEnabled())
|
|
||||||
s_logger.trace("Recyle context after idle check");
|
|
||||||
returnContext(context);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
s_logger.warn("Exception caught during VmwareContext idle check, close and discard the context", e);
|
|
||||||
context.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getKeepAliveCheckContexts(List<VmwareContext> l, int batchSize) {
|
private void getKeepAliveCheckContexts(List<VmwareContext> l, int batchSize) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
int size = Math.min(_outstandingRegistry.size(), batchSize);
|
int size = Math.min(_outstandingRegistry.size(), batchSize);
|
||||||
|
|||||||
@ -71,6 +71,7 @@ import com.cloud.utils.Ternary;
|
|||||||
import com.cloud.utils.exception.ExceptionUtil;
|
import com.cloud.utils.exception.ExceptionUtil;
|
||||||
|
|
||||||
public class VmwareHelper {
|
public class VmwareHelper {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private static final Logger s_logger = Logger.getLogger(VmwareHelper.class);
|
private static final Logger s_logger = Logger.getLogger(VmwareHelper.class);
|
||||||
|
|
||||||
public static boolean isReservedScsiDeviceNumber(int deviceNumber) {
|
public static boolean isReservedScsiDeviceNumber(int deviceNumber) {
|
||||||
@ -78,29 +79,29 @@ public class VmwareHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static VirtualDevice prepareNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String portGroupName,
|
public static VirtualDevice prepareNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String portGroupName,
|
||||||
String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
|
String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
|
||||||
|
|
||||||
VirtualEthernetCard nic;
|
VirtualEthernetCard nic;
|
||||||
switch (deviceType) {
|
switch (deviceType) {
|
||||||
case E1000:
|
case E1000:
|
||||||
nic = new VirtualE1000();
|
nic = new VirtualE1000();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCNet32:
|
case PCNet32:
|
||||||
nic = new VirtualPCNet32();
|
nic = new VirtualPCNet32();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Vmxnet2:
|
case Vmxnet2:
|
||||||
nic = new VirtualVmxnet2();
|
nic = new VirtualVmxnet2();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Vmxnet3:
|
case Vmxnet3:
|
||||||
nic = new VirtualVmxnet3();
|
nic = new VirtualVmxnet3();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert (false);
|
assert (false);
|
||||||
nic = new VirtualE1000();
|
nic = new VirtualE1000();
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
|
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
|
||||||
@ -121,29 +122,29 @@ public class VmwareHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static VirtualDevice prepareDvNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String dvPortGroupName,
|
public static VirtualDevice prepareDvNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String dvPortGroupName,
|
||||||
String dvSwitchUuid, String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
|
String dvSwitchUuid, String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
|
||||||
|
|
||||||
VirtualEthernetCard nic;
|
VirtualEthernetCard nic;
|
||||||
switch (deviceType) {
|
switch (deviceType) {
|
||||||
case E1000:
|
case E1000:
|
||||||
nic = new VirtualE1000();
|
nic = new VirtualE1000();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PCNet32:
|
case PCNet32:
|
||||||
nic = new VirtualPCNet32();
|
nic = new VirtualPCNet32();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Vmxnet2:
|
case Vmxnet2:
|
||||||
nic = new VirtualVmxnet2();
|
nic = new VirtualVmxnet2();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Vmxnet3:
|
case Vmxnet3:
|
||||||
nic = new VirtualVmxnet3();
|
nic = new VirtualVmxnet3();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert (false);
|
assert (false);
|
||||||
nic = new VirtualE1000();
|
nic = new VirtualE1000();
|
||||||
}
|
}
|
||||||
|
|
||||||
final VirtualEthernetCardDistributedVirtualPortBackingInfo dvPortBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
|
final VirtualEthernetCardDistributedVirtualPortBackingInfo dvPortBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
|
||||||
@ -170,7 +171,7 @@ public class VmwareHelper {
|
|||||||
|
|
||||||
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
||||||
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath, int sizeInMb, ManagedObjectReference morDs,
|
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath, int sizeInMb, ManagedObjectReference morDs,
|
||||||
int deviceNumber, int contextNumber) throws Exception {
|
int deviceNumber, int contextNumber) throws Exception {
|
||||||
|
|
||||||
VirtualDisk disk = new VirtualDisk();
|
VirtualDisk disk = new VirtualDisk();
|
||||||
|
|
||||||
@ -206,7 +207,7 @@ public class VmwareHelper {
|
|||||||
|
|
||||||
// vmdkDatastorePath: [datastore name] vmdkFilePath, create delta disk based on disk from template
|
// vmdkDatastorePath: [datastore name] vmdkFilePath, create delta disk based on disk from template
|
||||||
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath, int sizeInMb, ManagedObjectReference morDs,
|
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath, int sizeInMb, ManagedObjectReference morDs,
|
||||||
VirtualDisk templateDisk, int deviceNumber, int contextNumber) throws Exception {
|
VirtualDisk templateDisk, int deviceNumber, int contextNumber) throws Exception {
|
||||||
|
|
||||||
assert (templateDisk != null);
|
assert (templateDisk != null);
|
||||||
VirtualDeviceBackingInfo parentBacking = templateDisk.getBacking();
|
VirtualDeviceBackingInfo parentBacking = templateDisk.getBacking();
|
||||||
@ -277,7 +278,7 @@ public class VmwareHelper {
|
|||||||
|
|
||||||
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
||||||
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, VirtualDisk device, int controllerKey, String vmdkDatastorePathChain[],
|
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, VirtualDisk device, int controllerKey, String vmdkDatastorePathChain[],
|
||||||
ManagedObjectReference morDs, int deviceNumber, int contextNumber) throws Exception {
|
ManagedObjectReference morDs, int deviceNumber, int contextNumber) throws Exception {
|
||||||
|
|
||||||
assert (vmdkDatastorePathChain != null);
|
assert (vmdkDatastorePathChain != null);
|
||||||
assert (vmdkDatastorePathChain.length >= 1);
|
assert (vmdkDatastorePathChain.length >= 1);
|
||||||
@ -325,8 +326,9 @@ public class VmwareHelper {
|
|||||||
return disk;
|
return disk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, Pair<String, ManagedObjectReference>[] vmdkDatastorePathChain,
|
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, Pair<String, ManagedObjectReference>[] vmdkDatastorePathChain,
|
||||||
int deviceNumber, int contextNumber) throws Exception {
|
int deviceNumber, int contextNumber) throws Exception {
|
||||||
|
|
||||||
assert (vmdkDatastorePathChain != null);
|
assert (vmdkDatastorePathChain != null);
|
||||||
assert (vmdkDatastorePathChain.length >= 1);
|
assert (vmdkDatastorePathChain.length >= 1);
|
||||||
@ -385,6 +387,7 @@ public class VmwareHelper {
|
|||||||
backingInfo.setParent(parentBacking);
|
backingInfo.setParent(parentBacking);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static void setParentBackingInfo(VirtualDiskFlatVer2BackingInfo backingInfo, Pair<String, ManagedObjectReference>[] parentDatastorePathList) {
|
private static void setParentBackingInfo(VirtualDiskFlatVer2BackingInfo backingInfo, Pair<String, ManagedObjectReference>[] parentDatastorePathList) {
|
||||||
|
|
||||||
VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
|
VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
|
||||||
@ -403,7 +406,7 @@ public class VmwareHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<VirtualDevice, Boolean> prepareIsoDevice(VirtualMachineMO vmMo, String isoDatastorePath, ManagedObjectReference morDs, boolean connect,
|
public static Pair<VirtualDevice, Boolean> prepareIsoDevice(VirtualMachineMO vmMo, String isoDatastorePath, ManagedObjectReference morDs, boolean connect,
|
||||||
boolean connectAtBoot, int deviceNumber, int contextNumber) throws Exception {
|
boolean connectAtBoot, int deviceNumber, int contextNumber) throws Exception {
|
||||||
|
|
||||||
boolean newCdRom = false;
|
boolean newCdRom = false;
|
||||||
VirtualCdrom cdRom = (VirtualCdrom)vmMo.getIsoDevice();
|
VirtualCdrom cdRom = (VirtualCdrom)vmMo.getIsoDevice();
|
||||||
@ -549,7 +552,7 @@ public class VmwareHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setVmScaleUpConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB,
|
public static void setVmScaleUpConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB,
|
||||||
boolean limitCpuUse) {
|
boolean limitCpuUse) {
|
||||||
|
|
||||||
// VM config for scaling up
|
// VM config for scaling up
|
||||||
vmConfig.setMemoryMB((long)memoryMB);
|
vmConfig.setMemoryMB((long)memoryMB);
|
||||||
@ -573,7 +576,7 @@ public class VmwareHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setBasicVmConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB,
|
public static void setBasicVmConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB,
|
||||||
String guestOsIdentifier, boolean limitCpuUse) {
|
String guestOsIdentifier, boolean limitCpuUse) {
|
||||||
|
|
||||||
// VM config basics
|
// VM config basics
|
||||||
vmConfig.setMemoryMB((long)memoryMB);
|
vmConfig.setMemoryMB((long)memoryMB);
|
||||||
@ -640,10 +643,10 @@ public class VmwareHelper {
|
|||||||
//TODO: in vim 5.1, exceptions do not have a base exception class, MethodFault becomes a FaultInfo that we can only get
|
//TODO: in vim 5.1, exceptions do not have a base exception class, MethodFault becomes a FaultInfo that we can only get
|
||||||
// from individual exception through getFaultInfo, so we have to use reflection here to get MethodFault information.
|
// from individual exception through getFaultInfo, so we have to use reflection here to get MethodFault information.
|
||||||
try {
|
try {
|
||||||
Class cls = e.getClass();
|
Class<? extends Throwable> cls = e.getClass();
|
||||||
Method mth = cls.getDeclaredMethod("getFaultInfo", null);
|
Method mth = cls.getDeclaredMethod("getFaultInfo", (Class<?>)null);
|
||||||
if (mth != null) {
|
if (mth != null) {
|
||||||
Object fault = mth.invoke(e, null);
|
Object fault = mth.invoke(e, (Object[])null);
|
||||||
if (fault instanceof MethodFault) {
|
if (fault instanceof MethodFault) {
|
||||||
final StringWriter writer = new StringWriter();
|
final StringWriter writer = new StringWriter();
|
||||||
writer.append("Exception: " + fault.getClass().getName() + "\n");
|
writer.append("Exception: " + fault.getClass().getName() + "\n");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user