Hello, this is my full code to create a snapshot from an instance.
The code creates a new image with type snapshot, but after around 2 hours, its status is still in queue.
But when I create another snapshot via the Openstack UI, it works fine.
Would you please help me how can I create a snapshot?
import openstack
import datetime
now = datetime.datetime.now()
today = now.strftime('%Y_%m_%d_%H_%M_%S')
openstack.enable_logging(debug=False)
servers = []
images = []
openstack_connection = openstack.connect(cloud='region1') # clouds.yaml
for server in openstack_connection.compute.servers(details=True, hostname='my_server'):
servers.append(server.to_dict())
servers = servers[0]
for image in openstack_connection.compute.images(details=True, id=servers['image']['id']):
images.append(image.to_dict())
images = images[0]
name = f'my_server_{today}'
openstack_connection.image.create_image(
name=name,
disk_format='raw',
container_format='bare',
visibility='private',
timeout=1,
properties={
'hw_disk_bus': 'scsi',
'hw_qemu_guest_agent': 'yes',
'hw_scsi_model': 'virtio-scsi',
'hw_watchdog_action': 'reset',
'base_image_ref': servers['image']['id'],
'owner_user_name': 'whmcs',
'owner_project_name': 'admin',
'boot_roles': 'admin,reader,member',
'os_admin_user': 'administrator',
'os_distro': 'windows',
'os_type': 'windows',
'owner_specified.openstack.object': images['metadata']['owner_specified.openstack.object'],
'clean_attempts': '1',
'hw_machine_type': 'pc',
'password_0': '',
'password_1': '',
'password_2': '',
'password_3': '',
'hw_cdrom_bus': 'ide',
'hw_input_bus': 'usb',
'hw_pointer_model': 'usbtablet',
'hw_video_model': 'virtio',
'hw_vif_model': 'virtio',
'instance_uuid': servers['id'],
'image_type': 'snapshot',
}
)