Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/object/actor_push_resinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion core/object/node_push_asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion core/object/node_push_disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion core/object/node_push_pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 18 additions & 0 deletions core/oc3path/main.go
Original file line number Diff line number Diff line change
@@ -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"
)
6 changes: 3 additions & 3 deletions daemon/collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
// - @<nodename>: on node removed or node frozen state changed
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions daemon/collector/post_feed_daemon_status_and_ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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{
Expand Down
3 changes: 2 additions & 1 deletion daemon/collector/post_feed_object_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions util/requestfactory/main_test.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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",
Expand Down