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
0cfe5819
Commit
0cfe5819
authored
Sep 17, 2014
by
Mikhail Zholobov
Committed by
Rickard von Essen
Oct 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/parallels: Added driver method 'DeviceAddCdRom'
parent
5394ce61
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
+39
-0
builder/parallels/common/driver.go
builder/parallels/common/driver.go
+3
-0
builder/parallels/common/driver_9.go
builder/parallels/common/driver_9.go
+23
-0
builder/parallels/common/driver_mock.go
builder/parallels/common/driver_mock.go
+13
-0
No files found.
builder/parallels/common/driver.go
View file @
0cfe5819
...
@@ -15,6 +15,9 @@ import (
...
@@ -15,6 +15,9 @@ import (
// versions out of the builder steps, so sometimes the methods are
// versions out of the builder steps, so sometimes the methods are
// extremely specific.
// extremely specific.
type
Driver
interface
{
type
Driver
interface
{
// Adds new CD/DVD drive to the VM and returns name of this device
DeviceAddCdRom
(
string
,
string
)
(
string
,
error
)
// Import a VM
// Import a VM
Import
(
string
,
string
,
string
,
bool
)
error
Import
(
string
,
string
,
string
,
bool
)
error
...
...
builder/parallels/common/driver_9.go
View file @
0cfe5819
...
@@ -95,6 +95,29 @@ func getAppPath(bundleId string) (string, error) {
...
@@ -95,6 +95,29 @@ func getAppPath(bundleId string) (string, error) {
return
pathOutput
,
nil
return
pathOutput
,
nil
}
}
func
(
d
*
Parallels9Driver
)
DeviceAddCdRom
(
name
string
,
image
string
)
(
string
,
error
)
{
command
:=
[]
string
{
"set"
,
name
,
"--device-add"
,
"cdrom"
,
"--image"
,
image
,
}
out
,
err
:=
exec
.
Command
(
d
.
PrlctlPath
,
command
...
)
.
Output
()
if
err
!=
nil
{
return
""
,
err
}
deviceRe
:=
regexp
.
MustCompile
(
`\s+(cdrom\d+)\s+`
)
matches
:=
deviceRe
.
FindStringSubmatch
(
string
(
out
))
if
matches
==
nil
{
return
""
,
fmt
.
Errorf
(
"Could not determine cdrom device name in the output:
\n
%s"
,
string
(
out
))
}
device_name
:=
matches
[
1
]
return
device_name
,
nil
}
func
(
d
*
Parallels9Driver
)
IsRunning
(
name
string
)
(
bool
,
error
)
{
func
(
d
*
Parallels9Driver
)
IsRunning
(
name
string
)
(
bool
,
error
)
{
var
stdout
bytes
.
Buffer
var
stdout
bytes
.
Buffer
...
...
builder/parallels/common/driver_mock.go
View file @
0cfe5819
...
@@ -5,6 +5,12 @@ import "sync"
...
@@ -5,6 +5,12 @@ import "sync"
type
DriverMock
struct
{
type
DriverMock
struct
{
sync
.
Mutex
sync
.
Mutex
DeviceAddCdRomCalled
bool
DeviceAddCdRomName
string
DeviceAddCdRomImage
string
DeviceAddCdRomResult
string
DeviceAddCdRomErr
error
ImportCalled
bool
ImportCalled
bool
ImportName
string
ImportName
string
ImportSrcPath
string
ImportSrcPath
string
...
@@ -45,6 +51,13 @@ type DriverMock struct {
...
@@ -45,6 +51,13 @@ type DriverMock struct {
IpAddressError
error
IpAddressError
error
}
}
func
(
d
*
DriverMock
)
DeviceAddCdRom
(
name
string
,
image
string
)
(
string
,
error
)
{
d
.
DeviceAddCdRomCalled
=
true
d
.
DeviceAddCdRomName
=
name
d
.
DeviceAddCdRomImage
=
image
return
d
.
DeviceAddCdRomResult
,
d
.
DeviceAddCdRomErr
}
func
(
d
*
DriverMock
)
Import
(
name
,
srcPath
,
dstPath
string
,
reassignMac
bool
)
error
{
func
(
d
*
DriverMock
)
Import
(
name
,
srcPath
,
dstPath
string
,
reassignMac
bool
)
error
{
d
.
ImportCalled
=
true
d
.
ImportCalled
=
true
d
.
ImportName
=
name
d
.
ImportName
=
name
...
...
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