Commit afa196d7 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Defined/Corrected skeleton for Slice component

parent eaee6c8c
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -7,11 +7,12 @@ from slice.proto.slice_pb2_grpc import SliceServiceStub
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')

class SliceClient:
    def __init__(self, address, port):
        self.endpoint = '{}:{}'.format(address, port)
        LOGGER.debug('Creating channel to {}...'.format(self.endpoint))
        self.endpoint = '{:s}:{:s}'.format(str(address), str(port))
        LOGGER.debug('Creating channel to {:s}...'.format(self.endpoint))
        self.channel = None
        self.stub = None
        self.connect()
@@ -26,16 +27,16 @@ class SliceClient:
        self.channel = None
        self.stub = None

    @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')
    @RETRY_DECORATOR
    def CreateUpdateSlice(self, request : TransportSlice) -> SliceStatus:
        LOGGER.debug('CreateUpdateSlice request: {}'.format(request))
        LOGGER.debug('CreateUpdateSlice request: {:s}'.format(str(request)))
        response = self.stub.CreateUpdateSlice(request)
        LOGGER.debug('CreateUpdateSlice result: {}'.format(response))
        LOGGER.debug('CreateUpdateSlice result: {:s}'.format(str(response)))
        return response

    @retry(exceptions=set(), max_retries=MAX_RETRIES, delay_function=DELAY_FUNCTION, prepare_method_name='connect')
    @RETRY_DECORATOR
    def DeleteSlice(self, request : TransportSlice) -> Empty:
        LOGGER.debug('DeleteSlice request: {}'.format(request))
        LOGGER.debug('DeleteSlice request: {:s}'.format(str(request)))
        response = self.stub.DeleteSlice(request)
        LOGGER.debug('DeleteSlice result: {}'.format(response))
        LOGGER.debug('DeleteSlice result: {:s}'.format(str(response)))
        return response
+2045 −263

File changed.

Preview size limit exceeded, changes collapsed.

+78 −0
Original line number Diff line number Diff line
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: kpi_sample_types.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
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.FileDescriptor(
  name='kpi_sample_types.proto',
  package='kpi_sample_types',
  syntax='proto3',
  serialized_options=None,
  create_key=_descriptor._internal_create_key,
  serialized_pb=b'\n\x16kpi_sample_types.proto\x12\x10kpi_sample_types*\xbe\x01\n\rKpiSampleType\x12\x19\n\x15KPISAMPLETYPE_UNKNOWN\x10\x00\x12%\n!KPISAMPLETYPE_PACKETS_TRANSMITTED\x10\x65\x12\"\n\x1eKPISAMPLETYPE_PACKETS_RECEIVED\x10\x66\x12$\n\x1fKPISAMPLETYPE_BYTES_TRANSMITTED\x10\xc9\x01\x12!\n\x1cKPISAMPLETYPE_BYTES_RECEIVED\x10\xca\x01\x62\x06proto3'
)

_KPISAMPLETYPE = _descriptor.EnumDescriptor(
  name='KpiSampleType',
  full_name='kpi_sample_types.KpiSampleType',
  filename=None,
  file=DESCRIPTOR,
  create_key=_descriptor._internal_create_key,
  values=[
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_UNKNOWN', index=0, number=0,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_PACKETS_TRANSMITTED', index=1, number=101,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_PACKETS_RECEIVED', index=2, number=102,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_BYTES_TRANSMITTED', index=3, number=201,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
    _descriptor.EnumValueDescriptor(
      name='KPISAMPLETYPE_BYTES_RECEIVED', index=4, number=202,
      serialized_options=None,
      type=None,
      create_key=_descriptor._internal_create_key),
  ],
  containing_type=None,
  serialized_options=None,
  serialized_start=45,
  serialized_end=235,
)
_sym_db.RegisterEnumDescriptor(_KPISAMPLETYPE)

KpiSampleType = enum_type_wrapper.EnumTypeWrapper(_KPISAMPLETYPE)
KPISAMPLETYPE_UNKNOWN = 0
KPISAMPLETYPE_PACKETS_TRANSMITTED = 101
KPISAMPLETYPE_PACKETS_RECEIVED = 102
KPISAMPLETYPE_BYTES_TRANSMITTED = 201
KPISAMPLETYPE_BYTES_RECEIVED = 202


DESCRIPTOR.enum_types_by_name['KpiSampleType'] = _KPISAMPLETYPE
_sym_db.RegisterFileDescriptor(DESCRIPTOR)


# @@protoc_insertion_point(module_scope)
+11 −550

File changed.

Preview size limit exceeded, changes collapsed.

+15 −16
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@ _sym_db = _symbol_database.Default()


from . import context_pb2 as context__pb2
from . import service_pb2 as service__pb2


DESCRIPTOR = _descriptor.FileDescriptor(
@@ -22,9 +21,9 @@ DESCRIPTOR = _descriptor.FileDescriptor(
  syntax='proto3',
  serialized_options=None,
  create_key=_descriptor._internal_create_key,
  serialized_pb=b'\n\x0bslice.proto\x12\x05slice\x1a\rcontext.proto\x1a\rservice.proto\"3\n\rSliceEndpoint\x12\"\n\x07port_id\x18\x01 \x01(\x0b\x32\x11.context.EndPoint\"\xf4\x01\n\x0eTransportSlice\x12 \n\x08slice_id\x18\x01 \x01(\x0b\x32\x0e.slice.SliceId\x12\'\n\tendpoints\x18\x02 \x03(\x0b\x32\x14.slice.SliceEndpoint\x12(\n\x0b\x63onstraints\x18\x03 \x03(\x0b\x32\x13.context.Constraint\x12$\n\x08services\x18\x04 \x03(\x0b\x32\x12.service.ServiceId\x12#\n\x0bsubSlicesId\x18\x05 \x03(\x0b\x32\x0e.slice.SliceId\x12\"\n\x06status\x18\x06 \x01(\x0b\x32\x12.slice.SliceStatus\"Q\n\x07SliceId\x12%\n\tcontextId\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x1f\n\x08slice_id\x18\x02 \x01(\x0b\x32\r.context.Uuid\"W\n\x0bSliceStatus\x12 \n\x08slice_id\x18\x01 \x01(\x0b\x32\x0e.slice.SliceId\x12&\n\x06status\x18\x02 \x01(\x0e\x32\x16.slice.SliceStatusEnum*@\n\x0fSliceStatusEnum\x12\x0b\n\x07PLANNED\x10\x00\x12\x08\n\x04INIT\x10\x01\x12\n\n\x06\x41\x43TIVE\x10\x02\x12\n\n\x06\x44\x45INIT\x10\x03\x32\x88\x01\n\x0cSliceService\x12@\n\x11\x43reateUpdateSlice\x12\x15.slice.TransportSlice\x1a\x12.slice.SliceStatus\"\x00\x12\x36\n\x0b\x44\x65leteSlice\x12\x15.slice.TransportSlice\x1a\x0e.context.Empty\"\x00\x62\x06proto3'
  serialized_pb=b'\n\x0bslice.proto\x12\x05slice\x1a\rcontext.proto\"3\n\rSliceEndpoint\x12\"\n\x07port_id\x18\x01 \x01(\x0b\x32\x11.context.EndPoint\"\xf4\x01\n\x0eTransportSlice\x12 \n\x08slice_id\x18\x01 \x01(\x0b\x32\x0e.slice.SliceId\x12\'\n\tendpoints\x18\x02 \x03(\x0b\x32\x14.slice.SliceEndpoint\x12(\n\x0b\x63onstraints\x18\x03 \x03(\x0b\x32\x13.context.Constraint\x12$\n\x08services\x18\x04 \x03(\x0b\x32\x12.context.ServiceId\x12#\n\x0bsubSlicesId\x18\x05 \x03(\x0b\x32\x0e.slice.SliceId\x12\"\n\x06status\x18\x06 \x01(\x0b\x32\x12.slice.SliceStatus\"Q\n\x07SliceId\x12%\n\tcontextId\x18\x01 \x01(\x0b\x32\x12.context.ContextId\x12\x1f\n\x08slice_id\x18\x02 \x01(\x0b\x32\r.context.Uuid\"W\n\x0bSliceStatus\x12 \n\x08slice_id\x18\x01 \x01(\x0b\x32\x0e.slice.SliceId\x12&\n\x06status\x18\x02 \x01(\x0e\x32\x16.slice.SliceStatusEnum*@\n\x0fSliceStatusEnum\x12\x0b\n\x07PLANNED\x10\x00\x12\x08\n\x04INIT\x10\x01\x12\n\n\x06\x41\x43TIVE\x10\x02\x12\n\n\x06\x44\x45INIT\x10\x03\x32\x88\x01\n\x0cSliceService\x12@\n\x11\x43reateUpdateSlice\x12\x15.slice.TransportSlice\x1a\x12.slice.SliceStatus\"\x00\x12\x36\n\x0b\x44\x65leteSlice\x12\x15.slice.TransportSlice\x1a\x0e.context.Empty\"\x00\x62\x06proto3'
  ,
  dependencies=[context__pb2.DESCRIPTOR,service__pb2.DESCRIPTOR,])
  dependencies=[context__pb2.DESCRIPTOR,])

_SLICESTATUSENUM = _descriptor.EnumDescriptor(
  name='SliceStatusEnum',
@@ -56,8 +55,8 @@ _SLICESTATUSENUM = _descriptor.EnumDescriptor(
  ],
  containing_type=None,
  serialized_options=None,
  serialized_start=524,
  serialized_end=588,
  serialized_start=509,
  serialized_end=573,
)
_sym_db.RegisterEnumDescriptor(_SLICESTATUSENUM)

@@ -96,8 +95,8 @@ _SLICEENDPOINT = _descriptor.Descriptor(
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=52,
  serialized_end=103,
  serialized_start=37,
  serialized_end=88,
)


@@ -163,8 +162,8 @@ _TRANSPORTSLICE = _descriptor.Descriptor(
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=106,
  serialized_end=350,
  serialized_start=91,
  serialized_end=335,
)


@@ -202,8 +201,8 @@ _SLICEID = _descriptor.Descriptor(
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=352,
  serialized_end=433,
  serialized_start=337,
  serialized_end=418,
)


@@ -241,15 +240,15 @@ _SLICESTATUS = _descriptor.Descriptor(
  extension_ranges=[],
  oneofs=[
  ],
  serialized_start=435,
  serialized_end=522,
  serialized_start=420,
  serialized_end=507,
)

_SLICEENDPOINT.fields_by_name['port_id'].message_type = context__pb2._ENDPOINT
_TRANSPORTSLICE.fields_by_name['slice_id'].message_type = _SLICEID
_TRANSPORTSLICE.fields_by_name['endpoints'].message_type = _SLICEENDPOINT
_TRANSPORTSLICE.fields_by_name['constraints'].message_type = context__pb2._CONSTRAINT
_TRANSPORTSLICE.fields_by_name['services'].message_type = service__pb2._SERVICEID
_TRANSPORTSLICE.fields_by_name['services'].message_type = context__pb2._SERVICEID
_TRANSPORTSLICE.fields_by_name['subSlicesId'].message_type = _SLICEID
_TRANSPORTSLICE.fields_by_name['status'].message_type = _SLICESTATUS
_SLICEID.fields_by_name['contextId'].message_type = context__pb2._CONTEXTID
@@ -300,8 +299,8 @@ _SLICESERVICE = _descriptor.ServiceDescriptor(
  index=0,
  serialized_options=None,
  create_key=_descriptor._internal_create_key,
  serialized_start=591,
  serialized_end=727,
  serialized_start=576,
  serialized_end=712,
  methods=[
  _descriptor.MethodDescriptor(
    name='CreateUpdateSlice',
Loading