forked from apalia/cloudstack-csi-driver
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
15 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
package cloud | ||
|
||
import "context" | ||
import ( | ||
"context" | ||
"k8s.io/klog/v2" | ||
) | ||
|
||
func (c *client) GetNodeInfo(ctx context.Context, vmName string) (*VM, error) { | ||
// First, try to read the instance ID from meta-data (cloud-init) | ||
logger := klog.FromContext(ctx) | ||
|
||
// First, try to read the instance ID from meta-data. | ||
if id := c.metadataInstanceID(ctx); id != "" { | ||
// Instance ID found using metadata | ||
logger.V(4).Info("Looking up node info using VM ID found in metadata", "nodeID", id) | ||
|
||
// Use CloudStack API to get VM info | ||
return c.GetVMByID(ctx, id) | ||
} | ||
|
||
// VM ID was not found using metadata. | ||
// Use VM name instead | ||
// VM ID was not found using metadata, fall back to using VM name instead. | ||
logger.V(4).Info("Looking up node info using VM name", "nodeName", vmName) | ||
|
||
return c.getVMByName(ctx, vmName) | ||
} |