コード例 #1
0
    def test_ip_xml(self):
        """
        Test network ip xml
        """
        dhcp_range = {"start": "192.168.122.100", "end": "192.168.122.254"}
        params = {}

        dhcp = nxml._get_dhcp_elem(**params)
        self.assertEquals(None, dhcp)

        params["net"] = "192.168.122.0/255.255.255.0"
        params["dhcp"] = {'range': dhcp_range}
        xml = ET.tostring(nxml._get_ip_elem(**params))
        start = xpath_get_text(xml, "/ip/dhcp/range/@start")[0]
        end = xpath_get_text(xml, "/ip/dhcp/range/@end")[0]
        self.assertEquals(dhcp_range['start'], start)
        self.assertEquals(dhcp_range['end'], end)

        address = xpath_get_text(xml, "/ip/@address")[0]
        netmask = xpath_get_text(xml, "/ip/@netmask")[0]
        self.assertEquals(address, params["net"].split("/")[0])
        self.assertEquals(netmask, params["net"].split("/")[1])

        # test _get_ip_xml can accepts strings: '192.168.122.0/24',
        # which is same as "192.168.122.0/255.255.255.0"
        params["net"] = "192.168.122.0/24"
        xml = ET.tostring(nxml._get_ip_elem(**params))
        netmask = xpath_get_text(xml, "/ip/@netmask")[0]
        self.assertEquals(netmask,
                          str(ipaddr.IPNetwork(params["net"]).netmask))
コード例 #2
0
ファイル: test_networkxml.py プロジェクト: zhangy0gg/kimchi
    def test_ip_xml(self):
        """
        Test network ip xml
        """
        dhcp_range = {'start': '192.168.122.100', 'end': '192.168.122.254'}
        params = {}

        dhcp = nxml._get_dhcp_elem(**params)
        self.assertEqual(None, dhcp)

        params['net'] = '192.168.122.0/255.255.255.0'
        params['dhcp'] = {'range': dhcp_range}
        xml = ET.tostring(nxml._get_ip_elem(**params), encoding='unicode')
        start = xpath_get_text(xml, '/ip/dhcp/range/@start')[0]
        end = xpath_get_text(xml, '/ip/dhcp/range/@end')[0]
        self.assertEqual(dhcp_range['start'], start)
        self.assertEqual(dhcp_range['end'], end)

        address = xpath_get_text(xml, '/ip/@address')[0]
        netmask = xpath_get_text(xml, '/ip/@netmask')[0]
        self.assertEqual(address, params['net'].split('/')[0])
        self.assertEqual(netmask, params['net'].split('/')[1])

        # test _get_ip_xml can accepts strings: '192.168.122.0/24',
        # which is same as "192.168.122.0/255.255.255.0"
        params['net'] = '192.168.122.0/24'
        xml = ET.tostring(nxml._get_ip_elem(**params), encoding='unicode')
        netmask = xpath_get_text(xml, '/ip/@netmask')[0]
        self.assertEqual(netmask, str(ipaddr.IPNetwork(params['net']).netmask))
コード例 #3
0
ファイル: test_networkxml.py プロジェクト: alinefm/kimchi
    def test_ip_xml(self):
        """
        Test network ip xml
        """
        dhcp_range = {'start': '192.168.122.100', 'end': '192.168.122.254'}
        params = {}

        dhcp = nxml._get_dhcp_elem(**params)
        self.assertEqual(None, dhcp)

        params['net'] = '192.168.122.0/255.255.255.0'
        params['dhcp'] = {'range': dhcp_range}
        xml = ET.tostring(nxml._get_ip_elem(**params))
        start = xpath_get_text(xml, '/ip/dhcp/range/@start')[0]
        end = xpath_get_text(xml, '/ip/dhcp/range/@end')[0]
        self.assertEqual(dhcp_range['start'], start)
        self.assertEqual(dhcp_range['end'], end)

        address = xpath_get_text(xml, '/ip/@address')[0]
        netmask = xpath_get_text(xml, '/ip/@netmask')[0]
        self.assertEqual(address, params['net'].split('/')[0])
        self.assertEqual(netmask, params['net'].split('/')[1])

        # test _get_ip_xml can accepts strings: '192.168.122.0/24',
        # which is same as "192.168.122.0/255.255.255.0"
        params['net'] = '192.168.122.0/24'
        xml = ET.tostring(nxml._get_ip_elem(**params))
        netmask = xpath_get_text(xml, '/ip/@netmask')[0]
        self.assertEqual(netmask, str(ipaddr.IPNetwork(params['net']).netmask))
コード例 #4
0
ファイル: test_networkxml.py プロジェクト: madhawa/kimchi
    def test_ip_xml(self):
        """
        Test network ip xml
        """
        dhcp_range = {"start": "192.168.122.100", "end": "192.168.122.254"}
        params = {}

        dhcp = nxml._get_dhcp_elem(**params)
        self.assertEquals(None, dhcp)

        params["net"] = "192.168.122.0/255.255.255.0"
        params["dhcp"] = {'range': dhcp_range}
        xml = ET.tostring(nxml._get_ip_elem(**params))
        start = xpath_get_text(xml, "/ip/dhcp/range/@start")[0]
        end = xpath_get_text(xml, "/ip/dhcp/range/@end")[0]
        self.assertEquals(dhcp_range['start'], start)
        self.assertEquals(dhcp_range['end'], end)

        address = xpath_get_text(xml, "/ip/@address")[0]
        netmask = xpath_get_text(xml, "/ip/@netmask")[0]
        self.assertEquals(address, params["net"].split("/")[0])
        self.assertEquals(netmask, params["net"].split("/")[1])

        # test _get_ip_xml can accepts strings: '192.168.122.0/24',
        # which is same as "192.168.122.0/255.255.255.0"
        params["net"] = "192.168.122.0/24"
        xml = ET.tostring(nxml._get_ip_elem(**params))
        netmask = xpath_get_text(xml, "/ip/@netmask")[0]
        self.assertEquals(netmask,
                          str(ipaddr.IPNetwork(params["net"]).netmask))