예제 #1
0
    def test_server_hostnames_multiple_override(self):
        hostname.cached_server_hostnames = []
        fd = tempfile.mkstemp(text=True)
        tmpname = fd[1]
        os.close(fd[0])
        os.chmod(tmpname, os.stat(tmpname).st_mode | stat.S_IXUSR)

        tmpfile = file(tmpname, "w+")
        config = AmbariConfig()
        try:
            tmpfile.write(
                "#!/bin/sh\n\necho 'host1.example.com, host2.example.com, host3.example.com'"
            )
            tmpfile.close()

            config.set('server', 'hostname_script', tmpname)

            expected_hostnames = [
                'host1.example.com', 'host2.example.com', 'host3.example.com'
            ]
            server_hostnames = hostname.server_hostnames(config)
            self.assertEquals(
                server_hostnames, expected_hostnames,
                "expected hostnames {0}; got {1}".format(
                    expected_hostnames, server_hostnames))
        finally:
            os.remove(tmpname)
            config.remove_option('server', 'hostname_script')
        pass
예제 #2
0
 def test_server_hostnames(self):
   hostname.cached_server_hostnames = []
   config = AmbariConfig()
   default_server_hostname = config.get('server', 'hostname')
   config.set('server', 'hostname', 'ambari-host')
   server_hostnames = hostname.server_hostnames(config)
   self.assertEquals(['ambari-host'], server_hostnames,
                     "expected host name ['ambari-host']; got {0}".format(server_hostnames))
   config.set('server', 'hostname', default_server_hostname)
   pass
예제 #3
0
 def test_server_hostnames(self):
     hostname.cached_server_hostnames = []
     config = AmbariConfig()
     default_server_hostname = config.get('server', 'hostname')
     config.set('server', 'hostname', 'ambari-host')
     server_hostnames = hostname.server_hostnames(config)
     self.assertEquals(['ambari-host'], server_hostnames,
                       "expected host name ['ambari-host']; got {0}".format(
                           server_hostnames))
     config.set('server', 'hostname', default_server_hostname)
     pass
예제 #4
0
  def test_server_hostnames_override(self):
    hostname.cached_server_hostnames = []
    fd = tempfile.mkstemp(text=True)
    tmpname = fd[1]
    os.close(fd[0])
    os.chmod(tmpname, os.stat(tmpname).st_mode | stat.S_IXUSR)

    tmpfile = file(tmpname, "w+")
    config = AmbariConfig()
    try:
      tmpfile.write("#!/bin/sh\n\necho 'test.example.com'")
      tmpfile.close()

      config.set('server', 'hostname_script', tmpname)

      server_hostnames = hostname.server_hostnames(config)
      self.assertEquals(server_hostnames, ['test.example.com'], "expected hostname ['test.example.com']; got {0}".format(server_hostnames))
    finally:
      os.remove(tmpname)
      config.remove_option('server', 'hostname_script')
    pass