Search in sources :

Example 26 with LsServer

use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.

the class UCSMServiceTest method testSetNoBoot.

@Test(groups = "onDemand50")
public void testSetNoBoot() throws ClientGeneralException {
    LsServer lsServer = ucsmService.setServiceProfileToNoBoot(UCSM_SERVICE3, UCSM_HOST3_USERNAME, UCSM_HOST3_PASSWORD, SP_DN, new StringBuilder());
    Assert.assertNotNull(lsServer, "Couldn't update the LsServer's boot order " + SP_DN);
    System.out.println("Current State of the lsServer : " + lsServer.getOperState());
}
Also used : LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) Test(org.testng.annotations.Test)

Example 27 with LsServer

use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.

the class UCSMServiceTest method testSetSanBootTarget.

@Test(groups = "onDemand50", dependsOnMethods = "testSetLanBoot")
public void testSetSanBootTarget() throws ClientGeneralException {
    String aSide = "fc0";
    String bside = "fc1";
    Map<String, Map<String, Integer>> hbaToStoragePortMap = new HashMap<String, Map<String, Integer>>();
    hbaToStoragePortMap.put(bside, ImmutableMap.of("50:00:09:73:00:12:9D:60", 1, "50:00:09:73:00:12:9D:1C", 1, "50:00:09:73:00:12:9D:7F", 1));
    hbaToStoragePortMap.put(aSide, ImmutableMap.of("50:00:09:73:00:12:9D:60", 0, "50:00:09:73:00:12:9D:1C", 0, "50:00:09:73:00:12:9D:7F", 0));
    LsServer lsServer = ucsmService.setServiceProfileToSanBoot(UCSM_SERVICE3, UCSM_HOST3_USERNAME, UCSM_HOST3_PASSWORD, SP_DN, hbaToStoragePortMap, new StringBuilder());
    Assert.assertNotNull(lsServer, "Couldn't update the LsServer's boot order " + SP_DN);
    System.out.println("Current State of the lsServer : " + lsServer.getOperState());
}
Also used : HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.testng.annotations.Test)

Example 28 with LsServer

use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.

the class UcsComputeDevice method setSanBootTarget.

@Override
public void setSanBootTarget(ComputeSystem cs, URI computeElementId, URI hostId, URI volumeId, boolean waitForServerRestart) throws InternalException {
    ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, computeElementId);
    Map<String, Map<String, Integer>> hbaToStoragePorts = getHBAToStoragePorts(volumeId, hostId);
    // zoning map will be empty in older releases. Do we need to still continue this operation?
    try {
        if (null != computeElement) {
            StringBuilder errorMessage = new StringBuilder();
            LsServer lsServer = ucsmService.setServiceProfileToSanBoot(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), computeElement.getDn(), hbaToStoragePorts, 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 SAN boot target due to error from UCSM Service \n " + errorMessage);
            }
        } else {
            throw new RuntimeException("ComputeElement object is null for id " + computeElementId);
        }
    } catch (Exception e) {
        throw ComputeSystemControllerException.exceptions.unableToSetSanBootTarget(computeElementId.toString(), e);
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) Map(java.util.Map) HashMap(java.util.HashMap) 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 29 with LsServer

use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.

the class UcsComputeDevice method unbindHostFromTemplate.

@Override
public String unbindHostFromTemplate(URI computeSystemId, URI hostId) throws InternalException {
    LOGGER.info("unbindHostFromTemplate");
    Host host = _dbClient.queryObject(Host.class, hostId);
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    String sptDn = null;
    try {
        // Test mechanism to invoke a failure. No-op on production systems.
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_069);
        // No need to check for initiators here, we are only unbinding the service profile template
        if (host != null && !NullColumnValueGetter.isNullURI(host.getComputeElement()) && host.getUuid() != null) {
            ComputeElement ce = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
            URI sptId = URI.create(ce.getSptId());
            UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, sptId);
            sptDn = template.getDn();
            LsServer sp = ucsmService.getLsServer(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), host.getUuid());
            if (sp != null) {
                URL ucsmURL = getUcsmURL(cs);
                StringBuilder errorMessage = new StringBuilder();
                if (null == ucsmService.unbindSPFromTemplate(ucsmURL.toString(), cs.getUsername(), cs.getPassword(), sp.getDn(), errorMessage)) {
                    LOGGER.error("Failed to unbind service profile from template due to error from UCSM Service. \n " + errorMessage.toString());
                    throw new RuntimeException("Failed to unbind service profile from template due to error from UCSM Service. \n " + errorMessage.toString());
                }
                LOGGER.info("Successfully unbound host {} from template {}", host.getLabel(), template.getLabel());
            } else {
                LOGGER.error("Unable to unbind service profile to template.  LsServer is null");
                throw new RuntimeException("Unable to unbind service profile to template.  LsServer is null");
            }
        } else {
            LOGGER.error("Unable to unbind service profile to template, due to insufficient host data.  Host or ComputeElement or host UUID is null");
            throw new RuntimeException("Unable to unbind service profile to template, due to insufficient host data.  Host or host's computeElement or host UUID is null");
        }
    } catch (Exception e) {
        LOGGER.error("Unable to unbind service profile from template due to a exception", e);
        throw ComputeSystemControllerException.exceptions.unbindHostFromTemplateFailed(host != null ? host.getId().toString() : null, e);
    }
    return sptDn;
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) URL(java.net.URL) 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 30 with LsServer

use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.

the class UcsComputeDevice method modifyLsServerNoBoot.

/**
 * Modify the LsServer to have a no boot policy
 * @param cs ComputeSystem instance
 * @param contextStepId parent StepId
 * @param stepId Id of step being executed.
 * @return LsServer instance
 */
public LsServer modifyLsServerNoBoot(ComputeSystem cs, String contextStepId, String stepId) {
    WorkflowStepCompleter.stepExecuting(stepId);
    String spDn = (String) workflowService.loadStepData(contextStepId);
    LOGGER.info("Modifying Service Profile to have no Boot Policy: " + spDn);
    LsServer lsServer = null;
    try {
        StringBuilder errorMessage = new StringBuilder();
        lsServer = ucsmService.setServiceProfileToNoBoot(getUcsmURL(cs).toString(), cs.getUsername(), cs.getPassword(), spDn, errorMessage);
        // Test mechanism to invoke a failure. No-op on production systems.
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_062);
        if (null == lsServer) {
            throw new RuntimeException("UCS invocation to set serviceProfile to No Boot failed, null LsServer was returned. \n " + errorMessage.toString());
        }
        WorkflowStepCompleter.stepSucceded(stepId);
        LOGGER.info("Done updating Service Profile : " + spDn + " from Service Profile Template : " + spDn);
    } catch (Exception e) {
        LOGGER.error("Unable to modify LsServer...", e);
        WorkflowStepCompleter.stepFailed(stepId, ComputeSystemControllerException.exceptions.unableToProvisionHost(spDn, cs.getNativeGuid(), e));
    }
    return lsServer;
}
Also used : 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)

Aggregations

LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)37 ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)20 ConfigConfMo (com.emc.cloud.platform.ucs.in.model.ConfigConfMo)9 ConfigConfig (com.emc.cloud.platform.ucs.in.model.ConfigConfig)9 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)9 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)9 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)9 MalformedURLException (java.net.MalformedURLException)9 HashMap (java.util.HashMap)9 ComputeSystemControllerTimeoutException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException)8 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 DataObject (com.emc.storageos.db.client.model.DataObject)7 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)7 JAXBElement (javax.xml.bind.JAXBElement)7 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)6 ConfigSet (com.emc.cloud.platform.ucs.out.model.ConfigSet)5 Test (org.testng.annotations.Test)5 ConfigResolveClass (com.emc.cloud.platform.ucs.in.model.ConfigResolveClass)4 EqFilter (com.emc.cloud.platform.ucs.in.model.EqFilter)3