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
05affcea
Commit
05affcea
authored
Nov 27, 2014
by
Mikhail Zholobov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/parallels: Attach bootable ISO exactly to cdrom0 [GH-1667]
parent
347f02a7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
40 deletions
+19
-40
builder/parallels/iso/step_attach_iso.go
builder/parallels/iso/step_attach_iso.go
+19
-40
No files found.
builder/parallels/iso/step_attach_iso.go
View file @
05affcea
...
...
@@ -17,9 +17,8 @@ import (
// vmName string
//
// Produces:
type
stepAttachISO
struct
{
cdromDevice
string
}
// attachedIso bool
type
stepAttachISO
struct
{}
func
(
s
*
stepAttachISO
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
driver
:=
state
.
Get
(
"driver"
)
.
(
parallelscommon
.
Driver
)
...
...
@@ -27,22 +26,11 @@ func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction {
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
// Attach the disk to the controller
ui
.
Say
(
"Attaching ISO to the new CD/DVD drive..."
)
cdrom
,
err
:=
driver
.
DeviceAddCdRom
(
vmName
,
isoPath
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error attaching ISO: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
// Set new boot order
ui
.
Say
(
"Setting the boot order..."
)
command
:=
[]
string
{
"set"
,
vmName
,
"--device-bootorder"
,
fmt
.
Sprintf
(
"hdd0
%s cdrom0 net0"
,
cdrom
),
"--device-bootorder"
,
fmt
.
Sprintf
(
"hdd0
cdrom0 net0"
),
}
if
err
:=
driver
.
Prlctl
(
command
...
);
err
!=
nil
{
...
...
@@ -52,51 +40,42 @@ func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
}
//
Disable 'cdrom0' device
ui
.
Say
(
"
Disabling default CD/DVD driv
e..."
)
//
Attach the disk to the cdrom0 device. We couldn't use a separated device because it is failed to boot in PD9 [GH-1667]
ui
.
Say
(
"
Attaching ISO to the default CD/DVD ROM devic
e..."
)
command
=
[]
string
{
"set"
,
vmName
,
"--device-set"
,
"cdrom0"
,
"--disable"
,
"--device-set"
,
"cdrom0"
,
"--image"
,
isoPath
,
"--enable"
,
"--connect"
,
}
if
err
:=
driver
.
Prlctl
(
command
...
);
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error
disabling default CD/DVD drive
: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error
attaching ISO
: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
//
Track the device name so that we can can delete later
s
.
cdromDevice
=
cdrom
//
Set some state so we know to remove
s
tate
.
Put
(
"attachedIso"
,
true
)
return
multistep
.
ActionContinue
}
func
(
s
*
stepAttachISO
)
Cleanup
(
state
multistep
.
StateBag
)
{
if
_
,
ok
:=
state
.
GetOk
(
"attachedIso"
);
!
ok
{
return
}
driver
:=
state
.
Get
(
"driver"
)
.
(
parallelscommon
.
Driver
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
vmName
:=
state
.
Get
(
"vmName"
)
.
(
string
)
//
Enable 'cdrom0' device back
log
.
Println
(
"
Enabling default CD/DVD driv
e..."
)
//
Detach ISO by setting an empty string image.
log
.
Println
(
"
Detaching ISO from the default CD/DVD ROM devic
e..."
)
command
:=
[]
string
{
"set"
,
vmName
,
"--device-set"
,
"cdrom0"
,
"--enable"
,
"--disconnect"
,
}
if
err
:=
driver
.
Prlctl
(
command
...
);
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
"Error enabling default CD/DVD drive: %s"
,
err
))
}
// Detach ISO
if
s
.
cdromDevice
==
""
{
return
}
log
.
Println
(
"Detaching ISO..."
)
command
=
[]
string
{
"set"
,
vmName
,
"--device-del"
,
s
.
cdromDevice
,
"--device-set"
,
"cdrom0"
,
"--image"
,
""
,
"--disconnect"
,
"--enable"
,
}
if
err
:=
driver
.
Prlctl
(
command
...
);
err
!=
nil
{
...
...
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