def test_deallocated_ips_get_deleted(self): block = factory_models.PublicIpBlockFactory() ip = factory_models.IpAddressFactory(ip_block_id=block.id) block.deallocate_ip(ip.address) days = config.Config.get('keep_deallocated_ips_for_days') self._push_back_deallocated_date(ip, days) script = tests.melange_bin_path('melange-delete-deallocated-ips') config_file = tests.test_config_file() functional.execute("{0} --config-file={1}".format(script, config_file)) self.assertIsNone(models.IpAddress.get(ip.id))
def test_deallocated_ips_get_deleted(self): block = factory_models.PublicIpBlockFactory() ip = factory_models.IpAddressFactory(ip_block_id=block.id) block.deallocate_ip(ip.address) seconds = config.Config.get('keep_deallocated_ips_for_seconds') self._push_back_deallocated_date(ip, seconds) script = tests.melange_bin_path('melange-delete-deallocated-ips') config_file = tests.test_config_file() functional.execute("{0} --config-file={1}".format(script, config_file)) self.assertIsNone(models.IpAddress.get(ip.id))
def test_deallocated_ips_get_freed(self): block = factory_models.PublicIpBlockFactory() ip = factory_models.IpAddressFactory(ip_block_id=block.id) block.deallocate_ip(ip.address) seconds = config.Config.get('keep_deallocated_ips_for_seconds') self._push_back_deallocated_date(ip, seconds) script = tests.melange_bin_path('melange-delete-deallocated-ips') config_file = tests.test_config_file() functional.execute("{0} --config-file={1}".format(script, config_file)) # NOTE(jkoelker) Dirty, but works. Reset the session_maker so a # new session is started in the current thread session._MAKER = None ip = models.IpAddress.get(ip.id) self.assertFalse(ip.allocated) self.assertIsNone(ip.interface) self.assertIsNone(ip.used_by_tenant_id)
def run_melange_manage(command): melange_manage = tests.melange_bin_path('melange-manage') config_file = tests.test_config_file() return functional.execute("%(melange_manage)s %(command)s " "--config-file=%(config_file)s" % locals())
def run_melange_manage(command): cmd = dict(melange_manage=tests.melange_bin_path('melange-manage'), config_file=tests.test_config_file(), command=command) return functional.execute("%(melange_manage)s %(command)s " "--config-file=%(config_file)s" % cmd)