faucetconfrpc-ng 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) 2020-2022 IQT Labs LLC, All Rights Reserved.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,25 @@
1
+ Metadata-Version: 2.4
2
+ Name: faucetconfrpc-ng
3
+ Version: 1.0.0
4
+ Summary: utility to manage FAUCET config files via RPC (anarkiwi fork)
5
+ License: Apache-2.0
6
+ License-File: LICENSE
7
+ Author: Charlie Lewis
8
+ Author-email: clewis@iqt.org
9
+ Requires-Python: >=3.11,<3.14
10
+ Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Requires-Dist: c65faucet (==1.0.102)
16
+ Requires-Dist: cryptography (==48.0.0)
17
+ Requires-Dist: dnspython (<2.8.1)
18
+ Requires-Dist: grpcio (==1.80.0)
19
+ Requires-Dist: grpcio-tools (==1.80.0)
20
+ Requires-Dist: os-ken (>=3.0.1)
21
+ Requires-Dist: prometheus_client (==0.25.0)
22
+ Requires-Dist: protobuf (==6.33.6)
23
+ Requires-Dist: pybind11 (==3.0.4)
24
+ Requires-Dist: pyopenssl (>22.1.0)
25
+ Project-URL: homepage, https://github.com/IQTLabs/faucetconfrpc
@@ -0,0 +1,39 @@
1
+ [tool.poetry]
2
+ name = "faucetconfrpc-ng"
3
+ version = "1.0.0"
4
+ description = "utility to manage FAUCET config files via RPC (anarkiwi fork)"
5
+ authors = ["Charlie Lewis <clewis@iqt.org>"]
6
+ license = "Apache-2.0"
7
+ packages = [{include = "faucetconfrpc", from = "src"}]
8
+
9
+ [tool.poetry.dependencies]
10
+ python = ">=3.11,<3.14"
11
+ c65faucet = "1.0.102"
12
+ grpcio = "1.80.0"
13
+ grpcio-tools = "1.80.0"
14
+ protobuf = "6.33.6"
15
+ prometheus_client = "0.25.0"
16
+ pybind11 = "3.0.4"
17
+ # dnspython 2.3.0 is not compatible with eventlet
18
+ # https://github.com/eventlet/eventlet/issues/781
19
+ os-ken = ">=3.0.1"
20
+ dnspython = "<2.8.1"
21
+ pyopenssl = ">22.1.0"
22
+ cryptography = "48.0.0"
23
+
24
+ [tool.poetry.dev-dependencies]
25
+ attrs = "26.1.0"
26
+ pylint = "4.0.5"
27
+ pytype = "2024.10.11"
28
+ pytest = "9.0.3"
29
+
30
+ [tool.poetry.scripts]
31
+ faucetconfrpc_server = "faucetconfrpc.faucetconfrpc_server:serve"
32
+ faucetconfrpc_client = "faucetconfrpc.faucetconfrpc_client:main"
33
+
34
+ [tool.poetry.urls]
35
+ homepage = "https://github.com/IQTLabs/faucetconfrpc"
36
+
37
+ [build-system]
38
+ requires = ["poetry-core>=1.0.0"]
39
+ build-backend = "poetry.core.masonry.api"
File without changes
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/python3
2
+
3
+ """Manage FAUCET config files via RPC (client)."""
4
+
5
+ import argparse
6
+ import inspect
7
+ from faucetconfrpc.faucetconfrpc_client_lib import FaucetConfRpcClient
8
+ from faucetconfrpc.faucetconfrpc_server import yaml_load, yaml_dump
9
+
10
+
11
+ class ClientError(Exception):
12
+ """Exceptions for client."""
13
+
14
+
15
+ def get_attributes(cls):
16
+ """Get available RPCs via attrs"""
17
+ boring = dir(type('dummy', (object,), {}))
18
+ return [item for item in inspect.getmembers(cls) if item[0] not in boring]
19
+
20
+
21
+ def yaml_sanity():
22
+ """Ensure YAML libraries present."""
23
+ test_dict = {'test': 'value'}
24
+ test_yaml = yaml_dump(test_dict)
25
+ assert yaml_load(test_yaml) == test_dict
26
+
27
+
28
+ def main():
29
+ """Instantiate client and call it."""
30
+ yaml_sanity()
31
+ parser = argparse.ArgumentParser()
32
+ parser.add_argument(
33
+ '--key', help='client private key', action='store',
34
+ default='client.key')
35
+ parser.add_argument(
36
+ '--cert', help='client public cert', action='store',
37
+ default='client.crt')
38
+ parser.add_argument(
39
+ '--cacert', help='CA public cert', action='store',
40
+ default='ca.crt')
41
+ parser.add_argument(
42
+ '--port', help='port of rpc server', action='store',
43
+ default=59999, type=int)
44
+ parser.add_argument(
45
+ '--host', help='host address of rpc server',
46
+ default='localhost')
47
+ parser.add_argument(
48
+ 'commands', type=str, nargs='+',
49
+ help='rpc commands')
50
+ args = parser.parse_args()
51
+ server_addr = f'{args.host}:{args.port}'
52
+ client = FaucetConfRpcClient(args.key, args.cert, args.cacert, server_addr)
53
+
54
+ if args.commands[0] == 'list_rpcs':
55
+ attributes = get_attributes(client)
56
+ for attribute in attributes:
57
+ if not attribute[0].startswith('_'):
58
+ print(attribute[0])
59
+ return
60
+
61
+ command = getattr(client, args.commands[0], None)
62
+ if not command:
63
+ raise ClientError(f'no such rpc: {args.commands[0]}')
64
+ command_args = {}
65
+ for args in args.commands[1:]:
66
+ arg, val = args.split('=')
67
+ if val.lower() == 'true':
68
+ val = True
69
+ elif val.lower() == 'false':
70
+ val = False
71
+ command_args[arg] = val
72
+ print(command(**command_args))
73
+
74
+
75
+ if __name__ == '__main__':
76
+ main()
@@ -0,0 +1,188 @@
1
+ """faucetconfrpc client library."""
2
+
3
+ import logging
4
+ import grpc
5
+
6
+ from faucetconfrpc import faucetconfrpc_pb2
7
+ from faucetconfrpc import faucetconfrpc_pb2_grpc
8
+ from faucetconfrpc.faucetconfrpc_server import yaml_load, yaml_dump
9
+
10
+
11
+ class FaucetConfRpcClient:
12
+ """faucetconfrpc client library."""
13
+
14
+ def __init__(self, client_key, client_cert, ca_cert, server_addr):
15
+
16
+ def _read_file(filename):
17
+ with open(filename, 'rb', encoding=None) as filename_h:
18
+ return filename_h.read()
19
+
20
+ client_cred_args = {
21
+ arg: _read_file(keyfilename) for arg, keyfilename in (
22
+ ('root_certificates', ca_cert),
23
+ ('certificate_chain', client_cert),
24
+ ('private_key', client_key))}
25
+ client_creds = grpc.ssl_channel_credentials(**client_cred_args)
26
+ self._channel = grpc.secure_channel(server_addr, client_creds)
27
+ self._stub = faucetconfrpc_pb2_grpc.FaucetConfServerStub(self._channel)
28
+
29
+ @staticmethod
30
+ def _call(rpc, params):
31
+ try:
32
+ return rpc(params)
33
+ except grpc.RpcError as err:
34
+ logging.error(err)
35
+ return None
36
+
37
+ def get_config_file(self, config_filename=None):
38
+ """Get a YAML config file."""
39
+ response = self._call(self._stub.GetConfigFile, faucetconfrpc_pb2.GetConfigFileRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
40
+ config_filename=config_filename))
41
+ if response is not None:
42
+ return yaml_load(response.config_yaml)
43
+ return None
44
+
45
+ def set_config_file(self, config_yaml, config_filename=None, merge=True,
46
+ del_config_yaml_keys=''):
47
+ """Set a YAML config file."""
48
+ if isinstance(config_yaml, dict):
49
+ config_yaml = yaml_dump(config_yaml)
50
+ return self._call(self._stub.SetConfigFile, faucetconfrpc_pb2.SetConfigFileRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
51
+ config_filename=config_filename,
52
+ config_yaml=config_yaml,
53
+ merge=merge,
54
+ del_config_yaml_keys=del_config_yaml_keys))
55
+
56
+ def del_config_from_file(self, config_yaml_keys, config_filename=None):
57
+ """Delete a key from YAML config file."""
58
+ if isinstance(config_yaml_keys, list):
59
+ config_yaml_keys = yaml_dump(config_yaml_keys)
60
+ return self._call(self._stub.DelConfigFromFile, faucetconfrpc_pb2.DelConfigFromFileRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
61
+ config_filename=config_filename,
62
+ config_yaml_keys=config_yaml_keys))
63
+
64
+ def add_port_mirror(self, dp_name, port_no, mirror_port_no):
65
+ """Add port mirroring."""
66
+ return self._call(self._stub.AddPortMirror, faucetconfrpc_pb2.AddPortMirrorRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
67
+ dp_name=dp_name, port_no=port_no, mirror_port_no=mirror_port_no))
68
+
69
+ def remove_port_mirror(self, dp_name, port_no, mirror_port_no):
70
+ """Remove port mirroring."""
71
+ return self._call(self._stub.RemovePortMirror, faucetconfrpc_pb2.RemovePortMirrorRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
72
+ dp_name=dp_name, port_no=port_no, mirror_port_no=mirror_port_no))
73
+
74
+ def clear_port_mirror(self, dp_name, mirror_port_no):
75
+ """Clear all mirroring on port."""
76
+ return self._call(self._stub.ClearPortMirror, faucetconfrpc_pb2.ClearPortMirrorRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
77
+ dp_name=dp_name, mirror_port_no=mirror_port_no))
78
+
79
+ def add_port_acl(self, dp_name, port_no, acl):
80
+ """Add port ACL."""
81
+ return self._call(self._stub.AddPortAcl, faucetconfrpc_pb2.AddPortAclRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
82
+ dp_name=dp_name, port_no=port_no, acl=acl))
83
+
84
+ def set_port_acls(self, dp_name, port_no, acls):
85
+ """Set port ACL."""
86
+ return self._call(self._stub.SetPortAcl, faucetconfrpc_pb2.SetPortAclRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
87
+ dp_name=dp_name, port_no=port_no, acls=acls))
88
+
89
+ def set_vlan_out_acl(self, vlan_name, acl_out):
90
+ """Set VLAN out ACL."""
91
+ return self._call(self._stub.SetVlanOutAcl, faucetconfrpc_pb2.SetVlanOutAclRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
92
+ vlan_name=vlan_name, acl_out=acl_out))
93
+
94
+ def remove_port_acl(self, dp_name, port_no, acl=None):
95
+ """Remove port ACL."""
96
+ if acl:
97
+ return self._call(self._stub.RemovePortAcl, faucetconfrpc_pb2.RemovePortAclRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
98
+ dp_name=dp_name, port_no=port_no, acl=acl))
99
+ return self._call(self._stub.RemovePortAcl, faucetconfrpc_pb2.RemovePortAclRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
100
+ dp_name=dp_name, port_no=port_no, acl=acl))
101
+
102
+ def get_dp_info(self, dp_name=''):
103
+ """Get DP info."""
104
+ return self._call(self._stub.GetDpInfo, faucetconfrpc_pb2.GetDpInfoRequest( # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
105
+ dp_name=dp_name))
106
+
107
+ def set_dp_interfaces(self, dp_interfaces_requests=None):
108
+ """Set DP interfaces."""
109
+ if not dp_interfaces_requests:
110
+ dp_interfaces_requests = []
111
+ request = faucetconfrpc_pb2.SetDpInterfacesRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
112
+ for dp_name, dp_interfaces in dp_interfaces_requests:
113
+ dp_request = request.interfaces_config.add() # pylint: disable=no-member
114
+ dp_request.dp_name = dp_name
115
+ for port_no, config_yaml in dp_interfaces.items():
116
+ interfaces_request = dp_request.interface_config.add()
117
+ interfaces_request.port_no = port_no
118
+ interfaces_request.config_yaml = config_yaml
119
+ return self._call(self._stub.SetDpInterfaces, request)
120
+
121
+ def del_dp_interfaces(self, dp_interfaces_requests=None, delete_empty_dp=False):
122
+ """Delete DP interfaces."""
123
+ if not dp_interfaces_requests:
124
+ dp_interfaces_requests = []
125
+ request = faucetconfrpc_pb2.DelDpInterfacesRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
126
+ request.delete_empty_dp = delete_empty_dp
127
+ for dp_name, dp_interfaces in dp_interfaces_requests:
128
+ dp_request = request.interfaces_config.add() # pylint: disable=no-member
129
+ dp_request.name = dp_name
130
+ for port_no in dp_interfaces:
131
+ interfaces_request = dp_request.interfaces.add()
132
+ interfaces_request.port_no = port_no
133
+ return self._call(self._stub.DelDpInterfaces, request)
134
+
135
+ def del_dps(self, dps):
136
+ """Delete DPs."""
137
+ request = faucetconfrpc_pb2.DelDpsRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
138
+ for dp_name in dps:
139
+ dp_request = request.interfaces_config.add() # pylint: disable=no-member
140
+ dp_request.name = dp_name
141
+ return self._call(self._stub.DelDps, request)
142
+
143
+ def set_remote_mirror_port(self, dp_name='', port_no=0, tunnel_vid=0, # pylint: disable=too-many-arguments,disable=too-many-positional-arguments
144
+ remote_dp_name='', remote_port_no=''):
145
+ """Set a port to be a remote mirror via tunnel."""
146
+ request = faucetconfrpc_pb2.SetRemoteMirrorPortRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
147
+ request.dp_name = dp_name
148
+ request.port_no = port_no
149
+ request.tunnel_vid = tunnel_vid
150
+ request.remote_dp_name = remote_dp_name
151
+ request.remote_port_no = remote_port_no
152
+ return self._call(self._stub.SetRemoteMirrorPort, request)
153
+
154
+ def get_dp_names(self):
155
+ """Get a list of DP names."""
156
+ request = faucetconfrpc_pb2.GetDpNamesRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
157
+ return self._call(self._stub.GetDpNames, request)
158
+
159
+ def get_dp_ids(self):
160
+ """Get a list of DP IDs."""
161
+ request = faucetconfrpc_pb2.GetDpIDsRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
162
+ return self._call(self._stub.GetDpIDs, request)
163
+
164
+ def get_acl_names(self):
165
+ """Get a list of ACL names."""
166
+ request = faucetconfrpc_pb2.GetAclNamesRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
167
+ return self._call(self._stub.GetAclNames, request)
168
+
169
+ def set_dps(self, dps_config=None):
170
+ """Set DPs config."""
171
+ if dps_config is None:
172
+ dps_config = {}
173
+ request = faucetconfrpc_pb2.SetDpsRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
174
+ for dp_name, config_yaml in dps_config.items():
175
+ dp_request = request.dp_config.add() # pylint: disable=no-member
176
+ dp_request.dp_name = dp_name
177
+ dp_request.config_yaml = config_yaml
178
+ return self._call(self._stub.SetDps, request)
179
+
180
+ def make_coprocessor_port(self, dp_name='', port_no=0, description='coprocessor',
181
+ strategy='vlan_vid'):
182
+ """Make a coprocessor port."""
183
+ request = faucetconfrpc_pb2.MakeCoprocessorPortRequest() # pylint: disable=no-member,disable=line-too-long # pytype: disable=module-attr
184
+ request.dp_name = dp_name
185
+ request.port_no = port_no
186
+ request.description = description
187
+ request.strategy = strategy
188
+ return self._call(self._stub.MakeCoprocessorPort, request)
@@ -0,0 +1,117 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: faucetconfrpc/faucetconfrpc.proto
4
+ # Protobuf Python Version: 5.26.1
5
+ """Generated protocol buffer code."""
6
+ from google.protobuf import descriptor as _descriptor
7
+ from google.protobuf import descriptor_pool as _descriptor_pool
8
+ from google.protobuf import symbol_database as _symbol_database
9
+ from google.protobuf.internal import builder as _builder
10
+ # @@protoc_insertion_point(imports)
11
+
12
+ _sym_db = _symbol_database.Default()
13
+
14
+
15
+
16
+
17
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n!faucetconfrpc/faucetconfrpc.proto\x12\x10\x66\x61ucetconfserver\"/\n\x14GetConfigFileRequest\x12\x17\n\x0f\x63onfig_filename\x18\x01 \x01(\t\")\n\x12GetConfigFileReply\x12\x13\n\x0b\x63onfig_yaml\x18\x01 \x01(\t\"q\n\x14SetConfigFileRequest\x12\x17\n\x0f\x63onfig_filename\x18\x01 \x01(\t\x12\x13\n\x0b\x63onfig_yaml\x18\x02 \x01(\t\x12\r\n\x05merge\x18\x03 \x01(\x08\x12\x1c\n\x14\x64\x65l_config_yaml_keys\x18\x04 \x01(\t\"\x14\n\x12SetConfigFileReply\"M\n\x18\x44\x65lConfigFromFileRequest\x12\x17\n\x0f\x63onfig_filename\x18\x01 \x01(\t\x12\x18\n\x10\x63onfig_yaml_keys\x18\x02 \x01(\t\"\x18\n\x16\x44\x65lConfigFromFileReply\"\x82\x01\n\x1aSetRemoteMirrorPortRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x0f\n\x07port_no\x18\x02 \x01(\r\x12\x12\n\ntunnel_vid\x18\x03 \x01(\r\x12\x16\n\x0eremote_dp_name\x18\x04 \x01(\t\x12\x16\n\x0eremote_port_no\x18\x05 \x01(\r\"\x1a\n\x18SetRemoteMirrorPortReply\"P\n\x14\x41\x64\x64PortMirrorRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x0f\n\x07port_no\x18\x02 \x01(\r\x12\x16\n\x0emirror_port_no\x18\x03 \x01(\r\"\x14\n\x12\x41\x64\x64PortMirrorReply\"e\n\x1aMakeCoprocessorPortRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x0f\n\x07port_no\x18\x02 \x01(\r\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12\x10\n\x08strategy\x18\x04 \x01(\t\"\x1a\n\x18MakeCoprocessorPortReply\"S\n\x17RemovePortMirrorRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x0f\n\x07port_no\x18\x02 \x01(\r\x12\x16\n\x0emirror_port_no\x18\x03 \x01(\r\"\x17\n\x15RemovePortMirrorReply\"A\n\x16\x43learPortMirrorRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x16\n\x0emirror_port_no\x18\x02 \x01(\r\"\x16\n\x14\x43learPortMirrorReply\":\n\x14SetVlanOutAclRequest\x12\x11\n\tvlan_name\x18\x01 \x01(\t\x12\x0f\n\x07\x61\x63l_out\x18\x02 \x01(\t\"\x14\n\x12SetVlanOutAclReply\"C\n\x11SetPortAclRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x0f\n\x07port_no\x18\x02 \x01(\r\x12\x0c\n\x04\x61\x63ls\x18\x03 \x01(\t\"\x11\n\x0fSetPortAclReply\"B\n\x11\x41\x64\x64PortAclRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x0f\n\x07port_no\x18\x02 \x01(\r\x12\x0b\n\x03\x61\x63l\x18\x03 \x01(\t\"\x11\n\x0f\x41\x64\x64PortAclReply\"E\n\x14RemovePortAclRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x0f\n\x07port_no\x18\x02 \x01(\r\x12\x0b\n\x03\x61\x63l\x18\x03 \x01(\t\"\x14\n\x12RemovePortAclReply\"4\n\x0cSetInterface\x12\x0f\n\x07port_no\x18\x01 \x01(\r\x12\x13\n\x0b\x63onfig_yaml\x18\x02 \x01(\t\"\\\n\x0fSetDpInterfaces\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x38\n\x10interface_config\x18\x02 \x03(\x0b\x32\x1e.faucetconfserver.SetInterface\"V\n\x16SetDpInterfacesRequest\x12<\n\x11interfaces_config\x18\x01 \x03(\x0b\x32!.faucetconfserver.SetDpInterfaces\"\x16\n\x14SetDpInterfacesReply\"<\n\x10GetDpInfoRequest\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x17\n\x0f\x63onfig_filename\x18\x02 \x01(\t\"C\n\rInterfaceInfo\x12\x0f\n\x07port_no\x18\x01 \x01(\r\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\"o\n\x06\x44pInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\r\n\x05\x64p_id\x18\x02 \x01(\x04\x12\x13\n\x0b\x64\x65scription\x18\x03 \x01(\t\x12\x33\n\ninterfaces\x18\x04 \x03(\x0b\x32\x1f.faucetconfserver.InterfaceInfo\"7\n\x0eGetDpInfoReply\x12%\n\x03\x64ps\x18\x01 \x03(\x0b\x32\x18.faucetconfserver.DpInfo\"f\n\x16\x44\x65lDpInterfacesRequest\x12\x33\n\x11interfaces_config\x18\x01 \x03(\x0b\x32\x18.faucetconfserver.DpInfo\x12\x17\n\x0f\x64\x65lete_empty_dp\x18\x02 \x01(\x08\"\x16\n\x14\x44\x65lDpInterfacesReply\"D\n\rDelDpsRequest\x12\x33\n\x11interfaces_config\x18\x01 \x03(\x0b\x32\x18.faucetconfserver.DpInfo\"\r\n\x0b\x44\x65lDpsReply\"\x13\n\x11GetDpNamesRequest\"\"\n\x0fGetDpNamesReply\x12\x0f\n\x07\x64p_name\x18\x01 \x03(\t\"\x11\n\x0fGetDpIDsRequest\"\x1e\n\rGetDpIDsReply\x12\r\n\x05\x64p_id\x18\x01 \x03(\x04\"&\n\x12GetAclNamesRequest\x12\x10\n\x08\x61\x63l_name\x18\x01 \x03(\t\"$\n\x10GetAclNamesReply\x12\x10\n\x08\x61\x63l_name\x18\x01 \x03(\t\"-\n\x05SetDp\x12\x0f\n\x07\x64p_name\x18\x01 \x01(\t\x12\x13\n\x0b\x63onfig_yaml\x18\x02 \x01(\t\";\n\rSetDpsRequest\x12*\n\tdp_config\x18\x01 \x03(\x0b\x32\x17.faucetconfserver.SetDp\"\r\n\x0bSetDpsReply2\x8b\x0f\n\x10\x46\x61ucetConfServer\x12_\n\rGetConfigFile\x12&.faucetconfserver.GetConfigFileRequest\x1a$.faucetconfserver.GetConfigFileReply\"\x00\x12_\n\rSetConfigFile\x12&.faucetconfserver.SetConfigFileRequest\x1a$.faucetconfserver.SetConfigFileReply\"\x00\x12k\n\x11\x44\x65lConfigFromFile\x12*.faucetconfserver.DelConfigFromFileRequest\x1a(.faucetconfserver.DelConfigFromFileReply\"\x00\x12_\n\rAddPortMirror\x12&.faucetconfserver.AddPortMirrorRequest\x1a$.faucetconfserver.AddPortMirrorReply\"\x00\x12h\n\x10RemovePortMirror\x12).faucetconfserver.RemovePortMirrorRequest\x1a\'.faucetconfserver.RemovePortMirrorReply\"\x00\x12\x65\n\x0f\x43learPortMirror\x12(.faucetconfserver.ClearPortMirrorRequest\x1a&.faucetconfserver.ClearPortMirrorReply\"\x00\x12V\n\nAddPortAcl\x12#.faucetconfserver.AddPortAclRequest\x1a!.faucetconfserver.AddPortAclReply\"\x00\x12_\n\rRemovePortAcl\x12&.faucetconfserver.RemovePortAclRequest\x1a$.faucetconfserver.RemovePortAclReply\"\x00\x12V\n\nSetPortAcl\x12#.faucetconfserver.SetPortAclRequest\x1a!.faucetconfserver.SetPortAclReply\"\x00\x12\x65\n\x0fSetDpInterfaces\x12(.faucetconfserver.SetDpInterfacesRequest\x1a&.faucetconfserver.SetDpInterfacesReply\"\x00\x12S\n\tGetDpInfo\x12\".faucetconfserver.GetDpInfoRequest\x1a .faucetconfserver.GetDpInfoReply\"\x00\x12\x65\n\x0f\x44\x65lDpInterfaces\x12(.faucetconfserver.DelDpInterfacesRequest\x1a&.faucetconfserver.DelDpInterfacesReply\"\x00\x12J\n\x06\x44\x65lDps\x12\x1f.faucetconfserver.DelDpsRequest\x1a\x1d.faucetconfserver.DelDpsReply\"\x00\x12q\n\x13SetRemoteMirrorPort\x12,.faucetconfserver.SetRemoteMirrorPortRequest\x1a*.faucetconfserver.SetRemoteMirrorPortReply\"\x00\x12V\n\nGetDpNames\x12#.faucetconfserver.GetDpNamesRequest\x1a!.faucetconfserver.GetDpNamesReply\"\x00\x12P\n\x08GetDpIDs\x12!.faucetconfserver.GetDpIDsRequest\x1a\x1f.faucetconfserver.GetDpIDsReply\"\x00\x12Y\n\x0bGetAclNames\x12$.faucetconfserver.GetAclNamesRequest\x1a\".faucetconfserver.GetAclNamesReply\"\x00\x12J\n\x06SetDps\x12\x1f.faucetconfserver.SetDpsRequest\x1a\x1d.faucetconfserver.SetDpsReply\"\x00\x12q\n\x13MakeCoprocessorPort\x12,.faucetconfserver.MakeCoprocessorPortRequest\x1a*.faucetconfserver.MakeCoprocessorPortReply\"\x00\x12_\n\rSetVlanOutAcl\x12&.faucetconfserver.SetVlanOutAclRequest\x1a$.faucetconfserver.SetVlanOutAclReply\"\x00\x42\x13Z\x11\x66\x61ucetconfserver/b\x06proto3')
18
+
19
+ _globals = globals()
20
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
21
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'faucetconfrpc.faucetconfrpc_pb2', _globals)
22
+ if not _descriptor._USE_C_DESCRIPTORS:
23
+ _globals['DESCRIPTOR']._loaded_options = None
24
+ _globals['DESCRIPTOR']._serialized_options = b'Z\021faucetconfserver/'
25
+ _globals['_GETCONFIGFILEREQUEST']._serialized_start=55
26
+ _globals['_GETCONFIGFILEREQUEST']._serialized_end=102
27
+ _globals['_GETCONFIGFILEREPLY']._serialized_start=104
28
+ _globals['_GETCONFIGFILEREPLY']._serialized_end=145
29
+ _globals['_SETCONFIGFILEREQUEST']._serialized_start=147
30
+ _globals['_SETCONFIGFILEREQUEST']._serialized_end=260
31
+ _globals['_SETCONFIGFILEREPLY']._serialized_start=262
32
+ _globals['_SETCONFIGFILEREPLY']._serialized_end=282
33
+ _globals['_DELCONFIGFROMFILEREQUEST']._serialized_start=284
34
+ _globals['_DELCONFIGFROMFILEREQUEST']._serialized_end=361
35
+ _globals['_DELCONFIGFROMFILEREPLY']._serialized_start=363
36
+ _globals['_DELCONFIGFROMFILEREPLY']._serialized_end=387
37
+ _globals['_SETREMOTEMIRRORPORTREQUEST']._serialized_start=390
38
+ _globals['_SETREMOTEMIRRORPORTREQUEST']._serialized_end=520
39
+ _globals['_SETREMOTEMIRRORPORTREPLY']._serialized_start=522
40
+ _globals['_SETREMOTEMIRRORPORTREPLY']._serialized_end=548
41
+ _globals['_ADDPORTMIRRORREQUEST']._serialized_start=550
42
+ _globals['_ADDPORTMIRRORREQUEST']._serialized_end=630
43
+ _globals['_ADDPORTMIRRORREPLY']._serialized_start=632
44
+ _globals['_ADDPORTMIRRORREPLY']._serialized_end=652
45
+ _globals['_MAKECOPROCESSORPORTREQUEST']._serialized_start=654
46
+ _globals['_MAKECOPROCESSORPORTREQUEST']._serialized_end=755
47
+ _globals['_MAKECOPROCESSORPORTREPLY']._serialized_start=757
48
+ _globals['_MAKECOPROCESSORPORTREPLY']._serialized_end=783
49
+ _globals['_REMOVEPORTMIRRORREQUEST']._serialized_start=785
50
+ _globals['_REMOVEPORTMIRRORREQUEST']._serialized_end=868
51
+ _globals['_REMOVEPORTMIRRORREPLY']._serialized_start=870
52
+ _globals['_REMOVEPORTMIRRORREPLY']._serialized_end=893
53
+ _globals['_CLEARPORTMIRRORREQUEST']._serialized_start=895
54
+ _globals['_CLEARPORTMIRRORREQUEST']._serialized_end=960
55
+ _globals['_CLEARPORTMIRRORREPLY']._serialized_start=962
56
+ _globals['_CLEARPORTMIRRORREPLY']._serialized_end=984
57
+ _globals['_SETVLANOUTACLREQUEST']._serialized_start=986
58
+ _globals['_SETVLANOUTACLREQUEST']._serialized_end=1044
59
+ _globals['_SETVLANOUTACLREPLY']._serialized_start=1046
60
+ _globals['_SETVLANOUTACLREPLY']._serialized_end=1066
61
+ _globals['_SETPORTACLREQUEST']._serialized_start=1068
62
+ _globals['_SETPORTACLREQUEST']._serialized_end=1135
63
+ _globals['_SETPORTACLREPLY']._serialized_start=1137
64
+ _globals['_SETPORTACLREPLY']._serialized_end=1154
65
+ _globals['_ADDPORTACLREQUEST']._serialized_start=1156
66
+ _globals['_ADDPORTACLREQUEST']._serialized_end=1222
67
+ _globals['_ADDPORTACLREPLY']._serialized_start=1224
68
+ _globals['_ADDPORTACLREPLY']._serialized_end=1241
69
+ _globals['_REMOVEPORTACLREQUEST']._serialized_start=1243
70
+ _globals['_REMOVEPORTACLREQUEST']._serialized_end=1312
71
+ _globals['_REMOVEPORTACLREPLY']._serialized_start=1314
72
+ _globals['_REMOVEPORTACLREPLY']._serialized_end=1334
73
+ _globals['_SETINTERFACE']._serialized_start=1336
74
+ _globals['_SETINTERFACE']._serialized_end=1388
75
+ _globals['_SETDPINTERFACES']._serialized_start=1390
76
+ _globals['_SETDPINTERFACES']._serialized_end=1482
77
+ _globals['_SETDPINTERFACESREQUEST']._serialized_start=1484
78
+ _globals['_SETDPINTERFACESREQUEST']._serialized_end=1570
79
+ _globals['_SETDPINTERFACESREPLY']._serialized_start=1572
80
+ _globals['_SETDPINTERFACESREPLY']._serialized_end=1594
81
+ _globals['_GETDPINFOREQUEST']._serialized_start=1596
82
+ _globals['_GETDPINFOREQUEST']._serialized_end=1656
83
+ _globals['_INTERFACEINFO']._serialized_start=1658
84
+ _globals['_INTERFACEINFO']._serialized_end=1725
85
+ _globals['_DPINFO']._serialized_start=1727
86
+ _globals['_DPINFO']._serialized_end=1838
87
+ _globals['_GETDPINFOREPLY']._serialized_start=1840
88
+ _globals['_GETDPINFOREPLY']._serialized_end=1895
89
+ _globals['_DELDPINTERFACESREQUEST']._serialized_start=1897
90
+ _globals['_DELDPINTERFACESREQUEST']._serialized_end=1999
91
+ _globals['_DELDPINTERFACESREPLY']._serialized_start=2001
92
+ _globals['_DELDPINTERFACESREPLY']._serialized_end=2023
93
+ _globals['_DELDPSREQUEST']._serialized_start=2025
94
+ _globals['_DELDPSREQUEST']._serialized_end=2093
95
+ _globals['_DELDPSREPLY']._serialized_start=2095
96
+ _globals['_DELDPSREPLY']._serialized_end=2108
97
+ _globals['_GETDPNAMESREQUEST']._serialized_start=2110
98
+ _globals['_GETDPNAMESREQUEST']._serialized_end=2129
99
+ _globals['_GETDPNAMESREPLY']._serialized_start=2131
100
+ _globals['_GETDPNAMESREPLY']._serialized_end=2165
101
+ _globals['_GETDPIDSREQUEST']._serialized_start=2167
102
+ _globals['_GETDPIDSREQUEST']._serialized_end=2184
103
+ _globals['_GETDPIDSREPLY']._serialized_start=2186
104
+ _globals['_GETDPIDSREPLY']._serialized_end=2216
105
+ _globals['_GETACLNAMESREQUEST']._serialized_start=2218
106
+ _globals['_GETACLNAMESREQUEST']._serialized_end=2256
107
+ _globals['_GETACLNAMESREPLY']._serialized_start=2258
108
+ _globals['_GETACLNAMESREPLY']._serialized_end=2294
109
+ _globals['_SETDP']._serialized_start=2296
110
+ _globals['_SETDP']._serialized_end=2341
111
+ _globals['_SETDPSREQUEST']._serialized_start=2343
112
+ _globals['_SETDPSREQUEST']._serialized_end=2402
113
+ _globals['_SETDPSREPLY']._serialized_start=2404
114
+ _globals['_SETDPSREPLY']._serialized_end=2417
115
+ _globals['_FAUCETCONFSERVER']._serialized_start=2420
116
+ _globals['_FAUCETCONFSERVER']._serialized_end=4351
117
+ # @@protoc_insertion_point(module_scope)