Ejemplo n.º 1
0
    def create(self, **kwargs):
        # we always want the verbose response here
        kwargs['verbose'] = True

        if 'user' not in kwargs:
            kwargs['user'] = '******'

        if self.client.version >= (2, 0):
            if 'userRunAs' not in kwargs:
                kwargs['userRunAs'] = 'root'

        if 'ssh_key_path' in kwargs:
            ssh_key_path = os.path.expanduser(kwargs.pop('ssh_key_path'))
            with open(ssh_key_path) as ssh_key_file:
                kwargs['sshKey'] = ssh_key_file.read()

        if 'sshKey' not in kwargs:
            raise exceptions.BadRequest(
                "You must pass in a private ssh key to bootstrap hosts")

        data = self._generate_input_dict(**kwargs)
        self.load(
            self.client.post(self.url,
                             content_type="application/json",
                             data=data))
        # this special case morphs the object URL after creation since we don't
        # know the requestId ahead of time
        self._hosts = kwargs['hosts']
        self._href = None
        return self
Ejemplo n.º 2
0
    def skip(self):
        if not self.skippable:
            raise exceptions.BadRequest("Upgrade Item is not skippable")

        if self.status == 'HOLDING_TIMEDOUT':
            return self.update(status='TIMEDOUT')

        return self.update(status='FAILED')