Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion jasmin_cloud/provider/dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Size(namedtuple('Size', ['id', 'name', 'cpus', 'ram', 'disk'])):
class Machine(namedtuple('Machine', ['id', 'name', 'image', 'size',
'status', 'power_state', 'task',
'internal_ip', 'external_ip', 'nat_allowed',
'attached_volume_ids', 'owner', 'created'])):
'attached_volume_ids', 'owner', 'created', 'provisioned_by_caas'])):
"""
Represents a machine in a tenancy.

Expand All @@ -93,6 +93,7 @@ class Machine(namedtuple('Machine', ['id', 'name', 'image', 'size',
attached_volume_ids: A tuple of ids of attached volumes for the machine.
owner: The username of the user who deployed the machine.
created: The `datetime` at which the machine was deployed.
provisioned_by_caas: 1 if the machine was provisioned by caas, 0 otherwise.
"""
class Status(namedtuple('Status', ['type', 'name', 'details'])):
"""
Expand Down
7 changes: 5 additions & 2 deletions jasmin_cloud/provider/openstack/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,14 @@ def delete_machine(self, machine):
"""
See :py:meth:`.base.ScopedSession.delete_machine`.
"""
caas_machine = True if machine.provisioned_by_caas and machine.provisioned_by_caas == 1 else False

machine = machine.id if isinstance(machine, dto.Machine) else machine
self._log("Deleting machine '%s'", machine)
# First, delete any associated ports
for port in self._connection.network.ports.all(device_id = machine):
port._delete()
if not caas_machine:
for port in self._connection.network.ports.all(device_id = machine):
port._delete()
self._connection.compute.servers.delete(machine)
try:
return self.find_machine(machine)
Expand Down