more checking
This commit is contained in:
@@ -24,7 +24,7 @@ func (h *Handler) VmModify(w http.ResponseWriter, r *http.Request) {
|
|||||||
params := queries.CreateUpdateParams{}
|
params := queries.CreateUpdateParams{}
|
||||||
var unixTimestamp int64
|
var unixTimestamp int64
|
||||||
|
|
||||||
//re := regexp.MustCompile(`/([^/]+)/[^/]+\.vmdk$`)
|
re := regexp.MustCompile(`/([^/]+)/[^/]+\.vmdk$`)
|
||||||
|
|
||||||
reqBody, err := io.ReadAll(r.Body)
|
reqBody, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -102,6 +102,21 @@ func (h *Handler) VmModify(w http.ResponseWriter, r *http.Request) {
|
|||||||
for i := range testConfig.DeviceChange {
|
for i := range testConfig.DeviceChange {
|
||||||
if testConfig.DeviceChange[i].Device.Backing != nil {
|
if testConfig.DeviceChange[i].Device.Backing != nil {
|
||||||
h.Logger.Debug("Found backing in configspec", "backing", testConfig.DeviceChange[i].Device.Backing)
|
h.Logger.Debug("Found backing in configspec", "backing", testConfig.DeviceChange[i].Device.Backing)
|
||||||
|
|
||||||
|
// Find the match
|
||||||
|
backingFile := testConfig.DeviceChange[i].Device.Backing.FileName
|
||||||
|
matches := re.FindStringSubmatch(backingFile)
|
||||||
|
if len(matches) < 2 {
|
||||||
|
h.Logger.Warn("unable to match regex", "backing_filename", backingFile, "match_count", len(matches))
|
||||||
|
} else {
|
||||||
|
h.Logger.Debug("Matched regex", "disk_owner", matches[1])
|
||||||
|
|
||||||
|
if strings.ToLower(matches[1]) == strings.ToLower(event.CloudEvent.Data.VM.Name) {
|
||||||
|
h.Logger.Debug("This disk belongs to this VM")
|
||||||
|
} else {
|
||||||
|
h.Logger.Debug("This disk belongs to a different VM, don't record this config change")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user