From 591614ade5071258e3b023d8e508135d7a4adcb9 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 28 Apr 2019 23:57:39 +0200 Subject: [PATCH] Remove user from opennebula also --- datacenterlight/management/commands/deteteuser.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/datacenterlight/management/commands/deteteuser.py b/datacenterlight/management/commands/deteteuser.py index efed7e17..e508304b 100644 --- a/datacenterlight/management/commands/deteteuser.py +++ b/datacenterlight/management/commands/deteteuser.py @@ -1,4 +1,5 @@ import logging +import oca import sys import stripe @@ -7,6 +8,7 @@ from membership.models import CustomUser from hosting.models import ( HostingOrder, HostingBill, VMDetail, UserCardDetail, UserHostingKey ) +from opennebula_api.models import OpenNebulaManager logger = logging.getLogger(__name__) @@ -123,6 +125,13 @@ class Command(BaseCommand): # delete CustomUesr cus_user.delete() + + # remove user from OpenNebula + manager = OpenNebulaManager() + manager.oneadmin_client.call( + oca.User.METHODS['delete'], email + ) + logger.debug("Deleted {} SUCCESSFULLY.".format(email)) except Exception as e: print(" *** Error occurred. Details {}".format(str(e)))