-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b5e31c
commit 71f2aa1
Showing
12 changed files
with
346 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
- name: "Run ci/playbooks/edpm_baremetal_deployment/run_extracted.yml" | ||
hosts: "{{ cifmw_zuul_target_host | default('all') }}" | ||
gather_facts: true | ||
tasks: | ||
- name: Filter out host if needed | ||
when: | ||
- cifmw_zuul_target_host is defined | ||
- cifmw_zuul_target_host != 'all' | ||
- inventory_hostname != cifmw_zuul_target_host | ||
ansible.builtin.meta: end_host | ||
|
||
- name: Check for edpm-ansible.yml file | ||
ansible.builtin.stat: | ||
path: "{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml" | ||
register: edpm_file | ||
|
||
- name: Perform Podified and EDPM deployment on compute nodes with virtual baremetal | ||
ansible.builtin.command: | ||
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework" | ||
cmd: >- | ||
ansible-playbook deploy-edpm.yml | ||
-i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml" | ||
-e @scenarios/centos-9/base.yml | ||
-e @scenarios/centos-9/edpm_ci.yml | ||
-e @scenarios/centos-9/edpm_baremetal_deployment_ci_extracted.yml | ||
{%- if edpm_file.stat.exists %} | ||
-e @{{ ansible_user_dir }}/ci-framework-data/artifacts/edpm-ansible.yml | ||
{%- endif %} | ||
{%- if cifmw_extras is defined %} | ||
{%- for extra_var in cifmw_extras %} | ||
-e "{{ extra_var }}" | ||
{%- endfor %} | ||
{%- endif %} | ||
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
This directory contains the serial console log files from the virtual BMaaS | ||
bare-metal nodes. The *_console_* log files are the original log files and | ||
include ANSI control codes which can make the output difficult to read. The | ||
*_no_ansi_* log files have had ANSI control codes removed from the file and are | ||
easier to read. | ||
|
||
On some occasions there won't be a corresponding *_no_ansi_* log file. You may | ||
see a log file without a date/time in the file name. In that case you can | ||
display the logfile in your console by doing: | ||
$ curl URL_TO_LOGFILE | ||
|
||
This will have your terminal process the ANSI escape codes. | ||
|
||
Another option, if you have the 'pv' executable installed, is to simulate a | ||
low-speed connection. In this example simulate a 300 Bytes/second connection. | ||
$ curl URL_TO_LOGFILE | pv -q -L 300 | ||
|
||
This can allow you to see some of the content before the screen is cleared by | ||
an ANSI escape sequence. |
84 changes: 84 additions & 0 deletions
84
roles/edpm_deploy_baremetal/tasks/create_virtual_baremetal_vms.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
- name: Ensure packages are present | ||
ansible.builtin.package: | ||
name: "{{ item }}" | ||
loop: | ||
- libvirt | ||
- virt-install | ||
- qemu-kvm | ||
|
||
- name: Ensure directories are present | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: directory | ||
loop: | ||
- "{{ cifmw_edpm_deploy_baremetal_console_log_dir }}" | ||
- "{{ cifmw_edpm_deploy_baremetal_libvirt_hooks_path }}" | ||
|
||
- name: Set selinux context type to "virt_log_t" | ||
community.general.sefcontext: | ||
target: "{{ cifmw_edpm_deploy_baremetal_console_log_dir }}(/.*)?" | ||
setype: virt_log_t | ||
state: present | ||
|
||
- name: Copy README into console log directory | ||
ansible.builtin.copy: | ||
src: console_log_readme | ||
dest: "{{ (cifmw_edpm_deploy_baremetal_console_log_dir, '/README') | path_join }}" | ||
|
||
- name: Copy the qemu hook to the right directory | ||
ansible.builtin.template: | ||
src: logrotate_hook_py.j2 | ||
dest: "{{ (cifmw_edpm_deploy_baremetal_libvirt_hooks_path, '/10-logrotate.py') | path_join }}" | ||
mode: u+x,g+x,o+x | ||
|
||
- name: Enable virtualization services | ||
ansible.builtin.systemd: | ||
name: "{{ item }}" | ||
state: started | ||
enabled: true | ||
loop: | ||
- virtqemud | ||
- virtstoraged | ||
- virtnetworkd | ||
|
||
- name: Whoami | ||
become: false | ||
ansible.builtin.command: | ||
cmd: | | ||
whoami | ||
groups | ||
register: _tmp_whoami | ||
|
||
- name: Whoami debug | ||
become: false | ||
ansible.builtin.debug: | ||
msg: "{{ _tmp_whoami }}" | ||
|
||
- name: Create VMs XML | ||
become: false | ||
ansible.builtin.command: | ||
cmd: >- | ||
virt-install --connect qemu:///system | ||
--name "{{ cifmw_edpm_deploy_baremetal_instance_node_name_prefix}}-{{ item }}" | ||
--memory "{{ cifmw_edpm_deploy_baremetal_instance_memory }}" | ||
--vcpus "{{ cifmw_edpm_deploy_baremetal_instance_vcpu }}" | ||
--boot uefi,hd,bootmenu.enable=yes,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no | ||
--os-variant "{{ cifmw_edpm_deploy_baremetal_instance_os_variant }}" | ||
--disk size="{{ cifmw_edpm_deploy_baremetal_instance_disk_size }}" | ||
--network network="{{ cifmw_edpm_deploy_baremetal_instance_network_name }}",model="{{ cifmw_edpm_deploy_baremetal_instance_net_model }}" | ||
--graphics vnc | ||
--virt-type "{{ cifmw_edpm_deploy_baremetal_instance_virt_type }}" | ||
--serial file,path="{{ cifmw_edpm_deploy_baremetal_console_log_dir }}/{{ cifmw_edpm_deploy_baremetal_instance_node_name_prefix}}-{{ item }}_console.log" | ||
--rng /dev/urandom,rate.period=100,rate.bytes=1024 | ||
--print-xml | ||
register: vms_xml | ||
loop: "{{ range(1, cifmw_edpm_deploy_baremetal_instance_node_count + 1) | list }}" | ||
|
||
- name: Define VMs | ||
become: false | ||
community.libvirt.virt: | ||
command: define | ||
xml: "{{ item.stdout }}" | ||
uri: 'qemu:///system' | ||
with_items: "{{vms_xml.results}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
roles/edpm_deploy_baremetal/templates/logrotate_hook_py.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/usr/bin/python3 | ||
|
||
# Copyright (c) 2017 Intel Corporation | ||
# | ||
# 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. | ||
|
||
import datetime | ||
import os | ||
import re | ||
import sys | ||
|
||
|
||
# This script is run as a libvirt hook. | ||
# More information here: https://libvirt.org/hooks.html | ||
|
||
# The vbm-setup.sh script in function will replace LOG_DIR with the correct | ||
# location. And will place the script into the correct directory. | ||
VM_LOG_DIR = os.path.abspath("{{ cifmw_edpm_deploy_baremetal_console_log_dir }}") | ||
|
||
# Regular expression to find ANSI escape sequences at the beginning of a string | ||
ANSI_ESCAPE_RE = re.compile(r""" | ||
^\x1b\[ # ANSI escape codes are ESC (0x1b) [ | ||
?([\d;]*)(\w)""", re.VERBOSE) | ||
|
||
NOW = datetime.datetime.now().strftime("%Y-%m-%d-%H:%M:%S") | ||
|
||
|
||
def main(): | ||
if len(sys.argv) < 3: | ||
return | ||
|
||
guest_name = sys.argv[1] | ||
action = sys.argv[2] | ||
|
||
if action != "release": | ||
return | ||
|
||
if not console_log_exists(guest_name): | ||
return | ||
|
||
new_path = move_console_log(guest_name) | ||
if not new_path: | ||
return | ||
|
||
no_ansi_filename = "{}_no_ansi_{}.log".format(guest_name, NOW) | ||
no_ansi_path = os.path.join(VM_LOG_DIR, no_ansi_filename) | ||
create_no_ansi_file(new_path, no_ansi_path) | ||
|
||
|
||
def create_no_ansi_file(source_filename, dest_filename): | ||
with open(source_filename) as in_file: | ||
data = in_file.read() | ||
|
||
data = remove_ansi_codes(data) | ||
|
||
with open(dest_filename, 'w') as out_file: | ||
out_file.write(data) | ||
|
||
|
||
def get_console_log_path(guest_name): | ||
logfile_name = "{}_console.log".format(guest_name) | ||
return os.path.join(VM_LOG_DIR, logfile_name) | ||
|
||
|
||
def console_log_exists(guest_name): | ||
return os.path.isfile(get_console_log_path(guest_name)) | ||
|
||
|
||
def move_console_log(guest_name): | ||
new_logfile_name = "{}_console_{}.log".format(guest_name, NOW) | ||
new_path = os.path.join(VM_LOG_DIR, new_logfile_name) | ||
if os.path.exists(new_path): | ||
return False | ||
os.rename(get_console_log_path(guest_name), new_path) | ||
return new_path | ||
|
||
|
||
def remove_ansi_codes(data): | ||
"""Remove any ansi codes from the provided string""" | ||
output = '' | ||
while data: | ||
result = ANSI_ESCAPE_RE.match(data) | ||
if not result: | ||
output += data[0] | ||
data = data[1:] | ||
else: | ||
data = data[result.end():] | ||
return output | ||
|
||
|
||
if '__main__' == __name__: | ||
sys.exit(main()) |
23 changes: 23 additions & 0 deletions
23
scenarios/centos-9/edpm_baremetal_deployment_ci_extracted.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
cifmw_install_yamls_vars: | ||
DEPLOY_DIR: "{{ cifmw_basedir }}/artifacts/edpm_compute" # used during Baremetal deployment | ||
INFRA_REPO: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/infra-operator" | ||
BMAAS_INSTANCE_MEMORY: 8192 | ||
BMAAS_INSTANCE_VCPUS: 6 | ||
BMAAS_INSTANCE_DISK_SIZE: 40 | ||
DATAPLANE_GROWVOLS_ARGS: "/=8GB /tmp=1GB /home=1GB /var=8GB" | ||
|
||
# edpm_deploy role vars | ||
cifmw_baremetal_hypervisor_target: baremetal-hypervisor | ||
cifmw_edpm_deploy_baremetal: true | ||
cifmw_libvirt_manager_configuration: | ||
vms: | ||
compute: | ||
amount: 2 | ||
disk_file_name: "blank" | ||
disksize: 50 | ||
memory: 8 | ||
cpus: 4 | ||
nets: | ||
- public | ||
- default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.