Exemplo n.º 1
0
    def _assert_response_ok(self, tree):
        """Parses the XML returned by the device to check the return code.

        Raises a DotHillRequestError error if the return code is not 0
        or if the return code is None.
        """
        # Get the return code for the operation, raising an exception
        # if it is not present.
        return_code = tree.findtext(".//PROPERTY[@name='return-code']")
        if not return_code:
            raise exception.DotHillRequestError(message="No status found")

        ###  Change to Fix Copy Conflict Error  - START ###
        LOG.debug("Status Code from SAN %s", return_code)

        # If no error occurred, just return.

        #if return_code == '0':
        #    return

        if return_code == '0' or return_code == '-3529':
            return

        ###  END  ###

        # Format a message for the status code.
        msg = "%s (%s)" % (tree.findtext(".//PROPERTY[@name='response']"),
                           return_code)

        raise exception.DotHillRequestError(message=msg)
Exemplo n.º 2
0
    def _assert_response_ok(self, tree):
        """Parses the XML returned by the device to check the return code.

        Raises a DotHillRequestError error if the return code is not 0.
        """
        return_code = tree.findtext(".//PROPERTY[@name='return-code']")
        if return_code and return_code != '0':
            raise exception.DotHillRequestError(
                message=tree.findtext(".//PROPERTY[@name='response']"))
        elif not return_code:
            raise exception.DotHillRequestError(message="No status found")
    def map_volume(self, volume_name, connector, connector_element):
        if connector_element == 'wwpns':
            lun = self._get_first_available_lun_for_host(connector['wwpns'][0])
            host = ",".join(connector['wwpns'])
        else:
            host = connector['initiator']
            host_status = self._check_host(host)
            if host_status != 0:
                hostname = self._safe_hostname(connector['host'])
                try:
                    self._request("/create/host", hostname, id=host)
                except exception.DotHillRequestError as e:
                    # -10058: The host identifier or nickname is already in use
                    if '(-10058)' in e.msg:
                        LOG.error(
                            "While trying to create host nickname"
                            " %(nickname)s: %(error_msg)s", {
                                'nickname': hostname,
                                'error_msg': e.msg
                            })
                    else:
                        raise
            lun = self._get_first_available_lun_for_host(host)

        while lun < 255:
            try:
                self._request("/map/volume",
                              volume_name,
                              lun=str(lun),
                              host=host,
                              access="rw")
                return lun
            except exception.DotHillRequestError as e:
                # -3177 => "The specified LUN overlaps a previously defined LUN
                if '(-3177)' in e.msg:
                    LOG.info(
                        "Unable to map volume"
                        " %(volume_name)s to lun %(lun)d:"
                        " %(reason)s", {
                            'volume_name': volume_name,
                            'lun': lun,
                            'reason': e.msg
                        })
                    lun = self._get_next_available_lun_for_host(host,
                                                                after=lun)
                    continue
                raise
            except Exception as e:
                LOG.error(
                    "Error while mapping volume"
                    " %(volume_name)s to lun %(lun)d:", {
                        'volume_name': volume_name,
                        'lun': lun
                    }, e)
                raise

        raise exception.DotHillRequestError(
            message=_("Failed to find a free LUN for host %s") % host)
Exemplo n.º 4
0
 def test_delete_volume(self, mock_delete):
     not_found_e = exception.DotHillRequestError(
         'The volume was not found on this system.')
     mock_delete.side_effect = [not_found_e, exception.DotHillRequestError,
                                None]
     self.assertEqual(None, self.common.delete_volume(test_volume))
     self.assertRaises(exception.Invalid, self.common.delete_volume,
                       test_volume)
     self.assertEqual(None, self.common.delete_volume(test_volume))
     mock_delete.assert_called_with(encoded_volid)
Exemplo n.º 5
0
    def test_delete_snapshot(self, mock_delete):
        not_found_e = exception.DotHillRequestError(
            'The volume was not found on this system.')
        mock_delete.side_effect = [not_found_e, exception.DotHillRequestError,
                                   None]

        self.assertIsNone(self.common.delete_snapshot(test_snap))
        self.assertRaises(exception.Invalid, self.common.delete_snapshot,
                          test_snap)
        self.assertIsNone(self.common.delete_snapshot(test_snap))
        mock_delete.assert_called_with('sqqqqqqqqqqqqqqqqqqq')
    def _assert_response_ok(self, tree):
        """Parses the XML returned by the device to check the return code.

        Raises a DotHillRequestError error if the return code is not 0
        or if the return code is None.
        """
        # Get the return code for the operation, raising an exception
        # if it is not present.
        return_code = tree.findtext(".//PROPERTY[@name='return-code']")
        if not return_code:
            raise exception.DotHillRequestError(message="No status found")

        # If no error occurred, just return.
        if return_code == '0':
            return

        # Format a message for the status code.
        msg = "%s (%s)" % (tree.findtext(".//PROPERTY[@name='response']"),
                           return_code)

        raise exception.DotHillRequestError(message=msg)
 def _get_next_available_lun_for_host(self, host, after=0):
     # host can be a comma-separated list of WWPNs; we only use the first.
     firsthost = host.split(',')[0]
     LOG.debug('get_next_available_lun: host=%s, firsthost=%s, after=%d',
               host, firsthost, after)
     if after == 0:
         return self._get_first_available_lun_for_host(firsthost)
     luns = self._luns_in_use_by_host[firsthost]
     lun = after + 1
     while lun < 1024:
         LOG.debug('get_next_available_lun: host=%s, trying lun %d',
                   firsthost, lun)
         if lun not in luns:
             LOG.debug('get_next_available_lun: host=%s, RETURNING lun %d',
                       firsthost, lun)
             return lun
         lun += 1
     raise exception.DotHillRequestError(
         message=_("No LUNs available for mapping to host %s.") % host)