搜索admin_token_auth,从[pipeline:public_api],[pipeline:admin_api]和[pipeline:api_v3]中,把admin_token_auth去掉
例如:
pipeline= sizelimit url_normalize request_id build_auth_context token_auth admin_token_auth json_body ec2_extension user_crud_extension public_service
改为:
pipeline= sizelimit url_normalize request_id build_auth_context token_auth json_body ec2_extension user_crud_extension public_service
2)取消环境变量OS_TOKEN和OS_URL
unset OS_TOKEN OS_URL
3)然后再登陆admin和demo用户
openstack --os-auth-url :35357/v3 --os-project-domain-id default --os-user-domain-id default --os-project-name admin --os-username admin --os-auth-type password token issue
openstack --os-auth-url :5000/v3 --os-project-domain-id default --os-user-domain-id default --os-project-name demo --os-username demo --os-auth-type password token issue
4)创建两个openstack客户端脚本
vim admin-openrc.sh //内容
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=3qiVpzU2x
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
执行脚本
source admin-openrc.sh
申请认证令牌
openstack token issue
vim demo-openrc.sh //内容
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=demo
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=9TtbgaA1q
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
执行脚本
source demo-openrc.sh
申请认证令牌
openstack token issue
4.7、增加image
1、前期准备
image又叫做glance,是用来管理镜像的一个组件,我们用镜像来安装操作系统。glance支持让用户自己管理自定义镜像。
1)创建glance库和用户
mysql -uroot -ptn1Pi6Ytm
>CREATE database glance;
>GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'Zznky4tP0';
>GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'Zznky4tP0';
2)执行 admin-openrc.sh 脚本
source admin-openrc.sh
3)创建glance用户(密码为hf8LX9bow)
openstack user create --domain default --password-prompt glance
4)把admin角色添加到glance用户和service租户
openstack role add --project service --user glance admin
5)创建glance服务实体
openstack service create --name glance --description "OpenStack Image service" image
6)创建image服务api 端点
openstack endpoint create --region RegionOne image public :9292
openstack endpoint create --region RegionOne image internal :9292
openstack endpoint create --region RegionOne image admin :9292
2、安装和配置
1)安装包
yum install -y openstack-glance python-glance python-glanceclient
2)编辑配置文件
vim /etc/glance/glance-api.conf //更改或增加
[database]
connection= mysql://glance:Zznky4tP0@controller/glance
[keystone_authtoken]
auth_uri= :5000
auth_url= :35357
auth_plugin= password
project_domain_id= default
user_domain_id= default
project_name= service
username= glance
password= hf8LX9bow
[paste_deploy]
flavor= keystone
[glance_store]
default_store= file
filesystem_store_datadir= /var/lib/glance/images/
[DEFAULT]
notificaction_driver= noop
verbose=True
vim /etc/glance/glance-registry.conf //更改或增加
[DEFAULT]
notificaction_driver= noop
verbose=True
[database]
connection= mysql://glance:Zznky4tP0@controller/glance
[keystone_authtoken]
auth_uri= :5000
auth_url= :35357
auth_plugin= password
project_domain_id= default
user_domain_id= default
project_name= service
username= glance
password= hf8LX9bow
[paste_deploy]
flavor= keystone
3)同步glance数据库数据
su -s /bin/sh -c "glance-manage db_sync" glance
4)启动服务
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
3、验证操作
1)添加环境变量
echo"export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
2)执行admin-openrc.sh
source admin-openrc.sh
3)下载镜像
wget
4)把刚刚下载的镜像上传到镜像服务中心
glance image-create --name "cirros" \
--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--visibility public --progress
然后我们可以在 /var/lib/glance/images/目录下看到一个文件,这个就是刚刚上传的镜像,你会发现这个文件的名字和id是一致的。使用命令:
glance image-list //可以查看镜像列表