def __init__(self, ctx): """Initialize CliAction""" self.logger = logging.getLogger('shipyard_cli') self.api_parameters = ctx.obj['API_PARAMETERS'] self.resp_txt = "" self.needs_credentials = False self.output_format = ctx.obj['FORMAT'] self.auth_vars = self.api_parameters.get('auth_vars') self.context_marker = self.api_parameters.get('context_marker') self.debug = self.api_parameters.get('debug') self.client_context = ShipyardClientContext( self.auth_vars, self.context_marker, self.debug)
def get_api_client(): """ get a instance of shipyard client :returns: shipyard client with no context object """ keystone_auth = { 'project_domain_name': 'projDomainTest', 'user_domain_name': 'userDomainTest', 'project_name': 'projectTest', 'username': '******', 'password': '******', 'auth_url': 'urlTest' }, context = ShipyardClientContext( debug=True, keystone_auth=keystone_auth, context_marker='88888888-4444-4444-4444-121212121212') return ShipyardClient(context)
def __init__(self, context, buffer_mode='replace'): """ Initializes params to be used by Shipyard :param context: ShipyardHelper context object that contains params for initializing ShipyardClient with correct client context and the site_name. """ self.ctx = context self.api_parameters = self.ctx.obj['API_PARAMETERS'] self.auth_vars = self.api_parameters.get('auth_vars') self.context_marker = self.ctx.obj['context_marker'] if self.context_marker is None: self.context_marker = str(uuid.uuid4()) LOG.debug("context_marker is %s", self.context_marker) self.site_name = self.ctx.obj['site_name'] self.client_context = ShipyardClientContext( self.auth_vars, self.context_marker) self.api_client = ShipyardClient(self.client_context) self.buffer_mode = buffer_mode self.collection = self.ctx.obj.get('collection', self.site_name)