use of com.emc.cloud.platform.clientlib.ClientGeneralException in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method createLsbootSanCatSanImage.
private LsbootSanCatSanImage createLsbootSanCatSanImage(Map<String, Integer> ports, String hba, Map<String, String> hbaToSwitchIdMap) throws ClientGeneralException {
LsbootSanCatSanImage lsbootSanCatSanImage = new LsbootSanCatSanImage();
lsbootSanCatSanImage.setType(BootType.SAN.toString().toLowerCase());
if (SwitchId.A.name().equals(hbaToSwitchIdMap.get(hba))) {
lsbootSanCatSanImage.setRn("sanimg-" + SanImagePathType.primary.toString());
lsbootSanCatSanImage.setType(SanImagePathType.primary.toString());
lsbootSanCatSanImage.setVnicName(hba);
} else if (SwitchId.B.name().equals(hbaToSwitchIdMap.get(hba))) {
lsbootSanCatSanImage.setRn("sanimg-" + SanImagePathType.secondary.toString());
lsbootSanCatSanImage.setType(SanImagePathType.secondary.toString());
lsbootSanCatSanImage.setVnicName(hba);
} else {
log.error("Unable to determine fabric A or B for initiator {}", hba);
String[] s = { "Unable to determine fabric A or B for initiator " + hba };
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, s);
}
if (ports != null && ports.size() > 0) {
Iterator<String> portIterator = ports.keySet().iterator();
if (portIterator.hasNext()) {
String port = portIterator.next();
LsbootSanCatSanImagePath lsbootSanImagePath = createLsbootSanCatSanImagePath(SanImagePathType.primary, port, ports.get(port));
lsbootSanCatSanImage.getContent().add(factory.createLsbootSanCatSanImagePath(lsbootSanImagePath));
}
if (portIterator.hasNext()) {
String port = portIterator.next();
LsbootSanCatSanImagePath lsbootSanImagePath = createLsbootSanCatSanImagePath(SanImagePathType.secondary, port, ports.get(port));
lsbootSanCatSanImage.getContent().add(factory.createLsbootSanCatSanImagePath(lsbootSanImagePath));
}
} else {
log.error("Unable to determine array targets for initiator {}", hba);
String[] s = { "Unable to determine array targets for initiator " + hba };
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, s);
}
return lsbootSanCatSanImage;
}
use of com.emc.cloud.platform.clientlib.ClientGeneralException 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() });
}
}
}
use of com.emc.cloud.platform.clientlib.ClientGeneralException in project coprhd-controller by CoprHD.
the class UCSMServiceImpl method createLsbootSanImage.
private LsbootSanImage createLsbootSanImage(Map<String, Integer> ports, String hba, Map<String, String> hbaToSwitchIdMap) throws ClientGeneralException {
LsbootSanImage lsbootSanImage = new LsbootSanImage();
if (SwitchId.A.name().equals(hbaToSwitchIdMap.get(hba))) {
lsbootSanImage.setRn("san-primary");
lsbootSanImage.setType("primary");
lsbootSanImage.setVnicName(hba);
} else if (SwitchId.B.name().equals(hbaToSwitchIdMap.get(hba))) {
lsbootSanImage.setRn("san-secondary");
lsbootSanImage.setType("secondary");
lsbootSanImage.setVnicName(hba);
}
if (ports != null && ports.size() > 0) {
Iterator<String> portIterator = ports.keySet().iterator();
if (portIterator.hasNext()) {
String port = portIterator.next();
LsbootSanImagePath lsbootSanImagePath = createLsbootSanImagePath(SanImagePathType.primary, port, ports.get(port));
lsbootSanImage.getContent().add(factory.createLsbootSanImagePath(lsbootSanImagePath));
}
if (portIterator.hasNext()) {
String port = portIterator.next();
LsbootSanImagePath lsbootSanImagePath = createLsbootSanImagePath(SanImagePathType.secondary, port, ports.get(port));
lsbootSanImage.getContent().add(factory.createLsbootSanImagePath(lsbootSanImagePath));
}
} else {
log.error("Unable to determine array targets for initiator {}", hba);
String[] s = { "Unable to determine array targets for initiator " + hba };
throw new ClientGeneralException(ClientMessageKeys.UNEXPECTED_FAILURE, s);
}
return lsbootSanImage;
}
use of com.emc.cloud.platform.clientlib.ClientGeneralException 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.clientlib.ClientGeneralException 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;
}
Aggregations