示例#1
0
文件: aws.py 项目: yashrane015/botox
 def terminate(self, arg):
     """
     Terminate instance with given EC2 ID or nametag.
     """
     instance = self.get(arg)
     with self.msg("Terminating %s (%s): " % (instance.name, instance.id)):
         instance.rename("old-%s" % instance.name)
         instance.terminate()
         while instance.state != 'terminated':
             time.sleep(5)
             self.log(".", end='')
             instance.update()
示例#2
0
文件: aws.py 项目: bitprophet/botox
 def terminate(self, arg):
     """
     Terminate instance with given EC2 ID or nametag.
     """
     instance = self.get(arg)
     with self.msg("Terminating %s (%s): " % (instance.name, instance.id)):
         instance.rename("old-%s" % instance.name)
         instance.terminate()
         while instance.state != 'terminated':
             time.sleep(5)
             self.log(".", end='')
             instance.update()
示例#3
0
文件: aws.py 项目: bitprophet/botox
    def create(self, hostname, **kwargs):
        """
        Create new EC2 instance named ``hostname``.

        You may specify keyword arguments matching those of ``__init__`` (e.g.
        ``size``, ``ami``) to override any defaults given when the object was
        created, or to fill in parameters not given at initialization time.

        Additional parameters that are instance-specific:

        * ``ip``: The static private IP address for the new host.

        This method returns a ``boto.EC2.instance.Instance`` object.
        """
        # Create
        creating = "Creating '%s' (a %s instance of %s)" % (
            hostname, kwargs['size'], kwargs['ami']
        )
        with self.msg(creating):
            instance = self._create(hostname, kwargs)

        # Name
        with self.msg("Tagging as '%s'" % hostname):
            try:
                instance.rename(hostname)
            # One-time retry for API errors when setting tags
            except _ResponseError:
                time.sleep(1)
                instance.rename(hostname)

        # Wait for it to finish booting
        with self.msg("Waiting for boot: "):
            tick = 5
            while instance.state != 'running':
                self.log(".", end='')
                time.sleep(tick)
                instance.update()

        return instance
示例#4
0
文件: aws.py 项目: yashrane015/botox
    def create(self, hostname, **kwargs):
        """
        Create new EC2 instance named ``hostname``.

        You may specify keyword arguments matching those of ``__init__`` (e.g.
        ``size``, ``ami``) to override any defaults given when the object was
        created, or to fill in parameters not given at initialization time.

        Additional parameters that are instance-specific:

        * ``ip``: The static private IP address for the new host.

        This method returns a ``boto.EC2.instance.Instance`` object.
        """
        # Create
        creating = "Creating '%s' (a %s instance of %s)" % (
            hostname, kwargs['size'], kwargs['ami'])
        with self.msg(creating):
            instance = self._create(hostname, kwargs)

        # Name
        with self.msg("Tagging as '%s'" % hostname):
            try:
                instance.rename(hostname)
            # One-time retry for API errors when setting tags
            except _ResponseError:
                time.sleep(1)
                instance.rename(hostname)

        # Wait for it to finish booting
        with self.msg("Waiting for boot: "):
            tick = 5
            while instance.state != 'running':
                self.log(".", end='')
                time.sleep(tick)
                instance.update()

        return instance