刚刚开始尝试用脚本建立批量 用户 和项目,出现错误 “Missing parameter(s): Set a username with --os-username, OS_USERNAME, or auth.username Set an authen”
解决办法:
登录到 horizon 的web 界面
在 project -> compute->access&security 下 找到 API Access 下载 Download OpenStack RC File v3
将下载的文件的内容复制, 回到终端
创建 admin-openrc.sh 文件,粘贴进去刚刚复制的内容。
#创建文件并且 粘贴内容
cst@cstserver:~/Basic/openstack-data$ ls
admin-openrc.sh
# source 命令后 将提示输入 OpenStack的管理员密码
cst@cstserver:~/Basic/openstack-data$ source admin-openrc.sh
#提示输入管理员密码
Please enter your OpenStack Password for project admin as user admin:
#输入成功之后, 可以 查看信息
cst@cstserver:~/Basic/openstack-data$ echo $OS_USERNAME
admin
cst@cstserver:~/Basic/openstack-data$
先 source
source admin-openrc.sh
创建管理员租户、用户、角色
1 创建admin租户
openstack project create --description "Admin Project" admin
2 创建admin用户
openstack user create --password-prompt admin
# 输入密码和确认
User Password:
Repeat User Password:
3 创建admin角色
openstack role create admin
4 添加 admin 角色到 admin 租户和用户
openstack role add --project admin --user admin admin
创建一个service租户, 此服务用来管理nova,neuturn,glance等组件的服务
openstack project create --description "Service Project" service
创建非管理员 what 租户
1 创建what租户, 例如 密码是what 用户名也是 what
# usage: openstack project create --domain default --description "Demo Project" 项目名称
# 示例 创建 project -- what
openstack project create --domain default --description "Demo Project" what
2 创建 what 用户
openstack user create --domain default --password what what
3 创建 user 角色
openstack role create user
4 将what 用户 添加到 user 角色 和 what 租户
openstack role add --project what --user what user
注册keystone服务,虽然keystone本身是搞注册的,但是自己也需要注册服务
创建keystone认证
openstack service create --name keystone --description "OpenStack Identity" identity
分别创建三种类型的endpoint,分别为public:对外可见,internal内部使用,admin管理使用
openstack endpoint create --region RegionOne identity public http://controller:5000/v3/
openstack endpoint create --region RegionOne identity internal http://controller:5000/v3/
openstack endpoint create --region RegionOne identity admin http://controller:5000/v3/
常用命令
查看创建的用户
openstack user list
查看创建的项目
openstack project list
查看创建的用角色
openstack role list
查看创建的endpoint
openstack endpoint list
查看默认的计算配额
nova quota-defaults
+-----------------------------+-------+
| Quota | Limit |
+-----------------------------+-------+
| instances | 10 |
| cores | 20 |
| ram | 51200 |
| metadata_items | 128 |
| injected_files | 5 |
| injected_file_content_bytes | 10240 |
| injected_file_path_bytes | 255 |
| key_pairs | 100 |
| server_groups | 10 |
| server_group_members | 10 |
+-----------------------------+-------+
cst@cstserver:~/Basic/openstack-data$
更新默认 quota-defaults
# usage : nova quota-class-update default key value
# example
nova quota-class-update default --instances 1
nova quota-class-update default --ram 5120
nova quota-class-update default --cores 2
+-----------------------------+-------+
| Quota | Limit |
+-----------------------------+-------+
| instances | 1 |
| cores | 2 |
| ram | 5120 |
| metadata_items | 128 |
| injected_files | 5 |
| injected_file_content_bytes | 10240 |
| injected_file_path_bytes | 255 |
| key_pairs | 100 |
| server_groups | 10 |
| server_group_members | 10 |
+-----------------------------+-------+
cst@cstserver:~/Basic/openstack-data$
查看 Project -- what 的 quota
openstack quota show what
+----------------------+----------------------------------+
| Field | Value |
+----------------------+----------------------------------+
| cores | 2 |
| fixed-ips | -1 |
| floating-ips | 20 |
| injected-file-size | 10240 |
| injected-files | 5 |
| injected-path-size | 255 |
| instances | 1 |
| key-pairs | 100 |
| networks | 2 |
| ports | 5 |
| project | f74ac6c95ffa4ade907f609d559da13a |
| properties | 128 |
| ram | 5120 |
| rbac-policies | 10 |
| routers | 3 |
| secgroup-rules | 100 |
| secgroups | 10 |
| server-group-members | 10 |
| server-groups | 10 |
| subnetpools | -1 |
| subnets | 1 |
+----------------------+----------------------------------+
cst@cstserver:~/Basic/openstack-data$
更新指定 project 的 quota value
# example 更改 floating-ips 为 20
openstack quota set --floating-ips 20 f74ac6c95ffa4ade907f609d559da13a
# 查看更改结果
openstack quota show what
+----------------------+----------------------------------+
| Field | Value |
+----------------------+----------------------------------+
| cores | 2 |
| fixed-ips | -1 |
| floating-ips | 20 |
| injected-file-size | 10240 |
| injected-files | 5 |
| injected-path-size | 255 |
| instances | 1 |
| key-pairs | 100 |
| networks | 2 |
| ports | 5 |
| project | f74ac6c95ffa4ade907f609d559da13a |
| properties | 128 |
| ram | 5120 |
| rbac-policies | 10 |
| routers | 3 |
| secgroup-rules | 100 |
| secgroups | 10 |
| server-group-members | 10 |
| server-groups | 10 |
| subnetpools | -1 |
| subnets | 1 |
+----------------------+----------------------------------+