Exemplo n.º 1
0
    def testIsLocal(self):
        """test is_local()"""
        fqdn = socket.getfqdn()
        shortname = socket.gethostname().split(".", 1)[0]

        # Test shortname is local()
        srv = Server(shortname, ["%s@tcp" % shortname])
        self.assertTrue(srv.is_local())

        # Test fqdn is local()
        srv = Server(fqdn, ["%s@tcp" % fqdn])
        self.assertTrue(srv.is_local())

        # Test a dummy shortname should not be local
        shortname = shortname + "-shine-false-suffix"
        srv = Server(shortname, ["%s@tcp" % shortname])
        self.assertFalse(srv.is_local())

        # Test a false domain name with a good hostname
        othername = shortname + ".shine-false-tld"
        srv = Server(othername, ["%s@tcp" % othername])
        self.assertFalse(srv.is_local())

        # Test something else should not be local
        othername = fqdn + ".shine-false-tld"
        srv = Server(othername, ["%s@tcp" % othername])
        self.assertFalse(srv.is_local())

        # Check hostname methods are rightly seen as local
        self.assertTrue(Server(Server.hostname_short(), ["foo"]).is_local())
        self.assertTrue(Server(Server.hostname_long(), ["foo"]).is_local())
Exemplo n.º 2
0
    def testIsLocal(self):
        """test is_local()"""
        fqdn = socket.getfqdn()
        shortname = socket.gethostname().split('.', 1)[0]

        # Test shortname is local()
        srv = Server(shortname, ['%s@tcp' % shortname])
        self.assertTrue(srv.is_local())

        # Test fqdn is local()
        srv = Server(fqdn, ['%s@tcp' % fqdn])
        self.assertTrue(srv.is_local())

        # Test a dummy shortname should not be local
        shortname = shortname + "-shine-false-suffix"
        srv = Server(shortname, ['%s@tcp' % shortname])
        self.assertFalse(srv.is_local())

        # Test a false domain name with a good hostname
        othername = shortname + ".shine-false-tld"
        srv = Server(othername, ['%s@tcp' % othername])
        self.assertFalse(srv.is_local())

        # Test something else should not be local
        othername = fqdn + ".shine-false-tld"
        srv = Server(othername, ['%s@tcp' % othername])
        self.assertFalse(srv.is_local())

        # Check hostname methods are rightly seen as local
        self.assertTrue(Server(Server.hostname_short(), ['foo']).is_local())
        self.assertTrue(Server(Server.hostname_long(), ['foo']).is_local())
Exemplo n.º 3
0
 def init_execute(self):
     """
     Initialize execution of remote command, if needed. Should be called
     first from derived classes before really executing the command.
     """
     # Limit the scope of the command if called with local flag (-L) or
     # called remotely (-R).
     if self.has_local_flag():
         self.options.nodes = NodeSet(Server.hostname_short())
Exemplo n.º 4
0
 def init_execute(self):
     """
     Initialize execution of remote command, if needed. Should be called
     first from derived classes before really executing the command.
     """
     # Limit the scope of the command if called with local flag (-L) or
     # called remotely (-R).
     if self.has_local_flag():
         self.options.nodes = NodeSet(Server.hostname_short())
Exemplo n.º 5
0
    def testDistantServers(self):
        """test distant_servers()"""
        nodes = NodeSet("foo,bar")
        self.assertEqual(Server.distant_servers(nodes), nodes)

        nodes_short = nodes | NodeSet(Server.hostname_short())
        self.assertEqual(Server.distant_servers(nodes_short), nodes)

        nodes_long = nodes | NodeSet(Server.hostname_long())
        self.assertEqual(Server.distant_servers(nodes_long), nodes)
Exemplo n.º 6
0
    def testDistantServers(self):
        """test distant_servers()"""
        nodes = NodeSet("foo,bar")
        self.assertEqual(Server.distant_servers(nodes), nodes)

        nodes_short = nodes | NodeSet(Server.hostname_short())
        self.assertEqual(Server.distant_servers(nodes_short), nodes)

        nodes_long = nodes | NodeSet(Server.hostname_long())
        self.assertEqual(Server.distant_servers(nodes_long), nodes)
Exemplo n.º 7
0
 def testHostname(self):
     """test hostname resolution"""
     # Check hostname methods returns something
     self.assertTrue(Server.hostname_short())
     self.assertTrue(Server.hostname_long())
Exemplo n.º 8
0
 def testHostname(self):
     """test hostname resolution"""
     # Check hostname methods returns something
     self.assertTrue(Server.hostname_short())
     self.assertTrue(Server.hostname_long())