Update formatting because of black version
Change-Id: If43c4256e1b452fc160750f492d2d6fdcb44d389 (cherry picked from commit d9045e4b105a3b88067c7f30915ca92fa697f150)
This commit is contained in:
parent
ad19ed13b6
commit
c4bf791a08
@ -266,7 +266,7 @@ class NewProjectDefaultNetworkAction(NewDefaultNetworkAction):
|
|||||||
|
|
||||||
|
|
||||||
class UpdateProjectQuotasAction(BaseAction, QuotaMixin):
|
class UpdateProjectQuotasAction(BaseAction, QuotaMixin):
|
||||||
""" Updates quota for a project to a given size in a list of regions """
|
"""Updates quota for a project to a given size in a list of regions"""
|
||||||
|
|
||||||
required = [
|
required = [
|
||||||
"size",
|
"size",
|
||||||
@ -445,7 +445,7 @@ class UpdateProjectQuotasAction(BaseAction, QuotaMixin):
|
|||||||
|
|
||||||
|
|
||||||
class SetProjectQuotaAction(UpdateProjectQuotasAction):
|
class SetProjectQuotaAction(UpdateProjectQuotasAction):
|
||||||
""" Updates quota for a given project to a configured quota level """
|
"""Updates quota for a given project to a configured quota level"""
|
||||||
|
|
||||||
required = []
|
required = []
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ class ProjectActionTests(AdjutantTestCase):
|
|||||||
self.assertEqual(action.valid, False)
|
self.assertEqual(action.valid, False)
|
||||||
|
|
||||||
def test_new_project_invalid_domain_id(self):
|
def test_new_project_invalid_domain_id(self):
|
||||||
""" Create a project using an invalid domain """
|
"""Create a project using an invalid domain"""
|
||||||
|
|
||||||
setup_identity_cache()
|
setup_identity_cache()
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ class UserRoles(BaseDelegateAPI):
|
|||||||
|
|
||||||
@utils.mod_or_admin
|
@utils.mod_or_admin
|
||||||
def get(self, request, user_id):
|
def get(self, request, user_id):
|
||||||
""" Get role info based on the user id. """
|
"""Get role info based on the user id."""
|
||||||
id_manager = user_store.IdentityManager()
|
id_manager = user_store.IdentityManager()
|
||||||
user = id_manager.get_user(user_id)
|
user = id_manager.get_user(user_id)
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ class UserRoles(BaseDelegateAPI):
|
|||||||
|
|
||||||
@utils.mod_or_admin
|
@utils.mod_or_admin
|
||||||
def put(self, args, **kwargs):
|
def put(self, args, **kwargs):
|
||||||
""" Add user roles to the current project. """
|
"""Add user roles to the current project."""
|
||||||
kwargs["remove_role"] = False
|
kwargs["remove_role"] = False
|
||||||
return self._edit_user(args, **kwargs)
|
return self._edit_user(args, **kwargs)
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ class UserRoles(BaseDelegateAPI):
|
|||||||
return self._edit_user(args, **kwargs)
|
return self._edit_user(args, **kwargs)
|
||||||
|
|
||||||
def _edit_user(self, request, user_id, remove_role=False, format=None):
|
def _edit_user(self, request, user_id, remove_role=False, format=None):
|
||||||
""" Helper function to add or remove roles from a user """
|
"""Helper function to add or remove roles from a user"""
|
||||||
request.data["remove"] = remove_role
|
request.data["remove"] = remove_role
|
||||||
if "project_id" not in request.data:
|
if "project_id" not in request.data:
|
||||||
request.data["project_id"] = request.keystone_user["project_id"]
|
request.data["project_id"] = request.keystone_user["project_id"]
|
||||||
|
@ -335,7 +335,7 @@ class OpenstackAPITests(AdjutantAPITestCase):
|
|||||||
self.assertTrue(adj_user["manageable"])
|
self.assertTrue(adj_user["manageable"])
|
||||||
|
|
||||||
def test_remove_user_role(self):
|
def test_remove_user_role(self):
|
||||||
""" Remove all roles on a user from our project """
|
"""Remove all roles on a user from our project"""
|
||||||
project = fake_clients.FakeProject(name="test_project")
|
project = fake_clients.FakeProject(name="test_project")
|
||||||
|
|
||||||
user = fake_clients.FakeUser(
|
user = fake_clients.FakeUser(
|
||||||
@ -456,7 +456,7 @@ class QuotaAPITests(AdjutantAPITestCase):
|
|||||||
self.assertEqual(trove_quota["instances"], instance)
|
self.assertEqual(trove_quota["instances"], instance)
|
||||||
|
|
||||||
def test_update_quota_no_history(self):
|
def test_update_quota_no_history(self):
|
||||||
""" Update the quota size of a project with no history """
|
"""Update the quota size of a project with no history"""
|
||||||
|
|
||||||
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
||||||
|
|
||||||
@ -917,7 +917,7 @@ class QuotaAPITests(AdjutantAPITestCase):
|
|||||||
self.assertEqual(recent_task["status"], "Awaiting Approval")
|
self.assertEqual(recent_task["status"], "Awaiting Approval")
|
||||||
|
|
||||||
def test_set_multi_region_quota(self):
|
def test_set_multi_region_quota(self):
|
||||||
""" Sets a quota to all to all regions in a project """
|
"""Sets a quota to all to all regions in a project"""
|
||||||
|
|
||||||
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
||||||
|
|
||||||
@ -1079,7 +1079,7 @@ class QuotaAPITests(AdjutantAPITestCase):
|
|||||||
self.check_quota_cache("RegionTwo", project.id, "small")
|
self.check_quota_cache("RegionTwo", project.id, "small")
|
||||||
|
|
||||||
def test_set_quota_over_limit(self):
|
def test_set_quota_over_limit(self):
|
||||||
""" Attempts to set a smaller quota than the current usage """
|
"""Attempts to set a smaller quota than the current usage"""
|
||||||
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
||||||
|
|
||||||
user = fake_clients.FakeUser(
|
user = fake_clients.FakeUser(
|
||||||
@ -1146,7 +1146,7 @@ class QuotaAPITests(AdjutantAPITestCase):
|
|||||||
self.check_quota_cache("RegionOne", project.id, "small")
|
self.check_quota_cache("RegionOne", project.id, "small")
|
||||||
|
|
||||||
def test_set_quota_invalid_region(self):
|
def test_set_quota_invalid_region(self):
|
||||||
""" Attempts to set a quota on a non-existent region """
|
"""Attempts to set a quota on a non-existent region"""
|
||||||
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
||||||
|
|
||||||
user = fake_clients.FakeUser(
|
user = fake_clients.FakeUser(
|
||||||
@ -1180,7 +1180,7 @@ class QuotaAPITests(AdjutantAPITestCase):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
def test_no_auto_approved_quota_change(self):
|
def test_no_auto_approved_quota_change(self):
|
||||||
""" Test allow_auto_approve config setting on a task."""
|
"""Test allow_auto_approve config setting on a task."""
|
||||||
|
|
||||||
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
||||||
|
|
||||||
@ -1269,7 +1269,7 @@ class QuotaAPITests(AdjutantAPITestCase):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
def test_update_quota_extra_services(self):
|
def test_update_quota_extra_services(self):
|
||||||
""" Update quota for extra services """
|
"""Update quota for extra services"""
|
||||||
|
|
||||||
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
project = fake_clients.FakeProject(name="test_project", id="test_project_id")
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ client_auth_session = None
|
|||||||
|
|
||||||
|
|
||||||
def get_auth_session():
|
def get_auth_session():
|
||||||
""" Returns a global auth session to be shared by all clients """
|
"""Returns a global auth session to be shared by all clients"""
|
||||||
global client_auth_session
|
global client_auth_session
|
||||||
if not client_auth_session:
|
if not client_auth_session:
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ class QuotaManager(object):
|
|||||||
return current_quota
|
return current_quota
|
||||||
|
|
||||||
def get_quota_differences(self, current_quota):
|
def get_quota_differences(self, current_quota):
|
||||||
""" Gets the closest matching quota size for a given quota """
|
"""Gets the closest matching quota size for a given quota"""
|
||||||
quota_differences = {}
|
quota_differences = {}
|
||||||
for size, setting in CONF.quota.sizes.items():
|
for size, setting in CONF.quota.sizes.items():
|
||||||
match_percentages = []
|
match_percentages = []
|
||||||
@ -272,7 +272,7 @@ class QuotaManager(object):
|
|||||||
return quota_differences
|
return quota_differences
|
||||||
|
|
||||||
def get_quota_size(self, current_quota, difference_threshold=None):
|
def get_quota_size(self, current_quota, difference_threshold=None):
|
||||||
""" Gets the closest matching quota size for a given quota """
|
"""Gets the closest matching quota size for a given quota"""
|
||||||
quota_differences = self.get_quota_differences(current_quota)
|
quota_differences = self.get_quota_differences(current_quota)
|
||||||
|
|
||||||
diff_threshold = difference_threshold or self.size_diff_threshold
|
diff_threshold = difference_threshold or self.size_diff_threshold
|
||||||
@ -289,7 +289,7 @@ class QuotaManager(object):
|
|||||||
return "custom"
|
return "custom"
|
||||||
|
|
||||||
def get_quota_change_options(self, quota_size):
|
def get_quota_change_options(self, quota_size):
|
||||||
""" Get's the pre-approved quota change options for a given size """
|
"""Get's the pre-approved quota change options for a given size"""
|
||||||
quota_list = CONF.quota.sizes_ascending
|
quota_list = CONF.quota.sizes_ascending
|
||||||
try:
|
try:
|
||||||
list_position = quota_list.index(quota_size)
|
list_position = quota_list.index(quota_size)
|
||||||
@ -304,7 +304,7 @@ class QuotaManager(object):
|
|||||||
return quota_change_list
|
return quota_change_list
|
||||||
|
|
||||||
def get_smaller_quota_options(self, quota_size):
|
def get_smaller_quota_options(self, quota_size):
|
||||||
""" Get the quota sizes smaller than the current size."""
|
"""Get the quota sizes smaller than the current size."""
|
||||||
quota_list = CONF.quota.sizes_ascending
|
quota_list = CONF.quota.sizes_ascending
|
||||||
try:
|
try:
|
||||||
list_position = quota_list.index(quota_size)
|
list_position = quota_list.index(quota_size)
|
||||||
|
@ -534,7 +534,7 @@ class FakeManager(object):
|
|||||||
|
|
||||||
class FakeOpenstackClient(object):
|
class FakeOpenstackClient(object):
|
||||||
class Quotas(object):
|
class Quotas(object):
|
||||||
""" Stub class for testing quotas """
|
"""Stub class for testing quotas"""
|
||||||
|
|
||||||
def __init__(self, service):
|
def __init__(self, service):
|
||||||
self.service = service
|
self.service = service
|
||||||
@ -794,7 +794,7 @@ class FakeNovaClient(FakeOpenstackClient):
|
|||||||
|
|
||||||
class FakeCinderClient(FakeOpenstackClient):
|
class FakeCinderClient(FakeOpenstackClient):
|
||||||
class FakeResourceGroup(object):
|
class FakeResourceGroup(object):
|
||||||
""" Stub class to represent volumes and snapshots """
|
"""Stub class to represent volumes and snapshots"""
|
||||||
|
|
||||||
def __init__(self, region, cache_key):
|
def __init__(self, region, cache_key):
|
||||||
self.region = region
|
self.region = region
|
||||||
@ -901,7 +901,7 @@ def setup_nova_cache(region, project_id):
|
|||||||
|
|
||||||
|
|
||||||
def setup_quota_cache(region_name, project_id, size="small"):
|
def setup_quota_cache(region_name, project_id, size="small"):
|
||||||
""" Sets up the quota cache for a given region and project """
|
"""Sets up the quota cache for a given region and project"""
|
||||||
global cinder_cache
|
global cinder_cache
|
||||||
|
|
||||||
if region_name not in cinder_cache:
|
if region_name not in cinder_cache:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user