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
...
@@ -3,6 +3,7 @@ package openstack
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"log"
"time"
"time"
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
...
@@ -21,7 +22,8 @@ func SSHAddress(
...
@@ -21,7 +22,8 @@ func SSHAddress(
s
:=
state
.
Get
(
"server"
)
.
(
*
servers
.
Server
)
s
:=
state
.
Get
(
"server"
)
.
(
*
servers
.
Server
)
// If we have a floating IP, use that
// 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
return
fmt
.
Sprintf
(
"%s:%d"
,
ip
.
FixedIP
,
port
),
nil
}
}
...
@@ -29,33 +31,34 @@ func SSHAddress(
...
@@ -29,33 +31,34 @@ func SSHAddress(
return
fmt
.
Sprintf
(
"%s:%d"
,
s
.
AccessIPv4
,
port
),
nil
return
fmt
.
Sprintf
(
"%s:%d"
,
s
.
AccessIPv4
,
port
),
nil
}
}
// Get all the addresses associated with this server
// Get all the addresses associated with this server. This
/*
// was taken directly from Terraform.
ip_pools, err := s.AllAddressPools()
for
_
,
networkAddresses
:=
range
s
.
Addresses
{
if err != nil {
elements
,
ok
:=
networkAddresses
.
([]
interface
{})
return "", errors.New("Error parsing SSH addresses")
if
!
ok
{
log
.
Printf
(
"[ERROR] Unknown return type for address field: %#v"
,
networkAddresses
)
continue
}
}
for pool, addresses := range ip_pools {
if sshinterface != "" {
for
_
,
element
:=
range
elements
{
if pool != sshinterface {
var
addr
string
continue
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 != "" {
if
addr
!=
""
{
for _, address := range addresses {
return
fmt
.
Sprintf
(
"%s:%d"
,
addr
,
port
),
nil
if address.Addr != "" && address.Version == 4 {
return fmt.Sprintf("%s:%d", address.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
{
if
err
!=
nil
{
return
""
,
err
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 {
...
@@ -33,7 +33,7 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
state
.
Put
(
"access_ip"
,
instanceIp
)
state
.
Put
(
"access_ip"
,
instanceIp
)
if
s
.
FloatingIp
!=
""
{
if
s
.
FloatingIp
!=
""
{
instanceIp
.
FixedIP
=
s
.
FloatingIp
*
instanceIp
=
floatingip
.
FloatingIP
{
FixedIP
:
s
.
FloatingIp
}
}
else
if
s
.
FloatingIpPool
!=
""
{
}
else
if
s
.
FloatingIpPool
!=
""
{
newIp
,
err
:=
floatingip
.
Create
(
client
,
floatingip
.
CreateOpts
{
newIp
,
err
:=
floatingip
.
Create
(
client
,
floatingip
.
CreateOpts
{
Pool
:
s
.
FloatingIpPool
,
Pool
:
s
.
FloatingIpPool
,
...
@@ -45,11 +45,11 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -45,11 +45,11 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
instanceIp
=
newIp
*
instanceIp
=
*
newIp
ui
.
Say
(
fmt
.
Sprintf
(
"Created temporary floating IP %s..."
,
instanceIp
.
FixedIP
))
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
()
err
:=
floatingip
.
Associate
(
client
,
server
.
ID
,
instanceIp
.
FixedIP
)
.
ExtractErr
()
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
err
:=
fmt
.
Errorf
(
...
@@ -65,7 +65,6 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -65,7 +65,6 @@ func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction {
}
}
state
.
Put
(
"access_ip"
,
instanceIp
)
state
.
Put
(
"access_ip"
,
instanceIp
)
return
multistep
.
ActionContinue
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
...
@@ -42,7 +42,7 @@ func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction
CreateOptsBuilder
:
servers
.
CreateOpts
{
CreateOptsBuilder
:
servers
.
CreateOpts
{
Name
:
s
.
Name
,
Name
:
s
.
Name
,
ImageRef
:
s
.
SourceImage
,
ImageRef
:
s
.
SourceImage
,
Flavor
Ref
:
s
.
Flavor
,
Flavor
Name
:
s
.
Flavor
,
SecurityGroups
:
s
.
SecurityGroups
,
SecurityGroups
:
s
.
SecurityGroups
,
Networks
:
networks
,
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