Class: App42::Command::Config

Inherits:
Base
  • Object
show all
Defined in:
lib/app42/command/config.rb

Instance Method Summary collapse

Methods inherited from Base

#app_information, #app_operation, #app_url_availability, #cloudapi_operation, #collect_app_source, #create_cloud_setup, #create_gpaas_setup, #create_infrastructure, #create_service, #create_service_tunnel, #create_wordpress_setup, #custom_url_information, #custom_url_operation, #delete_cloudapi, #delete_gpaas, #delete_service, #delete_service_tunnel, #delete_wordpress, #get_app_name, #get_app_name_and_check_app_url_availability, #get_app_source, #get_custom_url, #get_framework, #get_iaas_providers, #get_instance, #get_kontena, #get_os_for_app, #get_os_for_service, #get_runtime, #get_setup_name, #get_setup_name_and_check_setup_url_availability, #get_subscription, #get_vm_types, #get_webserver, #get_wordpress_name, #get_wordpress_name_and_check_wordpress_url_availability, #gpaas_operation, #initialize, #interactive_get, #reset_password, #scale_or_descale_app, #service_name_availability, #service_operation, #setup_url_availability, #update_binary, #upgrade_or_downgrade_cloudapi, #upgrade_or_downgrade_gpaas, #upgrade_or_downgrade_wordpress, #upload_binary, #upload_service_backup, #vscale_or_vdescale_app, #vscale_or_vdescale_service, #wordpress_operation, #wordpress_url_availability

Methods included from Base::HttpHelper

#build_delete_request, #build_get_request, #build_post_request, #build_put_request, #delete_request, #get_request, #post_request, #put_request

Methods included from Base::Util

#app42_client_info, #ask_app_name, #camel_case_to_whitespace, #check_transaction_status, #check_transaction_status_of_setup, #escape_path, #get_flavour_for_upgrade_or_downgrade, #input, #ip_address_valid?, #is_app_exist?, #is_service_exist?, #is_setup_name_exist?, #json_parse, #message, #number_valid?, #numeric?, #numeric_including_zero?, #params, #parse_error_message, #print_new_line, #request_failed?, #resource_url, #show_wait_spinner, #signature, #status_call, #time_valid?, #util_base, #validate_app_and_service_name, #validate_database_name, #validate_git_url, #validate_setup_name, #validate_upload_backup_path, #validate_url, #validate_vm_config

Methods included from UserToken

#check_key_file?, #config_path, #ensure_config_dir, #ensure_key_file, #get_keys, #key_path, #local_app42_key, #remove_key_file

Constructor Details

This class inherits a constructor from App42::Command::Base

Instance Method Details

#frameworksObject

list app42paas supported frameworks



173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/app42/command/config.rb', line 173

def frameworks
  runtime = get_runtime
  vm_type = get_vm_types
  iaas = get_iaas_providers
  framework = get_frameworks iaas, vm_type, runtime
  rows = []
  framework['frameworks'].each_pair do |key, value|
    rows << Array(value.capitalize)
  end unless framework['frameworks'].nil?

  table = Terminal::Table.new  :title => Paint["=== Available Frameworks ===", :green], :rows => rows
  puts table 
  print_new_line
end

#get_flavour_type_fm_serverObject

return list of flavour



83
84
85
# File 'lib/app42/command/config.rb', line 83

def get_flavour_type_fm_server
  build_get_request params, 'info', 'flavour'
end

#get_flavour_type_fm_server_for_upgrade_or_downgrade(setup_name, type) ⇒ Object

return list of flavour



90
91
92
93
94
# File 'lib/app42/command/config.rb', line 90

def get_flavour_type_fm_server_for_upgrade_or_downgrade setup_name, type
  query_params = params
  query_params.store('setupName', setup_name)
  build_get_request query_params, 'info', "flavour/#{type}"
end

#get_frameworks(iaas, vm_type, rt) ⇒ Object

return list of templates



99
100
101
102
103
104
105
# File 'lib/app42/command/config.rb', line 99

def get_frameworks iaas, vm_type, rt
  query_params = params
  query_params.store('vmType', vm_type)
  query_params.store('iaas', iaas)
  query_params.store('runtime', rt)
  build_get_request query_params, 'info', 'frameworks'
end

#get_iaas_providerObject

return list of iaas_providers



32
33
34
# File 'lib/app42/command/config.rb', line 32

def get_iaas_provider
  build_get_request params, 'info', 'iaasproviders'
end

#get_instance_config_for_upgrade_or_downgrade(iaas, vm_type, setup_name, type) ⇒ Object

return list of instance configuration



63
64
65
66
67
68
69
# File 'lib/app42/command/config.rb', line 63

def get_instance_config_for_upgrade_or_downgrade iaas, vm_type, setup_name, type
  query_params = params
  query_params.store('vmType', vm_type)
  query_params.store('iaas', iaas)
  query_params.store('setupName', setup_name)
  build_get_request query_params, 'info', "instanceconfig/#{type}"
end

#get_instance_config_type(iaas, vm_type) ⇒ Object

return list of instance configuration



53
54
55
56
57
58
# File 'lib/app42/command/config.rb', line 53

def get_instance_config_type iaas, vm_type
  query_params = params
  query_params.store('vmType', vm_type)
  query_params.store('iaas', iaas)
  build_get_request query_params, 'info', 'instanceconfig'
end

#get_operating_sys_for_app(iaas, vm_type, rt, framework, webserver) ⇒ Object

return list of operating system for app



122
123
124
125
126
127
128
129
130
# File 'lib/app42/command/config.rb', line 122

def get_operating_sys_for_app iaas, vm_type, rt, framework, webserver
  query_params = params
  query_params.store('vmType', vm_type)
  query_params.store('iaas', iaas)
  query_params.store('runtime', rt)
  query_params.store('framework', framework)
  query_params.store('webServer', webserver)
  build_get_request query_params, 'info/app', 'os'
end

#get_operating_sys_for_service(iaas, vm_type, service) ⇒ Object

return list of operating system for service



135
136
137
138
139
140
141
# File 'lib/app42/command/config.rb', line 135

def get_operating_sys_for_service iaas, vm_type, service
  query_params = params
  query_params.store('vmType', vm_type)
  query_params.store('iaas', iaas)
  query_params.store('service', service)
  build_get_request query_params, 'info/service', 'os'
end

#get_runtimesObject

return list of runtimes



39
40
41
# File 'lib/app42/command/config.rb', line 39

def get_runtimes
  build_get_request params, 'info', 'runtimes'
end

#get_setup_details(setup_name) ⇒ Object

return setup details



74
75
76
77
78
# File 'lib/app42/command/config.rb', line 74

def get_setup_details setup_name
  query_params = params
  query_params.store('setupName', setup_name)
  build_get_request query_params, 'info', 'setupdetails'
end

#get_setup_type_fm_serverObject

return list of setup type



46
47
48
# File 'lib/app42/command/config.rb', line 46

def get_setup_type_fm_server
  build_get_request params, 'info', 'setuptype'
end

#get_vm_typeObject

return list of virtual machine type



18
19
20
# File 'lib/app42/command/config.rb', line 18

def get_vm_type
  build_get_request params, 'info', 'subscription'
end

#get_vmconfig(resource, vm_type, iaas) ⇒ Object

return list of vm_configuration(memory)



146
147
148
149
150
151
# File 'lib/app42/command/config.rb', line 146

def get_vmconfig resource, vm_type, iaas
  query_params = params
  query_params.store('vmType', vm_type)
  query_params.store('iaas', iaas)
  build_get_request query_params, "#{resource}", 'memory'
end

#get_webservers(iaas, vm_type, rt, framework) ⇒ Object

return list of web server



110
111
112
113
114
115
116
117
# File 'lib/app42/command/config.rb', line 110

def get_webservers iaas, vm_type, rt, framework
  query_params = params
  query_params.store('vmType', vm_type)
  query_params.store('iaas', iaas)
  query_params.store('runtime', rt)
  query_params.store('framework', framework)
  build_get_request query_params, 'info', 'webserver'
end

#iaas_providersObject

return list of iaas_provider



156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/app42/command/config.rb', line 156

def iaas_providers
   rows, rows_header_final, rows_header = [], [], nil
   get_iaas_provider['iaas'].each do |iaas|
     iaas.delete('id')
     rows_header = iaas.keys
     rows << iaas.values
   end

   rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) } 

   table = Terminal::Table.new  :title => Paint["=== Available IaaS Providers ===", :green], :headings => rows_header_final, :rows => rows
   puts table
end

#listObject

This will list all app42 available commands.



10
11
12
13
# File 'lib/app42/command/config.rb', line 10

def list
  message "All app42 available commands", true, 'blue'
  App42::Base::APP42_COMMAND.select { |action| puts Paint["app42 #{action}", :green]}
end

#memoryObject

list app42paas supported memory



220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/app42/command/config.rb', line 220

def memory
  vm_type = get_vm_types
  iaas = get_iaas_providers
  vmconfig = get_vmconfig vm_type, iaas
  rows = []
  vmconfig['vmconfig'].each_pair do |key, value|
    rows << Array(value.capitalize)
  end
  
  table = Terminal::Table.new  :title => Paint["=== Available vmconfigs ===", :green], :rows => rows
  puts table 
  print_new_line
end

#runtimesObject

list app42paas supported runtimes



202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/app42/command/config.rb', line 202

def runtimes
  rows, rows_header_final, rows_header = [], [], nil
  
  get_runtimes['runtimes'].each do |rt|
    rt.delete('id')
    rows_header = rt.keys 
    rows << rt.values
  end

  rows_header.map { |e| rows_header_final << camel_case_to_whitespace(e) } 

  table = Terminal::Table.new  :title => Paint["=== Available Runtimes ===", :green], :headings => rows_header_final, :rows => rows
  puts table 
end

#subscriptionObject

return subscription



25
26
27
# File 'lib/app42/command/config.rb', line 25

def subscription
  build_get_request params, 'info', 'subscriptiontype'
end

#updateObject

update the app42paas client



237
238
239
240
241
242
# File 'lib/app42/command/config.rb', line 237

def update
  puts 'Uninstalling current app42 client'
  system('gem uninstall app42')
  puts "Installing latest app42 client"
  system ("gem install app42-0.5.0.gem")
end

#versionObject

This version number is used as the RubyGem release version.



5
6
7
# File 'lib/app42/command/config.rb', line 5

def version
  puts message "App42 current version: #{App42::Version::VERSION::VERSION}", false, 'green'
end

#vm_typeObject

list app42paas supported vm_type



191
192
193
194
195
196
197
# File 'lib/app42/command/config.rb', line 191

def vm_type
  vm_type = get_config 'config', __method__
  puts Paint["=== Available virtual machine type ===", :green]
  vm_type['vm_type'].each do |vt|
    puts vt.capitalize
  end
end