Comment 1 for bug 1555393

Revision history for this message
David Ames (thedac) wrote :

I am afraid this bug is still an issue using python3-maas-client 2.0.0~alpha3+bzr4809-0ubuntu1~xenial1.

Attempting to create a dnsresource with post:

With post request not specifying an op code:

Traceback (most recent call last):
  File "ocf/maas/maas_dns.py", line 149, in <module>
    telco_ha_dns()
  File "ocf/maas/maas_dns.py", line 131, in telco_ha_dns
    dns_obj.create_dnsresource()
  File "ocf/maas/maas_dns.py", line 44, in create_dnsresource
    self.ttl)
  File "/home/thedac/dev/hacluster/ocf/maas/maasclient/__init__.py", line 78,
in create_dnsresource
    resp = self.driver.create_dnsresource(fqdn, ip_address, address_ttl)
  File "/home/thedac/dev/hacluster/ocf/maas/maasclient/apidriver.py", line
166, in create_dnsresource
    address_ttl=address_ttl)
  File "/home/thedac/dev/hacluster/ocf/maas/maasclient/apidriver.py", line 89,
in _post
    response = self.client.post(path, op, **kwargs)
  File "/usr/lib/python3/dist-packages/apiclient/maas_client.py", line 242, in
post
    path, kwargs, as_json=as_json)
  File "/usr/lib/python3/dist-packages/apiclient/maas_client.py", line 212, in
_formulate_change
    url += '?' + urlencode([('op', op)])
  File "/usr/lib/python3/dist-packages/apiclient/utils.py", line 42, in
urlencode
    for name, value in data)
  File "/usr/lib/python3/dist-packages/apiclient/utils.py", line 42, in
<genexpr>
    for name, value in data)
  File "/usr/lib/python3.5/urllib/parse.py", line 728, in quote_plus
    string = quote(string, safe + space, encoding, errors)
  File "/usr/lib/python3.5/urllib/parse.py", line 712, in quote
    return quote_from_bytes(string, safe)
  File "/usr/lib/python3.5/urllib/parse.py", line 737, in quote_from_bytes
    raise TypeError("quote_from_bytes() expected bytes")
TypeError: quote_from_bytes() expected bytes

If I explicitly set the op code to op=bytes('update', encoding='utf-8') and
working around LP Bug#1555392 it returns 400 Bad Request:

Traceback (most recent call last):
  File "ocf/maas/maas_dns.py", line 149, in <module>
    telco_ha_dns()
  File "ocf/maas/maas_dns.py", line 131, in telco_ha_dns
    dns_obj.create_dnsresource()
  File "ocf/maas/maas_dns.py", line 44, in create_dnsresource
    self.ttl)
  File "/home/thedac/dev/hacluster/ocf/maas/maasclient/__init__.py", line 78,
in create_dnsresource
    resp = self.driver.create_dnsresource(fqdn, ip_address, address_ttl)
  File "/home/thedac/dev/hacluster/ocf/maas/maasclient/apidriver.py", line
166, in create_dnsresource
    address_ttl=address_ttl)
  File "/home/thedac/dev/hacluster/ocf/maas/maasclient/apidriver.py", line 89,
in _post
    response = self.client.post(path, op, **kwargs)
  File "/usr/lib/python3/dist-packages/apiclient/maas_client.py", line 245, in
post
    url, method="POST", headers=headers, data=body)
  File "/usr/lib/python3/dist-packages/apiclient/maas_client.py", line 109, in
dispatch_query
    res = urllib.request.urlopen(req)
  File "/usr/lib/python3.5/urllib/request.py", line 162, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 471, in open
    response = meth(req, response)
  File "/usr/lib/python3.5/urllib/request.py", line 581, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.5/urllib/request.py", line 509, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 443, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 589, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: BAD REQUEST

MAAS regiond log:
2016-03-18 22:45:19 [-] 127.0.0.1 - - [18/Mar/2016:22:45:18 +0000] "POST
/MAAS/api/2.0/dnsresources/?op=update HTTP/1.1" 400 45 "-" "Python-urllib/3.5"