Search in sources :

Example 16 with PortInfo

use of com.emc.storageos.vplex.api.clientdata.PortInfo in project coprhd-controller by CoprHD.

the class VPlexApiTest method testCreateStorageViewTargetsOnly.

/**
 * Tests the API createStorageView when only a target ports are passed
 * in the request.
 */
@Test
public void testCreateStorageViewTargetsOnly() {
    boolean wasException = false;
    try {
        // Get the storage view name
        String storageViewName = _properties.getProperty(STORAGE_VIEW_NAME_PROP_KEY);
        // Get the target ports
        List<PortInfo> targetPortInfoList = new ArrayList<PortInfo>();
        String storageViewTargetsStr = _properties.getProperty(STORAGE_VIEW_TARGETS_PROP_KEY);
        StringTokenizer tokenizer = new StringTokenizer(storageViewTargetsStr, ",");
        while (tokenizer.hasMoreTokens()) {
            String portWWN = tokenizer.nextToken();
            PortInfo targetPortInfo = new PortInfo(portWWN);
            targetPortInfoList.add(targetPortInfo);
        }
        // Create the storage view
        VPlexStorageViewInfo storageViewInfo = _client.createStorageView(storageViewName, targetPortInfoList, null, null);
        Assert.assertNotNull(storageViewInfo);
        Assert.assertEquals(storageViewInfo.getName(), storageViewName);
        // Cleanup
        Boolean[] viewFound = new Boolean[] { new Boolean(false) };
        _client.deleteStorageView(storageViewName, VPLEX_TEST_CLUSTER, viewFound);
    } catch (Exception e) {
        wasException = true;
    }
    Assert.assertFalse(wasException);
}
Also used : PortInfo(com.emc.storageos.vplex.api.clientdata.PortInfo) StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with PortInfo

use of com.emc.storageos.vplex.api.clientdata.PortInfo in project coprhd-controller by CoprHD.

the class VPlexApiTest method testRemoveInitiatorsFromStorageView.

/**
 * Tests the API removeInitiatorFromStorageView.
 */
@Test
public void testRemoveInitiatorsFromStorageView() {
    boolean wasException = false;
    try {
        // Get the storage view name
        String storageViewName = _properties.getProperty(STORAGE_VIEW_NAME_PROP_KEY);
        // Get the target ports
        List<PortInfo> targetPortInfoList = new ArrayList<PortInfo>();
        String storageViewTargetsStr = _properties.getProperty(STORAGE_VIEW_TARGETS_PROP_KEY);
        StringTokenizer tokenizer = new StringTokenizer(storageViewTargetsStr, ",");
        while (tokenizer.hasMoreTokens()) {
            String portWWN = tokenizer.nextToken();
            PortInfo targetPortInfo = new PortInfo(portWWN);
            targetPortInfoList.add(targetPortInfo);
        }
        // Get the initiator ports
        List<PortInfo> initiatorPortInfoList = new ArrayList<PortInfo>();
        String storageViewInitiatorsStr = _properties.getProperty(STORAGE_VIEW_INITIATORS_PROP_KEY);
        tokenizer = new StringTokenizer(storageViewInitiatorsStr, ",");
        while (tokenizer.hasMoreTokens()) {
            String portWWN = tokenizer.nextToken();
            PortInfo initiatorPortInfo = new PortInfo(portWWN);
            initiatorPortInfoList.add(initiatorPortInfo);
        }
        // Create the storage view
        VPlexStorageViewInfo storageViewInfo = _client.createStorageView(storageViewName, targetPortInfoList, initiatorPortInfoList, null);
        Assert.assertNotNull(storageViewInfo);
        Assert.assertEquals(storageViewInfo.getName(), storageViewName);
        // Remove the initiators from the storage view.
        _client.removeInitiatorsFromStorageView(storageViewName, VPLEX_TEST_CLUSTER, initiatorPortInfoList);
        // Cleanup
        Boolean[] viewFound = new Boolean[] { new Boolean(false) };
        _client.deleteStorageView(storageViewName, VPLEX_TEST_CLUSTER, viewFound);
    } catch (Exception e) {
        wasException = true;
    }
    Assert.assertFalse(wasException);
}
Also used : PortInfo(com.emc.storageos.vplex.api.clientdata.PortInfo) StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 18 with PortInfo

use of com.emc.storageos.vplex.api.clientdata.PortInfo in project coprhd-controller by CoprHD.

the class VPlexApiTest method testAddInitiatorsToStorageView.

/**
 * Tests the API addInitiatorsToStorageView.
 */
@Test
public void testAddInitiatorsToStorageView() {
    boolean wasException = false;
    try {
        // Get the storage view name
        String storageViewName = _properties.getProperty(STORAGE_VIEW_NAME_PROP_KEY);
        // Get the target ports
        List<PortInfo> targetPortInfoList = new ArrayList<PortInfo>();
        String storageViewTargetsStr = _properties.getProperty(STORAGE_VIEW_TARGETS_PROP_KEY);
        StringTokenizer tokenizer = new StringTokenizer(storageViewTargetsStr, ",");
        while (tokenizer.hasMoreTokens()) {
            String portWWN = tokenizer.nextToken();
            PortInfo targetPortInfo = new PortInfo(portWWN);
            targetPortInfoList.add(targetPortInfo);
        }
        // Create the storage view
        VPlexStorageViewInfo storageViewInfo = _client.createStorageView(storageViewName, targetPortInfoList, null, null);
        Assert.assertNotNull(storageViewInfo);
        Assert.assertEquals(storageViewInfo.getName(), storageViewName);
        // Get the initiator ports
        List<PortInfo> initiatorPortInfoList = new ArrayList<PortInfo>();
        String storageViewInitiatorsStr = _properties.getProperty(STORAGE_VIEW_INITIATORS_PROP_KEY);
        tokenizer = new StringTokenizer(storageViewInitiatorsStr, ",");
        while (tokenizer.hasMoreTokens()) {
            String portWWN = tokenizer.nextToken();
            PortInfo initiatorPortInfo = new PortInfo(portWWN);
            initiatorPortInfoList.add(initiatorPortInfo);
        }
        // Add the initiators to the storage view.
        _client.addInitiatorsToStorageView(storageViewName, VPLEX_TEST_CLUSTER, initiatorPortInfoList);
        // Cleanup
        Boolean[] viewFound = new Boolean[] { new Boolean(false) };
        _client.deleteStorageView(storageViewName, VPLEX_TEST_CLUSTER, viewFound);
    } catch (Exception e) {
        wasException = true;
    }
    Assert.assertFalse(wasException);
}
Also used : PortInfo(com.emc.storageos.vplex.api.clientdata.PortInfo) StringTokenizer(java.util.StringTokenizer) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 19 with PortInfo

use of com.emc.storageos.vplex.api.clientdata.PortInfo in project coprhd-controller by CoprHD.

the class VPlexApiExportManager method getTargetInfoForPorts.

/**
 * Gets the target info for the passed ports.
 *
 * @param portInfoList The list of ports.
 *
 * @return A map of the associated target info for the ports keyed by the
 *         port WWN.
 *
 * @throws VPlexApiException When an error occurs getting the target info.
 */
public Map<String, VPlexTargetInfo> getTargetInfoForPorts(List<VPlexPortInfo> portInfoList) throws VPlexApiException {
    // There will only be targets for FE ports. Ignore ports that are
    // not FE ports.
    List<PortInfo> fePortInfoList = new ArrayList<PortInfo>();
    for (VPlexPortInfo portInfo : portInfoList) {
        if (portInfo.isFrontendPort()) {
            PortInfo fePortInfo = new PortInfo(portInfo.getPortWwn());
            fePortInfoList.add(fePortInfo);
        }
    }
    // Get the target info for these FE ports.
    List<VPlexTargetInfo> targetInfoList = new ArrayList<VPlexTargetInfo>();
    findTargets(fePortInfoList, targetInfoList, false);
    // Now map the target info for each FE port to the
    // port WWN of that port.
    Map<String, VPlexTargetInfo> targetInfoMap = new HashMap<String, VPlexTargetInfo>();
    for (VPlexTargetInfo targetInfo : targetInfoList) {
        targetInfoMap.put(targetInfo.getPortWwn(), targetInfo);
    }
    return targetInfoMap;
}
Also used : PortInfo(com.emc.storageos.vplex.api.clientdata.PortInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Aggregations

PortInfo (com.emc.storageos.vplex.api.clientdata.PortInfo)19 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)8 StringTokenizer (java.util.StringTokenizer)8 Test (org.junit.Test)8 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)6 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)6 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)6 ControllerException (com.emc.storageos.volumecontroller.ControllerException)6 VPlexApiClient (com.emc.storageos.vplex.api.VPlexApiClient)6 VPlexApiException (com.emc.storageos.vplex.api.VPlexApiException)6 WorkflowException (com.emc.storageos.workflow.WorkflowException)6 IOException (java.io.IOException)6 URISyntaxException (java.net.URISyntaxException)6 ExportMask (com.emc.storageos.db.client.model.ExportMask)5 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 StoragePort (com.emc.storageos.db.client.model.StoragePort)5