Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
579edee4
Commit
579edee4
authored
Mar 13, 2015
by
Alex Robinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5346 from justinsb/cloudprovider_multiple_addresses
Let CloudProvider return list of NodeAddress, not just one net.IP
parents
0cc2b62b
c3a6d000
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
59 additions
and
51 deletions
+59
-51
aws.go
pkg/cloudprovider/aws/aws.go
+4
-3
aws_test.go
pkg/cloudprovider/aws/aws_test.go
+8
-5
cloud.go
pkg/cloudprovider/cloud.go
+2
-2
nodecontroller.go
pkg/cloudprovider/controller/nodecontroller.go
+5
-6
nodecontroller_test.go
pkg/cloudprovider/controller/nodecontroller_test.go
+2
-2
fake.go
pkg/cloudprovider/fake/fake.go
+6
-6
gce.go
pkg/cloudprovider/gce/gce.go
+3
-3
openstack.go
pkg/cloudprovider/openstack/openstack.go
+5
-4
openstack_test.go
pkg/cloudprovider/openstack/openstack_test.go
+3
-3
ovirt.go
pkg/cloudprovider/ovirt/ovirt.go
+3
-3
rackspace.go
pkg/cloudprovider/rackspace/rackspace.go
+5
-4
rackspace_test.go
pkg/cloudprovider/rackspace/rackspace_test.go
+3
-3
vagrant.go
pkg/cloudprovider/vagrant/vagrant.go
+4
-3
vagrant_test.go
pkg/cloudprovider/vagrant/vagrant_test.go
+6
-4
No files found.
pkg/cloudprovider/aws/aws.go
View file @
579edee4
...
@@ -188,8 +188,8 @@ func (aws *AWSCloud) Zones() (cloudprovider.Zones, bool) {
...
@@ -188,8 +188,8 @@ func (aws *AWSCloud) Zones() (cloudprovider.Zones, bool) {
return
aws
,
true
return
aws
,
true
}
}
//
IPAddress is an implementation of Instances.IPAddres
s.
//
NodeAddresses is an implementation of Instances.NodeAddresse
s.
func
(
aws
*
AWSCloud
)
IPAddress
(
name
string
)
(
net
.
IP
,
error
)
{
func
(
aws
*
AWSCloud
)
NodeAddresses
(
name
string
)
([]
api
.
NodeAddress
,
error
)
{
inst
,
err
:=
aws
.
getInstancesByDnsName
(
name
)
inst
,
err
:=
aws
.
getInstancesByDnsName
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -198,7 +198,8 @@ func (aws *AWSCloud) IPAddress(name string) (net.IP, error) {
...
@@ -198,7 +198,8 @@ func (aws *AWSCloud) IPAddress(name string) (net.IP, error) {
if
ip
==
nil
{
if
ip
==
nil
{
return
nil
,
fmt
.
Errorf
(
"invalid network IP: %s"
,
inst
.
PrivateIpAddress
)
return
nil
,
fmt
.
Errorf
(
"invalid network IP: %s"
,
inst
.
PrivateIpAddress
)
}
}
return
ip
,
nil
return
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
ip
.
String
()}},
nil
}
}
// ExternalID returns the cloud provider ID of the specified instance.
// ExternalID returns the cloud provider ID of the specified instance.
...
...
pkg/cloudprovider/aws/aws_test.go
View file @
579edee4
...
@@ -156,7 +156,7 @@ func TestList(t *testing.T) {
...
@@ -156,7 +156,7 @@ func TestList(t *testing.T) {
}
}
}
}
func
Test
IPAddres
s
(
t
*
testing
.
T
)
{
func
Test
NodeAddresse
s
(
t
*
testing
.
T
)
{
// Note these instances have the same name
// Note these instances have the same name
// (we test that this produces an error)
// (we test that this produces an error)
instances
:=
make
([]
ec2
.
Instance
,
2
)
instances
:=
make
([]
ec2
.
Instance
,
2
)
...
@@ -168,23 +168,26 @@ func TestIPAddress(t *testing.T) {
...
@@ -168,23 +168,26 @@ func TestIPAddress(t *testing.T) {
instances
[
1
]
.
State
.
Name
=
"running"
instances
[
1
]
.
State
.
Name
=
"running"
aws1
:=
mockInstancesResp
([]
ec2
.
Instance
{})
aws1
:=
mockInstancesResp
([]
ec2
.
Instance
{})
_
,
err1
:=
aws1
.
IPAddres
s
(
"instance"
)
_
,
err1
:=
aws1
.
NodeAddresse
s
(
"instance"
)
if
err1
==
nil
{
if
err1
==
nil
{
t
.
Errorf
(
"Should error when no instance found"
)
t
.
Errorf
(
"Should error when no instance found"
)
}
}
aws2
:=
mockInstancesResp
(
instances
)
aws2
:=
mockInstancesResp
(
instances
)
_
,
err2
:=
aws2
.
IPAddres
s
(
"instance1"
)
_
,
err2
:=
aws2
.
NodeAddresse
s
(
"instance1"
)
if
err2
==
nil
{
if
err2
==
nil
{
t
.
Errorf
(
"Should error when multiple instances found"
)
t
.
Errorf
(
"Should error when multiple instances found"
)
}
}
aws3
:=
mockInstancesResp
(
instances
[
0
:
1
])
aws3
:=
mockInstancesResp
(
instances
[
0
:
1
])
ip3
,
err3
:=
aws3
.
IPAddres
s
(
"instance1"
)
addrs3
,
err3
:=
aws3
.
NodeAddresse
s
(
"instance1"
)
if
err3
!=
nil
{
if
err3
!=
nil
{
t
.
Errorf
(
"Should not error when instance found"
)
t
.
Errorf
(
"Should not error when instance found"
)
}
}
if
e
,
a
:=
instances
[
0
]
.
PrivateIpAddress
,
ip3
.
String
();
e
!=
a
{
if
len
(
addrs3
)
!=
1
{
t
.
Errorf
(
"Should return exactly one NodeAddress"
)
}
if
e
,
a
:=
instances
[
0
]
.
PrivateIpAddress
,
addrs3
[
0
]
.
Address
;
e
!=
a
{
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"Expected %v, got %v"
,
e
,
a
)
}
}
}
}
...
...
pkg/cloudprovider/cloud.go
View file @
579edee4
...
@@ -57,8 +57,8 @@ type TCPLoadBalancer interface {
...
@@ -57,8 +57,8 @@ type TCPLoadBalancer interface {
// Instances is an abstract, pluggable interface for sets of instances.
// Instances is an abstract, pluggable interface for sets of instances.
type
Instances
interface
{
type
Instances
interface
{
//
IPAddress returns an IP addres
s of the specified instance.
//
NodeAddresses returns the addresse
s of the specified instance.
IPAddress
(
name
string
)
(
net
.
IP
,
error
)
NodeAddresses
(
name
string
)
([]
api
.
NodeAddress
,
error
)
// ExternalID returns the cloud provider ID of the specified instance.
// ExternalID returns the cloud provider ID of the specified instance.
ExternalID
(
name
string
)
(
string
,
error
)
ExternalID
(
name
string
)
(
string
,
error
)
// List lists instances that match 'filter' which is a regular expression which must match the entire instance name (fqdn)
// List lists instances that match 'filter' which is a regular expression which must match the entire instance name (fqdn)
...
...
pkg/cloudprovider/controller/nodecontroller.go
View file @
579edee4
...
@@ -274,12 +274,11 @@ func (s *NodeController) PopulateAddresses(nodes *api.NodeList) (*api.NodeList,
...
@@ -274,12 +274,11 @@ func (s *NodeController) PopulateAddresses(nodes *api.NodeList) (*api.NodeList,
}
}
for
i
:=
range
nodes
.
Items
{
for
i
:=
range
nodes
.
Items
{
node
:=
&
nodes
.
Items
[
i
]
node
:=
&
nodes
.
Items
[
i
]
hostIP
,
err
:=
instances
.
IPAddres
s
(
node
.
Name
)
nodeAddresses
,
err
:=
instances
.
NodeAddresse
s
(
node
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"error getting instance
ip addres
s for %s: %v"
,
node
.
Name
,
err
)
glog
.
Errorf
(
"error getting instance
addresse
s for %s: %v"
,
node
.
Name
,
err
)
}
else
{
}
else
{
address
:=
api
.
NodeAddress
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
hostIP
.
String
()}
node
.
Status
.
Addresses
=
nodeAddresses
api
.
AddToNodeAddresses
(
&
node
.
Status
.
Addresses
,
address
)
}
}
}
}
}
else
{
}
else
{
...
@@ -288,7 +287,7 @@ func (s *NodeController) PopulateAddresses(nodes *api.NodeList) (*api.NodeList,
...
@@ -288,7 +287,7 @@ func (s *NodeController) PopulateAddresses(nodes *api.NodeList) (*api.NodeList,
addr
:=
net
.
ParseIP
(
node
.
Name
)
addr
:=
net
.
ParseIP
(
node
.
Name
)
if
addr
!=
nil
{
if
addr
!=
nil
{
address
:=
api
.
NodeAddress
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
addr
.
String
()}
address
:=
api
.
NodeAddress
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
addr
.
String
()}
api
.
AddToNodeAddresses
(
&
node
.
Status
.
Addresses
,
address
)
node
.
Status
.
Addresses
=
[]
api
.
NodeAddress
{
address
}
}
else
{
}
else
{
addrs
,
err
:=
s
.
lookupIP
(
node
.
Name
)
addrs
,
err
:=
s
.
lookupIP
(
node
.
Name
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -297,7 +296,7 @@ func (s *NodeController) PopulateAddresses(nodes *api.NodeList) (*api.NodeList,
...
@@ -297,7 +296,7 @@ func (s *NodeController) PopulateAddresses(nodes *api.NodeList) (*api.NodeList,
glog
.
Errorf
(
"No ip address for node %v"
,
node
.
Name
)
glog
.
Errorf
(
"No ip address for node %v"
,
node
.
Name
)
}
else
{
}
else
{
address
:=
api
.
NodeAddress
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
addrs
[
0
]
.
String
()}
address
:=
api
.
NodeAddress
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
addrs
[
0
]
.
String
()}
api
.
AddToNodeAddresses
(
&
node
.
Status
.
Addresses
,
address
)
node
.
Status
.
Addresses
=
[]
api
.
NodeAddress
{
address
}
}
}
}
}
}
}
...
...
pkg/cloudprovider/controller/nodecontroller_test.go
View file @
579edee4
...
@@ -649,7 +649,7 @@ func TestPopulateNodeAddresses(t *testing.T) {
...
@@ -649,7 +649,7 @@ func TestPopulateNodeAddresses(t *testing.T) {
}{
}{
{
{
nodes
:
&
api
.
NodeList
{
Items
:
[]
api
.
Node
{
*
newNode
(
"node0"
),
*
newNode
(
"node1"
)}},
nodes
:
&
api
.
NodeList
{
Items
:
[]
api
.
Node
{
*
newNode
(
"node0"
),
*
newNode
(
"node1"
)}},
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
IP
:
net
.
ParseIP
(
"1.2.3.4"
)
},
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
Addresses
:
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
"1.2.3.4"
}}
},
expectedAddresses
:
[]
api
.
NodeAddress
{
expectedAddresses
:
[]
api
.
NodeAddress
{
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
"1.2.3.4"
},
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
"1.2.3.4"
},
},
},
...
@@ -1061,7 +1061,7 @@ func TestSyncNodeStatus(t *testing.T) {
...
@@ -1061,7 +1061,7 @@ func TestSyncNodeStatus(t *testing.T) {
Err
:
nil
,
Err
:
nil
,
},
},
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
fakeCloud
:
&
fake_cloud
.
FakeCloud
{
IP
:
net
.
ParseIP
(
"1.2.3.4"
)
,
Addresses
:
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
"1.2.3.4"
}}
,
},
},
expectedNodes
:
[]
*
api
.
Node
{
expectedNodes
:
[]
*
api
.
Node
{
{
{
...
...
pkg/cloudprovider/fake/fake.go
View file @
579edee4
...
@@ -38,7 +38,7 @@ type FakeCloud struct {
...
@@ -38,7 +38,7 @@ type FakeCloud struct {
Exists
bool
Exists
bool
Err
error
Err
error
Calls
[]
string
Calls
[]
string
IP
net
.
IP
Addresses
[]
api
.
NodeAddress
ExtID
map
[
string
]
string
ExtID
map
[
string
]
string
Machines
[]
string
Machines
[]
string
NodeResources
*
api
.
NodeResources
NodeResources
*
api
.
NodeResources
...
@@ -115,11 +115,11 @@ func (f *FakeCloud) DeleteTCPLoadBalancer(name, region string) error {
...
@@ -115,11 +115,11 @@ func (f *FakeCloud) DeleteTCPLoadBalancer(name, region string) error {
return
f
.
Err
return
f
.
Err
}
}
//
IPAddress is a test-spy implementation of Instances.IPAddres
s.
//
NodeAddresses is a test-spy implementation of Instances.NodeAddresse
s.
// It adds an entry "
ip-addres
s" into the internal method call record.
// It adds an entry "
node-addresse
s" into the internal method call record.
func
(
f
*
FakeCloud
)
IPAddress
(
instance
string
)
(
net
.
IP
,
error
)
{
func
(
f
*
FakeCloud
)
NodeAddresses
(
instance
string
)
([]
api
.
NodeAddress
,
error
)
{
f
.
addCall
(
"
ip-addres
s"
)
f
.
addCall
(
"
node-addresse
s"
)
return
f
.
IP
,
f
.
Err
return
f
.
Addresses
,
f
.
Err
}
}
// ExternalID is a test-spy implementation of Instances.ExternalID.
// ExternalID is a test-spy implementation of Instances.ExternalID.
...
...
pkg/cloudprovider/gce/gce.go
View file @
579edee4
...
@@ -315,8 +315,8 @@ func (gce *GCECloud) getInstanceByName(name string) (*compute.Instance, error) {
...
@@ -315,8 +315,8 @@ func (gce *GCECloud) getInstanceByName(name string) (*compute.Instance, error) {
return
res
,
nil
return
res
,
nil
}
}
//
IPAddress is an implementation of Instances.IPAddres
s.
//
NodeAddresses is an implementation of Instances.NodeAddresse
s.
func
(
gce
*
GCECloud
)
IPAddress
(
instance
string
)
(
net
.
IP
,
error
)
{
func
(
gce
*
GCECloud
)
NodeAddresses
(
instance
string
)
([]
api
.
NodeAddress
,
error
)
{
inst
,
err
:=
gce
.
getInstanceByName
(
instance
)
inst
,
err
:=
gce
.
getInstanceByName
(
instance
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -325,7 +325,7 @@ func (gce *GCECloud) IPAddress(instance string) (net.IP, error) {
...
@@ -325,7 +325,7 @@ func (gce *GCECloud) IPAddress(instance string) (net.IP, error) {
if
ip
==
nil
{
if
ip
==
nil
{
return
nil
,
fmt
.
Errorf
(
"invalid network IP: %s"
,
inst
.
NetworkInterfaces
[
0
]
.
AccessConfigs
[
0
]
.
NatIP
)
return
nil
,
fmt
.
Errorf
(
"invalid network IP: %s"
,
inst
.
NetworkInterfaces
[
0
]
.
AccessConfigs
[
0
]
.
NatIP
)
}
}
return
ip
,
nil
return
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
ip
.
String
()}}
,
nil
}
}
// ExternalID returns the cloud provider ID of the specified instance.
// ExternalID returns the cloud provider ID of the specified instance.
...
...
pkg/cloudprovider/openstack/openstack.go
View file @
579edee4
...
@@ -299,17 +299,18 @@ func getAddressByName(api *gophercloud.ServiceClient, name string) (string, erro
...
@@ -299,17 +299,18 @@ func getAddressByName(api *gophercloud.ServiceClient, name string) (string, erro
return
s
,
nil
return
s
,
nil
}
}
func
(
i
*
Instances
)
IPAddress
(
name
string
)
(
net
.
IP
,
error
)
{
func
(
i
*
Instances
)
NodeAddresses
(
name
string
)
([]
api
.
NodeAddress
,
error
)
{
glog
.
V
(
2
)
.
Infof
(
"
IPAddres
s(%v) called"
,
name
)
glog
.
V
(
2
)
.
Infof
(
"
NodeAddresse
s(%v) called"
,
name
)
ip
,
err
:=
getAddressByName
(
i
.
compute
,
name
)
ip
,
err
:=
getAddressByName
(
i
.
compute
,
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
glog
.
V
(
2
)
.
Infof
(
"
IPAddres
s(%v) => %v"
,
name
,
ip
)
glog
.
V
(
2
)
.
Infof
(
"
NodeAddresse
s(%v) => %v"
,
name
,
ip
)
return
net
.
ParseIP
(
ip
),
err
// net.ParseIP().String() is to maintain compatibility with the old code
return
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
net
.
ParseIP
(
ip
)
.
String
()}},
nil
}
}
// ExternalID returns the cloud provider ID of the specified instance.
// ExternalID returns the cloud provider ID of the specified instance.
...
...
pkg/cloudprovider/openstack/openstack_test.go
View file @
579edee4
...
@@ -144,11 +144,11 @@ func TestInstances(t *testing.T) {
...
@@ -144,11 +144,11 @@ func TestInstances(t *testing.T) {
}
}
t
.
Logf
(
"Found servers (%d): %s
\n
"
,
len
(
srvs
),
srvs
)
t
.
Logf
(
"Found servers (%d): %s
\n
"
,
len
(
srvs
),
srvs
)
ip
,
err
:=
i
.
IPAddres
s
(
srvs
[
0
])
addrs
,
err
:=
i
.
NodeAddresse
s
(
srvs
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Instances.
IPAddres
s(%s) failed: %s"
,
srvs
[
0
],
err
)
t
.
Fatalf
(
"Instances.
NodeAddresse
s(%s) failed: %s"
,
srvs
[
0
],
err
)
}
}
t
.
Logf
(
"Found
IPAddress(%s) = %s
\n
"
,
srvs
[
0
],
ip
)
t
.
Logf
(
"Found
NodeAddresses(%s) = %s
\n
"
,
srvs
[
0
],
addrs
)
rsrcs
,
err
:=
i
.
GetNodeResources
(
srvs
[
0
])
rsrcs
,
err
:=
i
.
GetNodeResources
(
srvs
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/cloudprovider/ovirt/ovirt.go
View file @
579edee4
...
@@ -130,8 +130,8 @@ func (v *OVirtCloud) Zones() (cloudprovider.Zones, bool) {
...
@@ -130,8 +130,8 @@ func (v *OVirtCloud) Zones() (cloudprovider.Zones, bool) {
return
nil
,
false
return
nil
,
false
}
}
//
IPAddress returns the addres
s of a particular machine instance
//
NodeAddresses returns the NodeAddresse
s of a particular machine instance
func
(
v
*
OVirtCloud
)
IPAddress
(
name
string
)
(
net
.
IP
,
error
)
{
func
(
v
*
OVirtCloud
)
NodeAddresses
(
name
string
)
([]
api
.
NodeAddress
,
error
)
{
instance
,
err
:=
v
.
fetchInstance
(
name
)
instance
,
err
:=
v
.
fetchInstance
(
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -152,7 +152,7 @@ func (v *OVirtCloud) IPAddress(name string) (net.IP, error) {
...
@@ -152,7 +152,7 @@ func (v *OVirtCloud) IPAddress(name string) (net.IP, error) {
address
=
resolved
[
0
]
address
=
resolved
[
0
]
}
}
return
address
,
nil
return
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
address
.
String
()}}
,
nil
}
}
// ExternalID returns the cloud provider ID of the specified instance.
// ExternalID returns the cloud provider ID of the specified instance.
...
...
pkg/cloudprovider/rackspace/rackspace.go
View file @
579edee4
...
@@ -350,17 +350,18 @@ func getAddressByName(api *gophercloud.ServiceClient, name string) (string, erro
...
@@ -350,17 +350,18 @@ func getAddressByName(api *gophercloud.ServiceClient, name string) (string, erro
return
s
,
nil
return
s
,
nil
}
}
func
(
i
*
Instances
)
IPAddress
(
name
string
)
(
net
.
IP
,
error
)
{
func
(
i
*
Instances
)
NodeAddresses
(
name
string
)
([]
api
.
NodeAddress
,
error
)
{
glog
.
V
(
2
)
.
Infof
(
"
IPAddres
s(%v) called"
,
name
)
glog
.
V
(
2
)
.
Infof
(
"
NodeAddresse
s(%v) called"
,
name
)
ip
,
err
:=
getAddressByName
(
i
.
compute
,
name
)
ip
,
err
:=
getAddressByName
(
i
.
compute
,
name
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
glog
.
V
(
2
)
.
Infof
(
"
IPAddres
s(%v) => %v"
,
name
,
ip
)
glog
.
V
(
2
)
.
Infof
(
"
NodeAddresse
s(%v) => %v"
,
name
,
ip
)
return
net
.
ParseIP
(
ip
),
err
// net.ParseIP().String() is to maintain compatibility with the old code
return
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
net
.
ParseIP
(
ip
)
.
String
()}},
nil
}
}
// ExternalID returns the cloud provider ID of the specified instance.
// ExternalID returns the cloud provider ID of the specified instance.
...
...
pkg/cloudprovider/rackspace/rackspace_test.go
View file @
579edee4
...
@@ -144,11 +144,11 @@ func TestInstances(t *testing.T) {
...
@@ -144,11 +144,11 @@ func TestInstances(t *testing.T) {
}
}
t
.
Logf
(
"Found servers (%d): %s
\n
"
,
len
(
srvs
),
srvs
)
t
.
Logf
(
"Found servers (%d): %s
\n
"
,
len
(
srvs
),
srvs
)
ip
,
err
:=
i
.
IPAddres
s
(
srvs
[
0
])
addrs
,
err
:=
i
.
NodeAddresse
s
(
srvs
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Instances.
IPAddres
s(%s) failed: %s"
,
srvs
[
0
],
err
)
t
.
Fatalf
(
"Instances.
NodeAddresse
s(%s) failed: %s"
,
srvs
[
0
],
err
)
}
}
t
.
Logf
(
"Found
IPAddress(%s) = %s
\n
"
,
srvs
[
0
],
ip
)
t
.
Logf
(
"Found
NodeAddresses(%s) = %s
\n
"
,
srvs
[
0
],
addrs
)
rsrcs
,
err
:=
i
.
GetNodeResources
(
srvs
[
0
])
rsrcs
,
err
:=
i
.
GetNodeResources
(
srvs
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/cloudprovider/vagrant/vagrant.go
View file @
579edee4
...
@@ -119,14 +119,15 @@ func (v *VagrantCloud) getInstanceByAddress(address string) (*SaltMinion, error)
...
@@ -119,14 +119,15 @@ func (v *VagrantCloud) getInstanceByAddress(address string) (*SaltMinion, error)
return
nil
,
fmt
.
Errorf
(
"unable to find instance for address: %s"
,
address
)
return
nil
,
fmt
.
Errorf
(
"unable to find instance for address: %s"
,
address
)
}
}
//
IPAddress returns the addres
s of a particular machine instance.
//
NodeAddresses returns the NodeAddresse
s of a particular machine instance.
func
(
v
*
VagrantCloud
)
IPAddress
(
instance
string
)
(
net
.
IP
,
error
)
{
func
(
v
*
VagrantCloud
)
NodeAddresses
(
instance
string
)
([]
api
.
NodeAddress
,
error
)
{
// Due to vagrant not running with a dedicated DNS setup, we return the IP address of a minion as its hostname at this time
// Due to vagrant not running with a dedicated DNS setup, we return the IP address of a minion as its hostname at this time
minion
,
err
:=
v
.
getInstanceByAddress
(
instance
)
minion
,
err
:=
v
.
getInstanceByAddress
(
instance
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
return
net
.
ParseIP
(
minion
.
IP
),
nil
ip
:=
net
.
ParseIP
(
minion
.
IP
)
return
[]
api
.
NodeAddress
{{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
ip
.
String
()}},
nil
}
}
// ExternalID returns the cloud provider ID of the specified instance.
// ExternalID returns the cloud provider ID of the specified instance.
...
...
pkg/cloudprovider/vagrant/vagrant_test.go
View file @
579edee4
...
@@ -81,12 +81,14 @@ func TestVagrantCloud(t *testing.T) {
...
@@ -81,12 +81,14 @@ func TestVagrantCloud(t *testing.T) {
t
.
Fatalf
(
"Invalid instance returned"
)
t
.
Fatalf
(
"Invalid instance returned"
)
}
}
ip
,
err
:=
vagrantCloud
.
IPAddres
s
(
instances
[
0
])
addrs
,
err
:=
vagrantCloud
.
NodeAddresse
s
(
instances
[
0
])
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unexpected error, should have returned
a valid IP addres
s: %s"
,
err
)
t
.
Fatalf
(
"Unexpected error, should have returned
valid NodeAddresse
s: %s"
,
err
)
}
}
if
len
(
addrs
)
!=
1
{
if
ip
.
String
()
!=
expectedInstanceIP
{
t
.
Fatalf
(
"should have returned exactly one NodeAddress: %v"
,
addrs
)
}
if
addrs
[
0
]
.
Address
!=
expectedInstanceIP
{
t
.
Fatalf
(
"Invalid IP address returned"
)
t
.
Fatalf
(
"Invalid IP address returned"
)
}
}
}
}
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