def _cleanup(net, subnet, router, gateway): with cb_helpers.cleanup_action( lambda: helpers.cleanup_network(net)): with cb_helpers.cleanup_action( lambda: helpers.cleanup_subnet(subnet)): with cb_helpers.cleanup_action(lambda: router.delete()): with cb_helpers.cleanup_action( lambda: helpers.cleanup_gateway(gateway)): router.detach_subnet(subnet) router.detach_gateway(gateway)
def test_crud_floating_ip(self): gw = helpers.get_test_gateway(self.provider) def create_fip(label): fip = gw.floating_ips.create() return fip def cleanup_fip(fip): if fip: gw.floating_ips.delete(fip.id) with cb_helpers.cleanup_action(lambda: helpers.cleanup_gateway(gw)): sit.check_crud(self, gw.floating_ips, FloatingIP, "cb-crudfip", create_fip, cleanup_fip, skip_name_check=True)
def test_floating_ip_properties(self): # Check floating IP address gw = helpers.get_test_gateway(self.provider) fip = gw.floating_ips.create() with cb_helpers.cleanup_action(lambda: helpers.cleanup_gateway(gw)): with cb_helpers.cleanup_action(lambda: fip.delete()): fipl = list(gw.floating_ips) self.assertIn(fip, fipl) # 2016-08: address filtering not implemented in moto # empty_ipl = self.provider.network.floating_ips('dummy-net') # self.assertFalse( # empty_ipl, # "Bogus network should not have any floating IPs: {0}" # .format(empty_ipl)) self.assertFalse( fip.private_ip, "Floating IP should not have a private IP value ({0}).". format(fip.private_ip)) self.assertFalse( fip.in_use, "Newly created floating IP address should not be in use.")