From c2d52d4f8372496ac6fa71652ac7684b2745361a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 25 Oct 2018 16:31:32 -0400 Subject: [PATCH] Add functionality to delete volumes Further enriching the storage api by adding the ability to delete a volume. --- .../confluent/plugins/hardwaremanagement/ipmi.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index d2f5f427..27871955 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -941,6 +941,22 @@ class IpmiHandler(object): return self._show_storage(storelem) elif 'update' == self.op: return self._update_storage(storelem) + elif 'delete' == self.op: + return self._delete_storage(storelem) + + def _delete_storage(self, storelem): + if len(storelem) < 2 or storelem[0] != 'volumes': + raise exc.InvalidArgumentException('Must target a specific volume') + volname = storelem[-1] + curr = self.ipmicmd.get_storage_configuration() + volumes = [] + toremove = storage.ConfigSpec(arrays=[storage.Array(volumes=volumes)]) + for pool in curr.arrays: + for vol in pool.volumes: + if simplify_name(vol.name) == volname: + volumes.append(vol) + self.ipmicmd.remove_storage_configuration(toremove) + def _update_storage(self, storelem): if storelem[0] == 'disks':