Skip to content

Commit

Permalink
tm/snap_create_live: implement (copy from snap_create)
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Jun 11, 2024
1 parent 5574969 commit 6877a49
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tm/snap_create_live
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,33 @@ limitations under the License.

import sys

from one import util
from linstor import Resource
from one import consts, util, vm
from one.datastore import Datastore

SRC = sys.argv[1]
SNAP_ID = sys.argv[2]
VM_ID = int(sys.argv[3])
DS_ID = sys.argv[4]


def main():
util.log_info("Entering tm/snap_create_live")
util.log_info("Operation not supported!")
util.log_info("Entering tm/snap_create_live")
sys.exit(1)
disk_id = SRC.split(".")[-1].strip()
snap_id = util.arg_host(SNAP_ID).strip()

datastore = Datastore(util.show_ds(DS_ID))

target_vm = vm.Vm(util.show_vm(VM_ID))

res_name = target_vm.disk_source(disk_id)
if target_vm.disk_persistent(disk_id) != "YES":
res_name = "{}-vm{}-disk{}".format(res_name, VM_ID, disk_id)

res = Resource(name=res_name, uri=datastore.linstor_controllers)

res.snapshot_create("{}-{}".format(consts.SNAP_PREFIX, snap_id))
util.log_info("Exiting tm/snap_create_live")


if __name__ == "__main__":
Expand Down

0 comments on commit 6877a49

Please sign in to comment.