use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkDeviceController method deleteNetworkSystem.
@Override
public void deleteNetworkSystem(URI network, String taskId) throws ControllerException {
try {
NetworkSystem networkDevice = getNetworkSystemObject(network);
URIQueryResultList epUriList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemFCPortConnectionConstraint(network), epUriList);
while (epUriList.iterator().hasNext()) {
FCEndpoint connection = _dbClient.queryObject(FCEndpoint.class, epUriList.iterator().next());
if (connection != null) {
_dbClient.removeObject(connection);
}
}
List<URI> tzUriList = _dbClient.queryByType(Network.class, true);
NetworkDiscoveryWorker worker = new NetworkDiscoveryWorker(getDevice(networkDevice.getSystemType()), _dbClient);
worker.setCoordinator(_coordinator);
for (URI tzUri : tzUriList) {
Network tz = _dbClient.queryObject(Network.class, tzUri);
if (tz != null && (tz.getNetworkSystems() != null && tz.getNetworkSystems().contains(network.toString()))) {
worker.removeNetworkSystemTransportZone(tz, network.toString());
}
}
if (taskId != null) {
_dbClient.ready(NetworkSystem.class, network, taskId);
_auditMgr.recordAuditLog(null, null, EVENT_SERVICE_TYPE, OperationTypeEnum.DELETE_NETWORK_SYSTEM, System.currentTimeMillis(), AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_END, networkDevice.getId().toString(), networkDevice.getLabel(), networkDevice.getPortNumber(), networkDevice.getUsername(), networkDevice.getSmisProviderIP(), networkDevice.getSmisPortNumber(), networkDevice.getSmisUserName(), networkDevice.getSmisUseSSL());
}
} catch (Exception ex) {
String msg = MessageFormat.format("Exception encountered while removing FC Port Connection for {0} because: {1}", network, ex.getLocalizedMessage());
_log.error(msg);
if (taskId != null) {
try {
ServiceError serviceError = NetworkDeviceControllerException.errors.deleteNetworkSystemFailed(network.toString(), ex);
_dbClient.error(NetworkSystem.class, network, taskId, serviceError);
} catch (DatabaseException e) {
_log.error(e.getMessage());
}
}
}
}
use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkDiscoveryWorker method updateRoutedNetworks.
/**
* Looks in the topology view for endpoints that accessible by routing
*
* @param networkSystem the network system being refreshed
* @param updatedNetworks the networks that require updating
* @param routedEndpoints the routed endpoints map of Fabric-WWN-to-endpoints-WWN
* @throws Exception
*/
private void updateRoutedNetworks(NetworkSystem networkSystem, List<Network> updatedNetworks, Map<String, Set<String>> routedEndpoints) throws Exception {
if (!this.getDevice().isCapableOfRouting(networkSystem)) {
_log.info("NetworkSystem {} does not support routing across VSANs, skipping routed networks update/discovery", networkSystem.getLabel());
// Clear out the routedNetworks entries, if filled, for non-IVR Cisco switches. This can happen in upgrade scenarios.
URIQueryResultList networkSystemNetworkUriList = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemNetworkConstraint(networkSystem.getId()), networkSystemNetworkUriList);
for (URI networkSystemNetworkUri : networkSystemNetworkUriList) {
Network networkSystemNetwork = dbClient.queryObject(Network.class, networkSystemNetworkUri);
boolean isNetworkConnectedToRoutableSwitch = false;
for (String ns : networkSystemNetwork.getNetworkSystems()) {
NetworkSystem connectedNetworkSystem = dbClient.queryObject(NetworkSystem.class, URI.create(ns));
if (this.getDevice().isCapableOfRouting(connectedNetworkSystem)) {
isNetworkConnectedToRoutableSwitch = true;
;
}
}
// to another switch that supports routing.
if (!isNetworkConnectedToRoutableSwitch) {
_log.info("Updating routedNetwork to null for {}", networkSystemNetwork.getLabel());
networkSystemNetwork.setRoutedNetworks(null);
dbClient.updateObject(networkSystemNetwork);
}
}
// Update the connected varray assignments
_log.info("Updating connected network and varray assignments");
for (Network network : DataObjectUtils.toMap(NetworkUtil.getDiscoveredNetworks(dbClient)).values()) {
NetworkAssociationHelper.setNetworkConnectedVirtualArrays(network, false, dbClient);
}
return;
}
Map<URI, Network> allNetworks = DataObjectUtils.toMap(NetworkUtil.getDiscoveredNetworks(dbClient));
// Determine routed networks. We get here only for switches that have IVR feature enabled.
getDevice().determineRoutedNetworks(networkSystem);
for (Network network : allNetworks.values()) {
NetworkAssociationHelper.setNetworkConnectedVirtualArrays(network, false, dbClient);
}
}
use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class TransportZoneReconciler method createTransportZone.
private Network createTransportZone(NetworkSystem network, String fabricWwn, String fabricId) {
Network newTZ = new Network();
String nativeGuid = NativeGUIDGenerator.generateTransportZoneNativeGuid(Transport.FC.toString(), network.getSystemType(), fabricWwn);
String prefix = network.getSystemType().equals(NetworkSystem.Type.mds.toString()) ? PREFIX_VSAN : PREFIX_FABRIC;
newTZ.setId(URIUtil.createId(Network.class));
newTZ.setLabel(prefix + fabricId);
newTZ.setNativeId(fabricId);
newTZ.setTransportType(Transport.FC.toString());
newTZ.setDiscovered(true);
newTZ.setNativeGuid(nativeGuid);
newTZ.setNetworkSystems(new StringSet());
newTZ.getNetworkSystems().add(network.getId().toString());
newTZ.setRegistrationStatus(network.getRegistrationStatus());
return newTZ;
}
use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkService method getStoragePorts.
/**
* This call returns a list of all Storage Ports associated
* with the Network end points.
* <p>
*
* @param id the URN of a ViPR network
* @brief List storage ports
* @return StoragePortList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{id}/storage-ports")
public StoragePortList getStoragePorts(@PathParam("id") URI id) {
ArgValidator.checkUri(id);
Network tzone = _dbClient.queryObject(Network.class, id);
ArgValidator.checkEntityNotNull(tzone, id, isIdEmbeddedInURL(id));
StoragePortList registeredStoragePorts = new StoragePortList();
URIQueryResultList storagePortURIs = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getNetworkStoragePortConstraint(id.toString()), storagePortURIs);
Iterator<URI> storagePortURIsIter = storagePortURIs.iterator();
while (storagePortURIsIter.hasNext()) {
URI storagePortURI = storagePortURIsIter.next();
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, storagePortURI);
if (storagePort != null && !storagePort.getInactive()) {
registeredStoragePorts.getPorts().add(toNamedRelatedResource(storagePort, storagePort.getNativeGuid()));
}
}
return registeredStoragePorts;
}
use of com.emc.storageos.db.client.model.Network in project coprhd-controller by CoprHD.
the class NetworkService method deleteNetwork.
/**
* Deactivate network, this will delete a manually created network. The
* network must be deregistered and has no endpoints. When force is set to true
* the network can be deleted even if it has endpoints.
*
* @param id the URN of a ViPR Network
* @param force if set to true will delete a network even if it has endpoints
* @brief Delete network
* @return No data returned in response body
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public Response deleteNetwork(@PathParam("id") URI id, @QueryParam("force") boolean force) {
ArgValidator.checkFieldUriType(id, Network.class, "id");
Network network = _dbClient.queryObject(Network.class, id);
ArgValidator.checkEntityNotNull(network, id, isIdEmbeddedInURL(id));
if (!RegistrationStatus.UNREGISTERED.toString().equals(network.getRegistrationStatus())) {
throw APIException.badRequests.invalidParameterCannotDeactivateRegisteredNetwork(network.getId());
}
if (network.getDiscovered()) {
throw APIException.badRequests.invalidParameterCannotDeleteDiscoveredNetwork(network.getId());
}
if (network.getDiscovered() != true && force) {
// dis-associated the storage port from the network before marking it for deletion
NetworkAssociationHelper.handleEndpointsRemoved(network, network.retrieveEndpoints(), _dbClient, _coordinator);
_dbClient.markForDeletion(network);
} else if (network.getDiscovered() != true && network.retrieveEndpoints() != null && !network.retrieveEndpoints().isEmpty()) {
throw APIException.badRequests.unableToDeleteNetworkContainsEndpoints();
} else {
NetworkAssociationHelper.handleEndpointsRemoved(network, network.retrieveEndpoints(), _dbClient, _coordinator);
_dbClient.markForDeletion(network);
}
recordAndAudit(network, OperationTypeEnum.DELETE_NETWORK);
return Response.ok().build();
}
Aggregations