use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkDeviceController method removeSanZones.
@Override
public void removeSanZones(URI uri, String fabricId, String fabricWwn, List<Zone> zones, boolean activateZones, String taskId) throws ControllerException {
NetworkSystem networkSytem = getNetworkSystemObject(uri);
// Lock to prevent concurrent operations on the same VSAN / FABRIC.
InterProcessLock fabricLock = NetworkFabricLocker.lockFabric(fabricId, _coordinator);
try {
// Get the network system reference for the type of network system managed
// by the controller.
NetworkSystemDevice networkDevice = getDevice(networkSytem.getSystemType());
if (networkDevice == null) {
throw NetworkDeviceControllerException.exceptions.removeSanZonesFailedNull(networkSytem.getSystemType());
}
BiosCommandResult result = networkDevice.removeZones(networkSytem, zones, fabricId, fabricWwn, activateZones);
setStatus(NetworkSystem.class, networkSytem.getId(), taskId, result.isCommandSuccess(), result.getServiceCoded());
_auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.REMOVE_SAN_ZONE, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, networkSytem.getId().toString(), networkSytem.getLabel(), networkSytem.getPortNumber(), networkSytem.getUsername(), networkSytem.getSmisProviderIP(), networkSytem.getSmisPortNumber(), networkSytem.getSmisUserName(), networkSytem.getSmisUseSSL());
} catch (Exception ex) {
ServiceError serviceError = NetworkDeviceControllerException.errors.removeSanZonesFailedExc(networkSytem.getSystemType(), ex);
_dbClient.error(NetworkSystem.class, networkSytem.getId(), taskId, serviceError);
} finally {
NetworkFabricLocker.unlockFabric(fabricId, fabricLock);
}
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkDeviceController method getFabricIds.
@Override
public List<String> getFabricIds(URI uri) throws ControllerException {
NetworkSystem device = getNetworkSystemObject(uri);
// Get the file device reference for the type of file device managed
// by the controller.
NetworkSystemDevice networkDevice = getDevice(device.getSystemType());
if (networkDevice == null) {
throw NetworkDeviceControllerException.exceptions.getFabricIdsFailedNull(device.getSystemType());
}
try {
List<String> fabricIds = networkDevice.getFabricIds(device);
return fabricIds;
} catch (Exception ex) {
Date date = new Date();
throw NetworkDeviceControllerException.exceptions.getFabricIdsFailedExc(uri.toString(), date.toString(), ex);
}
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkDeviceController method fetchInitiatorsZones.
/**
* For the given network and initiators, which are in the network,
* use one of the network's network system to get the zones and populate
* wwnToZones map with the zones found. Return the network system
* used to get the zones.
* <p>
* This function is created because to create the ZoneInfoMap of {@link #getInitiatorsInNetworkZoneInfoMap(NetworkLite, List, Map)},
* both the network system used and the zones are needed, while for {@link #getInitiatorsInNetworkZones(NetworkLite, List)} only the
* zones are needed. This solution was to support both calling functions.
* <p>
* Note if a zone is found that has more than one of the initiator, the zone will be returned once for each initiator.
*
* @param network the network of the initiators
* @param initiators the initiators
* @param wwnToZones a IN/OUT parameters which is a map to be populated
* with the zone mappings found
* @return the network system used to get the zones.
*/
private NetworkSystem fetchInitiatorsZones(NetworkLite network, List<Initiator> initiators, Map<String, List<Zone>> wwnToZones) {
// Check some network systems are discovered.
if (!NetworkUtil.areNetworkSystemDiscovered(_dbClient)) {
return null;
}
if (!Transport.FC.toString().equals(network.getTransportType())) {
return null;
}
if (initiators == null || initiators.isEmpty()) {
return null;
}
// Select the network system to use
NetworkSystem networkSystem = null;
Map<String, Initiator> wwnToInitiatorMap = wwnToInitiatorMap(initiators);
List<NetworkSystem> zoningNetworkSystems = _networkScheduler.getZoningNetworkSystems(network, null);
Iterator<NetworkSystem> itr = zoningNetworkSystems.iterator();
while (itr.hasNext()) {
networkSystem = itr.next();
try {
if (networkSystem != null) {
_log.info("Trying network system {} for network {} to get initiator zones.", networkSystem.getLabel(), network.getLabel());
wwnToZones.putAll(getDevice(networkSystem.getSystemType()).getEndpointsZones(networkSystem, NetworkUtil.getNetworkWwn(network), network.getNativeId(), wwnToInitiatorMap.keySet()));
// if we get here, we were successful at getting the zones, do not try any more network systems
break;
}
} catch (Exception ex) {
// if we hit and exception, log it and try the next network system;
wwnToZones.clear();
_log.error("Failed to get the zones for initiators {} in network {} " + "using network system {}. Will try the other available network systems", new Object[] { wwnToInitiatorMap.keySet(), network.getLabel(), networkSystem == null ? "null" : networkSystem.getLabel() });
}
networkSystem = null;
}
if (networkSystem == null) {
_log.error("Failed to find a registered network system in good discovery status to discover the zones");
throw NetworkDeviceControllerException.exceptions.failedToFindNetworkSystem(wwnToInitiatorMap.keySet(), network.getLabel());
}
return networkSystem;
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkDeviceController method removeZone.
/**
* Remove a zone.
*
* @param volUri URI of the Volume
* @param fabricInfo NetworkFabricInfo generated by NetworkScheduler
* @return BiosCommandResult
*/
public BiosCommandResult removeZone(URI volUri, NetworkFCZoneInfo fabricInfo, boolean activateZones) throws ControllerException {
ServiceError serviceError = NetworkDeviceControllerException.errors.zoningFailedArgs(volUri.toString());
BiosCommandResult result = BiosCommandResult.createErrorResult(serviceError);
List<Zone> zones = new ArrayList<Zone>();
Zone zone = new Zone(fabricInfo.getZoneName());
zones.add(zone);
String taskId = UUID.randomUUID().toString();
for (String address : fabricInfo.getEndPoints()) {
ZoneMember member = new ZoneMember(address, ConnectivityMemberType.WWPN);
zone.getMembers().add(member);
}
// Lock to prevent concurrent operations on the same VSAN / FABRIC.
InterProcessLock fabricLock = NetworkFabricLocker.lockFabric(fabricInfo.getFabricId(), _coordinator);
try {
NetworkSystem device = getNetworkSystemObject(fabricInfo.getNetworkDeviceId());
// Get the file device reference for the type of file device managed
// by the controller.
NetworkSystemDevice networkDevice = getDevice(device.getSystemType());
if (networkDevice == null) {
throw NetworkDeviceControllerException.exceptions.removeZoneFailedNull(device.getSystemType());
}
if (fabricInfo.isLastReference() == true && !fabricInfo.isExistingZone()) {
result = networkDevice.removeZones(device, zones, fabricInfo.getFabricId(), fabricInfo.getFabricWwn(), activateZones);
} else {
// This is not the last reference, just mark our FCZoneReference for deletion
result = BiosCommandResult.createSuccessfulResult();
}
if (result.isCommandSuccess()) {
if (fabricInfo.getFcZoneReferenceId() != null) {
try {
// Mark our FcZoneReference object for removal
FCZoneReference reference = _dbClient.queryObject(FCZoneReference.class, fabricInfo.getFcZoneReferenceId());
if (reference != null) {
_dbClient.markForDeletion(reference);
recordZoneEvent(reference, OperationTypeEnum.REMOVE_SAN_ZONE.name(), OperationTypeEnum.REMOVE_SAN_ZONE.getDescription());
}
} catch (Exception ex) {
_log.error("Can't mark object for removal: " + fabricInfo.getFcZoneReferenceId());
}
}
}
if (!result.isCommandSuccess()) {
ServiceError svcError = NetworkDeviceControllerException.errors.removeZoneFailed(volUri.toString(), device.getSystemType());
setStatus(Volume.class, volUri, taskId, false, svcError);
} else {
setStatus(Volume.class, volUri, taskId, true, null);
}
} catch (ControllerException ex) {
_log.info("waiting for 2 min before retrying removeZone with alternate device");
try {
Thread.sleep(1000 * 120);
} catch (InterruptedException e) {
_log.warn("Thread sleep interrupted. Allowing to continue without sleep");
}
URI primaryUri = fabricInfo.getNetworkDeviceId();
URI altUri = fabricInfo.getAltNetworkDeviceId();
if (altUri != null && altUri != primaryUri) {
NetworkFabricLocker.unlockFabric(fabricInfo.getFabricId(), fabricLock);
fabricLock = null;
_log.error("Remove Zone failed using device: " + primaryUri + " retrying with alternate device: " + altUri);
fabricInfo.setNetworkDeviceId(altUri);
return removeZone(volUri, fabricInfo, activateZones);
} else {
ServiceError svcError = NetworkDeviceControllerException.errors.removeZoneFailedExc(volUri.toString());
setStatus(Volume.class, volUri, taskId, false, svcError);
throw ex;
}
} finally {
NetworkFabricLocker.unlockFabric(fabricInfo.getFabricId(), fabricLock);
}
return result;
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkDeviceController method updateSanZones.
@Override
public void updateSanZones(URI uri, String fabricId, String fabricWwn, List<ZoneUpdate> zones, boolean activateZones, String taskId) throws ControllerException {
NetworkSystem device = getNetworkSystemObject(uri);
// Lock to prevent concurrent operations on the same VSAN / FABRIC.
InterProcessLock fabricLock = NetworkFabricLocker.lockFabric(fabricId, _coordinator);
try {
// Get the file device reference for the type of file device managed
// by the controller.
NetworkSystemDevice networkDevice = getDevice(device.getSystemType());
if (networkDevice == null) {
throw NetworkDeviceControllerException.exceptions.updateSanZonesFailedNull(device.getSystemType());
}
BiosCommandResult result = networkDevice.updateZones(device, zones, fabricId, fabricWwn, activateZones);
setStatus(NetworkSystem.class, device.getId(), taskId, result.isCommandSuccess(), result.getServiceCoded());
_auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.UPDATE_SAN_ZONE, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL());
} catch (Exception ex) {
ServiceError serviceError = NetworkDeviceControllerException.errors.updateSanZonesFailedExc(device.getSystemType(), ex);
_dbClient.error(NetworkSystem.class, device.getId(), taskId, serviceError);
} finally {
NetworkFabricLocker.unlockFabric(fabricId, fabricLock);
}
}
Aggregations