diff --git a/core/object/actor_push_resinfo.go b/core/object/actor_push_resinfo.go index 21f364447..badc3ed49 100644 --- a/core/object/actor_push_resinfo.go +++ b/core/object/actor_push_resinfo.go @@ -11,6 +11,7 @@ import ( "path/filepath" "github.com/opensvc/om3/v3/core/actioncontext" + "github.com/opensvc/om3/v3/core/oc3path" "github.com/opensvc/om3/v3/core/resource" "github.com/opensvc/om3/v3/core/resourceselector" ) @@ -116,7 +117,7 @@ func (t *actor) collectorPushResInfo(infos resource.Infos) error { ioReader io.Reader method = http.MethodPost - path = "/oc3/feed/instance/resource_info" + path = oc3path.FeedInstanceResinfo ) node, err := t.Node() if err != nil { diff --git a/core/object/node_push_asset.go b/core/object/node_push_asset.go index d9f165951..cb8828bea 100644 --- a/core/object/node_push_asset.go +++ b/core/object/node_push_asset.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" + "github.com/opensvc/om3/v3/core/oc3path" "github.com/opensvc/om3/v3/core/rawconfig" "github.com/opensvc/om3/v3/util/asset" "github.com/opensvc/om3/v3/util/hostname" @@ -243,7 +244,7 @@ func (t Node) pushAsset(data asset.Data) error { ioReader io.Reader method = http.MethodPost - path = "/oc3/feed/node/system" + path = oc3path.FeedNodeSystem ) oc3, err := t.CollectorClient() if err != nil { diff --git a/core/object/node_push_disks.go b/core/object/node_push_disks.go index 810eae66d..3e481fef6 100644 --- a/core/object/node_push_disks.go +++ b/core/object/node_push_disks.go @@ -10,6 +10,7 @@ import ( "os" "path/filepath" + "github.com/opensvc/om3/v3/core/oc3path" "github.com/opensvc/om3/v3/core/rawconfig" "github.com/opensvc/om3/v3/core/naming" @@ -118,7 +119,7 @@ func (t Node) pushDisks(data disks.Disks) error { ioReader io.Reader method = http.MethodPost - path = "/oc3/feed/node/disk" + path = oc3path.FeedNodeDisk ) oc3, err := t.CollectorClient() if err != nil { diff --git a/core/object/node_push_pkg.go b/core/object/node_push_pkg.go index 8954bf3e9..f40c4f982 100644 --- a/core/object/node_push_pkg.go +++ b/core/object/node_push_pkg.go @@ -10,6 +10,7 @@ import ( "os" "path/filepath" + "github.com/opensvc/om3/v3/core/oc3path" "github.com/opensvc/om3/v3/core/rawconfig" "github.com/opensvc/om3/v3/util/packages" @@ -62,7 +63,7 @@ func (t Node) pushPkg(data []packages.Pkg) error { ioReader io.Reader method = http.MethodPost - path = "/oc3/feed/node/system" + path = oc3path.FeedNodeSystem ) oc3, err := t.CollectorClient() if err != nil { diff --git a/core/oc3path/main.go b/core/oc3path/main.go new file mode 100644 index 000000000..5962fe35d --- /dev/null +++ b/core/oc3path/main.go @@ -0,0 +1,18 @@ +package oc3path + +const ( + FeedDaemonChange = "/oc3/feed/api/daemon/change" + FeedDaemonPing = "/oc3/feed/api/daemon/ping" + FeedDaemonStatus = "/oc3/feed/api/daemon/status" + + FeedInstanceAction = "/oc3/feed/api/instance/action" + FeedInstanceResinfo = "/oc3/feed/api/instance/resource_info" + FeedInstanceStatus = "/oc3/feed/api/instance/status" + + FeedNodeDisk = "/oc3/feed/api/node/disk" + FeedNodeSystem = "/oc3/feed/api/node/system" + + FeedObjectConfig = "/oc3/feed/api/object/config" + + FeedVersion = "/oc3/feed/api/version" +) diff --git a/daemon/collector/main.go b/daemon/collector/main.go index 06afd6255..7bcc0a28e 100644 --- a/daemon/collector/main.go +++ b/daemon/collector/main.go @@ -64,8 +64,8 @@ type ( instances map[string]struct{} // daemonStatusChange is used when we have to post data to collector: - // if the map is empty, we POST /oc3/feed/daemon/ping - // else we POST /oc3/feed/daemon/status with header XDaemonChange + // if the map is empty, we POST oc3path.FeedDaemonPing + // else we POST oc3path.FeedDaemonStatus with header XDaemonChange // // The map keys are: // - @: on node removed or node frozen state changed @@ -78,7 +78,7 @@ type ( clusterData clusterDataer - // featurePostChange when true, POST /oc3/feed/daemon/change instead of + // featurePostChange when true, POST oc3path.FeedDaemonChange instead of featurePostChange bool // objectConfigToSend is a map of path to the most recent diff --git a/daemon/collector/post_feed_daemon_status_and_ping.go b/daemon/collector/post_feed_daemon_status_and_ping.go index 2fa8a47e9..67c187450 100644 --- a/daemon/collector/post_feed_daemon_status_and_ping.go +++ b/daemon/collector/post_feed_daemon_status_and_ping.go @@ -13,6 +13,7 @@ import ( "github.com/opensvc/om3/v3/core/clusterdump" "github.com/opensvc/om3/v3/core/naming" + "github.com/opensvc/om3/v3/core/oc3path" "github.com/opensvc/om3/v3/daemon/msgbus" "github.com/opensvc/om3/v3/util/xmap" ) @@ -95,7 +96,7 @@ func (t *T) postPing() error { err error method = http.MethodPost - path = "/oc3/feed/daemon/ping" + path = oc3path.FeedDaemonPing ioReader io.Reader ) @@ -180,7 +181,7 @@ func (t *T) postChanges() error { err error method = http.MethodPost - path = "/oc3/feed/daemon/changes" + path = oc3path.FeedDaemonChange ) now := time.Now() @@ -235,7 +236,8 @@ func (t *T) postStatus() error { err error ioReader io.Reader method = http.MethodPost - path = "/oc3/feed/daemon/status" + + path = oc3path.FeedDaemonStatus ) now := time.Now() body := postFeedDaemonStatus{ diff --git a/daemon/collector/post_feed_object_config.go b/daemon/collector/post_feed_object_config.go index a805b2028..eb3f3fa4c 100644 --- a/daemon/collector/post_feed_object_config.go +++ b/daemon/collector/post_feed_object_config.go @@ -18,6 +18,7 @@ import ( "github.com/opensvc/om3/v3/core/cluster" "github.com/opensvc/om3/v3/core/instance" "github.com/opensvc/om3/v3/core/naming" + "github.com/opensvc/om3/v3/core/oc3path" "github.com/opensvc/om3/v3/core/rawconfig" "github.com/opensvc/om3/v3/daemon/daemonenv" "github.com/opensvc/om3/v3/daemon/daemonsubsystem" @@ -241,7 +242,7 @@ func (t *T) doPostObjectConfig(checksum string, b []byte, p naming.Path) error { err error method = http.MethodPost - path = "/oc3/feed/object/config" + path = oc3path.FeedObjectConfig ) ctx, cancel := context.WithTimeout(t.ctx, defaultPostMaxDuration) diff --git a/util/requestfactory/main_test.go b/util/requestfactory/main_test.go index 7cd8fed97..d27976d73 100644 --- a/util/requestfactory/main_test.go +++ b/util/requestfactory/main_test.go @@ -1,11 +1,14 @@ package requestfactory import ( + "fmt" "net/http" "net/url" "testing" "github.com/stretchr/testify/require" + + "github.com/opensvc/om3/v3/core/oc3path" ) func TestNew(t *testing.T) { @@ -23,8 +26,8 @@ func TestNew(t *testing.T) { }{ { method: "POST", - relPath: "/oc3/daemon/ping", - expectedUrl: "https://localhost:128/proxy/oc3/daemon/ping", + relPath: oc3path.FeedDaemonPing, + expectedUrl: fmt.Sprintf("https://localhost:128/proxy%s", oc3path.FeedDaemonPing), }, { method: "GET",