[OpenStack] 终端登陆 用户切换

用Crowbar安装OpenStack,operating systeme: SLES 11SP3.


由于之前安装cisco插件出现的BUG (bug 问题以后再写),在终端登陆时,有的时候需要用不同的身份(role)来进行测试.

方法一 还没有验证

1.  用所需用户名登陆到openstack 的dashboard, 在相应project下面,点击进入access&security

2.  在API Access的标签栏里面,点击 Download OpenStack RC File。文件名字的格式为 PROJECT-openrc.sh, 其中PROJECT是下载文件所属的项目名字

3. 复制该文件到需要运行openstack命令的电脑上

4. source demo-openrc.sh


方法二 验证成功

个人喜欢这个方法,简单粗暴

直接建立一个文件,叫什么名字随便,方便自己记住就可以了。名字.sh


export OS_AUTH_URL=https://identityHost:portNumber/v2.0
export OS_TENANT_ID=demo
export OS_TENANT_NAME="demo"
export OS_USERNAME="demo"
export OS_PASSWORD="demo"

保存,直接运行文件就好了。

也可以要求每次操作都输入密码:

export OS_AUTH_URL=https://identityHost:portNumber/v2.0
export OS_TENANT_ID=demo
export OS_TENANT_NAME="demo"
export OS_USERNAME="demo"echo "Please enter your OpenStack Password: "
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT


$ keystone --os-password PASSWORD service-list
该命令用来修改替代文件中的密码 (即时一次性的)



附上官方文档

 Download and source the OpenStack RC file

  1. Log in to the OpenStack dashboard, choose the project for which you want to download the OpenStack RC file, and click Access & Security.

  2. On the API Access tab, click Download OpenStack RC File and save the file. The filename will be of the form PROJECT-openrc.sh where PROJECT is the name of the project for which you downloaded the file.

  3. Copy the PROJECT-openrc.sh file to the computer from which you want to run OpenStack commands.

    For example, copy the file to the computer from which you want to upload an image with a glance client command.

  4. On any shell from which you want to run OpenStack commands, source the PROJECT-openrc.sh file for the respective project.

    In the following example, the demo-openrc.sh file is sourced for the demo project:

    $ source demo-openrc.sh
  5. When you are prompted for an OpenStack password, enter the password for the user who downloaded the PROJECT-openrc.sh file.

 Create and source the OpenStack RC file

Alternatively, you can create the PROJECT-openrc.sh file from scratch, if for some reason you cannot download the file from the dashboard.

  1. In a text editor, create a file named PROJECT-openrc.sh file and add the following authentication information:

    1
    2
    3
    4
    5
    6
    7
    export OS_USERNAME=username
    export OS_PASSWORD=password
    export OS_TENANT_NAME=projectName
    export OS_AUTH_URL=https: //identityHost :portNumber /v2 .0
    # The following lines can be omitted
    export OS_TENANT_ID=tenantIDString
    export OS_REGION_NAME=regionName

    The following example shows the information for a project called admin, where the OS username is also admin, and the identity host is located at controller.

  2. On any shell from which you want to run OpenStack commands, source the PROJECT-openrc.sh file for the respective project. In this example, you source the admin-openrc.sh file for the admin project:

    $ source admin-openrc.sh
Note

You are not prompted for the password with this method. The password lives in clear text format in the PROJECT-openrc.sh file. Restrict the permissions on this file to avoid security problems. You can also remove the OS_PASSWORD variable from the file, and use the --password parameter with OpenStack client commands instead.

 Override environment variable values

When you run OpenStack client commands, you can override some environment variable settings by using the options that are listed at the end of the help output of the various client commands. For example, you can override the OS_PASSWORD setting in the PROJECT-openrc.sh file by specifying a password on a keystone command, as follows:

$ keystone --os-password PASSWORD service-list

Where PASSWORD is your password.


你可能感兴趣的:(OpenStack)