Ejemplo n.º 1
0
    def test_list_export_locations_replicated_share(self, version):
        """Test the export locations API changes between 2.46 and 2.47

        For API version <= 2.46, non-active replica export locations are
        included in the API response. They are not included in and beyond
        version 2.47.
        """
        # Setup data
        share = db_utils.create_share(
            replication_type=constants.REPLICATION_TYPE_READABLE,
            replica_state=constants.REPLICA_STATE_ACTIVE)
        active_replica_id = share.instance.id
        exports = [
            {
                'path': 'myshare.mydomain/active-replica-exp1',
                'is_admin_only': False
            },
            {
                'path': 'myshare.mydomain/active-replica-exp2',
                'is_admin_only': False
            },
        ]
        db.share_export_locations_update(self.ctxt['user'], active_replica_id,
                                         exports)

        # Replicas
        share_replica2 = db_utils.create_share_replica(
            share_id=share.id, replica_state=constants.REPLICA_STATE_IN_SYNC)
        share_replica3 = db_utils.create_share_replica(
            share_id=share.id,
            replica_state=constants.REPLICA_STATE_OUT_OF_SYNC)
        replica2_exports = [{
            'path': 'myshare.mydomain/insync-replica-exp',
            'is_admin_only': False
        }]
        replica3_exports = [{
            'path': 'myshare.mydomain/outofsync-replica-exp',
            'is_admin_only': False
        }]
        db.share_export_locations_update(self.ctxt['user'], share_replica2.id,
                                         replica2_exports)
        db.share_export_locations_update(self.ctxt['user'], share_replica3.id,
                                         replica3_exports)

        req = self._get_request(version=version)
        index_result = self.controller.index(req, share['id'])

        actual_paths = [el['path'] for el in index_result['export_locations']]
        if self.is_microversion_ge(version, '2.47'):
            self.assertEqual(2, len(index_result['export_locations']))
            self.assertNotIn('myshare.mydomain/insync-replica-exp',
                             actual_paths)
            self.assertNotIn('myshare.mydomain/outofsync-replica-exp',
                             actual_paths)
        else:
            self.assertEqual(4, len(index_result['export_locations']))
            self.assertIn('myshare.mydomain/insync-replica-exp', actual_paths)
            self.assertIn('myshare.mydomain/outofsync-replica-exp',
                          actual_paths)
    def test_list_export_locations_replicated_share(self, version):
        """Test the export locations API changes between 2.46 and 2.47

        For API version <= 2.46, non-active replica export locations are
        included in the API response. They are not included in and beyond
        version 2.47.
        """
        # Setup data
        share = db_utils.create_share(
            replication_type=constants.REPLICATION_TYPE_READABLE,
            replica_state=constants.REPLICA_STATE_ACTIVE)
        active_replica_id = share.instance.id
        exports = [
            {'path': 'myshare.mydomain/active-replica-exp1',
             'is_admin_only': False},
            {'path': 'myshare.mydomain/active-replica-exp2',
             'is_admin_only': False},
        ]
        db.share_export_locations_update(
            self.ctxt['user'], active_replica_id, exports)

        # Replicas
        share_replica2 = db_utils.create_share_replica(
            share_id=share.id, replica_state=constants.REPLICA_STATE_IN_SYNC)
        share_replica3 = db_utils.create_share_replica(
            share_id=share.id,
            replica_state=constants.REPLICA_STATE_OUT_OF_SYNC)
        replica2_exports = [
            {'path': 'myshare.mydomain/insync-replica-exp',
             'is_admin_only': False}
        ]
        replica3_exports = [
            {'path': 'myshare.mydomain/outofsync-replica-exp',
             'is_admin_only': False}
        ]
        db.share_export_locations_update(
            self.ctxt['user'], share_replica2.id, replica2_exports)
        db.share_export_locations_update(
            self.ctxt['user'], share_replica3.id, replica3_exports)

        req = self._get_request(version=version)
        index_result = self.controller.index(req, share['id'])

        actual_paths = [el['path'] for el in index_result['export_locations']]
        if self.is_microversion_ge(version, '2.47'):
            self.assertEqual(2, len(index_result['export_locations']))
            self.assertNotIn(
                'myshare.mydomain/insync-replica-exp', actual_paths)
            self.assertNotIn(
                'myshare.mydomain/outofsync-replica-exp', actual_paths)
        else:
            self.assertEqual(4, len(index_result['export_locations']))
            self.assertIn('myshare.mydomain/insync-replica-exp', actual_paths)
            self.assertIn(
                'myshare.mydomain/outofsync-replica-exp', actual_paths)
Ejemplo n.º 3
0
    def setUp(self):
        super(ShareReplicaExportLocationsAPITest, self).setUp()
        self.controller = (
            export_locations.ShareReplicaExportLocationController())
        self.resource_name = 'share_replica_export_location'
        self.ctxt = context.RequestContext('fake', 'fake')
        self.mock_policy_check = self.mock_object(policy, 'check_policy',
                                                  mock.Mock(return_value=True))
        self.share = db_utils.create_share(
            replication_type=constants.REPLICATION_TYPE_READABLE,
            replica_state=constants.REPLICA_STATE_ACTIVE)
        self.active_replica_id = self.share.instance.id
        self.req = self._get_request()
        exports = [
            {
                'path': 'myshare.mydomain/active-replica-exp1',
                'is_admin_only': False
            },
            {
                'path': 'myshare.mydomain/active-replica-exp2',
                'is_admin_only': False
            },
        ]
        db.share_export_locations_update(self.ctxt, self.active_replica_id,
                                         exports)

        # Replicas
        self.share_replica2 = db_utils.create_share_replica(
            share_id=self.share.id,
            replica_state=constants.REPLICA_STATE_IN_SYNC)
        self.share_replica3 = db_utils.create_share_replica(
            share_id=self.share.id,
            replica_state=constants.REPLICA_STATE_OUT_OF_SYNC)
        replica2_exports = [{
            'path': 'myshare.mydomain/insync-replica-exp',
            'is_admin_only': False
        }, {
            'path': 'myshare.mydomain/insync-replica-exp2',
            'is_admin_only': False
        }]
        replica3_exports = [{
            'path': 'myshare.mydomain/outofsync-replica-exp',
            'is_admin_only': False
        }, {
            'path': 'myshare.mydomain/outofsync-replica-exp2',
            'is_admin_only': False
        }]
        db.share_export_locations_update(self.ctxt, self.share_replica2.id,
                                         replica2_exports)
        db.share_export_locations_update(self.ctxt, self.share_replica3.id,
                                         replica3_exports)
Ejemplo n.º 4
0
 def setUp(self):
     super(ShareRpcAPITestCase, self).setUp()
     self.context = context.get_admin_context()
     share = db_utils.create_share(
         availability_zone=CONF.storage_availability_zone,
         status=constants.STATUS_AVAILABLE)
     snapshot = db_utils.create_snapshot(share_id=share['id'])
     share_replica = db_utils.create_share_replica(
         id='fake_replica',
         share_id='fake_share_id',
         host='fake_host',
     )
     share_server = db_utils.create_share_server()
     share_group = {'id': 'fake_share_group_id', 'host': 'fake_host'}
     share_group_snapshot = {'id': 'fake_share_group_id'}
     host = 'fake_host'
     self.fake_share = jsonutils.to_primitive(share)
     # mock out the getattr on the share db model object since jsonutils
     # doesn't know about those extra attributes to pull in
     self.fake_share['instance'] = jsonutils.to_primitive(share.instance)
     self.fake_share_replica = jsonutils.to_primitive(share_replica)
     self.fake_snapshot = jsonutils.to_primitive(snapshot)
     self.fake_snapshot['share_instance'] = jsonutils.to_primitive(
         snapshot.instance)
     self.fake_share_server = jsonutils.to_primitive(share_server)
     self.fake_share_group = jsonutils.to_primitive(share_group)
     self.fake_share_group_snapshot = jsonutils.to_primitive(
         share_group_snapshot)
     self.fake_host = jsonutils.to_primitive(host)
     self.ctxt = context.RequestContext('fake_user', 'fake_project')
     self.rpcapi = share_rpcapi.ShareAPI()
Ejemplo n.º 5
0
 def setUp(self):
     super(ShareRpcAPITestCase, self).setUp()
     self.context = context.get_admin_context()
     share = db_utils.create_share(
         availability_zone=CONF.storage_availability_zone,
         status=constants.STATUS_AVAILABLE)
     access = db_utils.create_access(share_id=share['id'])
     snapshot = db_utils.create_snapshot(share_id=share['id'])
     share_replica = db_utils.create_share_replica(
         id='fake_replica',
         share_id='fake_share_id',
     )
     share_server = db_utils.create_share_server()
     cg = {'id': 'fake_cg_id', 'host': 'fake_host'}
     cgsnapshot = {'id': 'fake_cg_id'}
     host = {'host': 'fake_host', 'capabilities': 1}
     self.fake_share = jsonutils.to_primitive(share)
     self.fake_share_replica = jsonutils.to_primitive(share_replica)
     self.fake_access = jsonutils.to_primitive(access)
     self.fake_snapshot = jsonutils.to_primitive(snapshot)
     self.fake_share_server = jsonutils.to_primitive(share_server)
     self.fake_cg = jsonutils.to_primitive(cg)
     self.fake_cgsnapshot = jsonutils.to_primitive(cgsnapshot)
     self.fake_host = jsonutils.to_primitive(host)
     self.ctxt = context.RequestContext('fake_user', 'fake_project')
     self.rpcapi = share_rpcapi.ShareAPI()
Ejemplo n.º 6
0
 def setUp(self):
     super(ShareRpcAPITestCase, self).setUp()
     self.context = context.get_admin_context()
     share = db_utils.create_share(
         availability_zone=CONF.storage_availability_zone,
         status=constants.STATUS_AVAILABLE
     )
     access = db_utils.create_access(share_id=share['id'])
     snapshot = db_utils.create_snapshot(share_id=share['id'])
     share_replica = db_utils.create_share_replica(
         id='fake_replica',
         share_id='fake_share_id',
         host='fake_host',
     )
     share_server = db_utils.create_share_server()
     cg = {'id': 'fake_cg_id', 'host': 'fake_host'}
     cgsnapshot = {'id': 'fake_cg_id'}
     host = {'host': 'fake_host', 'capabilities': 1}
     self.fake_share = jsonutils.to_primitive(share)
     # mock out the getattr on the share db model object since jsonutils
     # doesn't know about those extra attributes to pull in
     self.fake_share['instance'] = jsonutils.to_primitive(share.instance)
     self.fake_share_replica = jsonutils.to_primitive(share_replica)
     self.fake_access = jsonutils.to_primitive(access)
     self.fake_snapshot = jsonutils.to_primitive(snapshot)
     self.fake_share_server = jsonutils.to_primitive(share_server)
     self.fake_cg = jsonutils.to_primitive(cg)
     self.fake_cgsnapshot = jsonutils.to_primitive(cgsnapshot)
     self.fake_host = jsonutils.to_primitive(host)
     self.ctxt = context.RequestContext('fake_user', 'fake_project')
     self.rpcapi = share_rpcapi.ShareAPI()
    def setUp(self):
        super(ShareReplicaExportLocationsAPITest, self).setUp()
        self.controller = (
            export_locations.ShareReplicaExportLocationController())
        self.resource_name = 'share_replica_export_location'
        self.ctxt = context.RequestContext('fake', 'fake')
        self.mock_policy_check = self.mock_object(
            policy, 'check_policy', mock.Mock(return_value=True))
        self.share = db_utils.create_share(
            replication_type=constants.REPLICATION_TYPE_READABLE,
            replica_state=constants.REPLICA_STATE_ACTIVE)
        self.active_replica_id = self.share.instance.id
        self.req = self._get_request()
        exports = [
            {'path': 'myshare.mydomain/active-replica-exp1',
             'is_admin_only': False},
            {'path': 'myshare.mydomain/active-replica-exp2',
             'is_admin_only': False},
        ]
        db.share_export_locations_update(
            self.ctxt, self.active_replica_id, exports)

        # Replicas
        self.share_replica2 = db_utils.create_share_replica(
            share_id=self.share.id,
            replica_state=constants.REPLICA_STATE_IN_SYNC)
        self.share_replica3 = db_utils.create_share_replica(
            share_id=self.share.id,
            replica_state=constants.REPLICA_STATE_OUT_OF_SYNC)
        replica2_exports = [
            {'path': 'myshare.mydomain/insync-replica-exp',
             'is_admin_only': False},
            {'path': 'myshare.mydomain/insync-replica-exp2',
             'is_admin_only': False}
        ]
        replica3_exports = [
            {'path': 'myshare.mydomain/outofsync-replica-exp',
             'is_admin_only': False},
            {'path': 'myshare.mydomain/outofsync-replica-exp2',
             'is_admin_only': False}
        ]
        db.share_export_locations_update(
            self.ctxt, self.share_replica2.id, replica2_exports)
        db.share_export_locations_update(
            self.ctxt, self.share_replica3.id, replica3_exports)
Ejemplo n.º 8
0
    def _create_replica_get_req(self, **kwargs):
        if 'status' not in kwargs:
            kwargs['status'] = constants.STATUS_AVAILABLE
        if 'replica_state' not in kwargs:
            kwargs['replica_state'] = constants.REPLICA_STATE_IN_SYNC
        replica = db_utils.create_share_replica(**kwargs)
        req = fakes.HTTPRequest.blank('/v2/fake/share-replicas/%s/action' %
                                      replica['id'],
                                      version=self.api_version)
        req.method = 'POST'
        req.headers['content-type'] = 'application/json'
        req.headers['X-Openstack-Manila-Api-Version'] = self.api_version
        req.headers['X-Openstack-Manila-Api-Experimental'] = True

        return replica, req
Ejemplo n.º 9
0
    def _create_replica_get_req(self, **kwargs):
        if 'status' not in kwargs:
            kwargs['status'] = constants.STATUS_AVAILABLE
        if 'replica_state' not in kwargs:
            kwargs['replica_state'] = constants.REPLICA_STATE_IN_SYNC
        replica = db_utils.create_share_replica(**kwargs)
        req = fakes.HTTPRequest.blank(
            '/v2/fake/share-replicas/%s/action' % replica['id'],
            version=self.api_version)
        req.method = 'POST'
        req.headers['content-type'] = 'application/json'
        req.headers['X-Openstack-Manila-Api-Version'] = self.api_version
        req.headers['X-Openstack-Manila-Api-Experimental'] = True

        return replica, req
Ejemplo n.º 10
0
    def _create_replica_get_req(self, **kwargs):
        if 'status' not in kwargs:
            kwargs['status'] = constants.STATUS_AVAILABLE
        if 'replica_state' not in kwargs:
            kwargs['replica_state'] = constants.REPLICA_STATE_IN_SYNC
        replica = db_utils.create_share_replica(**kwargs)
        path = '/v2/fake/share-replicas/%s/action' % replica['id']
        microversion = kwargs.get('microversion', self.api_version)
        experimental = True
        if (api_version.APIVersionRequest(microversion) >=
                api_version.APIVersionRequest(GRADUATION_VERSION)):
            experimental = False
        req = fakes.HTTPRequest.blank(path,
                                      script_name=path,
                                      version=microversion,
                                      experimental=experimental)
        req.method = 'POST'
        req.headers['content-type'] = 'application/json'
        req.headers['X-Openstack-Manila-Api-Version'] = microversion
        req.headers['X-Openstack-Manila-Api-Experimental'] = True

        return replica, req