From f8300fb6a375b20e1c04bc2506f3f6fa494b5f86 Mon Sep 17 00:00:00 2001 From: tonic Date: Thu, 22 Sep 2016 15:03:39 +0800 Subject: [PATCH] add list network api --- cluster/calcium/network.go | 28 ++++ cluster/cluster.go | 1 + devtools/client.py | 17 +++ devtools/core_pb2.py | 210 +++++++++++++++++++++++------- network/calico/plugin.go | 36 +++++- network/network.go | 7 +- rpc/gen/core.pb.go | 258 +++++++++++++++++++++++-------------- rpc/gen/core.proto | 10 ++ rpc/rpc.go | 14 ++ rpc/transform.go | 4 + types/network.go | 6 + 11 files changed, 443 insertions(+), 148 deletions(-) create mode 100644 cluster/calcium/network.go create mode 100644 types/network.go diff --git a/cluster/calcium/network.go b/cluster/calcium/network.go new file mode 100644 index 000000000..fb148ae1a --- /dev/null +++ b/cluster/calcium/network.go @@ -0,0 +1,28 @@ +package calcium + +import ( + "fmt" + + "gitlab.ricebook.net/platform/core/types" + "gitlab.ricebook.net/platform/core/utils" +) + +// list networks for podname +// just get one node from podname +// and call docker network ls +// only get those driven by network driver +func (c *calcium) ListNetworks(podname string) ([]*types.Network, error) { + networks := []*types.Network{} + nodes, err := c.ListPodNodes(podname) + if err != nil { + return networks, err + } + + if len(nodes) == 0 { + return networks, fmt.Errorf("Pod %s has no nodes", podname) + } + + node := nodes[0] + ctx := utils.ToDockerContext(node.Engine) + return c.network.ListNetworks(ctx) +} diff --git a/cluster/cluster.go b/cluster/cluster.go index a5c551474..dc1f6db53 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -14,6 +14,7 @@ type Cluster interface { ListPodNodes(podname string) ([]*types.Node, error) GetContainer(id string) (*types.Container, error) GetContainers(ids []string) ([]*types.Container, error) + ListNetworks(podname string) ([]*types.Network, error) // cluster methods BuildImage(repository, version, uid, artifact string) (chan *types.BuildImageMessage, error) diff --git a/devtools/client.py b/devtools/client.py index 94ab3b109..274a2091a 100755 --- a/devtools/client.py +++ b/devtools/client.py @@ -95,6 +95,23 @@ def get_pod_nodes(ctx, name): click.echo(node) +@cli.command('pod:networks') +@click.argument('name') +@click.pass_context +def get_pod_networks(ctx, name): + stub = _get_stub(ctx) + opts = pb.GetPodOptions(name=name) + + try: + r = stub.ListNetworks(opts, 5) + except AbortionError as e: + click.echo(click.style('abortion error: %s' % e.details, fg='red', bold=True)) + ctx.exit(-1) + + for n in r.networks: + click.echo('%s: %s' % (n.name, ','.join(n.subnets))) + + @cli.command('node:get') @click.argument('podname') @click.argument('nodename') diff --git a/devtools/core_pb2.py b/devtools/core_pb2.py index 8b9c088d3..b8c2c86ca 100644 --- a/devtools/core_pb2.py +++ b/devtools/core_pb2.py @@ -19,7 +19,7 @@ name='core.proto', package='pb', syntax='proto3', - serialized_pb=_b('\n\ncore.proto\x12\x02pb\"\x07\n\x05\x45mpty\"!\n\x03Pod\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x65sc\x18\x02 \x01(\t\"\x1d\n\x04Pods\x12\x15\n\x04pods\x18\x01 \x03(\x0b\x32\x07.pb.Pod\"\xa1\x01\n\x04Node\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07podname\x18\x03 \x01(\t\x12\x0e\n\x06public\x18\x04 \x01(\x08\x12\x1e\n\x03\x63pu\x18\x05 \x03(\x0b\x32\x11.pb.Node.CpuEntry\x12\x0c\n\x04info\x18\x06 \x01(\t\x1a*\n\x08\x43puEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x03:\x02\x38\x01\" \n\x05Nodes\x12\x17\n\x05nodes\x18\x01 \x03(\x0b\x32\x08.pb.Node\"V\n\tContainer\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0f\n\x07podname\x18\x02 \x01(\t\x12\x10\n\x08nodename\x18\x03 \x01(\t\x12\x0c\n\x04name\x18\x04 \x01(\t\x12\x0c\n\x04info\x18\x05 \x01(\t\"/\n\nContainers\x12!\n\ncontainers\x18\x01 \x03(\x0b\x32\r.pb.Container\"\x19\n\x0b\x43ontainerID\x12\n\n\x02id\x18\x01 \x01(\t\",\n\x0c\x43ontainerIDs\x12\x1c\n\x03ids\x18\x01 \x03(\x0b\x32\x0f.pb.ContainerID\"+\n\rAddPodOptions\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x65sc\x18\x02 \x01(\t\"\x1d\n\rGetPodOptions\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x88\x01\n\x0e\x41\x64\x64NodeOptions\x12\x10\n\x08nodename\x18\x01 \x01(\t\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07podname\x18\x03 \x01(\t\x12\x0e\n\x06\x63\x61\x66ile\x18\x04 \x01(\t\x12\x10\n\x08\x63\x65rtfile\x18\x05 \x01(\t\x12\x0f\n\x07keyfile\x18\x06 \x01(\t\x12\x0e\n\x06public\x18\x07 \x01(\x08\"3\n\x0eGetNodeOptions\x12\x0f\n\x07podname\x18\x01 \x01(\t\x12\x10\n\x08nodename\x18\x02 \x01(\t\"#\n\x10ListNodesOptions\x12\x0f\n\x07podname\x18\x01 \x01(\t\"Q\n\x11\x42uildImageOptions\x12\x0c\n\x04repo\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x0b\n\x03uid\x18\x03 \x01(\t\x12\x10\n\x08\x61rtifact\x18\x04 \x01(\t\"\xa5\x02\n\rDeployOptions\x12\r\n\x05specs\x18\x01 \x01(\t\x12\x0f\n\x07\x61ppname\x18\x02 \x01(\t\x12\r\n\x05image\x18\x03 \x01(\t\x12\x0f\n\x07podname\x18\x04 \x01(\t\x12\x10\n\x08nodename\x18\x05 \x01(\t\x12\x12\n\nentrypoint\x18\x06 \x01(\t\x12\x11\n\tcpu_quota\x18\x07 \x01(\x01\x12\r\n\x05\x63ount\x18\x08 \x01(\x05\x12\x0e\n\x06memory\x18\t \x01(\x03\x12\x0b\n\x03\x65nv\x18\n \x03(\t\x12\x31\n\x08networks\x18\x0b \x03(\x0b\x32\x1f.pb.DeployOptions.NetworksEntry\x12\x0b\n\x03raw\x18\x0c \x01(\x08\x1a/\n\rNetworksEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"=\n\x0eUpgradeOptions\x12\x1c\n\x03ids\x18\x01 \x03(\x0b\x32\x0f.pb.ContainerID\x12\r\n\x05image\x18\x02 \x01(\t\"G\n\x12RemoveImageOptions\x12\x0f\n\x07podname\x18\x01 \x01(\t\x12\x10\n\x08nodename\x18\x02 \x01(\t\x12\x0e\n\x06images\x18\x03 \x03(\t\",\n\x0b\x45rrorDetail\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x03\x12\x0f\n\x07message\x18\x02 \x01(\t\"{\n\x11\x42uildImageMessage\x12\x0e\n\x06status\x18\x01 \x01(\t\x12\x10\n\x08progress\x18\x02 \x01(\t\x12\r\n\x05\x65rror\x18\x03 \x01(\t\x12\x0e\n\x06stream\x18\x04 \x01(\t\x12%\n\x0c\x65rror_detail\x18\x05 \x01(\x0b\x32\x0f.pb.ErrorDetail\"\xd3\x01\n\x16\x43reateContainerMessage\x12\x0f\n\x07podname\x18\x01 \x01(\t\x12\x10\n\x08nodename\x18\x02 \x01(\t\x12\n\n\x02id\x18\x03 \x01(\t\x12\x0c\n\x04name\x18\x04 \x01(\t\x12\r\n\x05\x65rror\x18\x05 \x01(\t\x12\x0f\n\x07success\x18\x06 \x01(\x08\x12\x30\n\x03\x63pu\x18\x07 \x03(\x0b\x32#.pb.CreateContainerMessage.CpuEntry\x1a*\n\x08\x43puEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x03:\x02\x38\x01\"F\n\x12RemoveImageMessage\x12\r\n\x05image\x18\x01 \x01(\t\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x10\n\x08messages\x18\x03 \x03(\t\"F\n\x16RemoveContainerMessage\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x0f\n\x07message\x18\x03 \x01(\t\"g\n\x17UpgradeContainerMessage\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0e\n\x06new_id\x18\x02 \x01(\t\x12\x10\n\x08new_name\x18\x03 \x01(\t\x12\r\n\x05\x65rror\x18\x04 \x01(\t\x12\x0f\n\x07success\x18\x05 \x01(\x08\x32\xbb\x05\n\x07\x43oreRPC\x12!\n\x08ListPods\x12\t.pb.Empty\x1a\x08.pb.Pods\"\x00\x12&\n\x06\x41\x64\x64Pod\x12\x11.pb.AddPodOptions\x1a\x07.pb.Pod\"\x00\x12&\n\x06GetPod\x12\x11.pb.GetPodOptions\x1a\x07.pb.Pod\"\x00\x12)\n\x07\x41\x64\x64Node\x12\x12.pb.AddNodeOptions\x1a\x08.pb.Node\"\x00\x12)\n\x07GetNode\x12\x12.pb.GetNodeOptions\x1a\x08.pb.Node\"\x00\x12\x31\n\x0cListPodNodes\x12\x14.pb.ListNodesOptions\x1a\t.pb.Nodes\"\x00\x12\x30\n\x0cGetContainer\x12\x0f.pb.ContainerID\x1a\r.pb.Container\"\x00\x12\x33\n\rGetContainers\x12\x10.pb.ContainerIDs\x1a\x0e.pb.Containers\"\x00\x12>\n\nBuildImage\x12\x15.pb.BuildImageOptions\x1a\x15.pb.BuildImageMessage\"\x00\x30\x01\x12\x42\n\x0f\x43reateContainer\x12\x11.pb.DeployOptions\x1a\x1a.pb.CreateContainerMessage0\x01\x12\x45\n\x10UpgradeContainer\x12\x12.pb.UpgradeOptions\x1a\x1b.pb.UpgradeContainerMessage0\x01\x12\x41\n\x0fRemoveContainer\x12\x10.pb.ContainerIDs\x1a\x1a.pb.RemoveContainerMessage0\x01\x12?\n\x0bRemoveImage\x12\x16.pb.RemoveImageOptions\x1a\x16.pb.RemoveImageMessage0\x01\x62\x06proto3') + serialized_pb=_b('\n\ncore.proto\x12\x02pb\"\x07\n\x05\x45mpty\"!\n\x03Pod\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x65sc\x18\x02 \x01(\t\"\x1d\n\x04Pods\x12\x15\n\x04pods\x18\x01 \x03(\x0b\x32\x07.pb.Pod\"(\n\x07Network\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07subnets\x18\x02 \x03(\t\")\n\x08Networks\x12\x1d\n\x08networks\x18\x01 \x03(\x0b\x32\x0b.pb.Network\"\xa1\x01\n\x04Node\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07podname\x18\x03 \x01(\t\x12\x0e\n\x06public\x18\x04 \x01(\x08\x12\x1e\n\x03\x63pu\x18\x05 \x03(\x0b\x32\x11.pb.Node.CpuEntry\x12\x0c\n\x04info\x18\x06 \x01(\t\x1a*\n\x08\x43puEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x03:\x02\x38\x01\" \n\x05Nodes\x12\x17\n\x05nodes\x18\x01 \x03(\x0b\x32\x08.pb.Node\"V\n\tContainer\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0f\n\x07podname\x18\x02 \x01(\t\x12\x10\n\x08nodename\x18\x03 \x01(\t\x12\x0c\n\x04name\x18\x04 \x01(\t\x12\x0c\n\x04info\x18\x05 \x01(\t\"/\n\nContainers\x12!\n\ncontainers\x18\x01 \x03(\x0b\x32\r.pb.Container\"\x19\n\x0b\x43ontainerID\x12\n\n\x02id\x18\x01 \x01(\t\",\n\x0c\x43ontainerIDs\x12\x1c\n\x03ids\x18\x01 \x03(\x0b\x32\x0f.pb.ContainerID\"+\n\rAddPodOptions\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x65sc\x18\x02 \x01(\t\"\x1d\n\rGetPodOptions\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x88\x01\n\x0e\x41\x64\x64NodeOptions\x12\x10\n\x08nodename\x18\x01 \x01(\t\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07podname\x18\x03 \x01(\t\x12\x0e\n\x06\x63\x61\x66ile\x18\x04 \x01(\t\x12\x10\n\x08\x63\x65rtfile\x18\x05 \x01(\t\x12\x0f\n\x07keyfile\x18\x06 \x01(\t\x12\x0e\n\x06public\x18\x07 \x01(\x08\"3\n\x0eGetNodeOptions\x12\x0f\n\x07podname\x18\x01 \x01(\t\x12\x10\n\x08nodename\x18\x02 \x01(\t\"#\n\x10ListNodesOptions\x12\x0f\n\x07podname\x18\x01 \x01(\t\"Q\n\x11\x42uildImageOptions\x12\x0c\n\x04repo\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x0b\n\x03uid\x18\x03 \x01(\t\x12\x10\n\x08\x61rtifact\x18\x04 \x01(\t\"\xa5\x02\n\rDeployOptions\x12\r\n\x05specs\x18\x01 \x01(\t\x12\x0f\n\x07\x61ppname\x18\x02 \x01(\t\x12\r\n\x05image\x18\x03 \x01(\t\x12\x0f\n\x07podname\x18\x04 \x01(\t\x12\x10\n\x08nodename\x18\x05 \x01(\t\x12\x12\n\nentrypoint\x18\x06 \x01(\t\x12\x11\n\tcpu_quota\x18\x07 \x01(\x01\x12\r\n\x05\x63ount\x18\x08 \x01(\x05\x12\x0e\n\x06memory\x18\t \x01(\x03\x12\x0b\n\x03\x65nv\x18\n \x03(\t\x12\x31\n\x08networks\x18\x0b \x03(\x0b\x32\x1f.pb.DeployOptions.NetworksEntry\x12\x0b\n\x03raw\x18\x0c \x01(\x08\x1a/\n\rNetworksEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"=\n\x0eUpgradeOptions\x12\x1c\n\x03ids\x18\x01 \x03(\x0b\x32\x0f.pb.ContainerID\x12\r\n\x05image\x18\x02 \x01(\t\"G\n\x12RemoveImageOptions\x12\x0f\n\x07podname\x18\x01 \x01(\t\x12\x10\n\x08nodename\x18\x02 \x01(\t\x12\x0e\n\x06images\x18\x03 \x03(\t\",\n\x0b\x45rrorDetail\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x03\x12\x0f\n\x07message\x18\x02 \x01(\t\"{\n\x11\x42uildImageMessage\x12\x0e\n\x06status\x18\x01 \x01(\t\x12\x10\n\x08progress\x18\x02 \x01(\t\x12\r\n\x05\x65rror\x18\x03 \x01(\t\x12\x0e\n\x06stream\x18\x04 \x01(\t\x12%\n\x0c\x65rror_detail\x18\x05 \x01(\x0b\x32\x0f.pb.ErrorDetail\"\xd3\x01\n\x16\x43reateContainerMessage\x12\x0f\n\x07podname\x18\x01 \x01(\t\x12\x10\n\x08nodename\x18\x02 \x01(\t\x12\n\n\x02id\x18\x03 \x01(\t\x12\x0c\n\x04name\x18\x04 \x01(\t\x12\r\n\x05\x65rror\x18\x05 \x01(\t\x12\x0f\n\x07success\x18\x06 \x01(\x08\x12\x30\n\x03\x63pu\x18\x07 \x03(\x0b\x32#.pb.CreateContainerMessage.CpuEntry\x1a*\n\x08\x43puEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x03:\x02\x38\x01\"F\n\x12RemoveImageMessage\x12\r\n\x05image\x18\x01 \x01(\t\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x10\n\x08messages\x18\x03 \x03(\t\"F\n\x16RemoveContainerMessage\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0f\n\x07success\x18\x02 \x01(\x08\x12\x0f\n\x07message\x18\x03 \x01(\t\"g\n\x17UpgradeContainerMessage\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0e\n\x06new_id\x18\x02 \x01(\t\x12\x10\n\x08new_name\x18\x03 \x01(\t\x12\r\n\x05\x65rror\x18\x04 \x01(\t\x12\x0f\n\x07success\x18\x05 \x01(\x08\x32\xee\x05\n\x07\x43oreRPC\x12!\n\x08ListPods\x12\t.pb.Empty\x1a\x08.pb.Pods\"\x00\x12&\n\x06\x41\x64\x64Pod\x12\x11.pb.AddPodOptions\x1a\x07.pb.Pod\"\x00\x12&\n\x06GetPod\x12\x11.pb.GetPodOptions\x1a\x07.pb.Pod\"\x00\x12)\n\x07\x41\x64\x64Node\x12\x12.pb.AddNodeOptions\x1a\x08.pb.Node\"\x00\x12)\n\x07GetNode\x12\x12.pb.GetNodeOptions\x1a\x08.pb.Node\"\x00\x12\x31\n\x0cListPodNodes\x12\x14.pb.ListNodesOptions\x1a\t.pb.Nodes\"\x00\x12\x30\n\x0cGetContainer\x12\x0f.pb.ContainerID\x1a\r.pb.Container\"\x00\x12\x33\n\rGetContainers\x12\x10.pb.ContainerIDs\x1a\x0e.pb.Containers\"\x00\x12\x31\n\x0cListNetworks\x12\x11.pb.GetPodOptions\x1a\x0c.pb.Networks\"\x00\x12>\n\nBuildImage\x12\x15.pb.BuildImageOptions\x1a\x15.pb.BuildImageMessage\"\x00\x30\x01\x12\x42\n\x0f\x43reateContainer\x12\x11.pb.DeployOptions\x1a\x1a.pb.CreateContainerMessage0\x01\x12\x45\n\x10UpgradeContainer\x12\x12.pb.UpgradeOptions\x1a\x1b.pb.UpgradeContainerMessage0\x01\x12\x41\n\x0fRemoveContainer\x12\x10.pb.ContainerIDs\x1a\x1a.pb.RemoveContainerMessage0\x01\x12?\n\x0bRemoveImage\x12\x16.pb.RemoveImageOptions\x1a\x16.pb.RemoveImageMessage0\x01\x62\x06proto3') ) _sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -119,6 +119,75 @@ ) +_NETWORK = _descriptor.Descriptor( + name='Network', + full_name='pb.Network', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='name', full_name='pb.Network.name', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='subnets', full_name='pb.Network.subnets', index=1, + number=2, type=9, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=93, + serialized_end=133, +) + + +_NETWORKS = _descriptor.Descriptor( + name='Networks', + full_name='pb.Networks', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='networks', full_name='pb.Networks.networks', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=135, + serialized_end=176, +) + + _NODE_CPUENTRY = _descriptor.Descriptor( name='CpuEntry', full_name='pb.Node.CpuEntry', @@ -152,8 +221,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=213, - serialized_end=255, + serialized_start=298, + serialized_end=340, ) _NODE = _descriptor.Descriptor( @@ -217,8 +286,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=94, - serialized_end=255, + serialized_start=179, + serialized_end=340, ) @@ -248,8 +317,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=257, - serialized_end=289, + serialized_start=342, + serialized_end=374, ) @@ -307,8 +376,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=291, - serialized_end=377, + serialized_start=376, + serialized_end=462, ) @@ -338,8 +407,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=379, - serialized_end=426, + serialized_start=464, + serialized_end=511, ) @@ -369,8 +438,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=428, - serialized_end=453, + serialized_start=513, + serialized_end=538, ) @@ -400,8 +469,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=455, - serialized_end=499, + serialized_start=540, + serialized_end=584, ) @@ -438,8 +507,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=501, - serialized_end=544, + serialized_start=586, + serialized_end=629, ) @@ -469,8 +538,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=546, - serialized_end=575, + serialized_start=631, + serialized_end=660, ) @@ -542,8 +611,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=578, - serialized_end=714, + serialized_start=663, + serialized_end=799, ) @@ -580,8 +649,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=716, - serialized_end=767, + serialized_start=801, + serialized_end=852, ) @@ -611,8 +680,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=769, - serialized_end=804, + serialized_start=854, + serialized_end=889, ) @@ -663,8 +732,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=806, - serialized_end=887, + serialized_start=891, + serialized_end=972, ) @@ -701,8 +770,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1136, - serialized_end=1183, + serialized_start=1221, + serialized_end=1268, ) _DEPLOYOPTIONS = _descriptor.Descriptor( @@ -808,8 +877,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=890, - serialized_end=1183, + serialized_start=975, + serialized_end=1268, ) @@ -846,8 +915,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1185, - serialized_end=1246, + serialized_start=1270, + serialized_end=1331, ) @@ -891,8 +960,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1248, - serialized_end=1319, + serialized_start=1333, + serialized_end=1404, ) @@ -929,8 +998,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1321, - serialized_end=1365, + serialized_start=1406, + serialized_end=1450, ) @@ -988,8 +1057,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1367, - serialized_end=1490, + serialized_start=1452, + serialized_end=1575, ) @@ -1026,8 +1095,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=213, - serialized_end=255, + serialized_start=298, + serialized_end=340, ) _CREATECONTAINERMESSAGE = _descriptor.Descriptor( @@ -1098,8 +1167,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1493, - serialized_end=1704, + serialized_start=1578, + serialized_end=1789, ) @@ -1143,8 +1212,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1706, - serialized_end=1776, + serialized_start=1791, + serialized_end=1861, ) @@ -1188,8 +1257,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1778, - serialized_end=1848, + serialized_start=1863, + serialized_end=1933, ) @@ -1247,11 +1316,12 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1850, - serialized_end=1953, + serialized_start=1935, + serialized_end=2038, ) _PODS.fields_by_name['pods'].message_type = _POD +_NETWORKS.fields_by_name['networks'].message_type = _NETWORK _NODE_CPUENTRY.containing_type = _NODE _NODE.fields_by_name['cpu'].message_type = _NODE_CPUENTRY _NODES.fields_by_name['nodes'].message_type = _NODE @@ -1266,6 +1336,8 @@ DESCRIPTOR.message_types_by_name['Empty'] = _EMPTY DESCRIPTOR.message_types_by_name['Pod'] = _POD DESCRIPTOR.message_types_by_name['Pods'] = _PODS +DESCRIPTOR.message_types_by_name['Network'] = _NETWORK +DESCRIPTOR.message_types_by_name['Networks'] = _NETWORKS DESCRIPTOR.message_types_by_name['Node'] = _NODE DESCRIPTOR.message_types_by_name['Nodes'] = _NODES DESCRIPTOR.message_types_by_name['Container'] = _CONTAINER @@ -1309,6 +1381,20 @@ )) _sym_db.RegisterMessage(Pods) +Network = _reflection.GeneratedProtocolMessageType('Network', (_message.Message,), dict( + DESCRIPTOR = _NETWORK, + __module__ = 'core_pb2' + # @@protoc_insertion_point(class_scope:pb.Network) + )) +_sym_db.RegisterMessage(Network) + +Networks = _reflection.GeneratedProtocolMessageType('Networks', (_message.Message,), dict( + DESCRIPTOR = _NETWORKS, + __module__ = 'core_pb2' + # @@protoc_insertion_point(class_scope:pb.Networks) + )) +_sym_db.RegisterMessage(Networks) + Node = _reflection.GeneratedProtocolMessageType('Node', (_message.Message,), dict( CpuEntry = _reflection.GeneratedProtocolMessageType('CpuEntry', (_message.Message,), dict( @@ -1542,6 +1628,11 @@ def __init__(self, channel): request_serializer=ContainerIDs.SerializeToString, response_deserializer=Containers.FromString, ) + self.ListNetworks = channel.unary_unary( + '/pb.CoreRPC/ListNetworks', + request_serializer=GetPodOptions.SerializeToString, + response_deserializer=Networks.FromString, + ) self.BuildImage = channel.unary_stream( '/pb.CoreRPC/BuildImage', request_serializer=BuildImageOptions.SerializeToString, @@ -1611,6 +1702,11 @@ def GetContainers(self, request, context): context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') + def ListNetworks(self, request, context): + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + def BuildImage(self, request, context): context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -1679,6 +1775,11 @@ def add_CoreRPCServicer_to_server(servicer, server): request_deserializer=ContainerIDs.FromString, response_serializer=Containers.SerializeToString, ), + 'ListNetworks': grpc.unary_unary_rpc_method_handler( + servicer.ListNetworks, + request_deserializer=GetPodOptions.FromString, + response_serializer=Networks.SerializeToString, + ), 'BuildImage': grpc.unary_stream_rpc_method_handler( servicer.BuildImage, request_deserializer=BuildImageOptions.FromString, @@ -1727,6 +1828,8 @@ def GetContainer(self, request, context): context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def GetContainers(self, request, context): context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) + def ListNetworks(self, request, context): + context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def BuildImage(self, request, context): context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) def CreateContainer(self, request, context): @@ -1764,6 +1867,9 @@ def GetContainer(self, request, timeout, metadata=None, with_call=False, protoco def GetContainers(self, request, timeout, metadata=None, with_call=False, protocol_options=None): raise NotImplementedError() GetContainers.future = None + def ListNetworks(self, request, timeout, metadata=None, with_call=False, protocol_options=None): + raise NotImplementedError() + ListNetworks.future = None def BuildImage(self, request, timeout, metadata=None, with_call=False, protocol_options=None): raise NotImplementedError() def CreateContainer(self, request, timeout, metadata=None, with_call=False, protocol_options=None): @@ -1786,6 +1892,7 @@ def beta_create_CoreRPC_server(servicer, pool=None, pool_size=None, default_time ('pb.CoreRPC', 'GetContainers'): ContainerIDs.FromString, ('pb.CoreRPC', 'GetNode'): GetNodeOptions.FromString, ('pb.CoreRPC', 'GetPod'): GetPodOptions.FromString, + ('pb.CoreRPC', 'ListNetworks'): GetPodOptions.FromString, ('pb.CoreRPC', 'ListPodNodes'): ListNodesOptions.FromString, ('pb.CoreRPC', 'ListPods'): Empty.FromString, ('pb.CoreRPC', 'RemoveContainer'): ContainerIDs.FromString, @@ -1801,6 +1908,7 @@ def beta_create_CoreRPC_server(servicer, pool=None, pool_size=None, default_time ('pb.CoreRPC', 'GetContainers'): Containers.SerializeToString, ('pb.CoreRPC', 'GetNode'): Node.SerializeToString, ('pb.CoreRPC', 'GetPod'): Pod.SerializeToString, + ('pb.CoreRPC', 'ListNetworks'): Networks.SerializeToString, ('pb.CoreRPC', 'ListPodNodes'): Nodes.SerializeToString, ('pb.CoreRPC', 'ListPods'): Pods.SerializeToString, ('pb.CoreRPC', 'RemoveContainer'): RemoveContainerMessage.SerializeToString, @@ -1816,6 +1924,7 @@ def beta_create_CoreRPC_server(servicer, pool=None, pool_size=None, default_time ('pb.CoreRPC', 'GetContainers'): face_utilities.unary_unary_inline(servicer.GetContainers), ('pb.CoreRPC', 'GetNode'): face_utilities.unary_unary_inline(servicer.GetNode), ('pb.CoreRPC', 'GetPod'): face_utilities.unary_unary_inline(servicer.GetPod), + ('pb.CoreRPC', 'ListNetworks'): face_utilities.unary_unary_inline(servicer.ListNetworks), ('pb.CoreRPC', 'ListPodNodes'): face_utilities.unary_unary_inline(servicer.ListPodNodes), ('pb.CoreRPC', 'ListPods'): face_utilities.unary_unary_inline(servicer.ListPods), ('pb.CoreRPC', 'RemoveContainer'): face_utilities.unary_stream_inline(servicer.RemoveContainer), @@ -1836,6 +1945,7 @@ def beta_create_CoreRPC_stub(channel, host=None, metadata_transformer=None, pool ('pb.CoreRPC', 'GetContainers'): ContainerIDs.SerializeToString, ('pb.CoreRPC', 'GetNode'): GetNodeOptions.SerializeToString, ('pb.CoreRPC', 'GetPod'): GetPodOptions.SerializeToString, + ('pb.CoreRPC', 'ListNetworks'): GetPodOptions.SerializeToString, ('pb.CoreRPC', 'ListPodNodes'): ListNodesOptions.SerializeToString, ('pb.CoreRPC', 'ListPods'): Empty.SerializeToString, ('pb.CoreRPC', 'RemoveContainer'): ContainerIDs.SerializeToString, @@ -1851,6 +1961,7 @@ def beta_create_CoreRPC_stub(channel, host=None, metadata_transformer=None, pool ('pb.CoreRPC', 'GetContainers'): Containers.FromString, ('pb.CoreRPC', 'GetNode'): Node.FromString, ('pb.CoreRPC', 'GetPod'): Pod.FromString, + ('pb.CoreRPC', 'ListNetworks'): Networks.FromString, ('pb.CoreRPC', 'ListPodNodes'): Nodes.FromString, ('pb.CoreRPC', 'ListPods'): Pods.FromString, ('pb.CoreRPC', 'RemoveContainer'): RemoveContainerMessage.FromString, @@ -1866,6 +1977,7 @@ def beta_create_CoreRPC_stub(channel, host=None, metadata_transformer=None, pool 'GetContainers': cardinality.Cardinality.UNARY_UNARY, 'GetNode': cardinality.Cardinality.UNARY_UNARY, 'GetPod': cardinality.Cardinality.UNARY_UNARY, + 'ListNetworks': cardinality.Cardinality.UNARY_UNARY, 'ListPodNodes': cardinality.Cardinality.UNARY_UNARY, 'ListPods': cardinality.Cardinality.UNARY_UNARY, 'RemoveContainer': cardinality.Cardinality.UNARY_STREAM, diff --git a/network/calico/plugin.go b/network/calico/plugin.go index 7440fdaf1..b59498d2b 100644 --- a/network/calico/plugin.go +++ b/network/calico/plugin.go @@ -5,7 +5,9 @@ import ( "net" log "github.com/Sirupsen/logrus" + enginetypes "github.com/docker/engine-api/types" enginenetwork "github.com/docker/engine-api/types/network" + "gitlab.ricebook.net/platform/core/types" "gitlab.ricebook.net/platform/core/utils" "golang.org/x/net/context" ) @@ -33,7 +35,7 @@ func (t *titanium) ConnectToNetwork(ctx context.Context, containerID, networkID, engine, ok := utils.FromDockerContext(ctx) if !ok { - return fmt.Errorf("Not actually a `engineapi.Client` for value engine in context", containerID) + return fmt.Errorf("Not actually a `engineapi.Client` for value engine in context") } config := &enginenetwork.EndpointSettings{ @@ -63,13 +65,43 @@ func (t *titanium) DisconnectFromNetwork(ctx context.Context, containerID, netwo engine, ok := utils.FromDockerContext(ctx) if !ok { - return fmt.Errorf("Not actually a `engineapi.Client` for value engine in context", containerID) + return fmt.Errorf("Not actually a `engineapi.Client` for value engine in context") } log.Debugf("Disconnect %q from %q", containerID, networkID) return engine.NetworkDisconnect(context.Background(), networkID, containerID, false) } +// list networks from context +func (t *titanium) ListNetworks(ctx context.Context) ([]*types.Network, error) { + networks := []*types.Network{} + engine, ok := utils.FromDockerContext(ctx) + if !ok { + return networks, fmt.Errorf("Not actually a `engineapi.Client` for value engine in context") + } + + ns, err := engine.NetworkList(context.Background(), enginetypes.NetworkListOptions{}) + if err != nil { + return networks, err + } + + driver := t.Name() + for _, n := range ns { + // TODO 之后可以用filter driver=xxx + // 但是现在版本的API还没有给出 + if n.Driver != driver { + continue + } + + subnets := []string{} + for _, config := range n.IPAM.Config { + subnets = append(subnets, config.Subnet) + } + networks = append(networks, &types.Network{Name: n.Name, Subnets: subnets}) + } + return networks, nil +} + func New() *titanium { return &titanium{} } diff --git a/network/network.go b/network/network.go index 683874149..eb693e022 100644 --- a/network/network.go +++ b/network/network.go @@ -1,11 +1,16 @@ package network -import "golang.org/x/net/context" +import ( + "gitlab.ricebook.net/platform/core/types" + "golang.org/x/net/context" +) type Network interface { // connect and disconnect ConnectToNetwork(ctx context.Context, containerID, networkID, ipv4 string) error DisconnectFromNetwork(ctx context.Context, containerID, networkID string) error + // list networks + ListNetworks(ctx context.Context) ([]*types.Network, error) // type and name to identify the network manager // this will determine when to call connect/disconnect Type() string diff --git a/rpc/gen/core.pb.go b/rpc/gen/core.pb.go index b694cbe1d..1e511a65a 100644 --- a/rpc/gen/core.pb.go +++ b/rpc/gen/core.pb.go @@ -12,6 +12,8 @@ It has these top-level messages: Empty Pod Pods + Network + Networks Node Nodes Container @@ -91,6 +93,32 @@ func (m *Pods) GetPods() []*Pod { return nil } +type Network struct { + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Subnets []string `protobuf:"bytes,2,rep,name=subnets" json:"subnets,omitempty"` +} + +func (m *Network) Reset() { *m = Network{} } +func (m *Network) String() string { return proto.CompactTextString(m) } +func (*Network) ProtoMessage() {} +func (*Network) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } + +type Networks struct { + Networks []*Network `protobuf:"bytes,1,rep,name=networks" json:"networks,omitempty"` +} + +func (m *Networks) Reset() { *m = Networks{} } +func (m *Networks) String() string { return proto.CompactTextString(m) } +func (*Networks) ProtoMessage() {} +func (*Networks) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } + +func (m *Networks) GetNetworks() []*Network { + if m != nil { + return m.Networks + } + return nil +} + type Node struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` Endpoint string `protobuf:"bytes,2,opt,name=endpoint" json:"endpoint,omitempty"` @@ -103,7 +131,7 @@ type Node struct { func (m *Node) Reset() { *m = Node{} } func (m *Node) String() string { return proto.CompactTextString(m) } func (*Node) ProtoMessage() {} -func (*Node) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +func (*Node) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } func (m *Node) GetCpu() map[string]int64 { if m != nil { @@ -119,7 +147,7 @@ type Nodes struct { func (m *Nodes) Reset() { *m = Nodes{} } func (m *Nodes) String() string { return proto.CompactTextString(m) } func (*Nodes) ProtoMessage() {} -func (*Nodes) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } +func (*Nodes) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } func (m *Nodes) GetNodes() []*Node { if m != nil { @@ -139,7 +167,7 @@ type Container struct { func (m *Container) Reset() { *m = Container{} } func (m *Container) String() string { return proto.CompactTextString(m) } func (*Container) ProtoMessage() {} -func (*Container) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } +func (*Container) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } type Containers struct { Containers []*Container `protobuf:"bytes,1,rep,name=containers" json:"containers,omitempty"` @@ -148,7 +176,7 @@ type Containers struct { func (m *Containers) Reset() { *m = Containers{} } func (m *Containers) String() string { return proto.CompactTextString(m) } func (*Containers) ProtoMessage() {} -func (*Containers) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } +func (*Containers) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } func (m *Containers) GetContainers() []*Container { if m != nil { @@ -166,7 +194,7 @@ type ContainerID struct { func (m *ContainerID) Reset() { *m = ContainerID{} } func (m *ContainerID) String() string { return proto.CompactTextString(m) } func (*ContainerID) ProtoMessage() {} -func (*ContainerID) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } +func (*ContainerID) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } type ContainerIDs struct { Ids []*ContainerID `protobuf:"bytes,1,rep,name=ids" json:"ids,omitempty"` @@ -175,7 +203,7 @@ type ContainerIDs struct { func (m *ContainerIDs) Reset() { *m = ContainerIDs{} } func (m *ContainerIDs) String() string { return proto.CompactTextString(m) } func (*ContainerIDs) ProtoMessage() {} -func (*ContainerIDs) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} } +func (*ContainerIDs) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } func (m *ContainerIDs) GetIds() []*ContainerID { if m != nil { @@ -192,7 +220,7 @@ type AddPodOptions struct { func (m *AddPodOptions) Reset() { *m = AddPodOptions{} } func (m *AddPodOptions) String() string { return proto.CompactTextString(m) } func (*AddPodOptions) ProtoMessage() {} -func (*AddPodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} } +func (*AddPodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } type GetPodOptions struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` @@ -201,7 +229,7 @@ type GetPodOptions struct { func (m *GetPodOptions) Reset() { *m = GetPodOptions{} } func (m *GetPodOptions) String() string { return proto.CompactTextString(m) } func (*GetPodOptions) ProtoMessage() {} -func (*GetPodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} } +func (*GetPodOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } type AddNodeOptions struct { Nodename string `protobuf:"bytes,1,opt,name=nodename" json:"nodename,omitempty"` @@ -216,7 +244,7 @@ type AddNodeOptions struct { func (m *AddNodeOptions) Reset() { *m = AddNodeOptions{} } func (m *AddNodeOptions) String() string { return proto.CompactTextString(m) } func (*AddNodeOptions) ProtoMessage() {} -func (*AddNodeOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} } +func (*AddNodeOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } type GetNodeOptions struct { Podname string `protobuf:"bytes,1,opt,name=podname" json:"podname,omitempty"` @@ -226,7 +254,7 @@ type GetNodeOptions struct { func (m *GetNodeOptions) Reset() { *m = GetNodeOptions{} } func (m *GetNodeOptions) String() string { return proto.CompactTextString(m) } func (*GetNodeOptions) ProtoMessage() {} -func (*GetNodeOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{12} } +func (*GetNodeOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } type ListNodesOptions struct { Podname string `protobuf:"bytes,1,opt,name=podname" json:"podname,omitempty"` @@ -235,7 +263,7 @@ type ListNodesOptions struct { func (m *ListNodesOptions) Reset() { *m = ListNodesOptions{} } func (m *ListNodesOptions) String() string { return proto.CompactTextString(m) } func (*ListNodesOptions) ProtoMessage() {} -func (*ListNodesOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{13} } +func (*ListNodesOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } type BuildImageOptions struct { Repo string `protobuf:"bytes,1,opt,name=repo" json:"repo,omitempty"` @@ -247,7 +275,7 @@ type BuildImageOptions struct { func (m *BuildImageOptions) Reset() { *m = BuildImageOptions{} } func (m *BuildImageOptions) String() string { return proto.CompactTextString(m) } func (*BuildImageOptions) ProtoMessage() {} -func (*BuildImageOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{14} } +func (*BuildImageOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } type DeployOptions struct { Specs string `protobuf:"bytes,1,opt,name=specs" json:"specs,omitempty"` @@ -267,7 +295,7 @@ type DeployOptions struct { func (m *DeployOptions) Reset() { *m = DeployOptions{} } func (m *DeployOptions) String() string { return proto.CompactTextString(m) } func (*DeployOptions) ProtoMessage() {} -func (*DeployOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{15} } +func (*DeployOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } func (m *DeployOptions) GetNetworks() map[string]string { if m != nil { @@ -284,7 +312,7 @@ type UpgradeOptions struct { func (m *UpgradeOptions) Reset() { *m = UpgradeOptions{} } func (m *UpgradeOptions) String() string { return proto.CompactTextString(m) } func (*UpgradeOptions) ProtoMessage() {} -func (*UpgradeOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{16} } +func (*UpgradeOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } func (m *UpgradeOptions) GetIds() []*ContainerID { if m != nil { @@ -302,7 +330,7 @@ type RemoveImageOptions struct { func (m *RemoveImageOptions) Reset() { *m = RemoveImageOptions{} } func (m *RemoveImageOptions) String() string { return proto.CompactTextString(m) } func (*RemoveImageOptions) ProtoMessage() {} -func (*RemoveImageOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{17} } +func (*RemoveImageOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} } type ErrorDetail struct { Code int64 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` @@ -312,7 +340,7 @@ type ErrorDetail struct { func (m *ErrorDetail) Reset() { *m = ErrorDetail{} } func (m *ErrorDetail) String() string { return proto.CompactTextString(m) } func (*ErrorDetail) ProtoMessage() {} -func (*ErrorDetail) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{18} } +func (*ErrorDetail) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} } type BuildImageMessage struct { Status string `protobuf:"bytes,1,opt,name=status" json:"status,omitempty"` @@ -325,7 +353,7 @@ type BuildImageMessage struct { func (m *BuildImageMessage) Reset() { *m = BuildImageMessage{} } func (m *BuildImageMessage) String() string { return proto.CompactTextString(m) } func (*BuildImageMessage) ProtoMessage() {} -func (*BuildImageMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{19} } +func (*BuildImageMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{21} } func (m *BuildImageMessage) GetErrorDetail() *ErrorDetail { if m != nil { @@ -347,7 +375,7 @@ type CreateContainerMessage struct { func (m *CreateContainerMessage) Reset() { *m = CreateContainerMessage{} } func (m *CreateContainerMessage) String() string { return proto.CompactTextString(m) } func (*CreateContainerMessage) ProtoMessage() {} -func (*CreateContainerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{20} } +func (*CreateContainerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{22} } func (m *CreateContainerMessage) GetCpu() map[string]int64 { if m != nil { @@ -365,7 +393,7 @@ type RemoveImageMessage struct { func (m *RemoveImageMessage) Reset() { *m = RemoveImageMessage{} } func (m *RemoveImageMessage) String() string { return proto.CompactTextString(m) } func (*RemoveImageMessage) ProtoMessage() {} -func (*RemoveImageMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{21} } +func (*RemoveImageMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} } type RemoveContainerMessage struct { Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` @@ -376,7 +404,7 @@ type RemoveContainerMessage struct { func (m *RemoveContainerMessage) Reset() { *m = RemoveContainerMessage{} } func (m *RemoveContainerMessage) String() string { return proto.CompactTextString(m) } func (*RemoveContainerMessage) ProtoMessage() {} -func (*RemoveContainerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{22} } +func (*RemoveContainerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{24} } type UpgradeContainerMessage struct { Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` @@ -389,12 +417,14 @@ type UpgradeContainerMessage struct { func (m *UpgradeContainerMessage) Reset() { *m = UpgradeContainerMessage{} } func (m *UpgradeContainerMessage) String() string { return proto.CompactTextString(m) } func (*UpgradeContainerMessage) ProtoMessage() {} -func (*UpgradeContainerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{23} } +func (*UpgradeContainerMessage) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{25} } func init() { proto.RegisterType((*Empty)(nil), "pb.Empty") proto.RegisterType((*Pod)(nil), "pb.Pod") proto.RegisterType((*Pods)(nil), "pb.Pods") + proto.RegisterType((*Network)(nil), "pb.Network") + proto.RegisterType((*Networks)(nil), "pb.Networks") proto.RegisterType((*Node)(nil), "pb.Node") proto.RegisterType((*Nodes)(nil), "pb.Nodes") proto.RegisterType((*Container)(nil), "pb.Container") @@ -437,6 +467,7 @@ type CoreRPCClient interface { ListPodNodes(ctx context.Context, in *ListNodesOptions, opts ...grpc.CallOption) (*Nodes, error) GetContainer(ctx context.Context, in *ContainerID, opts ...grpc.CallOption) (*Container, error) GetContainers(ctx context.Context, in *ContainerIDs, opts ...grpc.CallOption) (*Containers, error) + ListNetworks(ctx context.Context, in *GetPodOptions, opts ...grpc.CallOption) (*Networks, error) BuildImage(ctx context.Context, in *BuildImageOptions, opts ...grpc.CallOption) (CoreRPC_BuildImageClient, error) CreateContainer(ctx context.Context, in *DeployOptions, opts ...grpc.CallOption) (CoreRPC_CreateContainerClient, error) UpgradeContainer(ctx context.Context, in *UpgradeOptions, opts ...grpc.CallOption) (CoreRPC_UpgradeContainerClient, error) @@ -524,6 +555,15 @@ func (c *coreRPCClient) GetContainers(ctx context.Context, in *ContainerIDs, opt return out, nil } +func (c *coreRPCClient) ListNetworks(ctx context.Context, in *GetPodOptions, opts ...grpc.CallOption) (*Networks, error) { + out := new(Networks) + err := grpc.Invoke(ctx, "/pb.CoreRPC/ListNetworks", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *coreRPCClient) BuildImage(ctx context.Context, in *BuildImageOptions, opts ...grpc.CallOption) (CoreRPC_BuildImageClient, error) { stream, err := grpc.NewClientStream(ctx, &_CoreRPC_serviceDesc.Streams[0], c.cc, "/pb.CoreRPC/BuildImage", opts...) if err != nil { @@ -695,6 +735,7 @@ type CoreRPCServer interface { ListPodNodes(context.Context, *ListNodesOptions) (*Nodes, error) GetContainer(context.Context, *ContainerID) (*Container, error) GetContainers(context.Context, *ContainerIDs) (*Containers, error) + ListNetworks(context.Context, *GetPodOptions) (*Networks, error) BuildImage(*BuildImageOptions, CoreRPC_BuildImageServer) error CreateContainer(*DeployOptions, CoreRPC_CreateContainerServer) error UpgradeContainer(*UpgradeOptions, CoreRPC_UpgradeContainerServer) error @@ -850,6 +891,24 @@ func _CoreRPC_GetContainers_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _CoreRPC_ListNetworks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPodOptions) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CoreRPCServer).ListNetworks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.CoreRPC/ListNetworks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CoreRPCServer).ListNetworks(ctx, req.(*GetPodOptions)) + } + return interceptor(ctx, in, info, handler) +} + func _CoreRPC_BuildImage_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(BuildImageOptions) if err := stream.RecvMsg(m); err != nil { @@ -991,6 +1050,10 @@ var _CoreRPC_serviceDesc = grpc.ServiceDesc{ MethodName: "GetContainers", Handler: _CoreRPC_GetContainers_Handler, }, + { + MethodName: "ListNetworks", + Handler: _CoreRPC_ListNetworks_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -1025,79 +1088,82 @@ var _CoreRPC_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("core.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 1171 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x57, 0xeb, 0x6e, 0xe4, 0x34, - 0x14, 0x6e, 0x26, 0x93, 0xb9, 0x9c, 0xe9, 0x6d, 0xad, 0x6e, 0x09, 0xa9, 0x58, 0xba, 0xae, 0x04, - 0x45, 0x62, 0xab, 0x6e, 0x57, 0x5c, 0x44, 0x25, 0x50, 0xb7, 0x2d, 0x55, 0x25, 0x28, 0x25, 0x12, - 0xff, 0x90, 0x4a, 0x9a, 0xb8, 0x55, 0xd4, 0x99, 0x38, 0xe4, 0xd2, 0xd1, 0x3c, 0x03, 0xbf, 0x90, - 0x78, 0x09, 0x9e, 0x81, 0x17, 0xe0, 0x15, 0x78, 0x1b, 0x74, 0x7c, 0xc9, 0xd8, 0xd9, 0x29, 0x15, - 0xfd, 0xe7, 0xcf, 0x3e, 0x39, 0xe7, 0xf8, 0xf3, 0x77, 0x7c, 0x1c, 0x80, 0x98, 0x17, 0x6c, 0x2f, - 0x2f, 0x78, 0xc5, 0x49, 0x27, 0xbf, 0xa6, 0x7d, 0xf0, 0x4e, 0x27, 0x79, 0x35, 0xa3, 0xaf, 0xc0, - 0xbd, 0xe4, 0x09, 0x21, 0xd0, 0xcd, 0xa2, 0x09, 0xf3, 0x9d, 0x6d, 0x67, 0x77, 0x18,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x2e, 0x58, 0xce, 0x35, 0xd3, 0x38, 0x46, - 0x17, 0xf7, 0xac, 0x28, 0x53, 0x9e, 0x69, 0xd1, 0x2a, 0x88, 0x05, 0x54, 0xa7, 0x89, 0x22, 0x0d, - 0x87, 0x98, 0x5e, 0x54, 0x54, 0xe9, 0x4d, 0x14, 0x57, 0x8a, 0xb2, 0x06, 0xd3, 0x3f, 0x5c, 0x58, - 0x39, 0x61, 0xf9, 0x98, 0xcf, 0x74, 0xb4, 0x0d, 0xf0, 0xca, 0x9c, 0xc5, 0xa5, 0x0a, 0x27, 0x01, - 0xc6, 0x8b, 0xf2, 0xdc, 0x2c, 0x12, 0x05, 0xd1, 0x3e, 0xc5, 0x6c, 0x55, 0x44, 0x09, 0xcc, 0x2d, - 0x76, 0x1f, 0x26, 0xcb, 0x6b, 0x09, 0xe2, 0x05, 0x00, 0xc3, 0x5b, 0x40, 0x4a, 0x42, 0x9e, 0x94, - 0x31, 0x43, 0xb6, 0x60, 0x18, 0xe7, 0xf5, 0xd5, 0xaf, 0x35, 0xaf, 0x22, 0x71, 0x5e, 0x4e, 0x38, - 0x88, 0xf3, 0xfa, 0x47, 0xc4, 0x98, 0x48, 0xcc, 0xeb, 0xac, 0xf2, 0x07, 0xdb, 0xce, 0xae, 0x17, - 0x4a, 0x80, 0xe7, 0x3b, 0x61, 0x13, 0x5e, 0xcc, 0xfc, 0xa1, 0xb8, 0x3e, 0x14, 0x42, 0x9a, 0x58, - 0x76, 0xef, 0xc3, 0xb6, 0x8b, 0x34, 0xb1, 0xec, 0x9e, 0x1c, 0xc2, 0x20, 0x63, 0xd5, 0x94, 0x17, - 0x77, 0xa5, 0x3f, 0x12, 0x25, 0xf4, 0x21, 0x96, 0x90, 0xc5, 0xce, 0xde, 0x85, 0xb2, 0x90, 0x37, - 0x5a, 0xf3, 0x01, 0xba, 0x2b, 0xa2, 0xa9, 0xbf, 0x2c, 0x34, 0x84, 0xc3, 0xe0, 0x10, 0x56, 0x2c, - 0xe3, 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, 0x60, 0xa8, 0xbf, 0xc0, - 0x8d, 0xed, 0xc3, 0xf2, 0x19, 0xab, 0xe6, 0xaf, 0xb6, 0xf6, 0x95, 0x17, 0xd8, 0xcf, 0x26, 0xba, - 0x44, 0xde, 0x88, 0x17, 0x8a, 0xf1, 0xd8, 0x5a, 0x6f, 0x7d, 0x52, 0x06, 0xab, 0xd6, 0x0c, 0x86, - 0xf9, 0x1a, 0x60, 0x7e, 0xf7, 0x90, 0xe7, 0xb8, 0xfe, 0x4e, 0x03, 0x0e, 0x5a, 0xd3, 0x4a, 0x1c, - 0x74, 0x69, 0xdf, 0x21, 0x6f, 0x61, 0xad, 0x55, 0x5c, 0x92, 0x60, 0xab, 0x6b, 0x04, 0xc1, 0xc3, - 0x45, 0xb8, 0xef, 0x90, 0x53, 0x58, 0x6f, 0xeb, 0x4f, 0x32, 0x6a, 0xb7, 0x80, 0x60, 0xcb, 0x98, - 0x5b, 0xe0, 0xe6, 0x08, 0xd6, 0x5a, 0x55, 0xb2, 0x80, 0x01, 0x91, 0xc9, 0xe2, 0x62, 0xda, 0x77, - 0xc8, 0x37, 0x30, 0x32, 0x4a, 0x99, 0x6c, 0xce, 0x8d, 0x2d, 0x3e, 0xda, 0xf3, 0x8d, 0x83, 0xeb, - 0x9e, 0xf8, 0xab, 0x79, 0xf3, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x9e, 0x9a, 0x15, 0xe3, - 0x0c, 0x00, 0x00, + // 1218 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x9c, 0x57, 0xef, 0x6e, 0xdc, 0x44, + 0x10, 0xaf, 0xcf, 0xe7, 0x3b, 0xdf, 0xdc, 0x25, 0x4d, 0x57, 0x6d, 0x30, 0xae, 0x28, 0xe9, 0x56, + 0xa2, 0x41, 0xa2, 0x51, 0xda, 0x0a, 0x8a, 0x88, 0x04, 0x6a, 0x93, 0x50,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0e, 0x79, 0x03, 0x77, 0x3b, 0xef, 0x51, 0x59, 0x6d, 0x35, 0x9a, 0x30, 0xbc, 0xfe, 0xdd, 0xee, + 0x3b, 0xe4, 0x18, 0xb6, 0xba, 0x94, 0x55, 0x97, 0xd0, 0xee, 0x1a, 0xe1, 0x43, 0x6b, 0x6f, 0x8d, + 0x9a, 0xd7, 0x70, 0xb7, 0xf3, 0xb0, 0xd6, 0x24, 0x4d, 0x7a, 0xb2, 0xfe, 0xfd, 0xed, 0x3b, 0xe4, + 0x1b, 0x18, 0x5b, 0xaf, 0x9f, 0x6c, 0xaf, 0x84, 0x5b, 0xf9, 0xe8, 0xee, 0x37, 0x0a, 0xa6, 0x03, + 0xf9, 0xdb, 0xf5, 0xf2, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0xbb, 0xe6, 0xdc, 0x84, 0x0d, + 0x00, 0x00, } diff --git a/rpc/gen/core.proto b/rpc/gen/core.proto index c8488a3a7..cce17ab7f 100644 --- a/rpc/gen/core.proto +++ b/rpc/gen/core.proto @@ -12,6 +12,7 @@ service CoreRPC { rpc ListPodNodes(ListNodesOptions) returns (Nodes) {}; rpc GetContainer(ContainerID) returns (Container) {}; rpc GetContainers(ContainerIDs) returns (Containers) {}; + rpc ListNetworks(GetPodOptions) returns (Networks) {}; rpc BuildImage(BuildImageOptions) returns (stream BuildImageMessage) {}; rpc CreateContainer(DeployOptions) returns (stream CreateContainerMessage); @@ -32,6 +33,15 @@ message Pods { repeated Pod pods = 1; } +message Network { + string name = 1; + repeated string subnets = 2; +} + +message Networks { + repeated Network networks = 1; +} + message Node { string name = 1; string endpoint = 2; diff --git a/rpc/rpc.go b/rpc/rpc.go index 29a272a5e..01b2061a8 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -140,6 +140,20 @@ func (v *virbranium) GetContainers(ctx context.Context, cids *pb.ContainerIDs) ( return &pb.Containers{Containers: cs}, nil } +// list networks for pod +func (v *virbranium) ListNetworks(ctx context.Context, opts *pb.GetPodOptions) (*pb.Networks, error) { + networks, err := v.cluster.ListNetworks(opts.Name) + if err != nil { + return nil, err + } + + ns := []*pb.Network{} + for _, n := range networks { + ns = append(ns, toRPCNetwork(n)) + } + return &pb.Networks{Networks: ns}, nil +} + // streamed returned functions // caller must ensure that timeout will not be too short because these actions take a little time func (v *virbranium) BuildImage(opts *pb.BuildImageOptions, stream pb.CoreRPC_BuildImageServer) error { diff --git a/rpc/transform.go b/rpc/transform.go index be15a58ce..593878ad6 100644 --- a/rpc/transform.go +++ b/rpc/transform.go @@ -19,6 +19,10 @@ func toRPCPod(p *types.Pod) *pb.Pod { return &pb.Pod{Name: p.Name, Desc: p.Desc} } +func toRPCNetwork(n *types.Network) *pb.Network { + return &pb.Network{Name: n.Name, Subnets: n.Subnets} +} + func toRPCNode(n *types.Node) *pb.Node { bytes := []byte("") if info, err := n.Info(); err == nil { diff --git a/types/network.go b/types/network.go new file mode 100644 index 000000000..30f430bb0 --- /dev/null +++ b/types/network.go @@ -0,0 +1,6 @@ +package types + +type Network struct { + Name string `json:"name"` + Subnets []string `json:"cidr"` +}