Skip to content

Commit

Permalink
openstack: Only list external networks in prompt
Browse files Browse the repository at this point in the history
Non-external networks are not accepted and would make the Installer
error.
  • Loading branch information
pierreprinetti committed Sep 29, 2020
1 parent ed5dcf4 commit 3f392db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/asset/installconfig/openstack/openstack.go
Expand Up @@ -51,7 +51,7 @@ func Platform() (*openstack.Platform, error) {
// will be ignored if OS_CLOUD contains something.
os.Unsetenv("OS_CLOUD")

networkNames, err := getNetworkNames(cloud)
networkNames, err := getExternalNetworkNames(cloud)
if err != nil {
return nil, err
}
Expand Down
13 changes: 10 additions & 3 deletions pkg/asset/installconfig/openstack/validvaluesfetcher.go
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/pkg/errors"

"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
"github.com/gophercloud/utils/openstack/clientconfig"
Expand All @@ -24,16 +25,22 @@ func getCloudNames() ([]string, error) {
return cloudNames, nil
}

// getNetworkNames gets the valid network names.
func getNetworkNames(cloud string) ([]string, error) {
// getExternalNetworkNames interrogates OpenStack to get the external network
// names.
func getExternalNetworkNames(cloud string) ([]string, error) {
conn, err := clientconfig.NewServiceClient("network", &clientconfig.ClientOpts{
Cloud: cloud,
})
if err != nil {
return nil, err
}

listOpts := networks.ListOpts{}
iTrue := true
listOpts := external.ListOptsExt{
ListOptsBuilder: networks.ListOpts{},
External: &iTrue,
}

allPages, err := networks.List(conn, listOpts).AllPages()
if err != nil {
return nil, err
Expand Down

0 comments on commit 3f392db

Please sign in to comment.