[OpenStack] 终端登陆 用户切换

来源:互联网 发布:业绩考核软件 编辑:程序博客网 时间:2024/05/16 05:20

用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 clickAccess & Security.

  2. On the API Access tab, click Download OpenStack RC File and save the file. The filename will be of the formPROJECT-openrc.sh wherePROJECT 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 aglance 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 thePROJECT-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:

    Select Text
    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 atcontroller.

  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 theadmin-openrc.sh file for the admin project:

    $ source admin-openrc.sh
[Note]Note

You are not prompted for the password with this method. The password lives in clear text format in thePROJECT-openrc.sh file. Restrict the permissions on this file to avoid security problems. You can also remove theOS_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 thehelp output of the various client commands. For example, you can override theOS_PASSWORD setting in the PROJECT-openrc.sh file by specifying a password on akeystone command, as follows:

$ keystone --os-password PASSWORD service-list

Where PASSWORD is your password.


0 0
原创粉丝点击