use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class ClusterMO method importVmFromOVF.
@Override
public void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.get_value() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName + ", datastore: " + dsMo.getMor().get_value() + ", diskOption: " + diskOption);
ManagedObjectReference morRp = getHyperHostOwnerResourcePool();
assert (morRp != null);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - importVmFromOVF(). resource pool: " + morRp.get_value());
HypervisorHostHelper.importVmFromOVF(this, ovfFilePath, vmName, dsMo, diskOption, morRp, null);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - importVmFromOVF() done");
}
use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class DatacenterMO method getAllVmsOnDatacenter.
public List<Pair<ManagedObjectReference, String>> getAllVmsOnDatacenter() throws Exception {
List<Pair<ManagedObjectReference, String>> vms = new ArrayList<Pair<ManagedObjectReference, String>>();
ObjectContent[] ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
if (ocs != null) {
for (ObjectContent oc : ocs) {
String vmName = oc.getPropSet(0).getVal().toString();
vms.add(new Pair<ManagedObjectReference, String>(oc.getObj(), vmName));
}
}
return vms;
}
use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class DatacenterMO method getDvSwitchMor.
public ManagedObjectReference getDvSwitchMor(ManagedObjectReference dvPortGroupMor) throws Exception {
String dvPortGroupKey = null;
ManagedObjectReference dvSwitchMor = null;
PropertySpec pSpec = new PropertySpec();
pSpec.setType("DistributedVirtualPortgroup");
pSpec.setPathSet(new String[] { "key", "config.distributedVirtualSwitch" });
TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
datacenter2DvPortGroupTraversal.setType("Datacenter");
datacenter2DvPortGroupTraversal.setPath("network");
datacenter2DvPortGroupTraversal.setName("datacenter2DvPortgroupTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.setPropSet(new PropertySpec[] { pSpec });
pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
ObjectContent[] ocs = _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
if (ocs != null) {
for (ObjectContent oc : ocs) {
DynamicProperty[] props = oc.getPropSet();
if (props != null) {
assert (props.length == 2);
for (DynamicProperty prop : props) {
if (prop.getName().equals("key")) {
dvPortGroupKey = (String) prop.getVal();
} else {
dvSwitchMor = (ManagedObjectReference) prop.getVal();
}
}
if ((dvPortGroupKey != null) && dvPortGroupKey.equals(dvPortGroupMor.get_value())) {
return dvSwitchMor;
}
}
}
}
return null;
}
use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class DatacenterMO method getDvPortGroupMor.
public ManagedObjectReference getDvPortGroupMor(String dvPortGroupName) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setType("DistributedVirtualPortgroup");
pSpec.setPathSet(new String[] { "name" });
TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
datacenter2DvPortGroupTraversal.setType("Datacenter");
datacenter2DvPortGroupTraversal.setPath("network");
datacenter2DvPortGroupTraversal.setName("datacenter2DvPortgroupTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.setPropSet(new PropertySpec[] { pSpec });
pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
ObjectContent[] ocs = _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
if (ocs != null) {
for (ObjectContent oc : ocs) {
DynamicProperty[] props = oc.getPropSet();
if (props != null) {
for (DynamicProperty prop : props) {
if (prop.getVal().equals(dvPortGroupName))
return oc.getObj();
}
}
}
}
return null;
}
use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class DatacenterMO method getOwnerDatacenter.
public static Pair<DatacenterMO, String> getOwnerDatacenter(VmwareContext context, ManagedObjectReference morEntity) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datacenter");
pSpec.setPathSet(new String[] { "name" });
TraversalSpec entityParentTraversal = new TraversalSpec();
entityParentTraversal.setType("ManagedEntity");
entityParentTraversal.setPath("parent");
entityParentTraversal.setName("entityParentTraversal");
entityParentTraversal.setSelectSet(new SelectionSpec[] { new SelectionSpec(null, null, "entityParentTraversal") });
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(morEntity);
oSpec.setSkip(Boolean.TRUE);
oSpec.setSelectSet(new SelectionSpec[] { entityParentTraversal });
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.setPropSet(new PropertySpec[] { pSpec });
pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
ObjectContent[] ocs = context.getService().retrieveProperties(context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
assert (ocs != null);
assert (ocs[0].getObj() != null);
assert (ocs[0].getPropSet(0) != null);
assert (ocs[0].getPropSet(0).getVal() != null);
String dcName = ocs[0].getPropSet(0).getVal().toString();
return new Pair<DatacenterMO, String>(new DatacenterMO(context, ocs[0].getObj()), dcName);
}
Aggregations