Wsme ipv4address type can not used for rest api validate
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
WSME |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Magnum project used wsme and it has code as following
https:/
baymodel has following(code snip)
class BayModel(
"""API representation of a baymodel.
This class enforces type checking and value constraints, and converts
between the internal object model and the API representation of a baymodel.
"""
_coe = None
def _get_coe(self):
return self._coe
def _set_coe(self, value):
if value and self._coe != value:
elif value == wtypes.Unset:
uuid = types.uuid
"""Unique UUID for this baymodel"""
name = wtypes.
"""The name of the bay model"""
coe = wsme.wsproperty
"""The Container Orchestration Engine for this bay model"""
image_id = wsme.wsattr(
"""The image name or UUID to use as a base image for this baymodel"""
flavor_id = wtypes.
"""The flavor of this bay model"""
master_
"""The flavor of the master node for this bay model"""
dns_nameserver = wtypes.
"""The DNS nameserver address"""
....
Here the dns_nameserver if set with wtypes.
as wsme .IPv4AddressType() has logic as: (https:/
class IPv4AddressType
"""
A simple IPv4 type.
"""
basetype = six.string_types
name = "ipv4address"
@staticmethod
def validate(value):
try:
except ipaddress.
error = 'Value should be IPv4 format'
raise ValueError(error)
else:
return value
The ipaddress it import logic is:
try:
import ipaddress
except ImportError:
import ipaddr as ipaddress
The first ipaddress module can not accept unocide, like u'8.8.1.1', only import ipaddr as ipaddress can accept both string and unicode.
So it can cause issue, if it only have ipaddress module, so rest api pass string '8.8.1.1' would failed for ipaddress validate.
Our jenkins failure job can be found here:
http://
2015-05-14 06:58:55.425 | FAIL: magnum.
2015-05-14 06:58:55.425 | tags: worker-4
2015-05-14 06:58:55.425 | -------
2015-05-14 06:58:55.425 | Empty attachments:
2015-05-14 06:58:55.426 | stderr
2015-05-14 06:58:55.426 |
2015-05-14 06:58:55.426 | stdout: {{{POST: /v1/baymodels {'external_
2015-05-14 06:58:55.427 |
2015-05-14 06:58:55.427 | Traceback (most recent call last):
2015-05-14 06:58:55.427 | File "/home/
2015-05-14 06:58:55.428 | return func(*args, **keywargs)
2015-05-14 06:58:55.428 | File "magnum/
2015-05-14 06:58:55.428 | response = self.post_
2015-05-14 06:58:55.429 | File "magnum/
2015-05-14 06:58:55.429 | status=status, method="post")
2015-05-14 06:58:55.429 | File "magnum/
2015-05-14 06:58:55.429 | expect_
2015-05-14 06:58:55.430 | File "/home/
2015-05-14 06:58:55.430 | return self._gen_
2015-05-14 06:58:55.430 | File "/home/
2015-05-14 06:58:55.431 | expect_
2015-05-14 06:58:55.436 | File "/home/
2015-05-14 06:58:55.436 | self._check_
2015-05-14 06:58:55.436 | File "/home/
2015-05-14 06:58:55.436 | res)
2015-05-14 06:58:55.437 | webtest.
2015-05-14 06:58:55.437 | '{"error_message": "{\\"faultcode\\": \\"Client\\", \\"debuginfo\\": null, \\"faultstring\\": \\"Invalid input for field/attribute dns_nameserver. Value: \'8.8.1.1\'. Value should be IPv4 format\\"}"}'
2015-05-14 06:58:55.438 | =======
2015-05-14 06:58:55.438 | FAIL: magnum.
2015-05-14 06:58:55.438 | tags: worker-0
2015-05-14 06:58:55.438 | -------
Changed in wsme: | |
status: | New → In Progress |
Changed in wsme: | |
milestone: | none → 0.8.0 |
status: | Fix Committed → Fix Released |
There is a patch that is being worked on to substitute ipaddr with netaddr, I think it should fix this issue: https:/ /review. openstack. org/#/c/ 183449/
We should add unitests to check for this case...