From f7db2eefef27a5603560e3b29c4b1f9d0c676460 Mon Sep 17 00:00:00 2001 From: Prashanth Balasubramanian Date: Thu, 22 Oct 2015 11:25:04 -0700 Subject: [PATCH] cloudprovider methods to list resources and get health --- pkg/cloudprovider/providers/gce/gce.go | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pkg/cloudprovider/providers/gce/gce.go b/pkg/cloudprovider/providers/gce/gce.go index bd33d7a27d1..ea64db3e3ca 100644 --- a/pkg/cloudprovider/providers/gce/gce.go +++ b/pkg/cloudprovider/providers/gce/gce.go @@ -956,6 +956,11 @@ func (gce *GCECloud) DeleteUrlMap(name string) error { return gce.waitForGlobalOp(op) } +// ListUrlMaps lists all UrlMaps in the project. +func (gce *GCECloud) ListUrlMaps() (*compute.UrlMapList, error) { + return gce.service.UrlMaps.List(gce.projectID).Do() +} + // TargetHttpProxy management // GetTargetHttpProxy returns the UrlMap by name. @@ -1000,6 +1005,11 @@ func (gce *GCECloud) DeleteTargetHttpProxy(name string) error { return gce.waitForGlobalOp(op) } +// ListTargetHttpProxies lists all TargetHttpProxies in the project. +func (gce *GCECloud) ListTargetHttpProxies() (*compute.TargetHttpProxyList, error) { + return gce.service.TargetHttpProxies.List(gce.projectID).Do() +} + // GlobalForwardingRule management // CreateGlobalForwardingRule creates and returns a GlobalForwardingRule that points to the given TargetHttpProxy. @@ -1046,6 +1056,11 @@ func (gce *GCECloud) GetGlobalForwardingRule(name string) (*compute.ForwardingRu return gce.service.GlobalForwardingRules.Get(gce.projectID, name).Do() } +// ListGlobalForwardingRules lists all GlobalForwardingRules in the project. +func (gce *GCECloud) ListGlobalForwardingRules() (*compute.ForwardingRuleList, error) { + return gce.service.GlobalForwardingRules.List(gce.projectID).Do() +} + // BackendService Management // GetBackendService retrieves a backend by name. @@ -1083,6 +1098,19 @@ func (gce *GCECloud) CreateBackendService(bg *compute.BackendService) error { return gce.waitForGlobalOp(op) } +// ListBackendServices lists all backend services in the project. +func (gce *GCECloud) ListBackendServices() (*compute.BackendServiceList, error) { + return gce.service.BackendServices.List(gce.projectID).Do() +} + +// GetHealth returns the health of the BackendService identified by the given +// name, in the given instanceGroup. The instanceGroupLink is the fully +// qualified self link of an instance group. +func (gce *GCECloud) GetHealth(name string, instanceGroupLink string) (*compute.BackendServiceGroupHealth, error) { + groupRef := &compute.ResourceGroupReference{instanceGroupLink} + return gce.service.BackendServices.GetHealth(gce.projectID, name, groupRef).Do() +} + // Health Checks // GetHttpHealthCheck returns the given HttpHealthCheck by name. @@ -1120,6 +1148,11 @@ func (gce *GCECloud) CreateHttpHealthCheck(hc *compute.HttpHealthCheck) error { return gce.waitForGlobalOp(op) } +// ListHttpHealthCheck lists all HttpHealthChecks in the project. +func (gce *GCECloud) ListHttpHealthChecks() (*compute.HttpHealthCheckList, error) { + return gce.service.HttpHealthChecks.List(gce.projectID).Do() +} + // InstanceGroup Management // CreateInstanceGroup creates an instance group with the given instances. It is the callers responsibility to add named ports. @@ -1145,6 +1178,11 @@ func (gce *GCECloud) DeleteInstanceGroup(name string) error { return gce.waitForZoneOp(op) } +// ListInstanceGroups lists all InstanceGroups in the project and zone. +func (gce *GCECloud) ListInstanceGroups() (*compute.InstanceGroupList, error) { + return gce.service.InstanceGroups.List(gce.projectID, gce.zone).Do() +} + // ListInstancesInInstanceGroup lists all the instances in a given istance group and state. func (gce *GCECloud) ListInstancesInInstanceGroup(name string, state string) (*compute.InstanceGroupsListInstances, error) { return gce.service.InstanceGroups.ListInstances(