Skip to content

Commit 7d1dc6f

Browse files
authored
Merge pull request #16 from threefoldtech/update-zos-api-light
update zos-api-light to get farmer id from the caller
2 parents 4465cd7 + a37a0e8 commit 7d1dc6f

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

pkg/monitord/system.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/threefoldtech/zosbase/pkg"
1414
"github.com/threefoldtech/zosbase/pkg/gridtypes/zos"
1515
"github.com/threefoldtech/zosbase/pkg/kernel"
16-
"github.com/threefoldtech/zosbase/pkg/stubs"
16+
"github.com/threefoldtech/zosbase/pkg/stubs"
1717
)
1818

1919
var _ pkg.SystemMonitor = (*systemMonitor)(nil)
@@ -22,7 +22,7 @@ var _ pkg.SystemMonitor = (*systemMonitor)(nil)
2222
type systemMonitor struct {
2323
duration time.Duration
2424
node uint32
25-
cl zbus.Client
25+
cl zbus.Client
2626
}
2727

2828
// NewSystemMonitor creates new system of system monitor
@@ -31,7 +31,7 @@ func NewSystemMonitor(node uint32, duration time.Duration, cl zbus.Client) (pkg.
3131
duration = 2 * time.Second
3232
}
3333

34-
return &systemMonitor{duration: duration, node: node, cl: cl}, nil
34+
return &systemMonitor{duration: duration, node: node, cl: cl}, nil
3535
}
3636

3737
func (m *systemMonitor) NodeID() uint32 {
@@ -219,11 +219,11 @@ func (n *systemMonitor) GetNodeFeatures() []pkg.NodeFeature {
219219
}
220220
feat = append(feat, zosLightFeat...)
221221

222-
netStub := stubs.NewNetworkerLightStub(n.cl)
223-
config, err := netStub.LoadPublicConfig(context.Background())
224-
if err == nil && config.Domain != "" {
225-
feat = append(feat, "gateway-name-proxy")
226-
feat = append(feat, "gateway-fqdn-proxy")
222+
netStub := stubs.NewNetworkerLightStub(n.cl)
223+
config, err := netStub.LoadPublicConfig(context.Background())
224+
if err == nil && config.Domain != "" {
225+
feat = append(feat, "gateway-name-proxy")
226+
feat = append(feat, "gateway-fqdn-proxy")
227227
}
228228
return feat
229229
}

pkg/zos_api_light/zos_api.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,25 @@ func NewZosAPI(manager substrate.Manager, client zbus.Client, msgBrokerCon strin
6767
api.inMemCache = cache.New(cacheDefaultExpiration, cacheDefaultCleanup)
6868
return api, nil
6969
}
70+
71+
func NewZosAPIWithFarmerID(client zbus.Client, farmerID uint32, msgBrokerCon string) (ZosAPI, error) {
72+
diagnosticsManager, err := diagnostics.NewDiagnosticsManager(msgBrokerCon, client)
73+
if err != nil {
74+
return ZosAPI{}, err
75+
}
76+
storageModuleStub := stubs.NewStorageModuleStub(client)
77+
api := ZosAPI{
78+
oracle: capacity.NewResourceOracle(storageModuleStub),
79+
versionMonitorStub: stubs.NewVersionMonitorStub(client),
80+
systemMonitorStub: stubs.NewSystemMonitorStub(client),
81+
provisionStub: stubs.NewProvisionStub(client),
82+
networkerLightStub: stubs.NewNetworkerLightStub(client),
83+
statisticsStub: stubs.NewStatisticsStub(client),
84+
storageStub: storageModuleStub,
85+
performanceMonitorStub: stubs.NewPerformanceMonitorStub(client),
86+
diagnosticsManager: diagnosticsManager,
87+
}
88+
api.farmerID = farmerID
89+
api.inMemCache = cache.New(cacheDefaultExpiration, cacheDefaultCleanup)
90+
return api, nil
91+
}

0 commit comments

Comments
 (0)