#!/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. # """Test Chaining functions.""" from mock_trex import no_op from mock import MagicMock from mock import patch import pytest from nfvbench.chain_runner import ChainRunner from nfvbench.chaining import ChainException from nfvbench.chaining import ChainVnfPort from nfvbench.chaining import InstancePlacer from nfvbench.compute import Compute import nfvbench.credentials from nfvbench.factory import BasicFactory import nfvbench.log from nfvbench.nfvbench import load_default_config from nfvbench.nfvbench import NFVBench from nfvbench.packet_stats import InterfaceStats from nfvbench.specs import ChainType from nfvbench.specs import OpenStackSpec from nfvbench.specs import Specs from nfvbench.summarizer import _annotate_chain_stats from nfvbench.traffic_client import TrafficClient from nfvbench.traffic_gen.traffic_base import Latency from nfvbench.traffic_gen.trex_gen import TRex # just to get rid of the unused function warning no_op() def setup_module(module): """Enable log.""" nfvbench.log.setup(mute_stdout=False) nfvbench.log.set_level(debug=True) def _get_chain_config(sc=ChainType.PVP, scc=1, shared_net=True, rate='1Mpps'): config, _ = load_default_config() config.vm_image_file = 'nfvbenchvm-0.0.qcow2' config.service_chain_count = scc config.service_chain = sc config.service_chain_shared_net = shared_net config.rate = rate config['traffic_generator']['generator_profile'] = [{'name': 'dummy', 'tool': 'dummy', 'ip': '127.0.0.1', 'intf_speed': '10Gbps', 'interfaces': [{'port': 0, 'pci': '0.0'}, {'port': 1, 'pci': '0.0'}]}] config.ndr_run = False config.pdr_run = False config.single_run = True config.generator_profile = 'dummy' config.duration_sec = 2 config.interval_sec = 1 config.openrc_file = "dummy.rc" config.no_flow_stats = False config.no_latency_stats = False config.no_latency_streams = False return config def test_chain_runner_ext_no_openstack(): """Test ChainRunner EXT no openstack.""" config = _get_chain_config(sc=ChainType.EXT) specs = Specs() config.vlans = [100, 200] config['traffic_generator']['mac_addrs_left'] = ['00:00:00:00:00:00'] config['traffic_generator']['mac_addrs_right'] = ['00:00:00:00:01:00'] for shared_net in [True, False]: for no_arp in [False, True]: for vlan_tag in [False, True]: for scc in [1, 2]: config = _get_chain_config(ChainType.EXT, scc, shared_net) config.no_arp = no_arp if no_arp: # If EXT and no arp, the config must provide mac (1 pair per chain) config['traffic_generator']['mac_addrs_left'] = ['00:00:00:00:00:00'] * scc config['traffic_generator']['mac_addrs_right'] = ['00:00:00:00:01:00'] * scc config['vlan_tagging'] = vlan_tag if vlan_tag: # these are the 2 valid forms of vlan ranges if scc == 1: config.vlans = [100, 200] else: config.vlans = [[port * 100 + index for index in range(scc)] for port in range(2)] runner = ChainRunner(config, None, specs, BasicFactory()) runner.close() def _mock_find_image(self, image_name): return MagicMock() @patch.object(Compute, 'find_image', _mock_find_image) @patch('nfvbench.chaining.Client') @patch('nfvbench.chaining.neutronclient') @patch('nfvbench.chaining.glanceclient') def _test_pvp_chain(config, cred, mock_glance, mock_neutron, mock_client): # instance = self.novaclient.servers.create(name=vmname,...) # instance.status == 'ACTIVE' mock_client.return_value.servers.create.return_value.status = 'ACTIVE' netw = {'id': 0, 'provider:network_type': 'vlan', 'provider:segmentation_id': 1000} mock_neutron.Client.return_value.create_network.return_value = {'network': netw} mock_neutron.Client.return_value.list_networks.return_value = {'networks': None} specs = Specs() openstack_spec = OpenStackSpec() specs.set_openstack_spec(openstack_spec) cred = MagicMock(spec=nfvbench.credentials.Credentials) cred.is_admin = True runner = ChainRunner(config, cred, specs, BasicFactory()) runner.close() def test_pvp_chain_runner(): """Test PVP chain runner.""" cred = MagicMock(spec=nfvbenc
heat_template_version: pike

description: >
  Storage management network. Storage replication, etc.

parameters:
  # the defaults here work for static IP assignment (IPAM) only
  StorageMgmtNetCidr:
    default: '172.16.3.0/24'
    description: Cidr for the storage management network.
    type: string
  StorageMgmtNetValueSpecs:
    default: {'provider:physical_network': 'storage_mgmt', 'provider:network_type': 'flat'}
    description: Value specs for the storage_mgmt network.
    type: json
  StorageMgmtNetAdminStateUp:
    default: false
    description: This admin state of the network.
    type: boolean
  StorageMgmtNetEnableDHCP:
    default: false
    description: Whether to enable DHCP on the associated subnet.
    type: boolean
  StorageMgmtNetShared:
    default: false
    description: Whether this network is shared across all tenants.
    type: boolean
  StorageMgmtNetName:
    default: storage_mgmt
    description: The name of the Storage management network.
    type: string
  StorageMgmtSubnetName:
    default: storage_mgmt_subnet
    description: The name of the Storage management subnet in Neutron.
    type: string
  StorageMgmtAllocationPools:
    default: [{'start': '172.16.3.4', 'end': '172.16.3.250'}]
    description: Ip allocation pool range for the storage mgmt network.
    type: json

resources:
  StorageMgmtNetwork:
    type: OS::Neutron::Net
    properties:
      admin_state_up: {get_param: StorageMgmtNetAdminStateUp}
      name: {get_param: StorageMgmtNetName}
      shared: {get_param: StorageMgmtNetShared}
      value_specs: {get_param: StorageMgmtNetValueSpecs}

  StorageMgmtSubnet:
    type: OS::Neutron::Subnet
    properties:
      cidr: {get_param: StorageMgmtNetCidr}
      enable_dhcp: {get_param: StorageMgmtNetEnableDHCP}
      name: {get_param: StorageMgmtSubnetName}
      network: {get_resource: StorageMgmtNetwork}
      allocation_pools: {get_param: StorageMgmtAllocationPools}
      gateway_ip: null

outputs:
  OS::stack_id:
    description: Neutron storage management network
    value: {get_resource: StorageMgmtN