From 65ed0da1970c88a7b9ee6ec0ac5a2b2bf07f64fe Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 3 Apr 2017 12:08:51 +0100 Subject: [PATCH] Separate physical configuration for discovery After discovery Neutron needs to own the control of ports for the baremetal compute nodes. We separate the interface configuration and add an --enable-discovery flag to kayobe physical network configure --- ansible/group_vars/switches/config | 5 +++++ ansible/physical-network.yml | 9 +++++++++ doc/source/usage.rst | 6 +++++- kayobe/cli/commands.py | 7 ++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ansible/group_vars/switches/config b/ansible/group_vars/switches/config index 9af478b39..0099aa003 100644 --- a/ansible/group_vars/switches/config +++ b/ansible/group_vars/switches/config @@ -17,3 +17,8 @@ switch_config: [] # Generally this should be configured on a per-switch basis via a host_vars # file. switch_interface_config: {} + +# Interface configuration for hardware discovery. After discovery Neutron owns +# the configuration of these ports. Has the same format as +# switch_interface_config. +switch_interface_config_discovery: {} diff --git a/ansible/physical-network.yml b/ansible/physical-network.yml index 9ddecd260..928339b76 100644 --- a/ansible/physical-network.yml +++ b/ansible/physical-network.yml @@ -5,11 +5,20 @@ - name: Group hosts by their switch type hosts: switches gather_facts: no + vars: + # Set this variable to True to configure of network for hardware discovery. + physical_network_enable_discovery: False tasks: - name: Group hosts by their switch type group_by: key: "switches_of_type_{{ switch_type }}" + - name: Add discovery interface configuration when performing discovery + set_fact: + switch_interface_config: > + {{ switch_interface_config | combine(switch_interface_config_discovery) }} + when: "{{ physical_network_enable_discovery | bool }}" + - name: Ensure DellOS physical switches are configured hosts: switches_of_type_dellos6:switches_of_type_dellos9 gather_facts: no diff --git a/doc/source/usage.rst b/doc/source/usage.rst index 4dfad47db..2220e1fe4 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -151,11 +151,15 @@ modules. Currently Dell Network OS 6 and Dell Network OS 9 switches are supported but this could easily be extended. To provision the physical network:: - (kayobe-venv) $ kayobe physical network configure --group + (kayobe-venv) $ kayobe physical network configure --group [--enable-discovery] The ``--group`` argument is used to specify an Ansible group containing the switches to be configured. +The ``--enable-discovery`` argument enables a one-time configuration of ports +attached to baremetal compute nodes to support hardware discovery via ironic +inspector. + Seed ==== diff --git a/kayobe/cli/commands.py b/kayobe/cli/commands.py index d6a573f2e..4c8959851 100644 --- a/kayobe/cli/commands.py +++ b/kayobe/cli/commands.py @@ -136,12 +136,17 @@ class PhysicalNetworkConfigure(KayobeAnsibleMixin, Command): group = parser.add_argument_group("Physical Networking") group.add_argument("--group", required=True, help="the Ansible group to apply configuration to") + group.add_argument("--enable-discovery", action="store_true", + help="configure the network for hardware discovery") return parser def take_action(self, parsed_args): self.app.LOG.debug("Configuring a physical network") + extra_vars = {} + if parsed_args.enable_discovery: + extra_vars["physical_network_enable_discovery"] = True ansible.run_playbook(parsed_args, "ansible/physical-network.yml", - limit=parsed_args.group) + limit=parsed_args.group, extra_vars=extra_vars) class SeedVMProvision(KollaAnsibleMixin, KayobeAnsibleMixin, Command):