Merge branch 'master' of git://git.planet-lab.org/plstackapi
diff --git a/planetstack/dependency_walker.py b/planetstack/dependency_walker.py
index 93e1847..bc75b0c 100755
--- a/planetstack/dependency_walker.py
+++ b/planetstack/dependency_walker.py
@@ -55,7 +55,6 @@
def __walk_deps(fn, object, deps):
model = object.__class__.__name__
-
for dep in deps:
#print "Checking dep %s"%dep
peer=None
@@ -74,8 +73,10 @@
if (peer):
try:
peer_objects = peer.all()
- except:
+ except AttributeError:
peer_objects = [peer]
+ except:
+ peer_objects = []
for o in peer_objects:
fn(o, object)
diff --git a/planetstack/model_policy.py b/planetstack/model_policy.py
index 38cc4df..de6f73d 100644
--- a/planetstack/model_policy.py
+++ b/planetstack/model_policy.py
@@ -12,8 +12,12 @@
modelPolicyEnabled = x
def update_dep(d, o):
- if (d.updated < o.updated):
- d.save(update_fields=['updated'])
+ try:
+ if (d.updated < o.updated):
+ d.save(update_fields=['updated'])
+ except AttributeError,e:
+ pdb.set_trace()
+ raise e
def delete_if_inactive(d, o):
#print "Deleting %s (%s)"%(d,d.__class__.__name__)
diff --git a/planetstack/openstack_observer/ansible.py b/planetstack/openstack_observer/ansible.py
index 8570c17..5761327 100755
--- a/planetstack/openstack_observer/ansible.py
+++ b/planetstack/openstack_observer/ansible.py
@@ -46,7 +46,6 @@
template = os_template_env.get_template(name)
buffer = template.render(opts)
- import pdb
#f = open('/tmp/obsans','w')
try:
@@ -61,7 +60,6 @@
f.write(buffer)
f.flush()
- #os.system('cp %s %s-backup'%(fqp,fqp))
run = os.popen('/opt/planetstack/observer/run_ansible '+fqp)
msg = run.read()
status = run.close()
@@ -69,8 +67,17 @@
try:
ok_results = parse_output(msg)
except ValueError,e:
- print str(e)
- raise e
+ all_fatal = re.findall(r'^msg: (.*)',msg,re.MULTILINE)
+ all_fatal2 = re.findall(r'^ERROR: (.*)',msg,re.MULTILINE)
+
+
+ all_fatal.extend(all_fatal2)
+ try:
+ error = ' // '.join(all_fatal)
+ except:
+ pass
+ raise Exception(error)
+
return ok_results
def main():
diff --git a/planetstack/openstack_observer/steps/sync_controller_site_deployments.py b/planetstack/openstack_observer/steps/sync_controller_site_deployments.py
index 32ca19b..9316425 100644
--- a/planetstack/openstack_observer/steps/sync_controller_site_deployments.py
+++ b/planetstack/openstack_observer/steps/sync_controller_site_deployments.py
@@ -17,11 +17,12 @@
'admin_user': controller_site_deployment.controller.admin_user,
'admin_password': controller_site_deployment.controller.admin_password,
'admin_tenant': 'admin',
+ 'ansible_tag': '%s@%s'%(controller_site_deployment.site_deployment.site.login_base,controller_site_deployment.site_deployment.deployment.name), # name of ansible playbook
'tenant': controller_site_deployment.site_deployment.site.login_base,
'tenant_description': controller_site_deployment.site_deployment.site.name}
rendered = template.render(tenant_fields)
- res = run_template('sync_controller_site_deployments.yaml', tenant_fields)
+ res = run_template('sync_controller_site_deployments.yaml', tenant_fields, path='site_deployments')
if (len(res)==1):
controller_site_deployment.tenant_id = res[0]['id']
@@ -32,6 +33,29 @@
raise Exception('Could not create or update user %s'%tenant_fields['tenant'])
def delete_record(self, controller_site_deployment):
- if controller_site_deployment.tenant_id:
+ import pdb
+ pdb.set_trace()
+ if controller_site_deployment.tenant_id:
driver = self.driver.admin_driver(controller=controller_site_deployment.controller)
driver.delete_tenant(controller_site_deployment.tenant_id)
+
+ """
+ Ansible does not support tenant deletion yet
+
+ import pdb
+ pdb.set_trace()
+ template = os_template_env.get_template('delete_controller_site_deployments.yaml')
+ tenant_fields = {'endpoint':controller_site_deployment.controller.auth_url,
+ 'admin_user': controller_site_deployment.controller.admin_user,
+ 'admin_password': controller_site_deployment.controller.admin_password,
+ 'admin_tenant': 'admin',
+ 'ansible_tag': 'site_deployments/%s@%s'%(controller_site_deployment.site_deployment.site.login_base,controller_site_deployment.site_deployment.deployment.name), # name of ansible playbook
+ 'tenant': controller_site_deployment.site_deployment.site.login_base,
+ 'delete': True}
+
+ rendered = template.render(tenant_fields)
+ res = run_template('sync_controller_site_deployments.yaml', tenant_fields)
+
+ if (len(res)!=1):
+ raise Exception('Could not assign roles for user %s'%tenant_fields['tenant'])
+ """