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
f48fc1e2
Commit
f48fc1e2
authored
Jan 17, 2014
by
Kgespada
Committed by
Ben Broderick Phillips
May 01, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds security group support
Allows security groups to be specified in the template.
parent
92d58a5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
21 deletions
+30
-21
builder/openstack/builder.go
builder/openstack/builder.go
+4
-3
builder/openstack/run_config.go
builder/openstack/run_config.go
+11
-11
builder/openstack/step_run_source_server.go
builder/openstack/step_run_source_server.go
+15
-7
No files found.
builder/openstack/builder.go
View file @
f48fc1e2
...
...
@@ -88,9 +88,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
DebugKeyPath
:
fmt
.
Sprintf
(
"os_%s.pem"
,
b
.
config
.
PackerBuildName
),
},
&
StepRunSourceServer
{
Name
:
b
.
config
.
ImageName
,
Flavor
:
b
.
config
.
Flavor
,
SourceImage
:
b
.
config
.
SourceImage
,
Name
:
b
.
config
.
ImageName
,
Flavor
:
b
.
config
.
Flavor
,
SourceImage
:
b
.
config
.
SourceImage
,
SecurityGroups
:
b
.
config
.
SecurityGroups
,
},
&
StepAllocateIp
{
FloatingIpPool
:
b
.
config
.
FloatingIpPool
,
...
...
builder/openstack/run_config.go
View file @
f48fc1e2
...
...
@@ -10,15 +10,16 @@ import (
// RunConfig contains configuration for running an instance from a source
// image and details on how to access that launched image.
type
RunConfig
struct
{
SourceImage
string
`mapstructure:"source_image"`
Flavor
string
`mapstructure:"flavor"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPort
int
`mapstructure:"ssh_port"`
OpenstackProvider
string
`mapstructure:"openstack_provider"`
UseFloatingIp
bool
`mapstructure:"use_floating_ip"`
FloatingIpPool
string
`mapstructure:"floating_ip_pool"`
FloatingIp
string
`mapstructure:"floating_ip"`
SourceImage
string
`mapstructure:"source_image"`
Flavor
string
`mapstructure:"flavor"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPort
int
`mapstructure:"ssh_port"`
OpenstackProvider
string
`mapstructure:"openstack_provider"`
UseFloatingIp
bool
`mapstructure:"use_floating_ip"`
FloatingIpPool
string
`mapstructure:"floating_ip_pool"`
FloatingIp
string
`mapstructure:"floating_ip"`
SecurityGroups
[]
string
`mapstructure:"security_groups"`
// Unexported fields that are calculated from others
sshTimeout
time
.
Duration
...
...
@@ -76,8 +77,7 @@ func (c *RunConfig) Prepare(t *packer.ConfigTemplate) []error {
var
err
error
*
ptr
,
err
=
t
.
Process
(
*
ptr
,
nil
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
n
,
err
))
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Error processing %s: %s"
,
n
,
err
))
}
}
...
...
builder/openstack/step_run_source_server.go
View file @
f48fc1e2
...
...
@@ -9,9 +9,10 @@ import (
)
type
StepRunSourceServer
struct
{
Flavor
string
Name
string
SourceImage
string
Flavor
string
Name
string
SourceImage
string
SecurityGroups
[]
string
server
*
gophercloud
.
Server
}
...
...
@@ -23,11 +24,18 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
// XXX - validate image and flavor is available
securityGroups
:=
make
([]
map
[
string
]
interface
{},
len
(
s
.
SecurityGroups
))
for
i
,
groupName
:=
range
s
.
SecurityGroups
{
securityGroups
[
i
]
=
make
(
map
[
string
]
interface
{})
securityGroups
[
i
][
"name"
]
=
groupName
}
server
:=
gophercloud
.
NewServer
{
Name
:
s
.
Name
,
ImageRef
:
s
.
SourceImage
,
FlavorRef
:
s
.
Flavor
,
KeyPairName
:
keyName
,
Name
:
s
.
Name
,
ImageRef
:
s
.
SourceImage
,
FlavorRef
:
s
.
Flavor
,
KeyPairName
:
keyName
,
SecurityGroup
:
securityGroups
,
}
serverResp
,
err
:=
csp
.
CreateServer
(
server
)
...
...
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