use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VPlexMeteringTest method mockVPlexAdapter.
private StorageHADomain mockVPlexAdapter(StorageSystem storageSystem, String name, String serialNumber) throws InstantiationException, IllegalAccessException {
StorageHADomain director = mockObject(StorageHADomain.class, name);
director.setAdapterName(name);
director.setName(name);
director.setSerialNumber(serialNumber);
director.setProtocol(StoragePort.TransportType.FC.name());
director.setNumberofPorts("8");
director.setNativeGuid(String.format("%s:+ADAPTER+%s", storageSystem.getNativeGuid(), serialNumber));
director.setStorageDeviceURI(storageSystem.getId());
return director;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class VNXUnityFileStorageDeviceTest method getStorageHADomain.
public List<StorageHADomain> getStorageHADomain() {
VNXeApiClient apiclient = _unity.getVnxUnityClient(_device);
List<VNXeNasServer> nasServers = apiclient.getNasServers();
List<StorageHADomain> haDomains = new ArrayList<StorageHADomain>();
List<String> proto = new ArrayList<String>();
proto.add("CIFS");
StringSet protocols = new StringSet(proto);
for (VNXeNasServer nasServer : nasServers) {
StorageHADomain haDomain = new StorageHADomain();
haDomain.setId(URIUtil.createId(StorageHADomain.class));
String adapterNativeGuid = NativeGUIDGenerator.generateNativeGuid(_device, nasServer.getName(), NativeGUIDGenerator.ADAPTER);
haDomain.setNativeGuid(adapterNativeGuid);
haDomain.setStorageDeviceURI(_device.getId());
haDomain.setAdapterName(nasServer.getName());
haDomain.setName(nasServer.getName());
haDomain.setSerialNumber(nasServer.getId());
haDomain.setFileSharingProtocols(protocols);
haDomain.setVirtual(true);
haDomains.add(haDomain);
}
return haDomains;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method findSVMName.
/**
* Return the svm name associated with the file system. If a svm is not associated with
* this file system, then it will return null.
*/
private String findSVMName(FileShare fs) {
String portGroup = null;
URI port = fs.getStoragePort();
if (port == null) {
_log.info("No storage port URI to retrieve svm name");
} else {
StoragePort stPort = _dbClient.queryObject(StoragePort.class, port);
if (stPort != null) {
URI haDomainUri = stPort.getStorageHADomain();
if (haDomainUri == null) {
_log.info("No Port Group URI for port {}", port);
} else {
StorageHADomain haDomain = _dbClient.queryObject(StorageHADomain.class, haDomainUri);
if (haDomain != null && haDomain.getVirtual() == true) {
portGroup = stPort.getPortGroup();
_log.debug("using port {} and svm {}", stPort.getPortNetworkId(), portGroup);
}
}
}
}
return portGroup;
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class CephCommunicationInterface method discover.
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
_log.info("Starting discovery of Ceph StorageProvider. IP={}", accessProfile.getIpAddress());
StorageSystem system = _dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
List<StoragePool> newPools = new ArrayList<StoragePool>();
List<StoragePool> updatePools = new ArrayList<StoragePool>();
List<StoragePool> allPools = new ArrayList<StoragePool>();
String statusMsg = null;
try (CephClient cephClient = CephUtils.connectToCeph(_cephClientFactory, system)) {
system.setReachableStatus(true);
system.setSharedStorageCapacity(true);
ClusterInfo clusterInfo = cephClient.getClusterInfo();
List<PoolInfo> pools = cephClient.getPools();
for (PoolInfo pool : pools) {
String poolNativeGUID = NativeGUIDGenerator.generateNativeGuid(system, Long.toString(pool.getId()), NativeGUIDGenerator.POOL);
List<StoragePool> storagePools = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, StoragePool.class, "nativeGuid", poolNativeGUID);
StoragePool storagePool = null;
if (storagePools.isEmpty()) {
storagePool = new StoragePool();
storagePool.setId(URIUtil.createId(StoragePool.class));
storagePool.setNativeId(Long.toString(pool.getId()));
storagePool.setNativeGuid(poolNativeGUID);
storagePool.setPoolName(pool.getName());
storagePool.setLabel(pool.getName());
storagePool.setStorageDevice(system.getId());
storagePool.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
storagePool.setPoolServiceType(PoolServiceType.block.toString());
storagePool.setSupportedResourceTypes(SupportedResourceTypes.THIN_ONLY.name());
storagePool.setThinVolumePreAllocationSupported(false);
storagePool.addProtocols(RBD_ONLY);
storagePool.setSupportedCopyTypes(COPY_TYPES);
storagePool.setOperationalStatus(PoolOperationalStatus.READY.name());
storagePool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
storagePool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
storagePool.setMinimumThinVolumeSize(MINIMAL_VOLUME_SIZE);
// Ceph does not limit maximum volume size, but a limitation is required by CoprHD
// to allow volume creating
storagePool.setMaximumThinVolumeSize(MAXIMAL_VOLUME_SIZE);
newPools.add(storagePool);
} else if (storagePools.size() == 1) {
storagePool = storagePools.get(0);
updatePools.add(storagePool);
} else {
_log.warn("There are {} StoragePools with nativeGuid = {}", storagePools.size(), poolNativeGUID);
continue;
}
storagePool.setFreeCapacity(clusterInfo.getKbAvail());
storagePool.setTotalCapacity(clusterInfo.getKb());
}
StoragePoolAssociationHelper.setStoragePoolVarrays(system.getId(), newPools, _dbClient);
allPools.addAll(newPools);
allPools.addAll(updatePools);
DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, system.getId());
_dbClient.createObject(newPools);
_dbClient.updateObject(updatePools);
String adapterNativeGUID = NativeGUIDGenerator.generateNativeGuid(system, "-", NativeGUIDGenerator.ADAPTER);
List<StorageHADomain> storageAdapters = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, StorageHADomain.class, "nativeGuid", adapterNativeGUID);
StorageHADomain storageHADomain = null;
if (storageAdapters.isEmpty()) {
storageHADomain = new StorageHADomain();
storageHADomain.setId(URIUtil.createId(StorageHADomain.class));
storageHADomain.setStorageDeviceURI(system.getId());
storageHADomain.setNativeGuid(adapterNativeGUID);
String monitorHost = accessProfile.getIpAddress();
storageHADomain.setAdapterName(monitorHost);
storageHADomain.setName(monitorHost);
storageHADomain.setLabel(monitorHost);
storageHADomain.setNumberofPorts("1");
storageHADomain.setAdapterType(HADomainType.FRONTEND.name());
storageHADomain.setProtocol(Block.RBD.name());
_dbClient.createObject(storageHADomain);
} else {
storageHADomain = storageAdapters.get(0);
if (storageAdapters.size() != 1) {
_log.warn("There are {} StorageHADomains with nativeGuid = {}", storageAdapters.size(), adapterNativeGUID);
}
}
String portNativeGUID = NativeGUIDGenerator.generateNativeGuid(system, "-", NativeGUIDGenerator.PORT);
List<StoragePort> storagePorts = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, StoragePort.class, "nativeGuid", portNativeGUID);
StoragePort storagePort = null;
if (storagePorts.isEmpty()) {
storagePort = new StoragePort();
storagePort.setId(URIUtil.createId(StoragePort.class));
storagePort.setNativeGuid(portNativeGUID);
storagePort.setPortNetworkId(portNativeGUID);
storagePort.setPortName(PORT_NAME);
storagePort.setPortGroup(PORT_GROUP);
storagePort.setStorageDevice(system.getId());
storagePort.setStorageHADomain(storageHADomain.getId());
storagePort.setPortType(PortType.frontend.name());
storagePort.setTransportType(Transport.IP.name());
// TODO Neither Java client, nor pure librados provide details about Ceph status, though,
// it is possible to extend Ceph client (librados and Java library) functionality, and then use it here
storagePort.setOperationalStatus(OperationalStatus.OK.name());
storagePort.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_dbClient.createObject(storagePort);
} else {
storagePort = storagePorts.get(0);
if (storagePorts.size() != 1) {
_log.warn("There are {} StoragePorts with nativeGuid = {}", storagePorts.size(), portNativeGUID);
}
}
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(Collections.singletonList(storagePort), null, _dbClient, _coordinator, allPools);
statusMsg = String.format("Discovery completed successfully for Storage System: %s", system.getNativeGuid());
} catch (Exception e) {
system.setReachableStatus(false);
_log.error(String.format("Exception was encountered when attempting to discover Ceph Instance %s", accessProfile.getIpAddress()), e);
statusMsg = String.format("Discovery failed because %s", e.getLocalizedMessage());
throw CephException.exceptions.operationException(e);
} finally {
if (system != null) {
system.setLastDiscoveryStatusMessage(statusMsg);
_dbClient.updateObject(system);
}
}
}
use of com.emc.storageos.db.client.model.StorageHADomain in project coprhd-controller by CoprHD.
the class CinderCommunicationInterface method addPorts.
/**
* This method adds storage ports to the system if not done already
*
* @throws IOException
*/
private void addPorts(StorageSystem system) throws IOException {
StorageProtocol.Transport supportedProtocol = getProtocol(system);
_logger.info("Checking if system {} needs a new storage port", system.getLabel());
if (supportedProtocol == null) {
return;
}
_logger.info("System {} supports protocol {}", system.getLabel(), supportedProtocol.name().toString());
boolean isPresent = false;
List<StoragePort> allPorts = new ArrayList<StoragePort>();
URIQueryResultList storagePortURIs = new URIQueryResultList();
URI sysid = system.getId();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(sysid), storagePortURIs);
Iterator<URI> storagePortsIter = storagePortURIs.iterator();
while (storagePortsIter.hasNext()) {
URI storagePortURI = storagePortsIter.next();
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, storagePortURI);
if (storagePort != null && !storagePort.getInactive() && (storagePort.getTransportType().equalsIgnoreCase(supportedProtocol.name().toString()))) {
_logger.info("System {} already has port for protocol {}", system.getLabel(), supportedProtocol.name().toString());
isPresent = true;
if (storagePort.getPortNetworkId() == null) {
// update it -- this needs to change
storagePort.setPortNetworkId(storagePort.getNativeGuid());
_dbClient.persistObject(storagePort);
}
allPorts.add(storagePort);
}
}
// while
if (!isPresent) {
StorageHADomain adapter = CinderUtils.getStorageAdapter(system, _dbClient);
// Now we need to add the port to the system
_logger.info("Adding new storage port of type {} to storage system {}", supportedProtocol.name().toString(), system.getLabel());
StoragePort port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setStorageDevice(sysid);
// port name is "DEFAULT" since we don't know how to name it
String portName = CinderConstants.DEFAULT;
String nativeGuid = NativeGUIDGenerator.generateNativeGuid(system, portName, NativeGUIDGenerator.PORT);
port.setNativeGuid(nativeGuid);
port.setPortNetworkId(nativeGuid);
port.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.toString());
// always treat it as a frontend port
port.setPortType(PortType.frontend.name());
port.setOperationalStatus(OperationalStatus.OK.toString());
port.setTransportType(supportedProtocol.name().toString());
port.setLabel(portName);
port.setPortName(portName);
port.setStorageHADomain(adapter.getId());
port.setPortGroup(CinderConstants.CINDER_PORT_GROUP);
port.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
_dbClient.createObject(port);
allPorts.add(port);
}
StoragePortAssociationHelper.updatePortAssociations(allPorts, _dbClient);
DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, sysid);
}
Aggregations