Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/planetstack/openstack_observer/event_loop.py b/planetstack/openstack_observer/event_loop.py
index 9e8c7b4..12965bb 100644
--- a/planetstack/openstack_observer/event_loop.py
+++ b/planetstack/openstack_observer/event_loop.py
@@ -12,6 +12,7 @@
from collections import defaultdict
from core.models import *
from django.db.models import F, Q
+from django.db import connection
#from openstack.manager import OpenStackManager
from openstack.driver import OpenStackDriver
from util.logger import Logger, logging, logger
@@ -238,6 +239,7 @@
raise StepNotReady
def sync(self, S, deletion):
+ try:
step = self.step_lookup[S]
start_time=time.time()
@@ -337,6 +339,8 @@
except KeyError,e:
logger.info('Step %r is a leaf' % step)
pass
+ finally:
+ connection.close()
def run(self):
if not self.driver.enabled:
diff --git a/planetstack/tools/get_instance_ip.py b/planetstack/tools/get_instance_ip.py
index c227e2e..b3e4502 100644
--- a/planetstack/tools/get_instance_ip.py
+++ b/planetstack/tools/get_instance_ip.py
@@ -21,8 +21,13 @@
return r.json()[0]["id"]
def get_node_id(host_name):
- r = requests.get(NODES_API + "?name=%s" % host_name, auth=opencloud_auth)
- return r.json()[0]["id"]
+ r = requests.get(NODES_API)
+ nodes = r.json()
+ for node in nodes:
+ if node["name"].lower() == host_name.lower():
+ return node["id"]
+ print >> sys.stderr, "Error: failed to find node %s" % host_name
+ sys.exit(-1)
def get_slivers(slice_id=None, node_id=None):
queries = []
diff --git a/planetstack/tools/get_instance_name.py b/planetstack/tools/get_instance_name.py
index a0b55d2..01fc841 100644
--- a/planetstack/tools/get_instance_name.py
+++ b/planetstack/tools/get_instance_name.py
@@ -18,8 +18,15 @@
return r.json()[0]["id"]
def get_node_id(host_name):
- r = requests.get(NODES_API + "?name=%s" % host_name, auth=opencloud_auth)
- return r.json()[0]["id"]
+# r = requests.get(NODES_API + "?name=%s" % host_name, auth=opencloud_auth)
+# return r.json()[0]["id"]
+ r = requests.get(NODES_API)
+ nodes = r.json()
+ for node in nodes:
+ if node["name"].lower() == host_name.lower():
+ return node["id"]
+ print >> sys.stderr, "Error: failed to find node %s" % host_name
+ sys.exit(-1)
def get_slivers(slice_id=None, node_id=None):
queries = []