@@ -0,0 +1,1549 @@
+#!/usr/bin/env python%0A# -*- encoding: utf-8 -*-%0A%22%22%22%0ABOSH OpenStack Ironic CPI%0A%22%22%22%0A# Python 2 and 3 compatibility%0Afrom __future__ import unicode_literals%0A%0Afrom ironic_cpi.action import CPIAction%0Afrom ironic_cpi.action import CPIActionError%0Afrom ironic_cpi.actions.repositories.repository import RepositoryManager%0Afrom ironic_cpi.actions.repositories.repository import RepositoryError%0A# Import all repository implementations%0Afrom ironic_cpi.actions.repositories.webdav import WebDav%0A%0A%0Aclass Delete_Stemcell(CPIAction):%0A    action = 'delete_stemcell'%0A%0A    def __init__(self, context):%0A        super(Delete_Stemcell, self).__init__(context)%0A        self.repository = RepositoryManager(self.logger)%0A%0A    ##%0A    # Deletes a stemcell%0A    #%0A    # @param %5BString%5D stemcell_id, image UUID of the stemcell to be deleted%0A    # @return %5Bvoid%5D%0A    def run(self, config):%0A        image_id = self.args%5B0%5D%0A        repository =  self.repository.manage(config%5B'stemcell'%5D)%0A        try:%0A            stemcell_id = image_id + '.qcow2'%0A            if repository.exists(stemcell_id):%0A                repository.delete(stemcell_id)%0A            stemcell_md5 = image_id + '.md5'%0A            if repository.exists(stemcell_md5):%0A                repository.delete(stemcell_md5)  %0A        except RepositoryError as e:%0A            msg = %22Cannot delete '%25s' from repository%22 %25 image_id%0A            long_msg = msg + ': %25s' %25 (e)%0A            self.logger.error(msg)%0A            raise CPIActionError(msg, long_msg)%0A        self.logger.debug(%22Stemcell '%25s' deleted%22 %25 image_id)%0A%0A%0A# EOF%0A%0A

delete stemcell