Esempio n. 1
0
def cmd_halt():
  """Shutdown the system.
  """
  for instance in all_instances():
    if instance.state == RUNNING:
      instance.stop()
  # TODO: stop postgresql
  supervisor.stop()
Esempio n. 2
0
def cmd_list():
  """Lists the existing instances.
  """
  instances = all_instances()
  for instance in instances:
    print "Instance: %s" % instance.iid
    print instance
  return instances
Esempio n. 3
0
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)
Esempio n. 4
0
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()
Esempio n. 5
0
def cmd_monitor():
  """Scans all the instances and stops those that can be stopped.
  """
  for instance in all_instances():
    instance.monitor()
  session.commit()