summaryrefslogtreecommitdiffstats
path: root/xci
diff options
context:
space:
mode:
Diffstat (limited to 'xci')
-rw-r--r--xci/infra/bifrost/playbooks/xci-create-virtual.yml3
-rwxr-xr-xxci/playbooks/dynamic_inventory.py40
-rw-r--r--xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml6
-rw-r--r--xci/playbooks/roles/create-vm-nodes/tasks/main.yml2
-rw-r--r--xci/playbooks/roles/create-vm-nodes/templates/net.xml.j28
-rw-r--r--xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j210
-rw-r--r--xci/var/opnfv_vm_idf.yml19
-rw-r--r--xci/var/opnfv_vm_pdf.yml (renamed from xci/var/opnfv_vm.yml)34
8 files changed, 80 insertions, 42 deletions
diff --git a/xci/infra/bifrost/playbooks/xci-create-virtual.yml b/xci/infra/bifrost/playbooks/xci-create-virtual.yml
index bc40d108..381c4fd4 100644
--- a/xci/infra/bifrost/playbooks/xci-create-virtual.yml
+++ b/xci/infra/bifrost/playbooks/xci-create-virtual.yml
@@ -14,7 +14,8 @@
vars_files:
- "{{ pdf_file }}"
- "{{ idf_file }}"
- - "{{ xci_path }}/xci/var/opnfv_vm.yml"
+ - "{{ xci_path }}/xci/var/opnfv_vm_pdf.yml"
+ - "{{ xci_path }}/xci/var/opnfv_vm_idf.yml"
- "{{ xci_path }}/xci/var/opnfv.yml"
pre_tasks:
- name: Load distribution variables
diff --git a/xci/playbooks/dynamic_inventory.py b/xci/playbooks/dynamic_inventory.py
index f6e93398..7f60f94e 100755
--- a/xci/playbooks/dynamic_inventory.py
+++ b/xci/playbooks/dynamic_inventory.py
@@ -76,6 +76,8 @@ class XCIInventory(object):
def read_pdf_idf(self):
pdf_file = os.environ['PDF']
idf_file = os.environ['IDF']
+ opnfv_file = os.path.dirname(os.path.realpath(__file__)) + "/../var/opnfv_vm_pdf.yml"
+ opnfv_idf_file = os.path.dirname(os.path.realpath(__file__)) + "/../var/opnfv_vm_idf.yml"
nodes = []
host_networks = {}
@@ -93,6 +95,21 @@ class XCIInventory(object):
print(e)
sys.exit(1)
+ with open(opnfv_file) as f:
+ try:
+ opnfv_pdf = yaml.safe_load(f)
+ except yaml.YAMLError as e:
+ print(e)
+ sys.exit(1)
+
+ with open(opnfv_idf_file) as f:
+ try:
+ opnfv_idf = yaml.safe_load(f)
+ except yaml.YAMLError as e:
+ print(e)
+ sys.exit(1)
+
+
valid_host = (host for host in idf['xci']['installers'][self.installer]['nodes_roles'] \
if host in idf['xci']['flavors'][self.flavor] \
and host != 'opnfv')
@@ -119,10 +136,33 @@ class XCIInventory(object):
if 'dns' in ndata.keys():
host_networks[hostname][network]['dns'] = str(ndata['dns'])
+ # Get also vlan and mac_address from pdf
+ host_networks[hostname][network]['mac_address'] = str(pdf_host_info['interfaces'][int(network_interface_num)]['mac_address'])
+ host_networks[hostname][network]['vlan'] = str(pdf_host_info['interfaces'][int(network_interface_num)]['vlan'])
+
+ # Get also vlan and mac_address from opnfv_pdf
+ mgmt_idf_index = int(opnfv_idf['opnfv_vm_idf']['net_config']['mgmt']['interface'])
+ opnfv_mgmt = opnfv_pdf['opnfv_vm_pdf']['interfaces'][mgmt_idf_index]
+ admin_idf_index = int(opnfv_idf['opnfv_vm_idf']['net_config']['admin']['interface'])
+ opnfv_public = opnfv_pdf['opnfv_vm_pdf']['interfaces'][admin_idf_index]
+ self.opnfv_networks['opnfv']['mgmt']['mac_address'] = str(opnfv_mgmt['mac_address'])
+ self.opnfv_networks['opnfv']['mgmt']['vlan'] = str(opnfv_mgmt['vlan'])
+ self.opnfv_networks['opnfv']['public']['mac_address'] = str(opnfv_public['mac_address'])
+ self.opnfv_networks['opnfv']['public']['vlan'] = str(opnfv_public['vlan'])
+
+ # Add the interfaces from idf
+
+
host_networks.update(self.opnfv_networks)
self.add_groupvar('all', 'host_info', host_networks)
+ if 'deployment_host_interfaces' in idf['xci']['installers'][self.installer]['network']:
+ mgmt_idf_index = int(opnfv_idf['opnfv_vm_idf']['net_config']['mgmt']['interface'])
+ admin_idf_index = int(opnfv_idf['opnfv_vm_idf']['net_config']['admin']['interface'])
+ self.add_hostvar('deployment_host', 'network_interface_admin', idf['xci']['installers'][self.installer]['network']['deployment_host_interfaces'][admin_idf_index])
+ self.add_hostvar('deployment_host', 'network_interface_mgmt', idf['xci']['installers'][self.installer]['network']['deployment_host_interfaces'][mgmt_idf_index])
+
# Now add the additional groups
for parent in idf['xci']['installers'][self.installer]['groups'].keys():
map(lambda x: self.add_group(x, parent), idf['xci']['installers'][self.installer]['groups'][parent])
diff --git a/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml b/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml
index 700c6c72..df019c88 100644
--- a/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml
+++ b/xci/playbooks/roles/create-vm-nodes/tasks/create_vm.yml
@@ -128,9 +128,13 @@
command: get_xml
register: vm_xml
+ - name: Fetch the index for admin network
+ set_fact:
+ admin_index: "{{ (vm_name == 'opnfv') | ternary(opnfv_vm_idf.net_config.admin.interface, idf.net_config.admin.interface) | int }}"
+
- name: Fetch the ip
set_fact:
- vm_ip: "{%- for interface in item.1.interfaces %}{%- if 'native' in (interface.vlan | string) %}{{ interface.address }}{%- endif %}{%- endfor %}"
+ vm_ip: "{{ item.1.interfaces[admin_index | int].address }}"
# Assumes there is only a single NIC per VM
- name: get MAC from vm XML
diff --git a/xci/playbooks/roles/create-vm-nodes/tasks/main.yml b/xci/playbooks/roles/create-vm-nodes/tasks/main.yml
index c1cee6dc..64857d80 100644
--- a/xci/playbooks/roles/create-vm-nodes/tasks/main.yml
+++ b/xci/playbooks/roles/create-vm-nodes/tasks/main.yml
@@ -18,7 +18,7 @@
# First we create the opnfv_vm
- include_tasks: create_vm.yml
- with_indexed_items: "{{ [opnfv_vm] + nodes }}"
+ with_indexed_items: "{{ [opnfv_vm_pdf] + nodes }}"
- name: Start the opnfv vm
virt:
diff --git a/xci/playbooks/roles/create-vm-nodes/templates/net.xml.j2 b/xci/playbooks/roles/create-vm-nodes/templates/net.xml.j2
index 3c082170..7e372ffe 100644
--- a/xci/playbooks/roles/create-vm-nodes/templates/net.xml.j2
+++ b/xci/playbooks/roles/create-vm-nodes/templates/net.xml.j2
@@ -6,13 +6,9 @@
</nat>
</forward>
<bridge name='{{ network_interface }}' stp='on' delay='0'/>
- <ip address='{{ nodes[0].remote_management.address.split(':')[0] }}' netmask='{{ node_network_netmask }}'>
+ <ip address='{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.admin.interface].gateway }}' netmask='{{ node_network_netmask }}'>
<dhcp>
- {%- for interface in opnfv_vm.interfaces %}
- {%- if 'native' in (interface.vlan | string) %}
- <host mac="{{ interface.mac_address }}" ip="{{ interface.address }}"/>
- {%- endif %}
- {%- endfor %}
+ <host mac="{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.admin.interface].mac_address }}" ip="{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.admin.interface].address }}"/>
</dhcp>
</ip>
</network>
diff --git a/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2 b/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2
index 5c235f55..e4e41eda 100644
--- a/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2
+++ b/xci/playbooks/roles/create-vm-nodes/templates/vm.xml.j2
@@ -35,19 +35,11 @@
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
- {% set native_interfaces = [] %}
- {%- for interface in item.1.interfaces %}
- {%- if 'native' in (interface.vlan | string) %}
- {%- set _ = native_interfaces.append(interface) %}
- {%- endif %}
- {%- endfor %}
- {%- for interface in native_interfaces -%}
<interface type='network'>
<source network='{{ vm_network }}'/>
<model type='{{ vm_nic }}'/>
- <mac address='{{ interface.mac_address }}'/>
+ <mac address='{{ item.1.interfaces[opnfv_vm_idf.net_config.admin.interface].mac_address }}'/>
</interface>
- {% endfor -%}
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
diff --git a/xci/var/opnfv_vm_idf.yml b/xci/var/opnfv_vm_idf.yml
new file mode 100644
index 00000000..fa647287
--- /dev/null
+++ b/xci/var/opnfv_vm_idf.yml
@@ -0,0 +1,19 @@
+---
+##############################################################################
+# Copyright (c) 2017 Ericsson AB and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+opnfv_vm_idf:
+ version: 0.1
+ net_config: &net_config
+ admin:
+ interface: 0
+ network: 192.168.122.0
+ mask: 24
+ mgmt:
+ interface: 1
+ network: 172.29.236.0
+ mask: 22
diff --git a/xci/var/opnfv_vm.yml b/xci/var/opnfv_vm_pdf.yml
index 17f5038c..51371388 100644
--- a/xci/var/opnfv_vm.yml
+++ b/xci/var/opnfv_vm_pdf.yml
@@ -6,7 +6,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-opnfv_vm:
+opnfv_vm_pdf:
name: opnfv
node: &nodeparams
type: virtual
@@ -36,32 +36,18 @@ opnfv_vm:
name: nic1
speed:
features:
- vlan: 10
+ vlan: native
interface_common_nic2: &interface_common_nic2
name: nic2
speed:
features:
- vlan: 20
- interface_common_nic3: &interface_common_nic3
- name: nic3
- speed:
- features:
vlan: native
- interface_common_nic4: &interface_common_nic4
- name: nic4
- speed:
- features:
- vlan: 30
interfaces:
- - mac_address: "52:54:00:33:82:d0"
- address: 172.29.236.10
- <<: *interface_common_nic1
- - mac_address: "52:54:00:33:82:d0"
- address: 172.29.244.10
- <<: *interface_common_nic2
- - mac_address: "52:54:00:33:82:d0"
- address: 192.168.122.2
- <<: *interface_common_nic3
- - mac_address: "52:54:00:33:82:d0"
- address: 172.29.240.10
- <<: *interface_common_nic4
+ - mac_address: "52:54:00:33:82:d0"
+ address: 192.168.122.2
+ gateway: 192.168.122.1
+ <<: *interface_common_nic1
+ - mac_address: "52:54:00:33:82:d1"
+ address: 172.29.236.10
+ gateway: 172.29.236.1
+ <<: *interface_common_nic2