Class: LabManager
- Inherits:
-
Object
- Object
- LabManager
- Defined in:
- lib/lab_manager.rb
Overview
Lab Manager API
Configure using configure method:
LabManager.url = "YOUR URL"
Constant Summary collapse
- @@DEBUG =
false
Instance Attribute Summary collapse
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Class Method Summary collapse
- .configPath ⇒ Object
- .configPath=(value) ⇒ Object
- .DEBUG=(value) ⇒ Object
- .password ⇒ Object
- .reset ⇒ Object
- .url ⇒ Object
- .url=(value) ⇒ Object
- .username ⇒ Object
Instance Method Summary collapse
-
#checkout(configuration_name, new_configuration_name) ⇒ Object
Clones a configuration from a library.
-
#clone(configuration_name, new_configuration_name) ⇒ Object
Clone a configuration to a new name.
-
#configuration(name_or_id) ⇒ Object
Retrieve configuration information.
-
#configurations ⇒ Object
Retrieve a list of configuration information.
-
#delete(configuration_name, options = {}) ⇒ Object
Delete a configuration.
-
#initialize(organization, username = nil, password = nil, url = nil) ⇒ LabManager
constructor
A new instance of LabManager.
-
#machine(configuration_name, machineName) ⇒ Object
Retrieve the informaiton for a single machine in a configuration.
-
#machines(configuration_name, options = {}) ⇒ Object
Retrieve a list of machines in a configuration.
-
#revert(configuration_name) ⇒ Object
Revert a configuratoin to its original state.
-
#undeploy(configuration_name) ⇒ Object
Undeploys a configuration.
Constructor Details
#initialize(organization, username = nil, password = nil, url = nil) ⇒ LabManager
Returns a new instance of LabManager.
61 62 63 64 65 66 67 68 |
# File 'lib/lab_manager.rb', line 61 def initialize(organization, username = nil, password = nil, url = nil) load_config(url, username, password) raise "Missing url" if @@url.nil? raise "Missing username" if @@username.nil? raise "Missing password" if @@password.nil? @organization = organization end |
Instance Attribute Details
#workspace ⇒ Object
Returns the value of attribute workspace.
59 60 61 |
# File 'lib/lab_manager.rb', line 59 def workspace @workspace end |
Class Method Details
.configPath ⇒ Object
30 31 32 |
# File 'lib/lab_manager.rb', line 30 def self.configPath @@configPath end |
.configPath=(value) ⇒ Object
33 34 35 |
# File 'lib/lab_manager.rb', line 33 def self.configPath=(value) @@configPath = value end |
.DEBUG=(value) ⇒ Object
26 27 28 |
# File 'lib/lab_manager.rb', line 26 def self.DEBUG=(value) @@DEBUG = value end |
.password ⇒ Object
46 47 48 |
# File 'lib/lab_manager.rb', line 46 def self.password @@password end |
.reset ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/lab_manager.rb', line 50 def self.reset @@configPath = File.("~/.lab_manager") @@url = nil @@username = nil @@password = nil end |
.url ⇒ Object
37 38 39 |
# File 'lib/lab_manager.rb', line 37 def self.url @@url end |
.url=(value) ⇒ Object
40 41 42 |
# File 'lib/lab_manager.rb', line 40 def self.url=(value) @@url = value end |
.username ⇒ Object
43 44 45 |
# File 'lib/lab_manager.rb', line 43 def self.username @@username end |
Instance Method Details
#checkout(configuration_name, new_configuration_name) ⇒ Object
Clones a configuration from a library.
XML Samples
- configuration_name to clone from the library
- new_configuration_name to clone to
return the new configuration id
183 184 185 186 187 188 189 190 |
# File 'lib/lab_manager.rb', line 183 def checkout(configuration_name, new_configuration_name) config = configuration(configuration_name) data = proxy.ConfigurationCheckout( :configurationId => config.id, :workspaceName => new_configuration_name) data["ConfigurationCheckoutResult"] end |
#clone(configuration_name, new_configuration_name) ⇒ Object
Clone a configuration to a new name
XML Sample
- configuration_name to clone
- new_configuration_name to clone to
returns the id of the cloned configuration.
210 211 212 213 214 215 216 217 |
# File 'lib/lab_manager.rb', line 210 def clone(configuration_name, new_configuration_name) config = configuration(configuration_name) data = proxy.ConfigurationClone( :configurationId => config.id, :newWorkspaceName => new_configuration_name) data["ConfigurationCloneResult"] end |
#configuration(name_or_id) ⇒ Object
Retrieve configuration information
XML Sample
- name_or_id can be a configuration name or a configuration id returned by another method. An id is identified as only digits.
99 100 101 102 103 104 105 106 |
# File 'lib/lab_manager.rb', line 99 def configuration(name_or_id) if name_or_id =~ /^\d+$/ config_data = proxy.GetConfiguration(:configurationId => name_or_id) else config_data = proxy.GetConfigurationByName(:name => name_or_id) end Configuration.parse(config_data) end |
#configurations ⇒ Object
Retrieve a list of configuration information
109 110 111 |
# File 'lib/lab_manager.rb', line 109 def configurations() proxy.ListConfigurations(:configurationType => 2) end |
#delete(configuration_name, options = {}) ⇒ Object
Delete a configuration
XML Sample
- configuration_name to be deleted
raises SOAP:FaultError. See e.faultstring or e.detail
245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/lab_manager.rb', line 245 def delete(configuration_name, = {}) config = configuration(configuration_name) if (config.deployed) fault = OpenStruct.new( :faultstring => "Can not delete configuration that is deployed", :detail => "Must use force flag to auto-undeploy.") raise SOAP::FaultError.new(fault) unless [:force] proxy.ConfigurationUndeploy(:configurationId => config.id) end proxy.ConfigurationDelete(:configurationId => config.id) end |
#machine(configuration_name, machineName) ⇒ Object
Retrieve the informaiton for a single machine in a configuration
163 164 165 166 167 |
# File 'lib/lab_manager.rb', line 163 def machine(configuration_name, machineName) machines(configuration_name).find { |machine| machine.name == machineName } end |
#machines(configuration_name, options = {}) ⇒ Object
Retrieve a list of machines in a configuration
XML Sample
- configuration_name
Examples
lab_manager.machines("CONFIG NAME")
lab_manager.machines("CONFIG NAME", :exclude => ["machine name"])
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/lab_manager.rb', line 146 def machines(configuration_name, = {}) config = configuration(configuration_name) data = proxy.ListMachines(:configurationId => config.id) machines = Machine.from_list(data) if (![:exclude].nil?) machines = machines.find_all { |machine| ![:exclude].include?(machine.name) } end machines end |
#revert(configuration_name) ⇒ Object
Revert a configuratoin to its original state
XML Sample
268 269 270 271 272 273 274 |
# File 'lib/lab_manager.rb', line 268 def revert(configuration_name) config = configuration(configuration_name) proxy.ConfigurationPerformAction(:configurationId => config.id, :action => 7) true end |
#undeploy(configuration_name) ⇒ Object
Undeploys a configuration
XML Sample
- configuration_name to undeploy
225 226 227 228 229 |
# File 'lib/lab_manager.rb', line 225 def undeploy(configuration_name) config = configuration(configuration_name) proxy.ConfigurationUndeploy(:configurationId => config.id) end |