Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project import generated by Copybara. #87

Merged
merged 2 commits into from
Jul 12, 2024
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
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
matrix:
# Only the go_binary targets support cross-compilation at the moment:
target:
- //cdpi_agent/cmd/agent
- //agent/cmd/agent
- //tools/nbictl/cmd/nbictl
- //tools/generate_jwt
os: [linux, windows, darwin]
Expand All @@ -64,14 +64,14 @@ jobs:
path: |
bazel-bin/tools/nbictl/cmd/nbictl/nbictl_/nbictl
bazel-bin/tools/nbictl/cmd/nbictl/nbictl_/nbictl.exe
- name: Upload cdpi_agent binary
- name: Upload agent binary
uses: actions/upload-artifact@v3
if: matrix.target == '//cdpi_agent/cmd/agent'
if: matrix.target == '//agent/cmd/agent'
with:
name: cdpi_agent-${{ matrix.os }}-${{ matrix.arch }}
name: agent-${{ matrix.os }}-${{ matrix.arch }}
path: |
bazel-bin/cdpi_agent/cmd/agent/agent_/agent
bazel-bin/cdpi_agent/cmd/agent/agent_/agent.exe
bazel-bin/agent/cmd/agent/agent_/agent
bazel-bin/agent/cmd/agent/agent_/agent.exe
- name: Upload generate_jwt binary
uses: actions/upload-artifact@v3
if: matrix.target == '//tools/generate_jwt'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This site contains:
## Repo Contents
In this repo, you will find the following directories:
- [api](/api): The [gRPC](https://grpc.io/) and [Protocol Buffers](https://protobuf.dev/) definitions of the API.
- [cdpi_agent](/cdpi_agent): A Go implementation of a CDPI agent.
- [agent](/agent): A Go implementation of an SBI agent.
- [contrib](/contrib): An open-source directory of real hardware that has been modeled in Spacetime and used in real networks. Contributions are welcome!

## Contributing
Expand Down
22 changes: 11 additions & 11 deletions cdpi_agent/BUILD → agent/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
package(default_visibility = ["//visibility:public"])

go_library(
name = "cdpi_agent",
name = "agent",
srcs = [
"agent.go",
"enactment_service.go",
"node_controller.go",
"telemetry_service.go",
"timing.go",
],
importpath = "aalyria.com/spacetime/cdpi_agent",
importpath = "aalyria.com/spacetime/agent",
deps = [
"//agent/enactment",
"//agent/internal/channels",
"//agent/internal/loggable",
"//agent/internal/task",
"//agent/telemetry",
"//api/cdpi/v1alpha:cdpi_go_grpc",
"//api/common:common_go_proto",
"//api/scheduling/v1alpha:scheduling_go_grpc",
"//cdpi_agent/enactment",
"//cdpi_agent/internal/channels",
"//cdpi_agent/internal/loggable",
"//cdpi_agent/internal/task",
"//cdpi_agent/telemetry",
"@com_github_google_uuid//:uuid",
"@com_github_jonboulle_clockwork//:clockwork",
"@com_github_rs_zerolog//:zerolog",
Expand All @@ -52,7 +52,7 @@ go_library(
)

go_test(
name = "cdpi_agent_test",
name = "agent_test",
size = "small",
srcs = [
"agent_test.go",
Expand All @@ -61,13 +61,13 @@ go_test(
"telemetry_test.go",
"timing_test.go",
],
embed = [":cdpi_agent"],
embed = [":agent"],
deps = [
"//agent/internal/channels",
"//agent/internal/task",
"//api/cdpi/v1alpha:cdpi_go_grpc",
"//api/common:common_go_proto",
"//api/scheduling/v1alpha:scheduling_go_grpc",
"//cdpi_agent/internal/channels",
"//cdpi_agent/internal/task",
"@com_github_google_go_cmp//cmp",
"@com_github_jonboulle_clockwork//:clockwork",
"@com_github_rs_zerolog//:zerolog",
Expand Down
102 changes: 60 additions & 42 deletions cdpi_agent/README.md → agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@ sophisticated features.

This directory provides two important pieces for interacting with the Spacetime CDPI:

- The `agent` (`//cdpi_agent/cmd/agent`), a Go binary that handle the CDPI protocol and
- The `agent` (`//agent/cmd/agent`), a Go binary that handle the CDPI protocol and
authentication details while delegating the actual implementation of enactments to a
user-configured external process. While the details of the CDPI protocol are still subject to
change, the command line interface for these binaries is intended to be significantly more stable
and provide an easy to develop against abstraction that insulates platform integrators from the
majority of those changes.

- The `cdpi_agent` library (`//cdpi_agent`), a Go package that provides a growing set of
- The `agent` library (`//agent`), a Go package that provides a growing set of
abstractions for writing a new CDPI agent. This library is subject to change alongside the CDPI
protocol, so platform integrators are encouraged to use the `agent` binary until the underlying
APIs reach a stable milestone.

## Building

This repo uses the [bazel](https://bazel.build/) build system. Once you have a copy of `bazel` in
your `$PATH`, running `bazel build //cdpi_agent/cmd/agent` will build the Go binary. Similarly,
running `bazel build //cdpi_agent` will build the Go library.
your `$PATH`, running `bazel build //agent/cmd/agent` will build the Go binary. Similarly,
running `bazel build //agent` will build the Go library.

For a full list of available build targets, you can use `bazel query`:

```bash
bazel query //cdpi_agent/...:all
bazel query //agent/...:all
```

## Getting started with the `agent` binary

### Configuration

The `agent` binary accepts configuration in the form of a protobuf message, documented in
[config.proto](cdpi_agent/cmd/agent/config.proto). The message can be encoded in
[config.proto](agent/cmd/agent/config.proto). The message can be encoded in
[prototext format](https://protobuf.dev/reference/protobuf/textformat-spec/) (human readable and
writable), [json](https://protobuf.dev/programming-guides/proto3/#json), or the
[binary proto format](https://protobuf.dev/programming-guides/encoding/). Most users will find the
Expand All @@ -50,37 +50,34 @@ More details for each aspect of the configuration are provided below, but a simp
file might look like this:

```textproto
connection_params: {
# TODO: change to point to the domain of your spacetime instance
cdpi_endpoint: "dns:///my_instance.spacetime.aalyria.com"
# each network_node is configured with a stanza like so:
network_nodes: {
id: "node-a"
enactment_backend: {
connection_params: {
# TODO: change to point to the domain of your spacetime instance
endpoint_uri: "dns:///scheduling.my_instance.spacetime.aalyria.com"

transport_security: {
system_cert_pool: {}
}
transport_security: {
system_cert_pool: {}
}

auth_strategy: {
jwt: {
# TODO: change to the domain of your spacetime instance
audience: "my_instance.spacetime.aalyria.com"
# TODO: use the email your Aalyria representative will share with you
email: "my-cdpi-agent@example.com"
# TODO: use the private key ID your Aalyria representative will share with you
private_key_id: "BADDB0BACAFE"
signing_strategy: {
# TODO: change to the path of your PEM-encoded RSA private key
private_key_file: "/path/to/agent/private/key.pem"
auth_strategy: {
jwt: {
# TODO: change to the domain of your spacetime instance
audience: "scheduling.my_instance.spacetime.aalyria.com"
# TODO: use the email your Aalyria representative will share with you
email: "my-cdpi-agent@example.com"
# TODO: use the private key ID your Aalyria representative will share with you
private_key_id: "BADDB0BACAFE"
signing_strategy: {
# TODO: change to the path of your PEM-encoded RSA private key
private_key_file: "/path/to/agent/private/key.pem"
}
}
}
}
}
}

# each network_node is configured with a stanza like so:
network_nodes: {
id: "node-a"
state_backend: {
static_initial_state: {}
}
enactment_backend: {
external_command: {
# while each command invocation will receive a node ID as part of the
# enactment request, you can also pass additional arguments here to help
Expand All @@ -98,10 +95,31 @@ network_nodes: {

network_nodes: {
id: "node-b"
state_backend: {
static_initial_state: {}
}
enactment_backend: {
connection_params: {
# TODO: change to point to the domain of your spacetime instance
endpoint_uri: "dns:///scheduling.my_instance.spacetime.aalyria.com"

transport_security: {
system_cert_pool: {}
}

auth_strategy: {
jwt: {
# TODO: change to the domain of your spacetime instance
audience: "scheduling.my_instance.spacetime.aalyria.com"
# TODO: use the email your Aalyria representative will share with you
email: "my-cdpi-agent@example.com"
# TODO: use the private key ID your Aalyria representative will share with you
private_key_id: "BADDB0BACAFE"
signing_strategy: {
# TODO: change to the path of your PEM-encoded RSA private key
private_key_file: "/path/to/agent/private/key.pem"
}
}
}
}

external_command: {
args: "/usr/local/bin/some_other_enactment_cmd"
# Use the protobuf binary format for encoding both stdin and stdout messages.
Expand All @@ -111,20 +129,20 @@ network_nodes: {
}
```

See the documentation in [config.proto](cdpi_agent/cmd/agent/config.proto) for more details on the
See the documentation in [config.proto](agent/cmd/agent/config.proto) for more details on the
available options. You can use the `--dry-run` flag to check that your configuration is valid:

```bash
bazel run //cdpi_agent/cmd/agent -- --log-level trace --config "$PWD/config.textproto" --dry-run
bazel run //agent/cmd/agent -- --log-level trace --config "$PWD/config.textproto" --dry-run
INFO: Invocation ID: d8a4b02f-1e01-47cb-bd26-5366704165af
INFO: Analyzed target //cdpi_agent/cmd/agent:agent (0 packages loaded, 0 targets configured).
INFO: Analyzed target //agent/cmd/agent:agent (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //cdpi_agent/cmd/agent:agent up-to-date:
bazel-bin/cdpi_agent/cmd/agent/agent_/agent
Target //agent/cmd/agent:agent up-to-date:
bazel-bin/agent/cmd/agent/agent_/agent
INFO: Elapsed time: 1.768s, Critical Path: 1.56s
INFO: 3 processes: 1 internal, 2 linux-sandbox.
INFO: Build completed successfully, 3 total actions
INFO: Running command line: bazel-bin/cdpi_agent/cmd/agent/agent_/agent --log-level trace --config /path/to/config.textproto --format text --dry-run
INFO: Running command line: bazel-bin/agent/cmd/agent/agent_/agent --log-level trace --config /path/to/config.textproto --format text --dry-run
2023-04-19 11:57:01AM INF config is valid
```

Expand Down Expand Up @@ -153,7 +171,7 @@ Assuming you've saved your configuration in a file called `config.textproto`, yo
following command to start the agent:

```bash
bazel run //cdpi_agent/cmd/agent -- --config "$PWD/my_config.textproto" --log-level debug
bazel run //agent/cmd/agent -- --config "$PWD/my_config.textproto" --log-level debug
```

NOTE: `bazel run` changes the working directory of the process, so you'll need
Expand Down
6 changes: 3 additions & 3 deletions cdpi_agent/agent.go → agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
"fmt"
"sync"

"aalyria.com/spacetime/cdpi_agent/enactment"
"aalyria.com/spacetime/cdpi_agent/internal/task"
"aalyria.com/spacetime/cdpi_agent/telemetry"
"aalyria.com/spacetime/agent/enactment"
"aalyria.com/spacetime/agent/internal/task"
"aalyria.com/spacetime/agent/telemetry"

"github.com/jonboulle/clockwork"
"github.com/rs/zerolog"
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cdpi_agent/cmd/agent/BUILD → agent/cmd/agent/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ go_binary(
go_library(
name = "agent_lib",
srcs = ["agent.go"],
importpath = "aalyria.com/spacetime/cdpi_agent/cmd/agent",
deps = ["//cdpi_agent/internal/agentcli:agentcli_lib"],
importpath = "aalyria.com/spacetime/agent/cmd/agent",
deps = ["//agent/internal/agentcli:agentcli_lib"],
)
2 changes: 1 addition & 1 deletion cdpi_agent/cmd/agent/agent.go → agent/cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"os"

"aalyria.com/spacetime/cdpi_agent/internal/agentcli"
"aalyria.com/spacetime/agent/internal/agentcli"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package(default_visibility = ["//visibility:public"])
go_library(
name = "prom2spacetime_lib",
srcs = ["prom2spacetime.go"],
importpath = "aalyria.com/spacetime/cdpi_agent/cmd/prom2spacetime",
importpath = "aalyria.com/spacetime/agent/cmd/prom2spacetime",
deps = [
"//agent/telemetry/prometheus",
"//api/common:common_go_proto",
"//cdpi_agent/telemetry/prometheus",
"@org_golang_google_protobuf//encoding/protojson",
"@org_golang_google_protobuf//encoding/prototext",
"@org_golang_google_protobuf//encoding/protowire",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

apipb "aalyria.com/spacetime/api/common"
"aalyria.com/spacetime/cdpi_agent/telemetry/prometheus"
"aalyria.com/spacetime/agent/telemetry/prometheus"

"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/encoding/prototext"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cdpi_agent/enactment/BUILD → agent/enactment/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ package(default_visibility = ["//visibility:public"])
go_library(
name = "enactment",
srcs = ["enactment.go"],
importpath = "aalyria.com/spacetime/cdpi_agent/enactment",
importpath = "aalyria.com/spacetime/agent/enactment",
deps = ["//api/scheduling/v1alpha:scheduling_go_grpc"],
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package(default_visibility = ["//visibility:public"])
go_library(
name = "extproc",
srcs = ["extproc.go"],
importpath = "aalyria.com/spacetime/cdpi_agent/enactment/extproc",
importpath = "aalyria.com/spacetime/agent/enactment/extproc",
deps = [
"//agent/enactment",
"//agent/internal/extprocs",
"//agent/internal/protofmt",
"//api/scheduling/v1alpha:scheduling_go_grpc",
"//cdpi_agent/enactment",
"//cdpi_agent/internal/extprocs",
"//cdpi_agent/internal/protofmt",
"@com_github_rs_zerolog//:zerolog",
],
)
Expand All @@ -34,7 +34,7 @@ go_test(
srcs = ["extproc_test.go"],
embed = [":extproc"],
deps = [
"//agent/internal/protofmt",
"//api/scheduling/v1alpha:scheduling_go_grpc",
"//cdpi_agent/internal/protofmt",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import (
"os/exec"

schedpb "aalyria.com/spacetime/api/scheduling/v1alpha"
"aalyria.com/spacetime/cdpi_agent/enactment"
"aalyria.com/spacetime/cdpi_agent/internal/extprocs"
"aalyria.com/spacetime/cdpi_agent/internal/protofmt"
"aalyria.com/spacetime/agent/enactment"
"aalyria.com/spacetime/agent/internal/extprocs"
"aalyria.com/spacetime/agent/internal/protofmt"
"github.com/rs/zerolog"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"testing"

schedpb "aalyria.com/spacetime/api/scheduling/v1alpha"
"aalyria.com/spacetime/cdpi_agent/internal/protofmt"
"aalyria.com/spacetime/agent/internal/protofmt"
)

func TestDispatchEmptyOutput(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ go_library(
"errors.go",
"netlink.go",
],
importpath = "aalyria.com/spacetime/cdpi_agent/enactment/netlink",
importpath = "aalyria.com/spacetime/agent/enactment/netlink",
deps = [
"//api/common:common_go_proto",
"//api/scheduling/v1alpha:scheduling_go_grpc",
Expand Down
Loading
Loading