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
c338d313
Commit
c338d313
authored
Feb 24, 2015
by
Seth Vargo
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1925 from tdooner/add_rackconnect_support
Add Rackconnect support to openstack builder
parents
d4d829a0
726f5c45
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
2 deletions
+66
-2
builder/openstack/builder.go
builder/openstack/builder.go
+4
-1
builder/openstack/run_config.go
builder/openstack/run_config.go
+3
-0
builder/openstack/ssh.go
builder/openstack/ssh.go
+6
-1
builder/openstack/step_wait_for_rackconnect.go
builder/openstack/step_wait_for_rackconnect.go
+45
-0
website/source/docs/builders/openstack.html.markdown
website/source/docs/builders/openstack.html.markdown
+8
-0
No files found.
builder/openstack/builder.go
View file @
c338d313
...
...
@@ -95,12 +95,15 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
SecurityGroups
:
b
.
config
.
SecurityGroups
,
Networks
:
b
.
config
.
Networks
,
},
&
StepWaitForRackConnect
{
Wait
:
b
.
config
.
RackconnectWait
,
},
&
StepAllocateIp
{
FloatingIpPool
:
b
.
config
.
FloatingIpPool
,
FloatingIp
:
b
.
config
.
FloatingIp
,
},
&
common
.
StepConnectSSH
{
SSHAddress
:
SSHAddress
(
csp
,
b
.
config
.
SSHPort
),
SSHAddress
:
SSHAddress
(
csp
,
b
.
config
.
SSH
Interface
,
b
.
config
.
SSH
Port
),
SSHConfig
:
SSHConfig
(
b
.
config
.
SSHUsername
),
SSHWaitTimeout
:
b
.
config
.
SSHTimeout
(),
},
...
...
builder/openstack/run_config.go
View file @
c338d313
...
...
@@ -15,8 +15,10 @@ type RunConfig struct {
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPort
int
`mapstructure:"ssh_port"`
SSHInterface
string
`mapstructure:"ssh_interface"`
OpenstackProvider
string
`mapstructure:"openstack_provider"`
UseFloatingIp
bool
`mapstructure:"use_floating_ip"`
RackconnectWait
bool
`mapstructure:"rackconnect_wait"`
FloatingIpPool
string
`mapstructure:"floating_ip_pool"`
FloatingIp
string
`mapstructure:"floating_ip"`
SecurityGroups
[]
string
`mapstructure:"security_groups"`
...
...
@@ -71,6 +73,7 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
"flavor"
:
&
c
.
Flavor
,
"ssh_timeout"
:
&
c
.
RawSSHTimeout
,
"ssh_username"
:
&
c
.
SSHUsername
,
"ssh_interface"
:
&
c
.
SSHInterface
,
"source_image"
:
&
c
.
SourceImage
,
"openstack_provider"
:
&
c
.
OpenstackProvider
,
"floating_ip_pool"
:
&
c
.
FloatingIpPool
,
...
...
builder/openstack/ssh.go
View file @
c338d313
...
...
@@ -12,7 +12,7 @@ import (
// SSHAddress returns a function that can be given to the SSH communicator
// for determining the SSH address based on the server AccessIPv4 setting..
func
SSHAddress
(
csp
gophercloud
.
CloudServersProvider
,
port
int
)
func
(
multistep
.
StateBag
)
(
string
,
error
)
{
func
SSHAddress
(
csp
gophercloud
.
CloudServersProvider
,
sshinterface
string
,
port
int
)
func
(
multistep
.
StateBag
)
(
string
,
error
)
{
return
func
(
state
multistep
.
StateBag
)
(
string
,
error
)
{
s
:=
state
.
Get
(
"server"
)
.
(
*
gophercloud
.
Server
)
...
...
@@ -25,6 +25,11 @@ func SSHAddress(csp gophercloud.CloudServersProvider, port int) func(multistep.S
return
""
,
errors
.
New
(
"Error parsing SSH addresses"
)
}
for
pool
,
addresses
:=
range
ip_pools
{
if
sshinterface
!=
""
{
if
pool
!=
sshinterface
{
continue
}
}
if
pool
!=
""
{
for
_
,
address
:=
range
addresses
{
if
address
.
Addr
!=
""
&&
address
.
Version
==
4
{
...
...
builder/openstack/step_wait_for_rackconnect.go
0 → 100644
View file @
c338d313
package
openstack
import
(
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"time"
"github.com/mitchellh/gophercloud-fork-40444fb"
)
type
StepWaitForRackConnect
struct
{
Wait
bool
}
func
(
s
*
StepWaitForRackConnect
)
Run
(
state
multistep
.
StateBag
)
multistep
.
StepAction
{
if
!
s
.
Wait
{
return
multistep
.
ActionContinue
}
csp
:=
state
.
Get
(
"csp"
)
.
(
gophercloud
.
CloudServersProvider
)
server
:=
state
.
Get
(
"server"
)
.
(
*
gophercloud
.
Server
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
fmt
.
Printf
(
"%s"
,
server
)
ui
.
Say
(
fmt
.
Sprintf
(
"Waiting for server (%s) to become RackConnect ready..."
,
server
.
Id
))
for
{
server
,
err
:=
csp
.
ServerById
(
server
.
Id
)
if
err
!=
nil
{
return
multistep
.
ActionHalt
}
if
server
.
Metadata
[
"rackconnect_automation_status"
]
==
"DEPLOYED"
{
break
}
time
.
Sleep
(
2
*
time
.
Second
)
}
return
multistep
.
ActionContinue
}
func
(
s
*
StepWaitForRackConnect
)
Cleanup
(
state
multistep
.
StateBag
)
{
}
website/source/docs/builders/openstack.html.markdown
View file @
c338d313
...
...
@@ -102,12 +102,20 @@ each category, the available configuration keys are alphabetized.
*
`ssh_username`
(string) - The username to use in order to communicate
over SSH to the running server. The default is "root".
*
`ssh_interface`
(string) - The type of interface to connect via SSH. Values
useful for Rackspace are "public" or "private", and the default behavior is
to connect via whichever is returned first from the OpenStack API.
*
`tenant_id`
(string) - Tenant ID for accessing OpenStack if your
installation requires this.
*
`use_floating_ip`
(boolean) - Whether or not to use a floating IP for
the instance. Defaults to false.
*
`rackconnect_wait`
(boolean) - For rackspace, whether or not to wait for
Rackconnect to assign the machine an IP address before connecting via SSH.
Defaults to false.
## Basic Example: Rackspace public cloud
Here is a basic example. This is a working example to build a
...
...
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