def cmd_halt(): """Shutdown the system. """ for instance in all_instances(): if instance.state == RUNNING: instance.stop() # TODO: stop postgresql supervisor.stop()
def cmd_list(): """Lists the existing instances. """ instances = all_instances() for instance in instances: print "Instance: %s" % instance.iid print instance return instances
def cmd_clean(): """Drop database and remove all instances (useful for debugging). """ for instance in all_instances(): if instance.state == RUNNING: instance.stop() instance.purge() session.delete(instance) session.commit() #os.unlink(DB) system("rm -rf %s/nginx" % HOME)
def cmd_boot(): """Boot the system. Should only be called once after a reboot. """ Base.metadata.create_all(engine) # TODO: setup/start postgresql supervisor.gen_conf() setup_nginx() for instance in all_instances(): if instance.state == RUNNING: instance.state = READY instance.setup_nginx_config(reload=False) supervisor.start()
def cmd_monitor(): """Scans all the instances and stops those that can be stopped. """ for instance in all_instances(): instance.monitor() session.commit()