Integrate vino-builder
This patchset integrates vino-builder into the vino manager daemonset. See corresponding vino changes in [0]. [0] https://review.opendev.org/c/airship/vino/+/778209 Change-Id: I860ffef6275aca9d10a20abf79c1a25455ff3717
This commit is contained in:
parent
2a70f431cc
commit
183f26c048
113
vino-builder/Makefile
Normal file
113
vino-builder/Makefile
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
# Copyright 2021 AT&T Intellectual Property. All other rights reserved.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
SHELL := /bin/bash
|
||||||
|
BUILD_DIR ?= build
|
||||||
|
PUSH_IMAGE ?= false
|
||||||
|
IMAGE_ID ?= none
|
||||||
|
COMMIT ?= $(shell git rev-parse HEAD)
|
||||||
|
LABEL ?= org.airshipit.build=community
|
||||||
|
IMAGE_NAME ?= vino-builder
|
||||||
|
DOCKER_REGISTRY ?= quay.io
|
||||||
|
IMAGE_PREFIX ?= airshipit
|
||||||
|
IMAGE_TAG ?= latest
|
||||||
|
DISTRO ?= ubuntu_bionic
|
||||||
|
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO}
|
||||||
|
SH_TO_CHECK := $(wildcard files/*.sh )
|
||||||
|
PROXY ?= http://proxy.foo.com:8000
|
||||||
|
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
|
||||||
|
USE_PROXY ?= false
|
||||||
|
|
||||||
|
all: lint images
|
||||||
|
|
||||||
|
check-docker:
|
||||||
|
@if [ -z $$(which docker) ]; then \
|
||||||
|
echo "Missing \`docker\` client which is required for development"; \
|
||||||
|
exit 2; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
images: check-docker build_vino-builder
|
||||||
|
|
||||||
|
docs: clean build_docs
|
||||||
|
|
||||||
|
build_docs:
|
||||||
|
echo TODO
|
||||||
|
|
||||||
|
run_images: run_vino-builder
|
||||||
|
|
||||||
|
run_vino-builder:
|
||||||
|
echo TODO
|
||||||
|
|
||||||
|
build_vino-builder:
|
||||||
|
mkdir -p $(BUILD_DIR)
|
||||||
|
ifeq ($(IMAGE_ID), none)
|
||||||
|
ifeq ($(USE_PROXY), true)
|
||||||
|
docker build . \
|
||||||
|
--iidfile $(BUILD_DIR)/image_id \
|
||||||
|
--tag $(IMAGE) \
|
||||||
|
--label $(LABEL) \
|
||||||
|
--label "org.opencontainers.image.revision=$(COMMIT)" \
|
||||||
|
--label "org.opencontainers.image.created=\
|
||||||
|
$(shell date --rfc-3339=seconds --utc)" \
|
||||||
|
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
||||||
|
--build-arg http_proxy=$(PROXY) \
|
||||||
|
--build-arg https_proxy=$(PROXY) \
|
||||||
|
--build-arg HTTP_PROXY=$(PROXY) \
|
||||||
|
--build-arg HTTPS_PROXY=$(PROXY) \
|
||||||
|
--build-arg no_proxy=$(NO_PROXY) \
|
||||||
|
--build-arg NO_PROXY=$(NO_PROXY) \
|
||||||
|
--build-arg GIT_COMMIT=$(COMMIT)
|
||||||
|
else
|
||||||
|
docker build . \
|
||||||
|
--iidfile $(BUILD_DIR)/image_id \
|
||||||
|
--tag $(IMAGE) \
|
||||||
|
--label $(LABEL) \
|
||||||
|
--label "org.opencontainers.image.revision=$(COMMIT)" \
|
||||||
|
--label "org.opencontainers.image.created=\
|
||||||
|
$(shell date --rfc-3339=seconds --utc)" \
|
||||||
|
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
||||||
|
--build-arg GIT_COMMIT=$(COMMIT)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
echo $(IMAGE_ID) > $(BUILD_DIR)/image_id
|
||||||
|
endif
|
||||||
|
ifeq ($(PUSH_IMAGE), true)
|
||||||
|
docker push $(IMAGE)
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
ifeq ($(IMAGE_ID), none)
|
||||||
|
if [[ -s $(BUILD_DIR)/image_id ]]; \
|
||||||
|
then \
|
||||||
|
docker rmi $$(cat $(BUILD_DIR)/image_id); \
|
||||||
|
fi
|
||||||
|
endif
|
||||||
|
rm -rf $(BUILD_DIR)
|
||||||
|
|
||||||
|
# style checks
|
||||||
|
lint: test-shellcheck
|
||||||
|
|
||||||
|
tests: lint unit_tests run_vino-builder
|
||||||
|
|
||||||
|
test-shellcheck: $(SH_TO_CHECK)
|
||||||
|
|
||||||
|
unit_tests:
|
||||||
|
echo TODO
|
||||||
|
|
||||||
|
$(SH_TO_CHECK):
|
||||||
|
docker run --rm -v $(shell pwd):/mnt \
|
||||||
|
nlknguyen/alpine-shellcheck -x /mnt/$(@)
|
||||||
|
|
||||||
|
.PHONY: test clean $(SH_TO_CHECK) test-shellcheck tests lint build_vino-builder \
|
||||||
|
run_vino-builder run_images all build_docs docs check-docker images
|
@ -26,4 +26,10 @@ while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
ansible-playbook -v -e @/var/lib/vino-builder/vino-builder-config.yaml /playbooks/vino-builder.yaml
|
ansible-playbook -v \
|
||||||
|
-e @/vino/spec \
|
||||||
|
-e @/var/lib/vino-builder/flavors/flavors.yaml \
|
||||||
|
-e @/var/lib/vino-builder/flavor-templates/flavor-templates.yaml \
|
||||||
|
-e @/var/lib/vino-builder/network-templates/network-templates.yaml \
|
||||||
|
-e @/var/lib/vino-builder/storage-templates/storage-templates.yaml \
|
||||||
|
/playbooks/vino-builder.yaml
|
@ -60,7 +60,7 @@ def get_numa_cores():
|
|||||||
numa_core_dict[numa] = parsed_range_list
|
numa_core_dict[numa] = parsed_range_list
|
||||||
return numa_core_dict
|
return numa_core_dict
|
||||||
|
|
||||||
def allocate_cores(nodes, exclude_cpu):
|
def allocate_cores(nodes, flavors, exclude_cpu):
|
||||||
"""Return"""
|
"""Return"""
|
||||||
|
|
||||||
core_state = {}
|
core_state = {}
|
||||||
@ -96,13 +96,16 @@ def allocate_cores(nodes, exclude_cpu):
|
|||||||
# address the case where previous != desired - delete previous, re-run
|
# address the case where previous != desired - delete previous, re-run
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
|
|
||||||
|
flavor = node['labels']['vmFlavor']
|
||||||
|
vcpus = flavors[flavor]['vcpus']
|
||||||
|
|
||||||
for num_node in range(0, node['count']):
|
for num_node in range(0, node['count']):
|
||||||
|
|
||||||
# generate a unique name such as master-0, master-1
|
# generate a unique name such as master-0, master-1
|
||||||
node_name = node['name'] + '-' + str(num_node)
|
node_name = node['name'] + '-' + str(num_node)
|
||||||
|
|
||||||
# extract the core count
|
# extract the core count
|
||||||
core_count = int(node['instance']['vcpu'])
|
core_count = int(vcpus)
|
||||||
|
|
||||||
# discover any previous allocation
|
# discover any previous allocation
|
||||||
if 'assignments' in core_state:
|
if 'assignments' in core_state:
|
||||||
@ -140,10 +143,12 @@ def main():
|
|||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
nodes=dict(required=True, type='list'),
|
nodes=dict(required=True, type='list'),
|
||||||
|
flavors=dict(required=True, type='dict'),
|
||||||
exclude_cpu=dict(required=True, type='str')
|
exclude_cpu=dict(required=True, type='str')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
result = allocate_cores(module.params["nodes"],
|
result = allocate_cores(module.params["nodes"],
|
||||||
|
module.params["flavors"],
|
||||||
module.params["exclude_cpu"])
|
module.params["exclude_cpu"])
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
- name: debug print virsh xml domain
|
- name: debug print virsh xml domain
|
||||||
debug:
|
debug:
|
||||||
msg: "{{ libvirtDomains[node.name]['domainTemplate'] }}"
|
msg: "{{ flavorTemplates[node.labels.vmFlavor]['domainTemplate'] }}"
|
||||||
loop: "{{ range(0,node.count)|list }}"
|
loop: "{{ range(0,node.count)|list }}"
|
||||||
|
|
||||||
- name: get state of existing volumes
|
- name: get state of existing volumes
|
||||||
@ -14,7 +14,7 @@
|
|||||||
register: vol_list
|
register: vol_list
|
||||||
|
|
||||||
- name: write out domain volume request xml
|
- name: write out domain volume request xml
|
||||||
copy: content="{{libvirtDomains[node.name]['volumeTemplate']}}" dest=/tmp/vol-{{item}}.xml
|
copy: content="{{ flavorTemplates[node.labels.vmFlavor]['volumeTemplate'] }}" dest=/tmp/vol-{{item}}.xml
|
||||||
loop: "{{ range(0,node.count)|list }}"
|
loop: "{{ range(0,node.count)|list }}"
|
||||||
|
|
||||||
- name: create domain volume if it doesn't exist
|
- name: create domain volume if it doesn't exist
|
||||||
@ -35,7 +35,7 @@
|
|||||||
# to domains, so we must shell out here instead
|
# to domains, so we must shell out here instead
|
||||||
|
|
||||||
- name: write out domain volume request xml
|
- name: write out domain volume request xml
|
||||||
copy: content="{{libvirtDomains[node.name]['domainTemplate']}}" dest=/tmp/domain-{{item}}.xml
|
copy: content="{{ flavorTemplates[node.labels.vmFlavor]['domainTemplate'] }}" dest=/tmp/domain-{{item}}.xml
|
||||||
loop: "{{ range(0,node.count)|list }}"
|
loop: "{{ range(0,node.count)|list }}"
|
||||||
|
|
||||||
- name: virsh define domain
|
- name: virsh define domain
|
||||||
@ -43,10 +43,10 @@
|
|||||||
virsh define /tmp/domain-{{item}}.xml
|
virsh define /tmp/domain-{{item}}.xml
|
||||||
loop: "{{ range(0,node.count)|list }}"
|
loop: "{{ range(0,node.count)|list }}"
|
||||||
|
|
||||||
# - name: set vm to running
|
- name: set vm to running
|
||||||
# virt:
|
virt:
|
||||||
# name: "{{ node.name + '-' + item|string}}"
|
name: "{{ node.name + '-' + item|string}}"
|
||||||
# state: running
|
state: running
|
||||||
# # autostart: yes
|
autostart: yes
|
||||||
# loop: "{{ range(0,node.count)|list }}"
|
loop: "{{ range(0,node.count)|list }}"
|
||||||
# ignore_errors: true
|
ignore_errors: true
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
- name: initially gather facts on existing virsh networks
|
- name: initially gather facts on existing virsh networks
|
||||||
virt_net:
|
virt_net:
|
||||||
command: facts
|
command: facts
|
||||||
name: management # this attribute is not needed but required
|
name: "" # this attribute is not needed but required
|
||||||
uri: "{{ libvirt_uri }}"
|
uri: "{{ libvirt_uri }}"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
@ -27,7 +27,7 @@
|
|||||||
- name: re-gather facts on existing virsh networks
|
- name: re-gather facts on existing virsh networks
|
||||||
virt_net:
|
virt_net:
|
||||||
command: facts
|
command: facts
|
||||||
name: management
|
name: ""
|
||||||
uri: "{{ libvirt_uri }}"
|
uri: "{{ libvirt_uri }}"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
- name: allocate domain cores
|
- name: allocate domain cores
|
||||||
core_allocation:
|
core_allocation:
|
||||||
nodes: "{{ nodes }}"
|
nodes: "{{ nodes }}"
|
||||||
|
flavors: "{{ flavors }}"
|
||||||
exclude_cpu: "{{ configuration.cpuExclude }}"
|
exclude_cpu: "{{ configuration.cpuExclude }}"
|
||||||
register: node_core_map
|
register: node_core_map
|
||||||
when: nodes
|
when: nodes
|
||||||
|
Loading…
Reference in New Issue
Block a user