#!/usr/bin/env python # Copyright 2016 Cisco Systems, Inc. All rights reserved. # # 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 argparse import copy import datetime import importlib import json import os import sys import traceback from attrdict import AttrDict from logging import FileHandler import pbr.version from pkg_resources import resource_string from .__init__ import __version__ from .chain_runner import ChainRunner from .cleanup import Cleaner from .config import config_load from .config import config_loads from . import credentials from .fluentd import FluentLogHandler from . import log from .log import LOG from .nfvbenchd import WebServer from .specs import ChainType from .specs import Specs from .summarizer import NFVBenchSummarizer from . import utils fluent_logger = None class NFVBench(object): """Main class of NFV benchmarking tool.""" STATUS_OK = 'OK' STATUS_ERROR = 'ERROR' def __init__(self, config, openstack_spec, config_plugin, factory, notifier=None): # the base config never changes for a given NFVbench instance self.base_config = config # this is the running config, updated at every run() self.config = None self.config_plugin = config_plugin self.factory = factory self.notifier = notifier self.cred = credentials.Credentials(config.openrc_file, None, False) \ if config.openrc_file else None self.chain_runner = None self.specs = Specs() self.specs.set_openstack_spec(openstack_spec) self.vni_ports = [] sys.stdout.flush() def set_notifier(self, notifier): self.notifier = notifier def run(self, opts, args): """This run() method is called for every NFVbench benchmark request. In CLI mode, this method is called only once per invocation. In REST server mode, this is called once per REST POST request """ status = NFVBench.STATUS_OK result = None message = '' if fluent_logger: # take a snapshot of the current time for this new run # so that all subsequent logs can relate to this run fluent_logger.start_new_run() LOG.info(args) try: # recalc the running config based on the base config and options for this run self._update_config(opts) # check that an empty openrc file (no OpenStack) is only allowed # with EXT chain if not self.config.openrc_file and self.config.service_chain != ChainType.EXT: raise Exception("openrc_file in the configuration is required for PVP/PVVP chains") self.specs.set_run_spec(self.config_plugin.get_run_spec(self.config, self.specs.openstack)) self.chain_runner = ChainRunner(self.config, self.cred, self.specs, self.factory, self.notifier) new_frame_sizes = [] # make sure that the min frame size is 64 min_packet_size = 64 for frame_size in self.config.frame_sizes: try: if int(frame_size) < min_packet_size: frame_size = str(min_packet_size) LOG.info("Adjusting frame size %s bytes to minimum size %s bytes", frame_size, min_packet_size) if frame_size no
HeatTemplateFormatVersion: '2012-12-12'
Parameters:
C:
Type: String
Default: test3
resource2Image:
Type: String
Default: resource2
Resources:
notcomputeConfigMixin:
Type: AWS::AutoScaling::LaunchConfiguration
Metadata:
OpenStack::Role: notcomputeConfig
c: {Ref: C}
resource2:
Type: OS::Nova::Server
Properties:
flavor: test_flavor
image: {Ref: resource2Image}
key_name: test_key