Search in sources :

Example 41 with StoragePort

use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.

the class StorageSystemService method getStoragePort.

/**
 * Get information about the storage port with the passed id on the
 * registered storage system with the passed id.
 *
 * @param id the URN of a ViPR storage system.
 * @param portId The id of the storage port.
 *
 * @brief Show storage system storage port
 * @return A StoragePortRestRep reference specifying the data for the
 *         requested port.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-ports/{portId}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public StoragePortRestRep getStoragePort(@PathParam("id") URI id, @PathParam("portId") URI portId) {
    // Make sure the storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    ArgValidator.checkFieldUriType(portId, StoragePort.class, "portId");
    StoragePort port = _dbClient.queryObject(StoragePort.class, portId);
    ArgValidator.checkEntity(port, portId, isIdEmbeddedInURL(portId));
    return MapStoragePort.getInstance(_dbClient).toStoragePortRestRep(port);
}
Also used : MapStoragePort(com.emc.storageos.api.mapper.functions.MapStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 42 with StoragePort

use of com.emc.storageos.db.client.model.StoragePort 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);
}
Also used : NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) MapNetworkSystem(com.emc.storageos.api.mapper.functions.MapNetworkSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference) Network(com.emc.storageos.db.client.model.Network) NetworkSystemList(com.emc.storageos.model.network.NetworkSystemList) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 43 with StoragePort

use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.

the class FileService method failbackProtection.

/**
 * Request to fail Back the protection link associated with the param.copyID.
 *
 * NOTE: This is an asynchronous operation.
 *
 * @prereq none
 *
 * @param id
 *            the URN of a ViPR Source files hare
 * @param param
 *            FileReplicationParam to fail Back to
 *
 * @brief Fail Back the fileShare protection link
 * @return TaskList
 *
 * @throws ControllerException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failback")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failbackProtection(@PathParam("id") URI id, FileReplicationParam param) throws ControllerException {
    doMirrorOperationValidation(id, ProtectionOp.FAILBACK.toString());
    TaskResourceRep taskResp = null;
    StoragePort storageportNFS = null;
    StoragePort storageportCIFS = null;
    TaskList taskList = new TaskList();
    String task = UUID.randomUUID().toString();
    FileShare sourceFileShare = queryResource(id);
    Operation op = _dbClient.createTaskOpStatus(FileShare.class, id, task, ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILBACK);
    op.setDescription("failback to source file system from target system");
    boolean replicateConfiguration = param.isReplicateConfiguration();
    if (replicateConfiguration) {
        List<String> targetfileUris = new ArrayList<String>();
        targetfileUris.addAll(sourceFileShare.getMirrorfsTargets());
        FileShare targetFileShare = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        SMBShareMap smbShareMap = targetFileShare.getSMBFileShares();
        if (smbShareMap != null) {
            storageportCIFS = _fileScheduler.placeFileShareExport(sourceFileShare, StorageProtocol.File.CIFS.name(), null);
        }
        FSExportMap nfsExportMap = targetFileShare.getFsExports();
        if (nfsExportMap != null) {
            storageportNFS = _fileScheduler.placeFileShareExport(sourceFileShare, StorageProtocol.File.NFS.name(), null);
        }
    }
    FileServiceApi fileServiceApi = getFileShareServiceImpl(sourceFileShare, _dbClient);
    try {
        fileServiceApi.failbackFileShare(sourceFileShare.getId(), storageportNFS, storageportCIFS, replicateConfiguration, task);
    } catch (InternalException e) {
        if (_log.isErrorEnabled()) {
            _log.error("", e);
        }
        op = sourceFileShare.getOpStatus().get(task);
        op.error(e);
        sourceFileShare.getOpStatus().updateTaskStatus(task, op);
        _dbClient.updateObject(sourceFileShare);
        throw e;
    }
    taskResp = toTask(sourceFileShare, task, op);
    taskList.getTaskList().add(taskResp);
    return taskList;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) TaskList(com.emc.storageos.model.TaskList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 44 with StoragePort

use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.

the class FileService method export.

/**
 * Export file system.
 *
 * <p>
 * NOTE: This is an asynchronous operation.
 *
 * @param param
 *            File system export parameters
 * @param id
 *            the URN of a ViPR File system
 * @brief Create file export
 * @return Task resource representation
 * @throws InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/exports")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep export(@PathParam("id") URI id, FileSystemExportParam param) throws InternalException {
    _log.info("Export request recieved {}", id);
    // check file System
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    ArgValidator.checkFieldValueFromEnum(param.getPermissions(), "permissions", EnumSet.allOf(FileShareExport.Permissions.class));
    _log.info("Export security type {}", param.getSecurityType());
    for (String sectype : param.getSecurityType().split(",")) {
        ArgValidator.checkFieldValueFromEnum(sectype.trim(), "type", EnumSet.allOf(FileShareExport.SecurityTypes.class));
    }
    ArgValidator.checkFieldValueFromEnum(param.getProtocol(), "protocol", EnumSet.allOf(StorageProtocol.File.class));
    validateIpInterfacesRegistered(param.getEndpoints(), _dbClient);
    FileShare fs = queryResource(id);
    String task = UUID.randomUUID().toString();
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
    ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
    // Check for VirtualPool whether it has NFS enabled
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
    if (!vpool.getProtocols().contains(StorageProtocol.File.NFS.name()) && !vpool.getProtocols().contains(StorageProtocol.File.NFSv4.name())) {
        // Throw an error
        throw APIException.methodNotAllowed.vPoolDoesntSupportProtocol("Vpool doesn't support " + StorageProtocol.File.NFS.name() + " or " + StorageProtocol.File.NFSv4 + " protocol");
    }
    // locate storage port for exporting file System
    StoragePort sport = _fileScheduler.placeFileShareExport(fs, param.getProtocol(), param.getEndpoints());
    String path = fs.getPath();
    String mountPath = fs.getMountPath();
    String subDirectory = param.getSubDirectory();
    if (ArgValidator.checkSubDirName("sub_directory", param.getSubDirectory())) {
        // Add subdirectory to the path as this is a subdirectory export
        path += "/" + param.getSubDirectory();
        mountPath += "/" + param.getSubDirectory();
    }
    FSExportMap exportMap = fs.getFsExports();
    if (exportMap != null) {
        Iterator it = fs.getFsExports().keySet().iterator();
        boolean exportExists = false;
        while (it.hasNext()) {
            String fsExpKey = (String) it.next();
            FileExport fileExport = fs.getFsExports().get(fsExpKey);
            if (fileExport.getPath().equalsIgnoreCase(path)) {
                exportExists = true;
                break;
            }
        }
        if (exportExists) {
            throw APIException.badRequests.fileSystemHasExistingExport();
        }
    }
    String rootUserMapping = param.getRootUserMapping();
    if (rootUserMapping != null) {
        rootUserMapping = rootUserMapping.toLowerCase();
    }
    // check for bypassDnsCheck flag. If null then set to false
    Boolean dnsCheck = param.getBypassDnsCheck();
    if (dnsCheck == null) {
        dnsCheck = false;
    }
    FileShareExport export = new FileShareExport(param.getEndpoints(), param.getSecurityType(), param.getPermissions(), rootUserMapping, param.getProtocol(), sport.getPortGroup(), sport.getPortNetworkId(), path, mountPath, subDirectory, param.getComments(), dnsCheck);
    _log.info(String.format("FileShareExport --- FileShare id: %1$s, Clients: %2$s, StoragePort: %3$s, SecurityType: %4$s, " + "Permissions: %5$s, Root user mapping: %6$s, Protocol: %7$s, path: %8$s, mountPath: %9$s, SubDirectory: %10$s ,byPassDnsCheck: %11$s", id, export.getClients(), sport.getPortName(), export.getSecurityType(), export.getPermissions(), export.getRootUserMapping(), export.getProtocol(), export.getPath(), export.getMountPath(), export.getSubDirectory(), export.getBypassDnsCheck()));
    Operation op = _dbClient.createTaskOpStatus(FileShare.class, fs.getId(), task, ResourceOperationTypeEnum.EXPORT_FILE_SYSTEM);
    op.setDescription("Filesystem export");
    FileServiceApi fileServiceApi = getFileShareServiceImpl(fs, _dbClient);
    fileServiceApi.export(device.getId(), fs.getId(), Arrays.asList(export), task);
    auditOp(OperationTypeEnum.EXPORT_FILE_SYSTEM, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), device.getId().toString(), export.getClients(), param.getSecurityType(), param.getPermissions(), param.getRootUserMapping(), param.getProtocol());
    return toTask(fs, task, op);
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) FileShareExport(com.emc.storageos.volumecontroller.FileShareExport) SecurityTypes(com.emc.storageos.volumecontroller.FileShareExport.SecurityTypes) DefaultPermissions(com.emc.storageos.security.authorization.DefaultPermissions) Permissions(com.emc.storageos.volumecontroller.FileShareExport.Permissions) Iterator(java.util.Iterator) FileExport(com.emc.storageos.db.client.model.FileExport) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 45 with StoragePort

use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.

the class FileService method failoverProtection.

/**
 * Request to failover the protection link associated with the param.copyID.
 *
 * NOTE: This is an asynchronous operation.
 *
 * @prereq none
 *
 * @param id
 *            the URN of a ViPR Source fileshare
 * @param param
 *            FileReplicationParam to failover to
 *
 * @brief Failover the fileShare protection link
 * @return TaskList
 *
 * @throws ControllerException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failoverProtection(@PathParam("id") URI id, FileReplicationParam param) throws ControllerException {
    doMirrorOperationValidation(id, ProtectionOp.FAILOVER.toString());
    TaskResourceRep taskResp = null;
    StoragePort storageportNFS = null;
    StoragePort storageportCIFS = null;
    TaskList taskList = new TaskList();
    String task = UUID.randomUUID().toString();
    FileShare fs = queryResource(id);
    Operation op = _dbClient.createTaskOpStatus(FileShare.class, id, task, ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILOVER);
    op.setDescription("failover source file system to target system");
    boolean replicateConfiguration = param.isReplicateConfiguration();
    if (replicateConfiguration) {
        List<String> targetfileUris = new ArrayList<String>();
        targetfileUris.addAll(fs.getMirrorfsTargets());
        FileShare targetFileShare = _dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        SMBShareMap smbShareMap = fs.getSMBFileShares();
        if (smbShareMap != null) {
            storageportCIFS = _fileScheduler.placeFileShareExport(targetFileShare, StorageProtocol.File.CIFS.name(), null);
        }
        FSExportMap nfsExportMap = fs.getFsExports();
        if (nfsExportMap != null) {
            storageportNFS = _fileScheduler.placeFileShareExport(targetFileShare, StorageProtocol.File.NFS.name(), null);
        }
    }
    FileServiceApi fileServiceApi = getFileShareServiceImpl(fs, _dbClient);
    try {
        fileServiceApi.failoverFileShare(id, storageportNFS, storageportCIFS, replicateConfiguration, task);
    } catch (InternalException e) {
        if (_log.isErrorEnabled()) {
            _log.error("", e);
        }
        FileShare fileShare = _dbClient.queryObject(FileShare.class, fs.getId());
        op = fs.getOpStatus().get(task);
        op.error(e);
        fileShare.getOpStatus().updateTaskStatus(task, op);
        _dbClient.updateObject(fs);
        throw e;
    }
    taskResp = toTask(fs, task, op);
    taskList.getTaskList().add(taskResp);
    return taskList;
}
Also used : SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) TaskList(com.emc.storageos.model.TaskList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

StoragePort (com.emc.storageos.db.client.model.StoragePort)477 URI (java.net.URI)285 ArrayList (java.util.ArrayList)261 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)143 HashMap (java.util.HashMap)134 List (java.util.List)130 NetworkLite (com.emc.storageos.util.NetworkLite)110 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 StringSet (com.emc.storageos.db.client.model.StringSet)92 PortAllocationContext (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)84 HashSet (java.util.HashSet)81 Initiator (com.emc.storageos.db.client.model.Initiator)78 Map (java.util.Map)64 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)62 StoragePool (com.emc.storageos.db.client.model.StoragePool)51 IOException (java.io.IOException)48 StringMap (com.emc.storageos.db.client.model.StringMap)45 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)34