Skip to content

Commit

Permalink
Merge branch 'master' into fix-memory-type-proxmox-8.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mleone87 committed Dec 6, 2023
2 parents 9d51f1e + cd1b0d8 commit b3f8683
Show file tree
Hide file tree
Showing 68 changed files with 13,356 additions and 546 deletions.
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export PM_HTTP_HEADERS=Key,Value,Key1,Value1 (only if required)

./proxmox-api-go node shutdown proxmox-node-name

./proxmox-api-go unlink 123 proxmox-node-name "virtio1,virtio2,virtioN" [false|true]

```
## Proxy server support
Expand Down Expand Up @@ -157,6 +159,11 @@ createQemu JSON Sample:
"tag": -1
}
},
"rng0": {
"source": "/dev/urandom",
"max_bytes": "1024",
"period": "1000"
},
"usb": {
"0": {
"host": "0658:0200",
Expand Down
30 changes: 28 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Vagrant.configure("2") do |config|
config.vm.box = "debian/buster64"
config.vm.box = "generic/debian11"

config.vm.boot_timeout = 1800
config.vm.synced_folder ".", "/vagrant", disabled: true
Expand All @@ -11,13 +11,39 @@ Vagrant.configure("2") do |config|
host: 8006

# install and configure proxmox
config.vm.provision "shell",
config.vm.provision "Bootstrap System",
type: "shell",
privileged: true,
path: './scripts/vagrant-bootstrap.sh'

config.vm.provision "Import LXC Template",
type: "shell",
privileged: true,
path: './scripts/vagrant-get-container-template.sh',
run: "always"

config.vm.provision "Download Cloud-Init Template",
type: "shell",
privileged: true,
path: './scripts/vagrant-get-cloudinit-template.sh',
run: "always"

config.vm.provider :virtualbox do |vb|
vb.memory = 2048
vb.cpus = 2
vb.customize ["modifyvm", :id, "--nested-hw-virt", "on"]
end

config.vm.provider :hyperv do |hv|
hv.memory = 2048
hv.cpus = 2
hv.enable_virtualization_extensions = true
end

config.vm.provider :vmware do |vm|
vm.vmx["memsize"] = "2048"
vm.vmx["numvcpus"] = "2"
vm.vmx["vhv.enable"] = "TRUE"
end

config.vm.provider :libvirt do |v, override|
Expand Down
1 change: 1 addition & 0 deletions cli/command/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
_ "github.com/Telmate/proxmox-api-go/cli/command/delete"
_ "github.com/Telmate/proxmox-api-go/cli/command/example"
_ "github.com/Telmate/proxmox-api-go/cli/command/get"
_ "github.com/Telmate/proxmox-api-go/cli/command/get/guest"
_ "github.com/Telmate/proxmox-api-go/cli/command/get/id"
_ "github.com/Telmate/proxmox-api-go/cli/command/guest"
_ "github.com/Telmate/proxmox-api-go/cli/command/guest/qemu"
Expand Down
10 changes: 8 additions & 2 deletions cli/command/create/create-snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@ var (
id := cli.ValidateIntIDset(args, "GuestID")
snapName := cli.RequiredIDset(args, 1, "SnapshotName")
config := proxmox.ConfigSnapshot{
Name: snapName,
Name: proxmox.SnapshotName(snapName),
Description: cli.OptionalIDset(args, 2),
VmState: memory,
}
memory = false
err = config.CreateSnapshot(cli.NewClient(), uint(id))
client := cli.NewClient()
vmr := proxmox.NewVmRef(id)
_, err = client.GetVmInfo(vmr)
if err != nil {
return
}
err = config.CreateSnapshot(client, vmr)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/delete/delete-snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
RunE: func(cmd *cobra.Command, args []string) (err error) {
id := cli.ValidateIntIDset(args, "GuestID")
snapName := cli.RequiredIDset(args, 1, "SnapshotName")
_, err = proxmox.DeleteSnapshot(cli.NewClient(), proxmox.NewVmRef(id), snapName)
_, err = proxmox.DeleteSnapshot(cli.NewClient(), proxmox.NewVmRef(id), proxmox.SnapshotName(snapName))
if err != nil {
return
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package get
package guest

import (
"github.com/Telmate/proxmox-api-go/cli"
"github.com/Telmate/proxmox-api-go/proxmox"
"github.com/spf13/cobra"
)

var get_guestCmd = &cobra.Command{
Use: "guest GUESTID",
var configCmd = &cobra.Command{
Use: "config GUESTID",
Short: "Gets the configuration of the specified guest",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand All @@ -29,11 +29,11 @@ var get_guestCmd = &cobra.Command{
if err != nil {
return
}
cli.PrintFormattedJson(GetCmd.OutOrStdout(), config)
cli.PrintFormattedJson(guestCmd.OutOrStdout(), config)
return
},
}

func init() {
GetCmd.AddCommand(get_guestCmd)
guestCmd.AddCommand(configCmd)
}
32 changes: 32 additions & 0 deletions cli/command/get/guest/get-guest-feature.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package guest

import (
"github.com/Telmate/proxmox-api-go/cli"
"github.com/Telmate/proxmox-api-go/proxmox"
"github.com/spf13/cobra"
)

var featureCmd = &cobra.Command{
Use: "feature GUESTID",
Short: "Gets the available features of the specified guest",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
id := cli.ValidateIntIDset(args, "GuestID")
vmr := proxmox.NewVmRef(id)
c := cli.NewClient()
err = c.CheckVmRef(vmr)
if err != nil {
return
}
features, err := proxmox.ListGuestFeatures(vmr, c)
if err != nil {
return
}
cli.PrintFormattedJson(guestCmd.OutOrStdout(), features)
return
},
}

func init() {
guestCmd.AddCommand(featureCmd)
}
15 changes: 15 additions & 0 deletions cli/command/get/guest/get-guest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package guest

import (
"github.com/Telmate/proxmox-api-go/cli/command/get"
"github.com/spf13/cobra"
)

var guestCmd = &cobra.Command{
Use: "guest",
Short: "Commands to get information of guests on Proxmox",
}

func init() {
get.GetCmd.AddCommand(guestCmd)
}
7 changes: 6 additions & 1 deletion cli/command/list/list-guests.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package list

import (
"github.com/Telmate/proxmox-api-go/cli"
"github.com/Telmate/proxmox-api-go/proxmox"
"github.com/spf13/cobra"
)

Expand All @@ -9,7 +11,10 @@ var list_qemuguestsCmd = &cobra.Command{
Short: "Prints a list of Qemu/Lxc Guests in raw json format",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
listRaw("Guests")
c := cli.NewClient()
guests, err := proxmox.ListGuests(c)
cli.LogFatalListing("Guests", err)
cli.PrintRawJson(listCmd.OutOrStdout(), guests)
},
}

Expand Down
6 changes: 3 additions & 3 deletions cli/command/list/list-snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ var (
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
id := cli.ValidateExistingGuestID(args, 0)
jBody, err := proxmox.ListSnapshots(cli.NewClient(), proxmox.NewVmRef(id))
rawSnapshots, err := proxmox.ListSnapshots(cli.NewClient(), proxmox.NewVmRef(id))
if err != nil {
noTree = false
return
}
var list []*proxmox.Snapshot
if noTree {
noTree = false
list = proxmox.FormatSnapshotsList(jBody)
list = rawSnapshots.FormatSnapshotsList()
} else {
list = proxmox.FormatSnapshotsTree(jBody)
list = rawSnapshots.FormatSnapshotsTree()
}
if len(list) == 0 {
listCmd.Printf("Guest with ID (%d) has no snapshots", id)
Expand Down
2 changes: 0 additions & 2 deletions cli/command/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ func listRaw(IDtype string) {
list, err = c.GetAcmeAccountList()
case "AcmePlugins":
list, err = c.GetAcmePluginList()
case "Guests":
list, err = c.GetVmList()
case "MetricServers":
list, err = c.GetMetricsServerList()
case "Nodes":
Expand Down
2 changes: 1 addition & 1 deletion cli/command/update/update-snapshotdescription.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var update_snapshotCmd = &cobra.Command{
id := cli.ValidateIntIDset(args, "GuestID")
snapName := cli.RequiredIDset(args, 1, "SnapshotName")
des := cli.OptionalIDset(args, 2)
err = proxmox.UpdateSnapshotDescription(cli.NewClient(), proxmox.NewVmRef(id), snapName, des)
err = proxmox.UpdateSnapshotDescription(cli.NewClient(), proxmox.NewVmRef(id), proxmox.SnapshotName(snapName), des)
if err != nil {
return
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module github.com/Telmate/proxmox-api-go

go 1.18
go 1.19

require (
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.0
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.2
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
14 changes: 7 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit b3f8683

Please sign in to comment.