Fixed storage of Global and XDS Server configuration.
[src/xds/xds-agent.git] / lib / agent / apiv1.go
index a66f451..1921f98 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 "IoT.bzh"
+ * Copyright (C) 2017-2018 "IoT.bzh"
  * Author Sebastien Douheret <sebastien@iot.bzh>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,9 +21,10 @@ import (
        "fmt"
        "strconv"
 
+       "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent/lib/xaapiv1"
+       "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent/lib/xdsconfig"
+       "gerrit.automotivelinux.org/gerrit/src/xds/xds-server.git/lib/xsapiv1"
        "github.com/gin-gonic/gin"
-       "github.com/iotbzh/xds-agent/lib/xdsconfig"
-       "github.com/iotbzh/xds-server/lib/xsapiv1"
 )
 
 const apiBaseURL = "/api/v1"
@@ -163,3 +164,18 @@ func (s *APIService) DelXdsServer(id string) error {
        s.xdsServers[id].Close()
        return nil
 }
+}
+
+// UpdateXdsServer Update XDS Server configuration settings
+func (s *APIService) UpdateXdsServer(cfg xaapiv1.ServerCfg) error {
+       if _, exist := s.xdsServers[cfg.ID]; !exist {
+               return fmt.Errorf("Unknown Server ID %s", cfg.ID)
+       }
+
+       svr := s.xdsServers[cfg.ID]
+
+       // Update only some configurable fields
+       svr.ConnRetry = cfg.ConnRetry
+
+       return nil
+}