use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class HostDatastoreSystemMO method findDatastoreByUrl.
// storeUrl in nfs://host/exportpath format
public ManagedObjectReference findDatastoreByUrl(String storeUrl) throws Exception {
assert (storeUrl != null);
ManagedObjectReference[] datastores = getDatastores();
if (datastores != null && datastores.length > 0) {
for (ManagedObjectReference morDatastore : datastores) {
NasDatastoreInfo info = getNasDatastoreInfo(morDatastore);
if (info != null) {
URI uri = new URI(storeUrl);
String vmwareStyleUrl = "netfs://" + uri.getHost() + "/" + uri.getPath() + "/";
if (info.getUrl().equals(vmwareStyleUrl))
return morDatastore;
}
}
}
return null;
}
use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class HostDatastoreSystemMO method findDatastore.
public ManagedObjectReference findDatastore(String name) throws Exception {
// added cloud.com specific name convention, we will use custom field "cloud.uuid" as datastore name as well
CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(_context, _context.getServiceContent().getCustomFieldsManager());
int key = cfmMo.getCustomFieldKey("Datastore", CustomFieldConstants.CLOUD_UUID);
assert (key != 0);
ObjectContent[] ocs = getDatastorePropertiesOnHostDatastoreSystem(new String[] { "name", String.format("value[%d]", key) });
if (ocs != null) {
for (ObjectContent oc : ocs) {
if (oc.getPropSet(0).getVal().equals(name))
return oc.getObj();
if (oc.getPropSet().length > 1) {
DynamicProperty prop = oc.getPropSet(1);
if (prop != null && prop.getVal() != null) {
if (prop.getVal() instanceof CustomFieldStringValue) {
String val = ((CustomFieldStringValue) prop.getVal()).getValue();
if (val.equalsIgnoreCase(name))
return oc.getObj();
}
}
}
}
}
return null;
}
use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class HostDatastoreSystemMO method createNfsDatastore.
public ManagedObjectReference createNfsDatastore(String host, int port, String exportPath, String uuid) throws Exception {
HostNasVolumeSpec spec = new HostNasVolumeSpec();
spec.setRemoteHost(host);
spec.setRemotePath(exportPath);
spec.setType("nfs");
spec.setLocalPath(uuid);
// readOnly/readWrite
spec.setAccessMode("readWrite");
return _context.getService().createNasDatastore(_mor, spec);
}
use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class HostMO method createVm.
@Override
public boolean createVm(VirtualMachineConfigSpec vmSpec) throws Exception {
assert (vmSpec != null);
DatacenterMO dcMo = new DatacenterMO(_context, getHyperHostDatacenter());
ManagedObjectReference morPool = getHyperHostOwnerResourcePool();
ManagedObjectReference morTask = _context.getService().createVM_Task(dcMo.getVmFolder(), vmSpec, morPool, _mor);
String result = _context.getServiceUtil().waitForTask(morTask);
if (result.equals("sucess")) {
_context.waitForTaskProgressDone(morTask);
return true;
} else {
s_logger.error("VMware createVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}
return false;
}
use of com.vmware.vim25.ManagedObjectReference in project CloudStack-archive by CloudStack-extras.
the class HostMO method getNetworkMor.
public ManagedObjectReference getNetworkMor(String portGroupName) throws Exception {
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Network");
pSpec.setPathSet(new String[] { "summary.name" });
TraversalSpec host2NetworkTraversal = new TraversalSpec();
host2NetworkTraversal.setType("HostSystem");
host2NetworkTraversal.setPath("network");
host2NetworkTraversal.setName("host2NetworkTraversal");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(_mor);
oSpec.setSkip(Boolean.TRUE);
oSpec.setSelectSet(new SelectionSpec[] { host2NetworkTraversal });
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(portGroupName))
return oc.getObj();
}
}
}
}
return null;
}
Aggregations