summaryrefslogtreecommitdiff
path: root/validate.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-10-27 03:17:34 -0500
committerJeff Carr <[email protected]>2024-10-27 03:17:34 -0500
commitd948581300ecea1b5407662be9e812ddf237e6cf (patch)
treefd3d244edb003686e7fc97f5e2cd65ccb30f7ccc /validate.go
parent71f83d400048f6d4219793a76a3ffce16b8c63d8 (diff)
add /dumpdroplets
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'validate.go')
-rw-r--r--validate.go45
1 files changed, 6 insertions, 39 deletions
diff --git a/validate.go b/validate.go
index 274033c..16d78ac 100644
--- a/validate.go
+++ b/validate.go
@@ -71,41 +71,6 @@ func lookupFilename(cluster *pb.Cluster, filename string) *pb.Droplet {
return nil
}
-/*
-func InsertFilename(cluster *pb.Cluster, d *pb.Droplet, filename string) (*pb.Event, error) {
- dupd := lookupFilename(cluster, filename)
- if dupd != nil {
- log.Info("file", filename, "already on droplet", dupd.Hostname)
- log.Info("file", filename, "on new droplet", d.Hostname)
- if os.Getenv("VIRTIGO_IGNORE_DISKDUP") == "" {
- log.Info("duplicate disk names (--xml-ignore-disk to ignore)")
- return nil, errors.New("duplicate disk names")
- } else {
- log.Info("ignore duplicate disk names (--xml-ignore-disk=true)")
- }
- }
- filebase := filepath.Base(filename)
- dir := filepath.Dir(filename)
- for _, disk := range d.Disks {
- if disk.Filename == filebase {
- log.Info("already have disk", filename)
- return nil, nil
- }
- }
- // make a new Add Event
- e := d.NewChangeEvent("Add Disk", "", filename)
-
- // add the disk protobuf entry
- var disk *pb.Disk
- disk = new(pb.Disk)
- disk.Filename = filebase
- disk.Filepath = dir
- d.Disks = append(d.Disks, disk)
- log.Info("New filename", filebase, dir)
- return e, nil
-}
-*/
-
func ValidateUniqueFilenames(cluster *pb.Cluster) bool {
var ok bool = true
var disks map[string]string
@@ -170,7 +135,7 @@ func ValidateDiskFilenames(cluster *pb.Cluster) []*pb.Event {
// runs on startup. dies if there are duplicates
// the config file must then be edited by hand
-func ValidateDroplets(cluster *pb.Cluster) error {
+func ValidateDroplets(cluster *pb.Cluster) (map[string]string, map[string]string, error) {
// uuid map to check for duplicates
var umap map[string]string
umap = make(map[string]string)
@@ -191,7 +156,7 @@ func ValidateDroplets(cluster *pb.Cluster) error {
// UUID already exists
log.Info("duplicate UUID", d.Uuid, umap[d.Uuid])
log.Info("duplicate UUID", d.Uuid, d.Hostname)
- return errors.New("duplicate UUID: " + d.Uuid)
+ return umap, macs, errors.New("duplicate UUID: " + d.Uuid)
}
umap[d.Uuid] = d.Hostname
@@ -201,7 +166,7 @@ func ValidateDroplets(cluster *pb.Cluster) error {
// UUID already exists
log.Info("duplicate MAC", n.Mac, macs[n.Mac], umap[macs[n.Mac]])
log.Info("duplicate MAC", n.Mac, d.Hostname)
- return errors.New("duplicate MAC: " + n.Mac)
+ return umap, macs, errors.New("duplicate MAC: " + n.Mac)
}
macs[n.Mac] = d.Uuid
}
@@ -209,9 +174,10 @@ func ValidateDroplets(cluster *pb.Cluster) error {
log.Println("validated okay: no duplicate MAC addr")
log.Println("validated okay: no duplicate UUID")
- return nil
+ return umap, macs, nil
}
+/*
func safeValidateDroplets(cluster *pb.Cluster) (map[string]string, map[string]string) {
// uuid map to check for duplicates
var umap map[string]string
@@ -253,3 +219,4 @@ func safeValidateDroplets(cluster *pb.Cluster) (map[string]string, map[string]st
return umap, macs
}
+*/