From 4803b54bdf72347f6843549df8e4fa10d622bd7c Mon Sep 17 00:00:00 2001
From: Paul Bourke <paul.bourke@oracle.com>
Date: Thu, 15 Jun 2017 15:18:01 +0100
Subject: [PATCH] Add dev mode for Horizon

Includes murano-dashboard plugin

Change-Id: If99b0310dac75776ca462034926dd57794572ce9
---
 ansible/roles/horizon/defaults/main.yml | 15 +++++++++++++++
 ansible/roles/horizon/tasks/clone.yml   | 14 ++++++++++++++
 ansible/roles/horizon/tasks/deploy.yml  |  4 ++++
 3 files changed, 33 insertions(+)
 create mode 100644 ansible/roles/horizon/tasks/clone.yml

diff --git a/ansible/roles/horizon/defaults/main.yml b/ansible/roles/horizon/defaults/main.yml
index e1f56882a3..cd3f859244 100644
--- a/ansible/roles/horizon/defaults/main.yml
+++ b/ansible/roles/horizon/defaults/main.yml
@@ -26,8 +26,12 @@ horizon_services:
       ENABLE_TROVE: "{{ 'yes' if enable_horizon_trove | bool else 'no' }}"
       ENABLE_WATCHER: "{{ 'yes' if enable_horizon_watcher | bool else 'no' }}"
       ENABLE_ZUN: "{{ 'yes' if enable_horizon_zun | bool else 'no' }}"
+      FORCE_GENERATE: "{{ 'yes' if horizon_dev_mode | bool else 'no' }}"
     volumes:
       - "{{ node_config_directory }}/horizon/:{{ container_config_directory }}/:ro"
+      - "{{ kolla_dev_repos_directory ~ '/horizon/horizon:/var/lib/kolla/venv/lib/python2.7/site-packages/horizon' if horizon_dev_mode | bool else '' }}"
+      - "{{ kolla_dev_repos_directory ~ '/horizon/openstack_dashboard:/var/lib/kolla/venv/lib/python2.7/site-packages/openstack_dashboard' if horizon_dev_mode | bool else '' }}"
+      - "{{ kolla_dev_repos_directory ~ '/murano-dashboard/muranodashboard:/var/lib/kolla/venv/lib/python2.7/site-packages/muranodashboard' if horizon_murano_dev_mode | bool else '' }}"
       - "/etc/localtime:/etc/localtime:ro"
       - "kolla_logs:/var/log/kolla/"
 
@@ -53,3 +57,14 @@ horizon_image_full: "{{ horizon_image }}:{{ horizon_tag }}"
 openstack_horizon_auth: "{'auth_url':'{{ openstack_auth.auth_url }}','username':'{{ openstack_auth.username }}','password':'{{ openstack_auth.password }}','project_name':'{{ openstack_auth.project_name }}'}"
 
 horizon_logging_debug: "{{ openstack_logging_debug }}"
+
+
+####################
+# Kolla
+####################
+horizon_git_repository: "{{ kolla_dev_repos_git }}/{{ project_name }}"
+murano_dashboard_git_repository: "{{ kolla_dev_repos_git }}/murano-dashboard"
+
+horizon_dev_repos_pull: "{{ kolla_dev_repos_pull }}"
+horizon_dev_mode: "{{ kolla_dev_mode }}"
+horizon_murano_dev_mode: "{{ kolla_dev_mode }}"
diff --git a/ansible/roles/horizon/tasks/clone.yml b/ansible/roles/horizon/tasks/clone.yml
new file mode 100644
index 0000000000..46799ef668
--- /dev/null
+++ b/ansible/roles/horizon/tasks/clone.yml
@@ -0,0 +1,14 @@
+---
+- name: Cloning Horizon source repositories for development
+  git:
+    repo: "{{ horizon_git_repository }}"
+    dest: "{{ kolla_dev_repos_directory }}/{{ project_name }}"
+    update: "{{ horizon_dev_repos_pull }}"
+
+- name: Cloning murano-dashboard source repositories for development
+  git:
+    repo: "{{ murano_dashboard_git_repository }}"
+    dest: "{{ kolla_dev_repos_directory }}/murano-dashboard"
+    update: "{{ horizon_dev_repos_pull }}"
+  when:
+    - horizon_murano_dev_mode | bool
diff --git a/ansible/roles/horizon/tasks/deploy.yml b/ansible/roles/horizon/tasks/deploy.yml
index 7c5f051eca..16acf06efd 100644
--- a/ansible/roles/horizon/tasks/deploy.yml
+++ b/ansible/roles/horizon/tasks/deploy.yml
@@ -1,6 +1,10 @@
 ---
 - include: config.yml
 
+- include: clone.yml
+  when:
+    - horizon_dev_mode | bool
+
 - include: bootstrap.yml
   when: horizon_backend_database | bool