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
This commit is contained in:
parent
8510f072a9
commit
c29e5de381
|
@ -70,7 +70,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
||||||
|
|
||||||
// Build the steps
|
// Build the steps
|
||||||
steps := []multistep.Step{
|
steps := []multistep.Step{
|
||||||
&StepLoadExtensions{},
|
|
||||||
&StepLoadFlavor{
|
&StepLoadFlavor{
|
||||||
Flavor: b.config.Flavor,
|
Flavor: b.config.Flavor,
|
||||||
},
|
},
|
||||||
|
|
|
@ -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) {
|
|
||||||
}
|
|
|
@ -15,15 +15,8 @@ type StepStopServer struct{}
|
||||||
func (s *StepStopServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
func (s *StepStopServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
config := state.Get("config").(Config)
|
config := state.Get("config").(Config)
|
||||||
extensions := state.Get("extensions").(map[string]struct{})
|
|
||||||
server := state.Get("server").(*servers.Server)
|
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
|
// We need the v2 compute client
|
||||||
client, err := config.computeV2Client()
|
client, err := config.computeV2Client()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue