Ejemplo n.º 1
0
def address_generator_factory(cidr, **kwargs):
    default_generator = "melange.ipv6.tenant_based_generator."\
                        "TenantBasedIpV6Generator"
    ip_generator_class_name = config.Config.get("ipv6_generator",
                                                default_generator)
    ip_generator = utils.import_class(ip_generator_class_name)
    required_params = ip_generator.required_params\
        if hasattr(ip_generator, "required_params") else []

    not_none_kwargs = utils.remove_nones(kwargs)
    missing_params = set(required_params) - set(not_none_kwargs.keys())
    if missing_params:
        raise exception.ParamsMissingError(_("Required params are missing: %s")
                                           % (', '.join(missing_params)))

    return ip_generator(cidr, **kwargs)
Ejemplo n.º 2
0
def address_generator_factory(cidr, **kwargs):
    default_generator = "melange.ipv6.tenant_based_generator."\
                        "TenantBasedIpV6Generator"
    ip_generator_class_name = config.Config.get("ipv6_generator",
                                                default_generator)
    ip_generator = utils.import_class(ip_generator_class_name)
    required_params = ip_generator.required_params\
        if hasattr(ip_generator, "required_params") else []

    not_none_kwargs = utils.remove_nones(kwargs)
    missing_params = set(required_params) - set(not_none_kwargs.keys())
    if missing_params:
        raise exception.ParamsMissingError(
            _("Required params are missing: %s") % (', '.join(missing_params)))

    return ip_generator(cidr, **kwargs)
Ejemplo n.º 3
0
 def test_remove_nones(self):
     hash = utils.remove_nones(dict(a=1, b=None, c=3))
     self.assertEqual(hash, dict(a=1, c=3))
Ejemplo n.º 4
0
 def test_remove_nones(self):
     hash = utils.remove_nones(dict(a=1, b=None, c=3))
     self.assertEqual(hash, dict(a=1, c=3))