示例#1
0
 def test_handle_rhel_like_arping(self, m_subp):
     """Test handle on RHEL-like distros."""
     items = [{
         'source': '172.16.6.104',
         'destination': '172.17.0.2',
     }]
     ds.gratuitous_arp(items, self._fetch_distro('fedora'))
     self.assertEqual([
         mock.call(
             ['arping', '-c', '2', '-s', '172.16.6.104', '172.17.0.2'])
     ], m_subp.call_args_list)
 def test_handle_rhel_like_arping(self, m_subp):
     """Test handle on RHEL-like distros."""
     items = [{
         "source": "172.16.6.104",
         "destination": "172.17.0.2",
     }]
     ds.gratuitous_arp(items, self._fetch_distro("fedora"))
     self.assertEqual(
         [
             mock.call(
                 ["arping", "-c", "2", "-s", "172.16.6.104", "172.17.0.2"])
         ],
         m_subp.call_args_list,
     )
示例#3
0
 def test_generate_network_config(self):
     expected = {
         'version': 1,
         'config': [
             {
                 'subnets': [
                     {'control': 'auto',
                      'dns_nameservers': ['8.8.8.8', '8.8.4.4'],
                      'netmask': '255.255.248.0',
                      'address': '62.181.8.174',
                      'type': 'static', 'gateway': '62.181.8.1'}
                 ],
                 'type': 'physical',
                 'name': 'eth0',
                 'mac_address': '00:15:5d:ff:0f:03'
             },
             {
                 'subnets': [
                     {'control': 'auto',
                      'dns_nameservers': ['9.9.9.9', '8.8.8.8'],
                      'netmask': '255.255.255.0',
                      'address': '10.209.78.11',
                      'type': 'static',
                      'gateway': '10.209.78.1'}
                 ],
                 'type': 'physical',
                 'name': 'eth1',
                 'mac_address': '00:15:5d:ff:0f:24'
             }
         ]
     }
     self.assertTrue(
         ds.generate_network_config(CLOUD_METADATA['netadp']),
         expected
     )
示例#4
0
    def test_seed_read_user_data_callback_valid_disk(self):
        populate_user_metadata(self.seed_dir, '')
        populate_cloud_metadata(self.seed_dir, CLOUD_METADATA)
        results = ds.read_user_data_callback(self.seed_dir)

        self.assertNotEqual(results, None)
        self.assertTrue('userdata' in results)
        self.assertTrue('metadata' in results)
        self.assertTrue('cfg' in results)
示例#5
0
 def test_continue_on_arping_error(self, m_subp):
     """Continue when command error"""
     items = [
         {
             'destination': '172.17.0.2',
             'source': '172.16.6.104'
         },
         {
             'destination': '172.17.0.2',
             'source': '172.16.6.104',
         },
     ]
     ds.gratuitous_arp(items, self._fetch_distro('ubuntu'))
     self.assertEqual([
         mock.call(
             ['arping', '-c', '2', '-S', '172.16.6.104', '172.17.0.2']),
         mock.call(
             ['arping', '-c', '2', '-S', '172.16.6.104', '172.17.0.2'])
     ], m_subp.call_args_list)
示例#6
0
 def test_gratuitous_arp_run_standard_arping(self, m_subp):
     """Test handle run arping & parameters."""
     items = [
         {
             'destination': '172.17.0.2',
             'source': '172.16.6.104'
         },
         {
             'destination': '172.17.0.2',
             'source': '172.16.6.104',
         },
     ]
     ds.gratuitous_arp(items, self._fetch_distro('ubuntu'))
     self.assertEqual([
         mock.call(
             ['arping', '-c', '2', '-S', '172.16.6.104', '172.17.0.2']),
         mock.call(
             ['arping', '-c', '2', '-S', '172.16.6.104', '172.17.0.2'])
     ], m_subp.call_args_list)
示例#7
0
    def test_seed_read_user_data_callback_userdata(self):
        userdata = "#!/bin/sh\nexit 1"
        populate_user_metadata(self.seed_dir, userdata)
        populate_cloud_metadata(self.seed_dir, CLOUD_METADATA)

        results = ds.read_user_data_callback(self.seed_dir)

        self.assertNotEqual(results, None)
        self.assertTrue('userdata' in results)
        self.assertEqual(results['userdata'], userdata)
 def test_continue_on_arping_error(self, m_subp):
     """Continue when command error"""
     items = [
         {
             "destination": "172.17.0.2",
             "source": "172.16.6.104"
         },
         {
             "destination": "172.17.0.2",
             "source": "172.16.6.104",
         },
     ]
     ds.gratuitous_arp(items, self._fetch_distro("ubuntu"))
     self.assertEqual(
         [
             mock.call(
                 ["arping", "-c", "2", "-S", "172.16.6.104", "172.17.0.2"]),
             mock.call(
                 ["arping", "-c", "2", "-S", "172.16.6.104", "172.17.0.2"]),
         ],
         m_subp.call_args_list,
     )
 def test_gratuitous_arp_run_standard_arping(self, m_subp):
     """Test handle run arping & parameters."""
     items = [
         {
             "destination": "172.17.0.2",
             "source": "172.16.6.104"
         },
         {
             "destination": "172.17.0.2",
             "source": "172.16.6.104",
         },
     ]
     ds.gratuitous_arp(items, self._fetch_distro("ubuntu"))
     self.assertEqual(
         [
             mock.call(
                 ["arping", "-c", "2", "-S", "172.16.6.104", "172.17.0.2"]),
             mock.call(
                 ["arping", "-c", "2", "-S", "172.16.6.104", "172.17.0.2"]),
         ],
         m_subp.call_args_list,
     )
 def test_generate_network_config(self):
     expected = {
         "version":
         1,
         "config": [
             {
                 "subnets": [{
                     "control": "auto",
                     "dns_nameservers": ["8.8.8.8", "8.8.4.4"],
                     "netmask": "255.255.248.0",
                     "address": "62.181.8.174",
                     "type": "static",
                     "gateway": "62.181.8.1",
                 }],
                 "type":
                 "physical",
                 "name":
                 "eth0",
                 "mac_address":
                 "00:15:5d:ff:0f:03",
             },
             {
                 "subnets": [{
                     "control": "auto",
                     "dns_nameservers": ["9.9.9.9", "8.8.8.8"],
                     "netmask": "255.255.255.0",
                     "address": "10.209.78.11",
                     "type": "static",
                     "gateway": "10.209.78.1",
                 }],
                 "type":
                 "physical",
                 "name":
                 "eth1",
                 "mac_address":
                 "00:15:5d:ff:0f:24",
             },
         ],
     }
     self.assertTrue(ds.generate_network_config(CLOUD_METADATA["netadp"]),
                     expected)
示例#11
0
    def test_seed_read_user_data_callback_empty_file(self):
        populate_user_metadata(self.seed_dir, '')
        populate_cloud_metadata(self.seed_dir, {})
        results = ds.read_user_data_callback(self.seed_dir)

        self.assertIsNone(results)