Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset FCP assignements of deleted VM #845

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions zvmsdk/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,15 @@ def bulk_update_state_in_fcp_table(self, fcp_id_list: list,
conn.executemany("UPDATE fcp set state=? "
"WHERE fcp_id=?", data_to_update)

def reset_fcps_of_assigner(self, userid):
"""Reset fcp records for a given assigner."""
with get_fcp_conn() as conn:
conn.execute("UPDATE fcp SET assigner_id='', reserved=0, "
"connections=0, tmpl_id='' WHERE assigner_id=?",
(userid,))
LOG.debug("FCP records for user %s are reset in "
"fcp table" % userid)

def get_all_fcps_of_assigner(self, assigner_id=None):
"""Get dict of all fcp records of specified assigner.
If assigner is None, will get all fcp records.
Expand Down
7 changes: 5 additions & 2 deletions zvmsdk/smtclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def __init__(self):
self._NetDbOperator = database.NetworkDbOperator()
self._GuestDbOperator = database.GuestDbOperator()
self._ImageDbOperator = database.ImageDbOperator()
self._FCPDbOperator = database.FCPDbOperator()

def _request(self, requestData):
try:
Expand Down Expand Up @@ -2564,8 +2565,10 @@ def delete_vm(self, userid):
with zvmutils.log_and_reraise_sdkbase_error(action):
self._NetDbOperator.switch_delete_record_for_userid(userid)

# TODO: cleanup db record from volume table
pass
# cleanup db records from FCP table
action = "delete FCP records for user %s" % userid
with zvmutils.log_and_reraise_sdkbase_error(action):
self._FCPDbOperator.reset_fcps_of_assigner(userid)

# cleanup persistent folder for guest
self._pathutils.remove_guest_path(userid)
Expand Down
Loading