Pergunta

I have two accounts on Openshift platform. How can I setup my computer so that I can manage both of them with rhc? I cannot find any relevant option in the command line arguments.

Foi útil?

Solução

The rhc command-line tools come with the global option -l, --rhlogin LOGIN. You have two options:

  1. Use the -l flag with every command to specify the login name:

    rhc app create <appname> <cartridge> [-l <login1/login2>]
    
  2. Run rhc setup -l LOGIN between the sessions. Once done managing apps from one account you can end the session for it by running rhc account logout.

    rhc setup -l <login1> # First account's login
    rhc app create <appname> <cartridge>
    rhc logout
    rhc setup -l <login2> # Second account's login
    rhc app create <appname> <cartridge>
    rhc logout
    

When you can rhc setup command, the username information gets stored in .openshift/express.conf file; hence the need to run it again when you want to switch the account.

Outras dicas

The command line also supports --conf - where you pass a file. You can always alias the command via a shell script.

Quite old question, but I use yet another solution which seems to be more comfortable (at least for me) - the environment variable OPENSHIFT_CONFIG.

The OPENSHIFT_CONFIG environment variable can be used to override the OpenShift configuration name (by default "express"). When set the operations performed with rhc refers to ~/.openshift/${OPENSHIFT_CONFIG}.conf (instead of ~/.openshift/express.conf).

To switch to the another OpenShift account the following could be used (Bash):

export OPENSHIFT_CONFIG=thenewone 
rhc apps    //apps on the new account

...
unset OPENSHIFT_CONFIG
rhc apps    //apps on the default account

Verified with rhc 1.37.1, but should work with any version released after May 2013.

When you run the rhc setup command for the first time, the ~/.openshift/express.conf file is created, containing the settings for your initial server configuration. When you add another server, or run the rhc setup command again with the --server option, the ~/.openshift/servers.yml file is created, containing the settings for each server. You can edit this file to make any changes to the server configuration, and this takes precedence over the initial ~/.openshift/express.conf file.

rhc server use server.name.example.co
rhc server use Server_Nickname

More information here

Use rhc setup -l <login>. Here login is your registered OpenShift account's email address.

On Windows, run these commands like and respond I did (denoted by < and >):

rhc setup -l login@domain.mail.com
Enter the server hostname: <openshift.redhat.com>
Password: <**********><Press Enter>
Generate a token now? (yes|no) y<Press Enter>
Generating an authorization token for this client ... lasts about 1 month
Saving configuration to C:\Users\UserName\.openshift\express.conf ... done

Your private SSH key file should be set as readable only to yourself. To make this change, run:

chmod 600 C:\Users\<Your Username>\.ssh\id_rsa

Your client tools are now configured.

Then you can use console commands for a long time with generated token for your OpenShift login.

You can configure multiple accounts using the server add command and then you can provide the server nickname in all subsequent commands using --server option. For example:

rhc server add -l <first_account> --nickname srv1 <first-server>
rhc server add -l <second_account> --nickname srv2 <second-server>

You may add options like -p, --use-authorized-tokens to suppress the prompts for password and token-generation. Also --insecured if required

rhc server use srv1
rhc server use srv2

Commands above perform some sort of initialization. Once two steps above are done you are ready to use your multiple accounts.

Now in your rhc commands you need to specify which server should be used. For example:

rhc app-show -n <domain> <app> --server srv1

Command above will show details of app in srv1. For srv2 you can run

rhc app-show -n <domain> <app> --server srv2
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top