Open main menu

CDOT Wiki β

Changes

Talk:Fall 2008 SPR720 Sample Exam Questions

180 bytes added, 00:53, 11 December 2008
ANSWER
6. Write a python script which will ask the user for the name of a virtual machine and report whether that virtual machine is running. (Use libvirt).
===ANSWER===
<PRE>
#!/usr/bin/python
 
import libvirt
 
vm_Name=str(raw_input("Please enter your virtual machine's name: "))
conn=libvirt.open(None)
try:
vm=conn.lookupByName(vm_Name)
try: vm_id=vm.ID() print "Yes, your vm is up and running. The ID is ", vm_id except: print "Your vm is defined, but not running."
except:
print "Sorry, your vm is not running."
 
</pre>
Nes.. finally.. i did it.. @@
Nes: edit at 00:53, as CT suggested.
7. Write a bash script which will print all of the files in your home directory which end in .ps -- you must be able to run the script from any directory.