def setup_database(work_dir, db_info, artifact_info): "Setup database instance" if 'setup_file' in db_info: db_host = db_info['host'] db_user = db_info['root_user'] db_password = db_info['root_password'] db_setup_file = db_info['setup_file'] artifact_name = artifact_info['name'] artifact_version = artifact_info['version'] cmd = ( "mysql -h{db_host} --user={db_user} --password={db_password} < {setup_file}" ).format(db_host=db_host, db_user=db_user, db_password=db_password, setup_file=db_setup_file) cwd = os.getcwd() os.chdir(work_dir) # Create Dockerfile df = ( "FROM ubuntu:14.04 \n" "RUN apt-get update && apt-get install -y mysql-client-core-5.5\n" "COPY {setup_file} . \n" "CMD {cmd}").format(setup_file=db_setup_file, cmd=cmd) fp = open("Dockerfile", "w") fp.write(df) fp.close() cont_name = ("setup-db-{name}-{version}").format( name=artifact_name, version=artifact_version) docker_lib.DockerLib().build_container_image(cont_name, "Dockerfile") docker_lib.DockerLib().run_container(cont_name) os.chdir(cwd)
def __init__(self, task_def): self.task_def = task_def if task_def.app_data: self.app_dir = task_def.app_data['app_location'] self.app_name = task_def.app_data['app_name'] self.app_version = task_def.app_data['app_version'] self.services = {} if task_def.service_data: self.service_obj = service.Service(task_def.service_data[0]) if self.service_obj.get_service_type() == 'mysql': self.services['mysql'] = awsh.MySQLServiceHandler(self.task_def) self.docker_handler = docker_lib.DockerLib()
def __init__(self, task_def): self.task_def = task_def if task_def.app_data: self.app_dir = task_def.app_data['app_location'] self.app_name = task_def.app_data['app_name'] self.app_version = task_def.app_data['app_version'] self.services = {} if task_def.service_data: self.service_obj = service.Service(task_def.service_data[0]) if self.service_obj.get_service_type() == 'mysql': self.services['mysql'] = gh.MySQLServiceHandler(self.task_def) self.docker_client = Client(base_url='unix://var/run/docker.sock', version='1.18') self.docker_handler = docker_lib.DockerLib()
def __init__(self, task_def): self.task_def = task_def self.instance_name = '' self.instance_version = '' self.instance_prov_workdir = '' self.connection_name = '' self.database_version = '' self.database_tier = '' self.instance_ip_address = '' self.app_status_file = '' if task_def.app_data: self.instance_prov_workdir = task_def.app_data['app_location'] self.instance_name = task_def.app_data['app_name'] self.instance_version = task_def.app_data['app_version'] self.access_token_cont_name = "google-access-token-cont-" + self.instance_name + "-" + self.instance_version self.create_db_cont_name = "google-create-db-" + self.instance_name + "-" + self.instance_version self.app_status_file = constants.APP_STORE_PATH + "/" + self.instance_name + "/" + self.instance_version + "/app-status.txt" if task_def.service_data: self.service_obj = service.Service(task_def.service_data[0]) self.instance_prov_workdir = self.service_obj.get_service_prov_work_location( ) self.instance_name = self.service_obj.get_service_name() self.instance_version = self.service_obj.get_service_version() self.access_token_cont_name = "google-access-token-cont-" + self.instance_name + "-" + self.instance_version self.create_db_cont_name = "google-create-db-" + self.instance_name + "-" + self.instance_version self.mysql_db_name = constants.DEFAULT_DB_NAME self.mysql_user = constants.DEFAULT_DB_USER # Check if we have already provisioned a db instance. If so, use that password password = self._read_password() if not password: self.mysql_password = utils.generate_google_password() else: self.mysql_password = password self.db_info = {} self.db_info['user'] = self.mysql_user self.db_info['db'] = self.mysql_db_name self.db_info['password'] = self.mysql_password self.docker_handler = docker_lib.DockerLib()
def __init__(self, task_def): self.task_def = task_def #self.logger = logging.getLogger(name=self.__class__.__name__) self.services = {} self.app_obj = '' if self.task_def.app_data: self.app_obj = app.App(self.task_def.app_data) self.app_dir = task_def.app_data['app_location'] self.app_name = task_def.app_data['app_name'] if task_def.service_data: self.service_obj = service.Service(task_def.service_data[0]) if self.service_obj.get_service_type() == 'mysql': self.services['mysql'] = awsh.MySQLServiceHandler(self.task_def) self.docker_handler = docker_lib.DockerLib() self.docker_client = Client(base_url='unix://var/run/docker.sock', version='1.18')
def __init__(self, task_def): self.task_def = task_def self.instance_name = '' self.instance_version = '' self.app_name = '' self.app_version = '' self.services = {} self.service_handler = '' self.instance_prov_workdir = '' self.app_variables = '' # Set values using service_data first if task_def.service_data: self.service_obj = service.Service(task_def.service_data[0]) self.instance_prov_workdir = self.service_obj.get_service_prov_work_location( ) self.instance_name = self.service_obj.get_service_name() self.instance_version = self.service_obj.get_service_version() if self.service_obj.get_service_type() == 'mysql': self.services['mysql'] = awsh.MySQLServiceHandler( self.task_def) # If app_data is present overwrite the previously set values if self.task_def.app_data: self.app_type = task_def.app_data['app_type'] self.app_dir = task_def.app_data['app_location'] self.app_name = task_def.app_data['app_name'] self.app_version = task_def.app_data['app_version'] self.instance_prov_workdir = task_def.app_data[ 'app_location'] + "/" + task_def.app_data['app_name'] self.entry_point = app.App( task_def.app_data).get_entrypoint_file_name() if 'app_variables' in task_def.app_data: self.app_variables = task_def.app_data['app_variables'] self.deploy_dir = self.instance_prov_workdir self.docker_handler = docker_lib.DockerLib()
def __init__(self, task_def): self.task_def = task_def #self.logger = fmlogging.getLogger(name=self.__class__.__name__) #handler = lh.RotatingFileHandler(constants.LOG_FILE_NAME, # maxBytes=5000000, backupCount=0) #self.logger.addHandler(handler) if task_def.app_data: self.app_dir = task_def.app_data['app_location'] self.app_name = task_def.app_data['app_name'] self.app_version = task_def.app_data['app_version'] self.access_token_cont_name = "google-access-token-cont-" + self.app_name + "-" + self.app_version self.create_db_cont_name = "google-create-db-" + self.app_name + "-" + self.app_version self.app_obj = app.App(self.task_def.app_data) self.services = {} if task_def.service_data: self.service_obj = service.Service(task_def.service_data[0]) if self.service_obj.get_service_type() == 'mysql': self.services['mysql'] = gh.MySQLServiceHandler(self.task_def) self.docker_handler = docker_lib.DockerLib()
def __init__(self, task_def): self.task_def = task_def self.instance_name = '' self.instance_version = '' self.instance_prov_workdir = '' if task_def.app_data: self.app_type = task_def.app_data['app_type'] self.app_dir = task_def.app_data['app_location'] self.app_name = task_def.app_data['app_name'] self.entry_point = app.App(task_def.app_data).get_entrypoint_file_name() if 'app_variables' in task_def.app_data: self.app_variables = task_def.app_data['app_variables'] self.services = {} if task_def.service_data: self.service_obj = service.Service(task_def.service_data[0]) self.service_details = '' if self.service_obj.get_service_type() == 'mysql': self.services['mysql'] = gh.MySQLServiceHandler(self.task_def) self.docker_handler = docker_lib.DockerLib()
def __init__(self): self.docker_handler = docker_lib.DockerLib()
def __init__(self, task_def): self.task_def = task_def self.docker_client = Client(base_url='unix://var/run/docker.sock', version='1.18') self.docker_handler = docker_lib.DockerLib()