Search in sources :

Example 16 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class ComputeDeviceControllerImpl method addStepsVcenterHostCleanup.

/**
 * Method to add steps to perform host cleanup operations on the vcenter
 *
 * @param workflow
 *            {@link Workflow} instance
 * @param waitFor
 *            {@link String} If non-null, the step will not be queued for
 *            execution in the Dispatcher until the Step or StepGroup
 *            indicated by the waitFor has completed. The waitFor may either
 *            be a string representation of a Step UUID, or the name of a
 *            StepGroup.
 * @param hostId
 *            {@link URI} hostId URI
 * @return waitFor step name
 */
@Override
public String addStepsVcenterHostCleanup(Workflow workflow, String waitFor, URI hostId) throws InternalException {
    Host host = _dbClient.queryObject(Host.class, hostId);
    if (NullColumnValueGetter.isNullURI(host.getComputeElement())) {
        /**
         * No steps need to be added - as this was not a host that we
         * created in ViPR. If it was computeElement property of the host
         * would have been set.
         */
        log.info("Skipping VCenter Host cleanup for host with no blade association.  Host is " + hostId);
        return waitFor;
    }
    ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
    if (computeElement != null) {
        ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeElement.getComputeSystem());
        waitFor = workflow.createStep(CHECK_HOST_INITIATORS, "Check for host initiators", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("checkHostInitiators", hostId), null, null);
        // any update to the host using the hostService automatically adds this association.
        if (!NullColumnValueGetter.isNullURI(host.getVcenterDataCenter()) && host.getType() != null && host.getType().equalsIgnoreCase((Host.HostType.No_OS).name())) {
            log.info("Skipping Vcenter host cleanup steps because No_OS is specified on host " + hostId);
        } else {
            waitFor = workflow.createStep(DEACTIVATION_MAINTENANCE_MODE, "If synced with vCenter, put the host in maintenance mode", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("putHostInMaintenanceMode", hostId), null, null);
            waitFor = workflow.createStep(DEACTIVATION_REMOVE_HOST_VCENTER, "If synced with vCenter, remove the host from the cluster", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("removeHostFromVcenterCluster", hostId), null, null);
        }
    }
    return waitFor;
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 17 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class UcsComputeDevice method setNoBoot.

@Override
public void setNoBoot(ComputeSystem cs, URI computeElementId, URI hostId, boolean waitForServerRestart) throws InternalException {
    ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, computeElementId);
    try {
        if (null != computeElement) {
            StringBuilder errorMessage = new StringBuilder();
            LsServer lsServer = ucsmService.setServiceProfileToNoBoot(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), computeElement.getDn(), errorMessage);
            if (lsServer != null) {
                if (waitForServerRestart) {
                    pullAndPollManagedObject(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), computeElement.getDn(), LsServer.class);
                }
            } else {
                throw new RuntimeException("Failed to set no boot target due to error from UCSM Service. \n " + errorMessage.toString());
            }
        } else {
            throw new RuntimeException("ComputeElement object is null for id " + computeElementId);
        }
    } catch (Exception e) {
        throw ComputeSystemControllerException.exceptions.unableToSetNoBoot(computeElement != null ? computeElement.getLabel() : computeElementId.toString(), e);
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ComputeSystemControllerTimeoutException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException) MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 18 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class UcsComputeDevice method unbindHostFromComputeElement.

/*
     * Unbinds the host's service profile from the associated blade.
     * Determines the service profile to unbind using host's serviceProfile association.
     * In case of host provisioned using pre-Anakin version of ViPR and no serviceProfile association yet set,
     * serviceprofile to unbind will be determined by trying to find a serviceProfile that matches
     * the computeElement's uuid.
     */
private void unbindHostFromComputeElement(ComputeSystem cs, Host host) throws ClientGeneralException {
    // We already checked for empty initiators in a step before we get here
    if (host != null && !NullColumnValueGetter.isNullURI(host.getComputeElement())) {
        ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
        if (computeElement == null) {
            LOGGER.error("Host " + host.getLabel() + " has associated computeElementURI: " + host.getComputeElement() + " which is an invalid reference");
            LOGGER.info("Service profile unbind will not be triggered");
            return;
        }
        String spDn = null;
        LOGGER.info("Host.uuid: " + host.getUuid() + " ComputeElement.uuid: " + computeElement.getUuid());
        if (NullColumnValueGetter.isNullURI(host.getServiceProfile())) {
            LOGGER.error("Host has no asscoaited serviceProfile. Service profile unbind will not be triggered.");
            return;
        }
        UCSServiceProfile serviceProfile = _dbClient.queryObject(UCSServiceProfile.class, host.getServiceProfile());
        if (serviceProfile == null) {
            LOGGER.error("Host " + host.getLabel() + " has associated serviceProfileURI: " + host.getServiceProfile() + " which is an invalid reference");
            LOGGER.info("Service profile unbind will not be triggered");
            return;
        } else {
            spDn = serviceProfile.getDn();
            LOGGER.info("Host.uuid: " + host.getUuid() + " ComputeElement.uuid: " + computeElement.getUuid() + "serviceProfile.uuid:" + serviceProfile.getUuid());
        }
        if (spDn != null) {
            LOGGER.info("Unbinding service profile with dn: " + spDn);
            StringBuilder errorMessage = new StringBuilder();
            LsServer unboundServiceProfile = ucsmService.unbindServiceProfile(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), spDn, errorMessage);
            LOGGER.info("Operational state of Deleted Service Profile : " + unboundServiceProfile.getOperState());
            ComputeBlade computeBlade = pullAndPollManagedObject(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), computeElement.getLabel(), ComputeBlade.class);
            if (computeBlade == null) {
                LOGGER.info("ComputeBlade " + computeElement.getLabel() + " not found on UCS");
            } else {
                // Release the computeElement back into the pool as soon as we have unbound it from the service profile
                if (LsServerOperStates.UNASSOCIATED.equals(LsServerOperStates.fromString(computeBlade.getOperState()))) {
                    computeElement.setAvailable(true);
                }
                String originalUuid = computeElement.getOriginalUuid();
                LOGGER.info("ComputeBlade " + computeElement.getLabel() + " setting uuid back to originalUUid: " + originalUuid);
                computeElement.setUuid(originalUuid);
                _dbClient.updateObject(computeElement);
            }
        } else {
            LOGGER.error("spDn is null. Cannot determine the service profile to unbind");
        }
    } else {
        LOGGER.info("NO OP. Host is null or has no associated compute element");
    }
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) ComputeBlade(com.emc.cloud.platform.ucs.out.model.ComputeBlade) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer)

Example 19 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class UcsComputeDevice method setLanBootTarget.

@Override
public void setLanBootTarget(ComputeSystem cs, URI computeElementId, URI hostId, boolean waitForServerRestart) throws InternalException {
    ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, computeElementId);
    try {
        if (null != computeElement) {
            StringBuilder errorMessage = new StringBuilder();
            LsServer lsServer = ucsmService.setServiceProfileToLanBoot(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), computeElement.getDn(), errorMessage);
            if (lsServer != null) {
                if (waitForServerRestart) {
                    pullAndPollManagedObject(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), computeElement.getDn(), LsServer.class);
                }
            } else {
                throw new RuntimeException("Failed to set LAN boot target due to error from UCSM Service \n " + errorMessage.toString());
            }
        } else {
            throw new RuntimeException("ComputeElement object is null for id " + computeElementId);
        }
    } catch (Exception e) {
        throw ComputeSystemControllerException.exceptions.unableToSetLanBoot(computeElementId.toString(), e);
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ComputeSystemControllerTimeoutException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException) MalformedURLException(java.net.MalformedURLException) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 20 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class UcsComputeDevice method prepareOsInstallNetwork.

@Override
public Map<String, Boolean> prepareOsInstallNetwork(URI computeSystemId, URI computeElementId) throws InternalException {
    LOGGER.info("prepareOsInstallNetwork");
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    ComputeElement ce = _dbClient.queryObject(ComputeElement.class, computeElementId);
    String osInstallVlan = cs.getOsInstallNetwork();
    Map<String, Boolean> vlanMap = null;
    try {
        vlanMap = ucsmService.setOsInstallVlan(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), ce.getDn(), osInstallVlan);
    } catch (ClientGeneralException e) {
        LOGGER.error("Unable to set os install vlan: " + cs.getOsInstallNetwork() + " On computeElement : " + ce.getId(), e);
        throw ComputeSystemControllerException.exceptions.unableToSetOsInstallNetwork(osInstallVlan, ce.getId().toString(), e);
    }
    return vlanMap;
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Aggregations

ComputeElement (com.emc.storageos.db.client.model.ComputeElement)52 Host (com.emc.storageos.db.client.model.Host)24 URI (java.net.URI)20 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)12 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)11 ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)10 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)10 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)9 MalformedURLException (java.net.MalformedURLException)9 Produces (javax.ws.rs.Produces)9 ComputeSystemControllerTimeoutException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException)8 HashMap (java.util.HashMap)8 Path (javax.ws.rs.Path)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7 ComputeVirtualPool (com.emc.storageos.db.client.model.ComputeVirtualPool)6 UCSServiceProfile (com.emc.storageos.db.client.model.UCSServiceProfile)6 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)6 Cluster (com.emc.storageos.db.client.model.Cluster)4