Search in sources :

Example 36 with StorageSystemRestRep

use of com.emc.storageos.model.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.

the class Networks method endpointsJson.

/**
 * Creates and renders JSON datatable source for endpoints for the given network.
 *
 * @param networkId
 *            the network ID.
 */
public static void endpointsJson(String networkId) {
    NetworkRestRep network = NetworkUtils.getNetwork(networkId);
    if (network == null) {
        error(MessagesUtils.get(UNKNOWN, networkId));
    }
    List<EndpointInfo> items = Lists.newArrayList();
    // All known endpoints, remove endpoints from storage systems and hosts to get manual endpoints
    Set<String> endpoints = Sets.newTreeSet(new Comparator<String>() {

        @Override
        public int compare(String s1, String s2) {
            return s1.compareToIgnoreCase(s2);
        }
    });
    endpoints.addAll(network.getEndpoints());
    // Add ports from storage systems
    CachedResources<StorageSystemRestRep> storageSystems = StorageSystemUtils.createCache();
    for (StoragePortRestRep storagePort : StoragePortUtils.getStoragePortsByNetwork(network.getId())) {
        items.add(new EndpointInfo(storagePort, storageSystems));
        for (String endpoint : NetworkUtils.getEndPoints(storagePort)) {
            endpoints.remove(endpoint);
        }
    }
    // Add ports from hosts
    CachedResources<HostRestRep> hosts = HostUtils.createCache();
    for (InitiatorRestRep initiator : NetworkUtils.getInitiators(network.getId())) {
        if (initiator.getHost() != null) {
            items.add(new EndpointInfo(initiator, hosts));
            endpoints.remove(NetworkUtils.getEndPoint(initiator));
        }
    }
    for (IpInterfaceRestRep ipInterface : NetworkUtils.getIpInterfaces(network.getId())) {
        if (ipInterface.getHost() != null) {
            items.add(new EndpointInfo(ipInterface, hosts));
            endpoints.remove(NetworkUtils.getEndPoint(ipInterface));
        }
    }
    // Add any remaining endpoints as 'manual'
    for (String endpoint : endpoints) {
        items.add(new EndpointInfo(endpoint));
    }
    setEndpointAttrs(network, items);
    renderJSON(DataTablesSupport.createJSON(items, params));
}
Also used : StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) InitiatorRestRep(com.emc.storageos.model.host.InitiatorRestRep) IpInterfaceRestRep(com.emc.storageos.model.host.IpInterfaceRestRep) EndpointInfo(models.datatable.NetworkEndpointDataTable.EndpointInfo) HostRestRep(com.emc.storageos.model.host.HostRestRep) NetworkRestRep(com.emc.storageos.model.varray.NetworkRestRep)

Example 37 with StorageSystemRestRep

use of com.emc.storageos.model.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.

the class FileSystems method fileSystem.

public static void fileSystem(String fileSystemId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    FileShareRestRep fileSystem = null;
    try {
        fileSystem = client.fileSystems().get(uri(fileSystemId));
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404 || e.getHttpCode() == 400) {
            flash.error(MessagesUtils.get(UNKNOWN, fileSystemId));
            fileSystems(null);
        }
        throw e;
    }
    if (fileSystem != null) {
        if (fileSystem.getVirtualArray() != null) {
            VirtualArrayRestRep virtualArray = client.varrays().get(fileSystem.getVirtualArray());
            renderArgs.put("virtualArray", virtualArray);
        }
        if (fileSystem.getVirtualPool() != null) {
            FileVirtualPoolRestRep virtualPool = client.fileVpools().get(fileSystem.getVirtualPool());
            renderArgs.put("virtualPool", virtualPool);
        }
        if (Security.isSystemAdminOrRestrictedSystemAdmin()) {
            if (fileSystem.getStorageSystem() != null) {
                StorageSystemRestRep storageSystem = client.storageSystems().get(fileSystem.getStorageSystem());
                renderArgs.put("storageSystem", storageSystem);
            }
            if (fileSystem.getPool() != null) {
                StoragePoolRestRep storagePool = client.storagePools().get(fileSystem.getPool());
                renderArgs.put("storagePool", storagePool);
            }
            if (fileSystem.getStoragePort() != null) {
                StoragePortRestRep storagePort = client.storagePorts().get(fileSystem.getStoragePort());
                renderArgs.put("storagePort", storagePort);
            }
        }
        Tasks<FileShareRestRep> tasksResponse = client.fileSystems().getTasks(fileSystem.getId());
        List<Task<FileShareRestRep>> tasks = tasksResponse.getTasks();
        renderArgs.put("tasks", tasks);
    } else {
        notFound(MessagesUtils.get("resources.filesystems.notfound"));
    }
    renderArgs.put("permissionTypeOptions", PERMISSION_TYPES);
    render(fileSystem);
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) StoragePoolRestRep(com.emc.storageos.model.pools.StoragePoolRestRep) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 38 with StorageSystemRestRep

use of com.emc.storageos.model.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getExportPathStorageSystem.

@SuppressWarnings("incomplete-switch")
@Asset("exportPathStorageSystem")
@AssetDependencies({ "exportPathExport" })
public List<AssetOption> getExportPathStorageSystem(AssetOptionsContext ctx, URI exportId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    List<URI> storageSystemIds = new ArrayList<URI>();
    ExportGroupRestRep export = client.blockExports().get(exportId);
    List<ExportBlockParam> volumes = export.getVolumes();
    for (ExportBlockParam volume : volumes) {
        URI resourceId = volume.getId();
        ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
        switch(volumeType) {
            case VOLUME:
                VolumeRestRep v = client.blockVolumes().get(resourceId);
                if (v != null) {
                    storageSystemIds.add(v.getStorageController());
                }
                break;
            case BLOCK_SNAPSHOT:
                BlockSnapshotRestRep s = client.blockSnapshots().get(resourceId);
                if (s != null) {
                    storageSystemIds.add(s.getStorageController());
                }
                break;
        }
    }
    List<StorageSystemRestRep> storageSystems = client.storageSystems().getByIds(storageSystemIds);
    for (StorageSystemRestRep storageSystem : storageSystems) {
        String systemType = storageSystem.getSystemType();
        if (Type.vmax.name().equalsIgnoreCase(systemType) || Type.vplex.name().equalsIgnoreCase(systemType)) {
            options.add(new AssetOption(storageSystem.getId(), storageSystem.getName()));
        }
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) ArrayList(java.util.ArrayList) ResourceType(com.emc.sa.util.ResourceType) URI(java.net.URI) ExportBlockParam(com.emc.storageos.model.block.export.ExportBlockParam) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 39 with StorageSystemRestRep

use of com.emc.storageos.model.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getExportPathStorageSystem.

@Asset("exportPathStorageSystem")
public List<AssetOption> getExportPathStorageSystem(AssetOptionsContext ctx) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    List<StorageSystemRestRep> storageSystems = client.storageSystems().getAll();
    for (StorageSystemRestRep storageSystem : storageSystems) {
        String systemType = storageSystem.getSystemType();
        if (Type.vmax.name().equalsIgnoreCase(systemType) || Type.vplex.name().equalsIgnoreCase(systemType)) {
            options.add(new AssetOption(storageSystem.getId(), storageSystem.getName()));
        }
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) Asset(com.emc.sa.asset.annotation.Asset)

Example 40 with StorageSystemRestRep

use of com.emc.storageos.model.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.

the class GetMobilityGroupVolumesByHost method executeTask.

@Override
public Set<URI> executeTask() throws Exception {
    Set<URI> mobilityGroupVolumes = Sets.newHashSet();
    Set<URI> volumes = getHostExportedVolumes();
    for (URI volume : volumes) {
        VolumeRestRep vol = getClient().blockVolumes().get(volume);
        StorageSystemRestRep storage = getClient().storageSystems().get(vol.getStorageController());
        if (BlockStorageUtils.isVplexVolume(vol, storage.getSystemType())) {
            mobilityGroupVolumes.add(volume);
        }
    }
    return mobilityGroupVolumes;
}
Also used : StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Aggregations

StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)44 URI (java.net.URI)11 ArrayList (java.util.ArrayList)10 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)7 HashSet (java.util.HashSet)7 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)6 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)6 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 StoragePoolRestRep (com.emc.storageos.model.pools.StoragePoolRestRep)5 Asset (com.emc.sa.asset.annotation.Asset)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)3 StorageProviderRestRep (com.emc.storageos.model.smis.StorageProviderRestRep)3 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 HashMap (java.util.HashMap)3 GetStorageSystems (com.emc.sa.service.vipr.tasks.GetStorageSystems)2 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)2