maybe adds new droplets from libvirt xml

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-23 05:54:59 -05:00
parent 583fa15779
commit e807365ee9
1 changed files with 19 additions and 3 deletions

View File

@ -20,9 +20,25 @@ func addDomainDroplet(domcfg *libvirtxml.Domain) (*DropletT, error) {
if d != nil {
return d, errors.New(d.pb.Hostname + " droplet exists. need to update instead")
}
// this is a new unknown droplet (not in the config file)
d = new(DropletT)
log.Info("ADD FAILED", domcfg.Name, domcfg.UUID)
return nil, errors.New("not found")
d.pb = me.cluster.AddDroplet(domcfg.UUID, domcfg.Name, 2, 2*1024*1024)
me.droplets = append(me.droplets, d)
me.changed = true
if updateDroplet(d, domcfg) {
if me.changed {
log.Info("updateDroplet() worked. droplet changed")
} else {
log.Info("updateDroplet() worked. nothing changed")
}
} else {
log.Info("updateDroplet() failed for", d.pb.Hostname)
return d, errors.New("update failed for " + domcfg.Name)
}
log.Info("added new droplet", domcfg.Name, domcfg.UUID)
return d, nil
}
func findDomain(domcfg *libvirtxml.Domain) (*DropletT, error) {
@ -192,7 +208,7 @@ func updateDisk(d *DropletT, domcfg *libvirtxml.Domain) bool {
t = disk.Source.File
filename := t.File
if filename == "" {
fmt.Println("No disk source file found.")
fmt.Println("No disk source file found.")
continue
}