Search in sources :

Example 26 with StorageHADomain

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

the class VNXFileStorageDeviceXML method getDataMover.

private StorageHADomain getDataMover(FileShare fileShare) {
    StoragePort port = _dbClient.queryObject(StoragePort.class, fileShare.getStoragePort());
    StorageHADomain dm = null;
    if (port != null) {
        dm = _dbClient.queryObject(StorageHADomain.class, port.getStorageHADomain());
    }
    return dm;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 27 with StorageHADomain

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

the class VNXFileStorageDeviceXML method doShare.

@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    _log.info("Call FileShare doShare");
    boolean firstExport = false;
    if (args.getFileObjShares() == null || args.getFileObjShares().isEmpty()) {
        args.initFileObjShares();
    }
    firstExport = !(args.isFileShareMounted());
    if (firstExport) {
        _log.debug("First export: no existing file obj shares");
    }
    if (!args.getFileOperation()) {
        firstExport = false;
    }
    String portName = smbFileShare.getPortGroup();
    String path = smbFileShare.getPath();
    if (path == null || path.length() == 0) {
        if (args.getFileOperation()) {
            path = args.getFsMountPath();
        } else {
            path = args.getSnapshotMountPath();
        }
    }
    _log.debug("Data Mover: {}", portName);
    _log.debug("Mount path: {}", path);
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        List<String> clients = new ArrayList<String>();
        VNXFileExport fileExport = new VNXFileExport(clients, portName, path, // no security type
        "", smbFileShare.getPermission(), // root user mapping n/a for CIFS
        "", VNXFileSshApi.VNX_CIFS, // Port information is never used for for CIFS or NFS exports.
        "", // SUB DIR
        "", // Comments -- TODO
        "");
        fileExport.setExportName(smbFileShare.getName());
        fileExport.setComment(smbFileShare.getDescription());
        fileExport.setMaxUsers(Integer.toString(smbFileShare.getMaxUsers()));
        List<VNXFileExport> vnxExports = new ArrayList<VNXFileExport>();
        vnxExports.add(fileExport);
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        // Get DataMover
        StorageHADomain dm = this.getDataMover(args.getFs());
        if (dm == null) {
            Exception e = new Exception("VNX File Share creation Failed Data Mover not found");
            throw VNXException.exceptions.createExportFailed("VNX File Share creation Failed Data Mover not found", e);
        }
        List<String> paths = new ArrayList<String>();
        paths.add(path);
        if (args.getFileOperation()) {
            // Perform FileSystem export
            result = vnxComm.doExport(storage, dm, vnxExports, paths, args.getFileObj(), args.getFsNativeId(), firstExport);
        } else {
            // perform Snapshot export
            result = vnxComm.doExport(storage, dm, vnxExports, paths, args.getFileObj(), args.getSnapNativeId(), firstExport);
        }
        if ((result != null) && (result.isCommandSuccess())) {
            // Set MountPoint
            smbFileShare.setMountPoint(fileExport.getNetBios(), smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
            args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
        }
    } catch (VNXException e) {
        throw new DeviceControllerException(e);
    } catch (NumberFormatException e) {
        // Placeholder until real handling is determined.
        throw new DeviceControllerException(e);
    } finally {
        clearContext(context);
    }
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateFileShare(result.getMessage()));
    }
    return cmdResult;
}
Also used : ArrayList(java.util.ArrayList) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXFileExport(com.emc.storageos.vnx.xmlapi.VNXFileExport) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 28 with StorageHADomain

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

the class VNXFileStorageDeviceXML method doExport.

@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    boolean firstExport = false;
    if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
        args.initFileObjExports();
    }
    // mount the FileSystem
    firstExport = !(args.isFileShareMounted());
    if (firstExport) {
        _log.debug("First export: no existing file exports");
    }
    // Mounting is only necessary for FileSystem and not snapshot for the first time export
    if (!args.getFileOperation()) {
        firstExport = false;
    }
    // Create a list of the new exports.
    FSExportMap newExpList = new FSExportMap();
    FSExportMap curExpList = args.getFileObjExports();
    FileExport curExport = null;
    FileExport newExport = null;
    List<String> newPaths = new ArrayList<String>();
    Iterator<String> it = curExpList.keySet().iterator();
    while (it.hasNext()) {
        curExport = curExpList.get(it.next());
        newExport = new FileExport(curExport.getClients(), curExport.getStoragePortName(), ExportUtils.getFileMountPoint(curExport.getStoragePort(), curExport.getPath()), curExport.getSecurityType(), curExport.getPermissions(), curExport.getRootUserMapping(), curExport.getProtocol(), curExport.getStoragePort(), curExport.getPath(), curExport.getMountPath(), curExport.getSubDirectory(), curExport.getComments());
        _log.info("FileExport key : {} ", newExport.getFileExportKey());
        newExpList.put(newExport.getFileExportKey(), newExport);
    }
    for (FileExport exp : exportList) {
        newExport = new FileExport(exp.getClients(), exp.getStoragePortName(), ExportUtils.getFileMountPoint(exp.getStoragePort(), exp.getPath()), exp.getSecurityType(), exp.getPermissions(), exp.getRootUserMapping(), exp.getProtocol(), exp.getStoragePort(), exp.getPath(), exp.getMountPath(), exp.getSubDirectory(), exp.getComments());
        _log.info("FileExport key : {} ", newExport.getFileExportKey());
        newExpList.put(newExport.getFileExportKey(), newExport);
        if (!newPaths.contains(newExport.getPath())) {
            newPaths.add(newExport.getPath());
        }
    }
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        // Get DataMover Name and whether it is virtual
        StorageHADomain dm = this.getDataMover(args.getFs());
        if (dm == null) {
            Exception e = new Exception("VNX File Export Failed Data Mover not found");
            throw VNXException.exceptions.createExportFailed("VNX File Export Failed Data Mover not found", e);
        }
        List<VNXFileExport> vnxExports = getVNXFileExports(newExpList);
        if (args.getFileOperation()) {
            // Perform FileSystem export
            result = vnxComm.doExport(storage, dm, vnxExports, newPaths, args.getFileObj(), args.getFsNativeId(), firstExport);
        } else {
            // perform Snapshot export
            result = vnxComm.doExport(storage, dm, vnxExports, newPaths, args.getFileObj(), args.getSnapNativeId(), firstExport);
        }
        if (result.isCommandSuccess()) {
            curExpList.putAll(newExpList);
        }
    } catch (VNXException e) {
        throw VNXException.exceptions.createExportFailed("VNX File Export Failed", e);
    } finally {
        clearContext(context);
    }
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToExportFileSystem(result.getMessage()));
    }
    return cmdResult;
}
Also used : ArrayList(java.util.ArrayList) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) FileExport(com.emc.storageos.db.client.model.FileExport) VNXFileExport(com.emc.storageos.vnx.xmlapi.VNXFileExport) VNXFileExport(com.emc.storageos.vnx.xmlapi.VNXFileExport) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 29 with StorageHADomain

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

the class StoragePortsAllocator method addPortsToAlreadyAllocatedContext.

/**
 * Adds a list of Storage Ports to the context _alreadyAllocatedXXX sets.
 * This will carry state from an a previous allocation in one network to
 * a new allocation for Vpool update in another network.
 * Does nothing if previouslyAllocatedPorts is null or an empty set.
 *
 * @param dbClient
 * @param net
 * @param previouslyAllocatedPorts
 */
public void addPortsToAlreadyAllocatedContext(DbClient dbClient, NetworkLite net, Set<StoragePort> previouslyAllocatedPorts) {
    if (previouslyAllocatedPorts == null || previouslyAllocatedPorts.isEmpty()) {
        return;
    }
    for (StoragePort sp : previouslyAllocatedPorts) {
        StorageHADomain haDomain = null;
        if (null != sp.getStorageHADomain()) {
            haDomain = dbClient.queryObject(StorageHADomain.class, sp.getStorageHADomain());
        }
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, sp.getStorageDevice());
        String switchName = PlacementUtils.getSwitchName(sp, dbClient);
        if (context == null) {
            context = new PortAllocationContext(net, storageSystem.getNativeGuid());
        }
        context.addPortToAlreadyAllocatedContext(sp, haDomain, StorageSystem.Type.valueOf(storageSystem.getSystemType()), switchName);
    }
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 30 with StorageHADomain

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

the class StoragePortHADomainPopulater method process.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.db.client.upgrade.BaseCustomMigrationCallback#process()
     */
@Override
public void process() throws MigrationCallbackException {
    log.info("START - StoragePortHADomainPopulater migration call back");
    DbClient dbClient = getDbClient();
    List<URI> storagePortURIs = dbClient.queryByType(StoragePort.class, false);
    Iterator<StoragePort> storagePortsIter = dbClient.queryIterativeObjects(StoragePort.class, storagePortURIs);
    Map<URI, StorageSystem> uriVsSystem = new HashMap<>();
    List<StoragePort> modifiedPorts = new ArrayList<>();
    while (storagePortsIter.hasNext()) {
        StoragePort storagePort = storagePortsIter.next();
        URI deviceURI = storagePort.getStorageDevice();
        StorageSystem system = null;
        if (uriVsSystem.containsKey(deviceURI)) {
            system = uriVsSystem.get(deviceURI);
        } else {
            system = dbClient.queryObject(StorageSystem.class, deviceURI);
            if (null != system) {
                uriVsSystem.put(deviceURI, system);
            } else {
                log.warn("No storage system found for the port - {} , it will be skipped from" + "migration, storageHADomain will continue to remain empty", storagePort.getId().toString());
                continue;
            }
        }
        if (storagePort.getStorageHADomain() == null && DiscoveredDataObject.Type.openstack.name().equalsIgnoreCase((system.getSystemType()))) {
            StorageHADomain haDomain = createStorageAdapter(system, dbClient);
            log.info("Populating the storageHADomian for the port - {} ", storagePort.getId().toString());
            storagePort.setStorageHADomain(haDomain.getId());
            modifiedPorts.add(storagePort);
        }
    }
    // Persist the change
    if (!modifiedPorts.isEmpty()) {
        dbClient.persistObject(modifiedPorts);
    }
    log.info("END - StoragePortHADomainPopulater migration call back");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)80 URI (java.net.URI)41 StoragePort (com.emc.storageos.db.client.model.StoragePort)35 ArrayList (java.util.ArrayList)33 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)26 HashMap (java.util.HashMap)22 List (java.util.List)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)12 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 NamespaceList (com.emc.storageos.plugins.common.domainmodel.NamespaceList)11 URISyntaxException (java.net.URISyntaxException)11 LinkedList (java.util.LinkedList)10 IOException (java.io.IOException)9 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)8 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)8 HashSet (java.util.HashSet)8 Map (java.util.Map)7