def __init__(self, address=None, type=None, **kwargs):
    super(IP, self).__init__()
    self['address'] = address
    self['type'] = type
    self['version'] = kwargs.pop('version', None)
    self._set_meta(kwargs)
    if (self['address'] and (not self['version'])):
        try:
            self['version'] = netaddr.IPAddress(self['address']).version
        except netaddr.AddrFormatError:
            msg = (_('Invalid IP format %s') % self['address'])
            raise exception.InvalidIpAddressError(msg)
def __init__(self, address=None, type=None, **kwargs):
    super(IP, self).__init__()
    self['address'] = address
    self['type'] = type
    self['version'] = kwargs.pop('version', None)
    self._set_meta(kwargs)
    if (self['address'] and (not self['version'])):
        try:
            self['version'] = netaddr.IPAddress(self['address']).version
        except netaddr.AddrFormatError:
            msg = (_('Invalid IP format %s') % self['address'])
            raise exception.InvalidIpAddressError(msg)