Справочник Openstack API при работе с дисками

Commands API:

cinder reset-state --state available <volume_uuid>
nova volume-detach <server_uuid> <volume_uuid>

virsh attach-disk instance-0000092f --source /var/lib/nova/mnt/4b45f71470c61b525d443092281ac72d/volume-1168fe81-c449-4ebc-96eb-58bfbf80c328 --target vdb
virsh detach-disk --domain instance-000000b0 --target vdk --persistent

qemu-img create sheepdog://0.0.0.0:7000/test_200409 10G

mount -o loop,offset=1048576 -t auto img.file /mnt/tmp

mysqlcheck --no-defaults --databases --fix-db-names --fix-table-names mysql
--upgrade-system-tables 

Подключение диска

virsh attach-disk --help
  NAME
    attach-disk - attach disk device

  SYNOPSIS
    attach-disk <domain> <source> <target> [--targetbus <string>] [--driver <string>] [--subdriver <string>] [--iothread <string>] [--cache <string>] [--type <string>] [--mode <string>] [--sourcetype <string>] [--serial <string>] [--wwn <string>] [--rawio] [--address <string>] [--multifunction] [--print-xml] [--persistent] [--config] [--live] [--current]

  DESCRIPTION
    Attach new disk device.

  OPTIONS
    [--domain] <string>  domain name, id or uuid
    [--source] <string>  source of disk device
    [--target] <string>  target of disk device
    --targetbus <string>  target bus of disk device
    --driver <string>  driver of disk device
    --subdriver <string>  subdriver of disk device
    --iothread <string>  IOThread to be used by supported device
    --cache <string>  cache mode of disk device
    --type <string>  target device type
    --mode <string>  mode of device reading and writing
    --sourcetype <string>  type of source (block|file)
    --serial <string>  serial of disk device
    --wwn <string>   wwn of disk device
    --rawio          needs rawio capability
    --address <string>  address of disk device
    --multifunction  use multifunction pci under specified address
    --print-xml      print XML document rather than attach the disk
    --persistent     make live change persistent
    --config         affect next boot
    --live           affect running domain
    --current        affect current domain

Пример записи о sheepdog диске в xml-дампе

  <disk type='network' device='disk'>
      <driver name='qemu' type='raw' cache='none'/>
      <source protocol='sheepdog' name='volume-d655c3b1-efaf-415d-aff5-e1000d27fc53'>
        <host name='127.0.0.1' port='7000'/>
      </source>
      <backingStore/>
      <target dev='vdb' bus='virtio'/>
      <serial>d655c3b1-efaf-415d-aff5-e1000d27fc53</serial>
      <alias name='virtio-disk1'/>

      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>

</disk>

Справочник по таблицам СУБД

nova.block_device_mapping

nova.block_device_mapping
+-----------------------+--------------+------+-----+---------+----------------+
| Field                 | Type         | Null | Key | Default | Extra          |
+-----------------------+--------------+------+-----+---------+----------------+
| created_at            | datetime     | YES  |     | NULL    |                |
| updated_at            | datetime     | YES  |     | NULL    |                |
| deleted_at            | datetime     | YES  |     | NULL    |                |
| id                    | int(11)      | NO   | PRI | NULL    | auto_increment |
| device_name           | varchar(255) | YES  |     | NULL    |                |
| delete_on_termination | tinyint(1)   | YES  |     | NULL    |                |
| snapshot_id           | varchar(36)  | YES  | MUL | NULL    |                |
| volume_id             | varchar(36)  | YES  | MUL | NULL    |                |
| volume_size           | int(11)      | YES  |     | NULL    |                |
| no_device             | tinyint(1)   | YES  |     | NULL    |                |
| connection_info       | mediumtext   | YES  |     | NULL    |                |
| instance_uuid         | varchar(36)  | YES  | MUL | NULL    |                |
| deleted               | int(11)      | YES  |     | NULL    |                |
| source_type           | varchar(255) | YES  |     | NULL    |                |
| destination_type      | varchar(255) | YES  |     | NULL    |                |
| guest_format          | varchar(255) | YES  |     | NULL    |                |
| device_type           | varchar(255) | YES  |     | NULL    |                |
| disk_bus              | varchar(255) | YES  |     | NULL    |                |
| boot_index            | int(11)      | YES  |     | NULL    |                |
| image_id              | varchar(36)  | YES  |     | NULL    |                |
+-----------------------+--------------+------+-----+---------+----------------+

cinder.volume_attachment

cinder.volume_attachment
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| created_at    | datetime     | YES  |     | NULL    |       |
| updated_at    | datetime     | YES  |     | NULL    |       |
| deleted_at    | datetime     | YES  |     | NULL    |       |
| deleted       | tinyint(1)   | YES  |     | NULL    |       |
| id            | varchar(36)  | NO   | PRI | NULL    |       |
| volume_id     | varchar(36)  | NO   | MUL | NULL    |       |
| attached_host | varchar(255) | YES  |     | NULL    |       |
| instance_uuid | varchar(36)  | YES  |     | NULL    |       |
| mountpoint    | varchar(255) | YES  |     | NULL    |       |
| attach_time   | datetime     | YES  |     | NULL    |       |
| detach_time   | datetime     | YES  |     | NULL    |       |
| attach_mode   | varchar(36)  | YES  |     | NULL    |       |
| attach_status | varchar(255) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+

cinder.volumes

cinder.volumes
+-----------------------------+--------------+------+-----+---------+-------+
| Field                       | Type         | Null | Key | Default | Extra |
+-----------------------------+--------------+------+-----+---------+-------+
| created_at                  | datetime     | YES  |     | NULL    |       |
| updated_at                  | datetime     | YES  |     | NULL    |       |
| deleted_at                  | datetime     | YES  |     | NULL    |       |
| deleted                     | tinyint(1)   | YES  |     | NULL    |       |
| id                          | varchar(36)  | NO   | PRI | NULL    |       |
| ec2_id                      | varchar(255) | YES  |     | NULL    |       |
| user_id                     | varchar(255) | YES  |     | NULL    |       |
| project_id                  | varchar(255) | YES  |     | NULL    |       |
| host                        | varchar(255) | YES  |     | NULL    |       |
| size                        | int(11)      | YES  |     | NULL    |       |
| availability_zone           | varchar(255) | YES  |     | NULL    |       |
| status                      | varchar(255) | YES  |     | NULL    |       |
| attach_status               | varchar(255) | YES  |     | NULL    |       |
| scheduled_at                | datetime     | YES  |     | NULL    |       |
| launched_at                 | datetime     | YES  |     | NULL    |       |
| terminated_at               | datetime     | YES  |     | NULL    |       |
| display_name                | varchar(255) | YES  |     | NULL    |       |
| display_description         | varchar(255) | YES  |     | NULL    |       |
| provider_location           | varchar(256) | YES  |     | NULL    |       |
| provider_auth               | varchar(256) | YES  |     | NULL    |       |
| snapshot_id                 | varchar(36)  | YES  |     | NULL    |       |
| volume_type_id              | varchar(36)  | YES  |     | NULL    |       |
| source_volid                | varchar(36)  | YES  |     | NULL    |       |
| bootable                    | tinyint(1)   | YES  |     | NULL    |       |
| provider_geometry           | varchar(255) | YES  |     | NULL    |       |
| _name_id                    | varchar(36)  | YES  |     | NULL    |       |
| encryption_key_id           | varchar(36)  | YES  |     | NULL    |       |
| migration_status            | varchar(255) | YES  |     | NULL    |       |
| replication_status          | varchar(255) | YES  |     | NULL    |       |
| replication_extended_status | varchar(255) | YES  |     | NULL    |       |
| replication_driver_data     | varchar(255) | YES  |     | NULL    |       |
| consistencygroup_id         | varchar(36)  | YES  | MUL | NULL    |       |
| provider_id                 | varchar(255) | YES  |     | NULL    |       |
| multiattach                 | tinyint(1)   | YES  |     | NULL    |       |
| previous_status             | varchar(255) | YES  |     | NULL    |       |
+-----------------------------+--------------+------+-----+---------+-------+

source_type

mysql> select distinct source_type from block_device_mapping;
+-------------+
| source_type |
+-------------+
| image       |
| volume      |
| blank       |
+-------------+

destination_type

mysql> select distinct destination_type from block_device_mapping;
+------------------+
| destination_type |
+------------------+
| local            |
| volume           |
+------------------+

guest_format

mysql> select distinct guest_format from block_device_mapping;
+--------------+
| guest_format |
+--------------+
| NULL         |
| swap         |
+--------------+

disk_bus

mysql> select distinct disk_bus from block_device_mapping;
+----------+
| disk_bus |
+----------+
| NULL     |
| virtio   |
+----------+

boot_index

mysql> select distinct boot_index from block_device_mapping;
+------------+
| boot_index |
+------------+
|          0 |
|       NULL |
|         -1 |
+------------+

Примеры записей СУБД для правильно подключенного диска

CINDER database - nfs disk type

mysql> select id,instance_uuid,mountpoint,attach_status from volume_attachment where volume_id="ecfc6808-1a90-4ba1-bcc1-a5c755147ba7";



| id                                   | instance_uuid                        | mountpoint | attach_status |
| ------------------------------------ | ------------------------------------ | ---------- | ------------- |
| 7e1167c7-1b27-40b8-8bc9-82bd0c429345 | 08093b81-a00b-48ff-9dc2-7a3a33a0b98b | /dev/vdb   | attached      |

CINDER database - object disk type

mysql> select id,instance_uuid,mountpoint,attach_status from volume_attachment where volume_id="54d96cb2-ef58-4459-a704-4c9f7e5bfba8";

| id                                   | instance_uuid                        | mountpoint | attach_status |
| ------------------------------------ | ------------------------------------ | ---------- | ------------- |
| 3d749156-fd9c-4aaf-92c4-5c560a4befb5 | 08093b81-a00b-48ff-9dc2-7a3a33a0b98b | /dev/vdc   | attached      |

NOVA database object disk type

mysql> select id,device_name,connection_info,guest_format from block_device_mapping where instance_uuid="08093b81-a00b-48ff-9dc2-7a3a33a0b98b" and volume_id="54d96cb2-ef58-4459-a704-4c9f7e5bfba8";


| id   | device_name | connection_info                                              | guest_format |
| ---- | ----------- | ------------------------------------------------------------ | ------------ |
| 364  | /dev/vdc    | {"driver_volume_type": "sheepdog", "connector": {"initiator": "iqn.1993-08.org.debian:01:5ef1cbc4b853", "ip": "10.0.10.52", "platform": "x86_64", "host": "dc-comp-02", "os_type": "linux2", "multipath": false}, "serial": "54d96cb2-ef58-4459-a704-4c9f7e5bfba8", "data": {"name": "volume-54d96cb2-ef58-4459-a704-4c9f7e5bfba8", "encrypted": false, "qos_specs": null, "hosts": ["127.0.0.1"], "access_mode": "rw", "ports": ["7000"]}} | NULL         |