foreman_snapshot_management 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30f8e2f14c91a5cf8d79a5c39ae5d65bcf9df35b
|
4
|
+
data.tar.gz: 2b0299b2785eba2d00c7d4e5fc901532d72647d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4854c380a31a34c47df1cae2040e3c6720b69337b0d0298a1b33dab96034796a5999731d24e417ef8348235e5c2c3b99f890de5a2f7e0a2c35421bf54b541206
|
7
|
+
data.tar.gz: 276fa74482b40f90600e250ca1ddc57308ce4d241ebe835d8d3e7c5af95e28ac207dbb65341fb44bda75cc8824f78ba1f083cbbdd197c4d3faab694beb450a8f
|
@@ -10,6 +10,7 @@ module ForemanSnapshotManagement
|
|
10
10
|
|
11
11
|
define_model_callbacks :create, :save, :destroy, :revert
|
12
12
|
attr_accessor :id, :raw_snapshot, :name, :description, :host_id, :parent, :create_time
|
13
|
+
define_attribute_methods :name, :description
|
13
14
|
|
14
15
|
def self.all_for_host(host)
|
15
16
|
snapshots = host.compute_resource.get_snapshots(host.uuid).map do |raw_snapshot|
|
@@ -19,7 +20,7 @@ module ForemanSnapshotManagement
|
|
19
20
|
|
20
21
|
def self.find_for_host(host, id)
|
21
22
|
raw_snapshot = host.compute_resource.get_snapshot(host.uuid, id)
|
22
|
-
new_from_vmware(host, raw_snapshot)
|
23
|
+
new_from_vmware(host, raw_snapshot) if raw_snapshot
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.new_from_vmware(host, raw_snapshot, opts = {})
|
@@ -55,16 +56,36 @@ module ForemanSnapshotManagement
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def persisted?
|
58
|
-
|
59
|
+
@id.present?
|
60
|
+
end
|
61
|
+
|
62
|
+
def name=(value)
|
63
|
+
name_will_change! unless value == @name
|
64
|
+
@name = value
|
65
|
+
end
|
66
|
+
|
67
|
+
def description=(value)
|
68
|
+
description_will_change! unless value == @description
|
69
|
+
@description = value
|
59
70
|
end
|
60
71
|
|
61
72
|
# host accessors
|
62
73
|
def host
|
63
|
-
Host.find(
|
74
|
+
@host ||= Host.find(@host_id)
|
75
|
+
end
|
76
|
+
|
77
|
+
def host_id=(host_id)
|
78
|
+
if @host_id != host_id
|
79
|
+
@host_id = host_id
|
80
|
+
@host = nil
|
81
|
+
end
|
64
82
|
end
|
65
83
|
|
66
84
|
def host=(host)
|
67
|
-
|
85
|
+
if @host_id != host.id
|
86
|
+
@host_id = host.id
|
87
|
+
@host = host
|
88
|
+
end
|
68
89
|
end
|
69
90
|
|
70
91
|
def create_time
|
@@ -81,14 +102,17 @@ module ForemanSnapshotManagement
|
|
81
102
|
|
82
103
|
def update_attributes(new_attributes)
|
83
104
|
assign_attributes(new_attributes)
|
84
|
-
save
|
105
|
+
save if changed?
|
85
106
|
end
|
86
107
|
|
87
108
|
# crud
|
88
109
|
def create
|
89
110
|
run_callbacks(:create) do
|
90
111
|
handle_snapshot_errors do
|
112
|
+
host.audit_comment = "Create snapshot #{name}"
|
113
|
+
host.save!
|
91
114
|
host.compute_resource.create_snapshot(host.uuid, name, description)
|
115
|
+
changes_applied
|
92
116
|
end
|
93
117
|
end
|
94
118
|
end
|
@@ -96,7 +120,10 @@ module ForemanSnapshotManagement
|
|
96
120
|
def save
|
97
121
|
run_callbacks(:save) do
|
98
122
|
handle_snapshot_errors do
|
123
|
+
host.audit_comment = "Update snapshot #{name}"
|
124
|
+
host.save!
|
99
125
|
host.compute_resource.update_snapshot(raw_snapshot, name, description)
|
126
|
+
changes_applied
|
100
127
|
end
|
101
128
|
end
|
102
129
|
end
|
@@ -104,9 +131,11 @@ module ForemanSnapshotManagement
|
|
104
131
|
def destroy
|
105
132
|
run_callbacks(:destroy) do
|
106
133
|
result = handle_snapshot_errors do
|
134
|
+
host.audit_comment = "Destroy snapshot #{name}"
|
135
|
+
host.save!
|
107
136
|
result = host.compute_resource.remove_snapshot(raw_snapshot, false)
|
108
137
|
end
|
109
|
-
|
138
|
+
@id = nil
|
110
139
|
result
|
111
140
|
end
|
112
141
|
end
|
@@ -114,6 +143,8 @@ module ForemanSnapshotManagement
|
|
114
143
|
def revert
|
115
144
|
run_callbacks(:revert) do
|
116
145
|
handle_snapshot_errors do
|
146
|
+
host.audit_comment = "Revert snapshot #{name}"
|
147
|
+
host.save!
|
117
148
|
host.compute_resource.revert_snapshot(raw_snapshot)
|
118
149
|
end
|
119
150
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_snapshot_management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ATIX AG
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|