Class: VagrantSubutai::Rest::SubutaiConsole

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-subutai/rest/subutai_console.rb

Class Method Summary collapse

Class Method Details

.approve(token, url, id) ⇒ Object

Approves Resource Host



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 69

def self.approve(token, url, id)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::APPROVE + "/#{id}/approve?sptoken?=" + token)
  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::Post.new(uri.request_uri)

  https.request(request)
end

.command(cmd, hostid, path, timeout, url, token) ⇒ Object

Sends command to Subutai Console method POST



172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 172

def self.command(cmd, hostid, path, timeout, url, token)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::COMMAND + token)
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
  https.read_timeout = 21600 # 6 hours

  request = Net::HTTP::Post.new(uri.request_uri)
  request.set_form_data({'command' => cmd, 'hostid' => hostid, 'path' => path, 'timeout' => timeout})

  https.request(request)
end

.command_async(cmd, hostid, path, timeout, url, token) ⇒ Object

Sends async request to Subutai Console method POST



187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 187

def self.command_async(cmd, hostid, path, timeout, url, token)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::COMMAND_ASYNC + token)
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
  https.read_timeout = 21600 # 6 hours

  request = Net::HTTP::Post.new(uri.request_uri)
  request.set_form_data({'command' => cmd, 'hostid' => hostid, 'path' => path, 'timeout' => timeout})

  https.request(request)
end

.command_log(url, token, command_id) ⇒ Object



200
201
202
203
204
205
206
207
208
209
210
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 200

def self.command_log(url, token, command_id)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::COMMAND_LOG.gsub('{COMMAND_ID}', command_id) + token)
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
  https.read_timeout = 21600 # 6 hours

  request = Net::HTTP::Get.new(uri.request_uri)

  https.request(request)
end

.deregister(token, url) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 56

def self.deregister(token, url)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::DE_REGISTER_HUB + token)
  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::Delete.new(uri.request_uri)

  https.request(request)
end

.domain(url, token, env_id, domain) ⇒ Object

Add domain to Environment



227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 227

def self.domain(url, token, env_id, domain)
  uri = URI.parse("#{url}#{Configs::SubutaiConsoleAPI::V1::DOMAIN}#{env_id}/domains?sptoken=#{token}")
  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::Post.new(uri.request_uri)
  request.set_form([['file', ''], ['hostName', domain], ['strategy', 'NONE']], 'multipart/form-data')

  https.request(request)
end

.environment(url, token, params) ⇒ Object

Creates Environment method POST



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 129

def self.environment(url, token, params)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::ENVIRONMENT + token)
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
  https.read_timeout = 21600 # 6 hours

  request = Net::HTTP::Post.new(uri.request_uri)
  request.set_form_data({'topology' => params})

  https.request(request)
end

.environments(url, token) ⇒ Object

List Environments method GET



158
159
160
161
162
163
164
165
166
167
168
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 158

def self.environments(url, token)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::ENVIRONMENTS + token)
  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)

  https.request(request)
end

.fingerprint(url) ⇒ Object

Gets Finger print Subutai Console



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 94

def self.fingerprint(url)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::FINGERPRINT)
  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.body
    else
      raise "Try again! #{response.body}"
  end
end

.log(url, token, tracker_id) ⇒ Object

Gives logs of Blueprint Environment builds method GET



214
215
216
217
218
219
220
221
222
223
224
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 214

def self.log(url, token, tracker_id)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::LOG + "#{tracker_id}?sptoken=#{token}")
  https = Net::HTTP.new(uri.host, uri.port)
  https.use_ssl = true
  https.verify_mode = OpenSSL::SSL::VERIFY_NONE
  https.read_timeout = 21600 # 6 hours

  request = Net::HTTP::Get.new(uri.request_uri)

  https.request(request)
end

.password(url, username, password, new_password) ⇒ Object

Change password



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 27

def self.password(url, username, password, new_password)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::)
  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::Post.new(uri.request_uri)
  request.set_form_data('username' => username, 'password' => password, 'newpassword' => new_password)

  https.request(request)
end

.port(url, token, env_id, cont_id, port) ⇒ Object

Add port to container



241
242
243
244
245
246
247
248
249
250
251
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 241

def self.port(url, token, env_id, cont_id, port)
  uri = URI.parse("#{url}#{Configs::SubutaiConsoleAPI::V1::DOMAIN}#{env_id}/containers/#{cont_id}/domainnport?state=true&port=#{port}&sptoken=#{token}")
  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::Put.new(uri.request_uri)

  https.request(request)
end

.ready(url) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 81

def self.ready(url)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::READY)
  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)

  https.request(request)
end

.register(token, url, email, password, peer_name, peer_scope) ⇒ Object

Subutai Hub credentials email, password specify your peer_name peer_scope acceptable only like this “Public” : “Private”



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 43

def self.register(token, url, email, password, peer_name, peer_scope)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::REGISTER_HUB + token)
  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::Post.new(uri.request_uri)
  request.set_form_data({'email' => email, 'password' => password, 'peerName' => peer_name, 'peerScope' => peer_scope})

  https.request(request)
end

.requests(url, token) ⇒ Object

Get Subutai Console RH requests method GET



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 115

def self.requests(url, token)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::REQUESTS + token)
  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)

  https.request(request)
end

.resource(url, token) ⇒ Object

Gets Peer Os resources (disk, ram and cpu) method GET



144
145
146
147
148
149
150
151
152
153
154
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 144

def self.resource(url, token)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::RESOURCES + token)
  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)

  https.request(request)
end

.token(url, username, password) ⇒ Object

Subutai Console credentials username, password Subutai Console url login methods gets token



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-subutai/rest/subutai_console.rb', line 13

def self.token(url, username, password)
  uri = URI.parse(url + Configs::SubutaiConsoleAPI::V1::TOKEN)
  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::Post.new(uri.request_uri)
  request.set_form_data('username' => username, 'password' => password)

  https.request(request)
end