Fix deprecation warnings
Fix the following deprecation warnings. * DeprecationWarning: Using the 'user' argument is deprecated in version '2.18' and will be removed in version '3.0', please use the 'user_id' argument instead * DeprecationWarning: Property 'user' has moved to 'user_id' in version '2.6' and will be removed in version '3.0' Change-Id: I18802ae1e2318eae3c62a26459178b259c728ac4 Signed-off-by: Takashi Natsume <takanattie@gmail.com>
This commit is contained in:
parent
346e161220
commit
8c94e21196
@ -102,7 +102,7 @@ def nova_client(context, region_name=None, password=None):
|
||||
)
|
||||
|
||||
client = Client(CONF.nova_client_version,
|
||||
username=context.user,
|
||||
username=context.user_id,
|
||||
password=password,
|
||||
endpoint_override=url,
|
||||
project_id=context.project_id,
|
||||
@ -141,7 +141,7 @@ def cinder_client(context, region_name=None):
|
||||
endpoint_type=CONF.cinder_endpoint_type
|
||||
)
|
||||
|
||||
client = CinderClient.Client(context.user, context.auth_token,
|
||||
client = CinderClient.Client(context.user_id, context.auth_token,
|
||||
project_id=context.project_id,
|
||||
auth_url=CONF.service_credentials.auth_url,
|
||||
insecure=CONF.cinder_api_insecure)
|
||||
|
@ -115,7 +115,7 @@ class TroveBaseTraits(object):
|
||||
'state_description': instance.status.lower(),
|
||||
'state': instance.status.lower(),
|
||||
'tenant_id': instance.tenant_id,
|
||||
'user_id': instance.context.user,
|
||||
'user_id': instance.context.user_id,
|
||||
})
|
||||
|
||||
self.payload.update(kwargs)
|
||||
|
@ -549,7 +549,7 @@ class ContextMiddleware(base_wsgi.Middleware):
|
||||
limits = self._extract_limits(request.params)
|
||||
context = rd_context.TroveContext(auth_token=auth_token,
|
||||
project_id=tenant_id,
|
||||
user=user_id,
|
||||
user_id=user_id,
|
||||
is_admin=is_admin,
|
||||
limit=limits.get('limit'),
|
||||
marker=limits.get('marker'),
|
||||
|
@ -139,5 +139,5 @@ class RootHistory(object):
|
||||
history = cls.load(context, instance_id)
|
||||
if history is not None:
|
||||
return history
|
||||
history = RootHistory(instance_id, context.user)
|
||||
history = RootHistory(instance_id, context.user_id)
|
||||
return history.save()
|
||||
|
@ -44,7 +44,7 @@ class Manager(periodic_task.PeriodicTasks):
|
||||
def __init__(self):
|
||||
super(Manager, self).__init__(CONF)
|
||||
self.admin_context = TroveContext(
|
||||
user=CONF.service_credentials.username,
|
||||
user_id=CONF.service_credentials.username,
|
||||
project_id=CONF.service_credentials.project_id,
|
||||
user_domain_name=CONF.service_credentials.user_domain_name)
|
||||
if CONF.exists_notification_transformer:
|
||||
|
@ -116,7 +116,7 @@ class NotifyMixin(object):
|
||||
'state_description': self.status,
|
||||
'state': self.status,
|
||||
'tenant_id': self.tenant_id,
|
||||
'user_id': self.context.user,
|
||||
'user_id': self.context.user_id,
|
||||
}
|
||||
|
||||
if CONF.get(self.datastore_version.manager).volume_support:
|
||||
@ -980,7 +980,7 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
|
||||
nics, files={}, scheduler_hints=None):
|
||||
userdata = self.prepare_userdata(datastore_manager)
|
||||
metadata = {'trove_project_id': self.tenant_id,
|
||||
'trove_user_id': self.context.user,
|
||||
'trove_user_id': self.context.user_id,
|
||||
'trove_instance_id': self.id}
|
||||
bdmap_v2 = block_device_mapping_v2
|
||||
config_drive = CONF.use_nova_server_config_drive
|
||||
|
@ -24,7 +24,7 @@ from trove.tests.unittests import trove_testtools
|
||||
class TestTroveContext(trove_testtools.TestCase):
|
||||
def test_create_with_extended_args(self):
|
||||
expected_service_catalog = {'key': 'value'}
|
||||
ctx = context.TroveContext(user="test_user_id",
|
||||
ctx = context.TroveContext(user_id="test_user_id",
|
||||
request_id="test_req_id",
|
||||
limit="500",
|
||||
marker="x",
|
||||
@ -34,23 +34,23 @@ class TestTroveContext(trove_testtools.TestCase):
|
||||
self.assertThat(ctx.service_catalog, Equals(expected_service_catalog))
|
||||
|
||||
def test_create(self):
|
||||
ctx = context.TroveContext(user='test_user_id',
|
||||
ctx = context.TroveContext(user_id='test_user_id',
|
||||
request_id='test_req_id')
|
||||
self.assertThat(ctx.user, Equals('test_user_id'))
|
||||
self.assertThat(ctx.user_id, Equals('test_user_id'))
|
||||
self.assertThat(ctx.request_id, Equals('test_req_id'))
|
||||
self.assertThat(ctx.limit, Is(None))
|
||||
self.assertThat(ctx.marker, Is(None))
|
||||
self.assertThat(ctx.service_catalog, Is(None))
|
||||
|
||||
def test_to_dict(self):
|
||||
ctx = context.TroveContext(user='test_user_id',
|
||||
ctx = context.TroveContext(user_id='test_user_id',
|
||||
request_id='test_req_id')
|
||||
ctx_dict = ctx.to_dict()
|
||||
self.assertThat(ctx_dict.get('user'), Equals('test_user_id'))
|
||||
self.assertThat(ctx_dict.get('request_id'), Equals('test_req_id'))
|
||||
|
||||
def test_to_dict_with_notification(self):
|
||||
ctx = context.TroveContext(user='test_user_id',
|
||||
ctx = context.TroveContext(user_id='test_user_id',
|
||||
project_id='the_tenant',
|
||||
request_id='test_req_id')
|
||||
ctx.notification = DBaaSInstanceCreate(ctx,
|
||||
@ -70,7 +70,7 @@ class TestTroveContext(trove_testtools.TestCase):
|
||||
'request_id': 'test_req_id',
|
||||
'project_id': 'abc',
|
||||
'blah_blah': 'blah blah'})
|
||||
self.assertThat(ctx.user, Equals('test_user_id'))
|
||||
self.assertThat(ctx.user_id, Equals('test_user_id'))
|
||||
self.assertThat(ctx.request_id, Equals('test_req_id'))
|
||||
self.assertThat(ctx.project_id, Equals('abc'))
|
||||
self.assertThat(ctx.limit, Is(None))
|
||||
|
@ -42,7 +42,7 @@ class TestWsgi(trove_testtools.TestCase):
|
||||
# assertions
|
||||
ctx = req.environ[wsgi.CONTEXT_KEY]
|
||||
self.assertThat(ctx, Not(Is(None)))
|
||||
self.assertThat(ctx.user, Equals(user_id))
|
||||
self.assertThat(ctx.user_id, Equals(user_id))
|
||||
self.assertThat(ctx.auth_token, Equals(token))
|
||||
self.assertEqual(0, len(ctx.service_catalog))
|
||||
|
||||
|
@ -61,8 +61,8 @@ class TestDefaultRootController(trove_testtools.TestCase):
|
||||
def test_root_create(self, root_create):
|
||||
user = Mock()
|
||||
context = Mock()
|
||||
context.user = Mock()
|
||||
context.user.__getitem__ = Mock(return_value=user)
|
||||
context.user_id = Mock()
|
||||
context.user_id.__getitem__ = Mock(return_value=user)
|
||||
req = Mock()
|
||||
req.environ = Mock()
|
||||
req.environ.__getitem__ = Mock(return_value=context)
|
||||
@ -376,8 +376,8 @@ class TestClusterRootController(trove_testtools.TestCase):
|
||||
@patch.object(models.ClusterRoot, "create")
|
||||
def test_instance_root_create(self, mock_cluster_root_create):
|
||||
user = Mock()
|
||||
self.context.user = Mock()
|
||||
self.context.user.__getitem__ = Mock(return_value=user)
|
||||
self.context.user_id = Mock()
|
||||
self.context.user_id.__getitem__ = Mock(return_value=user)
|
||||
req = Mock()
|
||||
req.environ = {'trove.context': self.context}
|
||||
password = Mock()
|
||||
@ -393,8 +393,8 @@ class TestClusterRootController(trove_testtools.TestCase):
|
||||
@patch.object(models.ClusterRoot, "create")
|
||||
def test_instance_root_create_no_body(self, mock_cluster_root_create):
|
||||
user = Mock()
|
||||
self.context.user = Mock()
|
||||
self.context.user.__getitem__ = Mock(return_value=user)
|
||||
self.context.user_id = Mock()
|
||||
self.context.user_id.__getitem__ = Mock(return_value=user)
|
||||
req = Mock()
|
||||
req.environ = {'trove.context': self.context}
|
||||
password = None
|
||||
|
@ -221,7 +221,7 @@ class BaseFreshInstanceTasksTest(trove_testtools.TestCase):
|
||||
self.freshinstancetasks = taskmanager_models.FreshInstanceTasks(
|
||||
None, MagicMock(), None, None)
|
||||
self.freshinstancetasks.context = trove.common.context.TroveContext(
|
||||
user='test_user')
|
||||
user_id='test_user')
|
||||
|
||||
def tearDown(self):
|
||||
super(BaseFreshInstanceTasksTest, self).tearDown()
|
||||
@ -1195,16 +1195,16 @@ class RootReportTest(trove_testtools.TestCase):
|
||||
|
||||
def test_report_root_first_time(self):
|
||||
context = Mock()
|
||||
context.user = utils.generate_uuid()
|
||||
context.user_id = utils.generate_uuid()
|
||||
report = mysql_models.RootHistory.create(
|
||||
context, utils.generate_uuid())
|
||||
self.assertIsNotNone(report)
|
||||
|
||||
def test_report_root_double_create(self):
|
||||
context = Mock()
|
||||
context.user = utils.generate_uuid()
|
||||
context.user_id = utils.generate_uuid()
|
||||
id = utils.generate_uuid()
|
||||
history = mysql_models.RootHistory(id, context.user).save()
|
||||
history = mysql_models.RootHistory(id, context.user_id).save()
|
||||
with patch.object(mysql_models.RootHistory, 'load',
|
||||
Mock(return_value=history)):
|
||||
report = mysql_models.RootHistory.create(context, id)
|
||||
@ -1219,7 +1219,7 @@ class ClusterRootTest(trove_testtools.TestCase):
|
||||
@patch.object(common_models.Root, "create")
|
||||
def test_cluster_root_create(self, root_create, root_history_create):
|
||||
context = Mock()
|
||||
context.user = utils.generate_uuid()
|
||||
context.user_id = utils.generate_uuid()
|
||||
id = utils.generate_uuid()
|
||||
password = "rootpassword"
|
||||
cluster_instances = [utils.generate_uuid(), utils.generate_uuid()]
|
||||
|
Loading…
Reference in New Issue
Block a user