use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method unbindServiceProfile.
@Override
public LsServer unbindServiceProfile(String ucsmURL, String username, String password, String spDn, StringBuilder errorMessage) throws ClientGeneralException {
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
ConfigConfMo disAssocSPFromBladeMO = new ConfigConfMo();
disAssocSPFromBladeMO.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);
LsBinding lsBinding = new LsBinding();
lsBinding.setPnDn("");
lsBinding.setStatus(MO_DELETED_STATUS);
lsServer.getContent().add(factory.createLsBinding(lsBinding));
ConfigConfig configConfig = new ConfigConfig();
configConfig.setManagedObject(factory.createLsServer(lsServer));
disAssocSPFromBladeMO.getContent().add(factory.createConfigConfMoInConfig(configConfig));
LsServer updatedLsServer = pushLsServer(computeSession, factory, disAssocSPFromBladeMO, errorMessage);
log.info("The new Oper State of the Service Profile is : " + updatedLsServer.getOperState());
return updatedLsServer;
}
use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method getLsServerByDn.
private LsServer getLsServerByDn(String ucsmURL, String username, String password, String spDn) throws ClientGeneralException {
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 == 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);
}
return lsServerOut;
}
use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method getAllAssociatedLsServers.
@Override
public Map<String, LsServer> getAllAssociatedLsServers(String ucsmURL, String username, String password) throws ClientGeneralException {
Map<String, LsServer> associatedLsServers = Collections.synchronizedMap(new HashMap<String, LsServer>());
;
try {
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
ConfigResolveClass configResolveClass = new ConfigResolveClass();
configResolveClass.setClassId(NamingClassId.LS_SERVER);
configResolveClass.setInHierarchical("true");
// configResolveClass.getContent()
FilterFilter inFilter = new FilterFilter();
EqFilter eqFilter = new EqFilter();
eqFilter.setProperty("assocState");
eqFilter.setClazz(NamingClassId.LS_SERVER);
eqFilter.setValue("associated");
inFilter.setAbstractFilter(factory.createEq(eqFilter));
configResolveClass.getContent().add(new JAXBElement<FilterFilter>(new QName("inFilter"), FilterFilter.class, inFilter));
com.emc.cloud.platform.ucs.out.model.ConfigResolveClass configResolveClassOut = computeSession.execute(factory.createConfigResolveClass(configResolveClass), com.emc.cloud.platform.ucs.out.model.ConfigResolveClass.class);
ConfigSet configSet = null;
if (configResolveClassOut.getContent() != null && !configResolveClassOut.getContent().isEmpty()) {
for (Object object : configResolveClassOut.getContent()) {
if (object instanceof JAXBElement<?>) {
if (!(((JAXBElement) object).getValue() instanceof ConfigSet)) {
continue;
}
configSet = ((JAXBElement<ConfigSet>) object).getValue();
if (configSet != null && configSet.getManagedObject() != null && !configSet.getManagedObject().isEmpty()) {
for (JAXBElement<?> managedObject : configSet.getManagedObject()) {
if (managedObject.getValue() instanceof LsServer) {
LsServer lsServer = (LsServer) managedObject.getValue();
associatedLsServers.put(lsServer.getPnDn(), lsServer);
}
}
}
}
}
}
} catch (ClientGeneralException e) {
log.error("Unable to get all associated lsServers", e);
throw e;
}
return associatedLsServers;
}
use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method getServiceProfileTemplates.
@Override
public List<LsServer> getServiceProfileTemplates(String ucsmURL, String username, String password) throws ClientGeneralException {
List<LsServer> serviceProfileTemplates = Collections.synchronizedList(new ArrayList<LsServer>());
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
ConfigResolveClass configResolveClass = new ConfigResolveClass();
configResolveClass.setClassId(NamingClassId.LS_SERVER);
configResolveClass.setInHierarchical("true");
FilterFilter inFilter = new FilterFilter();
OrFilter orFilter = new OrFilter();
EqFilter eqFilterInitTemplate = new EqFilter();
eqFilterInitTemplate.setProperty("type");
eqFilterInitTemplate.setClazz(NamingClassId.LS_SERVER);
eqFilterInitTemplate.setValue("initial-template");
EqFilter eqFilterUpdatingTemplate = new EqFilter();
eqFilterUpdatingTemplate.setProperty("type");
eqFilterUpdatingTemplate.setClazz(NamingClassId.LS_SERVER);
eqFilterUpdatingTemplate.setValue("updating-template");
orFilter.getAbstractFilter().add(factory.createEq(eqFilterUpdatingTemplate));
orFilter.getAbstractFilter().add(factory.createEq(eqFilterInitTemplate));
inFilter.setAbstractFilter(factory.createOr(orFilter));
configResolveClass.getContent().add(new JAXBElement<FilterFilter>(new QName("inFilter"), FilterFilter.class, inFilter));
com.emc.cloud.platform.ucs.out.model.ConfigResolveClass configResolveClassOut = computeSession.execute(factory.createConfigResolveClass(configResolveClass), com.emc.cloud.platform.ucs.out.model.ConfigResolveClass.class);
ConfigSet configSet = null;
if (configResolveClassOut.getContent() != null && !configResolveClassOut.getContent().isEmpty()) {
for (Object object : configResolveClassOut.getContent()) {
if (object instanceof JAXBElement<?>) {
if (!(((JAXBElement) object).getValue() instanceof ConfigSet)) {
continue;
}
configSet = ((JAXBElement<ConfigSet>) object).getValue();
if (configSet != null && configSet.getManagedObject() != null && !configSet.getManagedObject().isEmpty()) {
for (JAXBElement<?> managedObject : configSet.getManagedObject()) {
if (managedObject.getValue() instanceof LsServer) {
serviceProfileTemplates.add((LsServer) managedObject.getValue());
LsServer spt = (LsServer) managedObject.getValue();
log.info("SPT Name:" + spt.getName());
}
}
}
}
}
}
return serviceProfileTemplates;
}
use of com.emc.cloud.platform.ucs.out.model.LsServer in project coprhd-controller by CoprHD.
the class UCSMServiceTest method testSetLsServerPowerState.
@Test(groups = "onDemand1")
public void testSetLsServerPowerState() throws ClientGeneralException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
Map<String, LsServer> associatedLsServers = ucsmService.getAllAssociatedLsServers(UCSM_SERVICE, UCSM_HOST_USERNAME, UCSM_HOST_PASSWORD);
String powerStateToSet = null;
if (associatedLsServers != null && !associatedLsServers.isEmpty()) {
for (LsServer lsServer : associatedLsServers.values()) {
if (SP_DN.equals(lsServer.getDn())) {
if (lsServer.getContent() != null && !lsServer.getContent().isEmpty()) {
for (Object object : lsServer.getContent()) {
if (object instanceof JAXBElement<?>) {
if (((JAXBElement) object).getValue() instanceof LsPower) {
LsPower lsPower = ((JAXBElement<LsPower>) object).getValue();
if ("up".equals(lsPower.getState())) {
powerStateToSet = "down";
} else if ("down".equals(lsPower.getState())) {
powerStateToSet = "up";
}
LsServer lsServerOut = ucsmService.setLsServerPowerState(UCSM_SERVICE, UCSM_HOST_USERNAME, UCSM_HOST_PASSWORD, lsServer.getDn(), powerStateToSet, new StringBuilder());
if (lsServerOut.getContent() != null && !lsServerOut.getContent().isEmpty()) {
for (Object object2 : lsServerOut.getContent()) {
if (object2 instanceof JAXBElement<?>) {
if (((JAXBElement) object2).getValue() instanceof LsPower) {
LsPower lsPower2 = ((JAXBElement<LsPower>) object2).getValue();
Assert.assertTrue(powerStateToSet.equals(lsPower2.getState()));
}
}
}
}
}
}
}
}
}
}
}
System.out.println("Number of associated lsServers found: " + associatedLsServers.size());
}
Aggregations