Search in sources :

Example 1 with WindowsSystemWinRM

use of com.iwave.ext.windows.WindowsSystemWinRM in project coprhd-controller by CoprHD.

the class WindowsHostDiscoveryAdapter method setNativeGuid.

@Override
protected void setNativeGuid(Host host) {
    WindowsSystemWinRM windows = createWindowsSystem(host);
    try {
        NetworkAdapter adapter = getPrimaryNetworkAdapter(windows.listNetworkAdapters());
        if (adapter != null && !host.getNativeGuid().equalsIgnoreCase(adapter.getMacAddress())) {
            checkDuplicateHost(host, adapter.getMacAddress());
            info("Setting nativeGuid for " + host.getId() + " as " + adapter.getMacAddress());
            host.setNativeGuid(adapter.getMacAddress());
            save(host);
        }
    } catch (WinRMException e) {
        throw new RuntimeException(e);
    }
}
Also used : WindowsSystemWinRM(com.iwave.ext.windows.WindowsSystemWinRM) WinRMException(com.iwave.ext.windows.winrm.WinRMException)

Example 2 with WindowsSystemWinRM

use of com.iwave.ext.windows.WindowsSystemWinRM in project coprhd-controller by CoprHD.

the class ExtendDriveHelper method createHelpers.

public static List<ExtendDriveHelper> createHelpers(URI hostId, List<WindowsSystemWinRM> windowsSystems, long volumeSizeInBytes) {
    List<ExtendDriveHelper> helpers = Lists.newArrayList();
    for (WindowsSystemWinRM windowsSystem : windowsSystems) {
        WindowsSupport windowsSupport = new WindowsSupport(windowsSystem);
        ExtendDriveHelper extendDriveHelper = new ExtendDriveHelper(hostId, windowsSupport, volumeSizeInBytes);
        BindingUtils.bind(extendDriveHelper, ExecutionUtils.currentContext().getParameters());
        helpers.add(extendDriveHelper);
    }
    return helpers;
}
Also used : WindowsSystemWinRM(com.iwave.ext.windows.WindowsSystemWinRM)

Example 3 with WindowsSystemWinRM

use of com.iwave.ext.windows.WindowsSystemWinRM in project coprhd-controller by CoprHD.

the class WindowsUtils method createWindowsSystem.

public static WindowsSystemWinRM createWindowsSystem(Host host, Cluster cluster) {
    boolean useSsl = host.getUseSSL() != null ? host.getUseSSL().booleanValue() : DEFAULT_USE_SSL;
    int portNumber = host.getPortNumber() != null ? host.getPortNumber().intValue() : DEFAULT_PORT_NUMBER;
    WindowsSystemWinRM windowsSystem = new WindowsSystemWinRM(host.getHostName(), portNumber, useSsl, host.getUsername(), host.getPassword());
    windowsSystem.setHostId(host.getId());
    if (cluster != null) {
        windowsSystem.setClusterId(cluster.getId());
    }
    return windowsSystem;
}
Also used : WindowsSystemWinRM(com.iwave.ext.windows.WindowsSystemWinRM)

Example 4 with WindowsSystemWinRM

use of com.iwave.ext.windows.WindowsSystemWinRM in project coprhd-controller by CoprHD.

the class WindowsHostDiscoveryAdapter method discoverIpInterfaces.

@Override
protected void discoverIpInterfaces(Host host, List<IpInterface> oldIpInterfaces) {
    WindowsSystemWinRM windows = createWindowsSystem(host);
    try {
        for (NetworkAdapter adapter : windows.listNetworkAdapters()) {
            if (StringUtils.isNotBlank(adapter.getIpAddress())) {
                IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, adapter.getIpAddress());
                discoverIp4Interface(host, ipInterface, adapter);
            }
            if (StringUtils.isNotBlank(adapter.getIp6Address())) {
                IpInterface ipInterface = getOrCreateIpInterface(oldIpInterfaces, adapter.getIp6Address());
                discoverIp6Interface(host, ipInterface, adapter);
            }
        }
    } catch (WinRMException e) {
        warn(e, "Error while retrieving IP interfaces: %s", e.getMessage());
        oldIpInterfaces.clear();
    }
}
Also used : IpInterface(com.emc.storageos.db.client.model.IpInterface) WindowsSystemWinRM(com.iwave.ext.windows.WindowsSystemWinRM) WinRMException(com.iwave.ext.windows.winrm.WinRMException)

Example 5 with WindowsSystemWinRM

use of com.iwave.ext.windows.WindowsSystemWinRM in project coprhd-controller by CoprHD.

the class WindowsHostDiscoveryAdapter method discoverInitiators.

@Override
protected void discoverInitiators(Host host, List<Initiator> oldInitiators, HostStateChange changes) {
    WindowsSystemWinRM windows = createWindowsSystem(host);
    List<Initiator> addedInitiators = new ArrayList<Initiator>();
    try {
        for (FibreChannelHBA hba : windows.listFibreChannelHBAs()) {
            Initiator initiator;
            if (findInitiatorByPort(oldInitiators, hba.getPortWWN()) == null) {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, hba.getPortWWN());
                addedInitiators.add(initiator);
            } else {
                initiator = getOrCreateInitiator(host.getId(), oldInitiators, hba.getPortWWN());
            }
            discoverFCInitiator(host, initiator, hba);
        }
    } catch (WinRMSoapException e) {
        info("Could not retrieve fibre channel HBAs: %s", e.getMessage());
        clearInitiators(oldInitiators, Protocol.FC.name());
    } catch (WinRMException e) {
        warn(e, "Error while retrieving fibre channel HBAs: %s", e.getMessage());
        clearInitiators(oldInitiators, Protocol.FC.name());
    }
    try {
        for (String iqn : windows.listIScsiInitiators()) {
            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 (WinRMSoapException e) {
        info("Could not retrieve iSCSI interfaces: %s", e.getMessage());
        clearInitiators(oldInitiators, Protocol.iSCSI.name());
    } catch (WinRMException e) {
        warn(e, "Error while retrieving iSCSI interfaces: %s", e.getMessage());
        clearInitiators(oldInitiators, Protocol.iSCSI.name());
    }
    // 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 : WindowsSystemWinRM(com.iwave.ext.windows.WindowsSystemWinRM) WinRMException(com.iwave.ext.windows.winrm.WinRMException) Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) WinRMSoapException(com.iwave.ext.windows.winrm.WinRMSoapException) URI(java.net.URI)

Aggregations

WindowsSystemWinRM (com.iwave.ext.windows.WindowsSystemWinRM)10 WinRMException (com.iwave.ext.windows.winrm.WinRMException)4 URI (java.net.URI)3 WinRMTarget (com.iwave.ext.windows.winrm.WinRMTarget)2 ArrayList (java.util.ArrayList)2 AuthnProvider (com.emc.storageos.db.client.model.AuthnProvider)1 HostType (com.emc.storageos.db.client.model.Host.HostType)1 Initiator (com.emc.storageos.db.client.model.Initiator)1 IpInterface (com.emc.storageos.db.client.model.IpInterface)1 WinRMSoapException (com.iwave.ext.windows.winrm.WinRMSoapException)1 List (java.util.List)1