use of com.vmware.vim25.RuntimeFaultFaultMsg in project cloudstack by apache.
the class VmwareResource method fillHostInfo.
protected void fillHostInfo(StartupRoutingCommand cmd) {
VmwareContext serviceContext = getServiceContext();
Map<String, String> details = cmd.getHostDetails();
if (details == null) {
details = new HashMap<String, String>();
}
try {
fillHostHardwareInfo(serviceContext, cmd);
fillHostNetworkInfo(serviceContext, cmd);
fillHostDetailsInfo(serviceContext, details);
} catch (RuntimeFaultFaultMsg e) {
s_logger.error("RuntimeFault while retrieving host info: " + e.toString(), e);
throw new CloudRuntimeException("RuntimeFault while retrieving host info");
} catch (RemoteException e) {
s_logger.error("RemoteException while retrieving host info: " + e.toString(), e);
invalidateServiceContext();
throw new CloudRuntimeException("RemoteException while retrieving host info");
} catch (Exception e) {
s_logger.error("Exception while retrieving host info: " + e.toString(), e);
invalidateServiceContext();
throw new CloudRuntimeException("Exception while retrieving host info: " + e.toString());
}
cmd.setHostDetails(details);
cmd.setName(_url);
cmd.setGuid(_guid);
cmd.setDataCenter(_dcId);
cmd.setIqn(getIqn());
cmd.setPod(_pod);
cmd.setCluster(_cluster);
cmd.setVersion(VmwareResource.class.getPackage().getImplementationVersion());
}
use of com.vmware.vim25.RuntimeFaultFaultMsg in project cloudstack by apache.
the class VmwareClient method getDecendentMoRef.
/**
* Get the ManagedObjectReference for an item under the
* specified root folder that has the type and name specified.
*
* @param root a root folder if available, or null for default
* @param type type of the managed object
* @param name name to match
*
* @return First ManagedObjectReference of the type / name pair found
*/
public ManagedObjectReference getDecendentMoRef(ManagedObjectReference root, String type, String name) throws Exception {
if (name == null || name.length() == 0) {
return null;
}
try {
// Create PropertySpecs
PropertySpec pSpec = new PropertySpec();
pSpec.setType(type);
pSpec.setAll(false);
pSpec.getPathSet().add("name");
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(root);
oSpec.setSkip(false);
oSpec.getSelectSet().addAll(constructCompleteTraversalSpec());
PropertyFilterSpec spec = new PropertyFilterSpec();
spec.getPropSet().add(pSpec);
spec.getObjectSet().add(oSpec);
List<PropertyFilterSpec> specArr = new ArrayList<PropertyFilterSpec>();
specArr.add(spec);
ManagedObjectReference propCollector = getPropCol();
List<ObjectContent> ocary = vimPort.retrieveProperties(propCollector, specArr);
if (ocary == null || ocary.size() == 0) {
return null;
}
// filter through retrieved objects to get the first match.
for (ObjectContent oc : ocary) {
ManagedObjectReference mor = oc.getObj();
List<DynamicProperty> propary = oc.getPropSet();
if (type == null || type.equals(mor.getType())) {
if (propary.size() > 0) {
String propval = (String) propary.get(0).getVal();
if (propval != null && name.equalsIgnoreCase(propval))
return mor;
}
}
}
} catch (InvalidPropertyFaultMsg invalidPropertyException) {
s_logger.debug("Failed to get Vmware ManagedObjectReference for name: " + name + " and type: " + type + " due to " + invalidPropertyException.getMessage());
throw invalidPropertyException;
} catch (RuntimeFaultFaultMsg runtimeFaultException) {
s_logger.debug("Failed to get Vmware ManagedObjectReference for name: " + name + " and type: " + type + " due to " + runtimeFaultException.getMessage());
throw runtimeFaultException;
}
return null;
}
use of com.vmware.vim25.RuntimeFaultFaultMsg in project cloudstack by apache.
the class VmwareClient method waitForValues.
/**
* Handle Updates for a single object. waits till expected values of
* properties to check are reached Destroys the ObjectFilter when done.
*
* @param objmor
* MOR of the Object to wait for
* @param filterProps
* Properties list to filter
* @param endWaitProps
* Properties list to check for expected values these be
* properties of a property in the filter properties list
* @param expectedVals
* values for properties to end the wait
* @return true indicating expected values were met, and false otherwise
* @throws RuntimeFaultFaultMsg
* @throws InvalidPropertyFaultMsg
* @throws InvalidCollectorVersionFaultMsg
*/
private Object[] waitForValues(ManagedObjectReference objmor, String[] filterProps, String[] endWaitProps, Object[][] expectedVals) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {
// version string is initially null
String version = "";
Object[] endVals = new Object[endWaitProps.length];
Object[] filterVals = new Object[filterProps.length];
PropertyFilterSpec spec = new PropertyFilterSpec();
ObjectSpec oSpec = new ObjectSpec();
oSpec.setObj(objmor);
oSpec.setSkip(Boolean.FALSE);
spec.getObjectSet().add(oSpec);
PropertySpec pSpec = new PropertySpec();
pSpec.getPathSet().addAll(Arrays.asList(filterProps));
pSpec.setType(objmor.getType());
spec.getPropSet().add(pSpec);
ManagedObjectReference propertyCollector = getPropCol();
ManagedObjectReference filterSpecRef = vimPort.createFilter(propertyCollector, spec, true);
boolean reached = false;
UpdateSet updateset = null;
List<PropertyFilterUpdate> filtupary = null;
List<ObjectUpdate> objupary = null;
List<PropertyChange> propchgary = null;
while (!reached) {
updateset = vimPort.waitForUpdates(propertyCollector, version);
if (updateset == null || updateset.getFilterSet() == null) {
continue;
}
version = updateset.getVersion();
// Make this code more general purpose when PropCol changes later.
filtupary = updateset.getFilterSet();
for (PropertyFilterUpdate filtup : filtupary) {
objupary = filtup.getObjectSet();
for (ObjectUpdate objup : objupary) {
// TODO: Handle all "kind"s of updates.
if (objup.getKind() == ObjectUpdateKind.MODIFY || objup.getKind() == ObjectUpdateKind.ENTER || objup.getKind() == ObjectUpdateKind.LEAVE) {
propchgary = objup.getChangeSet();
for (PropertyChange propchg : propchgary) {
updateValues(endWaitProps, endVals, propchg);
updateValues(filterProps, filterVals, propchg);
}
}
}
}
Object expctdval = null;
// Also exit the WaitForUpdates loop if this is the case.
for (int chgi = 0; chgi < endVals.length && !reached; chgi++) {
for (int vali = 0; vali < expectedVals[chgi].length && !reached; vali++) {
expctdval = expectedVals[chgi][vali];
reached = expctdval.equals(endVals[chgi]) || reached;
}
}
}
// Destroy the filter when we are done.
vimPort.destroyPropertyFilter(filterSpecRef);
return filterVals;
}
Aggregations