Class: Puppet::Util::AgentilSystem
- Inherits:
-
Object
- Object
- Puppet::Util::AgentilSystem
- Defined in:
- lib/puppet/util/agentil_system.rb
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#system_template_id ⇒ Object
readonly
Returns the value of attribute system_template_id.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #ccms_mode ⇒ Object
- #ccms_mode=(new_value) ⇒ Object
- #client ⇒ Object
- #client=(new_value) ⇒ Object
- #group ⇒ Object
- #group=(new_value) ⇒ Object
- #host ⇒ Object
- #host=(new_value) ⇒ Object
-
#initialize(id, element) ⇒ AgentilSystem
constructor
A new instance of AgentilSystem.
- #ip ⇒ Object
- #ip=(new_value) ⇒ Object
- #landscape ⇒ Object
- #landscape=(new_value) ⇒ Object
- #name ⇒ Object
- #name=(new_value) ⇒ Object
- #sid ⇒ Object
- #sid=(new_value) ⇒ Object
- #stack ⇒ Object
- #stack=(new_value) ⇒ Object
- #system_template ⇒ Object
- #system_template=(new_value) ⇒ Object
- #templates ⇒ Object
- #templates=(new_values) ⇒ Object
- #user ⇒ Object
- #user=(new_value) ⇒ Object
Constructor Details
#initialize(id, element) ⇒ AgentilSystem
Returns a new instance of AgentilSystem.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/puppet/util/agentil_system.rb', line 10 def initialize(id, element) @id = id @element = element if template_section = @element['TEMPLATES'] @template_ids = template_section.map(&:to_i) else @template_ids = [] end if system_template_attribute = @element['DEFAULT_TEMPLATE'] @system_template_id = system_template_attribute.to_i end if user_attribute = @element['USER_PROFILE'] @user_id = user_attribute.to_i end end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
8 9 10 |
# File 'lib/puppet/util/agentil_system.rb', line 8 def element @element end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/puppet/util/agentil_system.rb', line 8 def id @id end |
#system_template_id ⇒ Object (readonly)
Returns the value of attribute system_template_id.
8 9 10 |
# File 'lib/puppet/util/agentil_system.rb', line 8 def system_template_id @system_template_id end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
8 9 10 |
# File 'lib/puppet/util/agentil_system.rb', line 8 def user_id @user_id end |
Instance Method Details
#ccms_mode ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/puppet/util/agentil_system.rb', line 69 def ccms_mode if mode = @element['CCMS_STRICT_MODE'] and mode == 'true' :strict else :aggregated end end |
#ccms_mode=(new_value) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/puppet/util/agentil_system.rb', line 77 def ccms_mode=(new_value) case new_value when :strict @element['CCMS_STRICT_MODE'] = 'true' when :aggregated @element['CCMS_STRICT_MODE'] = 'false' end end |
#client ⇒ Object
94 95 96 |
# File 'lib/puppet/util/agentil_system.rb', line 94 def client @element['ABAP_CLIENT_NUMBER'] end |
#client=(new_value) ⇒ Object
98 99 100 |
# File 'lib/puppet/util/agentil_system.rb', line 98 def client=(new_value) @element['ABAP_CLIENT_NUMBER'] = new_value end |
#group ⇒ Object
102 103 104 |
# File 'lib/puppet/util/agentil_system.rb', line 102 def group @element['GROUP'] end |
#group=(new_value) ⇒ Object
106 107 108 |
# File 'lib/puppet/util/agentil_system.rb', line 106 def group=(new_value) @element['GROUP'] = new_value end |
#host ⇒ Object
37 38 39 |
# File 'lib/puppet/util/agentil_system.rb', line 37 def host @element['HOST'] end |
#host=(new_value) ⇒ Object
41 42 43 |
# File 'lib/puppet/util/agentil_system.rb', line 41 def host=(new_value) @element['HOST'] = new_value end |
#ip ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/puppet/util/agentil_system.rb', line 110 def ip if ips_element = @element['INSTANCE_IPS'] ips_element.dup else [] end end |
#ip=(new_value) ⇒ Object
118 119 120 121 122 123 124 |
# File 'lib/puppet/util/agentil_system.rb', line 118 def ip=(new_value) if new_value.empty? @element.delete('INSTANCE_IPS') else @element['INSTANCE_IPS'] = new_value.dup end end |
#landscape ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/puppet/util/agentil_system.rb', line 126 def landscape if id = @element['PARENT_ID'] if landscape = Puppet::Util::Agentil.landscapes[id.to_i] landscape else raise Puppet::Error, "Landscape with id=#{id} could not be found" end else raise Puppet::Error, 'System does not have a PARENT_ID attribute' end end |
#landscape=(new_value) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/puppet/util/agentil_system.rb', line 138 def landscape=(new_value) new_landscape = case new_value when Puppet::Util::AgentilLandscape new_value when Fixnum Puppet::Util::Agentil.landscapes[new_value] when String Puppet::Util::Agentil.landscapes.values.find { |l| l.name == new_value } end raise Puppet::Error, "Landscape #{new_value} not found" unless new_landscape if landscape_id = @element['PARENT_ID'] Puppet::Util::Agentil.landscapes[landscape_id.to_i].deassign_system id end new_landscape.assign_system id @element['PARENT_ID'] = new_landscape.id.to_s end |
#name ⇒ Object
29 30 31 |
# File 'lib/puppet/util/agentil_system.rb', line 29 def name @element['NAME'] end |
#name=(new_value) ⇒ Object
33 34 35 |
# File 'lib/puppet/util/agentil_system.rb', line 33 def name=(new_value) @element['NAME'] = new_value end |
#sid ⇒ Object
86 87 88 |
# File 'lib/puppet/util/agentil_system.rb', line 86 def sid @element['SYSTEM_ID'] end |
#sid=(new_value) ⇒ Object
90 91 92 |
# File 'lib/puppet/util/agentil_system.rb', line 90 def sid=(new_value) @element['SYSTEM_ID'] = new_value end |
#stack ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/puppet/util/agentil_system.rb', line 45 def stack if @element['ABAP_ENABLED'] == 'true' and @element['JAVA_ENABLED'] == 'true' :dual elsif @element['JAVA_ENABLED'] == 'true' :java else :abap end end |
#stack=(new_value) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/puppet/util/agentil_system.rb', line 55 def stack=(new_value) case new_value when :dual @element['ABAP_ENABLED'] = 'true' @element['JAVA_ENABLED'] = 'true' when :java @element['ABAP_ENABLED'] = 'false' @element['JAVA_ENABLED'] = 'true' else @element['ABAP_ENABLED'] = 'true' @element['JAVA_ENABLED'] = 'false' end end |
#system_template ⇒ Object
191 192 193 194 195 196 197 198 199 |
# File 'lib/puppet/util/agentil_system.rb', line 191 def system_template if @system_template_id if template = Puppet::Util::Agentil.templates[@system_template_id] template else raise Puppet::Error, "System template with id=#{@system_template_id} not found" end end end |
#system_template=(new_value) ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/puppet/util/agentil_system.rb', line 201 def system_template=(new_value) new_system_template = case new_value when Puppet::Util::AgentilTemplate new_value when Fixnum Puppet::Util::Agentil.templates[new_value] when String Puppet::Util::Agentil.templates.values.find { |t| t.name == new_value } end raise Puppet::Error, "Template #{new_value} not found" unless new_system_template @system_template_id = new_system_template.id @element['DEFAULT_TEMPLATE'] = @system_template_id.to_s end |
#templates ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/puppet/util/agentil_system.rb', line 158 def templates @template_ids.map do |id| if template = Puppet::Util::Agentil.templates[id] template else raise Puppet::Error, "Template with id=#{id} could not be found" end end end |
#templates=(new_values) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/puppet/util/agentil_system.rb', line 168 def templates=(new_values) if new_values.empty? @element.delete('TEMPLATES') @template_ids.clear else @template_ids = new_values.map do |new_value| template = case new_value when Puppet::Util::AgentilTemplate new_value when Fixnum Puppet::Util::Agentil.templates[new_value] when String Puppet::Util::Agentil.templates.values.find { |t| t.name == new_value } end raise Puppet::Error, "Template #{new_value} not found" unless template template.id end @element['TEMPLATES'] = @template_ids.dup end end |
#user ⇒ Object
218 219 220 221 222 223 224 225 226 |
# File 'lib/puppet/util/agentil_system.rb', line 218 def user if @user_id if user = Puppet::Util::Agentil.users[@user_id] user else raise Puppet::Error, "User with id=#{@user_id} not found" end end end |
#user=(new_value) ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/puppet/util/agentil_system.rb', line 228 def user=(new_value) new_user = case new_value when Puppet::Util::AgentilUser new_value when Fixnum Puppet::Util::Agentil.users[new_value] when String Puppet::Util::Agentil.users.values.find { |u| u.name == new_value } end raise Puppet::Error, "Unable to find user #{new_value}" unless new_user @user_id = new_user.id @element['USER_PROFILE'] = @user_id.to_s end |