コード例 #1
0
    def ifconfig(self):
        """
        Return the network information for this host.

        :returns: An :class:`IfConfig <deployer.utils.network.IfConfig>` instance.
        """
        # We add "cd /", to be sure that at least no error get thrown because
        # we're in a non existing directory right now.
        from deployer.utils import parse_ifconfig_output
        return parse_ifconfig_output(self._run_silent('cd /; /sbin/ifconfig'))
コード例 #2
0
ファイル: __init__.py プロジェクト: janfabry/python-deployer
    def ifconfig(self):
        """
        Return the network information for this host.

        :returns: A :class:`deployer.utils.IfConfig` instance.
        """
        # We add "cd /", to be sure that at least no error get thrown because
        # we're in a non existing directory right now.
        from deployer.utils import parse_ifconfig_output
        return parse_ifconfig_output(self._run_silent('cd /; /sbin/ifconfig'))
コード例 #3
0
    def test_node_initialisation(self):
        self.assertEqual(
            repr(parse_ifconfig_output(output_1)), "IfConfig(interfaces=[" +
            "NetworkInterface(name='eth0', ip='10.0.3.15'), " +
            "NetworkInterface(name='lo', ip='127.0.0.1'), " +
            "NetworkInterface(name='tap7', ip='46.29.46.232')])")

        self.assertEqual(
            repr(parse_ifconfig_output(output_2)), "IfConfig(interfaces=[" +
            "NetworkInterface(name='lo0', ip='127.0.0.1'), " +
            "NetworkInterface(name='en0', ip='10.126.120.72'), " +
            "NetworkInterface(name='en2', ip='10.126.100.28')])")

        # get_interface
        self.assertEqual(
            repr(parse_ifconfig_output(output_1).get_interface('eth0')),
            "NetworkInterface(name='eth0', ip='10.0.3.15')")
        self.assertRaises(AttributeError,
                          parse_ifconfig_output(output_1).get_interface,
                          'eth100')

        # get_adress
        self.assertEqual(
            repr(parse_ifconfig_output(output_1).get_address('10.0.3.15')),
            "NetworkInterface(name='eth0', ip='10.0.3.15')")
        self.assertRaises(AttributeError,
                          parse_ifconfig_output(output_1).get_address,
                          '10.100.100.100')
コード例 #4
0
    def test_node_initialisation(self):
        self.assertEqual(repr(parse_ifconfig_output(output_1)),
                "IfConfig(interfaces=[" +
                "NetworkInterface(name='eth0', ip='10.0.3.15'), " +
                "NetworkInterface(name='lo', ip='127.0.0.1'), " +
                "NetworkInterface(name='tap7', ip='46.29.46.232')])")

        self.assertEqual(repr(parse_ifconfig_output(output_2)),
                "IfConfig(interfaces=[" +
                "NetworkInterface(name='lo0', ip='127.0.0.1'), " +
                "NetworkInterface(name='en0', ip='10.126.120.72'), " +
                "NetworkInterface(name='en2', ip='10.126.100.28')])")

        # get_interface
        self.assertEqual(repr(parse_ifconfig_output(output_1).get_interface('eth0')),
                "NetworkInterface(name='eth0', ip='10.0.3.15')")
        self.assertRaises(AttributeError, parse_ifconfig_output(output_1).get_interface, 'eth100')

        # get_adress
        self.assertEqual(repr(parse_ifconfig_output(output_1).get_address('10.0.3.15')),
                "NetworkInterface(name='eth0', ip='10.0.3.15')")
        self.assertRaises(AttributeError, parse_ifconfig_output(output_1).get_address, '10.100.100.100')