Skip to content

Commit df19807

Browse files
committed
Looks for more device_owners when looking for a port for external
network #1985
1 parent acc680d commit df19807

File tree

1 file changed

+16
-2
lines changed
  • pkg/cloud/services/networking

1 file changed

+16
-2
lines changed

pkg/cloud/services/networking/port.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"strings"
2525
"time"
2626

27+
"github.com/gophercloud/gophercloud"
2728
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/portsbinding"
2829
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/portsecurity"
2930
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
@@ -58,6 +59,19 @@ func (s *Service) GetPortFromInstanceIP(instanceID string, ip string) ([]ports.P
5859
return s.client.ListPort(portOpts)
5960
}
6061

62+
type PortListOpts struct {
63+
DeviceOwner []string `q:"device_owner"`
64+
NetworkID string `q:"network_id"`
65+
}
66+
67+
func (p *PortListOpts) ToPortListQuery() (string, error) {
68+
q, err := gophercloud.BuildQueryString(p)
69+
if err != nil {
70+
return "", err
71+
}
72+
return q.String(), nil
73+
}
74+
6175
func (s *Service) GetPortForExternalNetwork(instanceID string, externalNetworkID string) (*ports.Port, error) {
6276
instancePortsOpts := ports.ListOpts{
6377
DeviceID: instanceID,
@@ -68,9 +82,9 @@ func (s *Service) GetPortForExternalNetwork(instanceID string, externalNetworkID
6882
}
6983

7084
for _, instancePort := range instancePorts {
71-
networkPortsOpts := ports.ListOpts{
85+
networkPortsOpts := &PortListOpts{
7286
NetworkID: instancePort.NetworkID,
73-
DeviceOwner: "network:router_interface",
87+
DeviceOwner: []string{"network:router_interface", "network:router_interface_distributed", "network:ha_router_replicated_interface", "network:router_ha_interface"},
7488
}
7589

7690
networkPorts, err := s.client.ListPort(networkPortsOpts)

0 commit comments

Comments
 (0)