Class: Delphix::Environment
- Inherits:
-
Object
- Object
- Delphix::Environment
- Includes:
- Base
- Defined in:
- lib/delphix/environment.rb
Instance Attribute Summary
Attributes included from Base
Class Method Summary collapse
-
.create(name, address, port, toolkit_path, username, password) ⇒ Object
class methods.
- .list ⇒ Object
Instance Method Summary collapse
-
#base_endpoint ⇒ Object
inherited operations.
-
#delete ⇒ Object
basic operations.
- #disable(disable_all_sources = true) ⇒ Object
-
#enable(enable_all_sources = false) ⇒ Object
specific operations.
-
#initialize(reference, details = nil) ⇒ Environment
constructor
A new instance of Environment.
- #refresh ⇒ Object
Methods included from Base
#name, #reference, #refresh_details, #to_s, #type
Constructor Details
#initialize(reference, details = nil) ⇒ Environment
Returns a new instance of Environment.
8 9 10 |
# File 'lib/delphix/environment.rb', line 8 def initialize(reference, details=nil) super(reference, details) end |
Class Method Details
.create(name, address, port, toolkit_path, username, password) ⇒ Object
class methods
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 104 105 106 107 |
# File 'lib/delphix/environment.rb', line 68 def self.create(name, address, port, toolkit_path, username, password) body = { :type => 'HostEnvironmentCreateParameters', :primaryUser => { :type => 'EnvironmentUser', :name => username, :credential => { :type => 'PasswordCredential', :password => password } }, :hostEnvironment => { :type => 'UnixHostEnvironment', :name => name }, :hostParameters => { :type => 'UnixHostCreateParameters', :host => { :type => 'UnixHost', :address => address, :sshPort => port, :toolkitPath => toolkit_path } } } # create the environment resp = Delphix::Response.new( Delphix.post('/resources/json/delphix/environment', body.to_json)) return nil if resp.is_error? # wait until the environment has been created resp.job.wait_for_completion # create a new skeleton environment object env = Delphix::Environment.new resp.details # and refresh the object from the engine env.refresh_details env end |
Instance Method Details
#base_endpoint ⇒ Object
inherited operations
62 63 64 |
# File 'lib/delphix/environment.rb', line 62 def base_endpoint '/resources/json/delphix/environment' end |
#delete ⇒ Object
basic operations
14 15 16 |
# File 'lib/delphix/environment.rb', line 14 def delete Delphix::Response.new( Delphix.delete("#{base_endpoint}/#{reference}")) end |
#disable(disable_all_sources = true) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/delphix/environment.rb', line 37 def disable(disable_all_sources=true) if disable_all_sources # stop and disable all sources on this environment sources = lookup_sources if sources != nil sources.each do |src| if src.virtual? src.stop.wait_for_completion end src.disable.wait_for_completion end end end # now disable the environment itself Delphix::Response.new( Delphix.post("#{base_endpoint}/#{reference}/disable")) end |
#enable(enable_all_sources = false) ⇒ Object
specific operations
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/delphix/environment.rb', line 20 def enable(enable_all_sources=false) resp = Delphix::Response.new( Delphix.post("#{base_endpoint}/#{reference}/enable")) return resp if !enable_all_sources resp.wait_for_completion # enable all sources on this environment sources = lookup_sources if sources != nil sources.each do |src| src.enable.wait_for_completion end end resp end |