summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go60
1 files changed, 9 insertions, 51 deletions
diff --git a/main.go b/main.go
index f38dded..fb26ee6 100644
--- a/main.go
+++ b/main.go
@@ -52,84 +52,42 @@ func main() {
// sanity check the droplets
checkDroplets(false)
- // ok tracks if all the libvirt xml files imported ok
- var ok bool = true
for _, filename := range argv.Xml {
domcfg, err := readXml(filename)
if err != nil {
// parsing the libvirt xml file failed
log.Info("error:", filename, err)
- ok = false
log.Info("readXml() error", filename)
log.Info("readXml() error", err)
log.Info("libvirt XML will have to be fixed by hand")
os.Exit(-1)
- continue
}
- // see if the libvirt xml droplet is already here
- d, err := findDomain(domcfg)
+ // this is a new droplet. add it to the cluster
+ log.Info("Add XML Droplet here", domcfg.Name)
+ _, err = addDomainDroplet(domcfg)
if err != nil {
- // some error. probably UUID mismatch or hostname duplication
- // this has to be fixed by hand
- ok = false
- log.Info("findDomain() error", filename)
- log.Info("findDomain() error", err)
+ log.Info("addDomainDroplet() error", filename)
+ log.Info("addDomainDroplet() error", err)
log.Info("libvirt XML will have to be fixed by hand")
os.Exit(-1)
- continue
- }
- if d == nil {
- // this is a new droplet. add it to the cluster
- log.Info("Add New Droplet here", domcfg.Name)
- _, err := addDomainDroplet(domcfg)
- if err != nil {
- ok = false
- log.Info("addDomainDroplet() error", filename)
- log.Info("addDomainDroplet() error", err)
- log.Info("libvirt XML will have to be fixed by hand")
- os.Exit(-1)
- }
- } else {
- // this droplet is already here
- err := updateDroplet(d, domcfg)
- if err != nil {
- log.Info("updateDroplet() error", filename)
- log.Info("updateDroplet() error", d.pb.Hostname, err)
- log.Info("libvirt XML will have to be fixed by hand")
- ok = false
- os.Exit(-1)
- }
}
}
if len(argv.Xml) != 0 {
- if !ok {
- log.Info("importing xml files had errors")
- os.Exit(-1)
- }
if me.changed {
if argv.Save {
writeConfigFile()
writeConfigFileDroplets()
+ log.Info("XML changes saved in protobuf config")
+ os.Exit(0)
} else {
log.Info("Not saving changes (use --save to save)")
+ os.Exit(0)
}
}
+ log.Info("No XML changes found")
os.Exit(0)
}
- /*
- log.Info("command line hypervisors:", argv.Hosts)
- for _, name := range argv.Hosts {
- h := findHypervisor(name)
- if h != nil {
- log.Info("command line hypervisor", name, "already in config file")
- continue
- }
- h = addHypervisor(name)
- h.pb.Active = true
- }
- */
-
// start the watchdog polling for each hypervisor
for _, h := range me.hypers {
log.Info("starting polling on", h.pb.Hostname)