Added a dummy test with pyqcy
This commit is contained in:
parent
734727be4b
commit
4937225fe3
87
.ropeproject/config.py
Normal file
87
.ropeproject/config.py
Normal file
@ -0,0 +1,87 @@
|
||||
# The default ``config.py``
|
||||
|
||||
|
||||
def set_prefs(prefs):
|
||||
"""This function is called before opening the project"""
|
||||
|
||||
# Specify which files and folders to ignore in the project.
|
||||
# Changes to ignored resources are not added to the history and
|
||||
# VCSs. Also they are not returned in `Project.get_files()`.
|
||||
# Note that ``?`` and ``*`` match all characters but slashes.
|
||||
# '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
|
||||
# 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
|
||||
# '.svn': matches 'pkg/.svn' and all of its children
|
||||
# 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
|
||||
# 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
|
||||
prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
|
||||
'.hg', '.svn', '_svn', '.git']
|
||||
|
||||
# Specifies which files should be considered python files. It is
|
||||
# useful when you have scripts inside your project. Only files
|
||||
# ending with ``.py`` are considered to be python files by
|
||||
# default.
|
||||
#prefs['python_files'] = ['*.py']
|
||||
|
||||
# Custom source folders: By default rope searches the project
|
||||
# for finding source folders (folders that should be searched
|
||||
# for finding modules). You can add paths to that list. Note
|
||||
# that rope guesses project source folders correctly most of the
|
||||
# time; use this if you have any problems.
|
||||
# The folders should be relative to project root and use '/' for
|
||||
# separating folders regardless of the platform rope is running on.
|
||||
# 'src/my_source_folder' for instance.
|
||||
#prefs.add('source_folders', 'src')
|
||||
|
||||
# You can extend python path for looking up modules
|
||||
#prefs.add('python_path', '~/python/')
|
||||
|
||||
# Should rope save object information or not.
|
||||
prefs['save_objectdb'] = True
|
||||
prefs['compress_objectdb'] = False
|
||||
|
||||
# If `True`, rope analyzes each module when it is being saved.
|
||||
prefs['automatic_soa'] = True
|
||||
# The depth of calls to follow in static object analysis
|
||||
prefs['soa_followed_calls'] = 0
|
||||
|
||||
# If `False` when running modules or unit tests "dynamic object
|
||||
# analysis" is turned off. This makes them much faster.
|
||||
prefs['perform_doa'] = True
|
||||
|
||||
# Rope can check the validity of its object DB when running.
|
||||
prefs['validate_objectdb'] = True
|
||||
|
||||
# How many undos to hold?
|
||||
prefs['max_history_items'] = 32
|
||||
|
||||
# Shows whether to save history across sessions.
|
||||
prefs['save_history'] = True
|
||||
prefs['compress_history'] = False
|
||||
|
||||
# Set the number spaces used for indenting. According to
|
||||
# :PEP:`8`, it is best to use 4 spaces. Since most of rope's
|
||||
# unit-tests use 4 spaces it is more reliable, too.
|
||||
prefs['indent_size'] = 4
|
||||
|
||||
# Builtin and c-extension modules that are allowed to be imported
|
||||
# and inspected by rope.
|
||||
prefs['extension_modules'] = []
|
||||
|
||||
# Add all standard c-extensions to extension_modules list.
|
||||
prefs['import_dynload_stdmods'] = True
|
||||
|
||||
# If `True` modules with syntax errors are considered to be empty.
|
||||
# The default value is `False`; When `False` syntax errors raise
|
||||
# `rope.base.exceptions.ModuleSyntaxError` exception.
|
||||
prefs['ignore_syntax_errors'] = False
|
||||
|
||||
# If `True`, rope ignores unresolvable imports. Otherwise, they
|
||||
# appear in the importing namespace.
|
||||
prefs['ignore_bad_imports'] = False
|
||||
|
||||
|
||||
def project_opened(project):
|
||||
"""This function is called after opening the project"""
|
||||
# Do whatever you like here!
|
||||
|
||||
prefs.add('python_path', '/usr/lib/python2.7/site-packages')
|
BIN
.ropeproject/globalnames
Normal file
BIN
.ropeproject/globalnames
Normal file
Binary file not shown.
1
.ropeproject/history
Normal file
1
.ropeproject/history
Normal file
@ -0,0 +1 @@
|
||||
€]q(]q]qe.
|
1
.ropeproject/objectdb
Normal file
1
.ropeproject/objectdb
Normal file
@ -0,0 +1 @@
|
||||
<EFBFBD>}q.
|
@ -0,0 +1,5 @@
|
||||
"""
|
||||
OpenStack Neat :: an add-on to OpenStack implementing energy and performance efficient dynamic consolidation of virtual machines
|
||||
"""
|
||||
__version__ = "0.1"
|
||||
__author__ = "Anton Beloglazov"
|
BIN
neat/__init__.pyc
Normal file
BIN
neat/__init__.pyc
Normal file
Binary file not shown.
54
neat/collector.py
Executable file
54
neat/collector.py
Executable file
@ -0,0 +1,54 @@
|
||||
#! /usr/bin/env python2
|
||||
import sys
|
||||
import time
|
||||
import libvirt
|
||||
|
||||
|
||||
def getNumberOfPhysicalCpus(connection):
|
||||
return connection.getInfo()[2]
|
||||
|
||||
|
||||
def getDomainTotalCpuTime(domain):
|
||||
return domain.getCPUStats(True, 0)[0]['cpu_time']
|
||||
|
||||
|
||||
def getCpuUtilization(numberOfPhysicalCpus, domain, previousTime, previousCpuTime, currentTime, currentCpuTime):
|
||||
#prevTime = time.time()
|
||||
#prevCpuTime = getDomainTotalCpuTime(domain)
|
||||
#time.sleep(1)
|
||||
#currTime = time.time()
|
||||
#currCpuTime = getDomainTotalCpuTime(domain)
|
||||
|
||||
return ((currentCpuTime - previousCpuTime) / ((currentTime - previousTime) * 1000000000 * numberOfPhysicalCpus))
|
||||
|
||||
def collectCpuUtilization(numberOfPhysicalCpus, timeInterval, reportingFunction):
|
||||
pass
|
||||
|
||||
|
||||
conn = libvirt.openReadOnly(None)
|
||||
if conn is None:
|
||||
print 'Failed to open connection to the hypervisor'
|
||||
sys.exit(1)
|
||||
|
||||
numberOfPhysicalCpus = getNumberOfPhysicalCpus(conn)
|
||||
#print "Host CPUs: " + str(numberOfPhysicalCpus)
|
||||
|
||||
|
||||
|
||||
|
||||
#getCpuUtilization(dom0, numberOfPhysicalCpus)
|
||||
|
||||
|
||||
#try:
|
||||
# dom0 = conn.lookupByName("cirros")
|
||||
#except:
|
||||
# print 'Failed to find the main domain'
|
||||
# sys.exit(1)
|
||||
|
||||
|
||||
#print "Domain 0: id %d running %s" % (dom0.ID(), dom0.OSType())
|
||||
#print dom0.info()
|
||||
#print dom0.getCPUStats(1, 0)
|
||||
#print dom0.vcpus()
|
||||
#print dom0.vcpuPinInfo(0)
|
||||
#print conn.getCPUStats(1, 0)
|
@ -1,55 +0,0 @@
|
||||
#! /usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
import libvirt
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def getNumberOfPhysicalCpus(connection):
|
||||
return connection.getInfo()[2]
|
||||
|
||||
|
||||
def getDomainTotalCpuTime(domain):
|
||||
return domain.getCPUStats(True, 0)[0]['cpu_time']
|
||||
|
||||
|
||||
def getCpuUtilization(domain, numberOfPhysicalCpus):
|
||||
prevTime = time.time()
|
||||
prevCpuTime = getDomainTotalCpuTime(domain)
|
||||
time.sleep(1)
|
||||
currTime = time.time()
|
||||
currCpuTime = getDomainTotalCpuTime(domain)
|
||||
|
||||
print "Prev time: " + str(prevTime)
|
||||
print "Prev cpu time: " + str(prevCpuTime)
|
||||
print "Curr time: " + str(currTime)
|
||||
print "Curr cpu time: " + str(currCpuTime)
|
||||
|
||||
print "CPU utilization: "
|
||||
print ((currCpuTime - prevCpuTime) / ((currTime - prevTime) * 1000000000 * numberOfPhysicalCpus))
|
||||
|
||||
|
||||
conn = libvirt.openReadOnly(None)
|
||||
if conn is None:
|
||||
print 'Failed to open connection to the hypervisor'
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
dom0 = conn.lookupByName("cirros")
|
||||
except:
|
||||
print 'Failed to find the main domain'
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
numberOfPhysicalCpus = getNumberOfPhysicalCpus(conn)
|
||||
print "Host CPUs: " + str(numberOfPhysicalCpus)
|
||||
|
||||
getCpuUtilization(dom0, numberOfPhysicalCpus)
|
||||
|
||||
|
||||
#print "Domain 0: id %d running %s" % (dom0.ID(), dom0.OSType())
|
||||
#print dom0.info()
|
||||
#print dom0.getCPUStats(1, 0)
|
||||
#print dom0.vcpus()
|
||||
#print dom0.vcpuPinInfo(0)
|
||||
#print conn.getCPUStats(1, 0)
|
4
tests/__init__.py
Normal file
4
tests/__init__.py
Normal file
@ -0,0 +1,4 @@
|
||||
from pyqcy import TestCase
|
||||
|
||||
# make nose not run it as standalone test case needlessly
|
||||
TestCase.__test__ = False
|
BIN
tests/__init__.pyc
Normal file
BIN
tests/__init__.pyc
Normal file
Binary file not shown.
10
tests/test_collector.py
Normal file
10
tests/test_collector.py
Normal file
@ -0,0 +1,10 @@
|
||||
from pyqcy import *
|
||||
|
||||
|
||||
@qc
|
||||
def addition_on_ints(x=int, y=int):
|
||||
assert isinstance(x + y, int)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
BIN
tests/test_collector.pyc
Normal file
BIN
tests/test_collector.pyc
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user