def test__sets_external_dhcp_when_not_managed_vlan(self):
     rack_controller = factory.make_RackController(interface=False)
     interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL,
                                        node=rack_controller)
     dhcp_ip = factory.make_ip_address()
     update_foreign_dhcp(rack_controller.system_id, interface.name, dhcp_ip)
     self.assertEquals(dhcp_ip, reload_object(interface.vlan).external_dhcp)
 def test__clears_external_dhcp_on_vlan(self):
     rack_controller = factory.make_RackController(interface=False)
     interface = factory.make_Interface(INTERFACE_TYPE.PHYSICAL,
                                        node=rack_controller)
     interface.vlan.external_dhcp = factory.make_ip_address()
     interface.vlan.save()
     update_foreign_dhcp(rack_controller.system_id, interface.name, None)
     self.assertIsNone(reload_object(interface.vlan).external_dhcp)
Exemple #3
0
 def test__logs_warning_for_external_dhcp_on_interface_no_vlan(self):
     rack_controller = factory.make_RackController(interface=False)
     interface = factory.make_Interface(
         INTERFACE_TYPE.PHYSICAL, node=rack_controller)
     dhcp_ip = factory.make_ip_address()
     interface.vlan = None
     interface.save()
     logger = self.useFixture(FakeLogger())
     update_foreign_dhcp(
         rack_controller.system_id, interface.name, dhcp_ip)
     self.assertThat(logger.output, DocTestMatches(
         "...DHCP server on an interface with no VLAN defined..."))
Exemple #4
0
 def test__clears_external_dhcp_when_managed_vlan(self):
     rack_controller = factory.make_RackController(interface=False)
     fabric = factory.make_Fabric()
     vlan = fabric.get_default_vlan()
     interface = factory.make_Interface(
         INTERFACE_TYPE.PHYSICAL, node=rack_controller, vlan=vlan)
     subnet = factory.make_Subnet()
     dhcp_ip = factory.pick_ip_in_Subnet(subnet)
     vlan.dhcp_on = True
     vlan.primary_rack = rack_controller
     vlan.external_dhcp = dhcp_ip
     vlan.save()
     factory.make_StaticIPAddress(
         alloc_type=IPADDRESS_TYPE.STICKY, ip=dhcp_ip,
         subnet=subnet, interface=interface)
     update_foreign_dhcp(
         rack_controller.system_id, interface.name, dhcp_ip)
     self.assertIsNone(reload_object(interface.vlan).external_dhcp)
 def test__doesnt_fail_if_interface_missing(self):
     rack_controller = factory.make_RackController()
     # No error should be raised.
     update_foreign_dhcp(rack_controller.system_id,
                         factory.make_name("eth"), None)