1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IBM Cloud: ibmcloudコマンドのセッションを複数同時に利用する方法

1
Posted at

1. はじめに

ある環境でibmcloudコマンドを実施する際に、

  • ある画面でibmcloudコマンドを実行して東京リージョンのつつ、別の画面でibmcloudコマンドを実行して大阪リージョンにアクセスする
  • ある画面でibmcloudコマンドを実行してアカウント1にアクセスしつつ、別の画面でibmcloudコマンドを実行してアカウント2にアクセスする

とかいうのはそのままではできず、セッション情報が共有されていることがわかる。これを回避する方法の紹介。

2. 方法

IBMCLOUD_HOMEという環境変数を明示的に指定する。

例えば、Terminal1とTerminal2がある時、

Terminal1
$ export IBMCLOUD_HOME=~/.bluemix_xxxxxxx
$ ibmcloud login --apikey @ibmcloud_apikey_xxxxxxx -r jp-tok
Terminal2
$ export IBMCLOUD_HOME=~/.bluemix_yyyyyyy
$ ibmcloud login --apikey @ibmcloud_apikey_yyyyyyy -r us-south

としてやれば同一環境上であろうとセッションやプラグイン情報は分離される。

3. 解説

ibmcloudコマンドはデフォルトでホームディレクトリに.bluemixというディレクトリを作成しており、そこでセッション情報やプラグイン情報を管理している。これを1つの環境で共有しているために、ターミナルなどが変わってもセッションが分離されない。
この管理情報の保管場所を明示的に指定するのがIBMCLOUD_HOMEという環境変数である。これを切り替えることで、セッションもプラグインも全て独立で管理される。

$ ls -l ~/.bluemix
total 16
-rw-------.  1 root root 4431 Oct  7 06:16 config.json
drwx------. 11 root root 4096 Sep 13 09:50 plugins
drwx------.  3 root root 4096 Sep 27 20:36 tmp
$ ls -l ~/.bluemix/plugins/
total 1964
drwx------. 2 root root    4096 May 20 09:20 cloud-functions
drwx------. 2 root root    4096 Jul 22 22:15 cloud-internet-services
drwx------. 2 root root    4096 Jul 26 09:37 cloud-object-storage
-rw-------. 1 root root 1972059 Oct  7 06:16 config.json
drwx------. 2 root root    4096 Sep 23 21:16 container-registry
drwx------. 3 root root    4096 Aug 25 14:03 container-service
drwx------. 2 root root    4096 Oct  5 15:36 power-iaas
drwx------. 2 root root    4096 Sep 13 09:50 tke
drwx------. 2 root root    4096 Sep 27 20:36 vpc-infrastructure
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?