Search in sources :

Example 56 with Initiator

use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.

the class AixVioDiscoveryAdapter method discoverInitiators.

@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
    AixVioCLI cli = getCli(host);
    List<Initiator> addedInitiators = Lists.newArrayList();
    try {
        for (HBAInfo hba : cli.listInitiators()) {
            Initiator initiator;
            String wwpn = SanUtils.normalizeWWN(hba.getWwpn());
            if (findInitiatorByPort(oldInitiators, wwpn) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, wwpn);
            }
            discoverFCInitiator(host, initiator, hba);
        }
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to list FC Ports, skipping");
    }
    try {
        for (String iqn : cli.listIQNs()) {
            Initiator initiator;
            if (findInitiatorByPort(oldInitiators, iqn) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, iqn);
            }
            discoverISCSIInitiator(host, initiator, iqn);
        }
    } catch (DeviceControllerException e) {
        throw e;
    } catch (Exception e) {
        LOG.error("Failed to list iSCSI Ports, skipping");
    }
    // update export groups with new initiators if host is in use.
    if (!addedInitiators.isEmpty()) {
        Collection<URI> addedInitiatorIds = Lists.newArrayList(Collections2.transform(addedInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
        changes.setNewInitiators(addedInitiatorIds);
    }
}
Also used : HBAInfo(com.iwave.ext.linux.model.HBAInfo) Initiator(com.emc.storageos.db.client.model.Initiator) AixVioCLI(com.emc.aix.AixVioCLI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CommandException(com.iwave.ext.command.CommandException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)

Example 57 with Initiator

use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.

the class EsxHostDiscoveryAdapter method discoverHost.

/**
 * Discover Exs host and its IpIterfaces and Initiators.
 *
 * @param hostSystem
 *            - {@link HostSystem} VI SDK managedObject instance
 * @param targetHost
 *            - {@link Host} being discovered.
 * @param changes
 *            {@link HostStateChange} instance containing host changes
 *            during discovery.
 */
private void discoverHost(HostSystem hostSystem, Host targetHost, HostStateChange changes) {
    // Only attempt to update ip interfaces or initiators for connected
    // hosts
    HostSystemConnectionState connectionState = getConnectionState(hostSystem);
    if (connectionState == HostSystemConnectionState.connected) {
        // discover initiators
        List<Initiator> oldInitiators = new ArrayList<Initiator>();
        List<Initiator> addedInitiators = new ArrayList<Initiator>();
        discoverConnectedHostInitiators(hostSystem, targetHost, oldInitiators, addedInitiators);
        if (!oldInitiators.isEmpty() || !addedInitiators.isEmpty()) {
            Collection<URI> oldInitiatorIds = Lists.newArrayList(Collections2.transform(oldInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
            changes.setOldInitiators(oldInitiatorIds);
            Collection<URI> addedInitiatorIds = Lists.newArrayList(Collections2.transform(addedInitiators, CommonTransformerFunctions.fctnDataObjectToID()));
            changes.setNewInitiators(addedInitiatorIds);
        }
    } else {
        if (connectionState == HostSystemConnectionState.disconnected) {
            throw new IllegalStateException("Host is disconnected");
        } else if (connectionState == HostSystemConnectionState.notResponding) {
            throw new IllegalStateException("Host is not responding");
        } else {
            throw new IllegalStateException("Could not determine host connection state");
        }
    }
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) HostSystemConnectionState(com.vmware.vim25.HostSystemConnectionState) URI(java.net.URI)

Example 58 with Initiator

use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.

the class EsxHostDiscoveryAdapter method discoverConnectedHostInitiators.

/**
 * Discovers connected Host's Initiators and Ipinterfaces
 *
 * @param hostSystem
 *            - {@link HostSystem} VI SDK managedObject instance
 * @param targetHost
 *            - {@link Host} being discovered.
 * @param oldInitiators
 *            - old initiator list
 * @param addedInitiators
 *            - new/added initiator list
 */
protected void discoverConnectedHostInitiators(HostSystem hostSystem, Host targetHost, List<Initiator> oldInitiators, List<Initiator> addedInitiators) {
    // discover ipInterfaces
    info(String.format("Discovering IP interfaces for %s", targetHost.forDisplay()));
    List<IpInterface> oldIpInterfaces = new ArrayList<IpInterface>();
    Iterables.addAll(oldIpInterfaces, getIpInterfaces(targetHost));
    for (HostVirtualNic nic : getNics(hostSystem)) {
        if (isIp6Interface(nic)) {
            IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, nic.spec.getIp().ipAddress);
            discoverIp6Interface(targetHost, ipInterface, nic);
        }
        if (isIp4Interface(nic)) {
            IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, nic.spec.getIp().ipAddress);
            discoverIp4Interface(targetHost, ipInterface, nic);
        }
    }
    removeDiscoveredInterfaces(oldIpInterfaces);
    info(String.format("Discovering initiators for %s", targetHost.forDisplay()));
    Iterables.addAll(oldInitiators, getInitiators(targetHost));
    for (HostHostBusAdapter hba : getHostBusAdapters(hostSystem)) {
        if (hba instanceof HostFibreChannelHba) {
            String port = SanUtils.normalizeWWN(((HostFibreChannelHba) hba).getPortWorldWideName());
            Initiator initiator;
            if (findInitiatorByPort(oldInitiators, port) == null) {
                initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, port);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, port);
            }
            discoverInitiator(targetHost, initiator, (HostFibreChannelHba) hba);
        } else if (hba instanceof HostInternetScsiHba) {
            String iqn = ((HostInternetScsiHba) hba).getIScsiName();
            Initiator initiator;
            if (findInitiatorByPort(oldInitiators, iqn) == null) {
                initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, iqn);
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(targetHost.getId(), oldInitiators, iqn);
            }
            discoverInitiator(targetHost, initiator, (HostInternetScsiHba) hba);
        }
    }
    if (!oldInitiators.isEmpty()) {
        clearScaleIOInitiators(oldInitiators);
    }
}
Also used : HostVirtualNic(com.vmware.vim25.HostVirtualNic) IpInterface(com.emc.storageos.db.client.model.IpInterface) Initiator(com.emc.storageos.db.client.model.Initiator) HostInternetScsiHba(com.vmware.vim25.HostInternetScsiHba) ArrayList(java.util.ArrayList) HostFibreChannelHba(com.vmware.vim25.HostFibreChannelHba) HostHostBusAdapter(com.vmware.vim25.HostHostBusAdapter)

Example 59 with Initiator

use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.

the class UcsComputeDevice method getHBAToStoragePorts.

private Map<String, Map<String, Integer>> getHBAToStoragePorts(URI volumeId, URI hostId) {
    Host host = _dbClient.queryObject(Host.class, hostId);
    Map<String, String> initiatorToHBAMapping = getInitiatorToHBAMapping(host.getComputeElement());
    Volume volume = _dbClient.queryObject(Volume.class, volumeId);
    List<Initiator> initiators = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, hostId, Initiator.class, "host");
    Map<ExportMask, ExportGroup> exportMasks = ExportUtils.getExportMasks(volume, _dbClient);
    Map<String, Map<String, Integer>> hbaToStoragePortMapForBoot = new HashMap<String, Map<String, Integer>>();
    for (Initiator initiator : initiators) {
        for (ExportMask exportMask : exportMasks.keySet()) {
            List<URI> storagePorts = ExportUtils.getInitiatorPortsInMask(exportMask, initiator, _dbClient);
            if (storagePorts != null && !storagePorts.isEmpty()) {
                Integer volumeHLU = Integer.valueOf(exportMask.getVolumes().get(volumeId.toString()));
                for (URI storagePortUri : storagePorts) {
                    StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortUri);
                    String hbaName = initiatorToHBAMapping.get(initiator.getInitiatorPort());
                    if (hbaName != null) {
                        if (hbaToStoragePortMapForBoot.get(hbaName) == null) {
                            hbaToStoragePortMapForBoot.put(hbaName, new HashMap<String, Integer>());
                        }
                        hbaToStoragePortMapForBoot.get(hbaName).put(port.getPortNetworkId(), volumeHLU);
                    }
                }
            }
        }
    }
    return hbaToStoragePortMapForBoot;
}
Also used : HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Volume(com.emc.storageos.db.client.model.Volume) Initiator(com.emc.storageos.db.client.model.Initiator) Map(java.util.Map) HashMap(java.util.HashMap)

Example 60 with Initiator

use of com.emc.storageos.db.client.model.Initiator in project coprhd-controller by CoprHD.

the class VplexExportGroupServiceApiImpl method getNetworkTaggedPortsForHost.

/**
 * This method returns all StoragePorts from networks containing initiators
 * of a host.
 *
 * @param hostUri
 * @param networkToPortsMap map of network to storageport set
 */
private Map<URI, StoragePort> getNetworkTaggedPortsForHost(URI hostUri, Map<Network, Set<StoragePort>> networkToPortsMap) {
    URIQueryResultList initiatorURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getContainedObjectsConstraint(hostUri, Initiator.class, "host"), initiatorURIs);
    Map<URI, StoragePort> networkStoragePorts = new HashMap<URI, StoragePort>();
    Set<StoragePort> storagePorts = new HashSet<StoragePort>();
    Iterator<URI> initiatorURIsIter = initiatorURIs.iterator();
    while (initiatorURIsIter.hasNext()) {
        URI initiatorURI = initiatorURIs.iterator().next();
        Initiator initiator = _dbClient.queryObject(Initiator.class, initiatorURI);
        if (!initiator.getInactive() && initiator.getRegistrationStatus().equals(DiscoveredDataObject.RegistrationStatus.REGISTERED.name())) {
            for (Map.Entry<Network, Set<StoragePort>> entry : networkToPortsMap.entrySet()) {
                if (entry.getKey().retrieveEndpoints().contains(initiator.getInitiatorPort())) {
                    storagePorts.addAll(entry.getValue());
                }
            }
        }
    }
    for (StoragePort storagePort : storagePorts) {
        networkStoragePorts.put(storagePort.getId(), storagePort);
    }
    return networkStoragePorts;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Initiator(com.emc.storageos.db.client.model.Initiator) Network(com.emc.storageos.db.client.model.Network) HashMap(java.util.HashMap) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap) HashSet(java.util.HashSet)

Aggregations

Initiator (com.emc.storageos.db.client.model.Initiator)487 URI (java.net.URI)345 ArrayList (java.util.ArrayList)266 HashMap (java.util.HashMap)170 HashSet (java.util.HashSet)161 ExportMask (com.emc.storageos.db.client.model.ExportMask)156 List (java.util.List)119 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)102 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)98 Map (java.util.Map)85 StringSet (com.emc.storageos.db.client.model.StringSet)83 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)82 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)81 StoragePort (com.emc.storageos.db.client.model.StoragePort)78 NamedURI (com.emc.storageos.db.client.model.NamedURI)73 Set (java.util.Set)72 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)58 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)57 StringMap (com.emc.storageos.db.client.model.StringMap)55 Host (com.emc.storageos.db.client.model.Host)54