Search in sources :

Example 1 with SwFcSanPc

use of com.emc.cloud.platform.ucs.out.model.SwFcSanPc in project coprhd-controller by CoprHD.

the class UCSMServiceImpl method getUplinkPortChannels.

@Override
public Map<String, SwFcSanPc> getUplinkPortChannels(String ucsmURL, String username, String password) throws ClientGeneralException {
    Map<String, SwFcSanPc> switchFcInterfaceMap = new HashMap<String, SwFcSanPc>();
    ComputeSession computeSession = sessionManager.getSession(ucsmURL, username, password);
    ConfigResolveClass configResolveClass = new ConfigResolveClass();
    configResolveClass.setClassId(NamingClassId.SW_FC_SAN_PC);
    configResolveClass.setInHierarchical("true");
    com.emc.cloud.platform.ucs.out.model.ConfigResolveClass configResolveClassOut = computeSession.execute(factory.createConfigResolveClass(configResolveClass), com.emc.cloud.platform.ucs.out.model.ConfigResolveClass.class);
    for (JAXBElement<?> managedObject : getConfigSetManagedObjects(configResolveClassOut)) {
        if (managedObject.getValue() instanceof SwFcSanPc) {
            switchFcInterfaceMap.put(((SwFcSanPc) managedObject.getValue()).getDn(), (SwFcSanPc) managedObject.getValue());
        }
    }
    return switchFcInterfaceMap;
}
Also used : HashMap(java.util.HashMap) ConfigResolveClass(com.emc.cloud.platform.ucs.in.model.ConfigResolveClass) SwFcSanPc(com.emc.cloud.platform.ucs.out.model.SwFcSanPc)

Example 2 with SwFcSanPc

use of com.emc.cloud.platform.ucs.out.model.SwFcSanPc in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method discoverComputeSystem.

public void discoverComputeSystem(URI computeSystemURI) {
    String ucsmVersion;
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemURI);
    _log.info("Inside discoverComputeSystems of class : " + getClass().toString());
    URL ucsmURL = getUcsmURL(cs);
    List<ComputeBlade> computeBlades;
    List<LsServer> allServiceProfiles;
    Map<String, LsServer> associatedLsServers;
    List<LsServer> serviceProfileTemplates;
    List<VnicLanConnTempl> vnicTemplates;
    List<VnicSanConnTempl> vhbaTemplates;
    Map<String, FcPIo> uplinkMap;
    Map<String, SwFcSanEp> fcInterfaceMap;
    List<SwVsan> vsanList;
    Map<String, SwFcSanPc> portChannelMap;
    List<FabricVlan> vlanList;
    List<FabricVsan> vsanFabricList;
    List<com.emc.cloud.platform.ucs.out.model.LsbootPolicy> bootPolicies;
    try {
        ucsmVersion = ucsmService.getDeviceVersion(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        verifyVersion(cs, ucsmVersion);
        computeBlades = ucsmService.getComputeBlades(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        allServiceProfiles = ucsmService.getAllServiceProfiles(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        associatedLsServers = ucsmService.getAllAssociatedLsServers(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        serviceProfileTemplates = ucsmService.getServiceProfileTemplates(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        bootPolicies = ucsmService.getBootPolicies(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vnicTemplates = ucsmService.getVnicTemplates(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vhbaTemplates = ucsmService.getVhbaTemplates(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        uplinkMap = ucsmService.getFICUplinkPorts(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        fcInterfaceMap = ucsmService.getSwitchFCInterfaces(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vsanList = ucsmService.getUcsSwitchVSans(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        portChannelMap = ucsmService.getUplinkPortChannels(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vlanList = ucsmService.getUcsVlans(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
        vsanFabricList = ucsmService.getUcsFabricVsans(ucsmURL.toString(), cs.getUsername(), cs.getPassword());
    } catch (Exception e) {
        _log.error("Failed to pull device data: " + cs.getId(), e);
        if (e.getCause() != null && e.getCause().getMessage() != null) {
            cs.setLastDiscoveryStatusMessage(e.getCause().getMessage());
        } else {
            cs.setLastDiscoveryStatusMessage(e.getMessage());
        }
        _dbClient.updateObject(cs);
        throw ComputeSystemControllerException.exceptions.discoverFailed(computeSystemURI.toString(), e);
    }
    try {
        reconcileServiceProfileTemplates(cs, serviceProfileTemplates);
        reconcileServiceProfiles(cs, allServiceProfiles);
        reconcileComputeBlades(cs, computeBlades, associatedLsServers);
        reconcileVhbas(cs, associatedLsServers, new VhbaHelper(vsanFabricList));
        reconcileServiceProfileTemplatesHBAs(cs, serviceProfileTemplates, new VhbaHelper(vsanFabricList));
        reconcileServiceProfileTemplatesVnics(cs, serviceProfileTemplates);
        reconcileServiceProfileTemplatesBootDefinitions(cs, serviceProfileTemplates);
        reconcileBootPolicies(cs, bootPolicies);
        reconcileVnicTemplates(cs, vnicTemplates);
        reconcileVhbaTemplates(cs, vhbaTemplates);
        Map<String, Set<String>> unpinnedVsans = getUnpinnedVSans(vsanList, fcInterfaceMap);
        reconcileUplinkPorts(cs, uplinkMap, fcInterfaceMap, unpinnedVsans);
        reconcileUplinkPortChannels(cs, portChannelMap, unpinnedVsans);
        reconcileVlans(cs, vlanList);
        associateComputeImageServer(cs);
        matchComputeBladesToHosts(cs);
        cs.setLastDiscoveryRunTime(Calendar.getInstance().getTimeInMillis());
        cs.setSuccessDiscoveryTime(Calendar.getInstance().getTimeInMillis());
        cs.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.name());
    } catch (ComputeSystemControllerException e) {
        cs.setLastDiscoveryStatusMessage(e.getMessage());
        throw ComputeSystemControllerException.exceptions.discoverFailed(cs.getId().toString(), e);
    } finally {
        _dbClient.persistObject(cs);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) ComputeBlade(com.emc.cloud.platform.ucs.out.model.ComputeBlade) FabricVsan(com.emc.cloud.platform.ucs.out.model.FabricVsan) FabricVlan(com.emc.cloud.platform.ucs.out.model.FabricVlan) URL(java.net.URL) FcPIo(com.emc.cloud.platform.ucs.out.model.FcPIo) VnicLanConnTempl(com.emc.cloud.platform.ucs.out.model.VnicLanConnTempl) SwVsan(com.emc.cloud.platform.ucs.out.model.SwVsan) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) LsbootPolicy(com.emc.cloud.platform.ucs.out.model.LsbootPolicy) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) VnicSanConnTempl(com.emc.cloud.platform.ucs.out.model.VnicSanConnTempl) SwFcSanPc(com.emc.cloud.platform.ucs.out.model.SwFcSanPc) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) MalformedURLException(java.net.MalformedURLException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) SwFcSanEp(com.emc.cloud.platform.ucs.out.model.SwFcSanEp)

Example 3 with SwFcSanPc

use of com.emc.cloud.platform.ucs.out.model.SwFcSanPc in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method reconcileUplinkPortChannels.

private void reconcileUplinkPortChannels(ComputeSystem cs, Map<String, SwFcSanPc> portChannelMap, Map<String, Set<String>> unpinnedVsans) {
    _log.info("Reconciling FIC uplink port channels");
    Map<String, ComputeFabricUplinkPortChannel> removePorts = new HashMap<String, ComputeFabricUplinkPortChannel>();
    Map<String, ComputeFabricUplinkPortChannel> updatePorts = new HashMap<String, ComputeFabricUplinkPortChannel>();
    Map<String, ComputeFabricUplinkPortChannel> addPorts = new HashMap<String, ComputeFabricUplinkPortChannel>();
    /*
         * Build a map with peerDns and discovered uplink ports.
         */
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeFabricUplinkPortConstraint(cs.getId()), uris);
    List<ComputeFabricUplinkPort> uplinkPorts = _dbClient.queryObject(ComputeFabricUplinkPort.class, uris, true);
    Map<String, ComputeFabricUplinkPort> peerDnUplinkPortMap = new HashMap<>();
    for (ComputeFabricUplinkPort port : uplinkPorts) {
        if (port.getPeerDn() != null) {
            String peerDn = port.getPeerDn();
            if (peerDn.endsWith("/")) {
                peerDn = peerDn.substring(0, peerDn.length() - 1);
            }
            peerDn = peerDn.substring(0, peerDn.lastIndexOf('/'));
            peerDnUplinkPortMap.put(peerDn, port);
        }
    }
    /*
         * Pulling uplink ports from the Database.
         */
    uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeUplinkPortChannelConstraint(cs.getId()), uris);
    List<ComputeFabricUplinkPortChannel> portsChannels = _dbClient.queryObject(ComputeFabricUplinkPortChannel.class, uris, true);
    for (ComputeFabricUplinkPortChannel pc : portsChannels) {
        removePorts.put(pc.getDn(), pc);
    }
    // discovered data
    for (SwFcSanPc pc : portChannelMap.values()) {
        ComputeFabricUplinkPortChannel cfup = removePorts.get(pc.getDn());
        ComputeFabricUplinkPort associatedPort = peerDnUplinkPortMap.get(pc.getPeerDn());
        /*
             * look for the port channel in the peerDn and uplink port map
             * If not found, the uplink port channel is considered inactive.
             * Ignore the object if new. Or simply delete during reconciliation.
             */
        if (associatedPort == null || pc.getPortId() == null || associatedPort.getWwpn() == null) {
            continue;
        }
        if (cfup != null) {
            updatePorts.put(pc.getDn(), cfup);
            removePorts.remove(pc.getDn());
            updateUplinkPortChannels(cfup, pc, unpinnedVsans, associatedPort);
        } else {
            cfup = new ComputeFabricUplinkPortChannel();
            addPorts.put(pc.getDn(), cfup);
            createUplinkPortChannels(cs, cfup, pc, unpinnedVsans, associatedPort);
        }
    }
    createDataObjects(new ArrayList<DataObject>(addPorts.values()));
    persistDataObjects(new ArrayList<DataObject>(updatePorts.values()));
    deleteDataObjects(new ArrayList<DataObject>(removePorts.values()));
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeFabricUplinkPort(com.emc.storageos.db.client.model.ComputeFabricUplinkPort) HashMap(java.util.HashMap) ComputeFabricUplinkPortChannel(com.emc.storageos.db.client.model.ComputeFabricUplinkPortChannel) SwFcSanPc(com.emc.cloud.platform.ucs.out.model.SwFcSanPc) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

SwFcSanPc (com.emc.cloud.platform.ucs.out.model.SwFcSanPc)3 HashMap (java.util.HashMap)2 ConfigResolveClass (com.emc.cloud.platform.ucs.in.model.ConfigResolveClass)1 ComputeBlade (com.emc.cloud.platform.ucs.out.model.ComputeBlade)1 FabricVlan (com.emc.cloud.platform.ucs.out.model.FabricVlan)1 FabricVsan (com.emc.cloud.platform.ucs.out.model.FabricVsan)1 FcPIo (com.emc.cloud.platform.ucs.out.model.FcPIo)1 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)1 LsbootPolicy (com.emc.cloud.platform.ucs.out.model.LsbootPolicy)1 SwFcSanEp (com.emc.cloud.platform.ucs.out.model.SwFcSanEp)1 SwVsan (com.emc.cloud.platform.ucs.out.model.SwVsan)1 VnicLanConnTempl (com.emc.cloud.platform.ucs.out.model.VnicLanConnTempl)1 VnicSanConnTempl (com.emc.cloud.platform.ucs.out.model.VnicSanConnTempl)1 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 ComputeFabricUplinkPort (com.emc.storageos.db.client.model.ComputeFabricUplinkPort)1 ComputeFabricUplinkPortChannel (com.emc.storageos.db.client.model.ComputeFabricUplinkPortChannel)1 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1