Add dhcp-networks agent function
Related-PROD: PROD-28687 (PROD:28687)
Change-Id: Ica9c2579f1620ea11ec6ef0b5f0931797ab5716a
diff --git a/openstack/networking/v2/extensions/agents/requests.go b/openstack/networking/v2/extensions/agents/requests.go
index 79e50dd..be38a3a 100644
--- a/openstack/networking/v2/extensions/agents/requests.go
+++ b/openstack/networking/v2/extensions/agents/requests.go
@@ -2,6 +2,7 @@
import (
gophercloud "gerrit.mcp.mirantis.net/debian/gophercloud.git"
+ "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/networking/v2/networks"
"gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination"
)
@@ -11,3 +12,10 @@
return AgentPage{pagination.SinglePageBase(r)}
})
}
+
+// ListDHCPNetworks makes a request against the API to list networks that a DHCP agent hosts.
+func ListDHCPNetworks(c *gophercloud.ServiceClient, id string) pagination.Pager {
+ return pagination.NewPager(c, listDHCPNetworksURL(c, id), func(r pagination.PageResult) pagination.Page {
+ return networks.NetworkPage{pagination.LinkedPageBase{PageResult: r}}
+ })
+}
diff --git a/openstack/networking/v2/extensions/agents/results.go b/openstack/networking/v2/extensions/agents/results.go
index 344e675..2f09cf1 100644
--- a/openstack/networking/v2/extensions/agents/results.go
+++ b/openstack/networking/v2/extensions/agents/results.go
@@ -3,11 +3,13 @@
import "gerrit.mcp.mirantis.net/debian/gophercloud.git/pagination"
type Agent struct {
- Host string `json:"host"`
- Binary string `json:"binary"`
- AvailabilityZone string `json:"availability_zone"`
AdminStateUp bool `json:"admin_state_up"`
Alive bool `json:"alive"`
+ AvailabilityZone string `json:"availability_zone"`
+ Binary string `json:"binary"`
+ Host string `json:"host"`
+ ID string `json:"id"`
+ Type string `json:"agent_type"`
}
type AgentPage struct {
diff --git a/openstack/networking/v2/extensions/agents/urls.go b/openstack/networking/v2/extensions/agents/urls.go
index e4fac8d..4336ab9 100644
--- a/openstack/networking/v2/extensions/agents/urls.go
+++ b/openstack/networking/v2/extensions/agents/urls.go
@@ -5,3 +5,7 @@
func listURL(c *gophercloud.ServiceClient) string {
return c.ServiceURL("agents")
}
+
+func listDHCPNetworksURL(client *gophercloud.ServiceClient, id string) string {
+ return client.ServiceURL("agents", id, "dhcp-networks")
+}