From 6ca4d6de3a622f8d2b9744087383546bb8233260 Mon Sep 17 00:00:00 2001 From: Ashique P S Date: Wed, 5 Jul 2023 13:22:06 +0530 Subject: [PATCH] Unique name for the newly provisioned VMs. (#66) * update version Signed-off-by: Rupesh0688 <134281322+Rupesh0688@users.noreply.github.com> * unique name for new VM provision by passing unique_name as true Signed-off-by: Rupesh0688 <134281322+Rupesh0688@users.noreply.github.com> * Update CHANGELOG.md Signed-off-by: Rupesh0688 <134281322+Rupesh0688@users.noreply.github.com> * Chefstyle resolve Signed-off-by: Rupesh0688 <134281322+Rupesh0688@users.noreply.github.com> * Updated chefstyle issues Signed-off-by: Rupesh0688 <134281322+Rupesh0688@users.noreply.github.com> * Minor changes in the params building Signed-off-by: Ashique P S --------- Signed-off-by: Rupesh0688 <134281322+Rupesh0688@users.noreply.github.com> Signed-off-by: Ashique P S Co-authored-by: Rupesh0688 <134281322+Rupesh0688@users.noreply.github.com> --- CHANGELOG.md | 6 ++++++ lib/kitchen/driver/vra.rb | 9 +++++++-- lib/kitchen/driver/vra_version.rb | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8699aac..be896d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [v3.3.2](https://github.com/chef-partners/kitchen-vra/tree/v3.3.2) + +[Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v3.3.1...v3.3.2) + +- This change helps in getting unique name of a deployment. The new deployement name will be deployment_deploymentId. We need to pass **unique_name** as true(unique_name: true) in the driver configuration. + ## [v3.3.1](https://github.com/chef-partners/kitchen-vra/tree/v3.3.1) [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v3.3.0...v3.3.1) diff --git a/lib/kitchen/driver/vra.rb b/lib/kitchen/driver/vra.rb index 91464d7..fcf0883 100644 --- a/lib/kitchen/driver/vra.rb +++ b/lib/kitchen/driver/vra.rb @@ -49,6 +49,7 @@ class Vra < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength default_config :request_timeout, 600 default_config :request_refresh_rate, 2 default_config :server_ready_retries, 1 + default_config :unique_name, false default_config :deployment_name do |driver| driver&.instance&.platform&.name end @@ -152,6 +153,9 @@ def request_server deployment_request = catalog_request.submit info("Catalog request #{deployment_request.id} submitted.") + if config[:unique_name] + info("Deployment name is deployment_#{deployment_request.id}") + end wait_for_request(deployment_request) raise "The vRA request failed: #{deployment_request.completion_details}" if deployment_request.failed? @@ -232,10 +236,11 @@ def catalog_request # rubocop:disable Metrics/MethodLength deployment_params = { image_mapping: config[:image_mapping], flavor_mapping: config[:flavor_mapping], - name: config[:deployment_name], project_id: config[:project_id], version: config[:version], - } + }.tap do |h| + h[:name] = config[:deployment_name] unless config[:unique_name] + end catalog_request = vra_client.catalog.request(config[:catalog_id], deployment_params) diff --git a/lib/kitchen/driver/vra_version.rb b/lib/kitchen/driver/vra_version.rb index 9058e1c..776db95 100644 --- a/lib/kitchen/driver/vra_version.rb +++ b/lib/kitchen/driver/vra_version.rb @@ -20,6 +20,6 @@ module Kitchen module Driver - VRA_VERSION = "3.3.1" + VRA_VERSION = "3.3.2" end end