Search in sources :

Example 1 with RuntimeFaultFaultMsg

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());
}
Also used : VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) RuntimeFaultFaultMsg(com.vmware.vim25.RuntimeFaultFaultMsg) RemoteException(java.rmi.RemoteException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) InternalErrorException(com.cloud.exception.InternalErrorException) CloudException(com.cloud.exception.CloudException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(javax.naming.ConfigurationException)

Example 2 with RuntimeFaultFaultMsg

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;
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) DynamicProperty(com.vmware.vim25.DynamicProperty) ArrayList(java.util.ArrayList) RuntimeFaultFaultMsg(com.vmware.vim25.RuntimeFaultFaultMsg) ObjectContent(com.vmware.vim25.ObjectContent) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) InvalidPropertyFaultMsg(com.vmware.vim25.InvalidPropertyFaultMsg) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 3 with RuntimeFaultFaultMsg

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;
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) PropertyFilterUpdate(com.vmware.vim25.PropertyFilterUpdate) PropertyChange(com.vmware.vim25.PropertyChange) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) UpdateSet(com.vmware.vim25.UpdateSet) ObjectUpdate(com.vmware.vim25.ObjectUpdate) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Aggregations

ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)2 ObjectSpec (com.vmware.vim25.ObjectSpec)2 PropertyFilterSpec (com.vmware.vim25.PropertyFilterSpec)2 PropertySpec (com.vmware.vim25.PropertySpec)2 RuntimeFaultFaultMsg (com.vmware.vim25.RuntimeFaultFaultMsg)2 CloudException (com.cloud.exception.CloudException)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 DynamicProperty (com.vmware.vim25.DynamicProperty)1 InvalidPropertyFaultMsg (com.vmware.vim25.InvalidPropertyFaultMsg)1 ObjectContent (com.vmware.vim25.ObjectContent)1 ObjectUpdate (com.vmware.vim25.ObjectUpdate)1 PropertyChange (com.vmware.vim25.PropertyChange)1 PropertyFilterUpdate (com.vmware.vim25.PropertyFilterUpdate)1 UpdateSet (com.vmware.vim25.UpdateSet)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ConnectException (java.net.ConnectException)1 RemoteException (java.rmi.RemoteException)1