Mercurial > hg > Applications > virsh-wrapper
changeset 19:7b4cdb0c9a99
unknown changed
author | taiki |
---|---|
date | Mon, 10 Feb 2014 04:30:48 -1000 |
parents | 12c32e47724d |
children | 07ef2fc111a2 |
files | ie-virsh.c newvm.py |
diffstat | 2 files changed, 14 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/ie-virsh.c Mon Dec 09 00:31:41 2013 -1000 +++ b/ie-virsh.c Mon Feb 10 04:30:48 2014 -1000 @@ -94,6 +94,7 @@ ('/'==c ) || ('-'==c )) continue; return 1; + printf("%c", c); } return 0; } @@ -142,7 +143,6 @@ setgid(0); setuid(0); - if (argc>=3) { if ( strncmp(argv[1], "define", 6) == 0 ) { if (regexec(pattern, argv[2], (size_t) 0, NULL, 0)) { @@ -201,12 +201,12 @@ perror("Execl:"); } } else if ( strncmp(argv[1], "define", 6) == 0 ) { - chdir("/etc/libvirt/qemu"); + chdir("/usr/local/etc/libvirt/qemu"); if (execl(command, command, define_command, name_xml, NULL) < 0) { perror("Execl:"); } } else if ( strncmp(argv[1], "undefine", 8) == 0 ) { - chdir("/etc/libvirt/qemu"); + chdir("/usr/local/etc/libvirt/qemu"); if (execl(command, command, undefine_command, argv[2], NULL) < 0) { perror("Execl:"); }
--- a/newvm.py Mon Dec 09 00:31:41 2013 -1000 +++ b/newvm.py Mon Feb 10 04:30:48 2014 -1000 @@ -22,6 +22,8 @@ return 1 elif re.match('^teachers/[-a-z0-9]+/0[1-4]$',name): return 0 + elif re.match('^(taiki)/0[1-4]$',name): + return 0 else: return 1 @@ -38,15 +40,17 @@ m=re.match('^(students/e\d\d/e\d\d57\d\d)/0[1-4]$',name) if m is None: m=re.match('^(teachers/[-a-z0-9]+)/0[1-4]$',name) + if m is None: + m=re.match('(taiki)/0[1-4]',name) if m is not None: dir=m.group(1) ie_mkdir1('/media/fcs/'+dir) - ie_mkdir1('/etc/libvirt/qemu/'+dir) - ie_mkdir1('/var/log/libvirt/qemu/'+dir) - ie_mkdir1('/var/run/libvirt/qemu/'+dir) - ie_mkdir1('/var/lib/libvirt/qemu/'+dir) + ie_mkdir1('/usr/local/etc/libvirt/qemu/'+dir) + ie_mkdir1('/usr/local/var/log/libvirt/qemu/'+dir) + ie_mkdir1('/usr/local/var/run/libvirt/qemu/'+dir) + ie_mkdir1('/usr/local/var/lib/libvirt/qemu/'+dir) os.system("/bin/chown "+os.getlogin()+" /media/fcs/"+dir) - + parser = OptionParser(); parser.add_option("-n", "--name", dest="name", help="VM name"); @@ -61,11 +65,11 @@ config = ET.parse(options.config) vm_name = options.name +print(options.config) if ie_check_name(vm_name): print "Bad vmname %s. Try students/e11/e115711/01 or teachers/kono/02" % vm_name sys.exit(1) ie_mkdir(vm_name) - name = config.find('name') name.text = vm_name uuid = config.find('uuid') @@ -82,8 +86,7 @@ if os.path.exists(vm_name + '.xml'): print "File %s.xml exists, abort" % vm_name sys.exit(1) -config.write('/etc/libvirt/qemu/' + vm_name + '.xml') +config.write('/usr/local/etc/libvirt/qemu/' + vm_name + '.xml') print "Created vm config file %s.xml" % vm_name print "Use disk image %s, you must create it from the template disk: %s" % (disk_image, disk_old) print "Done!" -