Add usage MAC for Ephemeral VM deploy

We should use interface naming independent on OS, type, speed, slot etc.
This CR takes an approach that is already used for the target node.
To define VMs, their script uses MAC addresses from manifests.

Relates-To: #285

Change-Id: Iafffd23bc584d2daf3fed5ee301491f447498193
This commit is contained in:
Nikolay Fedorov 2020-07-02 23:01:59 +04:00
parent 87dc0e386d
commit bd6f2f8e32
7 changed files with 85 additions and 57 deletions

View File

@ -7,7 +7,7 @@ metadata:
data:
PROVISIONING_IP: "192.168.10.100"
DHCP_RANGE: "192.168.10.200,192.168.10.250"
PROVISIONING_INTERFACE: "pxe0"
PROVISIONING_INTERFACE: "pxe"
HTTP: "80"
DEPLOY_KERNEL_PATH: "/images/tinyipa-stable-ussuri.vmlinuz"
DEPLOY_RAMDISK_PATH: "/images/tinyipa-stable-ussuri.gz"

View File

@ -7,4 +7,3 @@ metadata:
data:
PROVISIONING_IP: "10.23.24.101"
DHCP_RANGE: "10.23.24.200,10.23.24.250"
PROVISIONING_INTERFACE: "enp0s4"

View File

@ -19,10 +19,13 @@ hosts:
pxe: 52:54:00:b6:ed:31
bootMode: legacy
node02:
macAddress: 00:3b:8b:0c:ec:8b
macAddress: 52:54:00:b6:ed:02
bmcAddress: redfish+http://10.23.25.2:8000/redfish/v1/Systems/air-target-2
bmcUsername: username
bmcPassword: password
ipAddresses:
oam-ipv4: 10.23.25.101
pxe-ipv4: 10.23.24.101
macAddresses:
oam: 52:54:00:9b:27:02
pxe: 52:54:00:b6:ed:02

View File

@ -7,12 +7,12 @@ metadata:
commonNetworking:
links:
- id: oam
name: enp0s3
name: oam
type: phy
mtu: "1500"
# ethernet_mac_address: <from host-catalogue> (optional)
- id: pxe
name: enp0s4
name: pxe
type: phy
mtu: "1500"
# ethernet_mac_address: <from host-catalogue> (optional)

View File

@ -60,58 +60,17 @@
- name: clone document model
command: git clone -q {{ airship_config_primary_repo_url }} {{ remote_work_dir }}
when: remote_work_dir is defined
- name: get BareMetalHost objects
shell: |
set -e
kustomize build --enable_alpha_plugins \
{{ airship_config_manifest_directory }}/{{ airship_config_site_path }}/ephemeral/controlplane |
kustomize config grep "kind=BareMetalHost"
register: bmh_command
failed_when: "bmh_command.stdout == ''"
environment:
KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins"
KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true"
- set_fact:
bmh: "{{ bmh_command.stdout | from_yaml_all | list }}"
- name: get network configuration for BareMetalHost objects
shell: |
set -e
kustomize build --enable_alpha_plugins \
{{ airship_config_manifest_directory }}/{{ airship_config_site_path }}/ephemeral/controlplane |
kustomize config grep "metadata.name={{ item.spec.networkData.name }}"
register: netdata_command
failed_when: "netdata_command.stdout == ''"
environment:
KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins"
KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true"
with_items: "{{ bmh }}"
- name: get links from network data per BareMetalHost object
set_fact:
links: |
{{
netdata_command.results |
map(attribute='stdout')| map('from_yaml') |
map(attribute='stringData.networkData') | map('from_yaml') |
map(attribute='links') | list
}}
- name: define list of VM mac addresses
set_fact:
vm_nic: "{{ dict(['nat_mac', 'provision_mac'] | zip([nat_mac_list[0], item.spec.bootMACAddress])) }}"
vars:
nat_mac_list: |
{{
links[idx] |
rejectattr('ethernet_mac_address', 'undefined') |
selectattr('ethernet_mac_address', '!=', item.spec.bootMACAddress) |
map(attribute='ethernet_mac_address') | list
}}
failed_when: nat_mac_list | length == 0
loop: "{{ bmh }}"
loop_control:
index_var: idx
register: vm_nic_fact
- set_fact:
target_vm_nics: "{{ vm_nic_fact.results | map(attribute='ansible_facts.vm_nic') | list }}"
- name: get MACs from BareMetalHost objects
include_tasks:
file: get-mac-addresses.yaml
vars:
name: "{{ roleinputvar.name }}"
path: "{{ roleinputvar.path }}"
loop:
- { name: 'target', path: 'ephemeral/controlplane' }
- { name: 'ephemeral', path: 'ephemeral/bootstrap' }
loop_control:
loop_var: roleinputvar
- name: deploy-gate
include_role:
@ -131,6 +90,7 @@
ephemeral_vm_memory_mb: 6124
ephemeral_vm_vcpus: 4
ephemeral_disk_size: 20G
ephemeral_vm_nics: "{{ ephemeral_vm_nics }}"
target_disk_size: 10G
disk_format: qcow2
target_vms_count: 1

View File

@ -0,0 +1,64 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: get BareMetalHost objects
shell: |
set -e
kustomize build --enable_alpha_plugins \
{{ airship_config_manifest_directory }}/{{ airship_config_site_path }}/{{ path }} |
kustomize config grep "kind=BareMetalHost"
register: bmh_command
failed_when: "bmh_command.stdout == ''"
environment:
KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins"
KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true"
- set_fact:
bmh: "{{ bmh_command.stdout | from_yaml_all | list }}"
- name: get network configuration for BareMetalHost objects
shell: |
set -e
kustomize build --enable_alpha_plugins \
{{ airship_config_manifest_directory }}/{{ airship_config_site_path }}/{{ path }} |
kustomize config grep "metadata.name={{ item.spec.networkData.name }}"
register: netdata_command
failed_when: "netdata_command.stdout == ''"
environment:
KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins"
KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true"
with_items: "{{ bmh }}"
- name: get links from network data per BareMetalHost object
set_fact:
links: |
{{
netdata_command.results |
map(attribute='stdout')| map('from_yaml') |
map(attribute='stringData.networkData') | map('from_yaml') |
map(attribute='links') | list
}}
- name: define list of VM mac addresses
set_fact:
vm_nic: "{{ dict(['nat_mac', 'provision_mac'] | zip([nat_mac_list[0], item.spec.bootMACAddress])) }}"
vars:
nat_mac_list: |
{{
links[idx] |
rejectattr('ethernet_mac_address', 'undefined') |
selectattr('ethernet_mac_address', '!=', item.spec.bootMACAddress) |
map(attribute='ethernet_mac_address') | list
}}
failed_when: nat_mac_list | length == 0
loop: "{{ bmh }}"
loop_control:
index_var: idx
register: vm_nic_fact
- set_fact:
"{{ name }}_vm_nics": "{{ vm_nic_fact.results | map(attribute='ansible_facts.vm_nic') | list }}"

View File

@ -112,7 +112,9 @@
pool: "{{ airship_gate_names.pool }}"
interfaces:
- network: "{{ airship_gate_names.nat_network }}"
mac: "{{ chosen_flavor.ephemeral_vm_nics[0].nat_mac | default('')}}"
- network: "{{ airship_gate_names.provision_network }}"
mac: "{{ chosen_flavor.ephemeral_vm_nics[0].provision_mac | default('')}}"
- name: Add noauth sushy-emulator to apache
include_role: