File: backups.rb

package info (click to toggle)
ruby-fog-openstack 1.0.8-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 5,132 kB
  • sloc: ruby: 36,411; makefile: 5; sh: 4
file content (41 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'fog/openstack'
require 'fog/openstack/workflow/v2'

auth_url = "http://192.0.2.1:5000/v3/auth/tokens"
username = "admin"
password = "1b1d81f7e25b53e497246b168971823c5754f395"
project  = "admin"

@connection_params = {
  :openstack_auth_url     => auth_url,
  :openstack_username     => username,
  :openstack_api_key      => password,
  :openstack_project_name => project,
  :openstack_domain_id    => "default",
}

cinder = Fog::OpenStack::Volume.new(@connection_params)

puts "INFO: create backup of existing volume named test"

response = cinder.create_backup({:name => 'test-backup',
                                 :volume_id => '82fe2ad5-43a3-4c2b-8464-e57b138ea81c'})
puts response.body

puts "INFO: list backups"

backups = cinder.backups

puts "INFO: get details of existing backup"

backup_id = backups[0].id
backup = cinder.backups.get(backup_id)

puts "INFO: restore backup"

response = backup.restore('82fe2ad5-43a3-4c2b-8464-e57b138ea81c')
puts response.body

puts "INFO: delete backup"

backup.destroy