Pass credentials to each CSP method rather than an abstract auth object
This commit is contained in:
parent
776887686c
commit
0451dce8cf
@ -4,22 +4,11 @@ from atst.models.environment_role import CSPRole
|
|||||||
|
|
||||||
|
|
||||||
class CloudProviderInterface:
|
class CloudProviderInterface:
|
||||||
def get_auth(self, auth_credentials):
|
def create_environment(self, auth_credentials, user):
|
||||||
"""Validate credentials and create auth object
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
auth_credentials -- Object containing credentials
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
object: An object to be passed into subsequent calls
|
|
||||||
"""
|
|
||||||
raise NotImplementedError()
|
|
||||||
|
|
||||||
def create_environment(self, auth, user):
|
|
||||||
"""Create a new environment in the CSP.
|
"""Create a new environment in the CSP.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
auth -- Object representing authorization for the CSP
|
auth_credentials -- Object containing CSP account credentials
|
||||||
user -- ATAT user authorizing the environment creation
|
user -- ATAT user authorizing the environment creation
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -27,12 +16,12 @@ class CloudProviderInterface:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def create_atat_admin_user(self, auth, csp_environment_id):
|
def create_atat_admin_user(self, auth_credentials, csp_environment_id):
|
||||||
"""Creates a new, programmatic user in the CSP. Grants this user full permissions to administer
|
"""Creates a new, programmatic user in the CSP. Grants this user full permissions to administer
|
||||||
the CSP. Returns a dictionary containing user details, including user's API credentials.
|
the CSP. Returns a dictionary containing user details, including user's API credentials.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
auth -- Object representing authorization for the CSP
|
auth_credentials -- Object containing CSP account credentials
|
||||||
csp_environment_id -- ID of the CSP Environment the admin user should be created in
|
csp_environment_id -- ID of the CSP Environment the admin user should be created in
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -40,11 +29,11 @@ class CloudProviderInterface:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def create_environment_baseline(self, auth, csp_environment_id):
|
def create_environment_baseline(self, auth_credentials, csp_environment_id):
|
||||||
"""Provision the necessary baseline entities (such as roles) in the given environment
|
"""Provision the necessary baseline entities (such as roles) in the given environment
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
auth -- Object representing authorization for the CSP
|
auth_credentials -- Object containing CSP account credentials
|
||||||
csp_environment_id -- ID of the CSP Environment to provision roles against.
|
csp_environment_id -- ID of the CSP Environment to provision roles against.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -52,11 +41,11 @@ class CloudProviderInterface:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def create_or_update_user(self, auth, user_info, csp_role_id):
|
def create_or_update_user(self, auth_credentials, user_info, csp_role_id):
|
||||||
"""Creates a user or updates an existing user's role.
|
"""Creates a user or updates an existing user's role.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
auth -- Object representing authorization for the CSP
|
auth_credentials -- Object containing CSP account credentials
|
||||||
user_info -- object containing user data, if it has a csp_user_id
|
user_info -- object containing user data, if it has a csp_user_id
|
||||||
it will try to update a user with that id
|
it will try to update a user with that id
|
||||||
csp_role_id -- The id of the role the user should be given in the CSP
|
csp_role_id -- The id of the role the user should be given in the CSP
|
||||||
@ -66,12 +55,12 @@ class CloudProviderInterface:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def suspend_user(self, auth, csp_user_id):
|
def suspend_user(self, auth_credentials, csp_user_id):
|
||||||
"""Revoke all privileges for a user. Used to prevent user access while a full
|
"""Revoke all privileges for a user. Used to prevent user access while a full
|
||||||
delete is being processed.
|
delete is being processed.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
auth -- Object representing authorization for the CSP
|
auth_credentials -- Object containing CSP account credentials
|
||||||
csp_user_id -- CSP internal user identifier
|
csp_user_id -- CSP internal user identifier
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -79,11 +68,11 @@ class CloudProviderInterface:
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def delete_user(self, auth, csp_user_id):
|
def delete_user(self, auth_credentials, csp_user_id):
|
||||||
"""Given the csp-internal id for a user, initiate user deletion.
|
"""Given the csp-internal id for a user, initiate user deletion.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
auth -- Object representing authorization for the CSP
|
auth_credentials -- Object containing CSP account credentials
|
||||||
csp_user_id -- CSP internal user identifier
|
csp_user_id -- CSP internal user identifier
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -108,16 +97,13 @@ class CloudProviderInterface:
|
|||||||
|
|
||||||
|
|
||||||
class MockCloudProvider(CloudProviderInterface):
|
class MockCloudProvider(CloudProviderInterface):
|
||||||
def get_auth(self, auth_credentials):
|
def create_environment(self, auth_credentials, user):
|
||||||
return {}
|
|
||||||
|
|
||||||
def create_environment(self, auth, user):
|
|
||||||
return uuid4().hex
|
return uuid4().hex
|
||||||
|
|
||||||
def create_atat_admin_user(self, auth, csp_environment_id):
|
def create_atat_admin_user(self, auth_credentials, csp_environment_id):
|
||||||
return {"id": uuid4().hex, "credentials": {}}
|
return {"id": uuid4().hex, "credentials": {}}
|
||||||
|
|
||||||
def create_environment_baseline(self, auth, csp_environment_id):
|
def create_environment_baseline(self, auth_credentials, csp_environment_id):
|
||||||
return {
|
return {
|
||||||
CSPRole.BASIC_ACCESS: uuid4().hex,
|
CSPRole.BASIC_ACCESS: uuid4().hex,
|
||||||
CSPRole.NETWORK_ADMIN: uuid4().hex,
|
CSPRole.NETWORK_ADMIN: uuid4().hex,
|
||||||
@ -125,13 +111,13 @@ class MockCloudProvider(CloudProviderInterface):
|
|||||||
CSPRole.TECHNICAL_READ: uuid4().hex,
|
CSPRole.TECHNICAL_READ: uuid4().hex,
|
||||||
}
|
}
|
||||||
|
|
||||||
def create_or_update_user(self, auth, environment_role):
|
def create_or_update_user(self, auth_credentials, environment_role):
|
||||||
return {"id": uuid4().hex}
|
return {"id": uuid4().hex}
|
||||||
|
|
||||||
def suspend_user(self, auth, csp_user_id):
|
def suspend_user(self, auth_credentials, csp_user_id):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete_user(self, auth, csp_user_id):
|
def delete_user(self, auth_credentials, csp_user_id):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_calculator_url(self):
|
def get_calculator_url(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user