From c29e5de38122872cab55cf049580ebd5e8517f6d Mon Sep 17 00:00:00 2001 From: Edward Date: Fri, 17 Nov 2017 10:28:15 +0800 Subject: [PATCH] Remove the deprecated extensions The Nova extension API was deprecated from OpenStack N release. this parts of code cannot work well with the newest OpenStack version. This patch is to remove the relative parts: 1. Remove the step_load_extensions.go 2. Remove the step of extension from builder.go 3. Remove the parameter parsing from step_stop_server.go Resolves: #5581 --- builder/openstack/builder.go | 1 - builder/openstack/step_load_extensions.go | 59 ----------------------- builder/openstack/step_stop_server.go | 7 --- 3 files changed, 67 deletions(-) mode change 100644 => 100755 builder/openstack/builder.go delete mode 100644 builder/openstack/step_load_extensions.go mode change 100644 => 100755 builder/openstack/step_stop_server.go diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go old mode 100644 new mode 100755 index f3c6fd13b..42770c625 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -70,7 +70,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe // Build the steps steps := []multistep.Step{ - &StepLoadExtensions{}, &StepLoadFlavor{ Flavor: b.config.Flavor, }, diff --git a/builder/openstack/step_load_extensions.go b/builder/openstack/step_load_extensions.go deleted file mode 100644 index b11cf5527..000000000 --- a/builder/openstack/step_load_extensions.go +++ /dev/null @@ -1,59 +0,0 @@ -package openstack - -import ( - "context" - "fmt" - "log" - - "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions" - "github.com/gophercloud/gophercloud/pagination" - "github.com/hashicorp/packer/helper/multistep" - "github.com/hashicorp/packer/packer" -) - -// StepLoadExtensions gets the FlavorRef from a Flavor. It first assumes -// that the Flavor is a ref and verifies it. Otherwise, it tries to find -// the flavor by name. -type StepLoadExtensions struct{} - -func (s *StepLoadExtensions) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { - config := state.Get("config").(Config) - ui := state.Get("ui").(packer.Ui) - - // We need the v2 compute client - client, err := config.computeV2Client() - if err != nil { - err = fmt.Errorf("Error initializing compute client: %s", err) - state.Put("error", err) - return multistep.ActionHalt - } - - ui.Say("Discovering enabled extensions...") - result := make(map[string]struct{}, 15) - pager := extensions.List(client) - err = pager.EachPage(func(p pagination.Page) (bool, error) { - // Extract the extensions from this page - exts, err := extensions.ExtractExtensions(p) - if err != nil { - return false, err - } - - for _, ext := range exts { - log.Printf("[DEBUG] Discovered extension: %s", ext.Alias) - result[ext.Alias] = struct{}{} - } - - return true, nil - }) - if err != nil { - err = fmt.Errorf("Error loading extensions: %s", err) - state.Put("error", err) - return multistep.ActionHalt - } - - state.Put("extensions", result) - return multistep.ActionContinue -} - -func (s *StepLoadExtensions) Cleanup(state multistep.StateBag) { -} diff --git a/builder/openstack/step_stop_server.go b/builder/openstack/step_stop_server.go old mode 100644 new mode 100755 index 1c864eef0..4a0f867b0 --- a/builder/openstack/step_stop_server.go +++ b/builder/openstack/step_stop_server.go @@ -15,15 +15,8 @@ type StepStopServer struct{} func (s *StepStopServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) config := state.Get("config").(Config) - extensions := state.Get("extensions").(map[string]struct{}) server := state.Get("server").(*servers.Server) - // Verify we have the extension - if _, ok := extensions["os-server-start-stop"]; !ok { - ui.Say("OpenStack cluster doesn't support stop, skipping...") - return multistep.ActionContinue - } - // We need the v2 compute client client, err := config.computeV2Client() if err != nil {