Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions juju/client/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ async def connect(self, **kwargs):
for macaroon in kwargs.pop('macaroons'):
jar.set_cookie(go_to_py_cookie(macaroon))
self._connection = await Connection.connect(**kwargs)
controller = self.jujudata.controllers()[
self.jujudata.current_controller()
]
self._connection.endpoints = [
(e, controller["ca-cert"])
for e in controller["api-endpoints"]
]

async def disconnect(self):
"""Shut down the watcher task and close websockets.
Expand Down
29 changes: 23 additions & 6 deletions juju/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ async def connect(self, *args, **kwargs):
raise ValueError('Authentication parameters are required '
'if controller_name not given')
await self._connector.connect(**kwargs)
info = await self.info()
self._connector._connection.endpoints = [
(e, info.results[0].cacert)
for e in info.results[0].addresses
]

async def connect_current(self):
"""
Expand Down Expand Up @@ -181,12 +186,13 @@ def controller_uuid(self):
return self._connector.controller_uuid

@property
def api_endpoints(self):
controller_name = self._connector.jujudata.current_controller()
if controller_name:
return self._connector.jujudata.controllers().get(controller_name).get(
"api-endpoints"
)
async def api_endpoints(self):
"""Get API endpoints

:return list string: List of API Endpoints
"""
info = await self.info()
return info.results[0].addresses

async def disconnect(self):
"""Shut down the watcher task and close websockets.
Expand Down Expand Up @@ -273,6 +279,17 @@ async def add_cloud(self, name, cloud):
result = await self.cloud(name=name)
return result.cloud

async def info(self):
"""Show Controller Info from connection

:return ControllerAPIInfoResult
"""
log.debug('Getting information')
uuids = await self.model_uuids()
controller_facade = client.ControllerFacade.from_connection(self.connection())
params = [client.Entity(tag.model(uuids["controller"]))]
return await controller_facade.ControllerAPIInfoForModels(entities=params)

async def remove_cloud(self, name):
"""Remove a cloud from this controller.

Expand Down