support syncing ONOS apps to containers on bare metal
diff --git a/xos/observers/onos/steps/sync_onosapp.py b/xos/observers/onos/steps/sync_onosapp.py
index 97bb8a6..0feb2e5 100644
--- a/xos/observers/onos/steps/sync_onosapp.py
+++ b/xos/observers/onos/steps/sync_onosapp.py
@@ -106,14 +106,23 @@
self.write_configs(o)
def get_extra_attributes(self, o):
+ instance = self.get_instance(o)
+
fields={}
fields["files_dir"] = o.files_dir
fields["appname"] = o.name
- fields["nat_ip"] = self.get_instance(o).get_ssh_ip()
+ fields["nat_ip"] = instance.get_ssh_ip()
fields["config_fns"] = o.config_fns
fields["rest_configs"] = o.rest_configs
- fields["dependencies"] = [x.strip() for x in o.dependencies.split(",")]
- fields["ONOS_container"] = "ONOS"
+ if o.dependencies:
+ fields["dependencies"] = [x.strip() for x in o.dependencies.split(",")]
+ else:
+ fields["dependencies"] = []
+
+ if (instance.isolation=="container"):
+ fields["ONOS_container"] = "%s-%s" % (instance.slice.name, str(instance.id))
+ else:
+ fields["ONOS_container"] = "ONOS"
return fields
def sync_fields(self, o, fields):
diff --git a/xos/observers/onos/steps/sync_onosapp.yaml b/xos/observers/onos/steps/sync_onosapp.yaml
index 9105a2e..496fad0 100644
--- a/xos/observers/onos/steps/sync_onosapp.yaml
+++ b/xos/observers/onos/steps/sync_onosapp.yaml
@@ -2,7 +2,7 @@
- hosts: {{ instance_name }}
gather_facts: False
connection: ssh
- user: ubuntu
+ user: {{ username }}
sudo: yes
vars:
appname: {{ appname }}
@@ -17,6 +17,20 @@
tasks:
+ - name: Get Docker IP
+ script: /opt/xos/observers/onos/scripts/dockerip.sh {{ ONOS_container }}
+ register: onosaddr
+
+ - name: Wait for ONOS to come up
+ wait_for:
+ host={{ '{{' }} onosaddr.stdout {{ '}}' }}
+ port={{ '{{' }} item {{ '}}' }}
+ state=present
+ with_items:
+ - 8101
+ - 8181
+ - 9876
+
- name: Config file directory
file:
path=/home/ubuntu/{{ appname }}/
@@ -49,9 +63,10 @@
- name: Wait for ONOS to install the apps
wait_for: timeout=15
+{% if dependencies %}
- name: Add dependencies to ONOS
uri:
- url: http://localhost:8181/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active
+ url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active
method: POST
user: karaf
password: karaf
@@ -59,13 +74,14 @@
{% for dependency in dependencies %}
- {{ dependency }}
{% endfor %}
+{% endif %}
{% if rest_configs %}
# Do this after services have been activated, or it will cause an exception.
# vOLT will re-read its net config; vbng may not.
- name: Add ONOS configuration values
uri:
- url: http://localhost:8181/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/
+ url: http://{{ '{{' }} onosaddr.stdout {{ '}}' }}:8181/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/
body: "{{ '{{' }} item.body {{ '}}' }}"
body_format: raw
method: POST