Module: SettingsHelper

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

Instance Method Summary collapse

Instance Method Details

#configure_capybara(ops_manager_url) ⇒ Object



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

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, 1600) # avoid overlapping footer spec failures
end

#delete_timeoutObject



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

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

#environment_nameObject



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

def environment_name
  ENV.fetch('ENVIRONMENT_NAME')
end

#errand_namesObject



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

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

#export_destination_pathObject



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

def export_destination_path
  ENV.fetch('EXPORT_DESTINATION')
end

#fetch_environment_settingsObject



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

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

#import_file_pathObject



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

def import_file_path
  ENV.fetch('IMPORT_FILE')
end

#install_timeoutObject



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

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

#om_versionObject



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

def om_version
  ENV.fetch('OM_VERSION')
end

#ops_manager_api_driverObject



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

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



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

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



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

def product_name
  ENV.fetch('PRODUCT_NAME')
end

#product_pathObject



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

def product_path
  ENV.fetch('PRODUCT_PATH')
end

#stemcell_file_pathObject



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

def stemcell_file_path
  ENV.fetch('STEMCELL_FILE')
end