-
Notifications
You must be signed in to change notification settings - Fork 14
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
Check if node is virtualized #521
Conversation
Codecov Report
@@ Coverage Diff @@
## master #521 +/- ##
=========================================
Coverage ? 36.26%
=========================================
Files ? 75
Lines ? 5066
Branches ? 0
=========================================
Hits ? 1837
Misses ? 2963
Partials ? 266
Continue to review full report at Codecov.
|
tools/bcdb_mock/nodes_store.go
Outdated
@@ -140,14 +140,15 @@ func (s *nodeStore) updateUptime(nodeID string, uptime int64) error { | |||
return nil | |||
} | |||
|
|||
func (s *nodeStore) StoreProof(nodeID string, dmi dmi.DMI, disks capacity.Disks) error { | |||
func (s *nodeStore) StoreProof(nodeID string, dmi dmi.DMI, disks capacity.Disks, hypervisor string) error { |
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.
@zaibon this method signature is becoming too long, shouldn't we create (or reuse) one of the structures that already have these attributes? (same applies for other methods regarding capacity registration)
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.
Yep I was thinking the same.
node, err := s.Get(nodeID) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
proof := directory.TfgridNodeProof1{ | ||
Created: schema.Date{Time: time.Now()}, | ||
Created: schema.Date{Time: time.Now()}, | ||
Hypervisor: hypervisor, |
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.
Actually this is not enough. You will see in the code down, that it is possible that we do not store the proof
variable:
zos/tools/bcdb_mock/nodes_store.go
Lines 170 to 174 in a7a8e9b
for _, p := range node.Proofs { | |
if proof.Equal(p) { | |
return nil | |
} | |
} |
I would replace this block with
// don't save the proof if we already have one with the same
// hash/content
for i := range node.Proofs {
if proof.Equal(node.Proofs[i]) {
// always update hypervisor content
node.Proofs[i].Hypervisor = hypervisor
return nil
}
}
So we ensure that we always update the content of hypervisor even if the proof is already known and we do not store a new one.
…os into virt-what_implementation
out = bytes.TrimSpace(out) | ||
return s, nil | ||
str := strings.TrimSpace(string(out)) | ||
if len(str) == 0 { |
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.
👍
Checks if the 3Node is a virtual machine or not using virt-what
Thanks to @muhamadazmy for the help!