Untitled

mail@pastecode.io avatar
unknown
golang
2 years ago
3.3 kB
2
Indexable
Never
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://192.168.15.7:8848/api2/json/nodes/xvp8/storage/local-lvm/content"
  method := "POST"

  payload := strings.NewReader("filename=vm-1004819-1231344-1231418-12831231-devdisk&size=10G&vmid=1004819-1231344-1231418-12831231&mkfs=1&username=zsm&pubkey=ssh-rsa%20AAAAB3NzaC1yc2EAAAADAQABAAABAQCr%2FAvn2DFyQ15wuZLzpYs8cGYXFjDuGqeazW1QXsdG3bZ8XRdyh6xtYhEH4DbaI9rG5yjFvRoAQh%2BfUz3s5S9I2avM6bwGHeqnJfVX0%2F1doMGwhBY0yDlsJ%2FQFs1pXAIZxaETSmeO0ai%2BGCa5%2BiFDEKjAnJDzYgu6dPWsoCLy%2Bloy9sSFkgJuXUQpI1pRjC8oqIcOHxzIWtnTf%2FZR9W0c1jTTp%2FW2o%2B%2FmlH9Y78Np1iWyd1WHCkDxeALE57AzTUbXTJuDmK9x1V3DU9jfNTfFPgoOT%2F2hrXd0Gi4aKjYlPUup%2B%2F1f5W9b3SFe50%2BE7e730EGaxpI546UjzXRKUtS7d&prikey=-----BEGIN%20RSA%20PRIVATE%20KEY-----%0AProc-Type%3A%204%2CENCRYPTED%0ADEK-Info%3A%20AES-128-CBC%2CF8B634468DEA67BF9CEFBD184272827A%0A%0AKkwId7StI%2FM1cjVRL9%2Bmk4gvDxVIw%2FN3E9qcJJihy3X7ChdRLGySuIhjfMYFe8ju%0AEFsGhIYcSlFDUVXzMUlfZQIW5%2FoAkN1d9VEXrDEI03pc3WWIedUkaswuAhSbSS7F%0AamK9ZBDASV%2BVQmZFFcHmgbnQ3FQ7MXUjkT1RP4d76GYKiljDawseMozHahvsTNSk%0ACR%2B2iuPlg5SrAnVPw5PnFyDOciikftvzfZXmT4EgttP8%2BoRqS1%2FHMofbBzw%2BVZwa%0Ajghz9BZfw2rmVggWpSEN1EXKv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agI%2FqiB88vunfwW5WGYguZeBYb%0Aell4dH%2F0MaZkrBmenPWnxpSUctH0E%2BEi49ePTHPcwj3duhMDtEQ6uE18P9aUjKGj%0Aif1YbfOHWG%2F5D8mRgnfMKv3bJn%2Bv6diktveJ%2B%2FVVosDMPoQASTbz%2B04bJfhxd9Tw%0Af6%2B0kjDCmmot9NaK4qffHqw9VxB8ABMce1dAcj5WsrZJA0bBfjg9F7VbX5iaE9Lj%0AaiG6c3OAlOXfIK8X8DmxQhFuDP3j421zL2XZ7bPSmrRmYnn0jHoV%2Fp%2FTM%2FithhwJ%0AcBHRtFHEIrGgmtqtG34WgIahR7X3MbUto%2FHgj6OVNhK0sNQ7AcdHurmarOAQax2F%0A-----END%20RSA%20PRIVATE%20KEY-----&token=1y78xu184910u8&controller=192.168.14.1")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "XVPAPIToken=gwapi@xvp!gwapi=827239c5-0fd8-434d-a04d-a277e4843fff")
  req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}