From f54c78e2c36d7db53260bc868b5b538cb8e9d911 Mon Sep 17 00:00:00 2001
From: Manuel Buil <mbuil@suse.com>
Date: Wed, 3 Oct 2018 18:18:05 +0200
Subject: [PATCH] [Baremetal] - Change roles and playbooks names

A few playbooks and the create-vm-nodes role should change the name to
reflect the new reality once the baremetal patches are merged. The
playbooks that must change the name are:

- xci-prepare-virtual.yml
- xci-create-virtual.yml

Change-Id: Iaed1f93561fa9d39c7916e0643a5445cdddf4f97
Signed-off-by: Manuel Buil <mbuil@suse.com>
---
 xci/infra/bifrost/infra-provision.sh               |  4 +--
 ...xci-prepare-virtual.yml => xci-prepare-env.yml} |  0
 ...{xci-create-virtual.yml => xci-setup-nodes.yml} |  2 +-
 .../{create-vm-nodes => create-nodes}/README.md    | 35 ++++++++++------------
 .../defaults/main.yml                              |  0
 .../tasks/create_vm.yml                            |  0
 .../tasks/download_opnfvimage.yml                  |  0
 .../tasks/main.yml                                 |  0
 .../tasks/prepare_libvirt.yml                      |  0
 .../templates/net.xml.j2                           |  0
 .../templates/pool_dir.xml.j2                      |  0
 .../templates/vm.xml.j2                            |  0
 .../vars/debian.yml                                |  0
 .../vars/redhat.yml                                |  0
 .../vars/suse.yml                                  |  0
 15 files changed, 18 insertions(+), 23 deletions(-)
 rename xci/infra/bifrost/playbooks/{xci-prepare-virtual.yml => xci-prepare-env.yml} (100%)
 rename xci/infra/bifrost/playbooks/{xci-create-virtual.yml => xci-setup-nodes.yml} (98%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/README.md (84%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/defaults/main.yml (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/tasks/create_vm.yml (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/tasks/download_opnfvimage.yml (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/tasks/main.yml (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/tasks/prepare_libvirt.yml (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/templates/net.xml.j2 (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/templates/pool_dir.xml.j2 (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/templates/vm.xml.j2 (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/vars/debian.yml (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/vars/redhat.yml (100%)
 rename xci/playbooks/roles/{create-vm-nodes => create-nodes}/vars/suse.yml (100%)

diff --git a/xci/infra/bifrost/infra-provision.sh b/xci/infra/bifrost/infra-provision.sh
index ad5b377b..0b25f258 100644
--- a/xci/infra/bifrost/infra-provision.sh
+++ b/xci/infra/bifrost/infra-provision.sh
@@ -32,14 +32,14 @@ ansible-playbook ${XCI_ANSIBLE_PARAMS} \
         -e xci_distro=${XCI_DISTRO} \
         -e pdf_file=${PDF} \
         -e idf_file=${IDF} \
-        ${BIFROST_ROOT_DIR}/playbooks/xci-create-virtual.yml
+        ${BIFROST_ROOT_DIR}/playbooks/xci-setup-nodes.yml
 
 
 ansible-playbook ${XCI_ANSIBLE_PARAMS} \
         --private-key=${XCI_PATH}/xci/scripts/vm/id_rsa_for_dib \
         --user=devuser \
         -i ${XCI_PATH}/xci/playbooks/dynamic_inventory.py \
-        ${BIFROST_ROOT_DIR}/playbooks/xci-prepare-virtual.yml
+        ${BIFROST_ROOT_DIR}/playbooks/xci-prepare-env.yml
 
 source ${XCI_CACHE}/repos/bifrost/scripts/bifrost-env.sh
 
diff --git a/xci/infra/bifrost/playbooks/xci-prepare-virtual.yml b/xci/infra/bifrost/playbooks/xci-prepare-env.yml
similarity index 100%
rename from xci/infra/bifrost/playbooks/xci-prepare-virtual.yml
rename to xci/infra/bifrost/playbooks/xci-prepare-env.yml
diff --git a/xci/infra/bifrost/playbooks/xci-create-virtual.yml b/xci/infra/bifrost/playbooks/xci-setup-nodes.yml
similarity index 98%
rename from xci/infra/bifrost/playbooks/xci-create-virtual.yml
rename to xci/infra/bifrost/playbooks/xci-setup-nodes.yml
index 381c4fd4..9c9c1016 100644
--- a/xci/infra/bifrost/playbooks/xci-create-virtual.yml
+++ b/xci/infra/bifrost/playbooks/xci-setup-nodes.yml
@@ -22,7 +22,7 @@
       include_vars:
         file: "{{ xci_path }}/xci/var/{{ ansible_os_family }}.yml"
   roles:
-    - role: create-vm-nodes
+    - role: create-nodes
       become: yes
     - role: clone-repository
       project: "opnfv/bifrost"
diff --git a/xci/playbooks/roles/create-vm-nodes/README.md b/xci/playbooks/roles/create-nodes/README.md
similarity index 84%
rename from xci/playbooks/roles/create-vm-nodes/README.md
rename to xci/playbooks/roles/create-nodes/README.md
index d96a2981..bf079b9e 100644
--- a/xci/playbooks/roles/create-vm-nodes/README.md
+++ b/xci/playbooks/roles/create-nodes/README.md
@@ -1,14 +1,16 @@
-create-vm-nodes
+create-nodes
 ================
 
-This role creates the XCI VMs used to deploy scenarios. It is a branch from the
-bifrost role "bifrost-create-vm-nodes":
+This role creates the all nodes required for the XCI deployment. In a baremetal
+deployment, it creates the OPNFV VM and provisions the physical servers. In a
+non-baremetal deployment, it creates the OPNFV VM and the rest of VMs used to
+deploy scenarios. It is based on the bifrost role:
 
 https://github.com/openstack/bifrost/tree/master/playbooks/roles/bifrost-create-vm-nodes
 
-It creates the VMs based on the pdf and idf document which describes the
-characteristics of the VMs or physical servers. For more information check the
-spec:
+It creates the VMs or provisions the physical servers based on the pdf and idf
+document which describes the characteristics of the VMs or physical servers.
+For more information check the spec:
 
 https://github.com/opnfv/releng-xci/blob/master/docs/specs/infra_manager.rst
 
@@ -19,9 +21,9 @@ Flow
 The script xci/infra/bifrost/scripts/bifrost-provision.sh will call the
 playbook that starts executing the role:
 
-xci-create-vms.yaml
+xci-setup-nodes.yaml
 
-Note that at this stage the pdf and the opnfv_vm.yml are loaded.
+Note that at this stage the pdf and the opnfv_pdf_vm.yml are loaded.
 
 Some distro specific tasks related to variables are done and then the
 prepare_libvirt playbook is run. This playbook, as the name says,
@@ -32,7 +34,9 @@ the data and finally dump it all into the baremetal_json_file which will be
 read by bifrost in the subsequent role.
 
 The opnfv vm and the rest of vms get created using the xml libvirt template,
-which gets filled with the pdf and opnfv_vm.yml variables.
+which gets filled with the pdf and opnfv_pdf_vm.yml variables. If there is a
+baremetal deployment, the nodes_json_data gets filled in the
+baremetalhoststojson.yml playbook which basically reads the pdf info.
 
 Finally nodes_json_data is dumped.
 
@@ -49,18 +53,9 @@ The following packages are required and ensured to be present:
 Warning
 -------
 
-- It is currently assumed that the OS for the VM will be installed in the first
-disk of the node described by the pdf. That's why there is a [0] in:
-
-    - name: create volume for vm
-      command: >
-        virsh --connect {{ vm_libvirt_uri }}
-        vol-create-as {{ node_storage_pool }} {{ vm_name }}.qcow2
-        {{ item.disks[0].disk_capacity }}
-        --format qcow2 {{ prealloc|default("") }}
-
 - It is assumed that the opnfv VM characteristics are not described in the pdf
-but in a similar document called opnfv_vm.yml
+but in a similar document called opnfv_pdf_vm.yml. There is also an idf
+document opnfv_idf_vm.yml
 
 - All references to csv from bifrost-create-vm-nodes were removed
 
diff --git a/xci/playbooks/roles/create-vm-nodes/defaults/main.yml b/xci/playbooks/roles/create-nodes/defaults/main.yml
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/defaults/main.yml
rename to xci/playbooks/roles/create-nodes/defaults/main.yml
diff --git a/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml b/xci/playbooks/roles/create-nodes/tasks/create_vm.yml
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml
rename to xci/playbooks/roles/create-nodes/tasks/create_vm.yml
diff --git a/xci/playbooks/roles/create-vm-nodes/tasks/download_opnfvimage.yml b/xci/playbooks/roles/create-nodes/tasks/download_opnfvimage.yml
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/tasks/download_opnfvimage.yml
rename to xci/playbooks/roles/create-nodes/tasks/download_opnfvimage.yml
diff --git a/xci/playbooks/roles/create-vm-nodes/tasks/main.yml b/xci/playbooks/roles/create-nodes/tasks/main.yml
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/tasks/main.yml
rename to xci/playbooks/roles/create-nodes/tasks/main.yml
diff --git a/xci/playbooks/roles/create-vm-nodes/tasks/prepare_libvirt.yml b/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/tasks/prepare_libvirt.yml
rename to xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml
diff --git a/xci/playbooks/roles/create-vm-nodes/templates/net.xml.j2 b/xci/playbooks/roles/create-nodes/templates/net.xml.j2
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/templates/net.xml.j2
rename to xci/playbooks/roles/create-nodes/templates/net.xml.j2
diff --git a/xci/playbooks/roles/create-vm-nodes/templates/pool_dir.xml.j2 b/xci/playbooks/roles/create-nodes/templates/pool_dir.xml.j2
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/templates/pool_dir.xml.j2
rename to xci/playbooks/roles/create-nodes/templates/pool_dir.xml.j2
diff --git a/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2 b/xci/playbooks/roles/create-nodes/templates/vm.xml.j2
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2
rename to xci/playbooks/roles/create-nodes/templates/vm.xml.j2
diff --git a/xci/playbooks/roles/create-vm-nodes/vars/debian.yml b/xci/playbooks/roles/create-nodes/vars/debian.yml
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/vars/debian.yml
rename to xci/playbooks/roles/create-nodes/vars/debian.yml
diff --git a/xci/playbooks/roles/create-vm-nodes/vars/redhat.yml b/xci/playbooks/roles/create-nodes/vars/redhat.yml
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/vars/redhat.yml
rename to xci/playbooks/roles/create-nodes/vars/redhat.yml
diff --git a/xci/playbooks/roles/create-vm-nodes/vars/suse.yml b/xci/playbooks/roles/create-nodes/vars/suse.yml
similarity index 100%
rename from xci/playbooks/roles/create-vm-nodes/vars/suse.yml
rename to xci/playbooks/roles/create-nodes/vars/suse.yml
-- 
2.16.6