Ejemplo n.º 1
0
    def run_add(self):
        m = Machine(self.args.machine, user=self.args.username)
        t = Template(self.args.template, user=self.args.username)

        # grab the template we're associating to the machine
        try:
            t = self.cs.template_get(t, auth=True)

        except ServiceException as e:
            print(e)
            return 1

        # add template uuid to machine
        m.template = t.uuid

        # add machine bits that are specified
        if self.args.description is not None:
            m.description = self.args.description

        try:
            res = self.cs.machine_create(m)

        except ServiceException as e:
            print(e)
            return 1

        print(res)

        # update config with our newly added (registered) machine
        self.config.set('machine', 'uuid', res['uuid'])
        self.config.set('machine', 'key', res['key'])
        self.config.save()

        print('info: machine added.')
        return 0
Ejemplo n.º 2
0
    def run_add(self):
        m = Machine(self.args.machine, user=self.args.username)
        t = Template(self.args.template, user=self.args.username)

        # grab the template we're associating to the machine
        try:
            t = self.cs.template_get(t, auth=True, resolve_includes=False)

        except ServiceException as e:
            print(e)
            return 1

        # add template uuid to machine
        m.template = t.uuid

        # add machine bits that are specified
        if self.args.description is not None:
            m.description = self.args.description

        try:
            res = self.cs.machine_create(m)

        except ServiceException as e:
            print(e)
            return 1

        print(res)

        # update config with our newly added (registered) machine
        self.config.set('machine', 'uuid', res['uuid'])
        self.config.set('machine', 'key', res['key'])
        self.config.save()

        print('info: machine added.')
        return 0
Ejemplo n.º 3
0
    def run_update(self):
        m = Machine(self.args.machine, user=self.args.username)

        try:
            m = self.cs.machine_get(m)

        except ServiceException as e:
            print(e)
            return 1

        # add machine bits that are specified for update
        if self.args.template:
            t = Template(self.args.template, user=self.args.username)

            try:
                t = self.cs.template_get(t)

            except ServiceException as e:
                print(e)
                return 1

            m.template = t.uuid

        if self.args.name is not None:
            m.name = self.args.name

        if self.args.title is not None:
            m.title = self.args.title

        if self.args.title is not None:
            m.title = self.args.title

        if self.args.description is not None:
            m.description = self.args.description

        try:
            res = self.cs.machine_update(m)

        except ServiceException as e:
            print(e)
            return 1

        print('info: machine updated.')
        return 0
Ejemplo n.º 4
0
    def run_update(self):
        m = Machine(self.args.machine, user=self.args.username)

        try:
            m = self.cs.machine_get(m)

        except ServiceException as e:
            print(e)
            return 1

        # add machine bits that are specified for update
        if self.args.template:
            t = Template(self.args.template, user=self.args.username)

            try:
                t = self.cs.template_get(t, resolve_includes=False)

            except ServiceException as e:
                print(e)
                return 1

            m.template = t.uuid

        if self.args.name is not None:
            m.name = self.args.name

        if self.args.title is not None:
            m.title = self.args.title

        if self.args.title is not None:
            m.title = self.args.title

        if self.args.description is not None:
            m.description = self.args.description

        try:
            res = self.cs.machine_update(m)

        except ServiceException as e:
            print(e)
            return 1

        print('info: machine updated.')
        return 0