use of com.emc.storageos.security.authorization.CheckPermission 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.security.authorization.CheckPermission 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.security.authorization.CheckPermission 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);
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class ObjectNamespaceService method getObjectNamespace.
/**
* Get details of the object storage namespace specified
*
* @param id object storage namespace id
* @brief Show details for a namespace
* @return details of the namespace
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN, Role.SECURITY_ADMIN })
public ObjectNamespaceRestRep getObjectNamespace(@PathParam("id") URI id) {
_log.info("Getting details for the namespace: {}", id);
ArgValidator.checkFieldUriType(id, ObjectNamespace.class, "id");
ArgValidator.checkUri(id);
ObjectNamespace objNamespace = _dbClient.queryObject(ObjectNamespace.class, id);
ArgValidator.checkEntity(objNamespace, id, isIdEmbeddedInURL(id));
ObjectNamespaceRestRep restRep = toObjectNamespaceRestRep(objNamespace, _dbClient, _coordinator);
return restRep;
}
use of com.emc.storageos.security.authorization.CheckPermission in project coprhd-controller by CoprHD.
the class ObjectNamespaceService method getObjectNamespaces.
/**
* Get IDs of all object storage namespaces
*
* @brief List namespace names and IDs
* @return object namespace list
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN, Role.SECURITY_ADMIN })
public ObjectNamespaceList getObjectNamespaces() {
_log.info("Getting namespaces from all object storage systesm");
ObjectNamespaceList objNamespaceList = new ObjectNamespaceList();
List<URI> ids = _dbClient.queryByType(ObjectNamespace.class, true);
for (URI id : ids) {
ObjectNamespace objNamespace = _dbClient.queryObject(ObjectNamespace.class, id);
if (objNamespace != null) {
objNamespaceList.getNamespaces().add(toNamedRelatedResource(objNamespace, objNamespace.getNativeGuid()));
}
}
return objNamespaceList;
}
Aggregations