OpenStack 简单脚本命令操作

刚刚开始尝试用脚本建立批量 用户 和项目,出现错误 “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

 

API Access.png

将下载的文件的内容复制, 回到终端
创建 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                                |
+----------------------+----------------------------------+

如果觉得我的文章对你有帮助,请随意打赏。您的支持将鼓励我继续创



作者:2010jing
链接:https://www.jianshu.com/p/fa06810d1d8f
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值