Class: RightScaleCLI::ServerTemplates
- Inherits:
-
Thor
- Object
- Thor
- RightScaleCLI::ServerTemplates
- Defined in:
- lib/rightscale_cli/server_templates.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ ServerTemplates
constructor
A new instance of ServerTemplates.
- #inputs(server_template_id) ⇒ Object
- #inputs_dashboard(server_template_id) ⇒ Object
- #list ⇒ Object
- #show(server_template_id) ⇒ Object
Constructor Details
#initialize(*args) ⇒ ServerTemplates
Returns a new instance of ServerTemplates.
28 29 30 31 32 |
# File 'lib/rightscale_cli/server_templates.rb', line 28 def initialize(*args) super @client = RightScaleCLI::Client.new() @logger = RightScaleCLI::Logger.new() end |
Instance Method Details
#inputs(server_template_id) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/rightscale_cli/server_templates.rb', line 48 def inputs(server_template_id) server_template_inputs = [] @client.client.server_templates(:id => server_template_id).show.inputs.index.each do |input| server_template_inputs.push(input.raw) end @client.render(server_template_inputs, 'inputs') end |
#inputs_dashboard(server_template_id) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rightscale_cli/server_templates.rb', line 57 def inputs_dashboard(server_template_id) uri = URI.parse("#{@client.client.api_url}/acct/#{@client.client.account_id}/inputs/edit_inputs?container_id=#{server_template_id}&container_type=ServerTemplate") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(uri.request_uri) request.add_field("Referer", "#{@client.client.api_url}/acct/#{@client.client.account_id}/server_templates/#{server_template_id}") request.add_field("X-Requested-With", "XMLHttpRequest") request.add_field("Cookie", @client.client.last_request[:request].headers[:cookie]) response = http.request(request) puts response.body if [:debug] require 'nokogiri' inputs = [] html = Nokogiri::HTML(response.body) input_list = html.css('ul[class=inputList]').css('li[class=inputContainer]').css('div[class=inputInformation]').each { |input_html| input = {} input['name'] = input_html.css('div')[0].text.gsub!(/\s+/, "") input['possible_values'] = [] input_html.css('div[class=inputValue]').css('select[class=possible_values] option').each { |option| input['current'] = option['value'] if option['selected'] == 'selected' input['possible_values'].push(option['value']) } inputs.push(input) } @client.render(inputs, 'inputs') end |
#list ⇒ Object
38 39 40 |
# File 'lib/rightscale_cli/server_templates.rb', line 38 def list() @client.render(@client.get('server_templates'), 'server_templates') end |
#show(server_template_id) ⇒ Object
43 44 45 |
# File 'lib/rightscale_cli/server_templates.rb', line 43 def show(server_template_id) @client.render(@client.show('server_templates', server_template_id), 'server_template') end |