Beispiel #1
0
    def parse_arguments(self, argv : Optional[Tuple[str, ...]] = None):
        """ Parse commend line arguments.
            Returns handler_type, args
        """
        prog_basename = os.path.basename(sys.argv[0])
        (prog_root, _) = os.path.splitext(prog_basename)

        if argv is None:
            argv = sys.argv

        self._args = self._parser.parse_args(argv[1:])

        # handler parameter is mandatory
        if self._any_handler:
            if self._args.handler is None:
                print("-f, --handler parameter is mandatory. Valid values:{}".format(self._valid_handler_names))
                return None, None
            if self._args.handler not in self.handler_map:
                print("--handler value is invalid. Supported values:{}".format(self._valid_handler_names))
                return None, None
            self._handler_type = self.handler_map[self._args.handler]
            self._name = self._name is None and self._args.handler or self._name

        loglevel_map = {0: logging.WARN, 1: logging.INFO, 2: logging.DEBUG}
        OmciLogger(level=loglevel_map[self._args.loglevel])
        logger = OmciLogger.getLogger(prog_root)
        logger.debug('args %r' % self._args)
        return self._handler_type, self._args
def test_extractPayload():
    polt_host = '10.66.1.2'
    polt_port = 8433
    vomci_name = 'vomci1'
    cterm_name = 'channeltermination.1'
    onu_id = 0
    onu_name = 'onuTrial'
    tci = 1
    log_level = 2

    loglevel_map = {0: logging.WARN, 1: logging.INFO, 2: logging.DEBUG}
    OmciLogger(level=loglevel_map[log_level])
    logger = OmciLogger.getLogger(__name__)

    logger.info("test_YangtoOmciMapper: connecting to the pOLT {}:{}".format(
        polt_host, polt_port))
    channel = GrpcClientChannel(vomci_name)
    ret_val = channel.connect(polt_host, polt_port)
    if not ret_val:
        logger.info("test_YangtoOmciMapper: connection failed with pOLT")
        return -1
    olt = channel.add_managed_onu(channel.remote_endpoint_name, onu_name,
                                  (cterm_name, onu_id), tci)
    logger.info("test_YangtoOmciMapper: connected to the pOLT: {}".format(
        olt.id))
    onu = olt.OnuGet((cterm_name, onu_id))
    activate_handler = OnuActivateHandler(onu)
    status = activate_handler.run()
    logger.info(
        "test_YangtoOmciMapper: activate_handler status: {}".format(status))

    payload = '{"identifier": "0", "operation": "edit-config", ' \
              '"delta":{"bbf-qos-classifiers:classifiers": {"classifier-entry": [{"name" : "classifier1",  ' \
              '"classifier-action-entry-cfg": [{"action-type": "bbf-qos-cls:scheduling-traffic-class", "scheduling-traffic-class": 0}], ' \
              '"match-criteria": {"tag": [{"index": 0, "in-pbit-list": 0}]}}]}, ' \
              '"bbf-qos-policies:policies": {"policy": [{"name" : "policy1", "classifiers": [{"name":"classifier1"}]}]}, ' \
              '"bbf-qos-policies:qos-policy-profiles": {"policy-profile": [{"name": "profile1", "policy-list": [{"name": "policy1"}]}]}, ' \
              '"ietf-interfaces:interfaces": {"interface": [{"name": "uni.1", "type": "ianaift:ethernetCsmacd", ' \
              '"enabled": "true", "port-layer-if": "ontUni_ont1_1_1", "ingress-qos-policy-profile": "profile1"}, ' \
              '{"name": "enet_vlan_ont1", "type": "bbfift:vlan-sub-interface", "subif-lower-layer": {"interface" : "uni.1"}, ' \
              '"inline-frame-processing": {"ingress-rule": {"rule": [{"name": "rule1", "priority": "100", "flexible-match": {"match-criteria": "untagged"}, ' \
              '"ingress-rewrite": {"pop-tags" : 0, "push-tag": [{"index": 0, "dot1q-tag": {"tag-type": "bbf-dot1qt:c-vlan", "vlan-id": 100, "pbit-from-tag-index": 0}}]}}]}}, ' \
              '"ingress-qos-policy-profile": "profile1"}]}, "bbf-xpongemtcont:xpongemtcont": {"tconts": {"tcont": [{"name": "tcont.1", "alloc-id": 1024}]}, ' \
              '"gemports": {"gemport": [{"name": "gemport.1", "interface": "uni.1", "gemport-id": 1025, "traffic-class": 0, "tcont-ref": "tcont.1"}]}}}}'

    payloadDict = json.loads(payload)
    extractPayload(onu_name, olt.id, payloadDict)

    if onu.olt.channel is not None:
        onu.olt.channel.disconnect()
Beispiel #3
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 threading
import time
import logging
from omci_logger import OmciLogger
import vomci
import sys
from mapper.yang_to_omci_mapper import extractPayload
import json

OmciLogger(level=logging.DEBUG)
logger = OmciLogger.getLogger(__name__)


def start_vomci_threads():
    logger.debug('Starting vomci')
    v_omci = vomci.VOmci()
    v_omci.start()
    while True:
        time.sleep(20)
    # send_msg_to_proxy(v_omci)


def send_msg_to_proxy(v_omci):
    logger.info("sending a message to proxy")
    msg = b'this is a just a test message from vomci....'