def create_amazon(self, name, region, access_key, secret_key, params=None): '''Creates a new Amazon (AWS) provider on the account :param name string: Display name of the provider :param region string: AWS region (ex. us-east-1) :param access_key string: AWS API Access Key ID :param secret_key string: AWS API Access Secret Key :param dict params: Additional POST request data :returns: Provider dictionary object Example:: # Creates a new Amazon (AWS) provider provider = provider_mgr.create_amazon( name='MyAWSProvider', region='us-east-1', access_key='MY4CC3SSK3Y', secret_key='My$Freak1shly/L0ng=S3cr3t&K3y' ) # Refresh the provider provider_mgr.refresh(provider['id']) ''' return self.create( update_params( params, { 'type': 'ManageIQ::Providers::Amazon::CloudManager', 'name': name, 'provider_region': region, 'credentials': { 'userid': access_key, 'password': secret_key } }))
def create_amazon(self, name, region, access_key, secret_key, params=None): '''Creates a new Amazon (AWS) provider on the account :param name string: Display name of the provider :param region string: AWS region (ex. us-east-1) :param access_key string: AWS API Access Key ID :param secret_key string: AWS API Access Secret Key :param dict params: Additional POST request data :returns: Provider dictionary object Example:: # Creates a new Amazon (AWS) provider provider = provider_mgr.create_amazon( name='MyAWSProvider', region='us-east-1', access_key='MY4CC3SSK3Y', secret_key='My$Freak1shly/L0ng=S3cr3t&K3y' ) # Refresh the provider provider_mgr.refresh(provider['id']) ''' return self.create(update_params(params, { 'type': 'ManageIQ::Providers::Amazon::CloudManager', 'name': name, 'provider_region': region, 'credentials': { 'userid': access_key, 'password': secret_key } }))
def create(self, params=None): '''Creates a new provision request on the account :param dict params: Additional POST request data :returns: ProvisionRequest dictionary object ''' params = update_params(params, {'action': 'create'}) return normalize_object( self.client.call('post', '/provision_requests', data=params))
def perform_action(self, _id, action, params=None): '''Sends a request to perform an action on a provision request :param string _id: Specifies which provision request the request is for :param string action: The action to request (delete, refresh, etc.) :param dict params: Additional POST request data :returns: ProvisionRequest dictionary object ''' params = update_params(params, {'action': action}) return normalize_object( self.client.call('post', '/provision_requests/%s' % _id, data=params))
def list(self, params=None): '''Retrieve a list of all tasks on the account :param dict params: response-level options (attributes, limit, etc.) :returns: List of dictionaries representing the matching tasks Example:: # Gets a list of all tasks (returns IDs only) tasks = task_mgr.list({'attributes': 'id'}) ''' params = update_params(params, {'expand': 'resources'}) return normalize_collection( self.client.call('get', '/tasks', params=params))
def list(self, params=None): '''Retrieve a list of all tags on the account :param dict params: response-level options (attributes, limit, etc.) :returns: List of dictionaries representing the matching tags Example:: # Gets a list of all tags (returns IDs only) tags = tag_mgr.list({'attributes': 'id'}) ''' params = update_params(params, {'expand': 'resources'}) return normalize_collection( self.client.call('get', '/tags', params=params))
def get(self, _id, params=None): '''Retrieve details about a task on the account :param string _id: Specifies which task the request is for :param dict params: response-level options (attributes, limit, etc.) :returns: Dictionary representing the matching task Example:: # Gets a list of all tasks (returns IDs only) tasks = task_mgr.list({'attributes': 'id'}) for task in tasks: task_details = task_mgr.get(task['id']) ''' params = update_params(params, {'expand': 'resources'}) return normalize_object( self.client.call('get', '/tasks/%s' % _id, params=params))
def get(self, _id, params=None): '''Retrieve details about a tag on the account :param string _id: Specifies which tag the request is for :param dict params: response-level options (attributes, limit, etc.) :returns: Dictionary representing the matching tag Example:: # Gets a list of all tags (returns IDs only) tags = tag_mgr.list({'attributes': 'id'}) for tag in tags: tag_details = tag_mgr.get(tag['id']) ''' params = update_params(params, {'expand': 'resources'}) return normalize_object( self.client.call('get', '/tags/%s' % _id, params=params))
def get(self, _id, params=None): '''Retrieve details about a virtual server on the account :param string _id: Specifies which virtual server the request is for :param dict params: response-level options (attributes, limit, etc.) :returns: Dictionary representing the matching virtual server Example:: # Gets a list of all virtual server instances (returns IDs only) instances = vs_mgr.list({'attributes': 'id'}) for instance in instances: vs_details = vs_mgr.get(instance['id']) ''' params = update_params(params, {'expand': 'resources'}) return normalize_object( self.client.call('get', '/vms/%s' % _id, params=params))
def get(self, _id, params=None): '''Retrieve details about a provider on the account :param string _id: Specifies which provider the request is for :param dict params: response-level options (attributes, limit, etc.) :returns: Dictionary representing the matching provider Example:: # Gets a list of all providers (returns IDs only) providers = provider_mgr.list({'attributes': 'id'}) for provider in providers: provider_details = provider_mgr.get(provider['id']) ''' params = update_params(params, {'expand': 'resources'}) return normalize_object( self.client.call('get', '/providers/%s' % _id, params=params))
def perform_action(self, _id, action, params=None): '''Sends a request to perform an action on a provider :param string _id: Specifies which provider the request is for :param string action: The action to request (delete, refresh, etc.) :param dict params: Additional POST request data :returns: Task request, or Provider, dictionary object Example:: # Gets a list of all providers for provider in provider_mgr.list(): # Send requests to refresh all providers provider_mgr.perform_action(provider['id'], 'refresh') ''' params = update_params(params, {'action': action}) return normalize_object( self.client.call('post', '/providers/%s' % _id, data=params))
def perform_action(self, _id, action, params=None): '''Sends a request to perform an action on a virtual server :param string _id: Specifies which virtual server the request is for :param string action: The action to request (start, stop, suspend) :param dict params: Additional POST request data :returns: Task request dictionary (see TaskManager) Example:: # Gets a list of all virtual server instances for vsi in vs_mgr.list(): # Send requests to start all virtual server instances vs_mgr.perform_action(vsi['id'], 'start') ''' params = update_params(params, {'action': action}) return normalize_object( self.client.call('post', '/vms/%s' % _id, data=params))