def test_routes_on_all_nics(self): routes = [ {'linklocal': False, 'dst': '3.0.0.0/8', 'gateway': '8.12.42.3'}, {'linklocal': False, 'dst': '4.0.0.0/8', 'gateway': '10.210.1.4'}] expected = { 'version': 1, 'config': [ {'mac_address': '90:b8:d0:d8:82:b4', 'mtu': 1500, 'name': 'net0', 'type': 'physical', 'subnets': [{'address': '8.12.42.26/24', 'gateway': '8.12.42.1', 'type': 'static', 'routes': [{'network': '3.0.0.0/8', 'gateway': '8.12.42.3'}, {'network': '4.0.0.0/8', 'gateway': '10.210.1.4'}]}]}, {'mac_address': '90:b8:d0:0a:51:31', 'mtu': 1500, 'name': 'net1', 'type': 'physical', 'subnets': [{'address': '10.210.1.27/24', 'type': 'static', 'routes': [{'network': '3.0.0.0/8', 'gateway': '8.12.42.3'}, {'network': '4.0.0.0/8', 'gateway': '10.210.1.4'}]}]}]} found = convert_net(SDC_NICS_SINGLE_GATEWAY, routes=routes) self.maxDiff = None self.assertEqual(expected, found)
def test_convert_simple_alt(self): expected = { 'version': 1, 'config': [{ 'name': 'net0', 'type': 'physical', 'subnets': [{ 'type': 'static', 'gateway': '8.12.42.1', 'address': '8.12.42.51/24' }], 'mtu': 1500, 'mac_address': '90:b8:d0:ae:64:51' }, { 'name': 'net1', 'type': 'physical', 'subnets': [{ 'type': 'static', 'address': '10.210.1.217/24' }], 'mtu': 1500, 'mac_address': '90:b8:d0:bd:4f:9c' }] } found = convert_net(SDC_NICS_ALT) self.assertEqual(expected, found)
def test_gateways_not_on_all_nics(self): expected = { 'version': 1, 'config': [{ 'mac_address': '90:b8:d0:d8:82:b4', 'mtu': 1500, 'name': 'net0', 'type': 'physical', 'subnets': [{ 'address': '8.12.42.26/24', 'gateway': '8.12.42.1', 'type': 'static' }] }, { 'mac_address': '90:b8:d0:0a:51:31', 'mtu': 1500, 'name': 'net1', 'type': 'physical', 'subnets': [{ 'address': '10.210.1.27/24', 'type': 'static' }] }] } found = convert_net(SDC_NICS_SINGLE_GATEWAY) self.assertEqual(expected, found)
def test_convert_simple_dhcp(self): expected = { "version": 1, "config": [ { "name": "net0", "type": "physical", "subnets": [{ "type": "static", "gateway": "8.12.42.1", "address": "8.12.42.51/24", }], "mtu": 1500, "mac_address": "90:b8:d0:ae:64:51", }, { "name": "net1", "type": "physical", "subnets": [{ "type": "dhcp4" }], "mtu": 1500, "mac_address": "90:b8:d0:bd:4f:9c", }, ], } found = convert_net(SDC_NICS_DHCP) self.assertEqual(expected, found)
def test_convert_simple(self): expected = { "version": 1, "config": [ { "name": "net0", "type": "physical", "subnets": [{ "type": "static", "gateway": "8.12.42.1", "address": "8.12.42.102/24", }], "mtu": 1500, "mac_address": "90:b8:d0:f5:e4:f5", }, { "name": "net1", "type": "physical", "subnets": [{ "type": "static", "address": "192.168.128.93/22" }], "mtu": 8500, "mac_address": "90:b8:d0:a5:ff:cd", }, ], } found = convert_net(SDC_NICS) self.assertEqual(expected, found)
def test_gateways_not_on_all_nics(self): expected = { "version": 1, "config": [ { "mac_address": "90:b8:d0:d8:82:b4", "mtu": 1500, "name": "net0", "type": "physical", "subnets": [{ "address": "8.12.42.26/24", "gateway": "8.12.42.1", "type": "static", }], }, { "mac_address": "90:b8:d0:0a:51:31", "mtu": 1500, "name": "net1", "type": "physical", "subnets": [{ "address": "10.210.1.27/24", "type": "static" }], }, ], } found = convert_net(SDC_NICS_SINGLE_GATEWAY) self.assertEqual(expected, found)
def test_convert_simple(self): expected = { 'version': 1, 'config': [{ 'name': 'net0', 'type': 'physical', 'subnets': [{ 'type': 'static', 'gateway': '8.12.42.1', 'address': '8.12.42.102/24' }], 'mtu': 1500, 'mac_address': '90:b8:d0:f5:e4:f5' }, { 'name': 'net1', 'type': 'physical', 'subnets': [{ 'type': 'static', 'address': '192.168.128.93/22' }], 'mtu': 8500, 'mac_address': '90:b8:d0:a5:ff:cd' }] } found = convert_net(SDC_NICS) self.assertEqual(expected, found)
def test_routes_on_all_nics(self): routes = [ {"linklocal": False, "dst": "3.0.0.0/8", "gateway": "8.12.42.3"}, {"linklocal": False, "dst": "4.0.0.0/8", "gateway": "10.210.1.4"}, ] expected = { "version": 1, "config": [ { "mac_address": "90:b8:d0:d8:82:b4", "mtu": 1500, "name": "net0", "type": "physical", "subnets": [ { "address": "8.12.42.26/24", "gateway": "8.12.42.1", "type": "static", "routes": [ { "network": "3.0.0.0/8", "gateway": "8.12.42.3", }, { "network": "4.0.0.0/8", "gateway": "10.210.1.4", }, ], } ], }, { "mac_address": "90:b8:d0:0a:51:31", "mtu": 1500, "name": "net1", "type": "physical", "subnets": [ { "address": "10.210.1.27/24", "type": "static", "routes": [ { "network": "3.0.0.0/8", "gateway": "8.12.42.3", }, { "network": "4.0.0.0/8", "gateway": "10.210.1.4", }, ], } ], }, ], } found = convert_net(SDC_NICS_SINGLE_GATEWAY, routes=routes) self.maxDiff = None self.assertEqual(expected, found)
def test_convert_simple_dhcp(self): expected = { 'version': 1, 'config': [ {'name': 'net0', 'type': 'physical', 'subnets': [{'type': 'static', 'gateway': '8.12.42.1', 'address': '8.12.42.51/24'}], 'mtu': 1500, 'mac_address': '90:b8:d0:ae:64:51'}, {'name': 'net1', 'type': 'physical', 'subnets': [{'type': 'dhcp4'}], 'mtu': 1500, 'mac_address': '90:b8:d0:bd:4f:9c'}]} found = convert_net(SDC_NICS_DHCP) self.assertEqual(expected, found)
def test_gateways_not_on_all_nics(self): expected = { 'version': 1, 'config': [ {'mac_address': '90:b8:d0:d8:82:b4', 'mtu': 1500, 'name': 'net0', 'type': 'physical', 'subnets': [{'address': '8.12.42.26/24', 'gateway': '8.12.42.1', 'type': 'static'}]}, {'mac_address': '90:b8:d0:0a:51:31', 'mtu': 1500, 'name': 'net1', 'type': 'physical', 'subnets': [{'address': '10.210.1.27/24', 'type': 'static'}]}]} found = convert_net(SDC_NICS_SINGLE_GATEWAY) self.assertEqual(expected, found)
def test_convert_simple(self): expected = { 'version': 1, 'config': [ {'name': 'net0', 'type': 'physical', 'subnets': [{'type': 'static', 'gateway': '8.12.42.1', 'address': '8.12.42.102/24'}], 'mtu': 1500, 'mac_address': '90:b8:d0:f5:e4:f5'}, {'name': 'net1', 'type': 'physical', 'subnets': [{'type': 'static', 'address': '192.168.128.93/22'}], 'mtu': 8500, 'mac_address': '90:b8:d0:a5:ff:cd'}]} found = convert_net(SDC_NICS) self.assertEqual(expected, found)
def test_convert_simple_both_ipv4_ipv6(self): expected = { "version": 1, "config": [ { "mac_address": "90:b8:d0:ae:64:51", "mtu": 1500, "name": "net0", "type": "physical", "subnets": [ { "address": "2001::10/64", "gateway": "2001::1", "type": "static", }, { "address": "8.12.42.51/24", "gateway": "8.12.42.1", "type": "static", }, { "address": "2001::11/64", "type": "static" }, { "address": "8.12.42.52/32", "type": "static" }, ], }, { "mac_address": "90:b8:d0:bd:4f:9c", "mtu": 1500, "name": "net1", "type": "physical", "subnets": [{ "address": "10.210.1.217/24", "type": "static" }], }, ], } found = convert_net(SDC_NICS_IPV4_IPV6) self.assertEqual(expected, found)
def test_convert_simple_multi_ipv6(self): expected = { 'version': 1, 'config': [ {'name': 'net0', 'type': 'physical', 'subnets': [{'type': 'static', 'address': '2001:4800:78ff:1b:be76:4eff:fe06:96b3/64'}, {'type': 'static', 'gateway': '8.12.42.1', 'address': '8.12.42.51/24'}], 'mtu': 1500, 'mac_address': '90:b8:d0:ae:64:51'}, {'name': 'net1', 'type': 'physical', 'subnets': [{'type': 'static', 'address': '10.210.1.217/24'}], 'mtu': 1500, 'mac_address': '90:b8:d0:bd:4f:9c'}]} found = convert_net(SDC_NICS_MIP_IPV6) self.assertEqual(expected, found)
def test_convert_with_dns(self): expected = { 'version': 1, 'config': [ {'name': 'net0', 'type': 'physical', 'subnets': [{'type': 'static', 'gateway': '8.12.42.1', 'address': '8.12.42.51/24'}], 'mtu': 1500, 'mac_address': '90:b8:d0:ae:64:51'}, {'name': 'net1', 'type': 'physical', 'subnets': [{'type': 'dhcp4'}], 'mtu': 1500, 'mac_address': '90:b8:d0:bd:4f:9c'}, {'type': 'nameserver', 'address': ['8.8.8.8', '8.8.8.1'], 'search': ["local"]}]} found = convert_net( network_data=SDC_NICS_DHCP, dns_servers=['8.8.8.8', '8.8.8.1'], dns_domain="local") self.assertEqual(expected, found)
def test_convert_simple_both_ipv4_ipv6(self): expected = { 'version': 1, 'config': [{ 'mac_address': '90:b8:d0:ae:64:51', 'mtu': 1500, 'name': 'net0', 'type': 'physical', 'subnets': [{ 'address': '2001::10/64', 'gateway': '2001::1', 'type': 'static' }, { 'address': '8.12.42.51/24', 'gateway': '8.12.42.1', 'type': 'static' }, { 'address': '2001::11/64', 'type': 'static' }, { 'address': '8.12.42.52/32', 'type': 'static' }] }, { 'mac_address': '90:b8:d0:bd:4f:9c', 'mtu': 1500, 'name': 'net1', 'type': 'physical', 'subnets': [{ 'address': '10.210.1.217/24', 'type': 'static' }] }] } found = convert_net(SDC_NICS_IPV4_IPV6) self.assertEqual(expected, found)
def test_convert_simple_both_ipv4_ipv6(self): expected = { 'version': 1, 'config': [ {'mac_address': '90:b8:d0:ae:64:51', 'mtu': 1500, 'name': 'net0', 'type': 'physical', 'subnets': [{'address': '2001::10/64', 'gateway': '2001::1', 'type': 'static'}, {'address': '8.12.42.51/24', 'gateway': '8.12.42.1', 'type': 'static'}, {'address': '2001::11/64', 'type': 'static'}, {'address': '8.12.42.52/32', 'type': 'static'}]}, {'mac_address': '90:b8:d0:bd:4f:9c', 'mtu': 1500, 'name': 'net1', 'type': 'physical', 'subnets': [{'address': '10.210.1.217/24', 'type': 'static'}]}]} found = convert_net(SDC_NICS_IPV4_IPV6) self.assertEqual(expected, found)
def test_convert_with_dns(self): expected = { "version": 1, "config": [ { "name": "net0", "type": "physical", "subnets": [{ "type": "static", "gateway": "8.12.42.1", "address": "8.12.42.51/24", }], "mtu": 1500, "mac_address": "90:b8:d0:ae:64:51", }, { "name": "net1", "type": "physical", "subnets": [{ "type": "dhcp4" }], "mtu": 1500, "mac_address": "90:b8:d0:bd:4f:9c", }, { "type": "nameserver", "address": ["8.8.8.8", "8.8.8.1"], "search": ["local"], }, ], } found = convert_net( network_data=SDC_NICS_DHCP, dns_servers=["8.8.8.8", "8.8.8.1"], dns_domain="local", ) self.assertEqual(expected, found)
def test_convert_simple_multi_ipv6(self): expected = { "version": 1, "config": [ { "name": "net0", "type": "physical", "subnets": [ { "type": "static", "address": ("2001:4800:78ff:1b:be76:4eff:fe06:96b3/64"), }, { "type": "static", "gateway": "8.12.42.1", "address": "8.12.42.51/24", }, ], "mtu": 1500, "mac_address": "90:b8:d0:ae:64:51", }, { "name": "net1", "type": "physical", "subnets": [{ "type": "static", "address": "10.210.1.217/24" }], "mtu": 1500, "mac_address": "90:b8:d0:bd:4f:9c", }, ], } found = convert_net(SDC_NICS_MIP_IPV6) self.assertEqual(expected, found)