Skip to content

Commit

Permalink
Merge pull request #29 from AdamVB/master
Browse files Browse the repository at this point in the history
Fix Driver when using Subprojects + Updated Readme for external IP
  • Loading branch information
zzhaoy authored Nov 1, 2019
2 parents 9f5bbb6 + 57198c8 commit b47c6c8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.

Expand Down
3 changes: 3 additions & 0 deletions com/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
}

Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions com/cpp_sdk_core/cpp_sdk_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down
1 change: 1 addition & 0 deletions com/modules/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,5 @@ const (
CREDENTIAL = "Credential"
SDK_AUTHORIZATION_HEADER = "Authorization"
SDK_X_AUTH_TOKEN = "X-Auth-Token"
X_PROJECT_ID = "X-Project-Id"
)
1 change: 1 addition & 0 deletions com/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/*
Expand Down

0 comments on commit b47c6c8

Please sign in to comment.