예제 #1
0
    def handle(self, *args, **options):
        if args:
            raise CommandError("Command doesn't accept any arguments")

        name = options['name']
        user_id = options['user_id']
        project = options['project']
        backend_id = options['backend_id']
        image_id = options['image_id']
        flavor_id = options['flavor_id']
        password = options['password']
        volumes = options['volumes']
        helper_vm = options['helper_vm']

        if not name:
            raise CommandError("name is mandatory")
        if not user_id:
            raise CommandError("user is mandatory")
        if not project:
            project = user_id
        if not password:
            raise CommandError("password is mandatory")
        if not flavor_id:
            raise CommandError("flavor is mandatory")
        if not image_id and not volumes:
            raise CommandError("image is mandatory")

        flavor = common.get_resource("flavor", flavor_id)
        if image_id is not None:
            common.get_image(image_id, user_id)

        if backend_id:
            backend = common.get_resource("backend", backend_id)
        else:
            backend = None

        connection_list = parse_connections(options["connections"])
        volumes_list = parse_volumes(volumes)
        credentials = Credentials(user_id)
        server = servers.create(credentials,
                                name,
                                password,
                                flavor,
                                image_id,
                                networks=connection_list,
                                volumes=volumes_list,
                                use_backend=backend,
                                helper=helper_vm,
                                project=project)
        pprint.pprint_server(server, stdout=self.stdout)

        wait = parse_bool(options["wait"])
        common.wait_server_task(server, wait, self.stdout)
예제 #2
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a server ID")

        vm = common.get_vm(args[0], for_update=True)

        displayname = options['displayname']

        pprint.pprint_server(vm, display_mails=displayname, stdout=self.stdout)
        self.stdout.write("\n")
        pprint.pprint_server_nics(vm, stdout=self.stdout)
        self.stdout.write("\n")
        pprint.pprint_server_in_ganeti(vm, print_jobs=options["jobs"],
                                       stdout=self.stdout)
        self.stdout.write("\n")
예제 #3
0
    def handle(self, *args, **options):
        if args:
            raise CommandError("Command doesn't accept any arguments")

        name = options['name']
        user_id = options['user_id']
        project = options['project']
        backend_id = options['backend_id']
        image_id = options['image_id']
        flavor_id = options['flavor_id']
        password = options['password']
        volumes = options['volumes']
        helper_vm = options['helper_vm']

        if not name:
            raise CommandError("name is mandatory")
        if not user_id:
            raise CommandError("user is mandatory")
        if not project:
            project = user_id
        if not password:
            raise CommandError("password is mandatory")
        if not flavor_id:
            raise CommandError("flavor is mandatory")
        if not image_id and not volumes:
            raise CommandError("image is mandatory")

        flavor = common.get_resource("flavor", flavor_id)
        if image_id is not None:
            common.get_image(image_id, user_id)

        if backend_id:
            backend = common.get_resource("backend", backend_id)
        else:
            backend = None

        connection_list = parse_connections(options["connections"])
        volumes_list = parse_volumes(volumes)
        credentials = Credentials(user_id)
        server = servers.create(credentials, name, password, flavor, image_id,
                                networks=connection_list,
                                volumes=volumes_list,
                                use_backend=backend, helper=helper_vm,
                                project=project)
        pprint.pprint_server(server, stdout=self.stdout)

        wait = parse_bool(options["wait"])
        common.wait_server_task(server, wait, self.stdout)
예제 #4
0
    def handle(self, *args, **options):
        if len(args) != 1:
            raise CommandError("Please provide a server ID")

        vm = common.get_resource("server", args[0])

        display_mails = options['displaymails']

        pprint.pprint_server(vm, display_mails=display_mails, stdout=self.stdout)
        self.stdout.write("\n")
        pprint.pprint_server_nics(vm, stdout=self.stdout)
        self.stdout.write("\n")
        pprint.pprint_server_volumes(vm, stdout=self.stdout)
        self.stdout.write("\n")
        pprint.pprint_server_in_ganeti(vm, print_jobs=options["jobs"],
                                       stdout=self.stdout)
        self.stdout.write("\n")
예제 #5
0
    def handle(self, *args, **options):
        if args:
            raise CommandError("Command doesn't accept any arguments")

        name = options['name']
        user_id = options['user_id']
        backend_id = options['backend_id']
        image_id = options['image_id']
        flavor_id = options['flavor_id']
        password = options['password']

        if not name:
            raise CommandError("name is mandatory")
        if not user_id:
            raise CommandError("user-id is mandatory")
        if not password:
            raise CommandError("password is mandatory")
        if not flavor_id:
            raise CommandError("flavor-id is mandatory")
        if not image_id:
            raise CommandError("image-id is mandatory")

        flavor = common.get_flavor(flavor_id)
        image = common.get_image(image_id, user_id)
        if backend_id:
            backend = common.get_backend(backend_id)
        else:
            backend = None

        connection_list = parse_connections(options["connections"])
        server = servers.create(user_id,
                                name,
                                password,
                                flavor,
                                image,
                                networks=connection_list,
                                use_backend=backend)
        pprint.pprint_server(server, stdout=self.stdout)

        wait = parse_bool(options["wait"])
        common.wait_server_task(server, wait, self.stdout)