Ejemplo n.º 1
0
def setup_logging(file_template):
    """ Sets up the log file.
  Args:      file_template (str): Template file name for the log file
  """
    os.path.exists("/tmp") or os.mkdir("/tmp")
    initialize("/tmp/%s.log" % file_template)
    print "Logging to file /tmp/%s.log" % file_template
Ejemplo n.º 2
0
def main(argv):
  """Main function that parses command-line options and arguments and
  checks for undefined gflags in them.

  Arguments:
    argv: list of command-line arguments
  """
  # Setup logging.
  gflags.FLAGS.logtostderr = True
  log.initialize()

  check_undefined_gflags(_parse_cmd_line_opts_args(argv))

  if UNDEFINED_GFLAG_FOUND:
    sys.exit(1)
Ejemplo n.º 3
0
import sys
import os

sys.path.append("/home/nutanix/bin")
import env

sys.path.append(".")
from zeus_util import ZeusUtil

import util.base.log as log
#from qa.tools.serviceability.capacity_planning_fw_tools.zeus_util import ZeusUtil

if __name__ == "__main__":
    ip = sys.argv[1]
    uuid = sys.argv[2]
    cluster_name = sys.argv[3]
    log.initialize("zeus.log")
    print ip, uuid, cluster_name
    zeus_util = ZeusUtil(ip)
    #zeus_util.clean_zeus()
    #zeus_util.create_pe_entry(uuid)
    zeus_util.create_external_cluster_entry(uuid)
    zeus_util.create_zeusconfig_entry(uuid, cluster_name, None)
    zeus_util.create_clusterdatastate_entry(uuid)

    print zeus_util.read_zeusconfig_entry(uuid)
                 "compute_node_list and management_server_list")
        return 0

    if FLAGS.start_cvm:
        if not FLAGS.host_ip:
            log.ERROR("Please provide host ip to start cvm on")
            return 1
        return start_cvm(FLAGS.host_ip)


if __name__ == "__main__":
    try:
        global __doc__
        __doc__ = "Usage: %s [flags]\nTry %s --help" % (sys.argv[0],
                                                        sys.argv[0])
        args = FLAGS(sys.argv)
        FLAGS.logtostderr = True
        log.initialize()
        sys.exit(main())
    except gflags.FlagsError, e:
        log.ERROR("%s\n%s\n" % (str(e), __doc__))
        sys.exit(1)
    except KeyboardInterrupt:
        log.WARNING("Exiting on Ctrl-C")
        sys.exit(1)
    except Exception as ex:
        log.ERROR(traceback.format_exc())
        log.ERROR("Failed to execute action %s error (%s), exiting.." %
                  (args[0], str(ex)))
        sys.exit(1)