Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1881532: openstack: Only list external networks in prompt #4226

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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