diff --git a/shade/_tasks.py b/shade/_tasks.py index ab9c07dcd..1573304b3 100644 --- a/shade/_tasks.py +++ b/shade/_tasks.py @@ -162,11 +162,6 @@ class EndpointDelete(task_manager.Task): return client.keystone_client.endpoints.delete(**self.args) -class RoleDelete(task_manager.Task): - def main(self, client): - return client.keystone_client.roles.delete(**self.args) - - class RoleAddUser(task_manager.Task): def main(self, client): return client.keystone_client.roles.add_user_role(**self.args) diff --git a/shade/operatorcloud.py b/shade/operatorcloud.py index fdecd7d3b..0606e2e7a 100644 --- a/shade/operatorcloud.py +++ b/shade/operatorcloud.py @@ -1653,9 +1653,11 @@ class OperatorCloud(openstackcloud.OpenStackCloud): "Role %s not found for deleting", name_or_id) return False - with _utils.shade_exceptions("Unable to delete role {name}".format( - name=name_or_id)): - self.manager.submit_task(_tasks.RoleDelete(role=role['id'])) + v2 = self.cloud_config.get_api_version('identity').startswith('2') + url = '{preffix}/{id}'.format( + preffix='/OS-KSADM/roles' if v2 else '/roles', id=role['id']) + error_msg = "Unable to delete role {name}".format(name=name_or_id) + self._identity_client.delete(url, error_message=error_msg) return True