Expanding controller.py with basic user functions, get_models and destroy #89

Merged
merged 49 commits into from Apr 6, 2017

Conversation

Projects
None yet
3 participants
Contributor

mhmoerma commented Mar 16, 2017

Added several functions in controller.py:

  • get_user
  • enable_user
  • disable_user
  • destroy
  • change_user_password
  • add_user
  • get_models: Partial implementation, the parameters all_ and username are ignored. Isn't this handled when connecting to the controller?

Issues:

Missing:
the login, logout and get_model have no matching functions in _client.py

Member

tvansteenburgh commented Mar 16, 2017

Thanks for the contribution. All of the new Controller methods need to be async def, and all the facade method calls need to be awaited. Also please add integration tests where possible.

Contributor

mhmoerma commented Mar 17, 2017

Added integration tests for Add-user, disable user and enable user. All the controller methods now are async and facades are awaited for.

Contributor

mhmoerma commented Mar 23, 2017

I've added, the add-ssh, get-ssh and remove-ssh calls, as well as the grant calls on both controllers and models. The integration tests have been expanded accordingly.

@tvansteenburgh tvansteenburgh referenced this pull request Mar 24, 2017

Closed

UserInfo #95

This looks really good, thanks! A few comments below, mainly about test coverage. The merge conflict should be easy to resolve; it's just the conflicting addition of additional new tests.

@@ -207,15 +225,18 @@ def kill(self):
cloud = list(result.clouds.keys())[0] # only lives on one cloud
return tag.untag('cloud-', cloud)
- def get_models(self, all_=False, username=None):
+ async def get_models(self, all_=False, username=None):
@johnsca

johnsca Apr 3, 2017

Member

I believe this is missing coverage in the tests.

@mhmoerma

mhmoerma Apr 4, 2017

Contributor

I'll add it in

@@ -1178,14 +1191,13 @@ def import_ssh_key(self, identity):
raise NotImplementedError()
import_ssh_keys = import_ssh_key
- def get_machines(self, machine, utc=False):
+ async def get_machines(self):
@johnsca

johnsca Apr 3, 2017

Member

I believe this is missing coverage in the tests.

@mhmoerma

mhmoerma Apr 4, 2017

Contributor

Indeed, I'll add it in

juju/model.py
- raise NotImplementedError()
+ model_facade = client.ModelManagerFacade()
+ model_facade.connect(self.connection)
+ return await list(self.state.machines.keys())
@johnsca

johnsca Apr 3, 2017

Member

The facade seems to be unused.

@mhmoerma

mhmoerma Apr 4, 2017

Contributor

Indeed, I will remove it

tests/integration/test_model.py
@@ -120,6 +120,7 @@
_deploy_in_loop(new_loop, model_name))
await model._wait_for_new('application', 'ubuntu')
assert 'ubuntu' in model.applications
+ await model.disconnect()
@johnsca

johnsca Apr 3, 2017

Member

Why was this added? The CleanModel context handler ought to disconnect this for us. Did you run across an issue with it not being disconnected?

@mhmoerma

mhmoerma Apr 4, 2017

Contributor

This is a mistake from my end, will remove this

+
+# @base.bootstrapped
+# @pytest.mark.asyncio
+# async def test_grant(event_loop)
@johnsca

johnsca Apr 3, 2017

Member

Why is this test commented out?

@mhmoerma

mhmoerma Apr 4, 2017

Contributor

Because currently there is no possibility to request the model access of a user using the api, so it cannot be tested. But I should be included in the test asap, when model access is callable.

Contributor

mhmoerma commented Apr 4, 2017

The async def test_store_resources_bundle(event_loop): test seems to fail in my local setup. Is this because some file is missing (and it will pass when making the pull request to juju master) or is it something else?
Travis log

Member

johnsca commented Apr 4, 2017

@mhmoerma It looks like you are somehow missing the tests/functional/bundle directory so it's trying (and failing) to query information about that from the charm store. Those tests passed on #102 and pass for me. Is there any chance the new bundle directory got dropped when resolving the merge conflicts?

Contributor

mhmoerma commented Apr 5, 2017

I don't find this directory in the current master branch?

Member

johnsca commented Apr 5, 2017

@mhmoerma Sorry, I meant tests/integration/bundle.

theblues.errors.EntityNotFound: https://api.jujucharms.com/charmstore/v5//home/travis/build/mhmoerma/python-libjuju/tests/integration/bundle/meta/any?include=bundle-machine-count&include=bundle-metadata&include=bundle-unit-count&include=bundles-containing&include=charm-config&include=charm-metadata&include=common-info&include=extra-info&include=owner&include=revision-info&include=published&include=stats&include=resources&include=supported-series&include=terms

That request should not happen because it should get caught by the is_local check in Model.deploy (you can see that the URL has an absolute local path embedded in it: /home/travis/build/mhmoerma/python-libjuju/tests/integration/bundle).

Contributor

mhmoerma commented Apr 6, 2017

Indeed, after a merge with the master branch, everything works as it should. I've added in all the requested changes.

Contributor

mhmoerma commented Apr 6, 2017

Strange, the build runs locally raw_log, but fails on the test_store_resources_charm in the libjuju CI

Member

johnsca commented Apr 6, 2017

@mhmoerma That failure is spurious. It's due to juju-solutions/layer-basic#92 and was fixed in rev 19 of the ghost charm. I'm going to merge this and update the pinned rev in the test.

@johnsca johnsca merged commit d23810d into juju:master Apr 6, 2017

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
Contributor

mhmoerma commented Apr 7, 2017

Awesome, thanks!

Member

tvansteenburgh commented Apr 7, 2017

@mhmoerma Really appreciate your contribution, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment