Class: Operation
- Inherits:
-
Object
show all
- Defined in:
- lib/satops/operator.rb
Direct Known Subclasses
Activationkeys, Channels, Configchannels, KickstartFilepreservations, KickstartKeys, KickstartSnippets, Kickstarts, OrgTrusts, Orgs, SystemCustominfos, Systemgroups, Systems, Users
Class Attribute Summary collapse
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#clone(sat, src_name, dst_name) ⇒ Object
-
#create(sat) ⇒ Object
-
#destroy(sat) ⇒ Object
-
#export(type, sat, path) ⇒ Object
-
#extra(src_sat, dst_sat) ⇒ Object
-
#import(type, sat, path) ⇒ Object
-
#initialize(log) ⇒ Operation
constructor
A new instance of Operation.
-
#postsync(src_sat, dst_sat) ⇒ Object
-
#presync(src_sat, dst_sat) ⇒ Object
-
#sync(src_sat, dst_sat) ⇒ Object
Constructor Details
#initialize(log) ⇒ Operation
Returns a new instance of Operation.
10
11
12
13
14
15
|
# File 'lib/satops/operator.rb', line 10
def initialize(log)
@family=Kernel.const_get(self.class.to_s+'Set')
@log=log
@log.info "Init #{self.class.to_s}"
end
|
Class Attribute Details
.update ⇒ Object
Returns the value of attribute update.
4
5
6
|
# File 'lib/satops/operator.rb', line 4
def update
@update
end
|
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
8
9
10
|
# File 'lib/satops/operator.rb', line 8
def log
@log
end
|
Instance Method Details
#clone(sat, src_name, dst_name) ⇒ Object
21
22
23
|
# File 'lib/satops/operator.rb', line 21
def clone(sat, src_name, dst_name)
@log.info "Cloning #{self.class}"
end
|
#create(sat) ⇒ Object
17
18
19
|
# File 'lib/satops/operator.rb', line 17
def create(sat)
@family.class_eval { return self.new(sat) }
end
|
#destroy(sat) ⇒ Object
25
26
27
28
29
|
# File 'lib/satops/operator.rb', line 25
def destroy(sat)
@log.info "Deleting #{self.class}"
satobjects=create(sat)
satobjects.delete_all
end
|
#export(type, sat, path) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/satops/operator.rb', line 31
def export(type, sat, path)
@log.info "Exporting #{self.class}"
satobjects=create(sat)
satobjects.fetch
case type
when :mrb
File.open("#{path}/#{self.class}.mrb", "w+") do |f|
Marshal.dump(satobjects.list, f)
end
when :yaml
File.open("#{path}/#{self.class}.yaml", "w+") do |f|
YAML.dump(satobjects.list, f)
end
end
end
|
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/satops/operator.rb', line 81
def (src_sat, dst_sat)
@log.info "Applying extra #{self.class}"
src_satobjects=create(src_sat)
src_satobjects.fetch
dst_satobjects=create(dst_sat)
dst_satobjects.fetch
=[]
=dst_satobjects-src_satobjects
dst_satobjects.() unless .empty?
end
|
#import(type, sat, path) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/satops/operator.rb', line 48
def import(type, sat, path)
@log.info "Importing #{self.class}"
satobjects=[]
case type
when :mrb
File.open("#{path}/#{self.class}.mrb") do |f|
satobjects = Marshal.load(f)
end
when :yaml
File.open("#{path}/#{self.class}.yaml") do |f|
satobjects = YAML.load(f)
end
end
dst_satobjects=create(sat)
dst_satobjects.fetch
unless satobjects.nil?
satobjects.each do |satobject|
if self.class.update && dst_satobjects.include?(satobject)
satobject.update(sat)
else
satobject.create(sat)
end
end
end
end
|
#postsync(src_sat, dst_sat) ⇒ Object
78
79
|
# File 'lib/satops/operator.rb', line 78
def postsync(src_sat, dst_sat)
end
|
#presync(src_sat, dst_sat) ⇒ Object
75
76
|
# File 'lib/satops/operator.rb', line 75
def presync(src_sat, dst_sat)
end
|
#sync(src_sat, dst_sat) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/satops/operator.rb', line 93
def sync(src_sat, dst_sat)
@log.info "Synchronizing #{self.class}"
src_satobjects=create(src_sat)
src_satobjects.fetch
dst_satobjects=create(dst_sat)
dst_satobjects.fetch
presync(src_sat, dst_sat)
unless src_satobjects.nil?
src_satobjects.list.each do |src_satobject|
if self.class.update && dst_satobjects.include?(src_satobject)
src_satobject.update(dst_sat)
else
src_satobject.create(dst_sat)
end
end
end
postsync(src_sat, dst_sat)
end
|