diff --git a/README.md b/README.md index 01d60f7..128af94 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Option Name | Description ``--otc-ssh-user``|Instance's optional ssh user|| ``--otc-subnet-id``|Subnet ID for your instance private network (Network ID)|| ``--otc-tenant-id``|Tenant ID (Project ID)|| +``--otc-elastic-ip``|Set to 0 to not allocate an EIP (use private IP)|| ## Environment variables and default values: @@ -70,6 +71,7 @@ Option Name | Description | `--otc-ssh-user` | `SSH_USER` | - | | `--otc-subnet-id` | `SUBNET_ID` | - | | `--otc-tenant-id` | `TENANT_ID` | - | +| `--otc-elastic-ip` | `ELASTIC_IP` | `1` | Each environment variable may be overloaded by its option equivalent at runtime. diff --git a/com/client/client.go b/com/client/client.go index d19c1ff..eecf242 100644 --- a/com/client/client.go +++ b/com/client/client.go @@ -129,6 +129,7 @@ func InitV4Client(AK, SK, TenantID string, clientConfiguration modules.ClientCon RequestParam.SK = SK RequestParam.Token = "" RequestParam.AuthType = modules.V4_AUTH + RequestParam.Subproject_ID = TenantID client = &Client{TenantID, RequestParam} return client @@ -150,6 +151,7 @@ func InitTokenClient(Token, TenantID string, clientConfiguration modules.ClientC RequestParam.ServiceName = clientConfiguration.ServiceName RequestParam.Token = Token RequestParam.AuthType = modules.Token_AUTH + RequestParam.Subproject_ID = TenantID return &Client{TenantID, RequestParam} } @@ -170,6 +172,7 @@ func GetToken(username, password, tenant_id string, clientConfiguration modules. RequestParam.AuthType = modules.Token_AUTH RequestParam.RequestContentType = modules.ApplicationJson RequestParam.Token = "" + RequestParam.Subproject_ID = tenant_id jsonStr := `{"auth": {"identity": {"methods": ["password"], "password": {"user": {"domain": {"name": ""}, "name": "", "password": ""}}}, "scope": {"domain": {"name": ""}, "project": {"id": ""}}}}` var data AuthStructInfo diff --git a/com/cpp_sdk_core/cpp_sdk_core.go b/com/cpp_sdk_core/cpp_sdk_core.go index 19c9fe1..c4fc05c 100644 --- a/com/cpp_sdk_core/cpp_sdk_core.go +++ b/com/cpp_sdk_core/cpp_sdk_core.go @@ -206,6 +206,8 @@ func SendRequest(requestParam *modules.RequestParam) (result *modules.Result) { var authString string authString += modules.SDK_HMAC_SHA256 + " " + modules.CREDENTIAL + "=" + requestParam.AK + "/" + simpleTime + "/" + requestParam.Region + "/" + requestParam.ServiceName + "/" + modules.SDK_REQUEST + ", " + modules.SIGNED_HEADERS + "=" + signedHeadersValue + ", " + modules.SIGNATURE + "=" + finalSignature headerCollection[strings.ToLower(modules.SDK_AUTHORIZATION_HEADER)] = strings.TrimSpace(authString) + //set special X-Project-Id header for subproject + headerCollection[modules.X_PROJECT_ID] = requestParam.Subproject_ID } conn := &http.Client{Transport: getTransport()} diff --git a/com/modules/enum.go b/com/modules/enum.go index 118ff52..4424206 100644 --- a/com/modules/enum.go +++ b/com/modules/enum.go @@ -78,4 +78,5 @@ const ( CREDENTIAL = "Credential" SDK_AUTHORIZATION_HEADER = "Authorization" SDK_X_AUTH_TOKEN = "X-Auth-Token" + X_PROJECT_ID = "X-Project-Id" ) diff --git a/com/modules/modules.go b/com/modules/modules.go index 24ddd41..670546b 100644 --- a/com/modules/modules.go +++ b/com/modules/modules.go @@ -58,6 +58,7 @@ type RequestParam struct { RequestContentType string // Request content type AuthType int // Authorization mode Url string // Http url + Subproject_ID string // Subproject ID } /*