Commit 957b5c69 authored by Alain Takoudjou's avatar Alain Takoudjou

Remove unused files

parent 3f3a78a1
#!${:python_path}
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
# Echo client program
import socket
import time
# Connect to KVM qmp socket
so = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
connected = False
while not connected:
try:
so.connect('${:socket_path}')
except socket.error:
time.sleep(1)
else:
connected = True
data = so.recv(1024)
# Enable qmp
so.send('{ "execute": "qmp_capabilities" }')
data = so.recv(1024)
# Set VNC password
so.send('{ "execute": "change", ' \
'"arguments": { "device": "vnc", "target": "password", ' \
' "arg": "${:vnc_passwd}" } }')
data = so.recv(1024)
# Finish
so.close()
\ No newline at end of file
#!${:python_path}
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
# Echo client program
import hashlib
import os
import socket
import subprocess
import urllib
def getSocketStatus(host, port):
s = None
for res in socket.getaddrinfo(host, port,
socket.AF_UNSPEC, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
try:
s = socket.socket(af, socktype, proto)
except socket.error, msg:
s = None
continue
try:
s.connect(sa)
except socket.error, msg:
s.close()
s = None
continue
break
return s
disk_path = '${:disk_path}'
virtual_hard_drive_url = '${:virtual-hard-drive-url}'.strip()
virtual_hard_drive_md5_url = '${:virtual-hard-drive-md5-url}'.strip()
# Download existing hard drive if needed at first boot
if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
urllib.urlretrieve(virtual_hard_drive_url, disk_path)
local_md5sum = md5Checksum(disk_path)
md5sum = urllib.urlopen(virtual_hard_drive_md5_url).read().strip()
if local_md5sum != md5sum:
os.remove(disk_path)
raise Exception('MD5 mismatch.')
# create disk if doesn't exist
if not os.path.exists(disk_path):
subprocess.Popen(['${:qemu_img_path}', 'create' ,'-f', 'qcow2',
disk_path, '${:disk_size}G'])
# Generate NAT rules for ssh connexion
if "${:software_type}".strip() == "compute":
nat_rules = ",".join("hostfwd=tcp:${:vnc_ip}:%s-:%s" % (port, port) for port in [80, 443])
else:
nat_rules = ",".join("hostfwd=tcp:${:vnc_ip}:%s-:%s" % (port, port) for port in [80, 443, 5000, 6080, 6082, 3333, 9292, 3306, 35357])
kvm_argument_list = ['${:qemu_path}',
'-enable-kvm', '-net', 'nic,macaddr=${:mac_address}',
'-net', 'user,hostfwd=tcp:${:vnc_ip}:22222-:22,%s' % nat_rules,
'-smp', '${:smp_count}',
'-m', '${:ram_size}',
'-drive', 'file=${:disk_path},if=${:disk_type}',
'-vnc', '${:vnc_ip}:1,ipv4,password',
'-boot', 'menu=on',
'-qmp', 'unix:${:socket_path},server',
'-pidfile', '${:pid_file_path}',
]
s = getSocketStatus('${:nbd_ip}', ${:nbd_port})
if s is None:
# NBD is not available : launch kvm without it
print 'Warning : Nbd is not available.'
else:
# NBD is available
kvm_argument_list.extend([
'-drive',
'file=nbd:[%s]:%s,media=cdrom' % ('${:nbd_ip}', ${:nbd_port})])
os.execv('${:qemu_path}', kvm_argument_list)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment