module App42::Command class Config < Base # This version number is used as the RubyGem release version. def version puts message "App42 current version: #{App42::Version::VERSION::VERSION}", false, 'green' end # This will list all app42 available commands. def list message "All app42 available commands", true, 'blue' App42::Base::APP42_COMMAND.select { |action| puts Paint["app42 #{action}", :green]} end # # return list of virtual machine type # def get_vm_type build_get_request params, 'info', 'subscription' end # # return list of iaas_providers # def get_iaas_provider build_get_request params, 'info', 'iaasproviders' end # # return list of runtimes # def get_runtimes build_get_request params, 'info', 'runtimes' end # # return list of setup type # def get_setup_type_fm_server build_get_request params, 'info', 'setuptype' end # # return list of flavour # def get_flavour_type_fm_server build_get_request params, 'info', 'flavour' end # # return list of templates # 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 # # return list of web server # 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 # # return list of operating system for app # 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 # # return list of operating system for service # 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 # # return list of vm_configuration(memory) # 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 # # return list of iaas_provider # 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 # # list app42paas supported frameworks # 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 # # list app42paas supported vm_type # 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 # # list app42paas supported runtimes # 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 # # list app42paas supported memory # 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 # # update the app42paas client # 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 end end