def create_session(self, session_type='bash', docker_image=None, rm=None): assert isinstance(session_type, str) new_shutit = ShutIt(standalone=True) self.add_shutit_session(new_shutit) if session_type == 'bash': new_shutit.process_args(ShutItInit('build', delivery='bash')) # TODO: can we get rid of/rationalise load_configs? new_shutit.load_configs() new_shutit.setup_host_child_environment() return new_shutit elif session_type == 'docker': new_shutit.process_args(ShutItInit('build', delivery='docker', base_image=docker_image)) new_shutit.target['rm'] = rm # TODO: can we get rid of/rationalise load_configs? new_shutit.load_configs() target_child = new_shutit.conn_docker_start_container('target_child') new_shutit.setup_host_child_environment() new_shutit.setup_target_child_environment(target_child) return new_shutit else: new_shutit.fail('unhandled session type: ' + session_type)
def create_session(self, session_type='bash', docker_image=None, rm=None, loglevel='INFO'): assert isinstance(session_type, str) new_shutit = ShutIt() self.add_shutit_session(new_shutit) # TODO: only makes sense in session that's already bash - check this if session_type == 'bash': shutit_util.parse_args(new_shutit) shutit_util.load_configs(shutit=new_shutit) shutit_setup.setup_host_child_environment(new_shutit) return new_shutit elif session_type == 'docker': shutit_util.parse_args(new_shutit, set_loglevel=loglevel) # Set the configuration up appropriately using overrides. if docker_image: new_shutit.build['config_overrides'].append( ['build', 'base_image', docker_image]) if rm: new_shutit.target['rm'] = True # Now 'load' the configs shutit_util.load_configs(new_shutit) target_child = shutit_setup.conn_docker_start_container( new_shutit, 'target_child') shutit_setup.setup_host_child_environment(new_shutit) shutit_setup.setup_target_child_environment( new_shutit, target_child) return new_shutit else: new_shutit.fail('unhandled session type: ' + session_type)
def create_session(self, session_type='bash', docker_image=None, rm=None, echo=False, walkthrough=False, walkthrough_wait=-1, nocolor=False, loglevel='WARNING'): assert isinstance(session_type, str), shutit_util.print_debug() new_shutit = ShutIt(standalone=True) self.add_shutit_session(new_shutit) self.nocolor = nocolor if session_type == 'bash': new_shutit.process_args( ShutItInit('build', delivery='bash', echo=echo, walkthrough=walkthrough, walkthrough_wait=walkthrough_wait, log=loglevel)) # TODO: can we get rid of/rationalise load_configs? new_shutit.load_configs() new_shutit.setup_host_child_environment() return new_shutit elif session_type == 'docker': new_shutit.process_args( ShutItInit('build', delivery='docker', base_image=docker_image, echo=echo, walkthrough=walkthrough, walkthrough_wait=walkthrough_wait, log=loglevel)) new_shutit.target['rm'] = rm # TODO: can we get rid of/rationalise load_configs? new_shutit.load_configs() target_child = new_shutit.conn_docker_start_container( 'target_child') new_shutit.setup_host_child_environment() new_shutit.setup_target_child_environment(target_child) return new_shutit new_shutit.fail('unhandled session type: ' + session_type) return new_shutit
def create_session(self, session_type='bash', docker_image=None, rm=None, echo=False, walkthrough=False, walkthrough_wait=-1, nocolor=False, loglevel='WARNING'): assert isinstance(session_type, str), shutit_util.print_debug() new_shutit = ShutIt(standalone=True, session_type=session_type) self.shutit_objects.append(new_shutit) if session_type == 'bash': new_shutit.process_args(ShutItInit('build', delivery='bash', echo=echo, walkthrough=walkthrough, walkthrough_wait=walkthrough_wait, loglevel=loglevel)) new_shutit.load_configs() new_shutit.setup_host_child_environment() return new_shutit elif session_type == 'docker': new_shutit.process_args(ShutItInit('build', delivery='docker', base_image=docker_image, echo=echo, walkthrough=walkthrough, walkthrough_wait=walkthrough_wait, loglevel=loglevel)) new_shutit.target['rm'] = rm target_child = new_shutit.conn_docker_start_container('target_child') new_shutit.setup_host_child_environment() new_shutit.setup_target_child_environment(target_child) return new_shutit new_shutit.fail('unhandled session type: ' + session_type) return new_shutit