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
ad6091be
Commit
ad6091be
authored
Feb 16, 2015
by
Federico Simoncelli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gce: report the nodes external id
Signed-off-by:
Federico Simoncelli
<
fsimonce@redhat.com
>
parent
6b16f80d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
gce.go
pkg/cloudprovider/gce/gce.go
+19
-6
No files found.
pkg/cloudprovider/gce/gce.go
View file @
ad6091be
...
...
@@ -279,24 +279,37 @@ func canonicalizeInstanceName(name string) string {
return
name
}
// Return the instances matching the relevant name.
func
(
gce
*
GCECloud
)
getInstanceByName
(
name
string
)
(
*
compute
.
Instance
,
error
)
{
name
=
canonicalizeInstanceName
(
name
)
res
,
err
:=
gce
.
service
.
Instances
.
Get
(
gce
.
projectID
,
gce
.
zone
,
name
)
.
Do
()
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to retrieve TargetInstance resource for instance:%s"
,
name
)
return
nil
,
err
}
return
res
,
nil
}
// IPAddress is an implementation of Instances.IPAddress.
func
(
gce
*
GCECloud
)
IPAddress
(
instance
string
)
(
net
.
IP
,
error
)
{
instance
=
canonicalizeInstanceName
(
instance
)
res
,
err
:=
gce
.
service
.
Instances
.
Get
(
gce
.
projectID
,
gce
.
zone
,
instance
)
.
Do
()
inst
,
err
:=
gce
.
getInstanceByName
(
instance
)
if
err
!=
nil
{
glog
.
Errorf
(
"Failed to retrieve TargetInstance resource for instance:%s"
,
instance
)
return
nil
,
err
}
ip
:=
net
.
ParseIP
(
res
.
NetworkInterfaces
[
0
]
.
AccessConfigs
[
0
]
.
NatIP
)
ip
:=
net
.
ParseIP
(
inst
.
NetworkInterfaces
[
0
]
.
AccessConfigs
[
0
]
.
NatIP
)
if
ip
==
nil
{
return
nil
,
fmt
.
Errorf
(
"invalid network IP: %s"
,
res
.
NetworkInterfaces
[
0
]
.
AccessConfigs
[
0
]
.
NatIP
)
return
nil
,
fmt
.
Errorf
(
"invalid network IP: %s"
,
inst
.
NetworkInterfaces
[
0
]
.
AccessConfigs
[
0
]
.
NatIP
)
}
return
ip
,
nil
}
// ExternalID returns the cloud provider ID of the specified instance.
func
(
gce
*
GCECloud
)
ExternalID
(
instance
string
)
(
string
,
error
)
{
return
""
,
fmt
.
Errorf
(
"unimplemented"
)
inst
,
err
:=
gce
.
getInstanceByName
(
instance
)
if
err
!=
nil
{
return
""
,
err
}
return
string
(
inst
.
Id
),
nil
}
// fqdnSuffix is hacky function to compute the delta between hostame and hostname -f.
...
...
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