Merge branch 'master' of github.com:open-cloud/xos
diff --git a/xos/openstack_observer/steps/sync_slivers.py b/xos/openstack_observer/steps/sync_slivers.py
index ea6addd..539efba 100644
--- a/xos/openstack_observer/steps/sync_slivers.py
+++ b/xos/openstack_observer/steps/sync_slivers.py
@@ -22,8 +22,11 @@
requested_interval=0
observes=Sliver
- def get_userdata(self, sliver):
+ def get_userdata(self, sliver, pubkeys):
userdata = 'opencloud:\n slicename: "%s"\n hostname: "%s"\n restapi_hostname: "%s"\n restapi_port: "%s"\n' % (sliver.slice.name, sliver.node.name, RESTAPI_HOSTNAME, str(RESTAPI_PORT))
+ userdata += 'ssh-authorized-keys:\n'
+ for key in pubkeys:
+ userdata += ' - %s\n' % key
return userdata
def sync_record(self, sliver):
@@ -83,14 +86,6 @@
else:
image_id = sliver.image.id
- # look up key name at the controller
- # create/fetch keypair
- keyname = None
- keyname = sliver.creator.email.lower().replace('@', 'AT').replace('.', '') +\
- sliver.slice.name
- key_fields = {'name': keyname,
- 'public_key': sliver.creator.public_key}
-
try:
legacy = Config().observer_legacy
except:
@@ -104,7 +99,7 @@
availability_zone_filter = 'nova:%s'%host_filter
sliver_name = '%s-%d'%(sliver.slice.name,sliver.id)
- userData = self.get_userdata(sliver)
+ userData = self.get_userdata(sliver, pubkeys)
if sliver.userData:
userData = sliver.userData
@@ -119,11 +114,9 @@
'ansible_tag':sliver_name,
'availability_zone': availability_zone_filter,
'image_id':image_id,
- 'key_name':keyname,
'flavor_id':sliver.flavor.id,
'nics':nics,
'meta':metadata_update,
- 'key':key_fields,
'user_data':r'%s'%escape(userData)}
res = run_template('sync_slivers.yaml', tenant_fields,path='slivers', expected_num=2)
diff --git a/xos/openstack_observer/steps/sync_slivers.yaml b/xos/openstack_observer/steps/sync_slivers.yaml
index 0cf30df..6ac995f 100644
--- a/xos/openstack_observer/steps/sync_slivers.yaml
+++ b/xos/openstack_observer/steps/sync_slivers.yaml
@@ -2,16 +2,6 @@
- hosts: 127.0.0.1
connection: local
tasks:
- {% if not delete %}
- - nova_keypair:
- state: present
- auth_url: {{ endpoint }}
- login_username: {{ admin_user }}
- login_password: {{ admin_password }}
- login_tenant_name: {{ admin_tenant }}
- name: {{ key_name }}
- public_key: "{{ key.public_key}}"
- {% endif %}
- nova_compute:
auth_url: {{ endpoint }}
login_username: {{ admin_user }}
@@ -24,7 +14,6 @@
state: present
availability_zone: {{ availability_zone }}
image_id: {{ image_id }}
- key_name: {{ key_name }}
wait_for: 200
flavor_id: {{ flavor_id }}
user_data: "{{ user_data }}"
diff --git a/xos/util/logger.py b/xos/util/logger.py
index 4bba8b9..7a0d401 100644
--- a/xos/util/logger.py
+++ b/xos/util/logger.py
@@ -156,6 +156,7 @@
error_logger = Logger(loggername='error', level=logging.ERROR)
critical_logger = Logger(loggername='critical', level=logging.CRITICAL)
logger = info_logger
+observer_logger = Logger(logfile='/var/log/observer.log', loggername='observer', level=logging.DEBUG)
########################################
import time