From 22251274642319684fb60291b440d8a2e9a9fbbd Mon Sep 17 00:00:00 2001 From: zengchen1024 Date: Tue, 11 Sep 2018 14:43:34 +0800 Subject: [PATCH 1/2] update the endpoint of ces --- openstack/client.go | 5 ++++- openstack/cloudeyeservice/alarmrule/urls.go | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/openstack/client.go b/openstack/client.go index 8a59fe28e..574f1e622 100644 --- a/openstack/client.go +++ b/openstack/client.go @@ -513,10 +513,13 @@ func NewRdsServiceV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts } func NewCESClient(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { - sc, err := initClientOpts(client, eo, "ces") + sc, err := initClientOpts(client, eo, "volumev2") if err != nil { return nil, err + } + e := strings.Replace(sc.Endpoint, "v2", "V1.0", 1) + sc.Endpoint = strings.Replace(e, "evs", "ces", 1) sc.ResourceBase = sc.Endpoint return sc, err } diff --git a/openstack/cloudeyeservice/alarmrule/urls.go b/openstack/cloudeyeservice/alarmrule/urls.go index 1edc883fc..ab558a470 100644 --- a/openstack/cloudeyeservice/alarmrule/urls.go +++ b/openstack/cloudeyeservice/alarmrule/urls.go @@ -7,13 +7,13 @@ const ( ) func rootURL(c *golangsdk.ServiceClient) string { - return c.ServiceURL(c.ProjectID, rootPath) + return c.ServiceURL(rootPath) } func resourceURL(c *golangsdk.ServiceClient, id string) string { - return c.ServiceURL(c.ProjectID, rootPath, id) + return c.ServiceURL(rootPath, id) } func actionURL(c *golangsdk.ServiceClient, id string) string { - return c.ServiceURL(c.ProjectID, rootPath, id, "action") + return c.ServiceURL(rootPath, id, "action") } From a1bd9569d11ec60dd6fa66df408c681f07924c0f Mon Sep 17 00:00:00 2001 From: zengchen1024 Date: Tue, 11 Sep 2018 15:04:38 +0800 Subject: [PATCH 2/2] update endpoint of as --- openstack/autoscaling/v1/configurations/urls.go | 8 ++++---- openstack/autoscaling/v1/groups/urls.go | 12 ++++++------ openstack/autoscaling/v1/instances/urls.go | 6 +++--- openstack/autoscaling/v1/policies/urls.go | 8 ++++---- openstack/client.go | 9 +++++++-- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/openstack/autoscaling/v1/configurations/urls.go b/openstack/autoscaling/v1/configurations/urls.go index 4d8056f88..bc7388b82 100644 --- a/openstack/autoscaling/v1/configurations/urls.go +++ b/openstack/autoscaling/v1/configurations/urls.go @@ -7,17 +7,17 @@ import ( const resourcePath = "scaling_configuration" func createURL(client *golangsdk.ServiceClient) string { - return client.ServiceURL(client.ProjectID, resourcePath) + return client.ServiceURL(resourcePath) } func getURL(client *golangsdk.ServiceClient, id string) string { - return client.ServiceURL(client.ProjectID, resourcePath, id) + return client.ServiceURL(resourcePath, id) } func deleteURL(client *golangsdk.ServiceClient, id string) string { - return client.ServiceURL(client.ProjectID, resourcePath, id) + return client.ServiceURL(resourcePath, id) } func listURL(client *golangsdk.ServiceClient) string { - return client.ServiceURL(client.ProjectID, resourcePath) + return client.ServiceURL(resourcePath) } diff --git a/openstack/autoscaling/v1/groups/urls.go b/openstack/autoscaling/v1/groups/urls.go index ae02e4807..531275565 100644 --- a/openstack/autoscaling/v1/groups/urls.go +++ b/openstack/autoscaling/v1/groups/urls.go @@ -9,27 +9,27 @@ import ( const resourcePath = "scaling_group" func createURL(c *golangsdk.ServiceClient) string { - ur := c.ServiceURL(c.ProjectID, resourcePath) + ur := c.ServiceURL(resourcePath) log.Printf("[DEBUG] Create URL is: %#v", ur) return ur } func deleteURL(c *golangsdk.ServiceClient, id string) string { - return c.ServiceURL(c.ProjectID, resourcePath, id) + return c.ServiceURL(resourcePath, id) } func getURL(c *golangsdk.ServiceClient, id string) string { - return c.ServiceURL(c.ProjectID, resourcePath, id) + return c.ServiceURL(resourcePath, id) } func listURL(c *golangsdk.ServiceClient) string { - return c.ServiceURL(c.ProjectID, resourcePath) + return c.ServiceURL(resourcePath) } func enableURL(c *golangsdk.ServiceClient, id string) string { - return c.ServiceURL(c.ProjectID, resourcePath, id, "action") + return c.ServiceURL(resourcePath, id, "action") } func updateURL(c *golangsdk.ServiceClient, id string) string { - return c.ServiceURL(c.ProjectID, resourcePath, id) + return c.ServiceURL(resourcePath, id) } diff --git a/openstack/autoscaling/v1/instances/urls.go b/openstack/autoscaling/v1/instances/urls.go index 36199d01a..ef145f2b8 100644 --- a/openstack/autoscaling/v1/instances/urls.go +++ b/openstack/autoscaling/v1/instances/urls.go @@ -9,17 +9,17 @@ const resourcePath = "scaling_group_instance" //getURL will build the querystring by which can be able to query all the instances //of group func listURL(client *golangsdk.ServiceClient, groupID string) string { - return client.ServiceURL(client.ProjectID, resourcePath, groupID, "list") + return client.ServiceURL(resourcePath, groupID, "list") } //deleteURL will build the query url by which can be able to delete an instance from //the group func deleteURL(client *golangsdk.ServiceClient, id string) string { - return client.ServiceURL(client.ProjectID, resourcePath, id) + return client.ServiceURL(resourcePath, id) } //batchURL will build the query url by which can be able to batch add or delete //instances func batchURL(client *golangsdk.ServiceClient, groupID string) string { - return client.ServiceURL(client.ProjectID, resourcePath, groupID, "action") + return client.ServiceURL(resourcePath, groupID, "action") } diff --git a/openstack/autoscaling/v1/policies/urls.go b/openstack/autoscaling/v1/policies/urls.go index f538ccfc3..5d926e199 100644 --- a/openstack/autoscaling/v1/policies/urls.go +++ b/openstack/autoscaling/v1/policies/urls.go @@ -9,20 +9,20 @@ const resourcePath = "scaling_policy" //createURL will build the rest query url of creation //the create url is endpoint/scaling_policy func createURL(client *golangsdk.ServiceClient) string { - return client.ServiceURL(client.ProjectID, resourcePath) + return client.ServiceURL(resourcePath) } //deleteURL will build the url of deletion //its pattern is endpoint/scaling_policy/ func deleteURL(client *golangsdk.ServiceClient, id string) string { - return client.ServiceURL(client.ProjectID, resourcePath, id) + return client.ServiceURL(resourcePath, id) } //getURL will build the get url of get function func getURL(client *golangsdk.ServiceClient, id string) string { - return client.ServiceURL(client.ProjectID, resourcePath, id) + return client.ServiceURL(resourcePath, id) } func updateURL(c *golangsdk.ServiceClient, id string) string { - return c.ServiceURL(c.ProjectID, resourcePath, id) + return c.ServiceURL(resourcePath, id) } diff --git a/openstack/client.go b/openstack/client.go index 574f1e622..d3163fe11 100644 --- a/openstack/client.go +++ b/openstack/client.go @@ -516,7 +516,6 @@ func NewCESClient(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) ( sc, err := initClientOpts(client, eo, "volumev2") if err != nil { return nil, err - } e := strings.Replace(sc.Endpoint, "v2", "V1.0", 1) sc.Endpoint = strings.Replace(e, "evs", "ces", 1) @@ -541,7 +540,13 @@ func NewComputeV1(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) ( //NewAutoScalingService creates a ServiceClient that may be used to access the //auto-scaling service of huawei public cloud func NewAutoScalingService(client *golangsdk.ProviderClient, eo golangsdk.EndpointOpts) (*golangsdk.ServiceClient, error) { - sc, err := initClientOpts(client, eo, "as") + sc, err := initClientOpts(client, eo, "volumev2") + if err != nil { + return nil, err + } + e := strings.Replace(sc.Endpoint, "v2", "autoscaling-api/v1", 1) + sc.Endpoint = strings.Replace(e, "evs", "as", 1) + sc.ResourceBase = sc.Endpoint return sc, err }