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
2 changes: 1 addition & 1 deletion juju/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
'RetryStrategy': {'versions': [1]},
'Singular': {'versions': [2]},
'SSHClient': {'versions': [1, 2]},
'Spaces': {'versions': [2, 3]},
'Spaces': {'versions': [2, 3, 4, 5, 6]},
'StatusHistory': {'versions': [2]},
'Storage': {'versions': [3, 4]},
'StorageProvisioner': {'versions': [3, 4]},
Expand Down
20 changes: 14 additions & 6 deletions juju/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,17 +1222,22 @@ def _find_relation(*specs):
await self.block_until(lambda: _find_relation(*specs) is not None)
return _find_relation(*specs)

def add_space(self, name, *cidrs):
async def add_space(self, name, cidrs=None, public=True):
"""Add a new network space.

Adds a new space with the given name and associates the given
(optional) list of existing subnet CIDRs with it.

:param str name: Name of the space
:param *cidrs: Optional list of existing subnet CIDRs

:param List[str] cidrs: Optional list of existing subnet CIDRs
"""
raise NotImplementedError()
space_facade = client.SpacesFacade.from_connection(self.connection())
spaces = [
{
"cidrs": cidrs,
"space-tag": tag.space(name),
"public": public}]
return await space_facade.CreateSpaces(spaces=spaces)

async def add_ssh_key(self, user, key):
"""Add a public SSH key to this model.
Expand Down Expand Up @@ -1668,11 +1673,14 @@ def get_shares(self):
"""
raise NotImplementedError()

def get_spaces(self):
async def get_spaces(self):
"""Return list of all known spaces, including associated subnets.

Returns a List of :class:`~juju._definitions.Space` instances.
"""
raise NotImplementedError()
space_facade = client.SpacesFacade.from_connection(self.connection())
response = await space_facade.ListSpaces()
return response.results

async def get_ssh_key(self, raw_ssh=False):
"""Return known SSH keys for this model.
Expand Down
4 changes: 4 additions & 0 deletions juju/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ def unit(unit_name):

def action(action_uuid):
return _prefix('action-', action_uuid)


def space(space_name):
return _prefix('space-', space_name)