When using the API client to delete a resource, the resource is deleted all right but the client blocks forever.
= How to reproduce =
Assuming you've got a MAAS server installed on localhost:
# Create admin user.
sudo maas-region-admin createadmin --username admin --password test --email <email address hidden>
# Set up maas cli.
sudo maas login maas http://localhost/MAAS/api/1.0/ `sudo maas-region-admin apikey --username admin`
# Create a zone object.
sudo maas maas zones create name=test_zone
# Get the api key for the admin user.
sudo maas-region-admin apikey --username admin
<grab the API key>
# Now, in a python shell:
python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from apiclient.creds import convert_string_to_tuple
>>> from apiclient.maas_client import (
... MAASClient,
... MAASDispatcher,
... MAASOAuth,
... urllib2,
... )
>>> credentials = convert_string_to_tuple('<Replace with the API key>')
>>> auth = MAASOAuth(*credentials)
>>> client = MAASClient(auth, MAASDispatcher(), "http://localhost/MAAS")
>>> zone_uri = u'/api/1.0/zones/test_zone/'
>>> client.delete(zone_uri)
<blocked forever>
= Notes =
Note that, if you CTL-C the last command (the deletion of the zone), `sudo maas maas zones read` will show that the zone has effectively be deleted.
= Workaround =
A (pretty ugly) workaround is to set a timeout to `urlopen` used by the API client.
>>> from functools import partial
>>> urlopen_with_timeout = partial(urllib2.urlopen, timeout=4)
>>> from apiclient import maas_client
>>> maas_client.urllib2.urlopen = urlopen_with_timeout
When using the API client to delete a resource, the resource is deleted all right but the client blocks forever.
= How to reproduce =
Assuming you've got a MAAS server installed on localhost:
# Create admin user. localhost/ MAAS/api/ 1.0/ `sudo maas-region-admin apikey --username admin`
sudo maas-region-admin createadmin --username admin --password test --email <email address hidden>
# Set up maas cli.
sudo maas login maas http://
# Create a zone object.
sudo maas maas zones create name=test_zone
# Get the api key for the admin user.
sudo maas-region-admin apikey --username admin
<grab the API key>
# Now, in a python shell:
python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) string_ to_tuple maas_client import ( string_ to_tuple( '<Replace with the API key>') *credentials) localhost/ MAAS") 1.0/zones/ test_zone/ ' delete( zone_uri)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from apiclient.creds import convert_
>>> from apiclient.
... MAASClient,
... MAASDispatcher,
... MAASOAuth,
... urllib2,
... )
>>> credentials = convert_
>>> auth = MAASOAuth(
>>> client = MAASClient(auth, MAASDispatcher(), "http://
>>> zone_uri = u'/api/
>>> client.
<blocked forever>
= Notes =
Note that, if you CTL-C the last command (the deletion of the zone), `sudo maas maas zones read` will show that the zone has effectively be deleted.
= Workaround =
A (pretty ugly) workaround is to set a timeout to `urlopen` used by the API client.
>>> from functools import partial with_timeout = partial( urllib2. urlopen, timeout=4) urllib2. urlopen = urlopen_ with_timeout
>>> urlopen_
>>> from apiclient import maas_client
>>> maas_client.