예제 #1
0
 def test_get_interface(self, execute):
     # test centos 6.5
     platform.linux_distribution = mock.Mock(return_value=['', '6.5', ''])
     out = ['eth0      Link encap:Ethernet  HWaddr FA:16:3E:61:F2:CF',
            'inet addr:10.0.1.104  Bcast:10.0.1.255  Mask:255.255.255.0',
            'inet6 addr: fe80::f816:3eff:fe61:f2cf/64 Scope:Link',
            'UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1',
            'RX packets:20121 errors:0 dropped:0 overruns:0 frame:0',
            'TX packets:10163 errors:0 dropped:0 overruns:0 carrier:0',
            'collisions:0 txqueuelen:1000',
            'RX bytes:19492218 (18.5 MiB)  TX bytes:1173768 (1.1 MiB)']
     execute.return_value = (0, out)
     self.assertEqual(utils.get_interface('eth0')[0], 0)
     # test centos 7.0
     platform.linux_distribution = mock.Mock(return_value=['', '7.0', ''])
     out = ['eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500',
            'inet 10.0.1.101  netmask 255.255.255.0  broadcast 10.0.1.255',
            'inet6 fe80::f816:3eff:fe6f:1a9d  prefixlen 64  scopeid 0x20<l',
            'ether fa:16:3e:6f:1a:9d  txqueuelen 1000  (Ethernet)',
            'RX packets 415365  bytes 150440678 (143.4 MiB)',
            'RX errors 0  dropped 0  overruns 0  frame 0',
            'TX packets 275332  bytes 91891644 (87.6 MiB)',
            'TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0']
     execute.return_value = (0, out)
     self.assertEqual(utils.get_interface('eth0')[0], 0)
     # test other distribution
     platform.linux_distribution = mock.Mock(return_value=['', '6.6', ''])
     self.assertEqual(utils.get_interface('eth0')[0], 1)
예제 #2
0
 def test_get_interface(self, execute):
     # test centos 6.5
     platform.linux_distribution = mock.Mock(return_value=['', '6.5', ''])
     out = [
         'eth0      Link encap:Ethernet  HWaddr FA:16:3E:61:F2:CF',
         'inet addr:10.0.1.104  Bcast:10.0.1.255  Mask:255.255.255.0',
         'inet6 addr: fe80::f816:3eff:fe61:f2cf/64 Scope:Link',
         'UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1',
         'RX packets:20121 errors:0 dropped:0 overruns:0 frame:0',
         'TX packets:10163 errors:0 dropped:0 overruns:0 carrier:0',
         'collisions:0 txqueuelen:1000',
         'RX bytes:19492218 (18.5 MiB)  TX bytes:1173768 (1.1 MiB)'
     ]
     execute.return_value = (0, out)
     self.assertEqual(utils.get_interface('eth0')[0], 0)
     # test centos 7.0
     platform.linux_distribution = mock.Mock(return_value=['', '7.0', ''])
     out = [
         'eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500',
         'inet 10.0.1.101  netmask 255.255.255.0  broadcast 10.0.1.255',
         'inet6 fe80::f816:3eff:fe6f:1a9d  prefixlen 64  scopeid 0x20<l',
         'ether fa:16:3e:6f:1a:9d  txqueuelen 1000  (Ethernet)',
         'RX packets 415365  bytes 150440678 (143.4 MiB)',
         'RX errors 0  dropped 0  overruns 0  frame 0',
         'TX packets 275332  bytes 91891644 (87.6 MiB)',
         'TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0'
     ]
     execute.return_value = (0, out)
     self.assertEqual(utils.get_interface('eth0')[0], 0)
     # test centos 8.1
     platform.linux_distribution = mock.Mock(return_value=['', '7.1', ''])
     self.assertEqual(utils.get_interface('eth0')[0], 0)
     # test other distribution
     platform.linux_distribution = mock.Mock(return_value=['', '6.6', ''])
     self.assertEqual(utils.get_interface('eth0')[0], 1)
예제 #3
0
파일: api.py 프로젝트: vkdrao4git/steth
    def get_interface(self, interface='eth0'):
        """Interface info.

        ifconfig interface
        """
        LOG.info("RPC: get_interface interfae: %s" % interface)
        code, message, data = agent_utils.get_interface(interface)
        return agent_utils.make_response(code, message, data)
예제 #4
0
파일: api.py 프로젝트: jsonkey/steth
    def get_interface(self, interface='eth0'):
        """Interface info.

        ifconfig interface
        """
        LOG.info("RPC: get_interface interfae: %s" % interface)
        code, message, data = agent_utils.get_interface(interface)
        return agent_utils.make_response(code, message, data)