Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
756f4d7e1a | ||
|
4894eca5d3 | ||
|
d111a01612 | ||
|
fc6694679c | ||
|
36658a7875 | ||
|
deba45ef3a | ||
|
1e9c3eb66a | ||
|
7077d1e374 | ||
|
54738803d5 | ||
|
0ff8fa1e77 | ||
|
4b07607b11 | ||
|
bf1383d1e8 | ||
|
13c2a1d78a | ||
|
2a36fae810 | ||
|
c411df4b02 | ||
|
cc03e4a10c | ||
|
7147cb4592 | ||
|
1b20fbac99 | ||
|
6c9ee9dc94 | ||
|
b38a3b67bc | ||
|
a776a46e1e | ||
|
d11786a294 | ||
|
7a9e710071 | ||
|
88e56ca729 |
2
.github/workflows/go-test.yml
vendored
2
.github/workflows/go-test.yml
vendored
@ -19,6 +19,6 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.17
|
go-version: "1.20"
|
||||||
- name: Run go tests
|
- name: Run go tests
|
||||||
run: go test -race -count 1 ./... -timeout=3m
|
run: go test -race -count 1 ./... -timeout=3m
|
||||||
|
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.17
|
go-version: "1.20"
|
||||||
- name: Describe plugin
|
- name: Describe plugin
|
||||||
id: plugin_describe
|
id: plugin_describe
|
||||||
run: echo "::set-output name=api_version::$(go run . describe | jq -r '.api_version')"
|
run: echo "::set-output name=api_version::$(go run . describe | jq -r '.api_version')"
|
||||||
@ -36,10 +36,10 @@ jobs:
|
|||||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||||
- name: Run GoReleaser
|
- name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist
|
args: release --clean
|
||||||
env:
|
env:
|
||||||
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
1
.go-version
Normal file
1
.go-version
Normal file
@ -0,0 +1 @@
|
|||||||
|
1.20.11
|
@ -1,3 +1,4 @@
|
|||||||
|
version: 2
|
||||||
# This is an example goreleaser.yaml file with some sane defaults.
|
# This is an example goreleaser.yaml file with some sane defaults.
|
||||||
# Make sure to check the documentation at http://goreleaser.com
|
# Make sure to check the documentation at http://goreleaser.com
|
||||||
env:
|
env:
|
||||||
@ -70,4 +71,4 @@ release:
|
|||||||
draft: false
|
draft: false
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
skip: true
|
disable: true
|
||||||
|
@ -45,7 +45,7 @@ If you are using an older version of packer or are still using json templates yo
|
|||||||
### Dependencies
|
### Dependencies
|
||||||
* Packer >= v1.7.1 (https://packer.io)
|
* Packer >= v1.7.1 (https://packer.io)
|
||||||
* XenServer / Citrix Hypervisor > 7.6
|
* XenServer / Citrix Hypervisor > 7.6
|
||||||
* Golang 1.17
|
* Golang 1.20
|
||||||
|
|
||||||
## Compile the plugin
|
## Compile the plugin
|
||||||
|
|
||||||
|
@ -32,8 +32,8 @@ type StepTypeBootCommand struct {
|
|||||||
Ctx interpolate.Context
|
Ctx interpolate.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
func (step *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||||
config := state.Get("commonconfig").(CommonConfig)
|
config := state.Get("config").(Config)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
c := state.Get("client").(*Connection)
|
c := state.Get("client").(*Connection)
|
||||||
httpPort := state.Get("http_port").(int)
|
httpPort := state.Get("http_port").(int)
|
||||||
@ -74,7 +74,8 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
|
|||||||
}
|
}
|
||||||
locationPieces := strings.SplitAfter(location, "/")
|
locationPieces := strings.SplitAfter(location, "/")
|
||||||
consoleHost := strings.TrimSuffix(locationPieces[2], "/")
|
consoleHost := strings.TrimSuffix(locationPieces[2], "/")
|
||||||
ui.Say(fmt.Sprintf("Connecting to the VM console VNC over xapi via %s", consoleHost))
|
ui.Say("Connecting to VNC over XAPI...")
|
||||||
|
log.Printf("Connecting to host: %s", consoleHost)
|
||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:443", consoleHost))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:443", consoleHost))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -95,7 +96,7 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
|
|||||||
httpReq := fmt.Sprintf("CONNECT %s HTTP/1.0\r\nHost: %s\r\nCookie: session_id=%s\r\n\r\n", consoleLocation, consoleHost, c.session)
|
httpReq := fmt.Sprintf("CONNECT %s HTTP/1.0\r\nHost: %s\r\nCookie: session_id=%s\r\n\r\n", consoleLocation, consoleHost, c.session)
|
||||||
fmt.Printf("Sending the follow http req: %v", httpReq)
|
fmt.Printf("Sending the follow http req: %v", httpReq)
|
||||||
|
|
||||||
ui.Say(fmt.Sprintf("Making HTTP request to initiate VNC connection: %s", httpReq))
|
ui.Message(fmt.Sprintf("Making HTTP request to initiate VNC connection: %s", httpReq))
|
||||||
_, err = io.WriteString(tlsConn, httpReq)
|
_, err = io.WriteString(tlsConn, httpReq)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -114,9 +115,9 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
|
|||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.Say(fmt.Sprintf("Received response: %s", string(buffer)))
|
ui.Message(fmt.Sprintf("Received response: %s", string(buffer)))
|
||||||
|
|
||||||
vncClient, err := vnc.Client(tlsConn, &vnc.ClientConfig{Exclusive: true})
|
vncClient, err := vnc.Client(tlsConn, &vnc.ClientConfig{Exclusive: !config.PackerDebug})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error establishing VNC session: %s", err)
|
err := fmt.Errorf("Error establishing VNC session: %s", err)
|
||||||
@ -142,7 +143,7 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
|
|||||||
localIp := strings.Split(envVar, " ")[0]
|
localIp := strings.Split(envVar, " ")[0]
|
||||||
ui.Message(fmt.Sprintf("Found local IP: %s", localIp))
|
ui.Message(fmt.Sprintf("Found local IP: %s", localIp))
|
||||||
|
|
||||||
self.Ctx.Data = &bootCommandTemplateData{
|
step.Ctx.Data = &bootCommandTemplateData{
|
||||||
config.VMName,
|
config.VMName,
|
||||||
localIp,
|
localIp,
|
||||||
uint(httpPort),
|
uint(httpPort),
|
||||||
@ -151,7 +152,7 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
|
|||||||
ui.Say("Typing boot commands over VNC...")
|
ui.Say("Typing boot commands over VNC...")
|
||||||
for _, command := range config.BootCommand {
|
for _, command := range config.BootCommand {
|
||||||
|
|
||||||
command, err := interpolate.Render(command, &self.Ctx)
|
command, err := interpolate.Render(command, &step.Ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("Error preparing boot command: %s", err)
|
err := fmt.Errorf("Error preparing boot command: %s", err)
|
||||||
state.Put("error", err)
|
state.Put("error", err)
|
||||||
@ -167,12 +168,10 @@ func (self *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateB
|
|||||||
vncSendString(vncClient, command)
|
vncSendString(vncClient, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.Say("Finished typing.")
|
|
||||||
|
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StepTypeBootCommand) Cleanup(multistep.StateBag) {}
|
func (step *StepTypeBootCommand) Cleanup(multistep.StateBag) {}
|
||||||
|
|
||||||
// Taken from qemu's builder plugin - not an exported function.
|
// Taken from qemu's builder plugin - not an exported function.
|
||||||
func vncSendString(c *vnc.ClientConn, original string) {
|
func vncSendString(c *vnc.ClientConn, original string) {
|
||||||
|
27
go.mod
27
go.mod
@ -1,15 +1,15 @@
|
|||||||
module github.com/xenserver/packer-builder-xenserver
|
module github.com/xenserver/packer-builder-xenserver
|
||||||
|
|
||||||
go 1.17
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/amfranz/go-xmlrpc-client v0.0.0-20190612172737-76858463955d
|
github.com/amfranz/go-xmlrpc-client v0.0.0-20190612172737-76858463955d
|
||||||
github.com/hashicorp/hcl/v2 v2.12.0
|
github.com/hashicorp/hcl/v2 v2.20.1
|
||||||
github.com/hashicorp/packer-plugin-sdk v0.3.0
|
github.com/hashicorp/packer-plugin-sdk v0.3.0
|
||||||
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed
|
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed
|
||||||
github.com/terra-farm/go-xen-api-client v0.0.2
|
github.com/terra-farm/go-xen-api-client v0.0.2
|
||||||
github.com/zclconf/go-cty v1.10.0
|
github.com/zclconf/go-cty v1.14.4
|
||||||
golang.org/x/crypto v0.19.0
|
golang.org/x/crypto v0.24.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@ -22,6 +22,7 @@ require (
|
|||||||
github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 // indirect
|
github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 // indirect
|
||||||
github.com/agext/levenshtein v1.2.3 // indirect
|
github.com/agext/levenshtein v1.2.3 // indirect
|
||||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
||||||
github.com/armon/go-metrics v0.3.9 // indirect
|
github.com/armon/go-metrics v0.3.9 // indirect
|
||||||
github.com/aws/aws-sdk-go v1.40.34 // indirect
|
github.com/aws/aws-sdk-go v1.40.34 // indirect
|
||||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
||||||
@ -33,7 +34,7 @@ require (
|
|||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/golang/snappy v0.0.4 // indirect
|
github.com/golang/snappy v0.0.4 // indirect
|
||||||
github.com/google/go-cmp v0.5.9 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/google/uuid v1.3.0 // indirect
|
github.com/google/uuid v1.3.0 // indirect
|
||||||
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
|
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
|
||||||
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
|
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
|
||||||
@ -80,20 +81,24 @@ require (
|
|||||||
github.com/ugorji/go/codec v1.2.6 // indirect
|
github.com/ugorji/go/codec v1.2.6 // indirect
|
||||||
github.com/ulikunitz/xz v0.5.10 // indirect
|
github.com/ulikunitz/xz v0.5.10 // indirect
|
||||||
go.opencensus.io v0.24.0 // indirect
|
go.opencensus.io v0.24.0 // indirect
|
||||||
golang.org/x/net v0.17.0 // indirect
|
golang.org/x/mod v0.17.0 // indirect
|
||||||
|
golang.org/x/net v0.25.0 // indirect
|
||||||
golang.org/x/oauth2 v0.7.0 // indirect
|
golang.org/x/oauth2 v0.7.0 // indirect
|
||||||
golang.org/x/sync v0.3.0 // indirect
|
golang.org/x/sync v0.7.0 // indirect
|
||||||
golang.org/x/sys v0.17.0 // indirect
|
golang.org/x/sys v0.21.0 // indirect
|
||||||
golang.org/x/term v0.17.0 // indirect
|
golang.org/x/term v0.21.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.16.0 // indirect
|
||||||
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
|
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
|
||||||
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
||||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||||
google.golang.org/api v0.114.0 // indirect
|
google.golang.org/api v0.114.0 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
|
||||||
google.golang.org/grpc v1.56.3 // indirect
|
google.golang.org/grpc v1.56.3 // indirect
|
||||||
google.golang.org/protobuf v1.30.0 // indirect
|
google.golang.org/protobuf v1.33.0 // indirect
|
||||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
|
||||||
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
|
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/zclconf/go-cty => github.com/nywilken/go-cty v1.13.3 // added by packer-sdc fix as noted in github.com/hashicorp/packer-plugin-sdk/issues/187
|
||||||
|
18
main.go
18
main.go
@ -6,30 +6,16 @@ import (
|
|||||||
|
|
||||||
"github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso"
|
"github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso"
|
||||||
"github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva"
|
"github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva"
|
||||||
|
"github.com/xenserver/packer-builder-xenserver/version"
|
||||||
|
|
||||||
"github.com/hashicorp/packer-plugin-sdk/plugin"
|
"github.com/hashicorp/packer-plugin-sdk/plugin"
|
||||||
"github.com/hashicorp/packer-plugin-sdk/version"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// Version is the main version number that is being run at the moment.
|
|
||||||
Version = "v0.6.0"
|
|
||||||
|
|
||||||
// VersionPrerelease is A pre-release marker for the Version. If this is ""
|
|
||||||
// (empty string) then it means that it is a final release. Otherwise, this
|
|
||||||
// is a pre-release such as "dev" (in development), "beta", "rc1", etc.
|
|
||||||
VersionPrerelease = ""
|
|
||||||
|
|
||||||
// PluginVersion is used by the plugin set to allow Packer to recognize
|
|
||||||
// what version this plugin is.
|
|
||||||
PluginVersion = version.InitializePluginVersion(Version, VersionPrerelease)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
pps := plugin.NewSet()
|
pps := plugin.NewSet()
|
||||||
pps.RegisterBuilder("iso", new(iso.Builder))
|
pps.RegisterBuilder("iso", new(iso.Builder))
|
||||||
pps.RegisterBuilder("xva", new(xva.Builder))
|
pps.RegisterBuilder("xva", new(xva.Builder))
|
||||||
pps.SetVersion(PluginVersion)
|
pps.SetVersion(version.PluginVersion)
|
||||||
err := pps.Run()
|
err := pps.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err.Error())
|
fmt.Fprintln(os.Stderr, err.Error())
|
||||||
|
19
version/version.go
Normal file
19
version/version.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/packer-plugin-sdk/version"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Version is the main version number that is being run at the moment.
|
||||||
|
Version = "v0.6.0"
|
||||||
|
|
||||||
|
// VersionPrerelease is A pre-release marker for the Version. If this is ""
|
||||||
|
// (empty string) then it means that it is a final release. Otherwise, this
|
||||||
|
// is a pre-release such as "dev" (in development), "beta", "rc1", etc.
|
||||||
|
VersionPrerelease = "dev"
|
||||||
|
|
||||||
|
// PluginVersion is used by the plugin set to allow Packer to recognize
|
||||||
|
// what version this plugin is.
|
||||||
|
PluginVersion = version.InitializePluginVersion(Version, VersionPrerelease)
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user