GithubHelp home page GithubHelp logo

isabella232 / proxmox-api-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from netceler/proxmox-api-go

0.0 0.0 0.0 272 KB

Consume the proxmox API in golang

License: MIT License

Go 98.96% Makefile 0.06% Shell 0.98%

proxmox-api-go's Introduction

Proxmox API Go

Proxmox API in golang. For /api2/json. Work in progress.

Starting with Proxmox 5.2 you can use cloud-init options.

Build

go build -o proxmox-api-go

Run

export PM_API_URL="https://xxxx.com:8006/api2/json"
export PM_USER=user@pam
export PM_PASS=password
export PM_OTP=otpcode (only if required)

./proxmox-api-go installQemu proxmox-node-name < qemu1.json

./proxmox-api-go createQemu 123 proxmox-node-name < qemu1.json

./proxmox-api-go -debug start 123

./proxmox-api-go -debug stop 123

./proxmox-api-go cloneQemu template-name proxmox-node-name < clone1.json

./proxmox-api-go migrate pve1 123

./proxmox-api-go createQemuSnapshot vm-name snapshot_name

./proxmox-api-go deleteQemuSnapshot vm-name snapshot_name

./proxmox-api-go listQemuSnapshot vm-name

./proxmox-api-go rollbackQemu vm-name

Format

createQemu JSON Sample:

{
  "name": "golang1.test.com",
  "desc": "Test proxmox-api-go",
  "memory": 2048,
  "os": "l26",
  "cores": 2,
  "sockets": 1,
  "iso": "local:iso/ubuntu-14.04.5-server-amd64.iso",
  "disk": {
    "0": {
      "type": "virtio",
      "storage": "local",
      "storage_type": "dir",
      "size": "30G",
      "backup": true
    }
  },
  "network": {
    "0": {
      "model": "virtio",
      "bridge": "nat"
    },
    "1": {
      "model": "virtio",
      "bridge": "vmbr0",
      "firwall": true,
      "backup": true,
      "tag": -1
    }
  }
}

cloneQemu JSON Sample:

{
  "name": "golang2.test.com",
  "desc": "Test proxmox-api-go clone",
  "storage": "local",
  "memory": 2048,
  "cores": 2,
  "sockets": 1,
  "fullclone": 1
}

cloneQemu cloud-init JSON Sample:

{
  "name": "cloudinit.test.com",
  "desc": "Test proxmox-api-go clone",
  "storage": "local",
  "memory": 2048,
  "cores": 2,
  "sockets": 1,
  "ipconfig0": "gw=10.0.2.2,ip=10.0.2.17/24",
  "sshkeys" : "...",
  "nameserver": "8.8.8.8"
}

Cloud-init options

Cloud-init VMs must be cloned from a cloud-init ready template. See: https://pve.proxmox.com/wiki/Cloud-Init_Support

  • ciuser - User name to change ssh keys and password for instead of the image’s configured default user.
  • cipassword - Password to assign the user.
  • cicustom - Specify custom files to replace the automatically generated ones at start.
  • searchdomain - Sets DNS search domains for a container.
  • nameserver - Sets DNS server IP address for a container.
  • sshkeys - public ssh keys, one per line
  • ipconfig0 - [gw=] [,gw6=] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]
  • ipconfig1 - optional, same as ipconfig0 format

ISO requirements (non cloud-init)

Kickstart auto install

  • partition /dev/vda
  • network eth1
  • sshd (with preshared key/password)

Network is temprorarily eth1 during the pre-provision phase.

Test

You're going to need vagrant and virtualbox to run the tests:

make test

proxmox-api-go's People

Contributors

aabouzaid avatar aaron-k-t-berry avatar abuisine avatar aerialls avatar alessandrosechi avatar andrzejressel avatar basvandijk avatar carlpett avatar claudusd avatar dmitry-salin avatar doransmestad avatar elbandi avatar faffnir avatar gentoo9ball avatar ggongaware avatar hensur avatar ivanpedersen avatar jda avatar jmreyes avatar johnknott avatar johnpc35 avatar marcellanz avatar matchlighter avatar ni-cwinkelmann avatar osn64 avatar romantomjak avatar thecase avatar v-paranoiaque avatar yukron avatar zardam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.