MCPcopy Index your code
hub / github.com/Juniper/contrail

github.com/Juniper/contrail @v5.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.1 ↗ · + Follow
3,658 symbols 12,578 edges 439 files 1,301 documented · 36%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

[POC] Go code base for Contrail projects

This repository holds Go implementation for Contrail projects. The goal of this project is to realize Go-based implementation & etcd based such as Kubernetes in order to improve performance, scale and ease operation.

We are planning to add following sub components.

  • API Server (Python-based VNC API Server equivalent)
  • Sync (IF-MAP, RabbitMQ related code equivalent but depends on etcd)
  • Agent (SchemaTransformer, Device Manager equivalent)
  • Code generation tool (generateDS equivalent)

Currently, this project is POC stage so any external/internal API or design subject to change up to community discussion.

Development setup

Step1. Install Go, Docker and Docker Compose

Step2. Go get Contrail

go get -u github.com/Juniper/contrail

Note that go get -u github.com/Juniper/contrail/cmd/contrailutil fails because we don't commit generated code.

Step3. Install dependencies

# move to repo
cd $HOME/go/src/github.com/Juniper/contrail
# make sure put GOBIN to path
export PATH=$PATH:$HOME/go/bin
# or if you defined GOPATH
# cd $GOPATH/src/github.com/Juniper/contrail
make deps

Step4. Generate source code

make generate

Step5. Install Contrail binaries

make install

Step6. Setup test environment

make testenv reset_db

Note that these commands use docker command and depending on your Docker configuration they may require root permissions. See: Docker Documentation

First run

  • Run Contrail process

    bash contrail -c sample/contrail.yml run

    Note that you can overwrite configuration parameters using environment variable with prefix "CONTRAIL_"

    For example CONTRAIL_DATABASE_DEBUG is overwriting database.debug value.

    bash CONTRAIL_DATABASE_DEBUG=true contrail -c sample/contrail.yml run

    Individual processes can be enabled or disabled using the configuration parameters.

  • Run CLI commands

    ```bash export CONTRAIL_CONFIG=sample/cli.yml

    Show schema

    contrailcli schema virtual_network

    Sync resources

    contrailcli sync sample/sample_resource.yml

    List resources

    contrailcli list virtual_network --detail

    Delete resources

    contrailcli delete sample/sample_resource.yml ```

    See: CLI Usage

Testing

Run all tests with coverage:

make test

API documentation

OpenAPI specification file is generated during every run of make generate and it is located in ./public/openapi.json.

You can also run API doc server on local machine using:

make apidoc

The doc will be available on localhost:5000.

How to contribute

Step1

Setup Gerrit account. Sign CLA.

Step2

Install git-review tool.

pip install git-review

Step3

Send review to Gerrit:

git review

Documentation

See: Documentation index

Extension points exported contracts — how you extend this code

Runner (Interface)
Runner can be run and return an error. [6 implementers]
pkg/testutil/integration/service.go
EventProcessor (Interface)
EventProcessor can handle events on generic way. [9 implementers]
pkg/services/common.go
DataStore (Interface)
DataStore interface to store cluster data [5 implementers]
pkg/deploy/base/data.go
MessageBuilder (Interface)
MessageBuilder is interface to build the message [5 implementers]
pkg/collector/collector.go
InTransactionDoer (Interface)
InTransactionDoer executes do function atomically. [4 implementers]
pkg/types/service.go
AuthRequest (Interface)
AuthRequest is used to request an authentication. [2 implementers]
pkg/keystone/types.go
Codec (Interface)
Codec can encode objects and update encoded data with new data object. [2 implementers]
pkg/models/codec.go
EventDecoder (Interface)
EventDecoder is capable of decoding row data in form of map into an Event. [2 implementers]
pkg/sync/replication/event_decoder.go

Core symbols most depended-on inside this repo

GetUUID
called by 245
pkg/db/db.go
Run
called by 209
pkg/testutil/integration/service.go
Error
called by 146
pkg/neutron/logic/errors.go
GetString
called by 124
pkg/db/cassandra/cassandra.go
Quote
called by 95
pkg/db/basedb/query_builder.go
DoInTransaction
called by 81
pkg/compilation/service.go
Debugf
called by 72
pkg/retry/retry.go
Close
called by 70
pkg/sync/service.go

Shape

Method 1,761
Function 1,453
Struct 309
Interface 83
TypeAlias 44
FuncType 8

Languages

Go100%

Modules by API surface

pkg/deploy/base/data.go97 symbols
pkg/services/event_encoding.go84 symbols
pkg/cloud/data.go76 symbols
pkg/deploy/cluster/multi_cloud.go68 symbols
pkg/schema/schema.go64 symbols
pkg/services/common.go62 symbols
pkg/apisrv/server_test.go57 symbols
pkg/deploy/cluster/cluster_test.go55 symbols
pkg/neutron/logic/subnet.go54 symbols
pkg/db/basedb/query_builder.go52 symbols
pkg/deploy/cluster/ansible.go44 symbols
pkg/apisrv/rbac/rbac.go44 symbols

For agents

$ claude mcp add contrail \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact