Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
ciao-cli: Add tenant name evironment variable
Browse files Browse the repository at this point in the history
When user is part of more than one project (tenant), it
allows to use environment variables for passing the proper
project name instead of using the ``tenant-name`` or ``tenant-id``
parameters in ``ciao-cli`` command. It would verify if the
``CIAO_TENANT_NAME`` environment variable exists, it would use it;
if not, everything would normally proceed.

Signed-off-by: Munoz, Obed N <[email protected]>
  • Loading branch information
obedmr committed Jul 20, 2016
1 parent 051179b commit c6dcd31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ciao-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ credentials and networking information:
* `CIAO_COMPUTEPORT` exports the Ciao compute alternative port
* `CIAO_USERNAME` exports the Ciao username
* `CIAO_PASSWORD` export the Ciao password for `CIAO_USERNAME`
* `CIAO_TENANT_NAME` export the Ciao tenant name for `CIAO_USERNAME`

All those environment variables can be set through an rc file.
For example:
Expand All @@ -80,6 +81,7 @@ export CIAO_CONTROLLER=ciao-ctl.intel.com
export CIAO_IDENTITY=https://ciao-identity.intel.com:35357
export CIAO_USERNAME=user
export CIAO_PASSWORD=ciaouser
export CIAO_TENANT_NAME=admin
```

Exporting those variables is not compulsory and they can be defined
Expand Down Expand Up @@ -146,6 +148,7 @@ Let's assume we're running a Ciao cluster with the following settings:
* The `user` user is part of only one project: `project1`
* The password for `user` is `ciaouser`
* `project1` UUID is `68a76514-5c8e-40a8-8c9e-0570a11d035b`
*

This can be defined through the following Ciao rc file:

Expand All @@ -156,6 +159,7 @@ export CIAO_CONTROLLER=ciao-ctl.intel.com
export CIAO_IDENTITY=https://ciao-identity.intel.com:35357
export CIAO_USERNAME=user
export CIAO_PASSWORD=ciaouser
export CIAO_TENANT_NAME=project1
```

### Cluster status (Privileged)
Expand Down
6 changes: 6 additions & 0 deletions ciao-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ const (
ciaoUsernameEnv = "CIAO_USERNAME"
ciaoPasswordEnv = "CIAO_PASSWORD"
ciaoComputePortEnv = "CIAO_COMPUTEPORT"
ciaoTenantNameEnv = "CIAO_TENANT_NAME"
)

type queryValue struct {
Expand Down Expand Up @@ -262,13 +263,15 @@ func getCiaoEnvVariables() {
username := os.Getenv(ciaoUsernameEnv)
password := os.Getenv(ciaoPasswordEnv)
port := os.Getenv(ciaoComputePortEnv)
tenant := os.Getenv(ciaoTenantNameEnv)

infof("Ciao environment variables:\n")
infof("\t%s:%s\n", ciaoIdentityEnv, identity)
infof("\t%s:%s\n", ciaoControllerEnv, controller)
infof("\t%s:%s\n", ciaoUsernameEnv, username)
infof("\t%s:%s\n", ciaoPasswordEnv, password)
infof("\t%s:%s\n", ciaoComputePortEnv, port)
infof("\t%s:%s\n", ciaoTenantNameEnv, tenantName)

if identity != "" && *identityURL == "" {
*identityURL = identity
Expand All @@ -290,6 +293,9 @@ func getCiaoEnvVariables() {
*computePort, _ = strconv.Atoi(port)
}

if tenant != "" && *tenantName == "" {
*tenantName = tenant
}
}

func checkCompulsoryOptions() {
Expand Down

0 comments on commit c6dcd31

Please sign in to comment.