Пример #1
0
 def unmanage_share(self,
                    share_id,
                    version=LATEST_MICROVERSION,
                    url=None,
                    action_name=None,
                    body=None):
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = 'shares'
         else:
             url = 'os-share-unmanage'
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = 'action'
         else:
             action_name = 'unmanage'
     if body is None and utils.is_microversion_gt(version, "2.6"):
         body = json.dumps({'unmanage': {}})
     resp, body = self.post("%(url)s/%(share_id)s/%(action_name)s" % {
         'url': url,
         'share_id': share_id,
         'action_name': action_name
     },
                            body,
                            version=version)
     self.expected_success(202, resp.status)
     return body
Пример #2
0
 def manage_share(self,
                  service_host,
                  protocol,
                  export_path,
                  share_type_id,
                  name=None,
                  description=None,
                  is_public=False,
                  version=LATEST_MICROVERSION,
                  url=None):
     post_body = {
         "share": {
             "export_path": export_path,
             "service_host": service_host,
             "protocol": protocol,
             "share_type": share_type_id,
             "name": name,
             "description": description,
             "is_public": is_public,
         }
     }
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = 'shares/manage'
         else:
             url = 'os-share-manage'
     body = json.dumps(post_body)
     resp, body = self.post(url, body, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #3
0
    def reset_state(self,
                    s_id,
                    status="error",
                    s_type="shares",
                    headers=None,
                    version=LATEST_MICROVERSION,
                    action_name=None):
        """Resets the state of a share, snapshot, cg, or a cgsnapshot.

        status: available, error, creating, deleting, error_deleting
        s_type: shares, share_instances, snapshots, consistency-groups,
            cgsnapshots.
        """
        if action_name is None:
            if utils.is_microversion_gt(version, "2.6"):
                action_name = 'reset_status'
            else:
                action_name = 'os-reset_status'
        body = {action_name: {"status": status}}
        body = json.dumps(body)
        resp, body = self.post("%s/%s/action" % (s_type, s_id),
                               body,
                               headers=headers,
                               extra_headers=True,
                               version=version)
        self.expected_success(202, resp.status)
        return body
Пример #4
0
 def manage_share(
     self,
     service_host,
     protocol,
     export_path,
     share_type_id,
     name=None,
     description=None,
     is_public=False,
     version=LATEST_MICROVERSION,
     url=None,
 ):
     post_body = {
         "share": {
             "export_path": export_path,
             "service_host": service_host,
             "protocol": protocol,
             "share_type": share_type_id,
             "name": name,
             "description": description,
             "is_public": is_public,
         }
     }
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = "shares/manage"
         else:
             url = "os-share-manage"
     body = json.dumps(post_body)
     resp, body = self.post(url, body, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #5
0
 def migrate_share(self, share_id, host, version=LATEST_MICROVERSION, action_name=None):
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = "migrate_share"
         else:
             action_name = "os-migrate_share"
     post_body = {action_name: {"host": host}}
     body = json.dumps(post_body)
     return self.post("shares/%s/action" % share_id, body, headers=EXPERIMENTAL, extra_headers=True, version=version)
Пример #6
0
 def _verify_is_public_key_name(self, share_type, version):
     old_key_name = 'os-share-type-access:is_public'
     new_key_name = 'share_type_access:is_public'
     if utils.is_microversion_gt(version, "2.6"):
         self.assertIn(new_key_name, share_type)
         self.assertNotIn(old_key_name, share_type)
     else:
         self.assertIn(old_key_name, share_type)
         self.assertNotIn(new_key_name, share_type)
Пример #7
0
 def _verify_is_public_key_name(self, share_type, version):
     old_key_name = 'os-share-type-access:is_public'
     new_key_name = 'share_type_access:is_public'
     if utils.is_microversion_gt(version, "2.6"):
         self.assertIn(new_key_name, share_type)
         self.assertNotIn(old_key_name, share_type)
     else:
         self.assertIn(old_key_name, share_type)
         self.assertNotIn(new_key_name, share_type)
Пример #8
0
 def create_share_type(self, name, is_public=True, version=LATEST_MICROVERSION, **kwargs):
     if utils.is_microversion_gt(version, "2.6"):
         is_public_keyname = "share_type_access:is_public"
     else:
         is_public_keyname = "os-share-type-access:is_public"
     post_body = {"name": name, "extra_specs": kwargs.get("extra_specs"), is_public_keyname: is_public}
     post_body = json.dumps({"share_type": post_body})
     resp, body = self.post("types", post_body, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #9
0
 def list_availability_zones(self, url="availability-zones", version=LATEST_MICROVERSION):
     """Get list of availability zones."""
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = "availability-zones"
         else:
             url = "os-availability-zone"
     resp, body = self.get(url, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #10
0
 def shrink_share(self, share_id, new_size, version=LATEST_MICROVERSION, action_name=None):
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = "shrink"
         else:
             action_name = "os-shrink"
     post_body = {action_name: {"new_size": new_size}}
     body = json.dumps(post_body)
     resp, body = self.post("shares/%s/action" % share_id, body, version=version)
     self.expected_success(202, resp.status)
     return body
Пример #11
0
 def unmanage_share(self, share_id, version=LATEST_MICROVERSION, url=None, action_name=None, body=None):
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = "shares"
         else:
             url = "os-share-unmanage"
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = "action"
         else:
             action_name = "unmanage"
     if body is None and utils.is_microversion_gt(version, "2.6"):
         body = json.dumps({"unmanage": {}})
     resp, body = self.post(
         "%(url)s/%(share_id)s/%(action_name)s" % {"url": url, "share_id": share_id, "action_name": action_name},
         body,
         version=version,
     )
     self.expected_success(202, resp.status)
     return body
Пример #12
0
 def list_access_to_share_type(self, share_type_id, version=LATEST_MICROVERSION, action_name=None):
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = "share_type_access"
         else:
             action_name = "os-share-type-access"
     url = "types/%(st_id)s/%(action_name)s" % {"st_id": share_type_id, "action_name": action_name}
     resp, body = self.get(url, version=version)
     # [{"share_type_id": "%st_id%", "project_id": "%project_id%"}, ]
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #13
0
 def unmanage_share(self, share_id, version=LATEST_MICROVERSION, url=None,
                    action_name=None, body=None):
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = 'shares'
         else:
             url = 'os-share-unmanage'
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = 'action'
         else:
             action_name = 'unmanage'
     if body is None and utils.is_microversion_gt(version, "2.6"):
         body = json.dumps({'unmanage': {}})
     resp, body = self.post(
         "%(url)s/%(share_id)s/%(action_name)s" % {
             'url': url, 'share_id': share_id, 'action_name': action_name},
         body,
         version=version)
     self.expected_success(202, resp.status)
     return body
Пример #14
0
 def list_availability_zones(self,
                             url='availability-zones',
                             version=LATEST_MICROVERSION):
     """Get list of availability zones."""
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = 'availability-zones'
         else:
             url = 'os-availability-zone'
     resp, body = self.get(url, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #15
0
 def list_services(self, params=None, url=None, version=LATEST_MICROVERSION):
     """List services."""
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = "services"
         else:
             url = "os-services"
     if params:
         url += "?%s" % urlparse.urlencode(params)
     resp, body = self.get(url, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #16
0
 def create_share_type(self, name, is_public=True,
                       version=LATEST_MICROVERSION, **kwargs):
     if utils.is_microversion_gt(version, "2.6"):
         is_public_keyname = 'share_type_access:is_public'
     else:
         is_public_keyname = 'os-share-type-access:is_public'
     post_body = {
         'name': name,
         'extra_specs': kwargs.get('extra_specs'),
         is_public_keyname: is_public,
     }
     post_body = json.dumps({'share_type': post_body})
     resp, body = self.post('types', post_body, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #17
0
 def list_services(self,
                   params=None,
                   url=None,
                   version=LATEST_MICROVERSION):
     """List services."""
     if url is None:
         if utils.is_microversion_gt(version, "2.6"):
             url = 'services'
         else:
             url = 'os-services'
     if params:
         url += '?%s' % urlparse.urlencode(params)
     resp, body = self.get(url, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #18
0
    def force_delete(self, s_id, s_type="shares", headers=None, version=LATEST_MICROVERSION, action_name=None):
        """Force delete share or snapshot.

        s_type: shares, snapshots
        """
        if action_name is None:
            if utils.is_microversion_gt(version, "2.6"):
                action_name = "force_delete"
            else:
                action_name = "os-force_delete"
        body = {action_name: None}
        body = json.dumps(body)
        resp, body = self.post(
            "%s/%s/action" % (s_type, s_id), body, headers=headers, extra_headers=True, version=version
        )
        self.expected_success(202, resp.status)
        return body
Пример #19
0
 def list_access_to_share_type(self,
                               share_type_id,
                               version=LATEST_MICROVERSION,
                               action_name=None):
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = 'share_type_access'
         else:
             action_name = 'os-share-type-access'
     url = 'types/%(st_id)s/%(action_name)s' % {
         'st_id': share_type_id,
         'action_name': action_name
     }
     resp, body = self.get(url, version=version)
     # [{"share_type_id": "%st_id%", "project_id": "%project_id%"}, ]
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #20
0
 def create_share_type(self,
                       name,
                       is_public=True,
                       version=LATEST_MICROVERSION,
                       **kwargs):
     if utils.is_microversion_gt(version, "2.6"):
         is_public_keyname = 'share_type_access:is_public'
     else:
         is_public_keyname = 'os-share-type-access:is_public'
     post_body = {
         'name': name,
         'extra_specs': kwargs.get('extra_specs'),
         is_public_keyname: is_public,
     }
     post_body = json.dumps({'share_type': post_body})
     resp, body = self.post('types', post_body, version=version)
     self.expected_success(200, resp.status)
     return self._parse_resp(body)
Пример #21
0
    def reset_state(self, s_id, status="error", s_type="shares",
                    headers=None, version=LATEST_MICROVERSION,
                    action_name=None):
        """Resets the state of a share, snapshot, cg, or a cgsnapshot.

        status: available, error, creating, deleting, error_deleting
        s_type: shares, share_instances, snapshots, consistency-groups,
            cgsnapshots.
        """
        if action_name is None:
            if utils.is_microversion_gt(version, "2.6"):
                action_name = 'reset_status'
            else:
                action_name = 'os-reset_status'
        body = {action_name: {"status": status}}
        body = json.dumps(body)
        resp, body = self.post("%s/%s/action" % (s_type, s_id), body,
                               headers=headers, extra_headers=True,
                               version=version)
        self.expected_success(202, resp.status)
        return body
Пример #22
0
 def shrink_share(self,
                  share_id,
                  new_size,
                  version=LATEST_MICROVERSION,
                  action_name=None):
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = 'shrink'
         else:
             action_name = 'os-shrink'
     post_body = {
         action_name: {
             "new_size": new_size,
         }
     }
     body = json.dumps(post_body)
     resp, body = self.post("shares/%s/action" % share_id,
                            body,
                            version=version)
     self.expected_success(202, resp.status)
     return body
Пример #23
0
 def migrate_share(self,
                   share_id,
                   host,
                   version=LATEST_MICROVERSION,
                   action_name=None):
     if action_name is None:
         if utils.is_microversion_gt(version, "2.6"):
             action_name = 'migrate_share'
         else:
             action_name = 'os-migrate_share'
     post_body = {
         action_name: {
             'host': host,
         }
     }
     body = json.dumps(post_body)
     return self.post('shares/%s/action' % share_id,
                      body,
                      headers=EXPERIMENTAL,
                      extra_headers=True,
                      version=version)
Пример #24
0
    def force_delete(self,
                     s_id,
                     s_type="shares",
                     headers=None,
                     version=LATEST_MICROVERSION,
                     action_name=None):
        """Force delete share or snapshot.

        s_type: shares, snapshots
        """
        if action_name is None:
            if utils.is_microversion_gt(version, "2.6"):
                action_name = 'force_delete'
            else:
                action_name = 'os-force_delete'
        body = {action_name: None}
        body = json.dumps(body)
        resp, body = self.post("%s/%s/action" % (s_type, s_id),
                               body,
                               headers=headers,
                               extra_headers=True,
                               version=version)
        self.expected_success(202, resp.status)
        return body
Пример #25
0
    def test_share_server_migration_complete(self, new_share_network):
        """Test the share server migration complete."""
        share_network_id = self.provide_share_network(self.shares_v2_client,
                                                      self.networks_client)
        dest_share_network_id = share_network_id
        if new_share_network:
            src_share_network = self.shares_v2_client.get_share_network(
                share_network_id)['share_network']
            share_net_info = (
                utils.share_network_get_default_subnet(src_share_network))
            dest_share_network_id = self.create_share_network(
                neutron_net_id=share_net_info['neutron_net_id'],
                neutron_subnet_id=share_net_info['neutron_subnet_id'],
                cleanup_in_class=False)['id']

        share = self.create_share(share_protocol=self.protocol,
                                  share_type_id=self.share_type['id'],
                                  share_network_id=share_network_id,
                                  cleanup_in_class=False)
        share = self.shares_v2_client.get_share(share['id'])['share']

        # Initial migration setup.
        share, src_server_id, dest_host, snapshot_id = self._setup_migration(
            share)

        preserve_snapshots = True if snapshot_id else False

        # Start share server migration.
        self.shares_v2_client.share_server_migration_start(
            src_server_id,
            dest_host,
            new_share_network_id=dest_share_network_id,
            preserve_snapshots=preserve_snapshots)

        expected_state = constants.TASK_STATE_MIGRATION_DRIVER_PHASE1_DONE
        waiters.wait_for_resource_status(self.shares_v2_client,
                                         src_server_id,
                                         expected_state,
                                         resource_name='share_server',
                                         status_attr='task_state')
        # Get for the destination share server.
        dest_server_id = self._get_share_server_destination_for_migration(
            src_server_id)

        dest_server = self.shares_v2_client.show_share_server(
            dest_server_id)['share_server']
        self.assertEqual(dest_host, dest_server['host'])
        self.assertEqual(dest_share_network_id,
                         dest_server['share_network_id'])

        expected_status = constants.STATUS_SERVER_MIGRATING
        self._validate_state_of_resources(share, expected_status, snapshot_id)

        # Share server migration complete.
        self.shares_v2_client.share_server_migration_complete(src_server_id)

        # It's necessary wait for the destination server went to active status.
        expected_status = constants.SERVER_STATE_ACTIVE
        waiters.wait_for_resource_status(self.shares_v2_client,
                                         dest_server_id,
                                         expected_status,
                                         resource_name='share_server')

        # Validate the share server migration complete.
        share = self.shares_v2_client.get_share(share['id'])['share']
        self._validate_share_server_migration_complete(
            share,
            dest_host,
            dest_server_id,
            snapshot_id=snapshot_id,
            share_network_id=dest_share_network_id)

        # Source share server is only deleted after Wallaby release (2.63).
        if utils.is_microversion_gt(CONF.share.max_api_microversion, "2.63"):
            self.admin_shares_client.wait_for_resource_deletion(
                server_id=src_server_id)
Пример #26
0
 def _get_quotas_url(self, version):
     if utils.is_microversion_gt(version, "2.6"):
         return 'quota-sets'
     return 'os-quota-sets'
Пример #27
0
 def _get_access_action_name(self, version, action):
     if utils.is_microversion_gt(version, "2.6"):
         return action.split('os-')[-1]
     return action
Пример #28
0
 def _get_access_action_name(self, version):
     if utils.is_microversion_gt(version, "2.6"):
         return 'allow_access'
     return 'os-allow_access'
Пример #29
0
 def _get_access_action_name(self, version, action):
     if utils.is_microversion_gt(version, "2.6"):
         return action.split('os-')[-1]
     return action
Пример #30
0
 def _get_access_action_name(self, version):
     if utils.is_microversion_gt(version, "2.6"):
         return 'allow_access'
     return 'os-allow_access'
Пример #31
0
 def _get_quotas_url(self, version):
     if utils.is_microversion_gt(version, "2.6"):
         return 'quota-sets'
     return 'os-quota-sets'