Add clustering capabilities to Opendaylight role 45/61945/10
authorDimitrios Markou <mardim@intracom-telecom.com>
Thu, 17 Aug 2017 15:35:34 +0000 (18:35 +0300)
committerPeriyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>
Thu, 5 Oct 2017 08:22:21 +0000 (10:22 +0200)
When the variable 'cluster' is true then the Opendaylight
controller will be deployed in a clustering mode.

Change-Id: I8a1085bae933ad07eab33fc677d199ef613bc040
Signed-off-by: Dimitrios Markou <mardim@intracom-telecom.com>
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@ericsson.com>
tasks/configure_cluster.yml [new file with mode: 0644]
tasks/configure_karaf_features.yml
tasks/main.yml
templates/akka.conf.j2 [new file with mode: 0644]
templates/module-shards.conf.j2 [new file with mode: 0644]
vars/main.yml

diff --git a/tasks/configure_cluster.yml b/tasks/configure_cluster.yml
new file mode 100644 (file)
index 0000000..3f013c6
--- /dev/null
@@ -0,0 +1,16 @@
+- name: Create initial folder in Opendaylight
+  file:
+    path: /opt/opendaylight/configuration/initial
+    state: directory
+    mode: 0777
+
+- name: Add module-shards.conf file
+  template:
+    src: "module-shards.conf.j2"
+    dest: "/opt/opendaylight/configuration/initial/module-shards.conf"
+
+- name: Add akka.conf file
+  template:
+    src: "akka.conf.j2"
+    dest: "/opt/opendaylight/configuration/initial/akka.conf"
+
index 9bdcb27dd03c793829f4756b9edc1d8a290e589d..7de179e4767f75f1394de8a182d080aaeb816cb4 100644 (file)
@@ -1,6 +1,6 @@
 - name: Build Karaf feature list
   set_fact:
-    features: "{{ default_features + extra_features }}"
+    features: "{{ default_features + extra_features + cluster_features if cluster else default_features + extra_features }}"
 
 - name: Configure ODL Karaf features
   lineinfile:
index 48c91c75dc356b15ebb840a4f7a735598becdea8..de73435aa9b0314bb789aced4581e2edcb2c0e6f 100644 (file)
@@ -1,5 +1,9 @@
 ---
 - include: install_odl.yml
+- include: configure_cluster.yml
+  when:
+   - cluster
+
 - include: configure_karaf_features.yml
 - include: configure_nb_rest_port.yml
 - include: open_nb_rest_port.yml
diff --git a/templates/akka.conf.j2 b/templates/akka.conf.j2
new file mode 100644 (file)
index 0000000..d584f18
--- /dev/null
@@ -0,0 +1,62 @@
+# {{ ansible_managed }}
+
+{%- set odl_cluster_list = [] %}
+{% set vars = {'host_ip': None,'member_index': None} %}
+
+{% for host in groups["neutron_server_container"]  %}
+   {% if inventory_hostname == host %}
+      {% set _ = vars.update({'host_ip': hostvars[host]['container_address']|string}) %}
+      {% set _ = vars.update({'member_index': '"' + "member-" + loop.index|string + '"'}) %}
+   {% endif %}
+   {% set ip_address =  hostvars[host]['container_address']|string %}
+   {% set _ = odl_cluster_list.append('"' + "akka.tcp://opendaylight-cluster-data@" + ip_address + ":" + {{ akka_remoting_port }} + '"')  %}
+{%- endfor %}
+
+odl-cluster-data {
+  akka {
+    remote {
+      artery {
+        enabled = off
+        canonical.hostname = "{{vars.host_ip}}"
+        canonical.port = { akka_remoting_port }}
+      }
+      netty.tcp {
+        hostname = "{{vars.host_ip}}"
+        port = { akka_remoting_port }}
+      }
+      # when under load we might trip a false positive on the failure detector
+      # transport-failure-detector {
+        # heartbeat-interval = 4 s
+        # acceptable-heartbeat-pause = 16s
+      # }
+    }
+
+    cluster {
+      # Remove ".tcp" when using artery.
+      seed-nodes = [{{ odl_cluster_list | join(',') }}]
+      roles = [
+        {{vars.member_index}}
+      ]
+
+    }
+
+    persistence {
+      # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by
+      # modifying the following two properties. The directory location specified may be a relative or absolute path.
+      # The relative path is always relative to KARAF_HOME.
+
+      # snapshot-store.local.dir = "target/snapshots"
+      # journal.leveldb.dir = "target/journal"
+
+      journal {
+        leveldb {
+          # Set native = off to use a Java-only implementation of leveldb.
+          # Note that the Java-only version is not currently considered by Akka to be production quality.
+
+          # native = off
+        }
+      }
+    }
+  }
+}
+
diff --git a/templates/module-shards.conf.j2 b/templates/module-shards.conf.j2
new file mode 100644 (file)
index 0000000..1217ecc
--- /dev/null
@@ -0,0 +1,45 @@
+# {{ ansible_managed }}
+
+{%- set members_list = [] %}
+
+{% for host in groups["neutron_server_container"]  %}
+   {% set indexing = loop.index|string %}
+   {% set _ = members_list.append('"' + "member-" + indexing + '"')  %}
+{% endfor %}
+
+module-shards = [
+    {
+        name = "default"
+        shards = [
+            {
+                name="default"
+                replicas = [
+                  {{ members_list | join(',') }}
+                ]
+            }
+        ]
+    },
+    {
+        name = "topology"
+        shards = [
+            {
+                name="topology"
+                replicas = [
+                  {{ members_list | join(',') }}
+                ]
+            }
+        ]
+    },
+    {
+        name = "inventory"
+        shards = [
+            {
+                name="inventory"
+                replicas = [
+                  {{ members_list | join(',') }}
+                ]
+            }
+        ]
+    }
+]
+
index bfddb2354827d33d089d6bfb3974895af8d27109..0bc469167698a041f71d534d9fece11e2db3d95a 100755 (executable)
@@ -31,10 +31,27 @@ default_features:
 # CLIs is an anti-goal for CI/CD and automated deployments generally.
 extra_features: []
 
+# Deploying Opendaylight in a clustering mode is a feature
+# which is only supported when the current role is consumed
+# by the OSA project.
+# https://github.com/openstack/openstack-ansible
+
+# Enable or disable deploying OpenDaylight as a cluster.
+cluster: false
+
+# If OpenDaylight is deployed as a cluster, these features are required.
+cluster_features:
+  - 'odl-mdsal-clustering'
+  - 'odl-jolokia'
+
 # Specifies the port for the ODL northbound REST interface to listen on.
 # This was added because OpenStack's Swift project uses a conflicting port.
 nb_rest_port: 8080
 
+# Specifies the port for the ODL clustering which is being used by Akka
+# remoting for east-west communication.
+akka_remoting_port: 2550
+
 # Method to install ODL
 # Valid options:
 #   rpm_repo: Install ODL using its Yum repo config