2019 - PVE 社群 - Rails 串接 Proxmox VE API 自動化教學用虛...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →
蒼時弦や
December 07, 2019

2019 - PVE 社群 - Rails 串接 Proxmox VE API 自動化教學用虛擬機分配

再接案公司用 Proxmox VE 建制簡易的練習 VM 環境,讓同事可以在需要的時候申請機器來練習使用。

蒼時弦や

December 07, 2019

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

35 slides
  1. require 'net/http' rquire 'oj' uri = URI('https:!//192.168.100.220:8006/api2/json/access/ticket') req = Net!::HTTP!::Post.new

    req['Content-Type'] = 'application/x-!!www-form-urlencoded' req.body = URI.encode_!!www_form(username: 'xxx@pve', password: 'xxx') token = {} Net!::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| res = http.request(req) token = Oj.load(res.body)&.fetch('data', {}) end puts token['ticket'] # !=> XXXX puts token['CSRFPreventionToken'] # !=> XXX
  2. require 'net/http' rquire 'oj' uri = URI(TICKET_URI) req = Net!::HTTP!::Post.new

    req['Content-Type'] = 'application/x-!!www-form-urlencoded' req.body = URI.encode_!!www_form( username: 'xxx@pve', password: 'xxx' )
  3. token = {} Net!::HTTP.start( uri.host, uri.port, use_ssl: true ) do

    |http| res = http.request(req) token = Oj.load(res.body)&.fetch('data', {}) end puts token['ticket'] # !=> XXXX puts token['CSRFPreventionToken'] # !=> XXX
  4. File Write Qemu Agent VM PlayGround GitLab Public Key 將

    Public Key 寫入 指定的虛擬機

More Decks by 蒼時弦や

Other Decks in Programming