def testNormal(self):
        runtime.InitArchInfo()

        info = runtime.GetArchInfo()

        self.assertTrue(self.EXP_TYPES(info),
                        msg=("Doesn't match expected type description: %s" %
                             self.EXP_TYPES))
  def setUp(self):
    super(CmdlibTestCase, self).setUp()
    self._iallocator_patcher = None
    self._netutils_patcher = None
    self._ssh_patcher = None
    self._rpc_patcher = None

    try:
      runtime.InitArchInfo()
    except errors.ProgrammerError:
      # during tests, the arch info can be initialized multiple times
      pass

    self.ResetMocks()
Exemple #3
0
def CheckMasterd(options, args):
    """Initial checks whether to run or exit with a failure.

  """
    if args:  # masterd doesn't take any arguments
        print >> sys.stderr, ("Usage: %s [-f] [-d]" % sys.argv[0])
        sys.exit(constants.EXIT_FAILURE)

    ssconf.CheckMaster(options.debug)

    try:
        options.uid = pwd.getpwnam(constants.MASTERD_USER).pw_uid
        options.gid = grp.getgrnam(constants.DAEMONS_GROUP).gr_gid
    except KeyError:
        print >> sys.stderr, (
            "User or group not existing on system: %s:%s" %
            (constants.MASTERD_USER, constants.DAEMONS_GROUP))
        sys.exit(constants.EXIT_FAILURE)

    # Determine static runtime architecture information
    runtime.InitArchInfo()

    # Check the configuration is sane before anything else
    try:
        livelock = utils.livelock.LiveLock("masterd_check")
        config.GetConfig(None, livelock)
    except errors.ConfigVersionMismatch, err:
        v1 = "%s.%s.%s" % version.SplitVersion(err.args[0])
        v2 = "%s.%s.%s" % version.SplitVersion(err.args[1])
        print >> sys.stderr,  \
            ("Configuration version mismatch. The current Ganeti software"
             " expects version %s, but the on-disk configuration file has"
             " version %s. This is likely the result of upgrading the"
             " software without running the upgrade procedure. Please contact"
             " your cluster administrator or complete the upgrade using the"
             " cfgupgrade utility, after reading the upgrade notes." %
             (v1, v2))
        sys.exit(constants.EXIT_FAILURE)
    def testInitializeMultiple(self):
        runtime.InitArchInfo()

        self.assertRaises(errors.ProgrammerError, runtime.InitArchInfo)