use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkSystemService method getNetworkSystem.
/**
* Shows the attributes of the network system.
*
* @param id the URN of a ViPR network system.
* @prereq none
* @brief Show network system
* @return A rest representation of the attributes of the network system.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public NetworkSystemRestRep getNetworkSystem(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
NetworkSystem device = queryResource(id);
return map(device);
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkSystemService method updateAliases.
/**
* Changes the WWN member of one or more aliases on the specified network system. For Brocade
* the fabric of the aliases will be removed must be specified.
* For MDS, this input is ignored if provided.
* <p>
* Current address WWN is optional; however, if provided, it must match the one in system before update. If not, exception will be
* thrown.
* <p>
* This is an asynchronous call.
*
* @param aliases A parameter structure listing the aliases to be updated
* @param id the URN of a ViPR network system.
* @param fabricId The name of the VSAN or fabric. This parameter is ignored
* if network system is an MDS
* @prereq none
* @brief Update aliases in network system
* @return A task description structure.
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-aliases")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep updateAliases(WwnAliasUpdateParams updateAliasParam, @PathParam("id") URI id) throws InternalException {
String task = UUID.randomUUID().toString();
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
ArgValidator.checkFieldNotEmpty(updateAliasParam.getUpdateAliases(), "aliases");
NetworkSystem device = queryResource(id);
String fabricId = updateAliasParam.getFabricId();
if (Type.brocade.toString().equals(device.getSystemType())) {
ArgValidator.checkFieldNotEmpty(fabricId, "fabric-id");
}
String fabricWwn = null;
if (WWNUtility.isValidWWN(fabricId)) {
fabricWwn = fabricId;
fabricId = fabricId.replaceAll(":", "");
}
Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.UPDATE_ALIAS);
List<ZoneWwnAliasUpdate> zoneAliasesUpdate = new ArrayList<ZoneWwnAliasUpdate>();
for (WwnAliasUpdateParam updateAlias : updateAliasParam.getUpdateAliases()) {
validateAlias(updateAlias, false);
// validate new address
if (!StringUtils.isEmpty(updateAlias.getNewAddress())) {
validateWWN(updateAlias.getNewAddress());
}
// validate new name
if (!StringUtils.isEmpty(updateAlias.getNewName())) {
validateWWNAlias(updateAlias.getNewName());
}
zoneAliasesUpdate.add(new ZoneWwnAliasUpdate(updateAlias.getName(), updateAlias.getNewName(), updateAlias.getNewAddress(), updateAlias.getAddress()));
auditOp(OperationTypeEnum.UPDATE_ALIAS, true, AuditLogManager.AUDITOP_BEGIN, updateAlias.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
}
NetworkController controller = getNetworkController(device.getSystemType());
controller.updateAliases(device.getId(), fabricId, fabricWwn, zoneAliasesUpdate, task);
return toTask(device, task, op);
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkSystemService method deleteNetworkSystem.
/**
* Delete a network system. The method will delete the
* network system and all resources associated with it.
*
* @prereq The network system must be unregistered
* @brief Delete network system
* @return An asynchronous task.
*
* @throws DatabaseException
* When an error occurs querying the database.
*/
@POST
@Path("/{id}/deactivate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep deleteNetworkSystem(@PathParam("id") URI id) throws DatabaseException {
NetworkSystem system = queryObject(NetworkSystem.class, id, true);
ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
if (!RegistrationStatus.UNREGISTERED.toString().equals(system.getRegistrationStatus())) {
throw APIException.badRequests.invalidParameterCannotDeactivateRegisteredNetworkSystem(system.getId());
}
if (DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString().equals(system.getDiscoveryStatus()) || DiscoveredDataObject.DataCollectionJobStatus.SCHEDULED.toString().equals(system.getDiscoveryStatus())) {
throw APIException.serviceUnavailable.cannotDeactivateStorageSystemWhileInDiscover(system.getId());
}
List<Network> networkList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Network.class, AlternateIdConstraint.Factory.getConstraint(Network.class, "networkSystems", system.getId().toString()));
for (Network network : networkList) {
if (network != null && network.getInactive() != true && network.getConnectedVirtualArrays() != null && !network.getConnectedVirtualArrays().isEmpty() && (network.getNetworkSystems() != null && network.getNetworkSystems().contains(system.getId().toString()) && network.getNetworkSystems().size() == 1)) {
throw APIException.badRequests.invalidParameterNetworkMustBeUnassignedFromVirtualArray(network.getLabel(), system.getLabel());
}
}
Map<String, List<FCZoneReference>> zonesMap = getNetworkSystemZoneRefs(system);
List<URI> nsystems = null;
List<FCZoneReference> zones = null;
// by the purge process
for (Network network : networkList) {
// remove references from ports
nsystems = StringSetUtil.stringSetToUriList(network.getNetworkSystems());
nsystems.remove(system.getId());
if (nsystems.isEmpty()) {
// This network will be removed - Remove any storage port references
List<StoragePort> netPorts = NetworkAssociationHelper.getNetworkStoragePorts(network.getId().toString(), null, _dbClient);
NetworkAssociationHelper.clearPortAssociations(netPorts, _dbClient);
} else {
// This network will remain, update any zone references to use another network system
URI nsUri = nsystems.get(0);
zones = zonesMap.get(network.getNativeId());
if (zones != null) {
for (FCZoneReference zone : zones) {
zone.setNetworkSystemUri(nsUri);
}
_dbClient.updateObject(zones);
}
}
}
String taskId = UUID.randomUUID().toString();
Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, system.getId(), taskId, ResourceOperationTypeEnum.DELETE_NETWORK_SYSTEM);
PurgeRunnable.executePurging(_dbClient, _dbPurger, _asynchJobService.getExecutorService(), system, _retry_attempts, taskId, 60);
auditOp(OperationTypeEnum.DELETE_NETWORK_SYSTEM, true, AuditLogManager.AUDITOP_BEGIN, system.getId().toString(), system.getLabel(), system.getPortNumber(), system.getUsername(), system.getSmisProviderIP(), system.getSmisPortNumber(), system.getSmisUserName(), system.getSmisUseSSL(), system.getVersion(), system.getUptime());
return toTask(system, taskId, op);
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkSystemService method createNetworkSystem.
/**
* Creates a new network system. This can either represent an SSH connection to a Cisco
* MDS or Nexus switch, or an SMI-S connection to the Brocade Network Advisor.
* The call will return before communication has been established, but discovery of
* the device will be initiated.
*
* @param param The NetworkSystemCreate object contains all the parameters for creation.
* @prereq none
* @brief Create network system
* @return A REST representation of the newly created network device.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep createNetworkSystem(NetworkSystemCreate param) throws Exception {
// check device type
ArgValidator.checkFieldValueFromSystemType(param.getSystemType(), "system_type", Arrays.asList(NetworkSystem.Type.brocade, NetworkSystem.Type.mds));
NetworkSystem.Type deviceType = NetworkSystem.Type.valueOf(param.getSystemType());
if (NetworkSystem.Type.valueOf(param.getSystemType()) == NetworkSystem.Type.brocade) {
// Validate fields required for brocade
ArgValidator.checkFieldNotNull(param.getSmisProviderIp(), "smis_provider_ip");
ArgValidator.checkFieldNotNull(param.getSmisPortNumber(), "smis_port_number");
ArgValidator.checkFieldNotNull(param.getSmisUserName(), "smis_user_name");
ArgValidator.checkFieldNotNull(param.getSmisPassword(), "smis_password");
} else if (NetworkSystem.Type.valueOf(param.getSystemType()) == NetworkSystem.Type.mds) {
// Validate fields required for mds
ArgValidator.checkFieldNotNull(param.getIpAddress(), "ip_address");
ArgValidator.checkFieldNotNull(param.getPortNumber(), "port_number");
ArgValidator.checkFieldNotNull(param.getUserName(), "user_name");
ArgValidator.checkFieldNotNull(param.getPassword(), "password");
}
// Check for existing device.
checkForDuplicateDevice(null, param.getIpAddress(), param.getPortNumber(), param.getSmisProviderIp(), param.getSmisPortNumber(), param.getName());
NetworkSystem device = new NetworkSystem();
URI id = URIUtil.createId(NetworkSystem.class);
device.setId(id);
device.setLabel(param.getName());
device.setIpAddress(param.getIpAddress());
device.setPortNumber(param.getPortNumber());
device.setUsername(param.getUserName());
device.setPassword(param.getPassword());
device.setSystemType(deviceType.name());
device.setSmisProviderIP(param.getSmisProviderIp());
device.setSmisPortNumber(param.getSmisPortNumber());
device.setSmisUserName(param.getSmisUserName());
device.setSmisPassword(param.getSmisPassword());
device.setSmisUseSSL(param.getSmisUseSsl());
device.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(device));
device.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.name());
_dbClient.createObject(device);
auditOp(OperationTypeEnum.CREATE_NETWORK_SYSTEM, true, null, device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
return doDiscoverNetworkSystem(device);
}
use of com.emc.storageos.db.client.model.NetworkSystem in project coprhd-controller by CoprHD.
the class NetworkSystemService method addSanZones.
/**
* Adds one or more SAN zones to the active zoneset of the VSAN or fabric specified on a network system.
* This is an asynchronous call.
*
* @param sanZones A parameter structure listing the zone(s) to be added and their members.
* @param id the URN of a ViPR network system.
* @param fabricId The name of the VSAN or fabric as returned by
* /vdc/network-systems/{id}/san-fabrics or the VSAN or fabric WWN
* @prereq none
* @brief Add SAN zones to network system VSAN or fabric
* @return A task description structure.
* @throws InternalException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/san-fabrics/{fabricId}/san-zones")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep addSanZones(SanZoneCreateParam sanZones, @PathParam("id") URI id, @PathParam("fabricId") String fabricId) throws InternalException {
String task = UUID.randomUUID().toString();
String fabricWwn = null;
if (WWNUtility.isValidWWN(fabricId)) {
fabricWwn = fabricId;
fabricId = fabricId.replaceAll(":", "");
}
ArgValidator.checkFieldUriType(id, NetworkSystem.class, "id");
NetworkSystem device = queryResource(id);
List<Zone> zones = new ArrayList<Zone>();
for (SanZone sz : sanZones.getZones()) {
Zone zone = new Zone(sz.getName());
validateZoneName(sz.getName(), device.getSystemType());
zones.add(zone);
for (String szm : sz.getMembers()) {
ZoneMember member = createZoneMember(szm);
zone.getMembers().add(member);
}
ArgValidator.checkFieldNotEmpty(zone.getMembers(), "zone members");
auditOp(OperationTypeEnum.ADD_SAN_ZONE, true, AuditLogManager.AUDITOP_BEGIN, zone.getName(), device.getId().toString(), device.getLabel(), device.getPortNumber(), device.getUsername(), device.getSmisProviderIP(), device.getSmisPortNumber(), device.getSmisUserName(), device.getSmisUseSSL(), device.getVersion(), device.getUptime());
}
ArgValidator.checkFieldNotEmpty(zones, "zones");
Operation op = _dbClient.createTaskOpStatus(NetworkSystem.class, device.getId(), task, ResourceOperationTypeEnum.ADD_SAN_ZONE);
NetworkController controller = getNetworkController(device.getSystemType());
controller.addSanZones(device.getId(), fabricId, fabricWwn, zones, false, task);
return toTask(device, task, op);
}
Aggregations