foreman_snapshot_management 1.5.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +200 -2
- data/Rakefile +9 -2
- data/app/controllers/api/v2/snapshots_controller.rb +39 -7
- data/app/controllers/concerns/foreman/controller/parameters/snapshot.rb +2 -0
- data/app/controllers/foreman_snapshot_management/snapshots_controller.rb +10 -7
- data/app/helpers/concerns/foreman_snapshot_management/hosts_helper_extension.rb +2 -0
- data/app/helpers/foreman_snapshot_management/snapshot_helper.rb +2 -0
- data/app/models/concerns/fog_extensions/proxmox/snapshots/mock.rb +24 -0
- data/app/models/concerns/fog_extensions/vsphere/snapshots/mock.rb +2 -0
- data/app/models/concerns/fog_extensions/vsphere/snapshots/real.rb +4 -2
- data/app/models/foreman_snapshot_management/proxmox_extensions.rb +101 -0
- data/app/models/foreman_snapshot_management/snapshot.rb +36 -30
- data/app/models/foreman_snapshot_management/vmware_extensions.rb +42 -13
- data/app/views/api/v2/snapshots/base.json.rabl +4 -0
- data/app/views/api/v2/snapshots/create.json.rabl +2 -0
- data/app/views/api/v2/snapshots/destroy.json.rabl +2 -0
- data/app/views/api/v2/snapshots/index.json.rabl +2 -0
- data/app/views/api/v2/snapshots/main.json.rabl +4 -2
- data/app/views/api/v2/snapshots/revert.json.rabl +2 -0
- data/app/views/api/v2/snapshots/show.json.rabl +2 -0
- data/app/views/api/v2/snapshots/update.json.rabl +2 -0
- data/app/views/foreman_snapshot_management/snapshots/_index.html.erb +12 -74
- data/app/views/{foreman_snapshot_management/hosts/_snapshots_tab_content.html.erb → hosts/_snapshots_tab.html.erb} +8 -0
- data/config/routes.rb +2 -0
- data/lib/foreman_snapshot_management.rb +2 -0
- data/lib/foreman_snapshot_management/engine.rb +56 -17
- data/lib/foreman_snapshot_management/version.rb +3 -1
- data/lib/tasks/foreman_snapshot_management_tasks.rake +31 -10
- data/locale/de/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
- data/locale/de/foreman_snapshot_management.po +195 -0
- data/locale/en/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
- data/locale/en/foreman_snapshot_management.edit.po +0 -0
- data/locale/en/foreman_snapshot_management.po +179 -11
- data/locale/foreman_snapshot_management.pot +259 -8
- data/locale/gemspec.rb +3 -1
- data/package.json +46 -0
- data/test/controllers/api/v2/snapshots_test.rb +252 -39
- data/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb +63 -9
- data/test/factories/proxmox_factory.rb +18 -0
- data/test/test_plugin_helper.rb +5 -0
- data/webpack/components/SnapshotManagement/SnapshotManagement.js +84 -0
- data/webpack/components/SnapshotManagement/SnapshotManagementActions.js +212 -0
- data/webpack/components/SnapshotManagement/SnapshotManagementConstants.js +9 -0
- data/webpack/components/SnapshotManagement/SnapshotManagementReducer.js +100 -0
- data/webpack/components/SnapshotManagement/SnapshotManagementSelectors.js +8 -0
- data/webpack/components/SnapshotManagement/__tests__/SnapshotManagementActions.test.js +123 -0
- data/webpack/components/SnapshotManagement/__tests__/SnapshotManagementReducer.test.js +157 -0
- data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementActions.test.js.snap +314 -0
- data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementReducer.test.js.snap +214 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js +118 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormConstants.js +5 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/SnapshotForm.test.js +26 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap +476 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/index.js +19 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/snapshotForm.scss +3 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModal.js +37 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModalConstants.js +1 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/SnapshotFormModal.test.js +19 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/__snapshots__/SnapshotFormModal.test.js.snap +19 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/index.js +12 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/useSnapshotFormModal.js +7 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js +314 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js +70 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/SnapshotList.test.js +88 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/__snapshots__/SnapshotList.test.js.snap +1081 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/snapshotList.scss +13 -0
- data/webpack/components/SnapshotManagement/index.js +33 -0
- data/webpack/components/SnapshotManagement/snapshotManagement.scss +5 -0
- data/webpack/global_index.js +7 -0
- data/webpack/global_test_setup.js +11 -0
- data/webpack/index.js +8 -0
- data/webpack/reducers.js +7 -0
- data/webpack/test_setup.js +17 -0
- metadata +52 -54
- data/app/overrides/hosts/add_tab_to_host_overview.rb +0 -11
- data/app/views/foreman_snapshot_management/hosts/_snapshots_tab.html.erb +0 -3
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FogExtensions
|
2
4
|
module Vsphere
|
3
5
|
module Snapshots
|
@@ -7,7 +9,7 @@ module FogExtensions
|
|
7
9
|
raise ArgumentError, 'snapshot is a required parameter' unless options.key? 'snapshot'
|
8
10
|
raise ArgumentError, 'removeChildren is a required parameter' unless options.key? 'removeChildren'
|
9
11
|
|
10
|
-
raise ArgumentError, 'snapshot is a required parameter' unless ::
|
12
|
+
raise ArgumentError, 'snapshot is a required parameter' unless ::ForemanSnapshotManagement.fog_vsphere_namespace::Snapshot === options['snapshot']
|
11
13
|
|
12
14
|
task = options['snapshot'].mo_ref.RemoveSnapshot_Task(
|
13
15
|
removeChildren: options['removeChildren']
|
@@ -26,7 +28,7 @@ module FogExtensions
|
|
26
28
|
raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
|
27
29
|
raise ArgumentError, 'description is a required parameter' unless options.key? 'description'
|
28
30
|
|
29
|
-
raise ArgumentError, 'snapshot is a required parameter' unless ::
|
31
|
+
raise ArgumentError, 'snapshot is a required parameter' unless ::ForemanSnapshotManagement.fog_vsphere_namespace::Snapshot === options['snapshot']
|
30
32
|
|
31
33
|
options['snapshot'].mo_ref.RenameSnapshot(
|
32
34
|
name: options['name'],
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanSnapshotManagement
|
4
|
+
module ProxmoxExtensions
|
5
|
+
# Extend Proxmox's capabilities with snapshots.
|
6
|
+
def capabilities
|
7
|
+
super + [:snapshots]
|
8
|
+
end
|
9
|
+
|
10
|
+
# Create a Snapshot.
|
11
|
+
#
|
12
|
+
# This method creates a Snapshot with a given name and optional description.
|
13
|
+
def create_snapshot(host, name, description, _include_ram = false)
|
14
|
+
server = find_vm_by_uuid host.uuid
|
15
|
+
raise _('Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _') unless /^[A-Za-z][\w]{1,}$/.match?(name)
|
16
|
+
|
17
|
+
snapshot = server.snapshots.create(name: name)
|
18
|
+
snapshot.description = description
|
19
|
+
snapshot.update
|
20
|
+
rescue StandardError => e
|
21
|
+
Foreman::Logging.exception('Error creating Proxmox Snapshot', e)
|
22
|
+
raise ::Foreman::WrappedException.new(e, N_('Unable to create Proxmox Snapshot'))
|
23
|
+
end
|
24
|
+
|
25
|
+
# Remove Snapshot
|
26
|
+
#
|
27
|
+
# This method removes a Snapshot from a given host.
|
28
|
+
def remove_snapshot(snapshot)
|
29
|
+
snapshot.destroy
|
30
|
+
rescue StandardError => e
|
31
|
+
Foreman::Logging.exception('Error removing Proxmox Snapshot', e)
|
32
|
+
raise ::Foreman::WrappedException.new(e, N_('Unable to remove Proxmox Snapshot'))
|
33
|
+
end
|
34
|
+
|
35
|
+
# Revert Snapshot
|
36
|
+
#
|
37
|
+
# This method revert a host to a given Snapshot.
|
38
|
+
def revert_snapshot(snapshot)
|
39
|
+
snapshot.rollback
|
40
|
+
rescue StandardError => e
|
41
|
+
Foreman::Logging.exception('Error reverting Proxmox Snapshot', e)
|
42
|
+
raise ::Foreman::WrappedException.new(e, N_('Unable to revert Proxmox Snapshot'))
|
43
|
+
end
|
44
|
+
|
45
|
+
# Update Snapshot
|
46
|
+
#
|
47
|
+
# This method renames a Snapshot from a given host.
|
48
|
+
def update_snapshot(snapshot, name, description)
|
49
|
+
raise _('Snapshot name cannot be changed') if snapshot.name != name
|
50
|
+
|
51
|
+
snapshot.description = description
|
52
|
+
snapshot.update
|
53
|
+
rescue StandardError => e
|
54
|
+
Foreman::Logging.exception('Error updating Proxmox Snapshot', e)
|
55
|
+
raise ::Foreman::WrappedException.new(e, N_('Unable to update Proxmox Snapshot'))
|
56
|
+
end
|
57
|
+
|
58
|
+
# Get Snapshot
|
59
|
+
#
|
60
|
+
# This methods returns a specific Snapshot for a given host.
|
61
|
+
def get_snapshot(host, snapshot_id)
|
62
|
+
server = find_vm_by_uuid host.uuid
|
63
|
+
snapshot = server.snapshots.get(snapshot_id)
|
64
|
+
raw_to_snapshot(host, snapshot)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get Snapshot by name
|
68
|
+
#
|
69
|
+
# This method returns a specific Snapshot for a given host.
|
70
|
+
def get_snapshot_by_name(host, name)
|
71
|
+
server = find_vm_by_uuid host.uuid
|
72
|
+
snapshot = server.snapshots.get(name)
|
73
|
+
raw_to_snapshot(host, snapshot) if snapshot
|
74
|
+
end
|
75
|
+
|
76
|
+
# Get Snapshots
|
77
|
+
#
|
78
|
+
# This methods returns Snapshots for a given host.
|
79
|
+
def get_snapshots(host)
|
80
|
+
server = find_vm_by_uuid host.uuid
|
81
|
+
server.snapshots.delete(server.snapshots.get('current'))
|
82
|
+
server.snapshots.map do |snapshot|
|
83
|
+
raw_to_snapshot(host, snapshot)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def raw_to_snapshot(host, raw_snapshot)
|
90
|
+
if raw_snapshot
|
91
|
+
Snapshot.new(
|
92
|
+
host: host,
|
93
|
+
id: raw_snapshot.name,
|
94
|
+
raw_snapshot: raw_snapshot,
|
95
|
+
name: raw_snapshot.name,
|
96
|
+
description: raw_snapshot.description
|
97
|
+
)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
|
3
5
|
module ForemanSnapshotManagement
|
4
6
|
class Snapshot
|
5
7
|
extend ActiveModel::Callbacks
|
8
|
+
extend ActiveModel::Naming
|
6
9
|
include ActiveModel::Conversion
|
7
10
|
include ActiveModel::Model
|
8
11
|
include ActiveModel::Dirty
|
@@ -14,39 +17,39 @@ module ForemanSnapshotManagement
|
|
14
17
|
attr_reader :name, :description, :include_ram, :host_id
|
15
18
|
define_attribute_methods :name, :description, :include_ram
|
16
19
|
|
20
|
+
def self.model_name
|
21
|
+
Struct.new(:name, :klass, :singular, :plural, :element,
|
22
|
+
:human, :collection, :param_key, :i18n_key, :route_key, :singular_route_key).new(
|
23
|
+
'ForemanSnapshotManagement::Snapshot', ForemanSnapshotManagement::Snapshot,
|
24
|
+
'foreman_snapshot_management_snapshot', 'foreman_snapshot_management_snapshots',
|
25
|
+
'snapshot', 'Snapshot', 'foreman_snapshot_management/snapshots',
|
26
|
+
'snapshot', :'foreman_snapshot_management/snapshot', 'foreman_snapshot_management_snapshots',
|
27
|
+
'foreman_snapshot_management_snapshot'
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.any?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.new_for_host(host)
|
36
|
+
host.compute_resource.new_snapshot(host)
|
37
|
+
end
|
38
|
+
|
17
39
|
def self.all_for_host(host)
|
18
|
-
host.compute_resource.get_snapshots(host
|
19
|
-
new_from_vmware(host, raw_snapshot)
|
20
|
-
end
|
40
|
+
host.compute_resource.get_snapshots(host)
|
21
41
|
end
|
22
42
|
|
23
43
|
def self.find_for_host(host, id)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
new(
|
30
|
-
host: host,
|
31
|
-
id: raw_snapshot.ref,
|
32
|
-
raw_snapshot: raw_snapshot,
|
33
|
-
name: raw_snapshot.name,
|
34
|
-
description: raw_snapshot.description,
|
35
|
-
parent: opts[:parent],
|
36
|
-
create_time: raw_snapshot.create_time
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def children
|
41
|
-
return [] unless raw_snapshot
|
42
|
-
child_snapshots = raw_snapshot.child_snapshots.flat_map do |child_snapshot|
|
43
|
-
self.class.new_from_vmware(host, child_snapshot, parent: self)
|
44
|
-
end
|
45
|
-
child_snapshots + child_snapshots.flat_map(&:children)
|
44
|
+
host.compute_resource.get_snapshot(host, id)
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.find_for_host_by_name(host, name)
|
48
|
+
host.compute_resource.get_snapshot_by_name(host, name)
|
46
49
|
end
|
47
50
|
|
48
51
|
def inspect
|
49
|
-
"#<#{self.class}:0x#{self.__id__.to_s(16)} name=#{name} id=#{id} description=#{description} host_id=#{host_id} parent=#{parent.try(:id)}
|
52
|
+
"#<#{self.class}:0x#{self.__id__.to_s(16)} name=#{name} id=#{id} description=#{description} host_id=#{host_id} parent=#{parent.try(:id)}>"
|
50
53
|
end
|
51
54
|
|
52
55
|
def to_s
|
@@ -54,7 +57,7 @@ module ForemanSnapshotManagement
|
|
54
57
|
end
|
55
58
|
|
56
59
|
def formatted_create_time
|
57
|
-
create_time
|
60
|
+
create_time&.strftime('%F %H:%M')
|
58
61
|
end
|
59
62
|
|
60
63
|
def persisted?
|
@@ -73,6 +76,7 @@ module ForemanSnapshotManagement
|
|
73
76
|
|
74
77
|
def include_ram=(value)
|
75
78
|
raise Exception('Cannot modify include_ram on existing snapshots.') if persisted?
|
79
|
+
|
76
80
|
@include_ram = value
|
77
81
|
end
|
78
82
|
|
@@ -83,12 +87,14 @@ module ForemanSnapshotManagement
|
|
83
87
|
|
84
88
|
def host_id=(host_id)
|
85
89
|
return if @host_id == host_id
|
90
|
+
|
86
91
|
@host_id = host_id
|
87
92
|
@host = nil
|
88
93
|
end
|
89
94
|
|
90
95
|
def host=(host)
|
91
96
|
return if @host_id == host.id
|
97
|
+
|
92
98
|
@host_id = host.id
|
93
99
|
@host = host
|
94
100
|
end
|
@@ -105,7 +111,7 @@ module ForemanSnapshotManagement
|
|
105
111
|
end
|
106
112
|
end
|
107
113
|
|
108
|
-
def
|
114
|
+
def update(new_attributes)
|
109
115
|
assign_attributes(new_attributes)
|
110
116
|
save if changed?
|
111
117
|
end
|
@@ -116,7 +122,7 @@ module ForemanSnapshotManagement
|
|
116
122
|
handle_snapshot_errors do
|
117
123
|
host.audit_comment = "Create snapshot #{name}"
|
118
124
|
host.save!
|
119
|
-
host.compute_resource.create_snapshot(host
|
125
|
+
host.compute_resource.create_snapshot(host, name, description, include_ram)
|
120
126
|
changes_applied
|
121
127
|
end
|
122
128
|
end
|
@@ -138,7 +144,7 @@ module ForemanSnapshotManagement
|
|
138
144
|
result = handle_snapshot_errors do
|
139
145
|
host.audit_comment = "Destroy snapshot #{name}"
|
140
146
|
host.save!
|
141
|
-
result = host.compute_resource.remove_snapshot(raw_snapshot
|
147
|
+
result = host.compute_resource.remove_snapshot(raw_snapshot)
|
142
148
|
end
|
143
149
|
@id = nil
|
144
150
|
result
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ForemanSnapshotManagement
|
2
4
|
module VmwareExtensions
|
3
5
|
# Extend VMWare's capabilities with snapshots.
|
4
6
|
def capabilities
|
5
|
-
super + [:snapshots]
|
7
|
+
super + [:snapshots, :snapshot_include_ram, :editable_snapshot_name]
|
6
8
|
end
|
7
9
|
|
8
10
|
# Create a Snapshot.
|
9
11
|
#
|
10
12
|
# This method creates a Snapshot with a given name and optional description.
|
11
|
-
def create_snapshot(
|
12
|
-
task = client.vm_take_snapshot('instance_uuid' => uuid, 'name' => name, 'description' => description, 'memory' => include_ram)
|
13
|
+
def create_snapshot(host, name, description, include_ram = false)
|
14
|
+
task = client.vm_take_snapshot('instance_uuid' => host.uuid, 'name' => name, 'description' => description, 'memory' => include_ram)
|
13
15
|
task_successful?(task)
|
14
16
|
rescue RbVmomi::Fault => e
|
15
17
|
Foreman::Logging.exception('Error creating VMWare Snapshot', e)
|
@@ -19,7 +21,7 @@ module ForemanSnapshotManagement
|
|
19
21
|
# Remove Snapshot
|
20
22
|
#
|
21
23
|
# This method removes a Snapshot from a given host.
|
22
|
-
def remove_snapshot(snapshot, remove_children)
|
24
|
+
def remove_snapshot(snapshot, remove_children = false)
|
23
25
|
task = client.remove_snapshot('snapshot' => snapshot, 'removeChildren' => remove_children)
|
24
26
|
task_successful?(task)
|
25
27
|
rescue RbVmomi::Fault => e
|
@@ -52,23 +54,50 @@ module ForemanSnapshotManagement
|
|
52
54
|
# Get Snapshot
|
53
55
|
#
|
54
56
|
# This methods returns a specific Snapshot for a given host.
|
55
|
-
def get_snapshot(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
def get_snapshot(host, snapshot_id)
|
58
|
+
raw_snapshot = client.snapshots(server_id: host.uuid).get(snapshot_id)
|
59
|
+
raw_to_snapshot(host, raw_snapshot)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Get Snapshot by name
|
63
|
+
#
|
64
|
+
# This method returns a specific Snapshot for a given host.
|
65
|
+
def get_snapshot_by_name(host, name)
|
66
|
+
raw_snapshot = nil
|
67
|
+
client.snapshots(server_id: host.uuid).all(recursive: true).each do |snapshot|
|
68
|
+
if name == snapshot.name
|
69
|
+
raw_snapshot = snapshot
|
70
|
+
break
|
71
|
+
end
|
72
|
+
end
|
73
|
+
raw_to_snapshot(host, raw_snapshot)
|
61
74
|
end
|
62
75
|
|
63
76
|
# Get Snapshots
|
64
77
|
#
|
65
|
-
# This methods returns Snapshots
|
66
|
-
def get_snapshots(
|
67
|
-
client.snapshots(server_id:
|
78
|
+
# This methods returns Snapshots for a given host.
|
79
|
+
def get_snapshots(host)
|
80
|
+
client.snapshots(server_id: host.uuid).all(recursive: true).map do |raw_snapshot|
|
81
|
+
raw_to_snapshot(host, raw_snapshot)
|
82
|
+
end
|
68
83
|
end
|
69
84
|
|
70
85
|
private
|
71
86
|
|
87
|
+
def raw_to_snapshot(host, raw_snapshot, opts = {})
|
88
|
+
if raw_snapshot
|
89
|
+
Snapshot.new(
|
90
|
+
host: host,
|
91
|
+
id: raw_snapshot.ref,
|
92
|
+
raw_snapshot: raw_snapshot,
|
93
|
+
name: raw_snapshot.name,
|
94
|
+
description: raw_snapshot.description,
|
95
|
+
parent: opts[:parent],
|
96
|
+
create_time: raw_snapshot.create_time
|
97
|
+
)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
72
101
|
def task_successful?(task)
|
73
102
|
task['task_state'] == 'success' || task['state'] == 'success'
|
74
103
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
object @snapshot
|
2
4
|
|
3
5
|
extends 'api/v2/snapshots/base'
|
@@ -5,5 +7,5 @@ extends 'api/v2/snapshots/base'
|
|
5
7
|
attributes :description
|
6
8
|
|
7
9
|
node(:created_at, &:create_time)
|
8
|
-
node(:parent_id) { |snapshot| snapshot.parent.try(:id) }
|
9
|
-
node(:children_ids) { |snapshot| snapshot.children.map
|
10
|
+
node(:parent_id) { |snapshot| snapshot.try(:parent).try(:id) }
|
11
|
+
node(:children_ids) { |snapshot| snapshot.try(:children).try(:map, &:id) }
|
@@ -1,74 +1,12 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
<tr>
|
14
|
-
<td>
|
15
|
-
<%= f.text_field :name, class: 'form-control' %>
|
16
|
-
</td>
|
17
|
-
<td>
|
18
|
-
<%= f.text_field :description, class: 'form-control' %>
|
19
|
-
</td>
|
20
|
-
<td>
|
21
|
-
<%= f.check_box :include_ram, class: 'form-control' %>
|
22
|
-
</td>
|
23
|
-
<td>
|
24
|
-
<%= f.submit _('Create'), class: 'btn btn-success', :onclick => "$(this).attr('disabled', 'disabled'); $(this).parents('form').submit();" %>
|
25
|
-
</td>
|
26
|
-
</tr>
|
27
|
-
<% end %>
|
28
|
-
<% @snapshots.each do |snapshot| %>
|
29
|
-
<tr>
|
30
|
-
<td>
|
31
|
-
<% if authorized_for(:auth_object => @host, :permission => :edit_snapshots) %>
|
32
|
-
<%= edit_textfield snapshot, :name %>
|
33
|
-
<% else %>
|
34
|
-
<%= snapshot.name %>
|
35
|
-
<% end %>
|
36
|
-
<br /><%= snapshot.formatted_create_time() %>
|
37
|
-
</td>
|
38
|
-
<td>
|
39
|
-
<% if authorized_for(:auth_object => @host, :permission => :edit_snapshots) %>
|
40
|
-
<%= edit_textarea snapshot, :description %>
|
41
|
-
<% else %>
|
42
|
-
<%= snapshot.description %>
|
43
|
-
<% end %>
|
44
|
-
</td>
|
45
|
-
<td>
|
46
|
-
</td>
|
47
|
-
<td>
|
48
|
-
<%= action_buttons(
|
49
|
-
display_link_if_authorized(_('Rollback'), hash_for_revert_host_snapshot_path(host_id: @host, id: snapshot.id).merge(:auth_object => @host, :permission => :revert_snapshots), method: :put, class: 'btn btn-primary', data: {confirm: _('Are you sure to revert this Snapshot?'), 'disable-with': _('Reverting...')}),
|
50
|
-
display_delete_if_authorized(hash_for_host_snapshot_path(host_id: @host, id: snapshot.id).merge(:auth_object => @host, :permission => :destroy_snapshots), data: {confirm: _("Are you sure to delete this Snapshot?"), 'disable-with': _('Deleting...')}),
|
51
|
-
) %>
|
52
|
-
</td>
|
53
|
-
</tr>
|
54
|
-
<% end %>
|
55
|
-
</tbody>
|
56
|
-
</table>
|
57
|
-
<% end %>
|
58
|
-
|
59
|
-
<script type="text/javascript">
|
60
|
-
//<![CDATA[
|
61
|
-
$(document).ready(function() {
|
62
|
-
$('.editable').editable({
|
63
|
-
params: {
|
64
|
-
authenticity_token: AUTH_TOKEN
|
65
|
-
},
|
66
|
-
error: function(response) {
|
67
|
-
return $.parseJSON(response.responseText).errors;
|
68
|
-
}
|
69
|
-
});
|
70
|
-
var hash = window.location.hash;
|
71
|
-
hash && $('ul.nav a[href="' + hash + '"]').tab('show');
|
72
|
-
});
|
73
|
-
//]]>
|
74
|
-
</script>
|
1
|
+
<%= react_component('SnapshotManagement', {
|
2
|
+
host: @host,
|
3
|
+
canCreate: authorized_for(:auth_object => @host, :permission => :create_snapshots),
|
4
|
+
canUpdate: authorized_for(:auth_object => @host, :permission => :edit_snapshots),
|
5
|
+
canRevert: authorized_for(:auth_object => @host, :permission => :revert_snapshots),
|
6
|
+
canDelete: authorized_for(:auth_object => @host, :permission => :destroy_snapshots),
|
7
|
+
capabilities:
|
8
|
+
{
|
9
|
+
editableSnapshotName: @host.compute_resource.capable?(:editable_snapshot_name),
|
10
|
+
limitSnapshotNameFormat: @host.compute_resource.type == "ForemanFogProxmox::Proxmox"
|
11
|
+
}
|
12
|
+
}) %>
|