Exemplo n.º 1
0
    def _check_input(self):
        """Check the input values."""
        if not DASD_DEVICE_NUMBER.match(self._device_number):
            raise StorageDiscoveryError("Incorrect format of the given device number.")

        if not ZFCP_WWPN_NUMBER.match(self._wwpn):
            raise StorageDiscoveryError("Incorrect format of the given WWPN number.")

        if not ZFCP_LUN_NUMBER.match(self._lun):
            raise StorageDiscoveryError("Incorrect format of the given LUN number.")
Exemplo n.º 2
0
    def _discover_device(self):
        """Discover the device."""
        try:
            error_message = fcoe.add_san(self._nic, self._dcb, self._auto_vlan)
        except (IOError, OSError) as e:
            raise StorageDiscoveryError(str(e)) from e

        if error_message:
            raise StorageDiscoveryError(error_message)

        fcoe.added_nics.append(self._nic)
Exemplo n.º 3
0
    def _discover_device(self):
        """Discover the device."""
        # pylint: disable=try-except-raise
        try:
            online = blockdev.s390.dasd_online(self._device_number)
        except blockdev.S390Error as e:
            raise StorageDiscoveryError(str(e))

        if not online:
            raise StorageDiscoveryError(
                "The device could not be switched online. It may not exist.")
Exemplo n.º 4
0
 def _discover_device(self):
     """Discover the device."""
     # pylint: disable=try-except-raise
     try:
         blockdev.s390.dasd_online(self._device_number)
     except blockdev.S390Error as e:
         raise StorageDiscoveryError(str(e))
Exemplo n.º 5
0
 def _sanitize_input(self):
     """Sanitize the input values."""
     try:
         self._device_number = blockdev.s390.sanitize_dev_input(self._device_number)
         self._wwpn = blockdev.s390.zfcp_sanitize_wwpn_input(self._wwpn)
         self._lun = blockdev.s390.zfcp_sanitize_lun_input(self._lun)
     except (blockdev.S390Error, ValueError) as err:
         raise StorageDiscoveryError(str(err))
Exemplo n.º 6
0
 def _sanitize_input(self):
     """Sanitize the input values."""
     # pylint: disable=try-except-raise
     try:
         self._device_number = blockdev.s390.sanitize_dev_input(
             self._device_number)
     except blockdev.S390Error as e:
         raise StorageDiscoveryError(str(e))
Exemplo n.º 7
0
    def _discover_nodes(self, portal, credentials):
        """Discover iSCSI nodes.

        :param portal: the portal information
        :param credentials: the iSCSI credentials
        :return: a list of discovered nodes
        """
        try:
            nodes = iscsi.discover(ipaddr=portal.ip_address,
                                   username=credentials.username,
                                   password=credentials.password,
                                   r_username=credentials.reverse_username,
                                   r_password=credentials.reverse_password)
        except SafeDBusError as e:
            raise StorageDiscoveryError(str(e).split(':')[-1])

        if not nodes:
            raise StorageDiscoveryError("No nodes discovered.")

        return nodes
Exemplo n.º 8
0
    def _log_into_node(self, node_info, credentials):
        """Log into the node.

        :param node_info: an instance of NodeInfo
        :param credentials: an instance of Credentials
        """
        rc, msg = iscsi.log_into_node(node=node_info,
                                      username=credentials.username,
                                      password=credentials.password,
                                      r_username=credentials.reverse_username,
                                      r_password=credentials.reverse_password)

        if not rc:
            raise StorageDiscoveryError(msg)
Exemplo n.º 9
0
    def _update_interfaces(self, interfaces_mode):
        """Update the interfaces according to requested mode.

        :param interfaces_mode: required mode specified by IscsiInterfacesMode
        """
        if interfaces_mode == IscsiInterfacesMode.DEFAULT and iscsi.mode in (
                "default", "none"):
            if iscsi.ifaces:
                iscsi.delete_interfaces()
        elif interfaces_mode == IscsiInterfacesMode.IFACENAME and iscsi.mode in (
                "bind", "none"):
            network_proxy = NETWORK.get_proxy()
            activated = set(network_proxy.GetActivatedInterfaces())
            created = set(iscsi.ifaces.values())
            iscsi.create_interfaces(activated - created)
        else:
            raise StorageDiscoveryError(
                'Requiring "{}" mode while "{}" is already set.'.format(
                    interfaces_mode, iscsi.mode))
Exemplo n.º 10
0
    def _get_node_info(self, portal, node):
        """Get the node info.

        :param portal: an instance of Portal
        :param node: an instance of Node
        :return: an instance of NodeInfo or None
        """
        target_info = TargetInfo(portal.ip_address, portal.port)

        portal_nodes = [
            info.node
            for info in iscsi.discovered_targets.get(target_info, [])
            if not info.logged_in
        ]

        for info in portal_nodes:
            if info.name == node.name and info.address == node.address and \
               info.port == int(node.port) and info.iface == node.iface:
                return info

        raise StorageDiscoveryError("Unknown node.")
Exemplo n.º 11
0
 def _discover_device(self):
     """Discover the device."""
     try:
         zfcp.add_fcp(self._device_number, self._wwpn, self._lun)
     except ValueError as e:
         raise StorageDiscoveryError(str(e))