-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: missing vmnic info with r/cluster
import
#232
fix: missing vmnic info with r/cluster
import
#232
Conversation
r/cluster
import"
r/cluster
import"r/cluster
import
25b1826
to
eb65bda
Compare
fffa6a7
to
ca22241
Compare
ca22241
to
cb4761b
Compare
r/cluster
importr/cluster
import
r/cluster
importr/cluster
import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small change to add it back.
Could you also share the result and state in the testing section?
4f06167
to
f13751d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any tests that verify that the vmnic attribute is set on cluster's hosts.
54a5a65
to
e7c2134
Compare
e7c2134
to
f5a2527
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@burnsjared0415 could you address the following issues from the linter and check to see if this can be addressed in the test based on Dimitar's comment.
Error: internal/cluster/cluster_operations.go:393:17: ineffectual assignment to err (ineffassign)
clusterResult, err := apiClient.Clusters.GetCluster(getClusterParams)
^
Error: internal/cluster/cluster_operations.go:406:22: ineffectual assignment to err (ineffassign)
flattenedHostSpecs, err := getFlattenedHostSpecsForRefs(ctx, clusterObj.Hosts, apiClient)
f51b6ac
to
cc28e28
Compare
4687372
to
7b50744
Compare
Fix missing `vmnic` info with `r/cluster` import. Signed-off-by: Jared Burns <jared.burns@broadcom.com>
7b50744
to
97008d8
Compare
Rebased based on the changes to |
if len(host.PhysicalNics) > 0 { | ||
var physicalNics []map[string]interface{} | ||
for _, nic := range host.PhysicalNics { | ||
nicMap := make(map[string]interface{}) | ||
nicMap["name"] = nic.DeviceName | ||
nicMap["mac_address"] = nic.MacAddress | ||
physicalNics = append(physicalNics, nicMap) | ||
} | ||
result["vmnic"] = physicalNics | ||
} | ||
if len(host.PhysicalNics) > 0 { | ||
var physicalNics []map[string]interface{} | ||
for _, nic := range host.PhysicalNics { | ||
nicMap := make(map[string]interface{}) | ||
nicMap["name"] = nic.DeviceName | ||
nicMap["mac_address"] = nic.MacAddress | ||
physicalNics = append(physicalNics, nicMap) | ||
} | ||
result["vmnic"] = physicalNics | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeated code block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might also consider the following:
func FlattenHost(host vcf.Host) map[string]interface{} {
result := make(map[string]interface{})
result["id"] = host.Id
result["host_name"] = host.Fqdn
if host.IpAddresses != nil {
ipAddresses := *host.IpAddresses
if len(ipAddresses) > 0 {
result["ip_address"] = ipAddresses[0].IpAddress
}
}
if host.PhysicalNics != nil {
var physicalNics []map[string]interface{}
for _, nic := range host.PhysicalNics {
nicMap := make(map[string]interface{})
nicMap["name"] = nic.DeviceName
nicMap["mac_address"] = nic.MacAddress
physicalNics = append(physicalNics, nicMap)
}
result["vmnic"] = physicalNics
}
return result
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some repeated logic.
if len(host.PhysicalNics) > 0 { | ||
var physicalNics []map[string]interface{} | ||
for _, nic := range host.PhysicalNics { | ||
nicMap := make(map[string]interface{}) | ||
nicMap["name"] = nic.DeviceName | ||
nicMap["mac_address"] = nic.MacAddress | ||
physicalNics = append(physicalNics, nicMap) | ||
} | ||
result["vmnic"] = physicalNics | ||
} | ||
if len(host.PhysicalNics) > 0 { | ||
var physicalNics []map[string]interface{} | ||
for _, nic := range host.PhysicalNics { | ||
nicMap := make(map[string]interface{}) | ||
nicMap["name"] = nic.DeviceName | ||
nicMap["mac_address"] = nic.MacAddress | ||
physicalNics = append(physicalNics, nicMap) | ||
} | ||
result["vmnic"] = physicalNics | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might also consider the following:
func FlattenHost(host vcf.Host) map[string]interface{} {
result := make(map[string]interface{})
result["id"] = host.Id
result["host_name"] = host.Fqdn
if host.IpAddresses != nil {
ipAddresses := *host.IpAddresses
if len(ipAddresses) > 0 {
result["ip_address"] = ipAddresses[0].IpAddress
}
}
if host.PhysicalNics != nil {
var physicalNics []map[string]interface{}
for _, nic := range host.PhysicalNics {
nicMap := make(map[string]interface{})
nicMap["name"] = nic.DeviceName
nicMap["mac_address"] = nic.MacAddress
physicalNics = append(physicalNics, nicMap)
}
result["vmnic"] = physicalNics
}
return result
}
In order to have a good experience with our community, we recommend that you read the contributing guidelines for making a pull request.
Summary of Pull Request
Fix missing
vmnic
info withr/cluster
import.Type of Pull Request
Please describe:
Related to Existing Issues
Ref: #210
Test and Documentation Coverage
For bug fixes or features:
Breaking Changes?