Fixes for conjure-up #63

Merged
merged 12 commits into from Mar 7, 2017

Conversation

Projects
None yet
4 participants
Member

johnsca commented Mar 1, 2017

Includes:

  • Implement Model().get_status
  • Fixes Model.connect_model() failing in 2.1 due to model names now including username in models.yaml
  • Fixes explicit loop instance not being used in several places, causing the default loop to be used for some things but not others

@johnsca johnsca changed the title from Implement Model.get_status to Fixes for conjure-up Mar 2, 2017

Tests pass. I am +1 on this, if the modified model_name string is backwards compatible.

juju/client/connection.py
@@ -267,11 +273,13 @@ def https_connection(self):
username = accounts['user']
password = accounts.get('password')
models = jujudata.models()[controller_name]
+ if '/' not in model_name:
+ model_name = '{}/{}'.format(username, model_name)
@petevg

petevg Mar 2, 2017

Collaborator

Will this break in older versions of juju?

@johnsca

johnsca Mar 2, 2017

Member

It actually looks like this has always been the case in 2.x but we weren't using Connection.connect_model() directly before, so this is really more of a convenience that I thought was a bug before.

@petevg

petevg Mar 2, 2017

Collaborator

Cool. +1 to the change, then.

@mitechie

mitechie Mar 6, 2017

Owner

this looks like it should be part of determining the model_name logic above. This could include a : ?

Member

tvansteenburgh commented Mar 2, 2017

Most of this looks good, but I don't understand why we've added the loop param to the Connection class, since afaict it's never used. Am I missing something?

Member

johnsca commented Mar 2, 2017

@tvansteenburgh It gets passed to the websocket. Without that, the websocket events get processed by the wrong loop.

I'm currently working on a functional test for this, btw.

Member

tvansteenburgh commented Mar 2, 2017

@johnsca Ah, thanks I missed that line.

@battlemidget battlemidget referenced this pull request in conjure-up/conjure-up Mar 2, 2017

Closed

migrate to libjuju #697

johnsca added some commits Mar 1, 2017

Fix model name not including user
The model names in models.yaml include the username prefix.

Also fixed a lint error.
Pass through event loop
There were several places where the default event loop was used instead
of the given event loop.
Fix single app deploy not using config_yaml
Refactored to reduce duplicated code and ensure that both deploy paths
(bundle and single app) use new config_yaml param instead of config.

@johnsca johnsca referenced this pull request in conjure-up/conjure-up Mar 4, 2017

Closed

[wip] Switch from macumba to libjuju #710

Member

tvansteenburgh commented Mar 6, 2017

Not sure if there are any more commits coming on this, but I'm +1 on what's here so far.

@johnsca johnsca referenced this pull request in conjure-up/conjure-up Mar 6, 2017

Merged

Switch to libjuju and asyncio #713

Some questions and feedback. Let me know if you want to talk through any of it.

@@ -36,13 +37,14 @@ class Connection:
"""
def __init__(
self, endpoint, uuid, username, password, cacert=None,
- macaroons=None):
+ macaroons=None, loop=None):
@mitechie

mitechie Mar 6, 2017

Owner

Doe sthis need some help text and some usage docs updates? It looks like this changes how this can be fundamentally be used.

juju/client/connection.py
@@ -267,11 +273,13 @@ def https_connection(self):
username = accounts['user']
password = accounts.get('password')
models = jujudata.models()[controller_name]
+ if '/' not in model_name:
+ model_name = '{}/{}'.format(username, model_name)
@petevg

petevg Mar 2, 2017

Collaborator

Will this break in older versions of juju?

@johnsca

johnsca Mar 2, 2017

Member

It actually looks like this has always been the case in 2.x but we weren't using Connection.connect_model() directly before, so this is really more of a convenience that I thought was a bug before.

@petevg

petevg Mar 2, 2017

Collaborator

Cool. +1 to the change, then.

@mitechie

mitechie Mar 6, 2017

Owner

this looks like it should be part of determining the model_name logic above. This could include a : ?

juju/client/connection.py
jujudata = JujuData()
+
+ if ':' in model:
+ controller_name, model_name = model.split(':')
@mitechie

mitechie Mar 6, 2017

Owner

isn't there a third case where model is passed in but w/o the : ?

juju/client/connection.py
@@ -326,6 +338,12 @@ def current_controller(self):
output = yaml.safe_load(output)
return output.get('current-controller', '')
+ def current_model(self, controller_name=None):
+ models = self.models()[controller_name or self.current_controller()]
@mitechie

mitechie Mar 6, 2017

Owner

I think this would be better as two steps vs combined like this. It's kind of unclear what's going on at first glance.

juju/model.py
if not is_local:
+ parts = entity_id[3:].split('/')
@mitechie

mitechie Mar 6, 2017

Owner

we should update is_local to follow juju logic where it has to be a filepath starting with a '.'.

Then here we'd just do something like auto prefix with cs: and append the rest to the charmstore api?

@johnsca

johnsca Mar 7, 2017

Member

Just verified that a local charm path doesn't have to start with ./ (at least, absolute paths work fine)

@mitechie

mitechie Mar 7, 2017

Owner

Awesome, but local: is dead from the cli I believe.

juju/model.py
+ else:
+ entity = await self.charmstore.entity(entity_id)
+ ss = entity['Meta']['supported-series']
+ series = ss['SupportedSeries'][0]
@mitechie

mitechie Mar 6, 2017

Owner

we can let the charmstore do this right? Do we need to deal with the not series and such?

@johnsca

johnsca Mar 7, 2017

Member

The series param is required by the API, and the charm store doesn't tell us what, if any, series was provided in the URL. So we have to parse the URL ourselves and if not provided, get the first supported series from the charm store data. I will refactor this a little bit, though, because it currently makes two requests when it could make one. I will also add some more comments.

juju/model.py
+ placement=parse_placement(to),
+ )
+
+ async def _deploy(self, charm_url, application, series, config,
@mitechie

mitechie Mar 6, 2017

Owner

are there any comments as to why we now have a _deploy here?

Member

johnsca commented Mar 7, 2017

@tvansteenburgh I should have made multiple PRs but I was lazy and just kept adding to this one. If everyone is ok with this as is, I'd like to get it merged and I will be better about separate PRs for future changes.

Member

tvansteenburgh commented Mar 7, 2017

@johnsca Latest commit LGTM. Feel free to merge if @mitechie is +1.

I'm +1 with the one request for some testing around the charm parsing logic.

if not is_local:
+ if not application_name:
@mitechie

mitechie Mar 7, 2017

Owner

There's no test changes for this application parsing stuff that I think would be useful.

Owner

mitechie commented Mar 7, 2017

<3 ty and like how the testing caused a breakout of the method to be nice and clean.

@johnsca johnsca merged commit a09dd50 into master Mar 7, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment