Class: VagrantSubutai::Rest::Gorjun
- Inherits:
-
Object
- Object
- VagrantSubutai::Rest::Gorjun
- Defined in:
- lib/vagrant-subutai/rest/gorjun.rb
Class Method Summary collapse
Class Method Details
.template_id(name, owner) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant-subutai/rest/gorjun.rb', line 9 def self.template_id(name, owner) uri = URI.parse("#{url}?name=#{name}&owner=#{owner}") https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE https.read_timeout = 3600 # an hour request = Net::HTTP::Get.new(uri.request_uri) response = https.request(request) case response when Net::HTTPOK response = JSON.parse(response.body) response[0]['id'] when Net::HTTPNotFound Put.error "#{response.body} template name #{name}, owner #{owner}" end end |
.url ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-subutai/rest/gorjun.rb', line 28 def self.url env = SubutaiConfig.get(:SUBUTAI_ENV) env = env.to_s if env == VagrantSubutai::Configs::Environment::PROD return VagrantSubutai::Configs::Gorjun::INFO_PROD elsif env == VagrantSubutai::Configs::Environment::MASTER return VagrantSubutai::Configs::Gorjun::INFO_MASTER elsif env == VagrantSubutai::Configs::Environment::DEV return VagrantSubutai::Configs::Gorjun::INFO_DEV end end |