summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xansible/roles/download_pmu_tools/files/event_download_local.py213
-rw-r--r--ansible/roles/download_pmu_tools/tasks/main.yml7
-rw-r--r--samples/vnf_samples/nsut/prox/configs/tuples.lua37
-rw-r--r--tests/unit/network_services/nfvi/test_resource.py4
-rw-r--r--yardstick/network_services/nfvi/resource.py15
5 files changed, 10 insertions, 266 deletions
diff --git a/ansible/roles/download_pmu_tools/files/event_download_local.py b/ansible/roles/download_pmu_tools/files/event_download_local.py
deleted file mode 100755
index 8eda2cd0d..000000000
--- a/ansible/roles/download_pmu_tools/files/event_download_local.py
+++ /dev/null
@@ -1,213 +0,0 @@
-#!/usr/bin/env python
-# Copyright (c) 2014, Intel Corporation
-# Author: Andi Kleen
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms and conditions of the GNU General Public License,
-# version 2, as published by the Free Software Foundation.
-#
-# This program is distributed in the hope it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-# more details.
-#
-# Automatic event list downloader
-#
-# event_download.py download for current cpu
-# event_download.py -a download all
-# event_download.py cpustr... Download for specific CPU
-from __future__ import absolute_import
-from __future__ import print_function
-import sys
-
-import re
-import os
-import string
-from fnmatch import fnmatch
-from shutil import copyfile
-
-try:
- from urllib2 import URLError
-except ImportError:
- # python 3
- from urllib.error import URLError
-
-
-urlpath = 'https://download.01.org/perfmon'
-localpath = 'pmu_local_mirror/download.01.org/perfmon'
-mapfile = 'mapfile.csv'
-modelpath = localpath + "/" + mapfile
-NSB_JSON = os.environ.get("PMU_EVENTS_PATH", "/tmp/pmu_event.json")
-
-
-def get_cpustr():
- with open('/proc/cpuinfo', 'r') as f:
- cpu = [None, None, None]
- for j in f:
- n = j.split()
- if n[0] == 'vendor_id':
- cpu[0] = n[2]
- elif n[0] == 'model' and n[1] == ':':
- cpu[2] = int(n[2])
- elif n[0] == 'cpu' and n[1] == 'family':
- cpu[1] = int(n[3])
- if all(cpu):
- break
- return "%s-%d-%X" % (cpu[0], cpu[1], cpu[2])
-
-
-def sanitize(s, a):
- o = ""
- for j in s:
- if j in a:
- o += j
- return o
-
-
-def getdir():
- try:
- d = os.getenv("XDG_CACHE_HOME")
- xd = d
- if not d:
- home = os.getenv("HOME")
- d = "%s/.cache" % home
- d += "/pmu-events"
- if not os.path.isdir(d):
- # try to handle the sudo case
- if not xd:
- user = os.getenv("SUDO_USER")
- if user:
- nd = os.path.expanduser("~" + user) + "/.cache/pmu-events"
- if os.path.isdir(nd):
- return nd
- os.makedirs(d)
- return d
- except OSError:
- raise Exception('Cannot access ' + d)
-
-
-NUM_TRIES = 3
-
-
-def getfile(url, dir, fn):
- tries = 0
- print("Downloading", url, "to", fn)
- while True:
- try:
- f = open(url)
- data = f.read()
- except IOError:
- tries += 1
- if tries >= NUM_TRIES:
- raise
- print("retrying download")
- continue
- break
- with open(os.path.join(dir, fn), "w") as o:
- o.write(data)
- f.close()
-
-
-allowed_chars = string.ascii_letters + '_-.' + string.digits
-
-
-def download(match, key=None, link=True):
- found = 0
- dir = getdir()
- try:
- getfile(modelpath, dir, "mapfile.csv")
- models = open(os.path.join(dir, "mapfile.csv"))
- for j in models:
- n = j.rstrip().split(",")
- if len(n) < 4:
- if len(n) > 0:
- print("Cannot parse", n)
- continue
- cpu, version, name, type = n
- if not fnmatch(cpu, match) or (key is not None and type not in key) or type.startswith("EventType"):
- continue
- cpu = sanitize(cpu, allowed_chars)
- url = localpath + name
- fn = "%s-%s.json" % (cpu, sanitize(type, allowed_chars))
- try:
- os.remove(os.path.join(dir, fn))
- except OSError:
- pass
- getfile(url, dir, fn)
- if link:
- lname = re.sub(r'.*/', '', name)
- lname = sanitize(lname, allowed_chars)
- try:
- os.remove(os.path.join(dir, lname))
- except OSError:
- pass
- try:
- os.symlink(fn, os.path.join(dir, lname))
- except OSError as e:
- print("Cannot link %s to %s:" % (name, lname), e, file=sys.stderr)
- found += 1
- models.close()
- getfile(localpath + "/readme.txt", dir, "readme.txt")
- except URLError as e:
- print("Cannot access event server:", e, file=sys.stderr)
- print("If you need a proxy to access the internet please set it with:", file=sys.stderr)
- print("\texport https_proxy=http://proxyname...", file=sys.stderr)
- print("If you are not connected to the internet please run this on a connected system:", file=sys.stderr)
- print("\tevent_download.py '%s'" % match, file=sys.stderr)
- print("and then copy ~/.cache/pmu-events to the system under test", file=sys.stderr)
- print("To get events for all possible CPUs use:", file=sys.stderr)
- print("\tevent_download.py -a", file=sys.stderr)
- except OSError as e:
- print("Cannot write events file:", e, file=sys.stderr)
- return found
-
-
-def download_current(link=False):
- """Download JSON event list for current cpu.
- Returns >0 when a event list is found"""
- return download(get_cpustr(), link=link)
-
-
-def eventlist_name(name=None, key="core"):
- if not name:
- name = get_cpustr()
- cache = getdir()
- return "%s/%s-%s.json" % (cache, name, key)
-
-
-if __name__ == '__main__':
- # only import argparse when actually called from command line
- # this makes ocperf work on older python versions without it.
- import argparse
- p = argparse.ArgumentParser(usage='download Intel event files')
- p.add_argument('--all', '-a', help='Download all available event files', action='store_true')
- p.add_argument('--verbose', '-v', help='Be verbose', action='store_true')
- p.add_argument('--mine', help='Print name of current CPU', action='store_true')
- p.add_argument('--link', help='Create links with the original event file name',
- action='store_true', default=True)
- p.add_argument('cpus', help='CPU identifiers to download', nargs='*')
- args = p.parse_args()
-
- cpustr = get_cpustr()
- if args.verbose or args.mine:
- print("My CPU", cpustr)
- if args.mine:
- sys.exit(0)
- d = getdir()
- if args.all:
- found = download('*', link=args.link)
- elif len(args.cpus) == 0:
- found = download_current(link=args.link)
- else:
- found = 0
- for j in args.cpus:
- found += download(j, link=args.link)
-
- if found == 0:
- print("Nothing found", file=sys.stderr)
-
- el = eventlist_name()
- if os.path.exists(el):
- print("my event list", el)
- copyfile(el, NSB_JSON)
- print("File copied to ", NSB_JSON)
diff --git a/ansible/roles/download_pmu_tools/tasks/main.yml b/ansible/roles/download_pmu_tools/tasks/main.yml
index 59a63aa85..37375b668 100644
--- a/ansible/roles/download_pmu_tools/tasks/main.yml
+++ b/ansible/roles/download_pmu_tools/tasks/main.yml
@@ -34,10 +34,3 @@
failed_when: false #some of the links while creating mirror are not found, results in failure
no_log: True
-- name: Copy local event download file
- copy:
- src: event_download_local.py
- dest: "{{ INSTALL_BIN_PATH }}/event_download_local.py"
- owner: root
- group: root
- mode: 0755
diff --git a/samples/vnf_samples/nsut/prox/configs/tuples.lua b/samples/vnf_samples/nsut/prox/configs/tuples.lua
index 431125082..60a1b3ecd 100644
--- a/samples/vnf_samples/nsut/prox/configs/tuples.lua
+++ b/samples/vnf_samples/nsut/prox/configs/tuples.lua
@@ -1,34 +1,17 @@
+-- Copyright (c) 2016-2017 Intel Corporation
--
--- Dataplane Automated Testing System
+-- 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
--
--- Copyright (c) 2015-2017, Intel Corporation.
--- All rights reserved.
+-- http://www.apache.org/licenses/LICENSE-2.0
--
--- Redistribution and use in source and binary forms, with or without
--- modification, are permitted provided that the following conditions
--- are met:
+-- 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.
--
--- * Redistributions of source code must retain the above copyright
--- notice, this list of conditions and the following disclaimer.
--- * Redistributions in binary form must reproduce the above copyright
--- notice, this list of conditions and the following disclaimer in
--- the documentation and/or other materials provided with the
--- distribution.
--- * Neither the name of Intel Corporation nor the names of its
--- contributors may be used to endorse or promote products derived
--- from this software without specific prior written permission.
---
--- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
--- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
--- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
--- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
--- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
--- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
--- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
--- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
--- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
--- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
--- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
tuples = {};
diff --git a/tests/unit/network_services/nfvi/test_resource.py b/tests/unit/network_services/nfvi/test_resource.py
index f3244fdbd..3ec5abcf9 100644
--- a/tests/unit/network_services/nfvi/test_resource.py
+++ b/tests/unit/network_services/nfvi/test_resource.py
@@ -134,10 +134,6 @@ class TestResourceProfile(unittest.TestCase):
self.assertIsNone(
self.resource_profile._prepare_collectd_conf("/opt/nsb_bin"))
- def test__setup_intel_pmu(self):
- self.assertIsNone(
- self.resource_profile._setup_intel_pmu(self.ssh_mock, "/opt/nsb_bin"))
-
def test__setup_ovs_stats(self):
self.assertIsNone(
self.resource_profile._setup_ovs_stats(self.ssh_mock))
diff --git a/yardstick/network_services/nfvi/resource.py b/yardstick/network_services/nfvi/resource.py
index 5b96aaf29..c43a41b70 100644
--- a/yardstick/network_services/nfvi/resource.py
+++ b/yardstick/network_services/nfvi/resource.py
@@ -245,19 +245,6 @@ class ResourceProfile(object):
}
self._provide_config_file(config_file_path, self.COLLECTD_CONF, kwargs)
- def _setup_intel_pmu(self, connection, bin_path):
- pmu_event_path = os.path.join(bin_path, "pmu_event.json")
- try:
- self.plugins["intel_pmu"]["pmu_event_path"] = pmu_event_path
- except KeyError:
- # if intel_pmu is not a dict, force it into a dict
- self.plugins["intel_pmu"] = {"pmu_event_path": pmu_event_path}
- LOG.debug("Downloading event list for pmu_stats plugin")
- cmd = 'cd {0}; PMU_EVENTS_PATH={1} python event_download_local.py'.format(
- bin_path, pmu_event_path)
- cmd = "sudo bash -c '{}'".format(cmd)
- connection.execute(cmd)
-
def _setup_ovs_stats(self, connection):
try:
socket_path = self.plugins["ovs_stats"].get("ovs_socket_path", self.OVS_SOCKET_PATH)
@@ -284,8 +271,6 @@ class ResourceProfile(object):
# connection.execute("sudo %s '%s' '%s'" % (
# collectd_installer, http_proxy, https_proxy))
return
- if "intel_pmu" in self.plugins:
- self._setup_intel_pmu(connection, bin_path)
if "ovs_stats" in self.plugins:
self._setup_ovs_stats(connection)