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);
}
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);
}
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);
}
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;
}
Aggregations