Module: SettingsHelper

Defined in:
lib/opsmgr/ui_helpers/config_helper.rb

Instance Method Summary collapse

Instance Method Details

#configure_capybara(ops_manager_url) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 105

def configure_capybara(ops_manager_url)
  Capybara.configure do |c|
    c.default_driver = :webkit
  end

  begin
    Capybara::Webkit.configure do |c|
      c.allow_url(ops_manager_url)
      c.ignore_ssl_errors
    end
  rescue
    # Capybara says, "All configuration must take place before the driver starts"
  end

  page.current_window.resize_to(1024, 2600) # avoid overlapping footer spec failures
end

#delete_timeoutObject



41
42
43
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 41

def delete_timeout
  Integer(ENV.fetch('DELETE_TIMEOUT'))
end

#environment_nameObject



97
98
99
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 97

def environment_name
  ENV.fetch('ENVIRONMENT_NAME')
end

#errand_namesObject



45
46
47
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 45

def errand_names
  JSON.parse(ENV.fetch('ERRAND_NAMES'))
end

#export_destination_pathObject



21
22
23
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 21

def export_destination_path
  ENV.fetch('EXPORT_DESTINATION')
end

#fetch_environment_settingsObject



101
102
103
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 101

def fetch_environment_settings
  Opsmgr::Environments.for(environment_name).settings
end

#import_file_pathObject



25
26
27
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 25

def import_file_path
  ENV.fetch('IMPORT_FILE')
end

#install_timeoutObject



37
38
39
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 37

def install_timeout
  ENV.fetch('INSTALL_TIMEOUT').to_i
end

#om_versionObject



33
34
35
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 33

def om_version
  ENV.fetch('OM_VERSION')
end

#ops_manager_api_driverObject



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
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 65

def ops_manager_api_driver
  env_settings = fetch_environment_settings
  case om_version
  when '1.4'
    api_1_4(
      host: env_settings['ops_manager']['url'],
      username: env_settings['ops_manager']['username'],
      password: env_settings['ops_manager']['password'],
    )
  when '1.5'
    api_1_5(
      host: env_settings['ops_manager']['url'],
      username: env_settings['ops_manager']['username'],
      password: env_settings['ops_manager']['password'],
    )
  when '1.6'
    api_1_6(
      host: env_settings['ops_manager']['url'],
      username: env_settings['ops_manager']['username'],
      password: env_settings['ops_manager']['password'],
    )
  when '1.7'
    api_1_7(
      host: env_settings['ops_manager']['url'],
      username: env_settings['ops_manager']['username'],
      password: env_settings['ops_manager']['password'],
    )
  else
    fail "Unsupported Ops Manager Version #{om_version.inspect}"
  end
end

#ops_manager_driverObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 49

def ops_manager_driver
  configure_capybara(fetch_environment_settings['ops_manager']['url'])
  case om_version
  when '1.4'
    om_1_4(fetch_environment_settings['ops_manager']['url'])
  when '1.5'
    om_1_5(fetch_environment_settings['ops_manager']['url'])
  when '1.6'
    om_1_6(fetch_environment_settings['ops_manager']['url'])
  when '1.7'
    om_1_7(fetch_environment_settings['ops_manager']['url'])
  else
    fail "Unsupported Ops Manager Version #{om_version.inspect}"
  end
end

#product_nameObject



17
18
19
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 17

def product_name
  ENV.fetch('PRODUCT_NAME')
end

#product_pathObject



13
14
15
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 13

def product_path
  ENV.fetch('PRODUCT_PATH')
end

#stemcell_file_pathObject



29
30
31
# File 'lib/opsmgr/ui_helpers/config_helper.rb', line 29

def stemcell_file_path
  ENV.fetch('STEMCELL_FILE')
end