Documentation
¶
Overview ¶
Package client provides a simple RMB interface to work with the node.
Requirements ¶
1. A msgbusd instance must be running on the node. this client uses RMB (message bus) to send messages to nodes, and get the repspons. 2. A valid ed25519 key pair. this key is used to sign deployments and MUST be the same key used to configure the local twin on substrate.
Simple deployment ¶
create an instance from the default rmb client. ``` cl, err := rmb.Default()
if err != nil {
panic(err)
}
``` then create an instance of the node client ``` node := client.NewNodeClient(NodeTwinID, cl) ``` define your deployment object ```
dl := gridtypes.Deployment{
Version: Version,
TwinID: Twin, //LocalTwin,
// this contract id must match the one on substrate
Workloads: []gridtypes.Workload{
network(), // network workload definition
zmount(), // zmount workload definition
publicip(), // public ip definition
zmachine(), // zmachine definition
},
SignatureRequirement: gridtypes.SignatureRequirement{
WeightRequired: 1,
Requests: []gridtypes.SignatureRequest{
{
TwinID: Twin,
Weight: 1,
},
},
},
}
``` compute hash ``` hash, err := dl.ChallengeHash()
if err != nil {
panic("failed to create hash")
}
fmt.Printf("Hash: %x\n", hash) ``` create the contract and ge the contract id then “ dl.ContractID = 11 // from substrate ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() err = node.DeploymentDeploy(ctx, dl)
if err != nil {
panic(err)
}
```
Index ¶
- type NodeClient
- func (n *NodeClient) Counters(ctx context.Context) (total gridtypes.Capacity, used gridtypes.Capacity, err error)
- func (n *NodeClient) DeploymentChanges(ctx context.Context, contractID uint64) (changes []gridtypes.Workload, err error)
- func (n *NodeClient) DeploymentDelete(ctx context.Context, contractID uint64) error
- func (n *NodeClient) DeploymentDeploy(ctx context.Context, dl gridtypes.Deployment) error
- func (n *NodeClient) DeploymentGet(ctx context.Context, contractID uint64) (dl gridtypes.Deployment, err error)
- func (n *NodeClient) DeploymentUpdate(ctx context.Context, dl gridtypes.Deployment) error
- func (n *NodeClient) HasPublicIPv6(ctx context.Context) (bool, error)
- func (n *NodeClient) NetworkGetPublicConfig(ctx context.Context) (cfg pkg.PublicConfig, err error)
- func (n *NodeClient) NetworkListIPs(ctx context.Context) ([]string, error)
- func (n *NodeClient) NetworkListInterfaces(ctx context.Context) (map[string][]net.IP, error)
- func (n *NodeClient) NetworkListWGPorts(ctx context.Context) ([]uint16, error)
- func (n *NodeClient) NetworkSetPublicConfig(ctx context.Context, cfg pkg.PublicConfig) error
- func (n *NodeClient) SystemDMI(ctx context.Context) (result dmi.DMI, err error)
- func (n *NodeClient) SystemHypervisor(ctx context.Context) (result string, err error)
- func (n *NodeClient) SystemVersion(ctx context.Context) (ver Version, err error)
- type NodeStatus
- type ProxyClient
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NodeClient ¶
type NodeClient struct {
// contains filtered or unexported fields
}
NodeClient struct
func NewNodeClient ¶
func NewNodeClient(nodeTwin uint32, bus rmb.Client) *NodeClient
NewNodeClient creates a new node RMB client. This client then can be used to communicate with the node over RMB.
func (*NodeClient) Counters ¶
func (n *NodeClient) Counters(ctx context.Context) (total gridtypes.Capacity, used gridtypes.Capacity, err error)
Counters returns some node statistics. Including total and available cpu, memory, storage, etc...
func (*NodeClient) DeploymentChanges ¶
func (n *NodeClient) DeploymentChanges(ctx context.Context, contractID uint64) (changes []gridtypes.Workload, err error)
DeploymentGet gets a deployment via contract ID
func (*NodeClient) DeploymentDelete ¶
func (n *NodeClient) DeploymentDelete(ctx context.Context, contractID uint64) error
DeploymentDelete deletes a deployment, the node will make sure to decomission all deployments and set all workloads to deleted. A call to Get after delete is valid
func (*NodeClient) DeploymentDeploy ¶
func (n *NodeClient) DeploymentDeploy(ctx context.Context, dl gridtypes.Deployment) error
DeploymentDeploy sends the deployment to the node for processing.
func (*NodeClient) DeploymentGet ¶
func (n *NodeClient) DeploymentGet(ctx context.Context, contractID uint64) (dl gridtypes.Deployment, err error)
DeploymentGet gets a deployment via contract ID
func (*NodeClient) DeploymentUpdate ¶
func (n *NodeClient) DeploymentUpdate(ctx context.Context, dl gridtypes.Deployment) error
DeploymentUpdate update the given deployment. deployment must be a valid update for a deployment that has been already created via DeploymentDeploy
func (*NodeClient) HasPublicIPv6 ¶
func (n *NodeClient) HasPublicIPv6(ctx context.Context) (bool, error)
func (*NodeClient) NetworkGetPublicConfig ¶
func (n *NodeClient) NetworkGetPublicConfig(ctx context.Context) (cfg pkg.PublicConfig, err error)
NetworkGetPublicConfig returns the current public node network configuration. A node with a public config can be used as an access node for wireguard.
func (*NodeClient) NetworkListIPs ¶
func (n *NodeClient) NetworkListIPs(ctx context.Context) ([]string, error)
NetworkListIPs list taken public IPs on the node
func (*NodeClient) NetworkListInterfaces ¶
func (*NodeClient) NetworkListWGPorts ¶
func (n *NodeClient) NetworkListWGPorts(ctx context.Context) ([]uint16, error)
NetworkListWGPorts return a list of all "taken" ports on the node. A new deployment should be careful to use a free port for its network setup.
func (*NodeClient) NetworkSetPublicConfig ¶
func (n *NodeClient) NetworkSetPublicConfig(ctx context.Context, cfg pkg.PublicConfig) error
NetworkGetPublicConfig returns the current public node network configuration. A node with a public config can be used as an access node for wireguard.
func (*NodeClient) SystemHypervisor ¶
func (n *NodeClient) SystemHypervisor(ctx context.Context) (result string, err error)
func (*NodeClient) SystemVersion ¶
func (n *NodeClient) SystemVersion(ctx context.Context) (ver Version, err error)
type NodeStatus ¶
type ProxyClient ¶
type ProxyClient struct {
// contains filtered or unexported fields
}
ProxyClient struct
func NewProxyClient ¶
func NewProxyClient(twin uint32, bus rmb.Client) *ProxyClient
NewNodeClient creates a new node RMB client. This client then can be used to communicate with the node over RMB.
func (*ProxyClient) ReportStats ¶
func (n *ProxyClient) ReportStats(ctx context.Context, report NodeStatus) error