Class: Gear
- Inherits:
-
OpenShift::Model
- Object
- OpenShift::Model
- Gear
- Defined in:
- app/models/gear.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#configured_components ⇒ Object
Returns the value of attribute configured_components.
-
#container ⇒ Object
Returns the value of attribute container.
-
#group_instance_name ⇒ Object
Returns the value of attribute group_instance_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node_profile ⇒ Object
Returns the value of attribute node_profile.
-
#server_identity ⇒ Object
Returns the value of attribute server_identity.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
- #add_alias(server_alias) ⇒ Object
- #add_authorized_ssh_key(ssh_key, key_type = nil, comment = nil) ⇒ Object
- #add_broker_auth_key(iv, token) ⇒ Object
- #add_env_var(key, value) ⇒ Object
- #app_state_job_show ⇒ Object
- #broker_auth_key_job_add(iv, token) ⇒ Object
- #broker_auth_key_job_remove ⇒ Object
- #cartridges ⇒ Object
- #conceal_port(comp_inst) ⇒ Object
- #configure(comp_inst, template_git_url = nil) ⇒ Object
- #create ⇒ Object
- #deconfigure(comp_inst, force = false) ⇒ Object
- #destroy ⇒ Object
- #env_var_job_add(key, value) ⇒ Object
- #env_var_job_remove(key) ⇒ Object
- #execute_connector(comp_inst, connector_name, input_args) ⇒ Object
- #expose_port(comp_inst) ⇒ Object
- #force_destroy ⇒ Object
- #force_stop(comp_inst) ⇒ Object
- #gear_quota_job_show ⇒ Object
- #gear_quota_job_update(storage_in_gb, inodes) ⇒ Object
- #get_execute_connector_job(cart, connector_name, input_args) ⇒ Object
- #get_proxy ⇒ Object
- #get_quota ⇒ Object
- #group_instance ⇒ Object
-
#initialize(app, group_instance, uuid = nil, uid = nil) ⇒ Gear
constructor
A new instance of Gear.
- #prepare_namespace_update(dns_service, new_ns, old_ns) ⇒ Object
- #reload(comp_inst) ⇒ Object
- #remove_alias(server_alias) ⇒ Object
- #remove_authorized_ssh_key(ssh_key, comment = nil) ⇒ Object
- #remove_broker_auth_key ⇒ Object
- #remove_env_var(key) ⇒ Object
- #restart(comp_inst) ⇒ Object
- #set_quota(storage_in_gb, inodes) ⇒ Object
- #show_port(comp_inst) ⇒ Object
- #show_state ⇒ Object
- #ssh_key_job_add(ssh_key, ssh_key_type, ssh_key_comment) ⇒ Object
- #ssh_key_job_remove(ssh_key, ssh_key_comment) ⇒ Object
- #start(comp_inst) ⇒ Object
- #status(comp_inst) ⇒ Object
- #status_job(comp_inst) ⇒ Object
- #stop(comp_inst) ⇒ Object
- #system_messages(comp_inst) ⇒ Object
- #threaddump(comp_inst) ⇒ Object
- #tidy(comp_inst) ⇒ Object
Constructor Details
#initialize(app, group_instance, uuid = nil, uid = nil) ⇒ Gear
Returns a new instance of Gear.
6 7 8 9 10 11 12 13 14 15 |
# File 'app/models/gear.rb', line 6 def initialize(app, group_instance, uuid=nil, uid=nil) self.app = app @uuid = uuid || OpenShift::Model.gen_uuid self.name = @uuid[0..9] self.group_instance_name = group_instance.name self.node_profile = group_instance.node_profile self.configured_components = [] @uid = uid get_proxy end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
2 3 4 |
# File 'app/models/gear.rb', line 2 def app @app end |
#configured_components ⇒ Object
Returns the value of attribute configured_components.
2 3 4 |
# File 'app/models/gear.rb', line 2 def configured_components @configured_components end |
#container ⇒ Object
Returns the value of attribute container.
2 3 4 |
# File 'app/models/gear.rb', line 2 def container @container end |
#group_instance_name ⇒ Object
Returns the value of attribute group_instance_name.
2 3 4 |
# File 'app/models/gear.rb', line 2 def group_instance_name @group_instance_name end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'app/models/gear.rb', line 2 def name @name end |
#node_profile ⇒ Object
Returns the value of attribute node_profile.
2 3 4 |
# File 'app/models/gear.rb', line 2 def node_profile @node_profile end |
#server_identity ⇒ Object
Returns the value of attribute server_identity.
2 3 4 |
# File 'app/models/gear.rb', line 2 def server_identity @server_identity end |
#uid ⇒ Object
Returns the value of attribute uid.
2 3 4 |
# File 'app/models/gear.rb', line 2 def uid @uid end |
#uuid ⇒ Object
Returns the value of attribute uuid.
2 3 4 |
# File 'app/models/gear.rb', line 2 def uuid @uuid end |
Class Method Details
.gear_sizes_display_string ⇒ Object
345 346 347 348 349 350 351 352 353 354 |
# File 'app/models/gear.rb', line 345 def self.gear_sizes_display_string # Ex: (small(default)|jumbo|exlarge|large|medium|micro) out = '(' Rails.configuration.openshift[:gear_sizes].each_with_index do |gear_size, index| out += gear_size out += '(default)' if gear_size == Rails.configuration.openshift[:default_gear_size] out += '|' unless index == (Rails.configuration.openshift[:gear_sizes].length - 1) end out += ')' end |
.valid_gear_size?(gear_size) ⇒ Boolean
341 342 343 |
# File 'app/models/gear.rb', line 341 def self.valid_gear_size?(gear_size) Rails.configuration.openshift[:gear_sizes].include?(gear_size) end |
Instance Method Details
#add_alias(server_alias) ⇒ Object
195 196 197 198 199 200 201 |
# File 'app/models/gear.rb', line 195 def add_alias(server_alias) if app.gear.uuid == self.uuid get_proxy.add_alias(app, self, server_alias) else ResultIO.new end end |
#add_authorized_ssh_key(ssh_key, key_type = nil, comment = nil) ⇒ Object
211 212 213 |
# File 'app/models/gear.rb', line 211 def (ssh_key, key_type=nil, comment=nil) get_proxy.(app, self, ssh_key, key_type, comment) end |
#add_broker_auth_key(iv, token) ⇒ Object
280 281 282 |
# File 'app/models/gear.rb', line 280 def add_broker_auth_key(iv,token) get_proxy.add_broker_auth_key(app, self, iv, token) end |
#add_env_var(key, value) ⇒ Object
219 220 221 |
# File 'app/models/gear.rb', line 219 def add_env_var(key, value) get_proxy.add_env_var(app, self, key, value) end |
#app_state_job_show ⇒ Object
241 242 243 244 |
# File 'app/models/gear.rb', line 241 def app_state_job_show() job = get_proxy.get_show_state_job(app, self) job end |
#broker_auth_key_job_add(iv, token) ⇒ Object
256 257 258 259 |
# File 'app/models/gear.rb', line 256 def broker_auth_key_job_add(iv, token) job = get_proxy.get_broker_auth_key_add_job(app, self, iv, token) job end |
#broker_auth_key_job_remove ⇒ Object
271 272 273 274 |
# File 'app/models/gear.rb', line 271 def broker_auth_key_job_remove() job = get_proxy.get_broker_auth_key_remove_job(app, self) job end |
#cartridges ⇒ Object
288 289 290 291 292 293 |
# File 'app/models/gear.rb', line 288 def cartridges gi = group_instance carts = gi.component_instances.map{ |comp_instance_name| app.comp_instance_map[comp_instance_name].parent_cart_name } carts.delete(app.name) carts end |
#conceal_port(comp_inst) ⇒ Object
179 180 181 |
# File 'app/models/gear.rb', line 179 def conceal_port(comp_inst) get_proxy.conceal_port(app, self, comp_inst.parent_cart_name) end |
#configure(comp_inst, template_git_url = nil) ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'app/models/gear.rb', line 111 def configure(comp_inst, template_git_url=nil) r = ResultIO.new return r if self.configured_components.include?(comp_inst.name) result_io, cart_data = get_proxy.configure_cartridge(app, self, comp_inst.parent_cart_name, template_git_url) r.append result_io comp_inst.process_cart_data(cart_data) comp_inst.process_cart_properties(result_io.cart_properties) self.configured_components.push(comp_inst.name) r end |
#create ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/models/gear.rb', line 34 def create if server_identity.nil? ret = nil begin self.app.ngears += 1 self.container = OpenShift::ApplicationContainerProxy.find_available(self.node_profile) self.server_identity = self.container.id self.uid = self.container.reserve_uid self.group_instance.gears << self self.app.save ret = self.container.create(app,self) self.app.track_usage(self, UsageRecord::EVENTS[:begin]) if ret.exitcode == 0 rescue Exception => e Rails.logger.debug e. Rails.logger.debug e.backtrace.join("\n") ret = ResultIO.new ret.errorIO << e. ret.exitcode = 5 end ## recovery action if creation failed above if ret.exitcode != 0 begin get_proxy.destroy(self.app, self) rescue Exception => e end self.app.ngears -= 1 self.group_instance.gears.delete(self) self.app.save raise OpenShift::NodeException.new("Unable to create gear on node", 1, ret) end return ret end end |
#deconfigure(comp_inst, force = false) ⇒ Object
122 123 124 125 126 127 128 |
# File 'app/models/gear.rb', line 122 def deconfigure(comp_inst, force=false) r = ResultIO.new return r unless self.configured_components.include?(comp_inst.name) or force r.append get_proxy.deconfigure_cartridge(app,self,comp_inst.parent_cart_name) self.configured_components.delete(comp_inst.name) r end |
#destroy ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/models/gear.rb', line 69 def destroy ret = get_proxy.destroy(app, self) if ret.exitcode == 0 self.app.destroyed_gears = [] unless self.app.destroyed_gears self.app.destroyed_gears << @uuid track_destroy_usage self.app.ngears -= 1 self.group_instance.gears.delete(self) app.process_cartridge_commands(ret) self.app.save else raise OpenShift::NodeException.new("Unable to destroy gear on node", 1, ret) end return ret end |
#env_var_job_add(key, value) ⇒ Object
246 247 248 249 |
# File 'app/models/gear.rb', line 246 def env_var_job_add(key, value) job = get_proxy.get_env_var_add_job(app, self, key, value) job end |
#env_var_job_remove(key) ⇒ Object
261 262 263 264 |
# File 'app/models/gear.rb', line 261 def env_var_job_remove(key) job = get_proxy.get_env_var_remove_job(app, self, key) job end |
#execute_connector(comp_inst, connector_name, input_args) ⇒ Object
130 131 132 |
# File 'app/models/gear.rb', line 130 def execute_connector(comp_inst, connector_name, input_args) get_proxy.execute_connector(app, self, comp_inst.parent_cart_name, connector_name, input_args) end |
#expose_port(comp_inst) ⇒ Object
175 176 177 |
# File 'app/models/gear.rb', line 175 def expose_port(comp_inst) get_proxy.expose_port(app, self, comp_inst.parent_cart_name) end |
#force_destroy ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/models/gear.rb', line 85 def force_destroy ret = nil begin begin ret = get_proxy.destroy(app, self) rescue Exception => e Rails.logger.error("ERROR: Ignoring a failed destroy for gear with uuid: #{uuid}") end self.app.destroyed_gears = [] unless self.app.destroyed_gears self.app.destroyed_gears << @uuid track_destroy_usage ensure self.app.ngears -= 1 self.group_instance.gears.delete(self) if ret begin app.process_cartridge_commands(ret) rescue Exception => e Rails.logger.error("ERROR: Ignoring a failed process_cartridge_commands for gear with uuid: #{uuid}") end end self.app.save end return ret end |
#force_stop(comp_inst) ⇒ Object
150 151 152 |
# File 'app/models/gear.rb', line 150 def force_stop(comp_inst) get_proxy.force_stop(app, self, comp_inst.parent_cart_name) end |
#gear_quota_job_show ⇒ Object
231 232 233 234 |
# File 'app/models/gear.rb', line 231 def gear_quota_job_show() job = get_proxy.get_show_gear_quota_job(self) job end |
#gear_quota_job_update(storage_in_gb, inodes) ⇒ Object
236 237 238 239 |
# File 'app/models/gear.rb', line 236 def gear_quota_job_update(storage_in_gb, inodes) job = get_proxy.get_update_gear_quota_job(self, storage_in_gb, inodes) job end |
#get_execute_connector_job(cart, connector_name, input_args) ⇒ Object
134 135 136 |
# File 'app/models/gear.rb', line 134 def get_execute_connector_job(cart, connector_name, input_args) get_proxy.get_execute_connector_job(app, self, cart, connector_name, input_args) end |
#get_proxy ⇒ Object
27 28 29 30 31 32 |
# File 'app/models/gear.rb', line 27 def get_proxy if self.container.nil? and !@server_identity.nil? self.container = OpenShift::ApplicationContainerProxy.instance(@server_identity) end return self.container end |
#get_quota ⇒ Object
227 228 229 |
# File 'app/models/gear.rb', line 227 def get_quota() get_proxy.get_quota(self) end |
#group_instance ⇒ Object
295 296 297 |
# File 'app/models/gear.rb', line 295 def group_instance self.app.group_instance_map[self.group_instance_name] end |
#prepare_namespace_update(dns_service, new_ns, old_ns) ⇒ Object
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'app/models/gear.rb', line 312 def prepare_namespace_update(dns_service, new_ns, old_ns) results = [] gi = group_instance contains_proxy = false contains_framework = false result_io = ResultIO.new gi.component_instances.each do |cname| ci = self.app.comp_instance_map[cname] contains_proxy = true if ci.parent_cart_name == self.app.proxy_cartridge contains_framework = true if ci.parent_cart_name == self.app.framework end if contains_proxy || !self.app.scalable #proxy gear gets public dns register_application(dns_service, old_ns, new_ns, self.app.name) else #non-proxy gear gets gear specific dns register_application(dns_service, old_ns, new_ns, self.name) end if contains_framework result_io.append call_update_namespace_hook(self.app.framework, new_ns, old_ns) else result_io.append call_update_namespace_hook("abstract", new_ns, old_ns) end result_io end |
#reload(comp_inst) ⇒ Object
154 155 156 |
# File 'app/models/gear.rb', line 154 def reload(comp_inst) get_proxy.reload(app, self, comp_inst.parent_cart_name) end |
#remove_alias(server_alias) ⇒ Object
203 204 205 206 207 208 209 |
# File 'app/models/gear.rb', line 203 def remove_alias(server_alias) if app.gear.uuid == self.uuid get_proxy.remove_alias(app, self, server_alias) else ResultIO.new end end |
#remove_authorized_ssh_key(ssh_key, comment = nil) ⇒ Object
215 216 217 |
# File 'app/models/gear.rb', line 215 def (ssh_key, comment=nil) get_proxy.(app, self, ssh_key, comment) end |
#remove_broker_auth_key ⇒ Object
284 285 286 |
# File 'app/models/gear.rb', line 284 def remove_broker_auth_key get_proxy.remove_broker_auth_key(app, self) end |
#remove_env_var(key) ⇒ Object
276 277 278 |
# File 'app/models/gear.rb', line 276 def remove_env_var(key) get_proxy.remove_env_var(app, self, key) end |
#restart(comp_inst) ⇒ Object
146 147 148 |
# File 'app/models/gear.rb', line 146 def restart(comp_inst) get_proxy.restart(app, self, comp_inst.parent_cart_name) end |
#set_quota(storage_in_gb, inodes) ⇒ Object
223 224 225 |
# File 'app/models/gear.rb', line 223 def set_quota(storage_in_gb, inodes) get_proxy.set_quota(self, storage_in_gb, inodes) end |
#show_port(comp_inst) ⇒ Object
183 184 185 |
# File 'app/models/gear.rb', line 183 def show_port(comp_inst) get_proxy.show_port(app, self, comp_inst.parent_cart_name) end |
#show_state ⇒ Object
167 168 169 |
# File 'app/models/gear.rb', line 167 def show_state() get_proxy.show_state(app, self) end |
#ssh_key_job_add(ssh_key, ssh_key_type, ssh_key_comment) ⇒ Object
251 252 253 254 |
# File 'app/models/gear.rb', line 251 def ssh_key_job_add(ssh_key, ssh_key_type, ssh_key_comment) job = get_proxy.(app, self, ssh_key, ssh_key_type, ssh_key_comment) job end |
#ssh_key_job_remove(ssh_key, ssh_key_comment) ⇒ Object
266 267 268 269 |
# File 'app/models/gear.rb', line 266 def ssh_key_job_remove(ssh_key, ssh_key_comment) job = get_proxy.(app, self, ssh_key, ssh_key_comment) job end |
#start(comp_inst) ⇒ Object
138 139 140 |
# File 'app/models/gear.rb', line 138 def start(comp_inst) get_proxy.start(app, self, comp_inst.parent_cart_name) end |
#status(comp_inst) ⇒ Object
158 159 160 |
# File 'app/models/gear.rb', line 158 def status(comp_inst) get_proxy.status(app, self, comp_inst.parent_cart_name) end |
#status_job(comp_inst) ⇒ Object
162 163 164 165 |
# File 'app/models/gear.rb', line 162 def status_job(comp_inst) job = get_proxy.get_status_job(app, self, comp_inst.parent_cart_name) job end |
#stop(comp_inst) ⇒ Object
142 143 144 |
# File 'app/models/gear.rb', line 142 def stop(comp_inst) get_proxy.stop(app, self, comp_inst.parent_cart_name) end |
#system_messages(comp_inst) ⇒ Object
191 192 193 |
# File 'app/models/gear.rb', line 191 def (comp_inst) get_proxy.(app, self, comp_inst.parent_cart_name) end |
#threaddump(comp_inst) ⇒ Object
187 188 189 |
# File 'app/models/gear.rb', line 187 def threaddump(comp_inst) get_proxy.threaddump(app, self, comp_inst.parent_cart_name) end |
#tidy(comp_inst) ⇒ Object
171 172 173 |
# File 'app/models/gear.rb', line 171 def tidy(comp_inst) get_proxy.tidy(app, self, comp_inst.parent_cart_name) end |