Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
44602df6
Commit
44602df6
authored
Dec 08, 2014
by
Armon Dadgar
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1675 from cgroschupp/bugfix_vmx_upload
Upload VMX to ESX5 after editing
parents
64397f21
e9246ec4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
0 deletions
+73
-0
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+3
-0
builder/vmware/iso/driver_esx5.go
builder/vmware/iso/driver_esx5.go
+4
-0
builder/vmware/iso/remote_driver.go
builder/vmware/iso/remote_driver.go
+6
-0
builder/vmware/iso/remote_driver_mock.go
builder/vmware/iso/remote_driver_mock.go
+12
-0
builder/vmware/iso/step_upload_vmx.go
builder/vmware/iso/step_upload_vmx.go
+48
-0
No files found.
builder/vmware/iso/builder.go
View file @
44602df6
...
@@ -368,6 +368,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -368,6 +368,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
SkipFloppy
:
true
,
SkipFloppy
:
true
,
},
},
&
vmwcommon
.
StepCleanVMX
{},
&
vmwcommon
.
StepCleanVMX
{},
&
StepUploadVMX
{
RemoteType
:
b
.
config
.
RemoteType
,
},
&
vmwcommon
.
StepCompactDisk
{
&
vmwcommon
.
StepCompactDisk
{
Skip
:
b
.
config
.
SkipCompaction
,
Skip
:
b
.
config
.
SkipCompaction
,
},
},
...
...
builder/vmware/iso/driver_esx5.go
View file @
44602df6
...
@@ -56,6 +56,10 @@ func (d *ESX5Driver) IsRunning(string) (bool, error) {
...
@@ -56,6 +56,10 @@ func (d *ESX5Driver) IsRunning(string) (bool, error) {
return
strings
.
Contains
(
state
,
"Powered on"
),
nil
return
strings
.
Contains
(
state
,
"Powered on"
),
nil
}
}
func
(
d
*
ESX5Driver
)
ReloadVM
()
error
{
return
d
.
sh
(
"vim-cmd"
,
"vmsvc/reload"
,
d
.
vmId
)
}
func
(
d
*
ESX5Driver
)
Start
(
vmxPathLocal
string
,
headless
bool
)
error
{
func
(
d
*
ESX5Driver
)
Start
(
vmxPathLocal
string
,
headless
bool
)
error
{
for
i
:=
0
;
i
<
20
;
i
++
{
for
i
:=
0
;
i
<
20
;
i
++
{
err
:=
d
.
sh
(
"vim-cmd"
,
"vmsvc/power.on"
,
d
.
vmId
)
err
:=
d
.
sh
(
"vim-cmd"
,
"vmsvc/power.on"
,
d
.
vmId
)
...
...
builder/vmware/iso/remote_driver.go
View file @
44602df6
...
@@ -17,4 +17,10 @@ type RemoteDriver interface {
...
@@ -17,4 +17,10 @@ type RemoteDriver interface {
// Removes a VM from inventory specified by the path to the VMX given.
// Removes a VM from inventory specified by the path to the VMX given.
Unregister
(
string
)
error
Unregister
(
string
)
error
// Uploads a local file to remote side.
upload
(
dst
,
src
string
)
error
// Reload VM on remote side.
ReloadVM
()
error
}
}
builder/vmware/iso/remote_driver_mock.go
View file @
44602df6
...
@@ -19,6 +19,10 @@ type RemoteDriverMock struct {
...
@@ -19,6 +19,10 @@ type RemoteDriverMock struct {
UnregisterCalled
bool
UnregisterCalled
bool
UnregisterPath
string
UnregisterPath
string
UnregisterErr
error
UnregisterErr
error
uploadErr
error
ReloadVMErr
error
}
}
func
(
d
*
RemoteDriverMock
)
UploadISO
(
path
string
,
checksum
string
,
checksumType
string
)
(
string
,
error
)
{
func
(
d
*
RemoteDriverMock
)
UploadISO
(
path
string
,
checksum
string
,
checksumType
string
)
(
string
,
error
)
{
...
@@ -38,3 +42,11 @@ func (d *RemoteDriverMock) Unregister(path string) error {
...
@@ -38,3 +42,11 @@ func (d *RemoteDriverMock) Unregister(path string) error {
d
.
UnregisterPath
=
path
d
.
UnregisterPath
=
path
return
d
.
UnregisterErr
return
d
.
UnregisterErr
}
}
func
(
d
*
RemoteDriverMock
)
upload
(
dst
,
src
string
)
error
{
return
d
.
uploadErr
}
func
(
d
*
RemoteDriverMock
)
ReloadVM
()
error
{
return
d
.
ReloadVMErr
}
builder/vmware/iso/step_upload_vmx.go
0 → 100644
View file @
44602df6
package
iso
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
vmwcommon
"github.com/mitchellh/packer/builder/vmware/common"
"path/filepath"
)
// This step upload the VMX to the remote host
//
// Uses:
// driver Driver
// ui packer.Ui
// vmx_path string
//
// Produces:
// <nothing>
type
StepUploadVMX
struct
{
RemoteType
string
}
func
(
c
*
StepUploadVMX
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
driver
:=
state
.
Get
(
"driver"
)
.
(
vmwcommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmxPath
:=
state
.
Get
(
"vmx_path"
)
.
(
string
)
if
c
.
RemoteType
==
"esx5"
{
remoteDriver
,
ok
:=
driver
.
(
RemoteDriver
)
if
ok
{
remoteVmxPath
:=
filepath
.
ToSlash
(
filepath
.
Join
(
fmt
.
Sprintf
(
"%s"
,
remoteDriver
),
filepath
.
Base
(
vmxPath
)))
if
err
:=
remoteDriver
.
upload
(
remoteVmxPath
,
vmxPath
);
err
!=
nil
{
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error writing VMX: %s"
,
err
))
return
multistep
.
ActionHalt
}
}
if
err
:=
remoteDriver
.
ReloadVM
();
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error reload VM: %s"
,
err
))
}
}
return
multistep
.
ActionContinue
}
func
(
StepUploadVMX
)
Cleanup
(
multistep
.
StateBag
)
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment