From 6651b9240fe4818c2e78468f7b54d26edbf5ae8a Mon Sep 17 00:00:00 2001 From: tuotuobukaixin Date: Tue, 27 Mar 2018 15:31:49 +0800 Subject: [PATCH] update new endpoint --- com/client/ecsClient.go | 8 ++++---- com/client/imsClient.go | 2 +- com/client/neutronClient.go | 6 +++--- com/client/novaClient.go | 16 ++++++++-------- com/client/vpcClient.go | 28 ++++++++++++++-------------- otc/ecs.go | 4 ++-- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/com/client/ecsClient.go b/com/client/ecsClient.go index 0771d71..1e6c32c 100644 --- a/com/client/ecsClient.go +++ b/com/client/ecsClient.go @@ -25,7 +25,7 @@ import ( func (client *Client) CreateCloudServer(createCloudServerReq ecsModules.CreateCloudServerReq) ecsModules.CreateCloudServerResp { createCloudServerResp := ecsModules.CreateCloudServerResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/cloudservers" + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/cloudservers" client.RequestParam.Method = modules.HTTP_POST client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = createCloudServerReq.GetBodyContent() @@ -48,7 +48,7 @@ func (client *Client) CreateCloudServer(createCloudServerReq ecsModules.CreateCl func (client *Client) DeleteCloudServer(deleteCloudServerReq ecsModules.DeleteCloudServerReq) ecsModules.DeleteCloudServerResp { deleteCloudServerResp := ecsModules.DeleteCloudServerResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/cloudservers/delete" + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/cloudservers/delete" client.RequestParam.Method = modules.HTTP_POST client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = deleteCloudServerReq.GetBodyContent() @@ -71,7 +71,7 @@ func (client *Client) DeleteCloudServer(deleteCloudServerReq ecsModules.DeleteCl func (client *Client) ShowEcsJob(job_id string) ecsModules.ShowEcsJobResp { showEcsJobResp := ecsModules.ShowEcsJobResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/jobs/" + job_id + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/jobs/" + job_id client.RequestParam.Method = modules.HTTP_GET client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = "" @@ -94,7 +94,7 @@ func (client *Client) ShowEcsJob(job_id string) ecsModules.ShowEcsJobResp { func (client *Client) ListCloudServerFlavorsExt() ecsModules.ListCloudServerFlavorsExtResp { listCloudServerFlavorsExtResp := ecsModules.ListCloudServerFlavorsExtResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/cloudservers/flavors" + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/cloudservers/flavors" client.RequestParam.Method = modules.HTTP_GET client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = "" diff --git a/com/client/imsClient.go b/com/client/imsClient.go index 6c0b6a7..d4230c8 100644 --- a/com/client/imsClient.go +++ b/com/client/imsClient.go @@ -32,7 +32,7 @@ import ( */ func (client *Client) ListCloudImages(listCloudImagesReqEx *imsModules.ListCloudImagesReqEx) *imsModules.ListCloudImagesResp { ListCloudImagesResp := &imsModules.ListCloudImagesResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/cloudimages" + listCloudImagesReqEx.GetAbsolutePath() + client.RequestParam.Url = "https://ims." + client.RequestParam.Endpoint + "/v2/cloudimages" + listCloudImagesReqEx.GetAbsolutePath() client.RequestParam.Method = "GET" client.RequestParam.BodyContent = "" diff --git a/com/client/neutronClient.go b/com/client/neutronClient.go index cf7a82e..7442a08 100644 --- a/com/client/neutronClient.go +++ b/com/client/neutronClient.go @@ -32,7 +32,7 @@ import ( */ func (client *Client) CreateSecurityGroupRule(createSecurityGroupRuleReq *neutronModules.CreateSecurityGroupRuleReq) *neutronModules.CreateSecurityGroupRuleResp { CreateSecurityGroupRuleResp := &neutronModules.CreateSecurityGroupRuleResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2.0/security-group-rules" + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v2.0/security-group-rules" client.RequestParam.Method = "POST" client.RequestParam.BodyContent = createSecurityGroupRuleReq.GetBodyContent() @@ -65,7 +65,7 @@ func (client *Client) CreateSecurityGroupRule(createSecurityGroupRuleReq *neutro */ func (client *Client) ShowSecurityGroupRule(rules_security_groups_id string) *neutronModules.ShowSecurityGroupRuleResp { ShowSecurityGroupRuleResp := &neutronModules.ShowSecurityGroupRuleResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2.0/security-group-rules/" + rules_security_groups_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v2.0/security-group-rules/" + rules_security_groups_id client.RequestParam.Method = "GET" client.RequestParam.BodyContent = "" @@ -98,7 +98,7 @@ func (client *Client) ShowSecurityGroupRule(rules_security_groups_id string) *ne */ func (client *Client) DeleteSecurityGroupRule(rules_security_groups_id string) *neutronModules.DeleteSecurityGroupRuleResp { DeleteSecurityGroupRuleResp := &neutronModules.DeleteSecurityGroupRuleResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2.0/security-group-rules/" + rules_security_groups_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v2.0/security-group-rules/" + rules_security_groups_id client.RequestParam.Method = "DELETE" client.RequestParam.BodyContent = "" diff --git a/com/client/novaClient.go b/com/client/novaClient.go index 3b59064..6327fb4 100644 --- a/com/client/novaClient.go +++ b/com/client/novaClient.go @@ -26,7 +26,7 @@ import ( func (client *Client) ListInterfaces(server_id string) novaModules.ListInterfacesResp { listInterfacesResp := novaModules.ListInterfacesResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + "/os-interface" + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + "/os-interface" client.RequestParam.Method = modules.HTTP_GET client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = "" @@ -49,7 +49,7 @@ func (client *Client) ListInterfaces(server_id string) novaModules.ListInterface func (client *Client) CreateKeypair(createKeypairReq novaModules.CreateKeypairReq) novaModules.CreateKeypairResp { createKeypairResp := novaModules.CreateKeypairResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/os-keypairs" + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/os-keypairs" client.RequestParam.Method = modules.HTTP_POST client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = createKeypairReq.GetBodyContent() @@ -72,7 +72,7 @@ func (client *Client) CreateKeypair(createKeypairReq novaModules.CreateKeypairRe func (client *Client) DeleteKeyPair(keypair_name string) novaModules.DeleteKeyPairResp { deleteKeyPairResp := novaModules.DeleteKeyPairResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/os-keypairs/" + keypair_name + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/os-keypairs/" + keypair_name client.RequestParam.Method = modules.HTTP_DELETE client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = "" @@ -94,7 +94,7 @@ func (client *Client) DeleteKeyPair(keypair_name string) novaModules.DeleteKeyPa func (client *Client) StartServer(server_id string) novaModules.StartServerResp { startServer := novaModules.StartServerResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + "/action" + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + "/action" client.RequestParam.Method = modules.HTTP_POST client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = "{ \"os-start\": {} }" @@ -116,7 +116,7 @@ func (client *Client) StartServer(server_id string) novaModules.StartServerResp func (client *Client) StopServer(server_id string) novaModules.StopServerResp { stopServer := novaModules.StopServerResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + "/action" + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + "/action" client.RequestParam.Method = modules.HTTP_POST client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = "{ \"os-stop\": {} }" @@ -138,7 +138,7 @@ func (client *Client) StopServer(server_id string) novaModules.StopServerResp { func (client *Client) RebootServer(server_id, rebootType string) novaModules.RebootServerResp { rebootServer := novaModules.RebootServerResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + "/action" + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + "/action" client.RequestParam.Method = modules.HTTP_POST client.RequestParam.RequestContentType = modules.ApplicationJson bodyMap := make(map[string]map[string]string) @@ -166,7 +166,7 @@ func (client *Client) RebootServer(server_id, rebootType string) novaModules.Reb func (client *Client) DeleteAnServer(server_id string) novaModules.DeleteAnServerResp { deleteAnServerResp := novaModules.DeleteAnServerResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id client.RequestParam.Method = modules.HTTP_DELETE client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = "" @@ -192,7 +192,7 @@ func (client *Client) ShowServer(server_id string) novaModules.ShowServerResp { showServerResp.Server.NumaOpts = -1 showServerResp.Server.Progress = -1 - client.RequestParam.Url = client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id + client.RequestParam.Url = "https://ecs." + client.RequestParam.Endpoint + "/v2/" + client.TenantID + "/servers/" + server_id client.RequestParam.Method = modules.HTTP_GET client.RequestParam.RequestContentType = modules.ApplicationJson client.RequestParam.BodyContent = "" diff --git a/com/client/vpcClient.go b/com/client/vpcClient.go index 9f5338f..c380e1e 100644 --- a/com/client/vpcClient.go +++ b/com/client/vpcClient.go @@ -32,7 +32,7 @@ import ( */ func (client *Client) DeleteVpc(vpc_id string) *vpcModules.DeleteVpcResp { DeleteVpcResp := &vpcModules.DeleteVpcResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/vpcs/" + vpc_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/vpcs/" + vpc_id client.RequestParam.Method = "DELETE" client.RequestParam.BodyContent = "" @@ -60,7 +60,7 @@ func (client *Client) DeleteVpc(vpc_id string) *vpcModules.DeleteVpcResp { */ func (client *Client) CreateVpc(createVpcReq vpcModules.CreateVpcReq) *vpcModules.CreateVpcResp { CreateVpcResp := &vpcModules.CreateVpcResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/vpcs" + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/vpcs" client.RequestParam.Method = "POST" client.RequestParam.BodyContent = createVpcReq.GetBodyContent() @@ -90,7 +90,7 @@ func (client *Client) CreateVpc(createVpcReq vpcModules.CreateVpcReq) *vpcModule */ func (client *Client) ShowVpc(vpc_id string) *vpcModules.ShowVpcResp { ShowVpcResp := &vpcModules.ShowVpcResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/vpcs/" + vpc_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/vpcs/" + vpc_id client.RequestParam.Method = "GET" client.RequestParam.BodyContent = "" @@ -122,7 +122,7 @@ func (client *Client) ShowVpc(vpc_id string) *vpcModules.ShowVpcResp { */ func (client *Client) CreateSubnet(createSubnetReq *vpcModules.CreateSubnetReq) *vpcModules.CreateSubnetResp { CreateSubnetResp := &vpcModules.CreateSubnetResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/subnets" + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/subnets" client.RequestParam.Method = "POST" client.RequestParam.BodyContent = createSubnetReq.GetBodyContent() @@ -153,7 +153,7 @@ func (client *Client) CreateSubnet(createSubnetReq *vpcModules.CreateSubnetReq) */ func (client *Client) ShowSubnet(subnet_id string) *vpcModules.ShowSubnetResp { ShowSubnetResp := &vpcModules.ShowSubnetResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/subnets/" + subnet_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/subnets/" + subnet_id client.RequestParam.BodyContent = "" client.RequestParam.Method = "GET" @@ -177,7 +177,7 @@ func (client *Client) ShowSubnet(subnet_id string) *vpcModules.ShowSubnetResp { func (client *Client) ListSubnets(limit int, marker, vpc_id string) *vpcModules.ListSubnetsResp { ListSubnetsResp := &vpcModules.ListSubnetsResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/subnets" + "?limit=" + fmt.Sprintf("%d", limit) + "&marker=" + marker + "&vpc_id=" + vpc_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/subnets" + "?limit=" + fmt.Sprintf("%d", limit) + "&marker=" + marker + "&vpc_id=" + vpc_id client.RequestParam.BodyContent = "" client.RequestParam.Method = "GET" @@ -209,7 +209,7 @@ func (client *Client) ListSubnets(limit int, marker, vpc_id string) *vpcModules. */ func (client *Client) DeleteSubnet(vpc_id, subnet_id string) *vpcModules.DeleteSubnetResp { DeleteSubnetResp := &vpcModules.DeleteSubnetResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/vpcs/" + vpc_id + "/subnets/" + subnet_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/vpcs/" + vpc_id + "/subnets/" + subnet_id client.RequestParam.BodyContent = "" client.RequestParam.Method = "DELETE" @@ -239,7 +239,7 @@ func (client *Client) DeleteSubnet(vpc_id, subnet_id string) *vpcModules.DeleteS */ func (client *Client) UpdateBandwidth(bandwidth_id string, updateBandwidthReq *vpcModules.UpdateBandwidthReq) *vpcModules.UpdateBandwidthResp { UpdateBandwidthResp := &vpcModules.UpdateBandwidthResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/bandwidths/" + bandwidth_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/bandwidths/" + bandwidth_id client.RequestParam.BodyContent = updateBandwidthReq.GetBodyContent() client.RequestParam.Method = "PUT" @@ -275,7 +275,7 @@ func (client *Client) UpdateBandwidth(bandwidth_id string, updateBandwidthReq *v */ func (client *Client) ListBandwidths(limit int, marker string) *vpcModules.ListBandwidthsResp { ListBandwidthsResp := &vpcModules.ListBandwidthsResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/bandwidths" + "?limit=" + fmt.Sprintf("%d", limit) + "&marker=" + marker + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/bandwidths" + "?limit=" + fmt.Sprintf("%d", limit) + "&marker=" + marker client.RequestParam.Method = "GET" client.RequestParam.BodyContent = "" @@ -307,7 +307,7 @@ func (client *Client) ListBandwidths(limit int, marker string) *vpcModules.ListB */ func (client *Client) CreateSecurityGroup(createSecurityGroupReq *vpcModules.CreateSecurityGroupReq) *vpcModules.CreateSecurityGroupResp { CreateSecurityGroupResp := &vpcModules.CreateSecurityGroupResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/security-groups" + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/security-groups" client.RequestParam.Method = "POST" client.RequestParam.BodyContent = createSecurityGroupReq.GetBodyContent() @@ -345,7 +345,7 @@ func (client *Client) CreateSecurityGroup(createSecurityGroupReq *vpcModules.Cre */ func (client *Client) ListSecurityGroups(limit int, marker, vpc_id string) *vpcModules.ListSecurityGroupsResp { ListSecurityGroupsResp := &vpcModules.ListSecurityGroupsResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/security-groups" + "?limit=" + fmt.Sprintf("%d", limit) + "&marker=" + marker + "&vpc_id=" + vpc_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/security-groups" + "?limit=" + fmt.Sprintf("%d", limit) + "&marker=" + marker + "&vpc_id=" + vpc_id client.RequestParam.Method = "GET" client.RequestParam.BodyContent = "" @@ -377,7 +377,7 @@ func (client *Client) ListSecurityGroups(limit int, marker, vpc_id string) *vpcM */ func (client *Client) CreatePublicIp(createPublicipReq *vpcModules.CreatePublicIpReq) *vpcModules.CreatePublicIpResp { CreatePublicIpResp := &vpcModules.CreatePublicIpResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/publicips" + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/publicips" client.RequestParam.Method = "POST" client.RequestParam.BodyContent = createPublicipReq.GetBodyContent() @@ -413,7 +413,7 @@ func (client *Client) CreatePublicIp(createPublicipReq *vpcModules.CreatePublicI */ func (client *Client) UpdatePublicIp(publicip_id string, updatePublicIpReq *vpcModules.UpdatePublicIpReq) *vpcModules.UpdatePublicIpResp { UpdatePublicIpResp := &vpcModules.UpdatePublicIpResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/publicips/" + publicip_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/publicips/" + publicip_id client.RequestParam.Method = "PUT" client.RequestParam.BodyContent = updatePublicIpReq.GetBodyContent() @@ -445,7 +445,7 @@ func (client *Client) UpdatePublicIp(publicip_id string, updatePublicIpReq *vpcM */ func (client *Client) DeletePublicIp(publicip_id string) *vpcModules.DeletePublicIpResp { DeletePublicIpResp := &vpcModules.DeletePublicIpResp{} - client.RequestParam.Url = client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/publicips/" + publicip_id + client.RequestParam.Url = "https://vpc." + client.RequestParam.Endpoint + "/v1/" + client.TenantID + "/publicips/" + publicip_id client.RequestParam.Method = "DELETE" client.RequestParam.BodyContent = "" diff --git a/otc/ecs.go b/otc/ecs.go index 04ef5eb..234bec7 100644 --- a/otc/ecs.go +++ b/otc/ecs.go @@ -8,7 +8,7 @@ import ( "io" "io/ioutil" _ "os" - _ "strings" + "strings" "time" _ "github.com/huawei/DockerMachineDriver4OTC/otcgo/ecs" @@ -264,7 +264,7 @@ func generateId() string { func (d *Driver) initClient() *client.Client { var clientConf modules.ClientConfiguration - clientConf.Endpoint = d.ServiceEndpoint + clientConf.Endpoint = strings.Split(d.ServiceEndpoint, "https://ecs.")[1] clientConf.ServiceName = serviceName clientConf.Region = d.Region