Class: OpsManagerUiDrivers::Version18::Api

Direct Known Subclasses

OpsManagerUiDrivers::Version19::Api

Constant Summary collapse

SETUP_PATH =
'api/v0/setup'
PRODUCTS_PATH =
'api/v0/staged/products'
PRODUCTS_UPLOAD_PATH =
'api/v0/available_products'
STEMCELLS_UPLOAD_PATH =
'api/v0/stemcells'
NETWORKS_AND_AZS_PATH =
PRODUCTS_PATH + '/:product_id/networks_and_azs'

Instance Method Summary collapse

Methods inherited from OpsManagerUiDrivers::Version17::Api

#deployed_product_guid_from_name, #director_vm_credentials, #export_installation, #get_deployed_products, #get_products, #most_recent_installation_log, #set_director_second_network, #state_change_success?, #vm_credentials

Methods inherited from OpsManagerUiDrivers::Version14::Api

#export_installation, #initialize

Constructor Details

This class inherits a constructor from OpsManagerUiDrivers::Version14::Api

Instance Method Details

#add_product!(name:, product_version:) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/ops_manager_ui_drivers/version18/api.rb', line 33

def add_product!(name:, product_version:)
  params = {
    name: name,
    product_version: product_version
  }

  post_request(endpoint: PRODUCTS_PATH, params: params)
end

#assign_azs_and_network(product_guid:, singleton_availability_zone:, availability_zones:, network:, service_network: nil) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ops_manager_ui_drivers/version18/api.rb', line 68

def assign_azs_and_network(product_guid:, singleton_availability_zone:, availability_zones:, network:, service_network: nil)
  params = {
    networks_and_azs: {
      singleton_availability_zone: { name: singleton_availability_zone },
      other_availability_zones: availability_zones.map{|az| { name: az } },
      network: { name: network },
    }
  }

  params[:networks_and_azs].merge!(service_network: { name: service_network }) if service_network

  endpoint = url_for_product(product_id: product_guid, route: NETWORKS_AND_AZS_PATH)
  put_request(endpoint: endpoint, params: params)
end

#internal_setup!Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ops_manager_ui_drivers/version18/api.rb', line 19

def internal_setup!
  setup_params = {
    eula_accepted: 'true',
    admin_user_name: @username,
    admin_password: @password,
    admin_password_confirmation: @password,
    decryption_passphrase: @password,
    decryption_passphrase_confirmation: @password,
    identity_provider: 'internal',
  }

  post_request(endpoint: SETUP_PATH, params: setup_params)
end

#product_guid(product_name:) ⇒ Object



83
84
85
86
87
# File 'lib/ops_manager_ui_drivers/version18/api.rb', line 83

def product_guid(product_name:)
  response = get_request(endpoint: PRODUCTS_PATH)

  JSON.parse(response.body).find {|product_hash| product_hash['type'] == product_name }['guid']
end

#set_feature_flag(_flag_name, _value) ⇒ Object



15
16
17
# File 'lib/ops_manager_ui_drivers/version18/api.rb', line 15

def set_feature_flag(_flag_name, _value)
  Logger.error 'This method is a no-op. Ops Manager 1.8 does not support turning feature_flags on/off'
end

#upload_product_zip(path:) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ops_manager_ui_drivers/version18/api.rb', line 42

def upload_product_zip(path:)
  post_file(
    endpoint: PRODUCTS_UPLOAD_PATH,
    path: path,
    type: 'application/zip') do |file_param|
    {
      'product' => {
        'file' => file_param
      }
    }
  end
end

#upload_stemcell(path:) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ops_manager_ui_drivers/version18/api.rb', line 55

def upload_stemcell(path:)
  post_file(
    endpoint: STEMCELLS_UPLOAD_PATH,
    path: path,
    type: 'application/zip') do |file_param|
    {
      'stemcell' => {
        'file' => file_param
      }
    }
  end
end