use of com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverPorts.
/**
* Retrieve the Data Mover IP Interfaces (aka Storage Ports) for the specified VNX File Storage Array
*
* @param system storage system information including credentials.
* @return Map of New and Existing Storage Ports
* @throws VNXFileCollectionException
* @throws IOException
*/
private HashMap<String, List<StoragePort>> discoverPorts(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException, IOException {
HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
List<PhysicalNAS> modifiedServers = new ArrayList<PhysicalNAS>();
_logger.info("Start storage port discovery for storage system {}", system.getId());
// Retrieve the list of data movers interfaces for the VNX File device.
List<VNXDataMoverIntf> allDmIntfs = getPorts(system);
List<VNXVdm> vdms = getVdmPortGroups(system);
// Filter VDM ports
List<VNXDataMoverIntf> dataMovers = null;
Map<String, VNXDataMoverIntf> dmIntMap = new HashMap();
for (VNXDataMoverIntf intf : allDmIntfs) {
_logger.info("getPorts Adding {} : {}", intf.getName(), intf.getIpAddress());
dmIntMap.put(intf.getName(), intf);
}
// Changes to fix Jira CTRL - 9151
VNXFileSshApi sshDmApi = new VNXFileSshApi();
sshDmApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
// collect VDM interfaces
for (VNXVdm vdm : vdms) {
// Sometimes getVdmPortGroups(system) method does not collect all VDM interfaces,
// So running Collect NFS/CIFS interfaces from nas_server -info command. This will return
// Interfaces assigned to VDM and not thru CIFS servers
Map<String, String> vdmIntfs = sshDmApi.getVDMInterfaces(vdm.getVdmName());
for (String vdmIF : vdmIntfs.keySet()) {
_logger.info("Remove VDM interface {}", vdmIF);
dmIntMap.remove(vdmIF);
}
}
// Got the filtered out DataMover Interfaces
List<VNXDataMoverIntf> dmIntfs = new ArrayList(dmIntMap.values());
_logger.info("Number unfiltered mover interfaces found: {}", allDmIntfs.size());
_logger.info("Number mover interfaces found: {}", dmIntfs.size());
// Create the list of storage ports.
for (VNXDataMoverIntf intf : dmIntfs) {
StoragePort port = null;
StorageHADomain matchingHADomain = getMatchingMoverById(movers, intf.getDataMoverId());
// Check for valid data mover
if (null == matchingHADomain) {
continue;
}
// Check if storage port was already discovered
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
port = findExistingPort(portNativeGuid);
if (null == port) {
// Since a port was not found, attempt with previous naming convention (ADAPTER instead of PORT)
String oldNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.ADAPTER);
port = findExistingPort(oldNativeGuid);
if (null != port) {
// found with old naming convention, therefore update name.
port.setLabel(portNativeGuid);
port.setNativeGuid(portNativeGuid);
}
}
// If data mover interface was not previously discovered, add new storage port
if (port == null) {
port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setLabel(portNativeGuid);
port.setTransportType("IP");
port.setNativeGuid(portNativeGuid);
port.setStorageDevice(system.getId());
port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
port.setPortName(intf.getName());
port.setPortNetworkId(intf.getIpAddress());
port.setPortGroup(intf.getDataMoverId());
port.setStorageHADomain(matchingHADomain.getId());
_logger.info("Creating new storage port using NativeGuid : {} name : {}, IP : {}", new Object[] { portNativeGuid, intf.getName(), intf.getIpAddress() });
newStoragePorts.add(port);
} else {
port.setStorageHADomain(matchingHADomain.getId());
existingStoragePorts.add(port);
}
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
// Set storage port details to vNas
PhysicalNAS nas = findPhysicalNasByNativeId(system, intf.getDataMoverId());
if (nas != null) {
if (nas.getStoragePorts() != null && !nas.getStoragePorts().isEmpty()) {
if (nas.getStoragePorts().contains(port.getId())) {
nas.getStoragePorts().remove(port.getId());
}
}
nas.getStoragePorts().add(port.getId().toString());
modifiedServers.add(nas);
_logger.info("PhysicalNAS : {} : port : {} got modified", nas.getId(), port.getPortName());
}
}
// Persist the changed nas servers!!!
if (modifiedServers != null && !modifiedServers.isEmpty()) {
_logger.info("Modified PhysicalNAS servers size {}", modifiedServers.size());
_dbClient.persistObject(modifiedServers);
}
_logger.info("Storage port discovery for storage system {} complete", system.getId());
for (StoragePort newPort : newStoragePorts) {
_logger.info("New Storage Port : {} : {}", newPort.getNativeGuid(), newPort.getPortName() + ":" + newPort.getId());
}
for (StoragePort port : existingStoragePorts) {
_logger.info("Old Storage Port : {} : {}", port.getNativeGuid(), port.getPortName() + ":" + port.getId());
}
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
}
use of com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method discoverVdmPorts.
/**
* Retrieve the Data Mover IP Interfaces (aka Storage Ports) for the specified VNX File Storage Array
*
* @param system storage system information including credentials.
* @return Map of New and Existing Storage Ports
* @throws VNXFileCollectionException
* @throws IOException
*/
private HashMap<String, List<StoragePort>> discoverVdmPorts(StorageSystem system, Set<StorageHADomain> movers) throws VNXFileCollectionException, VNXException, IOException {
HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
_logger.info("Start storage port discovery for storage system {}", system.getId());
HashMap<String, VNXDataMoverIntf> vdmIntMap = new HashMap();
List<VirtualNAS> modifiedServers = new ArrayList<VirtualNAS>();
// Retrieve VDMs
List<VNXVdm> vdms = getVdmPortGroups(system);
// Retrieve the list of data movers interfaces for the VNX File device.
List<VNXDataMoverIntf> vdmIntfs = getVdmPorts(system, vdms);
for (VNXDataMoverIntf intf : vdmIntfs) {
_logger.info("getVdmPorts Adding {} : {}", intf.getName(), intf.getIpAddress());
vdmIntMap.put(intf.getName(), intf);
}
_logger.info("Number VDM mover interfaces found: {}", vdmIntfs.size());
for (VNXVdm vdm : vdms) {
List<String> vNasStoragePorts = new ArrayList<String>();
// Create the list of storage ports.
for (String vdmIF : vdm.getInterfaces()) {
VNXDataMoverIntf intf = vdmIntMap.get(vdmIF);
StoragePort port = null;
StorageHADomain matchingHADomain = getMatchingMoverByName(movers, vdm.getVdmName());
// Check for valid data mover
if (null == matchingHADomain) {
continue;
}
// Check if storage port was already discovered
String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, intf.getIpAddress(), NativeGUIDGenerator.PORT);
port = findExistingPort(portNativeGuid);
// If VDM interface was not previously discovered, add new storage port
if (port == null) {
port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setLabel(portNativeGuid);
port.setTransportType("IP");
port.setNativeGuid(portNativeGuid);
port.setStorageDevice(system.getId());
port.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
port.setPortName(intf.getName());
port.setPortNetworkId(intf.getIpAddress());
port.setPortGroup(vdm.getVdmId());
port.setStorageHADomain(matchingHADomain.getId());
_logger.info("Creating new storage port using NativeGuid : {} name : {}, IP : {}", new Object[] { portNativeGuid, intf.getName(), intf.getIpAddress(), intf.getDataMoverId(), vdm.getVdmId(), port.getPortName(), port.getPortGroup() });
newStoragePorts.add(port);
} else {
port.setStorageHADomain(matchingHADomain.getId());
port.setPortGroup(vdm.getVdmId());
existingStoragePorts.add(port);
}
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
port.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
vNasStoragePorts.add(port.getId().toString());
}
// Set storage port details to vNas
VirtualNAS vNas = findvNasByNativeId(system, vdm.getVdmId());
if (vNas != null) {
vNas.getStoragePorts().clear();
vNas.getStoragePorts().addAll(vNasStoragePorts);
modifiedServers.add(vNas);
}
}
// Persist the changed nas servers!!!
if (modifiedServers != null && !modifiedServers.isEmpty()) {
_logger.info("Modified VirtualNAS servers size {}", modifiedServers.size());
_dbClient.persistObject(modifiedServers);
}
_logger.info("Storage port discovery for storage system {} complete", system.getId());
for (StoragePort newPort : newStoragePorts) {
_logger.debug("New Storage Port : {} : {}", newPort.getNativeGuid(), newPort.getPortName() + ":" + newPort.getId());
}
for (StoragePort port : existingStoragePorts) {
_logger.debug("Old Storage Port : {} : {}", port.getNativeGuid(), port.getPortName() + ":" + port.getId());
}
storagePorts.put(NEW, newStoragePorts);
storagePorts.put(EXISTING, existingStoragePorts);
return storagePorts;
}
use of com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method getPorts.
private List<VNXDataMoverIntf> getPorts(final StorageSystem system) throws VNXException {
List<VNXDataMoverIntf> dataMovers = null;
try {
Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
_discExecutor.setKeyMap(reqAttributeMap);
_discExecutor.execute((Namespace) _discNamespaces.getNsList().get("vnxfileStoragePort"));
dataMovers = (ArrayList<VNXDataMoverIntf>) _discExecutor.getKeyMap().get(VNXFileConstants.STORAGE_PORTS);
} catch (BaseCollectionException e) {
throw new VNXException("Get Port op failed", e);
}
return dataMovers;
}
use of com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method getVdmPorts.
private List<VNXDataMoverIntf> getVdmPorts(final StorageSystem system, final List<VNXVdm> vdms) throws VNXException {
List<VNXDataMoverIntf> dataMoverInterfaces = null;
List<VNXDataMoverIntf> vdmInterfaces = new ArrayList<VNXDataMoverIntf>();
Map<String, VNXDataMoverIntf> dmIntMap = new HashMap();
try {
Map<String, Object> reqAttributeMap = getRequestParamsMap(system);
_discExecutor.setKeyMap(reqAttributeMap);
_discExecutor.execute((Namespace) _discNamespaces.getNsList().get("vnxfileStoragePort"));
dataMoverInterfaces = (ArrayList<VNXDataMoverIntf>) _discExecutor.getKeyMap().get(VNXFileConstants.STORAGE_PORTS);
// Make map
for (VNXDataMoverIntf intf : dataMoverInterfaces) {
dmIntMap.put(intf.getName(), intf);
}
VNXFileSshApi sshDmApi = new VNXFileSshApi();
sshDmApi.setConnParams(system.getIpAddress(), system.getUsername(), system.getPassword());
// collect VDM interfaces
for (VNXVdm vdm : vdms) {
for (String vdmIF : vdm.getInterfaces()) {
VNXDataMoverIntf vdmInterface = dmIntMap.get(vdmIF);
vdmInterfaces.add(vdmInterface);
_logger.info("Use this VDM interface {}", vdmIF);
}
// Collect NFS/CIFS interfaces from nas_server -info command. This will return
// Interfaces assigned to VDM and not thru CIFS servers
Map<String, String> vdmIntfs = sshDmApi.getVDMInterfaces(vdm.getVdmName());
for (String vdmNFSIf : vdmIntfs.keySet()) {
VNXDataMoverIntf vdmInterface = dmIntMap.get(vdmNFSIf);
if (vdmInterface != null) {
_logger.info("Use this NFS VDM interface {} for {}", vdmInterface, vdmNFSIf);
vdmInterfaces.add(vdmInterface);
// Check if the interface is already on the VDM, if not, add it.
if (!vdm.getInterfaces().contains(vdmInterface.getName())) {
vdm.getInterfaces().add(vdmInterface.getName());
}
} else {
_logger.info("No interface found for {}", vdmNFSIf);
}
}
}
} catch (BaseCollectionException e) {
throw new VNXException("Get VDM Port op failed", e);
}
return vdmInterfaces;
}
use of com.emc.storageos.vnx.xmlapi.VNXDataMoverIntf in project coprhd-controller by CoprHD.
the class VNXStoragePortsProcessor method processResult.
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
final PostMethod result = (PostMethod) resultObj;
_logger.info("processing vnx storageport response" + resultObj);
try {
ResponsePacket responsePacket = (ResponsePacket) _unmarshaller.unmarshal(result.getResponseBodyAsStream());
if (null != responsePacket.getPacketFault()) {
Status status = responsePacket.getPacketFault();
processErrorStatus(status, keyMap);
} else {
List<Object> queryResponse = getQueryResponse(responsePacket);
Iterator<Object> queryRespItr = queryResponse.iterator();
List<VNXDataMoverIntf> dmIntfs = new ArrayList<VNXDataMoverIntf>();
while (queryRespItr.hasNext()) {
Object responseObj = queryRespItr.next();
if (responseObj instanceof MoverInterface) {
MoverInterface mover = (MoverInterface) responseObj;
// Check that the interface is up and not an internal network interface.
String name = mover.getName();
if (mover.isUp() && !name.startsWith("el")) {
VNXDataMoverIntf vnxMover = new VNXDataMoverIntf(mover.getName(), mover.getIpAddress(), mover.getMover());
_logger.debug("Port Information : {}", vnxMover.toString());
dmIntfs.add(vnxMover);
}
}
}
_logger.info("Number of Ports found : {}", dmIntfs.size());
keyMap.put(VNXFileConstants.STORAGE_PORTS, dmIntfs);
// Extract session information from the response header.
Header[] headers = result.getResponseHeaders(VNXFileConstants.CELERRA_SESSION);
if (null != headers && headers.length > 0) {
keyMap.put(VNXFileConstants.CELERRA_SESSION, headers[0].getValue());
_logger.info("Recieved celerra storage ports information from the Server.");
}
}
} catch (final Exception ex) {
_logger.error("Exception occurred while processing the vnx storage ports info response due to ", ex);
} finally {
result.releaseConnection();
}
}
Aggregations