Class: TDLTools::ETDL
- Inherits:
-
Object
- Object
- TDLTools::ETDL
- Defined in:
- lib/etdl.rb
Instance Attribute Summary collapse
-
#cloud_attributes ⇒ Object
readonly
cloud attributes attr_reader :type, :provider, :username, :password, :keyname, :image, :ssh_cmd, :scp_cmd.
-
#instance_attributes ⇒ Object
readonly
instance attributes attr_reader :name, :description, :os, :repositories, :disk, :packages, :files, :commands.
-
#verify_cmds ⇒ Object
readonly
additional commands to verify instance.
Class Method Summary collapse
-
.parse(doc) ⇒ Object
Parse / return new eTDL instance from xml document.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ ETDL
constructor
A new instance of ETDL.
- #process(processor) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ ETDL
Returns a new instance of ETDL.
23 24 25 26 27 |
# File 'lib/etdl.rb', line 23 def initialize(args = {}) @cloud_attributes = args[:cloud_attributes] || {} @instance_attributes = args[:instance_attributes] || {} @verify_cmds = args[:verify_cmds] || [] end |
Instance Attribute Details
#cloud_attributes ⇒ Object (readonly)
cloud attributes attr_reader :type, :provider, :username, :password, :keyname, :image, :ssh_cmd, :scp_cmd
14 15 16 |
# File 'lib/etdl.rb', line 14 def cloud_attributes @cloud_attributes end |
#instance_attributes ⇒ Object (readonly)
instance attributes attr_reader :name, :description, :os, :repositories, :disk, :packages, :files, :commands
18 19 20 |
# File 'lib/etdl.rb', line 18 def instance_attributes @instance_attributes end |
#verify_cmds ⇒ Object (readonly)
additional commands to verify instance
21 22 23 |
# File 'lib/etdl.rb', line 21 def verify_cmds @verify_cmds end |
Class Method Details
.parse(doc) ⇒ Object
Parse / return new eTDL instance from xml document
30 31 32 33 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/etdl.rb', line 30 def self.parse(doc) cloud_attributes = {} instance_attributes = { :repositories => [], :packages => [], :files => [], :commands => [] } verify_cmds = [] doc.children.last.children.each { |c| if c.name == 'name' instance_attributes[:name] = c.text.strip elsif c.name == 'description' instance_attributes[:description] = c.text.strip elsif c.name == 'cloud' c.children.each { |ca| cloud_attributes[ca.name.intern] = ca.text.strip } elsif c.name == 'os' instance_attributes[:os] = {} c.children.each { |cc| instance_attributes[:os][cc.name] = cc.text.strip } # TODO c.name == 'disk' elsif c.name == 'repositories' c.children.each { |repo| unless repo['name'].nil? instance_attributes[:repositories] << { :name => repo['name'], :url => repo['url'] } end } elsif c.name == 'packages' c.children.each { |pkg| unless pkg['name'].nil? instance_attributes[:packages] << pkg['name'] end } elsif c.name == 'files' c.children.each { |file| unless file['name'].nil? instance_attributes[:files] << {:name => file['name'], :contents => file.text.strip} end } elsif c.name == 'commands' c.children.each { |cmd| unless cmd.name != "command" instance_attributes[:commands] << {:cmd => cmd.text.strip} end } elsif c.name == 'verify' c.children.each { |cmd| unless cmd.name != "command" ccmd = cmd.text.strip verify_cmds << ccmd unless ccmd.nil? || ccmd == "" end } end } #pp instance_attributes #pp cloud_attributes #pp verify_cmds etdl = ETDL.new :cloud_attributes => cloud_attributes, :instance_attributes => instance_attributes, :verify_cmds => verify_cmds end |
Instance Method Details
#process(processor) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/etdl.rb', line 105 def process(processor) instance = processor.launch_instance(self) processor.process(self, instance) processor.verify(self, instance) processor.terminate_instance(instance) end |