use of com.emc.storageos.hp3par.command.PortStatisticsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARUtil method discoverStoragePortsById.
/**
* Get storage port information
* @throws Exception
*/
public void discoverStoragePortsById(String storageSystemId, List<StoragePort> storagePorts, Registry driverRegistery) throws Exception {
// For this 3PAR system
try {
// get Api client
HP3PARApi hp3parApi = getHP3PARDeviceFromNativeId(storageSystemId, driverRegistery);
// get storage port details
PortCommandResult portResult = hp3parApi.getPortDetails();
PortStatisticsCommandResult portStatResult = hp3parApi.getPortStatisticsDetail();
// for each ViPR Storage port = 3PAR host port
for (PortMembers currMember : portResult.getMembers()) {
StoragePort port = new StoragePort();
// Consider online target ports
if (currMember.getMode() != HP3PARConstants.MODE_TARGET || currMember.getLinkState() != HP3PARConstants.LINK_READY) {
continue;
}
if (currMember.getLabel() == null) {
String label = String.format("port:%s:%s:%s", currMember.getPortPos().getNode(), currMember.getPortPos().getSlot(), currMember.getPortPos().getCardPort());
port.setPortName(label);
} else {
port.setPortName(currMember.getLabel());
}
port.setStorageSystemId(storageSystemId);
switch(currMember.getProtocol()) {
case 1:
port.setTransportType(TransportType.FC);
break;
case 3:
port.setTransportType(TransportType.Ethernet);
break;
case 2:
port.setTransportType(TransportType.IP);
break;
default:
_log.warn("3PARDriver: discoverStoragePorts Invalid port {}", port.getPortName());
break;
}
for (PortStatMembers currStat : portStatResult.getMembers()) {
if (currMember.getPortPos().getNode() == currStat.getNode() && currMember.getPortPos().getSlot() == currStat.getSlot() && currMember.getPortPos().getCardPort() == currStat.getCardPort()) {
port.setPortSpeed(currStat.getSpeed() * HP3PARConstants.MEGA_BYTE);
}
}
// grouping with cluster node and slot
port.setPortGroup(currMember.getPortPos().getNode().toString());
port.setPortSubGroup(currMember.getPortPos().getSlot().toString());
// set specific properties based on protocol
if (port.getTransportType().equals(TransportType.FC.toString())) {
port.setPortNetworkId(SanUtils.formatWWN(currMember.getPortWWN()));
// rest of the values
port.setEndPointID(port.getPortNetworkId());
port.setTcpPortNumber((long) 0);
} else if (port.getTransportType().equals(TransportType.IP.toString())) {
port.setIpAddress(currMember.getIPAddr());
port.setPortNetworkId(currMember.getiSCSINmae());
port.setTcpPortNumber(currMember.getiSCSIPortInfo().getiSNSPort());
// rest of the values
port.setEndPointID(port.getPortNetworkId());
}
port.setAvgBandwidth(port.getPortSpeed());
port.setPortHAZone(String.format("Group-%s", currMember.getPortPos().getNode()));
String id = String.format("%s:%s:%s", currMember.getPortPos().getNode(), currMember.getPortPos().getSlot(), currMember.getPortPos().getCardPort());
// Storage object properties
port.setNativeId(id);
port.setDeviceLabel(port.getPortName());
port.setDisplayName(port.getPortName());
port.setOperationalStatus(StoragePort.OperationalStatus.OK);
_log.info("3PARDriver: added storage port {}, native id {}", port.getPortName(), port.getNativeId());
storagePorts.add(port);
}
// for each storage pool
} catch (Exception e) {
throw e;
}
}
use of com.emc.storageos.hp3par.command.PortStatisticsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARApiFactory method main.
// Sample direct program
public static void main(String[] args) {
System.out.println("starting HP3PAR main");
try {
URI uri = URI.create(String.format("https://xxxxx:8080/api/v1/credentials"));
HP3PARApiFactory factory = new HP3PARApiFactory();
factory.setConnectionTimeoutMs(30000 * 4);
factory.setConnManagerTimeout(60000 * 4);
factory.setSocketConnectionTimeoutMs(7200000 * 4);
BasicConfigurator.configure();
factory.init();
HP3PARApi hp3parApi = factory.getRESTClient(uri, "xxx", "xxxx");
String authToken = hp3parApi.getAuthToken("xxxx", "xxxx");
System.out.println(authToken);
hp3parApi.verifyUserRole("test2");
SystemCommandResult sysRes = hp3parApi.getSystemDetails();
System.out.println(sysRes.toString());
CPGCommandResult cpgRes = hp3parApi.getAllCPGDetails();
System.out.println(cpgRes.toString());
hp3parApi.getPortDetails();
PortStatisticsCommandResult portStatRes = hp3parApi.getPortStatisticsDetail();
HostSetDetailsCommandResult hostsetRes = hp3parApi.getHostSetDetails("Cluster2021");
boolean present = false;
for (int index = 0; index < hostsetRes.getSetmembers().size(); index++) {
if ("myhost1".compareTo(hostsetRes.getSetmembers().get(index)) == 0) {
present = true;
break;
}
}
if (present == false) {
// update cluster with this host
hp3parApi.updateHostSet("Cluster2021", "host1");
}
} catch (Exception e) {
System.out.println("EROR");
System.out.println(e);
System.out.println(CompleteError.getStackTrace(e));
e.printStackTrace();
}
}
use of com.emc.storageos.hp3par.command.PortStatisticsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARApi method getPortStatisticsDetail.
/**
* Get port statistics information
* @return port details
* @throws Exception
*/
public PortStatisticsCommandResult getPortStatisticsDetail() throws Exception {
_log.info("3PARDriver:getPortStatisticsDetail enter");
ClientResponse clientResp = null;
try {
clientResp = get(URI_PORT_STATISTICS);
if (clientResp == null) {
_log.error("3PARDriver:There is no response from 3PAR");
throw new HP3PARException("There is no response from 3PAR");
} else if (clientResp.getStatus() != 200) {
String errResp = getResponseDetails(clientResp);
throw new HP3PARException(errResp);
} else {
String responseString = clientResp.getEntity(String.class);
_log.info("3PARDriveri:getPortStatisticsDetail 3PAR response is {}", responseString);
PortStatisticsCommandResult portStatResult = new Gson().fromJson(sanitize(responseString), PortStatisticsCommandResult.class);
return portStatResult;
}
} catch (Exception e) {
throw e;
} finally {
if (clientResp != null) {
clientResp.close();
}
_log.info("3PARDriver:getPortStatisticsDetail leave");
}
// end try/catch/finally
}
use of com.emc.storageos.hp3par.command.PortStatisticsCommandResult in project coprhd-controller by CoprHD.
the class HP3PARApi method getPortStatistics.
public PortStatisticsCommandResult getPortStatistics(String portId) throws Exception {
_log.info("3PARDriver: getPortStatistics enter");
ClientResponse clientResp = null;
final String path = MessageFormat.format(URI_PORT_STATISTICS_SPECIFIC, portId);
PortStatisticsCommandResult portStatResult = null;
_log.info("3PARDriver: getPortStatistics path is {}", path);
try {
clientResp = get(path);
if (clientResp == null) {
_log.error("3PARDriver: getPortStatistics There is no response from 3PAR");
throw new HP3PARException("There is no response from 3PAR");
} else if (clientResp.getStatus() != 200) {
String errResp = getResponseDetails(clientResp);
_log.error("3PARDriver: getPortStatistics There is error response from 3PAR = {}", errResp);
throw new HP3PARException(errResp);
} else {
String responseString = clientResp.getEntity(String.class);
_log.info("3PARDriveri:getPortStatistics 3PAR response is {}", responseString);
portStatResult = new Gson().fromJson(sanitize(responseString), PortStatisticsCommandResult.class);
}
} catch (Exception e) {
throw e;
} finally {
if (clientResp != null) {
clientResp.close();
}
_log.info("3PARDriver: getPortStatistics leave");
}
return portStatResult;
}
Aggregations