def execute_command(args, unknown_args): session = AuthenticatedSession(args.url, args.token) source = Boxes(args.boxes_path if 'boxes_path' in args else os.getcwd(), session) context = { 'path': EBX_CONTAINER_PATH, 'box': args.box_id, 'image': args.image or 'ubuntu', 'url': args.url } if 'dockerfile' in args and args.dockerfile: box_collection, scripts, ports = _get_setup_data(source, args.box_id) filename = os.path.abspath(args.dockerfile.name) context['boxes_path'] = os.path.relpath(os.path.dirname(filename), args.boxes_path) context['scripts'] = scripts context['ports'] = ports context['boxes'] = box_collection _generate_dockerfile(context, args.dockerfile) else: ebx_path = os.path.join(tempfile.gettempdir(), EBX_TEMPORARY_FOLDER) boxes = Boxes(os.path.join(ebx_path, 'boxes'), session) boxes.export_box(args.box_id, recursive=True, source=source) box_collection, scripts, ports = _get_setup_data(boxes, args.box_id) context['boxes_path'] = os.path.join(ebx_path, boxes) context['scripts'] = scripts context['ports'] = ports context['boxes'] = box_collection filename = os.path.join(ebx_path, args.box_id + '.dockerfile') with open(filename, 'w') as dockerfile: _generate_dockerfile(context, dockerfile) try: environment = os.environ.copy() environment['ELASTICBOX_PATH'] = EBX_CONTAINER_PATH if unknown_args: subprocess.call('docker build {0} -f {1} {2}'.format( ' '.join(unknown_args), filename, ebx_path), env=environment, cwd=ebx_path, shell=True) else: subprocess.call('docker build -f {0} {1}'.format( filename, ebx_path), cwd=ebx_path, shell=True, env=environment) finally: os.remove(filename)
def execute_command(args, _unknown): session = AuthenticatedSession(args.url, args.token) Boxes(args.path, session).export_box(args.box_id, args.recursive)
def execute_command(args, _unknown): session = AuthenticatedSession(args.url, args.token) boxes = Boxes(args.path, session) boxes.import_box(args.box_name, args.comment, args.workspace_id, args.image)
def execute_command(args, _unknown): session = AuthenticatedSession(args.url, args.token) Boxes(args.path, session).export_instance_boxes(args.instance_id)