Rebase and add USE_XE option to xva export
Signed-off-by: Phus Lu <phus.lu@citrix.com>
This commit is contained in:
parent
addd20360c
commit
a850d3d4f0
@ -1,7 +1,7 @@
|
||||
language: go
|
||||
go:
|
||||
# Test with the first and the latest go release - to ensure compatibility
|
||||
- 1.2
|
||||
- release
|
||||
- 1.6
|
||||
- tip
|
||||
script:
|
||||
- gofmtresult=$(gofmt -s -l .); if [[ -n $gofmtresult ]]; then echo -e "Please run \"gofmt -s -w .\" before committing for the below:\n$gofmtresult"; false; fi
|
||||
|
6
build.sh
6
build.sh
@ -6,15 +6,13 @@
|
||||
# Determine the arch/os combos we're building for
|
||||
XC_OS=${XC_OS:-$(go env GOOS)}
|
||||
XC_ARCH=${XC_ARCH:-$(go env GOARCH)}
|
||||
|
||||
# Install dependencies
|
||||
echo "==> Getting dependencies..."
|
||||
go get ./...
|
||||
GOPATH=${GOPATH:-$(go env GOPATH)}
|
||||
|
||||
# Delete the old dir
|
||||
echo "==> Removing old directory..."
|
||||
rm -f bin/*
|
||||
rm -rf pkg/*
|
||||
rm -rf $GOPATH/pkg/*
|
||||
mkdir -p bin/
|
||||
|
||||
gox \
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type StepExport struct{}
|
||||
@ -20,6 +21,7 @@ func downloadFile(url, filename string, ui packer.Ui) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer fh.Close()
|
||||
|
||||
// Define a new transport which allows self-signed certs
|
||||
tr := &http.Transport{
|
||||
@ -101,16 +103,36 @@ func (StepExport) Run(state multistep.StateBag) multistep.StepAction {
|
||||
case "xva":
|
||||
// export the VM
|
||||
|
||||
export_url := fmt.Sprintf("https://%s/export?uuid=%s&session_id=%s",
|
||||
client.Host,
|
||||
instance_uuid,
|
||||
client.Session.(string),
|
||||
)
|
||||
|
||||
export_filename := fmt.Sprintf("%s/%s.xva", config.OutputDir, config.VMName)
|
||||
|
||||
ui.Say("Getting XVA " + export_url)
|
||||
err = downloadFile(export_url, export_filename, ui)
|
||||
use_xe := os.Getenv("USE_XE") == "1"
|
||||
if xe, e := exec.LookPath("xe"); e == nil && use_xe {
|
||||
cmd := exec.Command(
|
||||
xe,
|
||||
"-s", client.Host,
|
||||
"-p", "443",
|
||||
"-u", client.Username,
|
||||
"-pw", client.Password,
|
||||
"vm-export",
|
||||
"vm="+instance_uuid,
|
||||
"compress=true",
|
||||
"filename="+export_filename,
|
||||
)
|
||||
|
||||
ui.Say(fmt.Sprintf("Getting XVA %+v %+v", cmd.Path, cmd.Args))
|
||||
|
||||
err = cmd.Run()
|
||||
} else {
|
||||
export_url := fmt.Sprintf("https://%s/export?uuid=%s&session_id=%s",
|
||||
client.Host,
|
||||
instance_uuid,
|
||||
client.Session.(string),
|
||||
)
|
||||
|
||||
ui.Say("Getting XVA " + export_url)
|
||||
err = downloadFile(export_url, export_filename, ui)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
ui.Error(fmt.Sprintf("Could not download XVA: %s", err.Error()))
|
||||
return multistep.ActionHalt
|
||||
|
@ -1,10 +1,10 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
gossh "code.google.com/p/go.crypto/ssh"
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
xsclient "github.com/xenserver/go-xenserver-client"
|
||||
"log"
|
||||
"time"
|
||||
|
@ -14,8 +14,8 @@ import (
|
||||
hconfig "github.com/mitchellh/packer/helper/config"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"github.com/mitchellh/packer/template/interpolate"
|
||||
xscommon "github.com/rdobson/packer-builder-xenserver/builder/xenserver/common"
|
||||
xsclient "github.com/xenserver/go-xenserver-client"
|
||||
xscommon "github.com/xenserver/packer-builder-xenserver/builder/xenserver/common"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
hconfig "github.com/mitchellh/packer/helper/config"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"github.com/mitchellh/packer/template/interpolate"
|
||||
xscommon "github.com/rdobson/packer-builder-xenserver/builder/xenserver/common"
|
||||
xsclient "github.com/xenserver/go-xenserver-client"
|
||||
xscommon "github.com/xenserver/packer-builder-xenserver/builder/xenserver/common"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
xscommon "github.com/rdobson/packer-builder-xenserver/builder/xenserver/common"
|
||||
xsclient "github.com/xenserver/go-xenserver-client"
|
||||
xscommon "github.com/xenserver/packer-builder-xenserver/builder/xenserver/common"
|
||||
)
|
||||
|
||||
type stepImportInstance struct {
|
||||
|
@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/packer/packer/plugin"
|
||||
"github.com/rdobson/packer-builder-xenserver/builder/xenserver/iso"
|
||||
"github.com/xenserver/packer-builder-xenserver/builder/xenserver/iso"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/packer/packer/plugin"
|
||||
"github.com/rdobson/packer-builder-xenserver/builder/xenserver/xva"
|
||||
"github.com/xenserver/packer-builder-xenserver/builder/xenserver/xva"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
Loading…
Reference in New Issue
Block a user