Skip to content

Commit 7f099ab

Browse files
committed
Add detach_storage
1 parent 8957d30 commit 7f099ab

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

juju/unit.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,25 @@ async def attach_storage(self, storage_ids=[]):
160160
unit_tag=self.tag,
161161
) for s_id in storage_ids])
162162

163+
async def detach_storage(self, force=False, *storage_ids):
164+
"""Detaches storage from units.
165+
166+
:param bool force: Forcefully detach storage
167+
:param [str] storage_ids:
168+
:return:
169+
"""
170+
if not storage_ids:
171+
raise JujuError("Expected at least one storage ID")
172+
173+
storage_facade = client.StorageFacade.from_connection(self.connection)
174+
return await storage_facade.DetachStorage(
175+
force=force,
176+
ids=[client.StorageAttachmentIds(ids=[client.StorageAttachmentId(
177+
storage_tag=tag.storage(s),
178+
unit_tag=self.tag,
179+
) for s in storage_ids])]
180+
)
181+
163182
async def run(self, command, timeout=None):
164183
"""Run command on this unit.
165184

0 commit comments

Comments
 (0)