Permalink
Browse files

Merge branch 'master' of github.com:nimbusproject/nimbus

  • Loading branch information...
2 parents 00fb6fa + 44aae3e commit 5e0fafd591de56dce7cc9c61a0f06d7f85b08ed3 @buzztroll buzztroll committed May 11, 2011
@@ -50,4 +50,10 @@ public int getAliasType() {
public String getAliasTypeData() {
return aliasTypeData;
}
+
+ public String toString() {
+
+ return "userID: '" + userId + "' aliasName: '" + aliasName + "' friendlyName: '" + friendlyName
+ + "' aliasType: '" + aliasType + "' aliasTypeData: '" + aliasTypeData + "'";
+ }
}
@@ -4,6 +4,7 @@
from urlparse import urlparse
import httplib
import shutil
+from array import array
from propagate_adapter import PropagationAdapter
from workspacecontrol.api.exceptions import *
import workspacecontrol.main.wc_args as wc_args
@@ -26,7 +27,10 @@ def validate_propagate_source(self, imagestr):
raise InvalidInput("invalid url, not https:// " + remote)
def validate_unpropagate_target(self, imagestr):
- raise InvalidInput("HTTPS unpropagation is not supported.")
+ url = urlparse(imagestr)
+ #urlparse breaks the url into a tuple
+ if url[0] != "https":
+ raise InvalidInput("invalid url, not https:// " + remote)
def propagate(self, remote_source, local_absolute_target):
self.c.log.info("HTTPS propagation - remote source: %s" % remote_source)
@@ -45,10 +49,6 @@ def propagate(self, remote_source, local_absolute_target):
port = 80
else:
port = 443
- except ValueError:
- errmsg = "%s doesn't seem to be a port (must be an integer)" % host_port[1]
- self.c.log.exception(errmsg)
- raise InvalidInput(errmsg)
credential = self._get_credential()
self.c.log.debug("server: %s port %s credential %s" % (host, port, credential))
if credential:
@@ -75,7 +75,54 @@ def propagate(self, remote_source, local_absolute_target):
self.c.log.info("Transfer complete.")
def unpropagate(self, local_absolute_source, remote_target):
- raise InvalidInput("HTTP unpropagation is not supported.")
+ self.c.log.info("HTTPS unpropagation - local source: %s" % local_absolute_source)
+ self.c.log.info("HTTPS unpropagation - remote target: %s" % remote_target)
+
+ url = urlparse(remote_target)
+ scheme = url[0]
+ netloc = url[1]
+ path = url[2] + "?" + url[4]
+ host_port = netloc.split(":")
+ host = host_port[0]
+ try:
+ port = int(host_port[1])
+ except IndexError:
+ if scheme == 'http':
+ port = 80
+ else:
+ port = 443
+ credential = self._get_credential()
+ self.c.log.debug("server: %s port %s credential %s" % (host, port, credential))
+
+ if credential:
+ connection = HTTPSConnectionCompat(host, port, strict=False, key_file=credential, cert_file=credential)
+ else:
+ connection = HTTPSConnectionCompat(host, port)
+
+ try:
+ try:
+ image = open(local_absolute_source)
+ # We pass an mmaped string, because httplib doesn't support passing
+ # file objects in Python 2.4
+ image_size = os.stat(image.name).st_size
+ try:
+ connection.request("PUT", path, image, headers={'content-length': image_size})
+ except:
+ self.c.log.exception("Problem unpropagating to %s" % remote_target)
+ raise
+ except:
+ self.c.log.exception("Could not open %s" % local_absolute_source)
+ raise
+ finally:
+ image.close()
+
+ response = connection.getresponse()
+
+ if response.status != 200:
+ raise InvalidInput("Problem unpropagating to %s. Got: '%s'" % (remote_target, response.reason))
+
+ self.c.log.info("Transfer complete.")
+
def _get_credential(self):
extra_args = self.p.get_arg_or_none(wc_args.EXTRA_ARGS)
@@ -141,3 +188,34 @@ def _get_handle_redirects(self, connection, path):
raise UnexpectedError(errmsg)
return self._get_handle_redirects(connection, redirect_path)
+
+class HTTPSConnectionCompat(httplib.HTTPSConnection):
+ """
+ HTTPSConnectionCompat subclasses HTTPSConnection to allow us to
+ send large files. This is not supported in the httplib that is bundled
+ with Python 2.4.
+
+ Once Python 2.4 compatibility is dropped, feel free to use a the
+ HTTPSConnection object included with Python.
+ """
+
+ def send(self, data):
+ """Send `data' to the server."""
+
+ if self.sock is None:
+ if self.auto_open:
+ self.connect()
+ else:
+ raise NotConnected()
+
+ if self.debuglevel > 0:
+ print "send:", repr(data)
+ blocksize = 8192
+ if hasattr(data,'read') and not isinstance(data, array):
+ if self.debuglevel > 0: print "sendIng a read()able"
+ datablock = data.read(blocksize)
+ while datablock:
+ self.sock.sendall(datablock)
+ datablock = data.read(blocksize)
+ else:
+ self.sock.sendall(data)
@@ -35,27 +35,27 @@
# result of "generate-index.py < workspacepilot.py"
INDEX = """
I. Globals (lines 10-69)
- II. Embedded, default configuration file (lines 71-191)
- III. Imports (lines 193-220)
- IV. Exceptions (lines 222-348)
- V. Logging (lines 350-569)
- VI. Signal handlers (lines 571-673)
- VII. Timer (lines 675-700)
- VIII. Path/system utilities (lines 702-1073)
- IX. Action (lines 1075-1126)
- X. ReserveSlot(Action) (lines 1128-1732)
- XI. KillNine(ReserveSlot) (lines 1734-1812)
- XII. ListenerThread(Thread) (lines 1814-1919)
- XIII. StateChangeListener (lines 1921-2147)
- XIV. XenActions(StateChangeListener) (lines 2149-2877)
- XV. FakeXenActions(XenActions) (lines 2879-2993)
- XVI. XenKillNine(XenActions) (lines 2995-3126)
- XVII. VWSNotifications(StateChangeListener) (lines 3128-3743)
- XVIII. Configuration objects (lines 3745-3981)
- XIX. Convert configurations (lines 3983-4245)
- XX. External configuration (lines 4247-4317)
- XXI. Commandline arguments (lines 4319-4534)
- XXII. Standalone entry and exit (lines 4536-4729)
+ II. Embedded, default configuration file (lines 71-205)
+ III. Imports (lines 207-234)
+ IV. Exceptions (lines 236-362)
+ V. Logging (lines 364-583)
+ VI. Signal handlers (lines 585-687)
+ VII. Timer (lines 689-714)
+ VIII. Path/system utilities (lines 716-1087)
+ IX. Action (lines 1089-1140)
+ X. ReserveSlot(Action) (lines 1142-1746)
+ XI. KillNine(ReserveSlot) (lines 1748-1826)
+ XII. ListenerThread(Thread) (lines 1828-1933)
+ XIII. StateChangeListener (lines 1935-2161)
+ XIV. XenActions(StateChangeListener) (lines 2163-2898)
+ XV. FakeXenActions(XenActions) (lines 2900-3014)
+ XVI. XenKillNine(XenActions) (lines 3016-3153)
+ XVII. VWSNotifications(StateChangeListener) (lines 3155-3770)
+ XVIII. Configuration objects (lines 3772-4011)
+ XIX. Convert configurations (lines 4013-4285)
+ XX. External configuration (lines 4287-4357)
+ XXI. Commandline arguments (lines 4359-4574)
+ XXII. Standalone entry and exit (lines 4576-4769)
"""
RESTART_XEND_SECONDS_DEFAULT = 2.0
@@ -146,6 +146,20 @@
# If unconfigured, default is 2.0 seconds
#restart_xend_secs: 0.3
+
+# This option determines whether pilot will attempt to bubble down memory for
+# VMs. The Xen Best Practices wiki page at
+# http://wiki.xensource.com/xenwiki/XenBestPractices recommends that you set a
+# fixed amount of memory for dom0 because:
+#
+# 1. (dom0) Linux kernel calculates various network related parameters based
+# on the boot time amount of memory.
+# 2. Linux needs memory to store the memory metadata (per page info structures),
+# and this allocation is also based on the boot time amount of memory.
+#
+# Anything that is not 'yes' is taken as a no, and yes is the default
+#bubble_mem: no
+
[systempaths]
# This is only necessary if using SSH as a backup notification mechanism
@@ -2295,8 +2309,11 @@ def reserving(self, timeout=None):
if not self.initialized:
raise ProgrammingError("not initialized")
-
-
+
+ if not self.conf.bubble_mem:
+ log.debug("Memory bubbling disabled. No reservation neccessary.")
+ return
+
memory = self.conf.memory
if self.common.trace:
log.debug("XenActions.reserving(), reserving %d MB" % memory)
@@ -2355,6 +2372,10 @@ def unreserving(self, timeout=None):
if self.common.trace:
log.debug("XenActions.unreserving(), unreserving %d MB" % memory)
+ if not self.conf.bubble_mem:
+ log.debug("Memory bubbling disabled. No unreservation neccessary.")
+ return
+
# Be sure to unlock for every exit point.
lockhandle = _get_lockhandle(self.conf.lockfile)
_lock(lockhandle)
@@ -2450,7 +2471,7 @@ def unreserving(self, timeout=None):
raise UnexpectedError(errmsg)
_unlock(lockhandle)
-
+
if raiseme:
raise raiseme
@@ -3069,6 +3090,7 @@ def unreserving(self, timeout=None):
else:
log.info("XenKillNine unreserving, releasing %d MB" % memory)
+
curmem = self.currentAllocation_MB()
log.info("current memory MB = %d" % curmem)
@@ -3085,6 +3107,10 @@ def unreserving(self, timeout=None):
killedVMs = self.killAll()
if killedVMs:
raiseme = KilledVMs(killedVMs)
+
+ if not self.conf.bubble_mem:
+ log.debug("Memory bubbling disabled. No return of memory neccessary.")
+ return
if memory == XenActionsConf.BESTEFFORT:
targetmem = freemem + curmem
@@ -3120,6 +3146,7 @@ def unreserving(self, timeout=None):
else:
raise UnexpectedError(errmsg)
+
if raiseme:
raise raiseme
@@ -3839,7 +3866,7 @@ class XenActionsConf:
BESTEFFORT = "BESTEFFORT"
- def __init__(self, xmpath, xendpath, xmsudo, sudopath, memory, minmem, xend_secs, lockfile):
+ def __init__(self, xmpath, xendpath, xmsudo, sudopath, memory, minmem, xend_secs, lockfile, bubble_mem):
"""Set the configurations.
Required parameters:
@@ -3861,6 +3888,8 @@ def __init__(self, xmpath, xendpath, xmsudo, sudopath, memory, minmem, xend_secs
* xend_secs -- If xendpath is configured, amount of time to
wait after a restart before checking if it booted.
+
+ * bubble_mem -- If set to False, pilot will not attempt memory bubbling
Raise InvalidConfig if there is a problem with parameters.
@@ -3871,6 +3900,7 @@ def __init__(self, xmpath, xendpath, xmsudo, sudopath, memory, minmem, xend_secs
self.sudopath = sudopath
self.xendpath = xendpath
self.lockfile = lockfile
+ self.bubble_mem = bubble_mem
log.debug("Xenactions lockfile: %s" % lockfile)
if memory == None:
@@ -4116,9 +4146,19 @@ def getXenActionsConf(opts, config):
except:
msg = "restart_xend_secs ('%s') is not a number" % xend_secs
raise InvalidConfig(msg)
+
+ bubble_mem = True
+ try:
+ bubble_mem_val = config.get("xen", "bubble_mem")
+ if bubble_mem_val:
+ if bubble_mem_val.lower() == 'no':
+ bubble_mem = False
+ except Exception, e:
+ log.debug("No bubble_mem attribute set, assuming True ")
+ log.info("Bubbling set to false!")
if not opts.killnine:
- return XenActionsConf(xm, xend, xmsudo, sudo, opts.memory, minmem, xend_secs, lockfile)
+ return XenActionsConf(xm, xend, xmsudo, sudo, opts.memory, minmem, xend_secs, lockfile, bubble_mem)
else:
alt = "going to kill all guest VMs (if they exist) and give dom0 "
alt += "their memory (which may or may not be the maximum available) "
@@ -4146,7 +4186,7 @@ def getXenActionsConf(opts, config):
log.info(msg + ", %s" % alt)
dom0mem = XenActionsConf.BESTEFFORT
- return XenActionsConf(xm, xend, xmsudo, sudo, dom0mem, minmem, xend_secs, lockfile)
+ return XenActionsConf(xm, xend, xmsudo, sudo, dom0mem, minmem, xend_secs, lockfile, bubble_mem)
def getVWSNotificationsConf(opts, config):
"""Return populated VWSNotificationsConf object or raise InvalidConfig
@@ -6,7 +6,27 @@
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<import resource="main.conflocator.xml" />
+ <import resource="authz-callout-ACTIVE.xml" />
+ <bean id="other.AuthzDataSource"
+ class="org.apache.commons.dbcp.BasicDataSource">
+ <property name="driverClassName" value="org.sqlite.JDBC" />
+ <property name="maxActive" value="10" />
+ <property name="maxIdle" value="4" />
+ <property name="maxWait" value="2000" />
+ <property name="poolPreparedStatements" value="true" />
+
+ <property name="url"
+ value="jdbc:sqlite://$CUMULUS{cumulus.authz.db}" />
+ <property name="username" value="nimbus"/>
+ <property name="password" value="nimbus"/>
+ </bean>
+
+
+ <bean id="other.authzDBAdapter" class="org.nimbus.authz.AuthzDBAdapter">
+ <constructor-arg ref="other.AuthzDataSource"/>
+ </bean>
+
<bean id="nimbus-rm.scheduler.SlotManagement"
class="org.globus.workspace.scheduler.defaults.pilot.PilotSlotManagement"
init-method="validate">
@@ -100,13 +120,16 @@
<property name="extraProperties" value="$PILOT{pbs.extra.properties}" />
<property name="destination" value="$PILOT{pbs.destination}" />
<property name="grace" value="$PILOT{pbs.grace}" />
+ <property name="accounting" value="$PILOT{pbs.accounting.type}" />
<!-- Needed workspace service modules -->
<constructor-arg ref="nimbus-rm.home.instance" />
<constructor-arg ref="nimbus-rm.loglevels" />
<constructor-arg ref="other.MainDataSource" />
<constructor-arg ref="other.timerManager" />
+ <constructor-arg ref="other.authzDBAdapter" />
+ <constructor-arg ref="nimbus-rm.service.binding.AuthorizationCallout" />
<!-- set after object creation time to avoid circular dep with home -->
<property name="instHome" ref="nimbus-rm.home.instance" />
Oops, something went wrong.

0 comments on commit 5e0fafd

Please sign in to comment.