Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
xen3 now working with end to end cloud setup
Browse files Browse the repository at this point in the history
  • Loading branch information
timf committed Dec 19, 2009
1 parent c731376 commit 23494c1
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 63 deletions.
4 changes: 2 additions & 2 deletions control/etc/workspace-control/internal.conf
Expand Up @@ -6,8 +6,8 @@


[libvirt_connections]
xen3: xen+unix:///
kvm0: qemu+unix:///system
xen3: xen:///
kvm0: qemu:///system


[persistence]
Expand Down
2 changes: 1 addition & 1 deletion control/etc/workspace-control/libvirt.conf
Expand Up @@ -6,5 +6,5 @@
# "kvm0" - http://libvirt.org/drvqemu.html
# "mock" - http://libvirt.org/drvtest.html (this does nothing)

vmm: mock
vmm: xen3

15 changes: 13 additions & 2 deletions control/etc/workspace-control/main.conf
@@ -1,18 +1,29 @@

[vmcreation]

# ---------- num_cpu_per_vm ----------
# The default number of vcpus to assign each created VM.
# - Commandline values can override this.
# - Central service's supplied values can override this.
# - Default is 1 if missing.

num_cpu_per_vm: 1


[vmshutdown]

# The default number of seconds to wait for a graceful shutdown before going
# ahead and "destroying." A graceful shutdown is usually triggered when the
# VM files are going to be saved back to the repository.
# - Default is 15 if missing.

shutdown_wait: 15


[notifications]

# for asynchronous notifications back to the service (such as a propagation
# related transfer completing)
# Can be absolute path. If not, PATH is used for resolution.

ssh: /usr/bin/ssh


Expand Down
11 changes: 2 additions & 9 deletions control/etc/workspace-control/networks.conf
Expand Up @@ -12,7 +12,7 @@
# The name of the bridge to use for every VM NIC without a match in the
# "bridges" section below. If blank or missing, there will be no default.

default: virbr1
default: eth0


[bridges]
Expand All @@ -32,10 +32,6 @@ default: virbr1
# xenbr0: 192.168.0.0-192.168.0.255
# virbr8: 172.16.0.0-172.31.255.255

virbr3: 192.168.0.0/24
virbr4: 192.168.1.0/24



[dhcp-bridges]

Expand All @@ -47,14 +43,11 @@ virbr4: 192.168.1.0/24

# The DHPCd process will be listening for requests on a particular interface:

virbr1: vif0.1
virbr3: vif0.2
virbr4: vif0.3
eth0: eth0

# Also note that for each network DHPCd will serve, a "subnet" configuration
# will be required in dhcpd.conf. See share/workspace-control/dhcpd.conf.example


[dhcp]

# This is called via sudo to adjust DHCP configurations for VMs.
Expand Down
6 changes: 3 additions & 3 deletions control/etc/workspace-control/sudo.conf
Expand Up @@ -12,9 +12,9 @@ sudo: /usr/bin/sudo
#
# Corresponding entries must be in the sudoers file, e.g:
#
# nimbus ALL=(root) NOPASSWD: /opt/nimbus/libexec/mount-alter.sh
# nimbus ALL=(root) NOPASSWD: /opt/nimbus/libexec/dhcp-config.sh
# nimbus ALL=(root) NOPASSWD: /opt/nimbus/libexec/ebtables-config.sh
# nimbus ALL=(root) NOPASSWD: /opt/nimbus/libexec/workspace-control/mount-alter.sh
# nimbus ALL=(root) NOPASSWD: /opt/nimbus/libexec/workspace-control/dhcp-config.sh
# nimbus ALL=(root) NOPASSWD: /opt/nimbus/libexec/workspace-control/ebtables-config.sh
#
# ...where "nimbus" (on the left) is the privileged account that runs the
# workspace-control program.
Expand Down
1 change: 1 addition & 0 deletions control/libexec/workspace-control/dhcp-config.sh
Expand Up @@ -270,6 +270,7 @@ until my_lockfile ; do
fi
done

SUCCESS="y"

if [ "$ADDREM" = "rem" ]; then
echo "CMD: $DHCPD_STOP"
Expand Down
6 changes: 3 additions & 3 deletions control/libexec/workspace-control/mount-alter.sh
Expand Up @@ -101,15 +101,15 @@ DRYRUN="false" # or "true"

# Only requests to mount files UNDER this directory are honored.
# You must use absolute path and include trailing slash.
IMAGE_DIR=/opt/workspace/secureimages/
IMAGE_DIR=/opt/nimbus/var/workspace-control/secureimages/

# Only requests to mount files TO this directory are honored.
# You must use absolute path and include trailing slash.
MOUNTPOINT_DIR=/opt/workspace/mnt/
MOUNTPOINT_DIR=/opt/nimbus/var/workspace-control/mnt/

# Only requests to copy over files UNDER this directory are honored.
# You must use absolute path and include trailing slash.
FILE_DIR=/opt/workspace/tmp/
FILE_DIR=/opt/nimbus/var/workspace-control/tmp/


#############
Expand Down
4 changes: 2 additions & 2 deletions control/src/python/workspacecontrol/defaults/Common.py
Expand Up @@ -178,10 +178,10 @@ def _configure_logging(self):
logfiledir = self.resolve_var_dir(logfiledir)

# base filename on time, action and name
self.logfilepath = logfiledir + "/" + time.strftime("wclog-%Y-%m-%d-%H.%M.%S")
self.logfilepath = logfiledir + "/" + time.strftime("wclog--%Y-%m-%d--h%H.m%M.s%S")
name = self.p.get_arg_or_none(wc_args.NAME)
if name:
self.logfilepath += "-" + str(name)
self.logfilepath += "--" + str(name)
action = self.p.get_arg_or_none(wc_args.ACTION)
if action:
self.logfilepath += "-" + str(action)
Expand Down
Expand Up @@ -156,7 +156,7 @@ def choose_vifnames(self, nic_set, vm_name):
if len(nic.vifname) > 15:
raise InvalidInput("vifname exceeds maximum interface name length: %s" % nic.vifname)

self.c.log.debug("%s: chose '%s' for vif name" % (logstr, nic.vifname))
self.c.log.debug("nic-%d: chose '%s' for vif name" % (i, nic.vifname))

# --------------------------------------------------------------------------
# network_name_to_bridge() from LocalNetworkSetup interface
Expand Down
Expand Up @@ -684,12 +684,12 @@ def _one_imagestr_propagation(self, lf, imgstr, unprop):
lf.path = self._derive_instance_dir()
lf.path = os.path.join(lf.path, local_filename)

if os.path.exists(lf.path):
pathexists = os.path.exists(lf.path)
if pathexists and lf._propagate_needed:
raise InvalidInput("file is going to be transferred to this host but the target exists already: '%s'" % lf.path)
if not pathexists and lf._unpropagate_needed:
raise InvalidInput("file is going to be transferred from this host but it does not exist: '%s'" % lf.path)

if self.c.trace:
self.c.log.debug("A file is going to be transferred to '%s' because of the input '%s'" % (lf.path, imgstr))

return

def _process_new_unproptargets(self, l_files, unproptargets_arg):
Expand Down
Expand Up @@ -3,6 +3,20 @@
from workspacecontrol.api.exceptions import *
import lvrt_model

class vmmadapter(PlatformAdapter):

def __init__(self, params, common):
PlatformAdapter.__init__(self, params, common)
other_uri = self.p.get_conf_or_none("libvirt_connections", "kvm0")
if other_uri:
self.connection_uri = other_uri
else:
self.connection_uri = "qemu:///system"
self.c.log.debug("KVM libvirt URI: '%s'" % self.connection_uri)

def validate(self):
self.c.log.debug("validating libvirt kvm adapter")

class intakeadapter(PlatformInputAdapter):
def __init__(self, params, common):
PlatformInputAdapter.__init__(self, params, common)
Expand Down
Expand Up @@ -7,8 +7,12 @@ class vmmadapter(PlatformAdapter):

def __init__(self, params, common):
PlatformAdapter.__init__(self, params, common)
testuri = ""
self.connection_uri = testuri
other_uri = self.p.get_conf_or_none("libvirt_connections", "xen3")
if other_uri:
self.connection_uri = other_uri
else:
self.connection_uri = "xen:///"
self.c.log.debug("Xen libvirt URI: '%s'" % self.connection_uri)

def validate(self):
self.c.log.debug("validating libvirt xen3 adapter")
Expand Down Expand Up @@ -61,6 +65,17 @@ def fill_model(self, dom, local_file_set, nic_set, kernel):
if kernel.initrd_path:
dom.os.initrd = kernel.initrd_path

rootmountpoint = None
for lf in local_file_set.flist():
if lf.rootdisk:
rootmountpoint = lf.mountpoint
if not rootmountpoint:
raise UnexpectedError("cannot find root disk's mountpoint")

rootstring = "ro root=/dev/%s" % rootmountpoint
if kernel.kernel_args:
dom.os.cmdline = kernel.kernel_args
dom.os.cmdline = "%s %s" % (rootstring, kernel.kernel_args)
else:
dom.os.cmdline = "%s" % (rootstring)


Expand Up @@ -207,7 +207,8 @@ def info(self, handle):
raise UnexpectedError("Unrecognized state information from libvirt: %s" % str(infolist[0]))

if state == DOM_STATE_NOSTATE:
self.c.log.warn("found VM with name '%s' but it has no state -- is this a persistent VM? Pretending it was not found at all.")
# this is the case right after a graceful shutdown succeeds
self.c.log.debug("found VM with name '%s' but it has no state -- from the perspective 'above' this means it was not found at all." % handle)
return None

if state == DOM_STATE_RUNNING:
Expand Down Expand Up @@ -295,6 +296,10 @@ def _validate_create_basics(self, dom):
memory = int(memory)
except:
raise InvalidInput("memory given for create is not an integer: %s" % memory)

# convert MB -> kB
memory = memory * 1024

if dom:
dom.memory = memory
self.c.log.debug("memory for create: %d" % memory)
Expand Down Expand Up @@ -352,6 +357,7 @@ def _fill_model(self, local_file_set, nic_set, kernel):
interface = lvrt_model.Interface()
interface.source = nic.bridge
interface.mac = nic.mac
interface.target = nic.vifname
dom.devices.interfaces.append(interface)

self.intakeadapter.fill_model(dom, local_file_set, nic_set, kernel)
Expand Down
Expand Up @@ -187,6 +187,9 @@ def __init__(self):
# <mac address='aa:00:00:00:00:11'/>
self.mac = None

# <target dev='wrksp-40-0'/>
self.target = None

# <script path='/etc/xen/scripts/vif-bridge'/>
self.script_path = None

Expand All @@ -197,6 +200,9 @@ def toXML(self):
x.write(L(3, "<source bridge='%s' />" % self.source))
x.write(L(3, "<mac address='%s' />" % self.mac))

if self.target:
x.write(L(3, "<target dev='%s' />" % self.target))

if self.script_path:
x.write(L(3, "<script path='%s' />" % self.script_path))

Expand Down

0 comments on commit 23494c1

Please sign in to comment.