Merge branch 'develop' into 'master'
Develop fix issue #5 See merge request !1
This commit is contained in:
commit
85310a69a7
2 changed files with 16 additions and 18 deletions
|
@ -125,40 +125,38 @@ class QEMU:
|
|||
def __prepare(self, hostname):
|
||||
# Create directory for new VM
|
||||
# os.popen('mkdir -p /tmp/libvirt/%s/templates/libvirt' % hostname, "r")
|
||||
subprocess.Popen([
|
||||
# 'mkdir', '-p', '/var/lib/libvirt/images/%s/templates/qemu' % hostname
|
||||
'mkdir', '-p', '/tmp/libvirt/%s/templates/libvirt' % hostname
|
||||
subprocess.Popen(
|
||||
[
|
||||
'mkdir', '-p', '/var/lib/libvirt/images/%s/templates/qemu' % hostname
|
||||
],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
# Copy tempaltes
|
||||
subprocess.Popen([
|
||||
'cp', '/etc/vmbuilder/libvirt/*', '/tmp/libvirt/%s/templates/libvirt' % hostname],
|
||||
'cp', '/etc/vmbuilder/libvirt/*', '/var/lib/libvirt/images/%s/templates/libvirt' % hostname],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
||||
)
|
||||
# os.popen("cp /etc/vmbuilder/libvirt/* /tmp/libvirt/%s/templates/libvirt" % hostname)
|
||||
|
||||
# os.popen("cp vm/firstboot.sh /var/lib/qemu/images/%s/boot.sh" % hostname, "r")
|
||||
os.popen("cp /etc/sws/cloud/firstboot.sh /tmp/libvirt/%s/boot.sh" % hostname, "r")
|
||||
os.popen("cp /etc/sws/cloud/firstboot.sh /var/lib/libvirt/images/%s/boot.sh" % hostname, "r")
|
||||
|
||||
return True
|
||||
|
||||
def __storage(self, hostname, storage, swap=0):
|
||||
# generate partition file
|
||||
# Open new data file
|
||||
# f = open("/var/lib/qemu/images/%s/partition" % hostname, "w")
|
||||
f = open("/tmp/libvirt/%s/partition" % hostname, "w")
|
||||
f = open("/var/lib/libvirt/images/%s/partition" % hostname, "w")
|
||||
f.write("root %s\n" % storage)
|
||||
if swap > 0:
|
||||
# f.write("---\n" % swap)
|
||||
f.write("---\n" % swap)
|
||||
f.write("swap %s\n" % swap)
|
||||
f.close()
|
||||
|
||||
return True
|
||||
|
||||
def __ssh_key(self, hostname, sshkey):
|
||||
f = open("/tmp/libvirt/%s/authorized_keys" % hostname, "w")
|
||||
f.write(sshkey)
|
||||
f = open("/var/lib/libvirt/images/%s/authorized_keys" % hostname, "w")
|
||||
if sshkey:
|
||||
f.write(sshkey)
|
||||
f.close()
|
||||
return True
|
||||
|
||||
|
@ -183,7 +181,7 @@ class QEMU:
|
|||
|
||||
c = [
|
||||
"cd",
|
||||
"/var/lib/libvirt/images;",
|
||||
"/var/lib/libvirt/images/%s;" % vm_id,
|
||||
"/usr/bin/vmbuilder",
|
||||
"kvm",
|
||||
os_name,
|
||||
|
@ -199,22 +197,22 @@ class QEMU:
|
|||
# "--part=/var/lib/qemu/images/%s/partition" % values['hostname'],
|
||||
"--rootsize=%s" % storage,
|
||||
"--swapsize=%s" % swap,
|
||||
"--templates=/tmp/libvirt/%s/templates/libvirt" % vm_id,
|
||||
"--templates=/var/lib/libvirt/images/%s/templates/libvirt" % vm_id,
|
||||
# USER
|
||||
"--user=administrator",
|
||||
"--name=administrator",
|
||||
"--pass=%s" % password,
|
||||
"--ssh-user-key=/tmp/libvirt/%s/authorized_keys" % vm_id,
|
||||
"--ssh-user-key=/var/lib/libvirt/images/%s/authorized_keys" % vm_id,
|
||||
# "--lock-user",
|
||||
"--rootpass=%s" % password,
|
||||
"--ssh-key=/tmp/libvirt/%s/authorized_keys" % vm_id,
|
||||
"--ssh-key=/var/lib/libvirt/images/%s/authorized_keys" % vm_id,
|
||||
"--addpkg=linux-image-generic",
|
||||
"--addpkg=vim-nox",
|
||||
# "--addpkg=nano",
|
||||
"--addpkg=unattended-upgrades",
|
||||
"--addpkg=acpid",
|
||||
# "--addpkg=fail2ban",
|
||||
"--firstboot=/tmp/libvirt/%s/boot.sh" % vm_id,
|
||||
"--firstboot=/var/lib/libvirt/images/%s/boot.sh" % vm_id,
|
||||
"--mem=%s" % memory,
|
||||
"--cpus=%s" % cores,
|
||||
# "--hostname=%s" % hostname,
|
||||
|
|
2
setup.py
2
setup.py
|
@ -4,7 +4,7 @@ from setuptools import setup
|
|||
|
||||
setup(
|
||||
name='SWSCloudNode',
|
||||
version='3.1.6',
|
||||
version='3.1.7',
|
||||
author='Vyacheslav Anzhiganov',
|
||||
author_email='vanzhiganov@ya.ru',
|
||||
packages=[
|
||||
|
|
Loading…
Add table
Reference in a new issue