From 533d9e0d3a688598b40546157f667ad87adb709f Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 17 Jul 2023 20:25:03 +0900 Subject: [PATCH] Require valid flavor id, key name and project name Flavor id and key name are required so that amphora driver functions properly. Also the project name to which the amphora belongs should be a valid name, otherwise the flavor can't be created properly. Change-Id: I9d6050013ecd58f588cdca2ff9e32258e2e11d0d --- manifests/controller.pp | 4 ++-- manifests/worker.pp | 44 +++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/manifests/controller.pp b/manifests/controller.pp index a3ae14d3..74f5e7e8 100644 --- a/manifests/controller.pp +++ b/manifests/controller.pp @@ -259,7 +259,7 @@ class octavia::controller ( String[1] $heartbeat_key, $amp_active_retries = $facts['os_service_default'], $amp_active_wait_sec = $facts['os_service_default'], - $amp_flavor_id = '65', + String[1] $amp_flavor_id = '65', $amp_image_tag = $facts['os_service_default'], $amp_image_owner_id = $facts['os_service_default'], $amp_secgroup_list = $facts['os_service_default'], @@ -275,7 +275,7 @@ class octavia::controller ( $amphora_delete_retry_interval = $facts['os_service_default'], $event_notifications = $facts['os_service_default'], Boolean $enable_ssh_access = true, - $amp_ssh_key_name = 'octavia-ssh-key', + String[1] $amp_ssh_key_name = 'octavia-ssh-key', $timeout_client_data = $facts['os_service_default'], $timeout_member_connect = $facts['os_service_default'], $timeout_member_data = $facts['os_service_default'], diff --git a/manifests/worker.pp b/manifests/worker.pp index 23b208e4..772f011a 100644 --- a/manifests/worker.pp +++ b/manifests/worker.pp @@ -62,40 +62,32 @@ class octavia::worker ( Boolean $manage_keygen = false, $ssh_key_type = 'rsa', $ssh_key_bits = 2048, - $amp_project_name = 'services', + String[1] $amp_project_name = 'services', ) { include octavia::deps include octavia::params include octavia::controller - if ! $::octavia::controller::amp_flavor_id { - if $manage_nova_flavor { - fail('When managing Nova flavor, octavia::controller::amp_flavor_id is required.') - } else { - warning('octavia::controller::amp_flavor_id is empty, Octavia Worker might not work correctly.') + if $manage_nova_flavor { + $octavia_flavor = { "octavia_${::octavia::controller::amp_flavor_id}" => + { 'id' => $::octavia::controller::amp_flavor_id, + 'project_name' => $amp_project_name + } } - } else { - if $manage_nova_flavor { - $octavia_flavor = { "octavia_${::octavia::controller::amp_flavor_id}" => - { 'id' => $::octavia::controller::amp_flavor_id, - 'project_name' => $amp_project_name - } - } - $octavia_flavor_defaults = { - 'ensure' => 'present', - 'ram' => '1024', - 'disk' => '2', - 'vcpus' => '1', - 'is_public' => false, - 'tag' => ['octavia'] - } - $nova_flavor_defaults = merge($octavia_flavor_defaults, $nova_flavor_config) - create_resources('nova_flavor', $octavia_flavor, $nova_flavor_defaults) - if $manage_service { - Nova_flavor<| tag == 'octavia' |> ~> Service['octavia-worker'] - } + $octavia_flavor_defaults = { + 'ensure' => 'present', + 'ram' => '1024', + 'disk' => '2', + 'vcpus' => '1', + 'is_public' => false, + 'tag' => ['octavia'] + } + $nova_flavor_defaults = merge($octavia_flavor_defaults, $nova_flavor_config) + create_resources('nova_flavor', $octavia_flavor, $nova_flavor_defaults) + if $manage_service { + Nova_flavor<| tag == 'octavia' |> ~> Service['octavia-worker'] } }