Friday, June 24, 2016

Some more VMWare techniques continued from the previous two post:
1) Clone a VM:
Specify a RelocateSpec
Specify a CloneSpec
Execute the CloneVM Workflow
The specs can be completed using the information from the virtual machine target to clone.
2) Take a snapshot of the VM:
snap_info = vm.snapshot
tree = snap_info.rootSnapshotList
while tree[0].childSnapshotList is not None:
    print("Snap: {0} => {1}".format(tree[0].name, tree[0].description))
    if len(tree[0].childSnapshotList) < 1:
        break
    tree = tree[0].childSnapshotList
3) Print VM info
def print_vm_info(virtual_machine):
    summary = virtual_machine.summary
    print("Name       : ", summary.config.name)
    print("Template   : ", summary.config.template)
    print("Path       : ", summary.config.vmPathName)
    print("Guest      : ", summary.config.guestFullName)
    print("Instance UUID : ", summary.config.instanceUuid)
    print("Bios UUID     : ", summary.config.uuid)
    annotation = summary.config.annotation
    if annotation:
        print("Annotation : ", annotation)
    print("State      : ", summary.runtime.powerState)
    if summary.guest is not None:
        ip_address = summary.guest.ipAddress
        tools_version = summary.guest.toolsStatus
            print("VMware-tools: ", repr(tools_version))
            print("IP         : ", repr(ip_address))
    print("")

#codingexercise
A knight on a chess board has to move from a start to a finish position. Find if the position is reachable and the minimum number of steps to take.
Int knightMoves (point[,] board, int N, point x, point y)
{
Add the starting point to a queue
While queue is not empty
     Extract a point
     If point == destination return
     If point already visited continue
     For each of eight moves the knight can make
        Enqueue the point

Return -1;
}

No comments:

Post a Comment