Merge pull request #8 from w-miller/multi-host

A few multi-host fixes
This commit is contained in:
w-miller 2018-09-07 13:43:43 +01:00 committed by GitHub
commit 3f4367396a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 50 additions and 19 deletions

View File

@ -43,11 +43,14 @@ class ActionModule(ActionBase):
hostname of the hypervisor to which they are scheduled.
"""
result = super(ActionModule, self).run(tmp, task_vars)
# Initialise our return dict.
result['result'] = {}
del tmp # tmp no longer has any effect
self._validate_vars(task_vars)
nodes = []
idx = 0
hypervisor_names = task_vars['hypervisor_vars'].keys()
for typ, cnt in six.iteritems(task_vars['specs']):
for _ in six.moves.range(cnt):
node = deepcopy(task_vars['node_types'][typ])
@ -59,12 +62,15 @@ class ActionModule(ActionBase):
vol['name'] = "%s%d" % (task_vars['vol_name_prefix'],
vol_idx)
nodes.append(node)
# Perform round-robin scheduling with node index modulo number
# of hypervisors.
hyp_name = hypervisor_names[idx % len(hypervisor_names)]
try:
result['result'][hyp_name].append(node)
except KeyError:
# This hypervisor doesn't yet have any scheduled nodes.
result['result'][hyp_name] = [node]
idx += 1
# TODO(w-miller): currently we just arbitrarily schedule all nodes to
# the first hypervisor. Improve this algorithm to make it more
# sophisticated.
result['result'] = {task_vars['hypervisor_vars'].keys()[0]: nodes}
return result
def _validate_vars(self, task_vars):

View File

@ -24,4 +24,5 @@
name: virtualbmc-daemon
vars:
vbmcd_virtualenv_path: "{{ virtualenv_path }}"
vbmcd_python_upper_contraints_url: "{{ python_upper_constraints_url }}"
vbmcd_python_upper_constraints_url: >-
{{ python_upper_constraints_url }}

9
ansible/group_vars/all Normal file
View File

@ -0,0 +1,9 @@
---
# Path to virtualenv used to install Python requirements. If a virtualenv does
# not exist at this location, one will be created.
virtualenv_path: "{{ '/'.join([ansible_env['HOME'], 'tenks-venv']) }}"
# The URL of the upper constraints file to pass to pip when installing Python
# packages.
python_upper_constraints_url: >-
https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt

View File

@ -6,15 +6,6 @@ physnet_mappings: {}
system_requirements:
- python-virtualenv
# Path to virtualenv used to install Python requirements. If a virtualenv does
# not exist at this location, one will be created.
virtualenv_path: "{{ '/'.join([ansible_env['HOME'], 'tenks-venv']) }}"
# The URL of the upper constraints file to pass to pip when installing Python
# packages.
python_upper_constraints_url: >-
https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt
# Naming scheme for bridges created by tenks for physical networks is
# {{ bridge_prefix + i }}, where `i` is the index of the physical network in
# physnet_mappings (sorted alphabetically by key).

View File

@ -13,7 +13,8 @@
source_type: direct
- name: Get source interface details
command: ip -details link show {{ source_interface }}
# NOTE(w-miller): The `ip` command may not be in $PATH, so use the full path.
command: /usr/sbin/ip -details link show {{ source_interface }}
register: if_details
changed_when: false
@ -69,6 +70,7 @@
type=patch
options:peer={{ veth_prefix + tenks_bridge +
veth_bridge_source_suffix }}
become: true
- name: Create patch port on source bridge
openvswitch_port:
@ -79,9 +81,11 @@
type=patch
options:peer={{ veth_prefix + tenks_bridge +
veth_bridge_ovs_suffix }}
become: true
- name: Plug source interface into Tenks bridge
when: source_type == 'direct'
openvswitch_port:
bridge: "{{ tenks_bridge }}"
port: "{{ source_interface }}"
become: true

View File

@ -1,7 +1,17 @@
---
# This is useful to get a uniquely generated temporary path.
- name: Create temporary file for pip requirements
tempfile:
register: req_file
- name: Copy requirements file to temporary location
copy:
src: requirements.txt
dest: "{{ req_file.path }}"
- name: Ensure Python requirements are installed
pip:
requirements: "{{ '/'.join([role_path, 'files', 'requirements.txt']) }}"
requirements: "{{ req_file.path }}"
extra_args: >-
-c {{ ironic_python_upper_constraints_url }}
virtualenv: "{{ ironic_virtualenv_path }}"

View File

@ -6,11 +6,21 @@
loop: "{{ vbmcd_packages }}"
become: true
# This is useful to get a uniquely generated temporary path.
- name: Create temporary file for pip requirements
tempfile:
register: req_file
- name: Copy requirements file to temporary location
copy:
src: requirements.txt
dest: "{{ req_file.path }}"
- name: Ensure Python requirements are installed
pip:
requirements: "{{ '/'.join([role_path, 'files', 'requirements.txt']) }}"
requirements: "{{ req_file.path }}"
extra_args: >-
-c {{ vbmcd_python_upper_contraints_url }}
-c {{ vbmcd_python_upper_constraints_url }}
virtualenv: "{{ vbmcd_virtualenv_path }}"
- name: Ensure Virtual BMC systemd service is configured