Search in sources :

Example 16 with LsServer

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

the class UCSMServiceImpl method bindSPToComputeElement.

@Override
public LsServer bindSPToComputeElement(String ucsmURL, String username, String password, String serviceProfileDn, String computeElementDn, StringBuilder errorMessage) throws ClientGeneralException {
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigConfMo bindSPToCEConfigConfMo = new ConfigConfMo();
    bindSPToCEConfigConfMo.setInHierarchical(Boolean.toString(true));
    // bindSPToCEConfigConfMo.
    com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
    lsServer.setDn(serviceProfileDn);
    LsBinding lsBinding = new LsBinding();
    lsBinding.setPnDn(computeElementDn);
    lsServer.getContent().add(factory.createLsBinding(lsBinding));
    ConfigConfig configConfig = new ConfigConfig();
    configConfig.setManagedObject(factory.createLsServer(lsServer));
    bindSPToCEConfigConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
    LsServer returnedLsServer = pushLsServer(computeSession, factory, bindSPToCEConfigConfMo, errorMessage);
    if ((returnedLsServer == null) || returnedLsServer.getAssignState().equals(ASSOC_STATE_UNASSOCIATED)) {
        throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "Failed to bind ServiceProfile " + serviceProfileDn + " to ComputeElement '" + computeElementDn + "' on LsServer : " + serviceProfileDn });
    }
    return returnedLsServer;
}
Also used : LsBinding(com.emc.cloud.platform.ucs.in.model.LsBinding) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ConfigConfMo(com.emc.cloud.platform.ucs.in.model.ConfigConfMo) ConfigConfig(com.emc.cloud.platform.ucs.in.model.ConfigConfig) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException)

Example 17 with LsServer

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

the class UCSMServiceTest method testDeleteServiceProfile.

@Test(groups = "onDemand6")
public void testDeleteServiceProfile() throws ClientGeneralException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    ucsmService.deleteServiceProfile(UCSM_SERVICE, UCSM_HOST_USERNAME, UCSM_HOST_PASSWORD, SP_DN3, new StringBuilder());
    LsServer deletedServiceProfile = ucsmService.getManagedObject(UCSM_SERVICE, UCSM_HOST_USERNAME, UCSM_HOST_PASSWORD, SP_DN3, true, LsServer.class);
    Assert.assertNull(deletedServiceProfile);
    System.out.println("Service Profile : " + SP_DN3 + " : DELETED");
}
Also used : LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) Test(org.testng.annotations.Test)

Example 18 with LsServer

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

the class UCSMServiceTest method testSetLanBoot.

@Test(groups = "onDemand50", dependsOnMethods = "testSetNoBoot")
public void testSetLanBoot() throws ClientGeneralException {
    LsServer lsServer = ucsmService.setServiceProfileToLanBoot(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 19 with LsServer

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

the class UCSMServiceImpl method removeOsInstallVlan.

@Override
public void removeOsInstallVlan(String ucsmURL, String username, String password, String spDn, String osInstallVlanId, Map<String, Boolean> vlanMap) throws ClientGeneralException {
    FabricVlan fabricVlan = getVlanById(ucsmURL, username, password, osInstallVlanId);
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigConfMo setOsInstallVlanConfMo = new ConfigConfMo();
    setOsInstallVlanConfMo.setInHierarchical(Boolean.toString(true));
    com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
    lsServer.setDn(spDn);
    LsServer lsServerOut = getManagedObject(ucsmURL, username, password, spDn, true, LsServer.class);
    if (null == fabricVlan) {
        log.error("Unable to fetch FabricVlan {}", osInstallVlanId);
        String[] s = { "Unable to fetch FabricVlan - " + osInstallVlanId };
        throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, s);
    }
    if (null == lsServerOut) {
        log.error("Unable to fetch LsServer for spDn {}", spDn);
        String[] s = { "Unable to fetch LsServer for spDn " + spDn };
        throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, s);
    }
    com.emc.cloud.platform.ucs.out.model.VnicEther firstVnic = getFirstVnic(lsServerOut);
    String interfaceName = firstVnic.getName();
    log.info("Restoring VLANs on " + lsServerOut.getName() + " after OS install on interface: " + interfaceName);
    Map<String, Boolean> vlansOnInterface = getVlansSetOnInterface(lsServerOut, interfaceName);
    if ((vlansOnInterface.size() != 1) || (vlansOnInterface.get(fabricVlan.getName()) == null)) {
        String[] s = { "Error restoring VLANs after OS Installation on " + lsServerOut.getName() + ".  VNICs were modified during OS install.  Interface " + interfaceName + " does not contain just the OS install VLAN.  It contains " + vlansOnInterface.keySet() };
        throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, s);
    }
    VnicEther vnicEther = new VnicEther();
    vnicEther.setDn(spDn + "/ether-" + interfaceName);
    vnicEther.setNwTemplName(firstVnic.getNwTemplName());
    boolean shouldDeleteOsInstallVlan = true;
    for (String vlan : vlanMap.keySet()) {
        if (vlan.equals(fabricVlan.getName())) {
            shouldDeleteOsInstallVlan = false;
        }
        VnicEtherIf vnicEtherIfToAdded = new VnicEtherIf();
        vnicEtherIfToAdded.setRn("if-" + vlan);
        vnicEtherIfToAdded.setName(vlan);
        vnicEtherIfToAdded.setStatus("");
        if (vlanMap.get(vlan)) {
            vnicEtherIfToAdded.setDefaultNet(DEFAULT_NETWORK_VALUES.YES.getValue());
        }
        vnicEther.getContent().add(factory.createVnicEtherIf(vnicEtherIfToAdded));
        log.info("  Adding VLAN " + vlan + " to be restored to interface " + interfaceName + " of " + lsServerOut.getName());
    }
    if (shouldDeleteOsInstallVlan) {
        VnicEtherIf vnicEtherIf = new VnicEtherIf();
        vnicEtherIf.setRn("if-" + fabricVlan.getName());
        vnicEtherIf.setStatus(MO_DELETED_STATUS);
        vnicEtherIf.setName(fabricVlan.getName());
        vnicEther.getContent().add(factory.createVnicEtherIf(vnicEtherIf));
        log.info("  Adding VLAN " + fabricVlan.getName() + " to be removed from interface " + interfaceName + " of " + lsServerOut.getName());
    }
    ConfigConfig configConfig = new ConfigConfig();
    configConfig.setManagedObject(factory.createVnicEther(vnicEther));
    setOsInstallVlanConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
    StringBuilder errorMessage = new StringBuilder();
    com.emc.cloud.platform.ucs.out.model.VnicEther returnedVnicEther = pushConfigConfMo(computeSession, factory, setOsInstallVlanConfMo, com.emc.cloud.platform.ucs.out.model.VnicEther.class, true, errorMessage).get(// expect 1
    0);
    List<VnicEtherIf> vnicEtherIfs = getSubElements(returnedVnicEther.getContent(), VnicEtherIf.class);
    for (String vlan : vlanMap.keySet()) {
        for (VnicEtherIf vnicEtherIf : vnicEtherIfs) {
            if (vnicEtherIf.getName().equals(vlan)) {
                throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "Failed to restore vNIC after OS Install with vLAN " + vlan });
            }
        }
    }
    for (VnicEtherIf vnicEtherIf : vnicEtherIfs) {
        if (vnicEtherIf.getName().equals(fabricVlan.getName())) {
            throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "Failed to remove OS Install vLAN " + fabricVlan.getName() });
        }
    }
}
Also used : VnicEtherIf(com.emc.cloud.platform.ucs.in.model.VnicEtherIf) FabricVlan(com.emc.cloud.platform.ucs.out.model.FabricVlan) ConfigConfig(com.emc.cloud.platform.ucs.in.model.ConfigConfig) ClientGeneralException(com.emc.cloud.platform.clientlib.ClientGeneralException) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) VnicEther(com.emc.cloud.platform.ucs.in.model.VnicEther) ConfigConfMo(com.emc.cloud.platform.ucs.in.model.ConfigConfMo)

Example 20 with LsServer

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

the class UCSMServiceImpl method deleteServiceProfile.

@Override
public void deleteServiceProfile(String ucsmURL, String username, String password, String spDn, StringBuilder errorMessage) throws ClientGeneralException {
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigConfMo deleteSPMO = new ConfigConfMo();
    deleteSPMO.setInHierarchical(Boolean.toString(true));
    com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
    lsServer.setDn(spDn);
    lsServer.setStatus(MO_DELETED_STATUS);
    ConfigConfig configConfig = new ConfigConfig();
    configConfig.setManagedObject(factory.createLsServer(lsServer));
    deleteSPMO.getContent().add(factory.createConfigConfMoInConfig(configConfig));
    pushLsServer(computeSession, factory, deleteSPMO, errorMessage);
    log.info("Deleted the Service Profile with dn : " + spDn);
}
Also used : ConfigConfMo(com.emc.cloud.platform.ucs.in.model.ConfigConfMo) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ConfigConfig(com.emc.cloud.platform.ucs.in.model.ConfigConfig)

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