Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • tfs/controller
1 result
Show changes
Showing
with 1324 additions and 0 deletions
<!-- Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. -->
<?xml version="1.0" encoding="UTF-8"?>
<config>
<!-- TCP port where the BGP is listening for incoming bgp4 connections. Optional Parameter. Default value: 179 (BGP Port) -->
<BGP4Port>22179</BGP4Port>
<BGPIdentifier>1.1.1.1</BGPIdentifier>
<!-- TCP port to connect to manage the BGP connection. Default value: 1112 -->
<BGP4ManagementPort>1112</BGP4ManagementPort>
<!-- Peers to which this Peer is going to establish connection -->
<configPeer>
<peer>localhost</peer>
<export>false</export>
<import>true</import>
<peerPort>11179</peerPort>
</configPeer>
<!-- Ficheros log (servidor, protocolo PCEP y OSPF). Campos opcionales-->
<BGP4LogFile>BGP4Parser2.log</BGP4LogFile><!-- Default value: BGP4Parser.log -->
<BGP4LogFileClient>BGP4Client2.log</BGP4LogFileClient><!-- Default value: BGP4Client.log-->
<BGP4LogFileServer>BGP4Server2.log</BGP4LogFileServer><!-- Default value: BGP4Server.log-->
<!-- If the tcp no delay option is used or not. Optional Parameter. Default value: false. -->
<nodelay>true</nodelay>
<!-- Waiting Time to re-connect to clients. Default value: 6000 ms. -->
<delay>40000</delay>
<setTraces>true</setTraces>
<!-- OPEN Parameters -->
<!-- RFC 4271. This 2-octet unsigned integer indicates the number of seconds the sender proposes for the value of the Hold Timer.
Upon receipt of an OPEN message, a BGP speaker MUST calculate the value of the Hold Timer by using the smaller of its configured
Hold Time and the Hold Time received in the OPEN message. The Hold Time MUST be either zero or at least three seconds. An
implementation MAY reject connections on the basis of the Hold Time. The calculated value indicates the maximum number of
seconds that may elapse between the receipt of successive KEEPALIVE and/or UPDATE messages from the sender. -->
<holdTime>180</holdTime><!-- Optional Parameter. Default value: 3. -->
<!-- RFC 4271. This 1-octet unsigned integer indicates the protocol version number of the message. The current BGP version number is 4. -->
<version>4</version><!-- Optional Parameter. Default value: 4. -->
<!-- RFC 4271. This 2-octet unsigned integer indicates the Autonomous System number of the sender.-->
<myAutonomousSystem>1</myAutonomousSystem>
<!-- RFC 4271. This 4-octet unsigned integer indicates the BGP Identifier of the sender. A given BGP speaker sets the value of its BGP
Identifier to an IP address that is assigned to that BGP speaker. The value of the BGP Identifier is determined upon
startup and is the same for every local interface and BGP peer. -->
<!--<BGPIdentifier>192.168.1.200</BGPIdentifier> -->
<!-- If the peer is in charge of sending its topology (only the interdomain Links) to the other BGP peer it is connected to. Default: false -->
<sendTopology>false</sendTopology>
<!-- If the peer is in charge of sending its whole topology to the other BGP peer it is connected to. Default: false -->
<sendIntradomainLinks>true</sendIntradomainLinks>
<!-- Optional Parameter. How to learn the topology. Possibilities: fromXML, fromBGP. Default: fromBGP -->
<learnTopology>fromBGP</learnTopology>
<!-- Topology network to read. It is mandatory if and only if learnTopology parameter is fromXML. -->
<!--<topologyFile>src/test/resources/network1.xml</topologyFile>-->
<!-- Optional Parameter. Instance Identifier for node and link NLRI. See rfc 6549. Default value: 0-->
<!--<instanceID>0</instanceID>-->
<!-- Optional Parameter. Default value: localhost -->
<localBGPAddress>0.0.0.0</localBGPAddress>
</config>
File added
File added
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<config>
<PCEServerPort>4189</PCEServerPort>
<PCEManagementPort>6666</PCEManagementPort>
<!--<LocalPCEAddress>192.168.1.200</LocalPCEAddress>-->
<!-- <LocalPCEAddress>127.0.0.1</LocalPCEAddress> -->
<!-- <LocalPCEAddress>192.168.165.172</LocalPCEAddress> -->
<!-- LocalPCEAddress>192.168.165.88</LocalPCEAddress>-->
<LocalPCEAddress>0.0.0.0</LocalPCEAddress>
<ConnectTimer>
<!-- Connect: the timer (in seconds) started after having initialized a
TCP connection using the PCEP-registered TCP port. The value of
the Connect timer is 60 seconds. -->
60
</ConnectTimer>
<KeepAliveTimer>
30
</KeepAliveTimer>
<DeadTimer>
120
</DeadTimer>
<ConnectMaxRetry>
<!-- ConnectMaxRetry: the maximum number of times the system tries to
establish a TCP connection using the PCEP-registered TCP port
before going back to the Idle state. The value of the
ConnectMaxRetry is 5.-->
5
</ConnectMaxRetry>
<OpenWait>
<!-- OpenWait: the timer that corresponds to the amount of time a PCEP
peer will wait to receive an Open message from the PCEP peer after
the expiration of which the system releases the PCEP resource and
goes back to the Idle state. The OpenWait timer has a fixed value
of 60 seconds.-->
60
</OpenWait>
<KeepWait>
<!-- KeepWait: the timer that corresponds to the amount of time a PCEP
peer will wait to receive a Keepalive or a PCErr message from the
PCEP peer after the expiration of which the system releases the
PCEP resource and goes back to the Idle state. The KeepWait timer
has a fixed value of 60 seconds.-->
</KeepWait>
<parentPCE>
<!-- <parentPCEAddress>10.95.30.29</parentPCEAddress> -->
<!-- <parentPCEAddress>2.2.2.2</parentPCEAddress>-->
<!--<parentPCEAddress>10.95.30.29</parentPCEAddress> -->
<!--<parentPCEAddress>10.95.15.126</parentPCEAddress>-->
<!-- <parentPCEPort>4172</parentPCEPort> -->
</parentPCE>
<!-- Ficheros log (servidor, protocolo PCEP y OSPF). Campos opcionales -->
<PCEServerLogFile>PCEServer.log</PCEServerLogFile>
<PCEPParserLogFile>PCEPParserServer.log</PCEPParserLogFile>
<OSPFParserLogFile>OSPFParser.log</OSPFParserLogFile>
<isStateful>true</isStateful>
<isActive>true</isActive>
<PCCRequestsProcessors>1</PCCRequestsProcessors>
<ParentPCERequestProcessors>1</ParentPCERequestProcessors>
<!--<networkDescriptionFile>networks\Network_8_nodes.xml</networkDescriptionFile>-->
<!--<networkDescriptionFile>networks\network_NSFNet.xml</networkDescriptionFile>-->
<!--<networkDescriptionFile>/usr/local/nodeConfig/topologia.xml</networkDescriptionFile>-->
<networkDescriptionFile>topologia_ifusion.xml</networkDescriptionFile>
<actingAsBGP4Peer>false</actingAsBGP4Peer>
<BGP4File>BGP4Parameters_2.xml</BGP4File>
<initialSessionID>1000</initialSessionID>
<nodelay>true</nodelay>
<reservation>false</reservation>
<optimizedRead>false</optimizedRead>
<analyzeRequestTime>true</analyzeRequestTime>
<multilayer>false</multilayer>
<setTraces>true</setTraces>
<!--OSPF>
<OSPFSession>true</OSPFSession>
<OSPFListenerIP>192.168.1.200</OSPFListenerIP>
<OSPFMulticast>true</OSPFMulticast>
<OSPFUnicast>false</OSPFUnicast>
<OSPFTCPSession>false</OSPFTCPSession>
<OSPFTCPPort>7762</OSPFTCPPort>
</OSPF-->
<!--WSON NETWORK-->
<!--<layer type="gmpls" default="true" encodingType="1" switchingType="150">77</layer>-->
<layer type="mpls" default="true" ></layer>
<!--<algorithmRule of="0" svec="false" name="mpls.MPLS_MinTH_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="false"/>-->
<!--<algorithmRule of="1000" svec="false" name="wson.SP_FF_RWA_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<<algorithmRule of="1002" svec="false" name="sson.AURE_SSON_algorithm" isParentPCEAlgorithm="false" isSSONAlgorithm="true"/>-->
<!--<algorithmRule of="998" svec="true" name="wson.svec.SVEC_SP_FF_WSON_PathComputing" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="1100" svec="false" name="multiLayer.Multilayer_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="900" svec="false" name="wson.KSPprecomp_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="1001" svec="false" name="wson.AURE_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="901" svec="false" name="wson.AURE_PACK_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="903" svec="false" name="wson.AURE_RANDOM_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="902" svec="false" name="wson.AURE_SPREAD_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="800" svec="false" name="wson.KSP_FF_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="801" svec="false" name="wson.KSP_PACK_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="803" svec="false" name="wson.KSP_RANDOM_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="802" svec="false" name="wson.KSP_SPREAD_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="900" svec="false" name="wson.AURE_FF_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="1001" svec="false" name="wson.AURE_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="false"/>-->
<!--<algorithmRule of="999" svec="true" name="CPLEXOptimizedPathComputing" isParentPCEAlgorithm="false" isWSONAlgorithm="false"/>-->
<!-- <layer type="mpls" default="true"/>-->
<!--<layer type="mpls" default="true"/>-->
</config>
"/home/ubuntu/downloads/apache-maven-3.8.8/bin/mvn" clean package -P pcep assembly:single -DskipTests=True -f "/home/ubuntu/tfs-ctrl/src/pcep/service/resources/java/netphony-pce/pom.xml"
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="BGP4Peer" level="trace" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Root level="DEBUG">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<network>
<domain>
<layer type="mpls" ></layer>
<domain_id>0.0.0.1</domain_id>
<reachability_entry>
<ipv4_address>1.1.1.0</ipv4_address>
<prefix>12</prefix>
</reachability_entry>
<node>
<router_id>1.1.1.1</router_id>
</node>
<node>
<router_id>1.1.1.2</router_id>
</node>
<node>
<router_id>1.1.1.3</router_id>
</node>
<!-- 1 al 2 -->
<edge type="intradomain">
<source>
<router_id>1.1.1.1</router_id>
<NumIf_id>192.168.1.11</NumIf_id>
</source>
<destination>
<router_id>1.1.1.2</router_id>
<NumIf_id>192.168.1.12</NumIf_id>
</destination>
<delay>
3.13
</delay>
<maximum_bandwidth>
100
</maximum_bandwidth>
<unreserved_bandwidth priority="0">
100
</unreserved_bandwidth>
</edge>
<edge type="intradomain">
<source>
<router_id>1.1.1.1</router_id>
<NumIf_id>192.168.3.11</NumIf_id>
</source>
<destination>
<router_id>1.1.1.3</router_id>
<NumIf_id>192.168.3.13</NumIf_id>
</destination>
<delay>
3.13
</delay>
<maximum_bandwidth>
100
</maximum_bandwidth>
<unreserved_bandwidth priority="0">
100
</unreserved_bandwidth>
</edge>
<edge type="intradomain">
<source>
<router_id>1.1.1.3</router_id>
<NumIf_id>192.168.2.13</NumIf_id>
</source>
<destination>
<router_id>1.1.1.2</router_id>
<NumIf_id>192.168.2.12</NumIf_id>
</destination>
<delay>
3.13
</delay>
<maximum_bandwidth>
100
</maximum_bandwidth>
<unreserved_bandwidth priority="0">
100
</unreserved_bandwidth>
</edge>
</domain>
</network>
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging,threading, queue
import logging,threading
import grpc
import logging
from .JavaRunner import JavaRunner
LOGGER = logging.getLogger(__name__)
#_ONE_DAY_IN_SECONDS = 60 * 60 * 24
#SERVER_ADDRESS = 'localhost:2021'
class GrpcServer():
def __init__(self) -> None: # pylint: disable=super-init-not-called
self.__lock = threading.Lock()
self.__started = threading.Event()
self.__terminate = threading.Event()
self.__out_samples = queue.Queue()
self.__server=grpc.aio.server()
self.__runnerList=[]
def connectToJavaPcep(self, address):
runner = JavaRunner(address)
# Sets IpAddress in XML config file for java program
runner.setPeer(address)
process_thread = threading.Thread(target=runner.execPcep)
process_thread.start()
self.__runnerList.append(runner)
return process_thread
'''
def ConnectThread(self) -> bool:
# TODO: Metodos necesarios para conectarte al speaker
# If started, assume it is already connected
if self.__started.is_set(): return True
self.__started.set()
self.__server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
grpcService_pb2_grpc.add_pceServiceServicer_to_server(self, self.__server)
self.__server.add_insecure_port(SERVER_ADDRESS)
LOGGER.info("Starting server on %s", SERVER_ADDRESS)
self.__server.start()
try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
except KeyboardInterrupt:
LOGGER.info("DISCONNECT")
self.Disconnect()
return True
def Connect(self):
grpcThread = threading.Thread(target=self.ConnectThread)
grpcThread.start()
LOGGER.info("Calling the JavaRunner")
return True
def Disconnect(self) -> bool:
self.__terminate.set()
# If not started, assume it is already disconnected
if not self.__started.is_set(): return True
LOGGER.info("Keyboard interrupt, stop server")
self.__server.stop(0)
# Disconnect triggers deactivation of sampling events
# self.__scheduler.shutdown()
# exit(0)
return True
def update():
with grpc.insecure_channel('localhost:10060') as channel:
#n = "initiate lsp directo 10.95.90.56 1.1.1.1 1.1.1.3 m1228800 na192.168.3.11-192.168.3.13"
n = "terminate lsp 10.95.90.56 0 nombre"
#n="create candidatepath 10.95.90.56 1.1.1.1 4 97 m69644288 nn1.1.1.3 m69640192 nn1.1.1.2"
stub = grpcService_pb2_grpc.pceServiceStub(channel)
request = grpcService_pb2.commandRequest(command=n)
print("updateService req: " ,request)
response = stub.update(request)
print("updateService client received: " ,response.commandResp)
def requestToJavaPcep(self,message):
with grpc.insecure_channel('localhost:10060') as channel:
#n = "initiate lsp largo2 10.95.90.56 1.1.1.1 1.1.1.2 m69644288 nn1.1.1.3 m69640192 nn1.1.1.2"
#n = "initiate lsp directo 10.95.90.56 1.1.1.1 1.1.1.3 m1228800 na192.168.3.11-192.168.3.13"
LOGGER.debug("LLego al request")
stub = grpcService_pb2_grpc.pceServiceStub(channel)
LOGGER.debug("updateService req 2: %s" ,message)
request = grpcService_pb2.commandRequest(command=message)
LOGGER.debug("updateService req 2: %s" ,request)
response = stub.update(request)
LOGGER.debug("updateServide client received: %s" ,response.commandResp)
LOGGER.debug("updateServide client received IP: %s" ,response.ipAddress)
return response.ipAddress
def terminateRunners(self):
for runner in self.__runnerList:
runner.endBGPSpeaker()
return True
def terminateGrpcServer(self):
LOGGER.debug("Terminating java programs...")
self.terminateRunners()
LOGGER.debug("Disconnecting grpc server...")
self.Disconnect()
return True
def terminateRunnerById(self,speaker_id):
"""
Disconnect from BGP-LS speaker given an speaker Id. Its the same
as the java running proccess PID.
"""
for runner in self.__runnerList:
if(runner.getPid()==speaker_id):
runner.endBGPSpeaker()
self.__runnerList.remove(runner)
return True
'''
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import grpc, logging
from common.Constants import ServiceNameEnum
from common.Settings import get_service_host, get_service_port_grpc
from common.tools.client.RetryDecorator import retry, delay_exponential
from pcep.service.tools.Grpc_TestClient.grpcService_pb2 import LSPdb_Request, Session_Request
from pcep.service.tools.Grpc_TestClient.grpcService_pb2 import commandRequest
from pcep.service.tools.Grpc_TestClient.grpcService_pb2_grpc import pceServiceStub
LOGGER = logging.getLogger(__name__)
MAX_RETRIES = 15
DELAY_FUNCTION = delay_exponential(initial=0.01, increment=2.0, maximum=5.0)
RETRY_DECORATOR = retry(max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')
PORT = 10060
class GrpcPcepClient:
def __init__(self, host=None, port=None):
if not host: host = get_service_host(ServiceNameEnum.PCEP)
#if not port: port = get_service_port_grpc(ServiceNameEnum.PCEP)
if not port: port = PORT #Maybe should not be hardcoded
self.endpoint = '{:s}:{:s}'.format(str(host), str(port))
LOGGER.warning('Creating channel to {:s}...'.format(str(self.endpoint)))
self.channel = None
self.stub = None
self.connect()
LOGGER.warning('Channel created')
def connect(self):
#LOGGER.warning('IAM IN CONNECT')
LOGGER.warning('Creating channel to {:s}...'.format(str(self.endpoint)))
self.channel = grpc.insecure_channel(self.endpoint)
self.stub = pceServiceStub(self.channel)
LOGGER.warning('Channel created')
def close(self):
#LOGGER.warning('IAM IN CLOSE')
if self.channel is not None: self.channel.close()
self.channel = None
self.stub = None
@RETRY_DECORATOR
def showSessions(self):
requestsessions = Session_Request()
responsesessions = self.stub.getSessionsInfo(requestsessions)
LOGGER.warning("IAM IN SHOWSESSIONS: {:s}".format(str(responsesessions)))
return responsesessions
@RETRY_DECORATOR
def showLSPDB(self):
#LOGGER.warning("IAM IN SHOWLSPDB")
requestlsp = LSPdb_Request()
responselsp = self.stub.getLSPdb(requestlsp)
return responselsp
@RETRY_DECORATOR
def sendUpdate(self, data):
#LOGGER.warning("IAM IN SEND UPDATE")
commandrequest = commandRequest() # Create an instance without passing data to __init__
commandrequest.command = data
#LOGGER.warning("This is Command Request: %s", str(commandrequest))
commandresponse = self.stub.update(commandrequest)
#LOGGER.warning("This is Command Response: %s", str(commandresponse))
#LOGGER.warning("Success: %s", str(commandresponse.success))
#LOGGER.warning("Error Message: %s", str(commandresponse.error_message))
return commandresponse
// Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package src.main.proto;
//el modulo python abre la comunicacion
//el servidor java responde con un ACK (En caso de que se haya mandado un comando) o con la informacion de la LSPDB (En caso de peticion de LSPDB)
// Command request from the client
message commandRequest{
string command = 1;
}
// Response after a Command Request (If bad request show error log)
message commandResponse{
bool success = 1;
string error_message = 2;
}
// LSP database request from the client
message LSPdb_Request{
}
// Response containing LSP database information
message LSPdb_Response{
string LSPdb_data = 2;
}
// Active PCEP sessions request from the client
message Session_Request{
}
// Response containing LSP database information
message Session_Response{
string Session_data = 2;
}
// Defining a Service, a Service can have multiple RPC operations
service pceService {
// RPC method for command execution
rpc update(commandRequest) returns (commandResponse);
// RPC method for retrieving LSP database
rpc getLSPdb(LSPdb_Request) returns (LSPdb_Response);
// RPC method for retrieving LSP database
rpc getSessionsInfo(Session_Request) returns (Session_Response);
}
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: grpcService.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11grpcService.proto\x12\x0esrc.main.proto\"!\n\x0e\x63ommandRequest\x12\x0f\n\x07\x63ommand\x18\x01 \x01(\t\"9\n\x0f\x63ommandResponse\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x15\n\rerror_message\x18\x02 \x01(\t\"\x0f\n\rLSPdb_Request\"$\n\x0eLSPdb_Response\x12\x12\n\nLSPdb_data\x18\x02 \x01(\t\"\x11\n\x0fSession_Request\"(\n\x10Session_Response\x12\x14\n\x0cSession_data\x18\x02 \x01(\t2\xf8\x01\n\npceService\x12I\n\x06update\x12\x1e.src.main.proto.commandRequest\x1a\x1f.src.main.proto.commandResponse\x12I\n\x08getLSPdb\x12\x1d.src.main.proto.LSPdb_Request\x1a\x1e.src.main.proto.LSPdb_Response\x12T\n\x0fgetSessionsInfo\x12\x1f.src.main.proto.Session_Request\x1a .src.main.proto.Session_Responseb\x06proto3')
_COMMANDREQUEST = DESCRIPTOR.message_types_by_name['commandRequest']
_COMMANDRESPONSE = DESCRIPTOR.message_types_by_name['commandResponse']
_LSPDB_REQUEST = DESCRIPTOR.message_types_by_name['LSPdb_Request']
_LSPDB_RESPONSE = DESCRIPTOR.message_types_by_name['LSPdb_Response']
_SESSION_REQUEST = DESCRIPTOR.message_types_by_name['Session_Request']
_SESSION_RESPONSE = DESCRIPTOR.message_types_by_name['Session_Response']
commandRequest = _reflection.GeneratedProtocolMessageType('commandRequest', (_message.Message,), {
'DESCRIPTOR' : _COMMANDREQUEST,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.commandRequest)
})
_sym_db.RegisterMessage(commandRequest)
commandResponse = _reflection.GeneratedProtocolMessageType('commandResponse', (_message.Message,), {
'DESCRIPTOR' : _COMMANDRESPONSE,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.commandResponse)
})
_sym_db.RegisterMessage(commandResponse)
LSPdb_Request = _reflection.GeneratedProtocolMessageType('LSPdb_Request', (_message.Message,), {
'DESCRIPTOR' : _LSPDB_REQUEST,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.LSPdb_Request)
})
_sym_db.RegisterMessage(LSPdb_Request)
LSPdb_Response = _reflection.GeneratedProtocolMessageType('LSPdb_Response', (_message.Message,), {
'DESCRIPTOR' : _LSPDB_RESPONSE,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.LSPdb_Response)
})
_sym_db.RegisterMessage(LSPdb_Response)
Session_Request = _reflection.GeneratedProtocolMessageType('Session_Request', (_message.Message,), {
'DESCRIPTOR' : _SESSION_REQUEST,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.Session_Request)
})
_sym_db.RegisterMessage(Session_Request)
Session_Response = _reflection.GeneratedProtocolMessageType('Session_Response', (_message.Message,), {
'DESCRIPTOR' : _SESSION_RESPONSE,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.Session_Response)
})
_sym_db.RegisterMessage(Session_Response)
_PCESERVICE = DESCRIPTOR.services_by_name['pceService']
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
_COMMANDREQUEST._serialized_start=37
_COMMANDREQUEST._serialized_end=70
_COMMANDRESPONSE._serialized_start=72
_COMMANDRESPONSE._serialized_end=129
_LSPDB_REQUEST._serialized_start=131
_LSPDB_REQUEST._serialized_end=146
_LSPDB_RESPONSE._serialized_start=148
_LSPDB_RESPONSE._serialized_end=184
_SESSION_REQUEST._serialized_start=186
_SESSION_REQUEST._serialized_end=203
_SESSION_RESPONSE._serialized_start=205
_SESSION_RESPONSE._serialized_end=245
_PCESERVICE._serialized_start=248
_PCESERVICE._serialized_end=496
# @@protoc_insertion_point(module_scope)
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
import pcep.service.tools.Grpc_TestClient.grpcService_pb2 as grpcService__pb2
#import grpcService_pb2 as grpcService__pb2
class pceServiceStub(object):
"""Defining a Service, a Service can have multiple RPC operations"""
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.update = channel.unary_unary(
'/src.main.proto.pceService/update',
request_serializer=grpcService__pb2.commandRequest.SerializeToString,
response_deserializer=grpcService__pb2.commandResponse.FromString,
)
self.getLSPdb = channel.unary_unary(
'/src.main.proto.pceService/getLSPdb',
request_serializer=grpcService__pb2.LSPdb_Request.SerializeToString,
response_deserializer=grpcService__pb2.LSPdb_Response.FromString,
)
self.getSessionsInfo = channel.unary_unary(
'/src.main.proto.pceService/getSessionsInfo',
request_serializer=grpcService__pb2.Session_Request.SerializeToString,
response_deserializer=grpcService__pb2.Session_Response.FromString,
)
class pceServiceServicer(object):
"""Defining a Service, a Service can have multiple RPC operations"""
def update(self, request, context):
"""RPC method for command execution"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def getLSPdb(self, request, context):
"""RPC method for retrieving LSP database"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def getSessionsInfo(self, request, context):
"""RPC method for retrieving LSP database"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_pceServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'update': grpc.unary_unary_rpc_method_handler(
servicer.update,
request_deserializer=grpcService__pb2.commandRequest.FromString,
response_serializer=grpcService__pb2.commandResponse.SerializeToString,
),
'getLSPdb': grpc.unary_unary_rpc_method_handler(
servicer.getLSPdb,
request_deserializer=grpcService__pb2.LSPdb_Request.FromString,
response_serializer=grpcService__pb2.LSPdb_Response.SerializeToString,
),
'getSessionsInfo': grpc.unary_unary_rpc_method_handler(
servicer.getSessionsInfo,
request_deserializer=grpcService__pb2.Session_Request.FromString,
response_serializer=grpcService__pb2.Session_Response.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'src.main.proto.pceService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
# This class is part of an EXPERIMENTAL API.
class pceService(object):
"""Defining a Service, a Service can have multiple RPC operations"""
@staticmethod
def update(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/src.main.proto.pceService/update',
grpcService__pb2.commandRequest.SerializeToString,
grpcService__pb2.commandResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def getLSPdb(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/src.main.proto.pceService/getLSPdb',
grpcService__pb2.LSPdb_Request.SerializeToString,
grpcService__pb2.LSPdb_Response.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def getSessionsInfo(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/src.main.proto.pceService/getSessionsInfo',
grpcService__pb2.Session_Request.SerializeToString,
grpcService__pb2.Session_Response.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import grpc
import logging
from grpcService_pb2 import LSPdb_Request, Session_Request
from grpcService_pb2_grpc import pceServiceStub
def run():
# Create a gRPC channel
channel = grpc.insecure_channel('10.1.114.109:10060')
# channel = grpc.insecure_channel('localhost:10060')
# Create a gRPC stub
stub = pceServiceStub(channel)
'''
#LSPDB
# Construct a request (LSPDB Request)
requestlsp = LSPdb_Request()
# Make the gRPC call
responselsp = stub.getLSPdb(requestlsp)
# Print the received response
print("\nRESPUESTA RECIBIDA")
print(responselsp)
'''
# Construct a request (Session Request)
sessionrequest = Session_Request()
# Make the gRPC call
sessionresponse = stub.getSessionsInfo(sessionrequest)
# Print the received response
print("\nRESPUESTA RECIBIDA")
print(sessionresponse)
if __name__ == '__main__':
logging.basicConfig()
run()
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging,threading, time
import logging
from lxml import etree
import os
import subprocess
XML_CONFIG_FILE="/var/teraflow/pcep/service/resources/PCEServerConfiguration.xml"
LOGGER = logging.getLogger(__name__)
class JavaRunner:
def __init__(self,address):
self.__process=None
self.__lock = threading.Lock()
self.__address = address
def getCurrentLocalPort(self):
with self.__lock:
return self.__localPort
def getCurrentMngPort(self):
with self.__lock:
return self.__managementPort
def getPid(self):
return self.__process.pid
def execAndKill(self):
LOGGER.debug("Before exec and kill")
os.chdir("/var/teraflow/pcep/service/resources/")
cwd = os.getcwd()
LOGGER.info("Current working directory: %s", cwd)
# Security shell=False
self.__process=subprocess.Popen(['java -jar PCE-jar-with-dependencies.jar '],#+ XML_CONFIG_FILE
shell=False,start_new_session=True,stdout=subprocess.PIPE)
LOGGER.debug("Time to sleep")
java_pid = self.__process.pid
print("Java PID:", java_pid)
time.sleep(15)
self.__process.terminate()
def execPcep(self) -> bool:
"""
Executes java pcep in non-blocking process
"""
LOGGER.debug("Executing JavaRunner")
os.chdir("/var/teraflow/pcep/service/resources/")
try:
#self.__process = subprocess.Popen(['java', '-jar', 'Ejecutable_2.jar'],
# shell=False, start_new_session=True,
# stdout=subprocess.PIPE, stderr=subprocess.PIPE)
LOGGER.debug("Executing command: %s", ('java', '-Dlog4j.configurationFile=log4j2.xml', '-jar', 'PCE-jar-with-dependencies.jar', 'PCEServerConfiguration.xml'))
self.__process = subprocess.Popen(['java', '-Dlog4j.configurationFile=log4j2.xml', '-jar', 'PCE-jar-with-dependencies.jar', 'PCEServerConfiguration.xml'],
shell=False, start_new_session=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout_thread = threading.Thread(target=self.read_stdout)
stderr_thread = threading.Thread(target=self.read_stderr)
stdout_thread.start()
stderr_thread.start()
self.__process.wait()
stdout_thread.join()
stderr_thread.join()
except subprocess.CalledProcessError as err:
LOGGER.debug('ERROR: %s', err)
return self.__process
def read_stdout(self):
try:
for line in iter(self.__process.stdout.readline, b''):
print(f"STDOUT: {line.decode('utf-8')}", flush=True)
except Exception as e:
print(f"Error in read_stdout: {e}")
def read_stderr(self):
try:
for line in iter(self.__process.stderr.readline, b''):
print(f"STDERR: {line.decode('utf-8')}", flush=True)
except Exception as e:
print(f"Error in read_stderr: {e}")
def setPort(self,port):
self.__peerPort=port
return True
def setAsNumber(self,asNumber):
self.__asNumber=asNumber
return True
def setPeer(self, address) -> bool:
"""
Sets XML existing config file with peer address and port. TODO: as_number
"""
XMLParser = etree.XMLParser(remove_blank_text=False)
tree = etree.parse(XML_CONFIG_FILE, parser=XMLParser)
root = tree.getroot()
# Find the <LocalPCEAddress> element
pceAddress = root.find(".//LocalPCEAddress")
#Check if the element is found
if pceAddress is not None:
LOGGER.debug("Old LocalPCEAddress value: %s", pceAddress.text)
# Update the text content of the element with the new address
pceAddress.text = str(address)
LOGGER.debug("New LocalPCEAddress value: %s", pceAddress.text)
# Save the modified XML back to the file
tree.write(XML_CONFIG_FILE, pretty_print=True)
return True # Return True to indicate success
return False # Return False if the element is not found
#return True
def endBGPSpeaker(self) -> bool:
"""
Kills java program connected to BGPLS Speaker with SIGKILL signal
"""
LOGGER.debug("sending kill signal to process %s",self.__process.pid)
LOGGER.debug("PID: %d",self.__process.pid)
self.__process.kill()
return True
def getRunnerInfo(self):
return self.__address,self.__asNumber,self.__peerPort
<?xml version="1.0" encoding="UTF-8"?>
<config>
<PCEServerPort>4189</PCEServerPort>
<PCEManagementPort>6666</PCEManagementPort>
<!--<LocalPCEAddress>192.168.1.200</LocalPCEAddress>-->
<!--<LocalPCEAddress>10.95.40.175</LocalPCEAddress>-->
<!--<LocalPCEAddress>127.0.0.1</LocalPCEAddress>-->
<LocalPCEAddress>10.95.43.150</LocalPCEAddress>
<ConnectTimer>
<!-- Connect: the timer (in seconds) started after having initialized a
TCP connection using the PCEP-registered TCP port. The value of
the Connect timer is 60 seconds. -->
60
</ConnectTimer>
<KeepAliveTimer>
30
</KeepAliveTimer>
<DeadTimer>
120
</DeadTimer>
<ConnectMaxRetry>
<!-- ConnectMaxRetry: the maximum number of times the system tries to
establish a TCP connection using the PCEP-registered TCP port
before going back to the Idle state. The value of the
ConnectMaxRetry is 5.-->
5
</ConnectMaxRetry>
<OpenWait>
<!-- OpenWait: the timer that corresponds to the amount of time a PCEP
peer will wait to receive an Open message from the PCEP peer after
the expiration of which the system releases the PCEP resource and
goes back to the Idle state. The OpenWait timer has a fixed value
of 60 seconds.-->
60
</OpenWait>
<KeepWait>
<!-- KeepWait: the timer that corresponds to the amount of time a PCEP
peer will wait to receive a Keepalive or a PCErr message from the
PCEP peer after the expiration of which the system releases the
PCEP resource and goes back to the Idle state. The KeepWait timer
has a fixed value of 60 seconds.-->
</KeepWait>
<parentPCE>
<!-- <parentPCEAddress>10.95.30.29</parentPCEAddress> -->
<!-- <parentPCEAddress>2.2.2.2</parentPCEAddress>-->
<!--<parentPCEAddress>10.95.30.29</parentPCEAddress> -->
<!--<parentPCEAddress>10.95.15.126</parentPCEAddress>-->
<!-- <parentPCEPort>4172</parentPCEPort> -->
</parentPCE>
<!-- Ficheros log (servidor, protocolo PCEP y OSPF). Campos opcionales -->
<PCEServerLogFile>PCEServer.log</PCEServerLogFile>
<PCEPParserLogFile>PCEPParserServer.log</PCEPParserLogFile>
<OSPFParserLogFile>OSPFParser.log</OSPFParserLogFile>
<isStateful>true</isStateful>
<isActive>true</isActive>
<PCCRequestsProcessors>1</PCCRequestsProcessors>
<ParentPCERequestProcessors>1</ParentPCERequestProcessors>
<!--<networkDescriptionFile>networks\Network_8_nodes.xml</networkDescriptionFile>-->
<!--<networkDescriptionFile>networks\network_NSFNet.xml</networkDescriptionFile>-->
<!--<networkDescriptionFile>/usr/local/nodeConfig/topologia.xml</networkDescriptionFile>-->
<networkDescriptionFile>topologia_ifusion.xml</networkDescriptionFile>
<actingAsBGP4Peer>false</actingAsBGP4Peer>
<BGP4File>BGP4Parameters_2.xml</BGP4File>
<initialSessionID>1000</initialSessionID>
<nodelay>true</nodelay>
<reservation>false</reservation>
<optimizedRead>false</optimizedRead>
<analyzeRequestTime>true</analyzeRequestTime>
<multilayer>false</multilayer>
<setTraces>true</setTraces>
<!--OSPF>
<OSPFSession>true</OSPFSession>
<OSPFListenerIP>192.168.1.200</OSPFListenerIP>
<OSPFMulticast>true</OSPFMulticast>
<OSPFUnicast>false</OSPFUnicast>
<OSPFTCPSession>false</OSPFTCPSession>
<OSPFTCPPort>7762</OSPFTCPPort>
</OSPF-->
<!--WSON NETWORK-->
<!--<layer type="gmpls" default="true" encodingType="1" switchingType="150">77</layer>-->
<layer type="mpls" default="true" ></layer>
<!--<algorithmRule of="0" svec="false" name="mpls.MPLS_MinTH_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="false"/>-->
<!--<algorithmRule of="1000" svec="false" name="wson.SP_FF_RWA_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<<algorithmRule of="1002" svec="false" name="sson.AURE_SSON_algorithm" isParentPCEAlgorithm="false" isSSONAlgorithm="true"/>-->
<!--<algorithmRule of="998" svec="true" name="wson.svec.SVEC_SP_FF_WSON_PathComputing" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="1100" svec="false" name="multiLayer.Multilayer_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="900" svec="false" name="wson.KSPprecomp_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="1001" svec="false" name="wson.AURE_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="901" svec="false" name="wson.AURE_PACK_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="903" svec="false" name="wson.AURE_RANDOM_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="902" svec="false" name="wson.AURE_SPREAD_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="800" svec="false" name="wson.KSP_FF_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="801" svec="false" name="wson.KSP_PACK_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="803" svec="false" name="wson.KSP_RANDOM_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="802" svec="false" name="wson.KSP_SPREAD_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="900" svec="false" name="wson.AURE_FF_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="true"/>-->
<!--<algorithmRule of="1001" svec="false" name="wson.AURE_Algorithm" isParentPCEAlgorithm="false" isWSONAlgorithm="false"/>-->
<!--<algorithmRule of="999" svec="true" name="CPLEXOptimizedPathComputing" isParentPCEAlgorithm="false" isWSONAlgorithm="false"/>-->
<!-- <layer type="mpls" default="true"/>-->
<!--<layer type="mpls" default="true"/>-->
</config>
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
syntax = "proto3";
package src.main.proto;
// Command request from the client
message commandRequest{
string command = 1;
}
// Empty response for command execution acknowledgment
message commandResponse{
}
// LSP database request from the client
message LSPdb_Request{
}
// Response containing LSP database information
message LSPdb_Response{
string LSPdb_data = 2;
}
// Defining a Service, a Service can have multiple RPC operations
service pceService {
// RPC method for command execution
rpc update(commandRequest) returns (commandResponse);
// RPC method for retrieving LSP database
rpc getLSPdb(LSPdb_Request) returns (LSPdb_Response);
}
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: grpcService.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x11grpcService.proto\x12\x0esrc.main.proto\"!\n\x0e\x63ommandRequest\x12\x0f\n\x07\x63ommand\x18\x01 \x01(\t\"\x11\n\x0f\x63ommandResponse\"\x0f\n\rLSPdb_Request\"$\n\x0eLSPdb_Response\x12\x12\n\nLSPdb_data\x18\x02 \x01(\t2\xa2\x01\n\npceService\x12I\n\x06update\x12\x1e.src.main.proto.commandRequest\x1a\x1f.src.main.proto.commandResponse\x12I\n\x08getLSPdb\x12\x1d.src.main.proto.LSPdb_Request\x1a\x1e.src.main.proto.LSPdb_Responseb\x06proto3')
_COMMANDREQUEST = DESCRIPTOR.message_types_by_name['commandRequest']
_COMMANDRESPONSE = DESCRIPTOR.message_types_by_name['commandResponse']
_LSPDB_REQUEST = DESCRIPTOR.message_types_by_name['LSPdb_Request']
_LSPDB_RESPONSE = DESCRIPTOR.message_types_by_name['LSPdb_Response']
commandRequest = _reflection.GeneratedProtocolMessageType('commandRequest', (_message.Message,), {
'DESCRIPTOR' : _COMMANDREQUEST,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.commandRequest)
})
_sym_db.RegisterMessage(commandRequest)
commandResponse = _reflection.GeneratedProtocolMessageType('commandResponse', (_message.Message,), {
'DESCRIPTOR' : _COMMANDRESPONSE,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.commandResponse)
})
_sym_db.RegisterMessage(commandResponse)
LSPdb_Request = _reflection.GeneratedProtocolMessageType('LSPdb_Request', (_message.Message,), {
'DESCRIPTOR' : _LSPDB_REQUEST,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.LSPdb_Request)
})
_sym_db.RegisterMessage(LSPdb_Request)
LSPdb_Response = _reflection.GeneratedProtocolMessageType('LSPdb_Response', (_message.Message,), {
'DESCRIPTOR' : _LSPDB_RESPONSE,
'__module__' : 'grpcService_pb2'
# @@protoc_insertion_point(class_scope:src.main.proto.LSPdb_Response)
})
_sym_db.RegisterMessage(LSPdb_Response)
_PCESERVICE = DESCRIPTOR.services_by_name['pceService']
if _descriptor._USE_C_DESCRIPTORS == False:
DESCRIPTOR._options = None
_COMMANDREQUEST._serialized_start=37
_COMMANDREQUEST._serialized_end=70
_COMMANDRESPONSE._serialized_start=72
_COMMANDRESPONSE._serialized_end=89
_LSPDB_REQUEST._serialized_start=91
_LSPDB_REQUEST._serialized_end=106
_LSPDB_RESPONSE._serialized_start=108
_LSPDB_RESPONSE._serialized_end=144
_PCESERVICE._serialized_start=147
_PCESERVICE._serialized_end=309
# @@protoc_insertion_point(module_scope)
# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/)
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
from . import grpcService_pb2 as grpcService__pb2
class pceServiceStub(object):
"""Defining a Service, a Service can have multiple RPC operation"""
def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.update = channel.unary_unary(
'/src.main.proto.pceService/update',
request_serializer=grpcService__pb2.commandRequest.SerializeToString,
response_deserializer=grpcService__pb2.commandResponse.FromString,
)
self.getLSPdb = channel.unary_unary(
'/src.main.proto.pceService/getLSPdb',
request_serializer=grpcService__pb2.LSPdb_Request.SerializeToString,
response_deserializer=grpcService__pb2.LSPdb_Response.FromString,
)
class pceServiceServicer(object):
"""Defining a Service, a Service can have multiple RPC operations"""
def update(self, request, context):
"""RPC method for command execution"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def getLSPdb(self, request, context):
"""RPC method for retrieving LSP database"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def add_pceServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'update': grpc.unary_unary_rpc_method_handler(
servicer.update,
request_deserializer=grpcService__pb2.commandRequest.FromString,
response_serializer=grpcService__pb2.commandResponse.SerializeToString,
),
'getLSPdb': grpc.unary_unary_rpc_method_handler(
servicer.getLSPdb,
request_deserializer=grpcService__pb2.LSPdb_Request.FromString,
response_serializer=grpcService__pb2.LSPdb_Response.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'src.main.proto.pceService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
# This class is part of an EXPERIMENTAL API.
class pceService(object):
"""Defining a Service, a Service can have multiple RPC operations"""
@staticmethod
def update(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/src.main.proto.pceService/update',
grpcService__pb2.commandRequest.SerializeToString,
grpcService__pb2.commandResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def getLSPdb(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/src.main.proto.pceService/getLSPdb',
grpcService__pb2.LSPdb_Request.SerializeToString,
grpcService__pb2.LSPdb_Response.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
# Add here your files containing confidential testbed details such as IP addresses, ports, usernames, passwords, etc.