def start(droplet_id=None, **_): """ XXX Starts a new Droplet, if it exists, otherwise creates a new one and starts it. does not check back for success. :param droplet_id: :return: None """ def start_droplet(droplet): for action in droplet.get_actions(): action.load() ctx.logger.debug("Executing action '{0}' for droplet '{1}'..." % [str(action), str(droplet)]) if droplet_id is None: ctx.logger.info("Creating, then starting a new droplet.") start_droplet(create()) else: ctx.logger.info("Starting existing droplet. Droplet id = '{0}'." .format(droplet_id)) d = get_droplet(droplet_id) if d is not None: start_droplet(d) else: raise NonRecoverableError( droplet_does_not_exist_for_operation("start", droplet_id)) # TODO need to check back later to see that the start operation has # failed or succeeded or is still processing pass
def start(droplet_id=None, **_): """ XXX Starts a new Droplet, if it exists, otherwise creates a new one and starts it. does not check back for success. :param droplet_id: :return: None """ def start_droplet(droplet): for action in droplet.get_actions(): action.load() ctx.logger.debug("Executing action '{0}' for droplet '{1}'..." % [str(action), str(droplet)]) if droplet_id is None: ctx.logger.info("Creating, then starting a new droplet.") start_droplet(create()) else: ctx.logger.info( "Starting existing droplet. Droplet id = '{0}'.".format( droplet_id)) d = get_droplet(droplet_id) if d is not None: start_droplet(d) else: raise NonRecoverableError( droplet_does_not_exist_for_operation("start", droplet_id)) # TODO need to check back later to see that the start operation has # failed or succeeded or is still processing pass
def stop(droplet_id, **_): """ XXX Asks the API to destroy a droplet, if it exists. Does not check back for success. :param droplet_id: :return: None """ d = get_droplet(droplet_id) if d is None: raise NonRecoverableError( droplet_does_not_exist_for_operation("stop", droplet_id)) else: ctx.logger.info("Stopping droplet with droplet id = '{0}'." .format(droplet_id)) d.destroy() # TODO need to check back later to see that the start operation has # failed or succeeded or is still processing pass
def stop(droplet_id, **_): """ XXX Asks the API to destroy a droplet, if it exists. Does not check back for success. :param droplet_id: :return: None """ d = get_droplet(droplet_id) if d is None: raise NonRecoverableError( droplet_does_not_exist_for_operation("stop", droplet_id)) else: ctx.logger.info( "Stopping droplet with droplet id = '{0}'.".format(droplet_id)) d.destroy() # TODO need to check back later to see that the start operation has # failed or succeeded or is still processing pass