use of com.emc.cloud.platform.ucs.in.model.ConfigConfMo in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method setOsInstallVlan.
@Override
public Map<String, Boolean> setOsInstallVlan(String ucsmURL, String username, String password, String spDn, String osInstallVlanId) throws ClientGeneralException {
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
FabricVlan fabricVlan = getVlanById(ucsmURL, username, password, osInstallVlanId);
if (null == fabricVlan) {
log.error("Unable to fetch FabricVlan {}", osInstallVlanId);
String[] s = { "Unable to fetch FabricVlan - " + osInstallVlanId };
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, s);
}
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);
}
String interfaceName = getFirstVnic(lsServerOut).getName();
log.info("Selecting OS install interface " + interfaceName + " on " + lsServerOut.getName());
/**
* This is the list of vlans that were set on the interface that
*/
Map<String, Boolean> vlanMap = getVlansSetOnInterface(lsServerOut, interfaceName);
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);
VnicEther vnicEther = new VnicEther();
vnicEther.setDn(spDn + "/ether-" + interfaceName);
// Unbind vnic from vnic template
vnicEther.setNwTemplName("");
for (String vlan : vlanMap.keySet()) {
if (vlan.equals(fabricVlan.getName())) {
continue;
}
VnicEtherIf vnicEtherIfToBeDeleted = new VnicEtherIf();
vnicEtherIfToBeDeleted.setRn("if-" + vlan);
vnicEtherIfToBeDeleted.setStatus(MO_DELETED_STATUS);
vnicEtherIfToBeDeleted.setName(vlan);
vnicEther.getContent().add(factory.createVnicEtherIf(vnicEtherIfToBeDeleted));
log.info("Removing VLAN " + vlan + " from interface " + interfaceName + " temporarily for OS installation on " + lsServerOut.getName());
}
VnicEtherIf vnicEtherIf = new VnicEtherIf();
vnicEtherIf.setRn("if-" + fabricVlan.getName());
vnicEtherIf.setDefaultNet("yes");
vnicEtherIf.setStatus("");
vnicEtherIf.setName(fabricVlan.getName());
vnicEther.getContent().add(factory.createVnicEtherIf(vnicEtherIf));
log.info("Adding OS install VLAN " + fabricVlan.getName() + " temporarily to interface " + interfaceName + " on " + lsServerOut.getName());
ConfigConfig configConfig = new ConfigConfig();
configConfig.setManagedObject(factory.createVnicEther(vnicEther));
setOsInstallVlanConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
computeSession.execute(factory.createConfigConfMo(setOsInstallVlanConfMo), com.emc.cloud.platform.ucs.out.model.ConfigConfMo.class);
return vlanMap;
}
use of com.emc.cloud.platform.ucs.in.model.ConfigConfMo in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method setLsServerPowerState.
/**
* @param ucsmURL
* @param username
* @param password
* @param lsServerDN
* - is the DN of the lsServer (unique for the UCSM that's
* represented by ucsmURL)
* @param powerState
* - is "up" or "down"
* @return
* @throws ClientGeneralException
*/
@Override
public LsServer setLsServerPowerState(String ucsmURL, String username, String password, String lsServerDN, String powerState, StringBuilder errorMessage) throws ClientGeneralException {
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
ConfigConfMo configConfMo = new ConfigConfMo();
configConfMo.setInHierarchical("true");
com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
lsServer.setDn(lsServerDN);
LsPower lsPower = new LsPower();
lsPower.setRn("power");
lsPower.setState(powerState);
lsServer.getContent().add(factory.createLsPower(lsPower));
ConfigConfig configConfig = new ConfigConfig();
configConfig.setManagedObject(factory.createLsServer(lsServer));
configConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
LsServer returnedLsServer = pushLsServer(computeSession, factory, configConfMo, errorMessage);
List<LsPower> lsPowers = getSubElements(returnedLsServer.getContent(), LsPower.class);
if ((lsPowers == null) || lsPowers.isEmpty() || (lsPowers.get(0) == null) || !lsPowers.get(0).getState().equals(powerState)) {
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "Failed to set power state to '" + powerState + "' on LsServer : " + lsServerDN });
}
return returnedLsServer;
}
use of com.emc.cloud.platform.ucs.in.model.ConfigConfMo in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method bindSPToTemplate.
@Override
public LsServer bindSPToTemplate(String ucsmURL, String username, String password, String serviceProfileDn, String sptDn, StringBuilder errorMessage) throws ClientGeneralException {
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
ConfigConfMo bindSPToSPTConfigConfMo = new ConfigConfMo();
bindSPToSPTConfigConfMo.setInHierarchical(Boolean.toString(true));
com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
lsServer.setDn(serviceProfileDn);
lsServer.setSrcTemplName(sptDn);
ConfigConfig configConfig = new ConfigConfig();
configConfig.setManagedObject(factory.createLsServer(lsServer));
bindSPToSPTConfigConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
LsServer returnedLsServer = pushLsServer(computeSession, factory, bindSPToSPTConfigConfMo, errorMessage);
if ((returnedLsServer == null) || (!returnedLsServer.getDn().equals(serviceProfileDn)) || (!returnedLsServer.getSrcTemplName().equals(sptDn))) {
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "Failed to bind SP to Template '" + sptDn + "' on LsServer : " + serviceProfileDn });
}
return returnedLsServer;
}
use of com.emc.cloud.platform.ucs.in.model.ConfigConfMo in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method unbindSPFromTemplate.
@Override
public LsServer unbindSPFromTemplate(String ucsmURL, String username, String password, String serviceProfileDn, StringBuilder errorMessage) throws ClientGeneralException {
ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
ConfigConfMo unbindSPFromSPTConfigConfMo = new ConfigConfMo();
unbindSPFromSPTConfigConfMo.setInHierarchical(Boolean.toString(true));
com.emc.cloud.platform.ucs.in.model.LsServer lsServer = new com.emc.cloud.platform.ucs.in.model.LsServer();
lsServer.setDn(serviceProfileDn);
lsServer.setSrcTemplName("");
ConfigConfig configConfig = new ConfigConfig();
configConfig.setManagedObject(factory.createLsServer(lsServer));
unbindSPFromSPTConfigConfMo.getContent().add(factory.createConfigConfMoInConfig(configConfig));
LsServer pushedObject = pushLsServer(computeSession, factory, unbindSPFromSPTConfigConfMo, errorMessage);
String pushedObjectTemplateName = null;
if (pushedObject != null) {
pushedObjectTemplateName = pushedObject.getSrcTemplName();
}
if ((pushedObject == null) || (pushedObjectTemplateName != null && !pushedObjectTemplateName.equals(""))) {
// COP-26669
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, new String[] { "ServiceProfile failed to disassociate : " + serviceProfileDn });
}
return pushedObject;
}
use of com.emc.cloud.platform.ucs.in.model.ConfigConfMo 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;
}
Aggregations