fixing up the EC2 observer
diff --git a/planetstack/ec2_observer/event_loop.py b/planetstack/ec2_observer/event_loop.py
index 1319fec..fb5f973 100644
--- a/planetstack/ec2_observer/event_loop.py
+++ b/planetstack/ec2_observer/event_loop.py
@@ -16,7 +16,7 @@
from openstack.driver import OpenStackDriver
from util.logger import Logger, logging, logger
#from timeout import timeout
-from planetstack.config import Config
+from planetstack.config import Config, XOS_DIR
from observer.steps import *
from syncstep import SyncStep
from toposort import toposort
@@ -82,7 +82,7 @@
if hasattr(Config(), "observer_steps_dir"):
step_dir = Config().observer_steps_dir
else:
- step_dir = "/opt/planetstack/observer/steps"
+ step_dir = XOS_DIR + "/observer/steps"
for fn in os.listdir(step_dir):
pathname = os.path.join(step_dir,fn)
@@ -336,7 +336,7 @@
while True:
try:
- error_map_file = getattr(Config(), "error_map_path", "/opt/planetstack/error_map.txt")
+ error_map_file = getattr(Config(), "error_map_path", XOS_DIR + "/error_map.txt")
self.error_mapper = ErrorMapper(error_map_file)
# Set of whole steps that failed
diff --git a/planetstack/ec2_observer/event_manager.py b/planetstack/ec2_observer/event_manager.py
index 97454ec..190d4eb 100644
--- a/planetstack/ec2_observer/event_manager.py
+++ b/planetstack/ec2_observer/event_manager.py
@@ -1,7 +1,7 @@
import threading
import requests, json
-from planetstack.config import Config
+from planetstack.config import Config, XOS_DIR
import uuid
import os
@@ -16,13 +16,13 @@
def get_random_client_id():
global random_client_id
- if (random_client_id is None) and os.path.exists("/opt/planetstack/random_client_id"):
+ if (random_client_id is None) and os.path.exists(XOS_DIR + "/random_client_id"):
# try to use the last one we used, if we saved it
try:
- random_client_id = open("/opt/planetstack/random_client_id","r").readline().strip()
+ random_client_id = open(XOS_DIR+"/random_client_id","r").readline().strip()
print "get_random_client_id: loaded %s" % random_client_id
except:
- print "get_random_client_id: failed to read /opt/planetstack/random_client_id"
+ print "get_random_client_id: failed to read " + XOS_DIR + "/random_client_id"
if random_client_id is None:
random_client_id = base64.urlsafe_b64encode(os.urandom(12))
@@ -30,9 +30,9 @@
# try to save it for later (XXX: could race with another client here)
try:
- open("/opt/planetstack/random_client_id","w").write("%s\n" % random_client_id)
+ open(XOS_DIR + "/random_client_id","w").write("%s\n" % random_client_id)
except:
- print "get_random_client_id: failed to write /opt/planetstack/random_client_id"
+ print "get_random_client_id: failed to write " + XOS_DIR + "/random_client_id"
return random_client_id
diff --git a/planetstack/ec2_observer/steps/sync_images.py b/planetstack/ec2_observer/steps/sync_images.py
index 903b73b..b494c06 100644
--- a/planetstack/ec2_observer/steps/sync_images.py
+++ b/planetstack/ec2_observer/steps/sync_images.py
@@ -1,7 +1,7 @@
import os
import base64
from django.db.models import F, Q
-from planetstack.config import Config
+from planetstack.config import Config, XOS_DIR
from ec2_observer.syncstep import SyncStep
from core.models.image import Image
from ec2_observer.awslib import *
@@ -21,10 +21,10 @@
new_images = []
try:
- aws_images = json.loads(open('/opt/planetstack/aws-images').read())
+ aws_images = json.loads(open(XOS_DIR + '/aws-images').read())
except:
aws_images = aws_run('ec2 describe-images --owner 099720109477')
- open('/opt/planetstack/aws-images','w').write(json.dumps(aws_images))
+ open(XOS_DIR + '/aws-images','w').write(json.dumps(aws_images))