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
551e8077
Commit
551e8077
authored
Jun 12, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/openstack-new: fix some issues
parent
c903579a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
27 deletions
+29
-27
builder/openstack-new/ssh.go
builder/openstack-new/ssh.go
+25
-22
builder/openstack-new/step_allocate_ip.go
builder/openstack-new/step_allocate_ip.go
+3
-4
builder/openstack-new/step_run_source_server.go
builder/openstack-new/step_run_source_server.go
+1
-1
No files found.
builder/openstack-new/ssh.go
View file @
551e8077
...
...
@@ -3,6 +3,7 @@ package openstack
import
(
"errors"
"fmt"
"log"
"time"
"github.com/mitchellh/multistep"
...
...
@@ -21,7 +22,8 @@ func SSHAddress(
s
:=
state
.
Get
(
"server"
)
.
(
*
servers
.
Server
)
// If we have a floating IP, use that
if
ip
:=
state
.
Get
(
"access_ip"
)
.
(
*
floatingip
.
FloatingIP
);
ip
.
FixedIP
!=
""
{
ip
:=
state
.
Get
(
"access_ip"
)
.
(
*
floatingip
.
FloatingIP
)
if
ip
!=
nil
&&
ip
.
FixedIP
!=
""
{
return
fmt
.
Sprintf
(
"%s:%d"
,
ip
.
FixedIP
,
port
),
nil
}
...
...
@@ -29,33 +31,34 @@ func SSHAddress(
return
fmt
.
Sprintf
(
"%s:%d"
,
s
.
AccessIPv4
,
port
),
nil
}
// Get all the addresses associated with this server
/*
ip_pools, err := s.AllAddressPools()
if err != nil {
return "", errors.New("Error parsing SSH addresses")
// Get all the addresses associated with this server. This
// was taken directly from Terraform.
for
_
,
networkAddresses
:=
range
s
.
Addresses
{
elements
,
ok
:=
networkAddresses
.
([]
interface
{})
if
!
ok
{
log
.
Printf
(
"[ERROR] Unknown return type for address field: %#v"
,
networkAddresses
)
continue
}
for pool, addresses := range ip_pools {
if sshinterface != "" {
if pool != sshinterface {
continue
for
_
,
element
:=
range
elements
{
var
addr
string
address
:=
element
.
(
map
[
string
]
interface
{})
if
address
[
"OS-EXT-IPS:type"
]
==
"floating"
{
addr
=
address
[
"addr"
]
.
(
string
)
}
else
{
if
address
[
"version"
]
.
(
float64
)
==
4
{
addr
=
address
[
"addr"
]
.
(
string
)
}
}
if pool != "" {
for _, address := range addresses {
if address.Addr != "" && address.Version == 4 {
return fmt.Sprintf("%s:%d", address.Addr, port), nil
}
}
if
addr
!=
""
{
return
fmt
.
Sprintf
(
"%s:%d"
,
addr
,
port
),
nil
}
}
*/
result
:=
servers
.
Get
(
client
,
s
.
ID
)
err
:=
result
.
Err
if
err
==
nil
{
s
,
err
=
result
.
Extract
()
}
s
,
err
:=
servers
.
Get
(
client
,
s
.
ID
)
.
Extract
()
if
err
!=
nil
{
return
""
,
err
}
...
...
builder/openstack-new/step_allocate_ip.go
View file @
551e8077
...
...
@@ -33,7 +33,7 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
state
.
Put
(
"access_ip"
,
instanceIp
)
if
s
.
FloatingIp
!=
""
{
instanceIp
.
FixedIP
=
s
.
FloatingIp
*
instanceIp
=
floatingip
.
FloatingIP
{
FixedIP
:
s
.
FloatingIp
}
}
else
if
s
.
FloatingIpPool
!=
""
{
newIp
,
err
:=
floatingip
.
Create
(
client
,
floatingip
.
CreateOpts
{
Pool
:
s
.
FloatingIpPool
,
...
...
@@ -45,11 +45,11 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
}
instanceIp
=
newIp
*
instanceIp
=
*
newIp
ui
.
Say
(
fmt
.
Sprintf
(
"Created temporary floating IP %s..."
,
instanceIp
.
FixedIP
))
}
if
instanceIp
.
FixedIP
!=
""
{
if
instanceIp
!=
nil
&&
instanceIp
.
FixedIP
!=
""
{
err
:=
floatingip
.
Associate
(
client
,
server
.
ID
,
instanceIp
.
FixedIP
)
.
ExtractErr
()
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
...
...
@@ -65,7 +65,6 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
}
state
.
Put
(
"access_ip"
,
instanceIp
)
return
multistep
.
ActionContinue
}
...
...
builder/openstack-new/step_run_source_server.go
View file @
551e8077
...
...
@@ -42,7 +42,7 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
CreateOptsBuilder
:
servers
.
CreateOpts
{
Name
:
s
.
Name
,
ImageRef
:
s
.
SourceImage
,
Flavor
Ref
:
s
.
Flavor
,
Flavor
Name
:
s
.
Flavor
,
SecurityGroups
:
s
.
SecurityGroups
,
Networks
:
networks
,
},
...
...
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