def setUp(self): ''' If the cloud info file is not present assume running in a UNITTEST environment. This will allow for exercising some of the code without having to be running in a cloud VM. ''' # Create the client Object self.cs_client = CSClient(**DUMMY_CS_CONFIG) self.cs_client.http = HttpUnitTest()
def __init__(self, conf): ''' conf: argparse dict ''' tool_dir = {} if 'pwd' in conf and conf['pwd']: tool_dir = {'tool_dir': PWD_TOOLING} # Create the Client Object self.client = CSClient(**conf) self.client.test_connection() # Get any optional tooling from the Config Server tooling_status, tarball = self.client.get_tooling() if tooling_status != 200: LOGGER.error('Get Tooling returned: %s' % tooling_status) raise AAErrorGetTooling('Get Tooling returned: %s' % tooling_status) self.tooling = Tooling(tarball, **tool_dir)
def main(): ''' Description: This script will be used on EC2 for configuring the running instance based on Cloud Engine configuration supplied at launch time in the user data. Config Server Status: 200 HTTP OK - Success and no more data of this type 202 HTTP Accepted - Success and more data of this type 404 HTTP Not Found - This may be temporary so try again ''' # parse the args and setup logging conf = parse_args() log_file = {} if 'pwd' in conf and conf.pwd: log_file = {'logfile_name': 'audrey.log'} logger = setup_logging(level=conf.log_level, **log_file) if not conf.endpoint: # discover the cloud I'm on # update the conf with the user data #conf = dict(vars(conf).items() + user_data.discover().read().items()) vars(conf).update(user_data.discover().read().items()) # ensure the conf is a dictionary, not a namespace if hasattr(conf, '__dict__'): conf = vars(conf) logger.info('Invoked audrey main') # Create the Client Object and test connectivity # to CS by negotiating the api version client = CSClient(**conf) client.test_connection() # Get the agent object agent = AudreyFactory(client.api_version).agent # run the agent agent(conf).run()