当前位置:   article > 正文

OpenStack Yoga版安装笔记(六)glance练习

OpenStack Yoga版安装笔记(六)glance练习

1、glance架构

Glance api处理来自用户端(OpenStackClient等)的请求,如果是读写镜像元数据,则对glance db进行读写操作,因为镜像元数据都保存在glance db里面;如果是存取镜像本身,则对后端存储进行操作,因为镜像保存在后端存储里。同时,用户端、glance servcie都需要到keystone进行身份认证。

需要注意的是,验证后的授权不在keystone这里处理,而是交给被访问的service处理。比如user访问glance service,具体能读写哪些镜像以及镜像元数据,根据该user的role,由glance service进行授权。

2、glance安装过程

首先,在controller node上的MariaDB中创建glance DB,用于存储镜像的元数据;然后,通过OpenStackClient操作之前创建的keystone DB,创建glance user(即“glance” image service的身份凭证),创建命名为glance的image service,并设置Image service api endpoint;最后,安装glance API软件包,并编辑配置文件,配置必要的连接信息,如glance DB(存储镜像元数据)、keystone的认证信息以及后端存储(存储镜像)等。

在本次安装中,glance数据库、keystone数据库、keystone以及glance都部署在控制节点上。实际上,根据需求,这些组件可以分别安装在不同的服务器上。

3、glance练习1

3.1 keystone DB

  1. root@controller:~# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is 35
  4. Server version: 10.6.18-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04
  5. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  6. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  7. MariaDB [(none)]> SHOW DATABASES;
  8. +--------------------+
  9. | Database |
  10. +--------------------+
  11. | glance |
  12. | information_schema |
  13. | keystone |
  14. | mysql |
  15. | performance_schema |
  16. | sys |
  17. +--------------------+
  18. 6 rows in set (0.002 sec)
  19. MariaDB [(none)]> USE keystone;
  20. Reading table information for completion of table and column names
  21. You can turn off this feature to get a quicker startup with -A
  22. Database changed
  23. MariaDB [keystone]> SHOW TABLES;
  24. (略)
  25. MariaDB [keystone]> select * from local_user;
  26. +----+----------------------------------+----------------------------------+-----------+-------------------+----------------+
  27. | id | user_id | domain_id | name | failed_auth_count | failed_auth_at |
  28. +----+----------------------------------+----------------------------------+-----------+-------------------+----------------+
  29. | 1 | 2947c213547147979dce3c8f8b85697f | default | admin | 0 | NULL |
  30. | 2 | 9382b59561c04dd1abf0a4cb7a8252ec | default | myuser | 0 | NULL |
  31. | 4 | 981d061282aa43afba72df6ff637f41c | f2a209f9e83040c9a619ca05c41e952b | testuser1 | 0 | NULL |
  32. | 5 | b7849907a23b4604a3e3940f4034326b | default | glance | 0 | NULL |
  33. +----+----------------------------------+----------------------------------+-----------+-------------------+----------------+
  34. 4 rows in set (0.000 sec)
  35. MariaDB [keystone]> SELECT * FROM service;
  36. +----------------------------------+----------+---------+------------------------------------------------------+
  37. | id | type | enabled | extra |
  38. +----------------------------------+----------+---------+------------------------------------------------------+
  39. | 75fe01049ec648b69e48d200971bf601 | identity | 1 | {"name": "keystone"} |
  40. | d6a3dadf92e542289c5ebd37e3553cdd | image | 1 | {"name": "glance", "description": "OpenStack Image"} |
  41. +----------------------------------+----------+---------+------------------------------------------------------+
  42. 2 rows in set (0.000 sec)
  43. MariaDB [keystone]> SELECT * from endpoint;
  44. +----------------------------------+--------------------+-----------+----------------------------------+----------------------------+-------+---------+-----------+
  45. | id | legacy_endpoint_id | interface | service_id | url | extra | enabled | region_id |
  46. +----------------------------------+--------------------+-----------+----------------------------------+----------------------------+-------+---------+-----------+
  47. | 56d1454571064cb3ad3c749d18fb57e6 | NULL | admin | d6a3dadf92e542289c5ebd37e3553cdd | http://controller:9292 | {} | 1 | RegionOne |
  48. | a82bd043e133464fa863fba98b400460 | NULL | admin | 75fe01049ec648b69e48d200971bf601 | http://controller:5000/v3/ | {} | 1 | RegionOne |
  49. | ac109817862344c4854b783d642be412 | NULL | internal | 75fe01049ec648b69e48d200971bf601 | http://controller:5000/v3/ | {} | 1 | RegionOne |
  50. | ae98462c8f4346f3991d693232a108d3 | NULL | internal | d6a3dadf92e542289c5ebd37e3553cdd | http://controller:9292 | {} | 1 | RegionOne |
  51. | e047382ce61740bf9dc4219c97eff2f8 | NULL | public | d6a3dadf92e542289c5ebd37e3553cdd | http://controller:9292 | {} | 1 | RegionOne |
  52. | eaf4ddaab1b74aa59403f9fbf5fc4ac1 | NULL | public | 75fe01049ec648b69e48d200971bf601 | http://controller:5000/v3/ | {} | 1 | RegionOne |
  53. +----------------------------------+--------------------+-----------+----------------------------------+----------------------------+-------+---------+-----------+
  54. 6 rows in set (0.000 sec)
  55. MariaDB [keystone]>

3.2 glance DB

  1. MariaDB [(none)]> use glance;
  2. Reading table information for completion of table and column names
  3. You can turn off this feature to get a quicker startup with -A
  4. Database changed
  5. MariaDB [glance]> show tables;
  6. +----------------------------------+
  7. | Tables_in_glance |
  8. +----------------------------------+
  9. | alembic_version |
  10. | image_locations |
  11. | image_members |
  12. | image_properties |
  13. | image_tags |
  14. | images |
  15. | metadef_namespace_resource_types |
  16. | metadef_namespaces |
  17. | metadef_objects |
  18. | metadef_properties |
  19. | metadef_resource_types |
  20. | metadef_tags |
  21. | task_info |
  22. | tasks |
  23. +----------------------------------+
  24. 14 rows in set (0.000 sec)
  25. MariaDB [glance]> select * from images;
  26. +--------------------------------------+--------+----------+--------+---------------------+---------------------+------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+------------+-----------+--------------+----------------------------------------------------------------------------------------------------------------------------------+
  27. | id | name | size | status | created_at | updated_at | deleted_at | deleted | disk_format | container_format | checksum | owner | min_disk | min_ram | protected | virtual_size | visibility | os_hidden | os_hash_algo | os_hash_value |
  28. +--------------------------------------+--------+----------+--------+---------------------+---------------------+------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+------------+-----------+--------------+----------------------------------------------------------------------------------------------------------------------------------+
  29. | 429decdd-9230-49c0-b735-70364c226eb5 | cirros | 12716032 | active | 2024-07-06 13:54:01 | 2024-07-06 13:54:02 | NULL | 0 | qcow2 | bare | 443b7623e27ecf03dc9e01ee93f67afe | ee65b6c3961747b988ab8bd1cc19fb93 | 0 | 0 | 0 | 46137344 | public | 0 | sha512 | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78 |
  30. +--------------------------------------+--------+----------+--------+---------------------+---------------------+------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+------------+-----------+--------------+----------------------------------------------------------------------------------------------------------------------------------+
  31. 1 row in set (0.000 sec)
  32. MariaDB [glance]> select * from image_properties;
  33. Empty set (0.000 sec)
  34. MariaDB [glance]>

3.3 后端存储

本次安装为了简化操作,将镜像上传并存储在托管镜像服务的控制节点上的一个目录中。默认情况下,这个目录是/var/lib/glance/images/

检查该目录:

  1. root@controller:~# ls -l /var/lib/glance/images/
  2. total 12420
  3. -rw-r----- 1 glance glance 12716032 Jul 6 13:54 429decdd-9230-49c0-b735-70364c226eb5
  4. root@controller:~#
  5. 文件名和glance DB的select * from images;中的id一致。

3.4 OpenStackClient操作(用户端操作)

用户端可以通过访问glance api,完成对后端存储、glance DB、keystoneDB的信息进行操作。

  1. ------keystone DB:
  2. ubcode@osclient ~(admin/amdin)$ openstack user list
  3. +----------------------------------+-----------+
  4. | ID | Name |
  5. +----------------------------------+-----------+
  6. | 2947c213547147979dce3c8f8b85697f | admin |
  7. | 9382b59561c04dd1abf0a4cb7a8252ec | myuser |
  8. | 981d061282aa43afba72df6ff637f41c | testuser1 |
  9. | b7849907a23b4604a3e3940f4034326b | glance |
  10. +----------------------------------+-----------+
  11. ubcode@osclient ~(admin/amdin)$ openstack service list
  12. +----------------------------------+----------+----------+
  13. | ID | Name | Type |
  14. +----------------------------------+----------+----------+
  15. | 75fe01049ec648b69e48d200971bf601 | keystone | identity |
  16. | d6a3dadf92e542289c5ebd37e3553cdd | glance | image |
  17. +----------------------------------+----------+----------+
  18. ubcode@osclient ~(admin/amdin)$ openstack endpoint list
  19. +----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+
  20. | ID | Region | Service Name | Service Type | Enabled | Interface | URL |
  21. +----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+
  22. | 56d1454571064cb3ad3c749d18fb57e6 | RegionOne | glance | image | True | admin | http://controller:9292 |
  23. | a82bd043e133464fa863fba98b400460 | RegionOne | keystone | identity | True | admin | http://controller:5000/v3/ |
  24. | ac109817862344c4854b783d642be412 | RegionOne | keystone | identity | True | internal | http://controller:5000/v3/ |
  25. | ae98462c8f4346f3991d693232a108d3 | RegionOne | glance | image | True | internal | http://controller:9292 |
  26. | e047382ce61740bf9dc4219c97eff2f8 | RegionOne | glance | image | True | public | http://controller:9292 |
  27. | eaf4ddaab1b74aa59403f9fbf5fc4ac1 | RegionOne | keystone | identity | True | public | http://controller:5000/v3/ |
  28. +----------------------------------+-----------+--------------+--------------+---------+-----------+----------------------------+
  29. ubcode@osclient ~(admin/amdin)$
  30. ------glance DB:
  31. ubcode@osclient ~(admin/amdin)$ openstack image list
  32. +--------------------------------------+--------+--------+
  33. | ID | Name | Status |
  34. +--------------------------------------+--------+--------+
  35. | 429decdd-9230-49c0-b735-70364c226eb5 | cirros | active |
  36. +--------------------------------------+--------+--------+
  37. ubcode@osclient ~(admin/amdin)$ openstack image show cirros
  38. +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | Field | Value |
  40. +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | checksum | 443b7623e27ecf03dc9e01ee93f67afe |
  42. | container_format | bare |
  43. | created_at | 2024-07-06T13:54:01Z |
  44. | disk_format | qcow2 |
  45. | file | /v2/images/429decdd-9230-49c0-b735-70364c226eb5/file |
  46. | id | 429decdd-9230-49c0-b735-70364c226eb5 |
  47. | min_disk | 0 |
  48. | min_ram | 0 |
  49. | name | cirros |
  50. | owner | ee65b6c3961747b988ab8bd1cc19fb93 |
  51. | properties | os_hash_algo='sha512', os_hash_value='6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78', os_hidden='False' |
  52. | protected | False |
  53. | schema | /v2/schemas/image |
  54. | size | 12716032 |
  55. | status | active |
  56. | tags | |
  57. | updated_at | 2024-07-06T13:54:02Z |
  58. | virtual_size | 46137344 |
  59. | visibility | public |
  60. +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

4、glance练习2——glanc独立安装

为了方便查看OpenStack各组件之间的交互情况,将glance服务独立安装。

4.1 网络拓扑

4.2 新增一台虚机image1

根据之前的介绍,新增一台虚机(4G内存/2CPU,可根据实际情况调整),用于安装glance。虚机hostname设置为image1,配置ip地址为10.0.20.16/24。

该虚机信息如下:

  1. ------网络配置:
  2. ubcode@image1:~$ cat /etc/netplan/00-installer-config.yaml
  3. cat: /etc/netplan/00-installer-config.yaml: Permission denied
  4. ubcode@image1:~$ sudo cat /etc/netplan/00-installer-config.yaml
  5. [sudo] password for ubcode:
  6. # This is the network config written by 'subiquity'
  7. network:
  8. ethernets:
  9. ens32:
  10. addresses:
  11. - 10.0.20.16/24
  12. nameservers:
  13. addresses:
  14. - 10.0.20.2
  15. search: []
  16. routes:
  17. - to: default
  18. via: 10.0.20.2
  19. version: 2
  20. ------hosts文件:
  21. ubcode@image1:~$ cat /etc/hosts
  22. 127.0.0.1 localhost
  23. # 127.0.1.1 image1
  24. # The following lines are desirable for IPv6 capable hosts
  25. ::1 ip6-localhost ip6-loopback
  26. fe00::0 ip6-localnet
  27. ff00::0 ip6-mcastprefix
  28. ff02::1 ip6-allnodes
  29. ff02::2 ip6-allrouters
  30. 10.0.20.11 controller
  31. 10.0.20.12 compute1
  32. 10.0.20.16 image1
  33. ------NTP配置:
  34. ubcode@image1:~$ cat /etc/chrony/chrony.conf
  35. ...
  36. # pool ntp.ubuntu.com iburst maxsources 4
  37. # pool 0.ubuntu.pool.ntp.org iburst maxsources 1
  38. # pool 1.ubuntu.pool.ntp.org iburst maxsources 1
  39. # pool 2.ubuntu.pool.ntp.org iburst maxsources 2
  40. server controller iburst

controller(10.0.20.11)虚机和osclient(10.0.20.100)虚机hosts文件增加image1信息:

  1. root@controller:~# cat /etc/hosts
  2. 127.0.0.1 localhost
  3. # 127.0.1.1 os-1
  4. # The following lines are desirable for IPv6 capable hosts
  5. ::1 ip6-localhost ip6-loopback
  6. fe00::0 ip6-localnet
  7. ff00::0 ip6-mcastprefix
  8. ff02::1 ip6-allnodes
  9. ff02::2 ip6-allrouters
  10. 10.0.20.11 controller
  11. 10.0.20.12 compute1
  12. 10.0.20.16 image1 <---新增

4.3 controller node虚机恢复快照

快照转到“keyston安装完成”:

 (快照名称后来修改过)

4.4 Install and configure (Ubuntu)

4.4.1 controller node(hostname: controller)

1、创建glance DB

  1. root@controller:~# mysql
  2. Welcome to the MariaDB monitor. Commands end with ; or \g.
  3. Your MariaDB connection id is 31
  4. Server version: 10.6.18-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04
  5. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
  6. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  7. MariaDB [(none)]> show databases;
  8. +--------------------+
  9. | Database |
  10. +--------------------+
  11. | information_schema |
  12. | keystone |
  13. | mysql |
  14. | performance_schema |
  15. | sys |
  16. +--------------------+
  17. 5 rows in set (0.002 sec)
  18. MariaDB [(none)]> CREATE DATABASE glance;
  19. Query OK, 1 row affected (0.001 sec)
  20. MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
  21. -> IDENTIFIED BY 'openstack';
  22. Query OK, 0 rows affected (0.001 sec)
  23. MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
  24. -> IDENTIFIED BY 'openstack';
  25. Query OK, 0 rows affected (0.001 sec)
  26. MariaDB [(none)]>
  27. MariaDB [(none)]> quit
  28. Bye
  29. root@controller:~#

4.4.2 OpenStackClient(hostname: osclient)

在OpenStackClient(10.0.20.100),创建glance user、“glance” image service以及endpoint,注意endpoint指向了image node 1 (hostname: image1)。

  1. ubcode@osclient:~$ . admin-openrc
  2. ubcode@osclient ~(admin/amdin)$ openstack user create --domain default --password-prompt glance
  3. User Password:
  4. Repeat User Password:
  5. +---------------------+----------------------------------+
  6. | Field | Value |
  7. +---------------------+----------------------------------+
  8. | domain_id | default |
  9. | enabled | True |
  10. | id | 2eb252b5fc2743e995141d9529569e2d |
  11. | name | glance |
  12. | options | {} |
  13. | password_expires_at | None |
  14. +---------------------+----------------------------------+
  15. ubcode@osclient ~(admin/amdin)$ openstack role add --project service --user glance admin
  16. ubcode@osclient ~(admin/amdin)$ openstack service create --name glance \
  17. > --description "OpenStack Image" image
  18. +-------------+----------------------------------+
  19. | Field | Value |
  20. +-------------+----------------------------------+
  21. | description | OpenStack Image |
  22. | enabled | True |
  23. | id | f378aa833518466c9ce2c9ef85e82ace |
  24. | name | glance |
  25. | type | image |
  26. +-------------+----------------------------------+
  27. ubcode@osclient ~(admin/amdin)$ openstack endpoint create --region RegionOne \
  28. > image public http://image1:9292
  29. +--------------+----------------------------------+
  30. | Field | Value |
  31. +--------------+----------------------------------+
  32. | enabled | True |
  33. | id | c37250b6bd2d471f92427483d31fd5c7 |
  34. | interface | public |
  35. | region | RegionOne |
  36. | region_id | RegionOne |
  37. | service_id | f378aa833518466c9ce2c9ef85e82ace |
  38. | service_name | glance |
  39. | service_type | image |
  40. | url | http://image1:9292 |
  41. +--------------+----------------------------------+
  42. ubcode@osclient ~(admin/amdin)$ openstack endpoint create --region RegionOne \
  43. > image internal http://image1:9292
  44. +--------------+----------------------------------+
  45. | Field | Value |
  46. +--------------+----------------------------------+
  47. | enabled | True |
  48. | id | 7d17e6182d8640a7a6637f4f460a5c08 |
  49. | interface | internal |
  50. | region | RegionOne |
  51. | region_id | RegionOne |
  52. | service_id | f378aa833518466c9ce2c9ef85e82ace |
  53. | service_name | glance |
  54. | service_type | image |
  55. | url | http://image1:9292 |
  56. +--------------+----------------------------------+
  57. ubcode@osclient ~(admin/amdin)$ openstack endpoint create --region RegionOne \
  58. > image admin http://image1:9292
  59. +--------------+----------------------------------+
  60. | Field | Value |
  61. +--------------+----------------------------------+
  62. | enabled | True |
  63. | id | f210d94217e54d2781192170bdf26877 |
  64. | interface | admin |
  65. | region | RegionOne |
  66. | region_id | RegionOne |
  67. | service_id | f378aa833518466c9ce2c9ef85e82ace |
  68. | service_name | glance |
  69. | service_type | image |
  70. | url | http://image1:9292 |
  71. +--------------+----------------------------------+

4.4.3 image node 1(hostname: image1)

1、安装glance软件包

ubcode@image1:~$ apt install glance

2、配置glance-api.conf

  1. ubcode@image1:~$ sudo vi /etc/glance/glance-api.conf
  2. [database]
  3. # connection = sqlite:var/lib/glance/glance.sqlite
  4. connection = mysql+pymysql://glance:openstack@controller/glance
  5. backend = sqlalchemy
  6. [keystone_authtoken]
  7. www_authenticate_uri = http://controller:5000
  8. auth_url = http://controller:5000
  9. memcached_servers = controller:11211
  10. auth_type = password
  11. project_domain_name = Default
  12. user_domain_name = Default
  13. project_name = service
  14. username = glance
  15. password = openstack
  16. [paste_deploy]
  17. flavor = keystone
  18. [glance_store]
  19. stores = file,http
  20. default_store = file
  21. filesystem_store_datadir = /var/lib/glance/images/

3、初始化glance数据库,重启glance-api

  1. ubcode@image1:~$ sudo passwd root
  2. New password:
  3. Retype new password:
  4. passwd: password updated successfully
  5. ubcode@image1:~$ su
  6. Password:
  7. root@image1:/home/ubcode# su -s /bin/sh -c "glance-manage db_sync" glance
  8. 2024-07-07 08:18:13.472 6118 INFO alembic.runtime.migration [-] Context impl MySQLImpl.
  9. 2024-07-07 08:18:13.472 6118 INFO alembic.runtime.migration [-] Will assume non-transactional DDL.
  10. 2024-07-07 08:18:13.482 6118 INFO alembic.runtime.migration [-] Context impl MySQLImpl.
  11. 2024-07-07 08:18:13.482 6118 INFO alembic.runtime.migration [-] Will assume non-transactional DDL.
  12. INFO [alembic.runtime.migration] Context impl MySQLImpl.
  13. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
  14. INFO [alembic.runtime.migration] Running upgrade -> liberty, liberty initial
  15. INFO [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of 'images' table
  16. INFO [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server
  17. INFO [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_expand01, add visibility to images
  18. INFO [alembic.runtime.migration] Running upgrade ocata_expand01 -> pike_expand01, empty expand for symmetry with pike_contract01
  19. INFO [alembic.runtime.migration] Running upgrade pike_expand01 -> queens_expand01
  20. INFO [alembic.runtime.migration] Running upgrade queens_expand01 -> rocky_expand01, add os_hidden column to images table
  21. INFO [alembic.runtime.migration] Running upgrade rocky_expand01 -> rocky_expand02, add os_hash_algo and os_hash_value columns to images table
  22. INFO [alembic.runtime.migration] Running upgrade rocky_expand02 -> train_expand01, empty expand for symmetry with train_contract01
  23. INFO [alembic.runtime.migration] Running upgrade train_expand01 -> ussuri_expand01, empty expand for symmetry with ussuri_expand01
  24. INFO [alembic.runtime.migration] Running upgrade ussuri_expand01 -> wallaby_expand01, add image_id, request_id, user columns to tasks table"
  25. INFO [alembic.runtime.migration] Context impl MySQLImpl.
  26. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
  27. Upgraded database to: wallaby_expand01, current revision(s): wallaby_expand01
  28. INFO [alembic.runtime.migration] Context impl MySQLImpl.
  29. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
  30. INFO [alembic.runtime.migration] Context impl MySQLImpl.
  31. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
  32. Database migration is up to date. No migration needed.
  33. INFO [alembic.runtime.migration] Context impl MySQLImpl.
  34. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
  35. INFO [alembic.runtime.migration] Context impl MySQLImpl.
  36. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
  37. INFO [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_contract01, remove is_public from images
  38. INFO [alembic.runtime.migration] Running upgrade ocata_contract01 -> pike_contract01, drop glare artifacts tables
  39. INFO [alembic.runtime.migration] Running upgrade pike_contract01 -> queens_contract01
  40. INFO [alembic.runtime.migration] Running upgrade queens_contract01 -> rocky_contract01
  41. INFO [alembic.runtime.migration] Running upgrade rocky_contract01 -> rocky_contract02
  42. INFO [alembic.runtime.migration] Running upgrade rocky_contract02 -> train_contract01
  43. INFO [alembic.runtime.migration] Running upgrade train_contract01 -> ussuri_contract01
  44. INFO [alembic.runtime.migration] Running upgrade ussuri_contract01 -> wallaby_contract01
  45. INFO [alembic.runtime.migration] Context impl MySQLImpl.
  46. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
  47. Upgraded database to: wallaby_contract01, current revision(s): wallaby_contract01
  48. INFO [alembic.runtime.migration] Context impl MySQLImpl.
  49. INFO [alembic.runtime.migration] Will assume non-transactional DDL.
  50. Database is synced successfully.
  51. root@image1:/home/ubcode#
  52. root@image1:/home/ubcode# service glance-api restart
  53. ubcode@image1:~$ glance-manage --version
  54. 24.2.1

4.4.4 image node 1(Verify operation)

  1. ubcode@image1:~$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
  2. ubcode@image1:~$ sudo vi admin-openrc
  3. ubcode@image1:~$ cat admin-openrc
  4. export OS_PROJECT_DOMAIN_NAME=Default
  5. export OS_USER_DOMAIN_NAME=Default
  6. export OS_PROJECT_NAME=admin
  7. export OS_USERNAME=admin
  8. export OS_PASSWORD=openstack
  9. export OS_AUTH_URL=http://controller:5000/v3
  10. export OS_IDENTITY_API_VERSION=3
  11. export OS_IMAGE_API_VERSION=2
  12. export PS1='\u@\h \W(admin/amdin)\$ '
  13. ubcode@image1:~$
  14. ubcode@image1 ~(admin/amdin)$ ls
  15. admin-openrc cirros-0.4.0-x86_64-disk.img
  16. ubcode@image1 ~(admin/amdin)$ glance image-create --name "cirros" \
  17. > --file cirros-0.4.0-x86_64-disk.img \
  18. > --disk-format qcow2 --container-format bare \
  19. > --visibility=public
  20. +------------------+----------------------------------------------------------------------------------+
  21. | Property | Value |
  22. +------------------+----------------------------------------------------------------------------------+
  23. | checksum | 443b7623e27ecf03dc9e01ee93f67afe |
  24. | container_format | bare |
  25. | created_at | 2024-07-07T08:26:02Z |
  26. | disk_format | qcow2 |
  27. | id | 9f0e6328-3e96-41e1-b282-d577b6749a09 |
  28. | min_disk | 0 |
  29. | min_ram | 0 |
  30. | name | cirros |
  31. | os_hash_algo | sha512 |
  32. | os_hash_value | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e |
  33. | | 2161b5b5186106570c17a9e58b64dd39390617cd5a350f78 |
  34. | os_hidden | False |
  35. | owner | ee65b6c3961747b988ab8bd1cc19fb93 |
  36. | protected | False |
  37. | size | 12716032 |
  38. | status | active |
  39. | tags | [] |
  40. | updated_at | 2024-07-07T08:26:02Z |
  41. | virtual_size | 46137344 |
  42. | visibility | public |
  43. +------------------+----------------------------------------------------------------------------------+
  44. ubcode@image1 ~(admin/amdin)$ glance image-list
  45. +--------------------------------------+--------+
  46. | ID | Name |
  47. +--------------------------------------+--------+
  48. | 9f0e6328-3e96-41e1-b282-d577b6749a09 | cirros |
  49. +--------------------------------------+--------+
  50. ubcode@image1 ~(admin/amdin)$ openstack image list
  51. +--------------------------------------+--------+--------+
  52. | ID | Name | Status |
  53. +--------------------------------------+--------+--------+
  54. | 9f0e6328-3e96-41e1-b282-d577b6749a09 | cirros | active |
  55. +--------------------------------------+--------+--------+
  56. root@image1:/var/lib/glance/images# ls
  57. 9f0e6328-3e96-41e1-b282-d577b6749a09

4.5 Wireshark抓包

4.5.1 抓包目的

查看OpenStack各组件之间的交互情况。

4.5.2 抓包方式

1、在win11上运行wireshark,抓取VMware Network Adapter VMnet8的流量:

 2、在osclient上,执行:openstack image list

  1. ubcode@osclient:~$ . admin-openrc
  2. ubcode@osclient ~(admin/amdin)$ openstack image list
  3. +--------------------------------------+--------+--------+
  4. | ID | Name | Status |
  5. +--------------------------------------+--------+--------+
  6. | 9f0e6328-3e96-41e1-b282-d577b6749a09 | cirros | active |
  7. +--------------------------------------+--------+--------+
  8. ubcode@osclient ~(admin/amdin)$

3、停止抓包,进行分析

4.6 Wireshark抓包分析

4.6.1 抓包结果

过滤无关数据包,filter: http or tcp.port -- 11211 or tcp.port ==3306

抓包显示了OpenStackClient、keystone、glance、glance DB之间的交互情况。

  • OpenStackClient --> keystone,认证user admin身份,取得user admin的token。
  • OpenStackClient --> glance,请求image list
  • glance --> MEMCACHE,验证user admin的token
  • glance --> keystone,认证uer glance身份,取得user glance的token
  • glance --> MEMCACHE,存储admin token
  • glance --> Marria DB,MySQL/login,查询glance DB,取得image元数据
  • glance --> OpenStackClient,返回查询结果

4.6.2 抓包的流量图

 4.6.3 典型数据包

1/ user admin认证

OpenStackClient--->keystone,认证admin user scope to project admin:

  1. Frame 262: 284 bytes on wire (2272 bits), 284 bytes captured (2272 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: VMware_ff:20:81 (00:0c:29:ff:20:81), Dst: controller (00:0c:29:a8:e0:3c)
  3. Internet Protocol Version 4, Src: 10.0.20.100 (10.0.20.100), Dst: controller (10.0.20.11)
  4. Transmission Control Protocol, Src Port: 57938, Dst Port: 5000, Seq: 501, Ack: 534, Len: 218
  5. [2 Reassembled TCP Segments (501 bytes): #261(283), #262(218)]
  6. Hypertext Transfer Protocol
  7. POST /v3/auth/tokens HTTP/1.1\r\n
  8. Host: controller:5000\r\n
  9. User-Agent: openstacksdk/0.61.0 keystoneauth1/4.4.0 python-requests/2.25.1 CPython/3.10.12\r\n
  10. Accept-Encoding: gzip, deflate\r\n
  11. Accept: application/json\r\n
  12. Connection: keep-alive\r\n
  13. Content-Type: application/json\r\n
  14. Content-Length: 218\r\n
  15. \r\n
  16. [Full request URI: http://controller:5000/v3/auth/tokens]
  17. [HTTP request 2/2]
  18. [Prev request in frame: 257]
  19. [Response in frame: 266]
  20. File Data: 218 bytes
  21. JavaScript Object Notation: application/json
  22. JSON raw form:
  23. {
  24. "auth": {
  25. "identity": {
  26. "methods": [
  27. "password"
  28. ],
  29. "password": {
  30. "user": {
  31. "password": "openstack",
  32. "name": "admin",
  33. "domain": {
  34. "name": "Default"
  35. }
  36. }
  37. }
  38. },
  39. "scope": {
  40. "project": {
  41. "name": "admin",
  42. "domain": {
  43. "name": "Default"
  44. }
  45. }
  46. }
  47. }
  48. }
  49. Object

认证成功,取得token(X-Subject-Token)

  1. Frame 266: 858 bytes on wire (6864 bits), 858 bytes captured (6864 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: controller (00:0c:29:a8:e0:3c), Dst: VMware_ff:20:81 (00:0c:29:ff:20:81)
  3. Internet Protocol Version 4, Src: controller (10.0.20.11), Dst: 10.0.20.100 (10.0.20.100)
  4. Transmission Control Protocol, Src Port: 5000, Dst Port: 57938, Seq: 1982, Ack: 719, Len: 792
  5. [2 Reassembled TCP Segments (2240 bytes): #265(1448), #266(792)]
  6. Hypertext Transfer Protocol
  7. HTTP/1.1 201 CREATED\r\n
  8. Date: Thu, 11 Jul 2024 21:58:26 GMT\r\n
  9. Server: Apache/2.4.52 (Ubuntu)\r\n
  10. Content-Length: 1750\r\n
  11. X-Subject-Token: gAAAAABmkFWFJBbsCv5MsBqeIGj9Fc426FeFSZTyQsjlgM4lC6I6crQcE3x-ygbUSoDUoMzjTh06W5STx4YChIbkhHCe_5OuuKOx8ZAp1pxs9M_yMLD6PtuYK7TDPwlPNfjdHOKWNvrA6BHc3Xg-mjdvnsi_Z2tKdw_A3AQUYN3uAub3zaxK418\r\n
  12. Vary: X-Auth-Token\r\n
  13. x-openstack-request-id: req-d1c97182-1225-48de-a8cd-b657907a6d50\r\n
  14. Keep-Alive: timeout=5, max=99\r\n
  15. Connection: Keep-Alive\r\n
  16. Content-Type: application/json\r\n
  17. \r\n
  18. [HTTP response 2/2]
  19. [Time since request: 3.077388000 seconds]
  20. [Prev request in frame: 257]
  21. [Prev response in frame: 259]
  22. [Request in frame: 262]
  23. [Request URI: http://controller:5000/v3/auth/tokens]
  24. File Data: 1750 bytes
  25. JavaScript Object Notation: application/json
  26. JSON raw form:
  27. {
  28. "token": {
  29. "methods": [
  30. "password"
  31. ],
  32. "user": {
  33. "domain": {
  34. "id": "default",
  35. "name": "Default"
  36. },
  37. "id": "2947c213547147979dce3c8f8b85697f",
  38. "name": "admin",
  39. "password_expires_at": null
  40. },
  41. "audit_ids": [
  42. "-gVm2yInSBWpjE6RI9Q78A"
  43. ],
  44. "expires_at": "2024-07-11T22:58:29.000000Z",
  45. "issued_at": "2024-07-11T21:58:29.000000Z",
  46. "project": {
  47. "domain": {
  48. "id": "default",
  49. "name": "Default"
  50. },
  51. "id": "ee65b6c3961747b988ab8bd1cc19fb93",
  52. "name": "admin"
  53. },
  54. "is_domain": false,
  55. "roles": [
  56. {
  57. "id": "17552c9a365d4944a50fd8ac271791c6",
  58. "name": "member"
  59. },
  60. {
  61. "id": "e434c66b7af647158bcaa77686ca6e93",
  62. "name": "admin"
  63. },
  64. {
  65. "id": "be23525c20c44f05b3ba071455522fcb",
  66. "name": "reader"
  67. }
  68. ],
  69. "catalog": [
  70. {
  71. "endpoints": [
  72. {
  73. "id": "7d17e6182d8640a7a6637f4f460a5c08",
  74. "interface": "internal",
  75. "region_id": "RegionOne",
  76. "url": "http://image1:9292",
  77. "region": "RegionOne"
  78. },
  79. {
  80. "id": "c37250b6bd2d471f92427483d31fd5c7",
  81. "interface": "public",
  82. "region_id": "RegionOne",
  83. "url": "http://image1:9292",
  84. "region": "RegionOne"
  85. },
  86. {
  87. "id": "f210d94217e54d2781192170bdf26877",
  88. "interface": "admin",
  89. "region_id": "RegionOne",
  90. "url": "http://image1:9292",
  91. "region": "RegionOne"
  92. }
  93. ],
  94. "id": "f378aa833518466c9ce2c9ef85e82ace",
  95. "type": "image",
  96. "name": "glance"
  97. },
  98. {
  99. "endpoints": [
  100. {
  101. "id": "a82bd043e133464fa863fba98b400460",
  102. "interface": "admin",
  103. "region_id": "RegionOne",
  104. "url": "http://controller:5000/v3/",
  105. "region": "RegionOne"
  106. },
  107. {
  108. "id": "ac109817862344c4854b783d642be412",
  109. "interface": "internal",
  110. "region_id": "RegionOne",
  111. "url": "http://controller:5000/v3/",
  112. "region": "RegionOne"
  113. },
  114. {
  115. "id": "eaf4ddaab1b74aa59403f9fbf5fc4ac1",
  116. "interface": "public",
  117. "region_id": "RegionOne",
  118. "url": "http://controller:5000/v3/",
  119. "region": "RegionOne"
  120. }
  121. ],
  122. "id": "75fe01049ec648b69e48d200971bf601",
  123. "type": "identity",
  124. "name": "keystone"
  125. }
  126. ]
  127. }
  128. }
  129. Object
2/ 查询image list

OpenStackClient ---> glance,查询image list,注意携带了之前获得的token(X-Auth-Token):

  1. Frame 277: 485 bytes on wire (3880 bits), 485 bytes captured (3880 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: VMware_ff:20:81 (00:0c:29:ff:20:81), Dst: image1 (00:0c:29:cc:19:7d)
  3. Internet Protocol Version 4, Src: 10.0.20.100 (10.0.20.100), Dst: image1 (10.0.20.16)
  4. Transmission Control Protocol, Src Port: 32788, Dst Port: 9292, Seq: 212, Ack: 1172, Len: 419
  5. Hypertext Transfer Protocol
  6. GET /v2/images HTTP/1.1\r\n
  7. [Expert Info (Chat/Sequence): GET /v2/images HTTP/1.1\r\n]
  8. Request Method: GET
  9. Request URI: /v2/images
  10. Request Version: HTTP/1.1
  11. Host: image1:9292\r\n
  12. User-Agent: openstacksdk/0.61.0 keystoneauth1/4.4.0 python-requests/2.25.1 CPython/3.10.12\r\n
  13. Accept-Encoding: gzip, deflate\r\n
  14. Accept: application/json\r\n
  15. Connection: keep-alive\r\n
  16. X-Auth-Token: gAAAAABmkFWFJBbsCv5MsBqeIGj9Fc426FeFSZTyQsjlgM4lC6I6crQcE3x-ygbUSoDUoMzjTh06W5STx4YChIbkhHCe_5OuuKOx8ZAp1pxs9M_yMLD6PtuYK7TDPwlPNfjdHOKWNvrA6BHc3Xg-mjdvnsi_Z2tKdw_A3AQUYN3uAub3zaxK418\r\n
  17. \r\n
  18. [Full request URI: http://image1:9292/v2/images]
  19. [HTTP request 2/2]
  20. [Prev request in frame: 273]
  21. [Response in frame: 362]
3/ MEMCACHE验证token

glance ---> MEMCACHE,验证token:

  1. Frame 281: 143 bytes on wire (1144 bits), 143 bytes captured (1144 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: image1 (00:0c:29:cc:19:7d), Dst: controller (00:0c:29:a8:e0:3c)
  3. Internet Protocol Version 4, Src: image1 (10.0.20.16), Dst: controller (10.0.20.11)
  4. Transmission Control Protocol, Src Port: 59524, Dst Port: 11211, Seq: 1, Ack: 1, Len: 77
  5. Memcache Protocol
  6. Command: get
  7. Key: tokens/773e2dee2fb1030e539ea2f4cbee331eb398d4f8145ca001c733c4b3f63ca862

MEMCACHE---> glance,MEMCACHE回复验证请求:

  1. Frame 282: 66 bytes on wire (528 bits), 66 bytes captured (528 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: controller (00:0c:29:a8:e0:3c), Dst: image1 (00:0c:29:cc:19:7d)
  3. Internet Protocol Version 4, Src: controller (10.0.20.11), Dst: image1 (10.0.20.16)
  4. Transmission Control Protocol, Src Port: 11211, Dst Port: 59524, Seq: 1, Ack: 78, Len: 0
  5. Source Port: 11211
  6. Destination Port: 59524
  7. [Stream index: 3]
  8. [Conversation completeness: Incomplete, DATA (15)]
  9. [TCP Segment Len: 0]
  10. Sequence Number: 1 (relative sequence number)
  11. Sequence Number (raw): 981702265
  12. [Next Sequence Number: 1 (relative sequence number)]
  13. Acknowledgment Number: 78 (relative ack number)
  14. Acknowledgment number (raw): 2808812894
  15. 1000 .... = Header Length: 32 bytes (8)
  16. Flags: 0x010 (ACK)
  17. Window: 509
  18. [Calculated window size: 65152]
  19. [Window size scaling factor: 128]
  20. Checksum: 0x13d8 [unverified]
  21. [Checksum Status: Unverified]
  22. Urgent Pointer: 0
  23. Options: (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
  24. TCP Option - No-Operation (NOP)
  25. TCP Option - No-Operation (NOP)
  26. TCP Option - Timestamps: TSval 2111276189, TSecr 3515395769
  27. [Timestamps]
  28. [Time since first frame in this TCP stream: 0.000488000 seconds]
  29. [Time since previous frame in this TCP stream: 0.000127000 seconds]
  30. [SEQ/ACK analysis]
  31. [This is an ACK to the segment in frame: 281] <-------回复验证请求
  32. [The RTT to ACK the segment was: 0.000127000 seconds]
  33. [iRTT: 0.000232000 seconds]
4/ user glance认证

glance ---> keystone,user glance scope to project service,认证身份:

  1. Frame 294: 287 bytes on wire (2296 bits), 287 bytes captured (2296 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: image1 (00:0c:29:cc:19:7d), Dst: controller (00:0c:29:a8:e0:3c)
  3. Internet Protocol Version 4, Src: image1 (10.0.20.16), Dst: controller (10.0.20.11)
  4. Transmission Control Protocol, Src Port: 35368, Dst Port: 5000, Seq: 559, Ack: 601, Len: 221
  5. [2 Reassembled TCP Segments (534 bytes): #293(313), #294(221)]
  6. Hypertext Transfer Protocol
  7. POST /v3/auth/tokens HTTP/1.1\r\n
  8. [Expert Info (Chat/Sequence): POST /v3/auth/tokens HTTP/1.1\r\n]
  9. Request Method: POST
  10. Request URI: /v3/auth/tokens
  11. Request Version: HTTP/1.1
  12. Host: controller:5000\r\n
  13. User-Agent: glance/24.2.1 keystonemiddleware.auth_token/9.4.0 keystoneauth1/4.4.0 python-requests/2.25.1 CPython/3.10.12\r\n
  14. Accept-Encoding: gzip, deflate\r\n
  15. Accept: application/json\r\n
  16. Connection: keep-alive\r\n
  17. Content-Type: application/json\r\n
  18. Content-Length: 221\r\n
  19. \r\n
  20. [Full request URI: http://controller:5000/v3/auth/tokens]
  21. [HTTP request 2/3]
  22. [Prev request in frame: 288]
  23. [Response in frame: 304]
  24. [Next request in frame: 306]
  25. File Data: 221 bytes
  26. JavaScript Object Notation: application/json
  27. JSON raw form:
  28. {
  29. "auth": {
  30. "identity": {
  31. "methods": [
  32. "password"
  33. ],
  34. "password": {
  35. "user": {
  36. "password": "openstack",
  37. "name": "glance",
  38. "domain": {
  39. "name": "Default"
  40. }
  41. }
  42. }
  43. },
  44. "scope": {
  45. "project": {
  46. "name": "service",
  47. "domain": {
  48. "name": "Default"
  49. }
  50. }
  51. }
  52. }
  53. }
  54. Object

keystone ---> glance,认证成功,发放glance的token(X-Subject-Token):

  1. Frame 304: 861 bytes on wire (6888 bits), 861 bytes captured (6888 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: controller (00:0c:29:a8:e0:3c), Dst: image1 (00:0c:29:cc:19:7d)
  3. Internet Protocol Version 4, Src: controller (10.0.20.11), Dst: image1 (10.0.20.16)
  4. Transmission Control Protocol, Src Port: 5000, Dst Port: 35368, Seq: 2049, Ack: 780, Len: 795
  5. [2 Reassembled TCP Segments (2243 bytes): #303(1448), #304(795)]
  6. Hypertext Transfer Protocol
  7. HTTP/1.1 201 CREATED\r\n
  8. [Expert Info (Chat/Sequence): HTTP/1.1 201 CREATED\r\n]
  9. Response Version: HTTP/1.1
  10. Status Code: 201
  11. [Status Code Description: Created]
  12. Response Phrase: CREATED
  13. Date: Thu, 11 Jul 2024 21:58:32 GMT\r\n
  14. Server: Apache/2.4.52 (Ubuntu)\r\n
  15. Content-Length: 1753\r\n
  16. X-Subject-Token: gAAAAABmkFWLEgmaDAIh3GTU4gl2BQm2dgjcP7vCi7j6Z3h3rrjAL_c37havjhwmUxFXoxsZdKDWpzMuxjcL7UGBmoZeRHPxsnYeETpA_qz3OYhhZBV5LZM0gbZey_dCmWCJnI8dWyIXA3Iyd9wLxKX6vIYLYD9TZkTyNUuHsasmVrluTNp9i6s\r\n
  17. Vary: X-Auth-Token\r\n
  18. x-openstack-request-id: req-da6fa8c4-ce65-4dbe-b10b-f997d0858666\r\n
  19. Keep-Alive: timeout=5, max=99\r\n
  20. Connection: Keep-Alive\r\n
  21. Content-Type: application/json\r\n
  22. \r\n
  23. [HTTP response 2/3]
  24. [Time since request: 3.104488000 seconds]
  25. [Prev request in frame: 288]
  26. [Prev response in frame: 291]
  27. [Request in frame: 294]
  28. [Next request in frame: 306]
  29. [Next response in frame: 309]
  30. [Request URI: http://controller:5000/v3/auth/tokens]
  31. File Data: 1753 bytes
  32. JavaScript Object Notation: application/json
  33. JSON raw form:
  34. {
  35. "token": {
  36. "methods": [
  37. "password"
  38. ],
  39. "user": {
  40. "domain": {
  41. "id": "default",
  42. "name": "Default"
  43. },
  44. "id": "2eb252b5fc2743e995141d9529569e2d",
  45. "name": "glance",
  46. "password_expires_at": null
  47. },
  48. "audit_ids": [
  49. "JX1DnLlpRlS_8qqim-V36w"
  50. ],
  51. "expires_at": "2024-07-11T22:58:35.000000Z",
  52. "issued_at": "2024-07-11T21:58:35.000000Z",
  53. "project": {
  54. "domain": {
  55. "id": "default",
  56. "name": "Default"
  57. },
  58. "id": "fe9220b4131041e4b551b42b64a8f9ca",
  59. "name": "service"
  60. },
  61. "is_domain": false,
  62. "roles": [
  63. {
  64. "id": "17552c9a365d4944a50fd8ac271791c6",
  65. "name": "member"
  66. },
  67. {
  68. "id": "e434c66b7af647158bcaa77686ca6e93",
  69. "name": "admin"
  70. },
  71. {
  72. "id": "be23525c20c44f05b3ba071455522fcb",
  73. "name": "reader"
  74. }
  75. ],
  76. "catalog": [
  77. {
  78. "endpoints": [
  79. {
  80. "id": "7d17e6182d8640a7a6637f4f460a5c08",
  81. "interface": "internal",
  82. "region_id": "RegionOne",
  83. "url": "http://image1:9292",
  84. "region": "RegionOne"
  85. },
  86. {
  87. "id": "c37250b6bd2d471f92427483d31fd5c7",
  88. "interface": "public",
  89. "region_id": "RegionOne",
  90. "url": "http://image1:9292",
  91. "region": "RegionOne"
  92. },
  93. {
  94. "id": "f210d94217e54d2781192170bdf26877",
  95. "interface": "admin",
  96. "region_id": "RegionOne",
  97. "url": "http://image1:9292",
  98. "region": "RegionOne"
  99. }
  100. ],
  101. "id": "f378aa833518466c9ce2c9ef85e82ace",
  102. "type": "image",
  103. "name": "glance"
  104. },
  105. {
  106. "endpoints": [
  107. {
  108. "id": "a82bd043e133464fa863fba98b400460",
  109. "interface": "admin",
  110. "region_id": "RegionOne",
  111. "url": "http://controller:5000/v3/",
  112. "region": "RegionOne"
  113. },
  114. {
  115. "id": "ac109817862344c4854b783d642be412",
  116. "interface": "internal",
  117. "region_id": "RegionOne",
  118. "url": "http://controller:5000/v3/",
  119. "region": "RegionOne"
  120. },
  121. {
  122. "id": "eaf4ddaab1b74aa59403f9fbf5fc4ac1",
  123. "interface": "public",
  124. "region_id": "RegionOne",
  125. "url": "http://controller:5000/v3/",
  126. "region": "RegionOne"
  127. }
  128. ],
  129. "id": "75fe01049ec648b69e48d200971bf601",
  130. "type": "identity",
  131. "name": "keystone"
  132. }
  133. ]
  134. }
  135. }
  136. Object
5/ glance验证admin的token

glance ---> keystone,glance认证自己的身份获得token(X-Auth-Token)后,继续验证admin user scope to project admin的token(X-Subject-Token):

  1. Frame 306: 675 bytes on wire (5400 bits), 675 bytes captured (5400 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: image1 (00:0c:29:cc:19:7d), Dst: controller (00:0c:29:a8:e0:3c)
  3. Internet Protocol Version 4, Src: image1 (10.0.20.16), Dst: controller (10.0.20.11)
  4. Transmission Control Protocol, Src Port: 35368, Dst Port: 5000, Seq: 780, Ack: 2844, Len: 609
  5. Hypertext Transfer Protocol
  6. GET /v3/auth/tokens HTTP/1.1\r\n
  7. [Expert Info (Chat/Sequence): GET /v3/auth/tokens HTTP/1.1\r\n]
  8. Request Method: GET
  9. Request URI: /v3/auth/tokens
  10. Request Version: HTTP/1.1
  11. Host: controller:5000\r\n
  12. User-Agent: python-keystoneclient\r\n
  13. Accept-Encoding: gzip, deflate\r\n
  14. Accept: application/json\r\n
  15. Connection: keep-alive\r\n
  16. X-Subject-Token: gAAAAABmkFWFJBbsCv5MsBqeIGj9Fc426FeFSZTyQsjlgM4lC6I6crQcE3x-ygbUSoDUoMzjTh06W5STx4YChIbkhHCe_5OuuKOx8ZAp1pxs9M_yMLD6PtuYK7TDPwlPNfjdHOKWNvrA6BHc3Xg-mjdvnsi_Z2tKdw_A3AQUYN3uAub3zaxK418\r\n
  17. OpenStack-Identity-Access-Rules: 1\r\n
  18. X-Auth-Token: gAAAAABmkFWLEgmaDAIh3GTU4gl2BQm2dgjcP7vCi7j6Z3h3rrjAL_c37havjhwmUxFXoxsZdKDWpzMuxjcL7UGBmoZeRHPxsnYeETpA_qz3OYhhZBV5LZM0gbZey_dCmWCJnI8dWyIXA3Iyd9wLxKX6vIYLYD9TZkTyNUuHsasmVrluTNp9i6s\r\n
  19. \r\n
  20. [Full request URI: http://controller:5000/v3/auth/tokens]
  21. [HTTP request 3/3]
  22. [Prev request in frame: 294]
  23. [Response in frame: 309]

keystone ---> glance,告知user admin scope to project admin的token没问题,并返回相关的服务目录和endpoint:

  1. Frame 309: 853 bytes on wire (6824 bits), 853 bytes captured (6824 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: controller (00:0c:29:a8:e0:3c), Dst: image1 (00:0c:29:cc:19:7d)
  3. Internet Protocol Version 4, Src: controller (10.0.20.11), Dst: image1 (10.0.20.16)
  4. Transmission Control Protocol, Src Port: 5000, Dst Port: 35368, Seq: 4292, Ack: 1389, Len: 787
  5. [2 Reassembled TCP Segments (2235 bytes): #308(1448), #309(787)]
  6. Hypertext Transfer Protocol
  7. HTTP/1.1 200 OK\r\n
  8. [Expert Info (Chat/Sequence): HTTP/1.1 200 OK\r\n]
  9. Response Version: HTTP/1.1
  10. Status Code: 200
  11. [Status Code Description: OK]
  12. Response Phrase: OK
  13. Date: Thu, 11 Jul 2024 21:58:35 GMT\r\n
  14. Server: Apache/2.4.52 (Ubuntu)\r\n
  15. Content-Length: 1750\r\n
  16. X-Subject-Token: gAAAAABmkFWFJBbsCv5MsBqeIGj9Fc426FeFSZTyQsjlgM4lC6I6crQcE3x-ygbUSoDUoMzjTh06W5STx4YChIbkhHCe_5OuuKOx8ZAp1pxs9M_yMLD6PtuYK7TDPwlPNfjdHOKWNvrA6BHc3Xg-mjdvnsi_Z2tKdw_A3AQUYN3uAub3zaxK418\r\n
  17. Vary: X-Auth-Token\r\n
  18. x-openstack-request-id: req-1e89695f-0ef0-4703-88b5-0396bc0ea1c9\r\n
  19. Keep-Alive: timeout=5, max=98\r\n
  20. Connection: Keep-Alive\r\n
  21. Content-Type: application/json\r\n
  22. \r\n
  23. [HTTP response 3/3]
  24. [Time since request: 2.943232000 seconds]
  25. [Prev request in frame: 294]
  26. [Prev response in frame: 304]
  27. [Request in frame: 306]
  28. [Request URI: http://controller:5000/v3/auth/tokens]
  29. File Data: 1750 bytes
  30. JavaScript Object Notation: application/json
  31. JSON raw form:
  32. {
  33. "token": {
  34. "methods": [
  35. "password"
  36. ],
  37. "user": {
  38. "domain": {
  39. "id": "default",
  40. "name": "Default"
  41. },
  42. "id": "2947c213547147979dce3c8f8b85697f",
  43. "name": "admin",
  44. "password_expires_at": null
  45. },
  46. "audit_ids": [
  47. "-gVm2yInSBWpjE6RI9Q78A"
  48. ],
  49. "expires_at": "2024-07-11T22:58:29.000000Z",
  50. "issued_at": "2024-07-11T21:58:29.000000Z",
  51. "project": {
  52. "domain": {
  53. "id": "default",
  54. "name": "Default"
  55. },
  56. "id": "ee65b6c3961747b988ab8bd1cc19fb93",
  57. "name": "admin"
  58. },
  59. "is_domain": false,
  60. "roles": [
  61. {
  62. "id": "17552c9a365d4944a50fd8ac271791c6",
  63. "name": "member"
  64. },
  65. {
  66. "id": "e434c66b7af647158bcaa77686ca6e93",
  67. "name": "admin"
  68. },
  69. {
  70. "id": "be23525c20c44f05b3ba071455522fcb",
  71. "name": "reader"
  72. }
  73. ],
  74. "catalog": [
  75. {
  76. "endpoints": [
  77. {
  78. "id": "7d17e6182d8640a7a6637f4f460a5c08",
  79. "interface": "internal",
  80. "region_id": "RegionOne",
  81. "url": "http://image1:9292",
  82. "region": "RegionOne"
  83. },
  84. {
  85. "id": "c37250b6bd2d471f92427483d31fd5c7",
  86. "interface": "public",
  87. "region_id": "RegionOne",
  88. "url": "http://image1:9292",
  89. "region": "RegionOne"
  90. },
  91. {
  92. "id": "f210d94217e54d2781192170bdf26877",
  93. "interface": "admin",
  94. "region_id": "RegionOne",
  95. "url": "http://image1:9292",
  96. "region": "RegionOne"
  97. }
  98. ],
  99. "id": "f378aa833518466c9ce2c9ef85e82ace",
  100. "type": "image",
  101. "name": "glance"
  102. },
  103. {
  104. "endpoints": [
  105. {
  106. "id": "a82bd043e133464fa863fba98b400460",
  107. "interface": "admin",
  108. "region_id": "RegionOne",
  109. "url": "http://controller:5000/v3/",
  110. "region": "RegionOne"
  111. },
  112. {
  113. "id": "ac109817862344c4854b783d642be412",
  114. "interface": "internal",
  115. "region_id": "RegionOne",
  116. "url": "http://controller:5000/v3/",
  117. "region": "RegionOne"
  118. },
  119. {
  120. "id": "eaf4ddaab1b74aa59403f9fbf5fc4ac1",
  121. "interface": "public",
  122. "region_id": "RegionOne",
  123. "url": "http://controller:5000/v3/",
  124. "region": "RegionOne"
  125. }
  126. ],
  127. "id": "75fe01049ec648b69e48d200971bf601",
  128. "type": "identity",
  129. "name": "keystone"
  130. }
  131. ]
  132. }
  133. }
  134. Object
6/ MEMCACHE储存token

glance ---> MEMCACHE,储存token:

  1. Frame 312: 677 bytes on wire (5416 bits), 677 bytes captured (5416 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: image1 (00:0c:29:cc:19:7d), Dst: controller (00:0c:29:a8:e0:3c)
  3. Internet Protocol Version 4, Src: image1 (10.0.20.16), Dst: controller (10.0.20.11)
  4. Transmission Control Protocol, Src Port: 59524, Dst Port: 11211, Seq: 1526, Ack: 6, Len: 611
  5. [2 Reassembled TCP Segments (2059 bytes): #311(1448), #312(611)]
  6. Memcache Protocol
  7. Command: set
  8. Key: tokens/773e2dee2fb1030e539ea2f4cbee331eb398d4f8145ca001c733c4b3f63ca862
  9. Flags: 0
  10. Expiration: 300
  11. Value length: 1968
  12. Value [truncated]: {"token": {"methods": ["password"], "user": {"domain": {"id": "default", "name": "Default"}, "id": "2947c213547147979dce3c8f8b85697f", "name": "admin", "password_expires_at": null}, "audit_ids": ["-gVm2yInSBWpjE6RI9Q78A"

MEMCACHE成功储存:

  1. Frame 314: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: controller (00:0c:29:a8:e0:3c), Dst: image1 (00:0c:29:cc:19:7d)
  3. Internet Protocol Version 4, Src: controller (10.0.20.11), Dst: image1 (10.0.20.16)
  4. Transmission Control Protocol, Src Port: 11211, Dst Port: 59524, Seq: 6, Ack: 2137, Len: 8
  5. Memcache Protocol
  6. Response: STORED
7/ glance连接数据库,SQL查询

(只展示login信息,其他SQL查询信息略)

  1. Frame 321: 212 bytes on wire (1696 bits), 212 bytes captured (1696 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: image1 (00:0c:29:cc:19:7d), Dst: controller (00:0c:29:a8:e0:3c)
  3. Internet Protocol Version 4, Src: image1 (10.0.20.16), Dst: controller (10.0.20.11)
  4. Transmission Control Protocol, Src Port: 46382, Dst Port: 3306, Seq: 1, Ack: 111, Len: 146
  5. MySQL Protocol
  6. Packet Length: 142
  7. Packet Number: 1
  8. Login Request
  9. Client Capabilities: 0xa20f
  10. Extended Client Capabilities: 0x003a
  11. MAX Packet: 16777215
  12. Charset: utf8 COLLATE utf8_general_ci (33)
  13. Unused: 0000000000000000000000000000000000000000000000
  14. Username: glance
  15. Password: 4d1590709f0fb6fdce405042311a3773f737dd5a
  16. Schema: glance
  17. Client Auth Plugin: mysql_native_password
  18. Connection Attributes
8/ glance将查询结果返回给OpenStackClient:
  1. Frame 362: 1117 bytes on wire (8936 bits), 1117 bytes captured (8936 bits) on interface \Device\NPF_{3CF2B347-CE40-406F-B67A-13F210B29B37}, id 0
  2. Ethernet II, Src: image1 (00:0c:29:cc:19:7d), Dst: VMware_ff:20:81 (00:0c:29:ff:20:81)
  3. Internet Protocol Version 4, Src: image1 (10.0.20.16), Dst: 10.0.20.100 (10.0.20.100)
  4. Transmission Control Protocol, Src Port: 9292, Dst Port: 32788, Seq: 1172, Ack: 631, Len: 1051
  5. Hypertext Transfer Protocol
  6. HTTP/1.1 200 OK\r\n
  7. [Expert Info (Chat/Sequence): HTTP/1.1 200 OK\r\n]
  8. Response Version: HTTP/1.1
  9. Status Code: 200
  10. [Status Code Description: OK]
  11. Response Phrase: OK
  12. Content-Length: 852\r\n
  13. Content-Type: application/json\r\n
  14. X-Openstack-Request-Id: req-3fd463a0-2fae-4d96-b668-ecd6c402861c\r\n
  15. Date: Thu, 11 Jul 2024 21:58:38 GMT\r\n
  16. Connection: keep-alive\r\n
  17. \r\n
  18. [HTTP response 2/2]
  19. [Time since request: 8.837414000 seconds]
  20. [Prev request in frame: 273]
  21. [Prev response in frame: 275]
  22. [Request in frame: 277]
  23. [Request URI: http://image1:9292/v2/images]
  24. File Data: 852 bytes
  25. JavaScript Object Notation: application/json
  26. JSON raw form:
  27. {
  28. "images": [
  29. {
  30. "name": "cirros",
  31. "disk_format": "qcow2",
  32. "container_format": "bare",
  33. "visibility": "public",
  34. "size": 12716032,
  35. "virtual_size": 46137344,
  36. "status": "active",
  37. "checksum": "443b7623e27ecf03dc9e01ee93f67afe",
  38. "protected": false,
  39. "min_ram": 0,
  40. "min_disk": 0,
  41. "owner": "ee65b6c3961747b988ab8bd1cc19fb93",
  42. "os_hidden": false,
  43. "os_hash_algo": "sha512",
  44. "os_hash_value": "6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78",
  45. "id": "9f0e6328-3e96-41e1-b282-d577b6749a09",
  46. "created_at": "2024-07-07T08:26:02Z",
  47. "updated_at": "2024-07-07T08:26:02Z",
  48. "tags": [],
  49. "self": "/v2/images/9f0e6328-3e96-41e1-b282-d577b6749a09",
  50. "file": "/v2/images/9f0e6328-3e96-41e1-b282-d577b6749a09/file",
  51. "schema": "/v2/schemas/image"
  52. }
  53. ],
  54. "first": "/v2/images",
  55. "schema": "/v2/schemas/images"
  56. }
  57. Object

5、关闭虚机,拍摄快照

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/829844
推荐阅读
相关标签
  

闽ICP备14008679号