OpenShift rhc setup using multiple accounts
Asked Answered
N

7

94

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.

Nevski answered 16/4, 2013 at 20:3 Comment(0)
C
181

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.

Countdown answered 16/4, 2013 at 21:37 Comment(2)
when you say <login>, what exactly does it mean??... username?? OR password??... I think it would be nicer to clearly let us know that you mean <openshift-username>Gadwall
But then how do you switch accounts? I can't find anything in the rhc help that indicates how to login once logged-outHedi
A
12

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

Attempt answered 17/4, 2013 at 16:48 Comment(0)
P
7

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.

Practise answered 24/10, 2015 at 12:39 Comment(0)
V
2

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

Vibraphone answered 24/3, 2016 at 18:28 Comment(0)
M
1

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

rhc setup -l [email protected]
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.

Mandiemandingo answered 25/6, 2016 at 11:34 Comment(0)
B
1

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
Blakeley answered 1/9, 2016 at 11:39 Comment(0)
H
1

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

Hertzfeld answered 6/10, 2016 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.