Pycopia storage package

This package primarily provides the persistent storage model for the other Pycopia packages pycopia-QA, pycopia-WWW”, and *pycopia-SNMP. It defines a schema that is used by those packages, so may not be generally useful. However, the configuration table models a hierarchical storage that you may find useful.

It also provides web app helpers, importers, and exporters.

Models

class pycopia.db.models.Address[source]
ROW_DISPLAY = (u'address', u'address2', u'city', u'stateprov', u'postalcode')
address
address2
city
country
country_id
id
postalcode
stateprov
class pycopia.db.models.AttributeType[source]
ROW_DISPLAY = (u'name', u'value_type', u'description')
description
classmethod get_attribute_list(session)[source]
classmethod get_by_name(session, name)[source]
id
name
value_type
class pycopia.db.models.Capability[source]
ROW_DISPLAY = (u'type', u'value')
equipment
equipment_id
id
type
type_id
validate_value(attrname, value)[source]
value
class pycopia.db.models.CapabilityGroup[source]
ROW_DISPLAY = (u'name',)
id
name
class pycopia.db.models.CapabilityType[source]
ROW_DISPLAY = (u'name', u'value_type', u'description', u'group')
description
group
group_id
id
name
value_type
class pycopia.db.models.Component[source]
ROW_DISPLAY = (u'name', u'description', u'created')
created
description
id
name
class pycopia.db.models.Config[source]
ROW_DISPLAY = (u'name', u'value', u'user', u'testcase', u'testsuite')
children
comment
get_child(session, name)[source]
id
name
parent_id
set_owner(session, user)[source]
testcase
testcase_id
testsuite
testsuite_id
user
user_id
value
class pycopia.db.models.Contact[source]
ROW_DISPLAY = (u'lastname', u'firstname', u'middlename', u'email')
address
address_id
email
fax
firstname
id
lastname
middlename
note
pager
phonehome
phonemobile
phoneoffice
phoneother
phonework
position
prefix
title
user
user_id
class pycopia.db.models.Cookie[source]
comment
comment_url
discard
domain
expires
id
max_age
name
path
port
secure
user_id
value
version
class pycopia.db.models.CorporateAttribute[source]
ROW_DISPLAY = (u'type', u'value')
corporation
corporation_id
id
type
type_id
validate_value(attrname, value)[source]
value
class pycopia.db.models.CorporateAttributeType[source]
ROW_DISPLAY = (u'name', u'value_type', u'description')
description
classmethod get_attribute_list(session)[source]
classmethod get_by_name(session, name)[source]
id
name
value_type
class pycopia.db.models.Corporation[source]
ROW_DISPLAY = (u'name',)
add_service(session, service)[source]
address
address_id
contact
contact_id
country
country_id
del_attribute(session, attrtype)[source]
del_service(session, service)[source]
get_attribute(session, attrname)[source]
static get_attribute_class()[source]
static get_attribute_list(session)[source]
id
name
notes
parent_id
services
set_attribute(session, attrname, value)[source]
update_attribute(session, attrname, value)[source]
class pycopia.db.models.Country[source]
ROW_DISPLAY = (u'name', u'isocode')
id
isocode
name
class pycopia.db.models.CountrySet[source]
ROW_DISPLAY = (u'name',)
countries
id
name
class pycopia.db.models.DatabaseContext[source]
class pycopia.db.models.Environment[source]
ROW_DISPLAY = (u'name', u'owner')
clear_owner(session)[source]
del_attribute(session, attrtype)[source]
equipment

A descriptor that presents a read/write view of an object attribute.

get_DUT(session)[source]
get_all_equipment_with_role(session, rolename)[source]
get_attribute(session, attrname)[source]
static get_attribute_class()[source]
static get_attribute_list(session)[source]
get_equipment_with_role(session, rolename)[source]
get_supported_roles(session)[source]
id
is_owned()[source]
name
owner
owner_id
set_attribute(session, attrname, value)[source]
set_owner_by_username(session, username)[source]
update_attribute(session, attrname, value)[source]
class pycopia.db.models.EnvironmentAttribute[source]
ROW_DISPLAY = (u'type', u'value')
environment
environment_id
id
type
type_id
validate_value(attrname, value)[source]
value
class pycopia.db.models.EnvironmentAttributeType[source]
ROW_DISPLAY = (u'name', u'value_type', u'description')
description
classmethod get_attribute_list(session)[source]
classmethod get_by_name(session, name)[source]
id
name
value_type
class pycopia.db.models.Equipment[source]
ROW_DISPLAY = (u'name', u'model', u'serno')
account
account_id
active
add_interface(session, name, ifindex=None, interface_type=None, macaddr=None, ipaddr=None, network=None)[source]
addeddate
any_interface[source]
attach_interface(session, **selectkw)[source]

Attach an existing interface entry that is currently detached.

comments
connect(session, intf, network, force=False)[source]

Connect this equipments named interface to a network.

If “force” is True then alter network part of address to match network.

del_attribute(session, attrname)[source]
del_interface(session, name)[source]
disconnect(session, intf)[source]
get_attribute(session, attrname)[source]
static get_attribute_class()[source]
static get_attribute_list(session)[source]
id
language
language_id
location
location_id
model
model_id
name
owner
owner_id
parent_id
serno
set_attribute(session, attrname, value)[source]
software
subcomponents
sublocation
update_attribute(session, attrname, value)[source]
vendor
vendor_id
class pycopia.db.models.EquipmentAttribute[source]
ROW_DISPLAY = (u'type', u'value')
equipment
equipment_id
id
type
type_id
validate_value(attrname, value)[source]
value
class pycopia.db.models.EquipmentCategory[source]
id
name
class pycopia.db.models.EquipmentModel[source]
ROW_DISPLAY = (u'manufacturer', u'name', u'category')
category
category_id
del_attribute(session, attrtype)[source]
embeddedsoftware
get_attribute(session, attrname)[source]
static get_attribute_class()[source]
static get_attribute_list(session)[source]
id
manufacturer
manufacturer_id
name
note
picture
set_attribute(session, attrname, value)[source]
specs
update_attribute(session, attrname, value)[source]
class pycopia.db.models.EquipmentModelAttribute[source]
ROW_DISPLAY = (u'type', u'value')
equipmentmodel
equipmentmodel_id
id
type
type_id
validate_value(attrname, value)[source]
value
class pycopia.db.models.FunctionalArea[source]
ROW_DISPLAY = (u'name',)
description
id
name
class pycopia.db.models.Group[source]
ROW_DISPLAY = (u'name', u'permissions')
id
name
permissions
class pycopia.db.models.Interface[source]
ROW_DISPLAY = (u'name', u'ifindex', u'interface_type', u'equipment', u'macaddr', u'ipaddr', u'network')
alias
create_subinterface(session, subname)[source]
description
equipment
equipment_id
id
ifindex
interface_type
interface_type_id
ipaddr
macaddr
mtu
name
network
network_id
parent_id
classmethod select_unattached(session)[source]
speed
status
subinterfaces
vlan
class pycopia.db.models.InterfaceType[source]
enumeration
id
name
class pycopia.db.models.Language[source]
ROW_DISPLAY = (u'name', u'isocode')
id
isocode
name
class pycopia.db.models.LanguageSet[source]
ROW_DISPLAY = (u'name',)
id
languages
name
class pycopia.db.models.Location[source]
ROW_DISPLAY = (u'locationcode',)
address
address_id
contact
contact_id
id
locationcode
class pycopia.db.models.LoginAccount[source]
ROW_DISPLAY = (u'identifier', u'login')
id
identifier
login
note
password
class pycopia.db.models.MetaDataTuple

MetaDataTuple(coltype, colname, default, m2m, nullable, uselist, collection)

collection

Alias for field number 6

colname

Alias for field number 1

coltype

Alias for field number 0

default

Alias for field number 2

m2m

Alias for field number 3

nullable

Alias for field number 4

uselist

Alias for field number 5

exception pycopia.db.models.ModelAttributeError[source]

Raised for errors related to models with attributes.

exception pycopia.db.models.ModelError[source]

Raised when something doesn’t make sense for this model

class pycopia.db.models.Network[source]
ROW_DISPLAY = (u'name', u'layer', u'vlanid', u'ipnetwork', u'notes')
id
ipnetwork
layer
lower_id
name
notes
upperlayers
vlanid
class pycopia.db.models.Permission[source]
ROW_DISPLAY = (u'name', u'description')
description
id
name
class pycopia.db.models.Project[source]
ROW_DISPLAY = (u'name', u'category', u'description')
category
category_id
components
created
description
id
leader
leader_id
name
class pycopia.db.models.ProjectCategory[source]
ROW_DISPLAY = (u'name',)
id
name
class pycopia.db.models.ProjectVersion[source]
ROW_DISPLAY = (u'project', u'major', u'minor', u'subminor', u'build')
build
id
major
minor
project
project_id
subminor
valid
class pycopia.db.models.Requirement[source]
ROW_DISPLAY = (u'uri',)
description
id
uri
class pycopia.db.models.RiskCategory[source]
ROW_DISPLAY = (u'name',)
description
id
name
class pycopia.db.models.RiskFactor[source]
ROW_DISPLAY = (u'description',)
description
id
likelihood
priority
requirement
requirement_id
risk_category
risk_category_id
severity
testcase
testcase_id
class pycopia.db.models.Schedule[source]
ROW_DISPLAY = (u'name', u'user', u'minute', u'hour', u'day_of_month', u'month', u'day_of_week')
day_of_month
day_of_week
hour
id
minute
month
name
user
user_id
class pycopia.db.models.Session(user, lifetime=48)[source]
classmethod clean(session)[source]
data
expire_date
classmethod get_expired(session)[source]
is_expired()[source]
session_key
class pycopia.db.models.Software[source]
ROW_DISPLAY = (u'name', u'category', u'manufacturer', u'vendor')
category
category_id
del_attribute(session, attrtype)[source]
get_attribute(session, attrname)[source]
static get_attribute_class()[source]
static get_attribute_list(session)[source]
id
manufacturer
manufacturer_id
name
set_attribute(session, attrname, value)[source]
update_attribute(session, attrname, value)[source]
variants
vendor
vendor_id
class pycopia.db.models.SoftwareAttribute[source]
ROW_DISPLAY = (u'type', u'value')
id
software
software_id
type
type_id
validate_value(attrname, value)[source]
value
class pycopia.db.models.SoftwareCategory[source]
ROW_DISPLAY = (u'name', u'description')
description
classmethod get_by_name(session, rolename)[source]
id
name
class pycopia.db.models.SoftwareVariant[source]
ROW_DISPLAY = (u'name', u'encoding')
country
country_id
encoding
id
language
language_id
name
class pycopia.db.models.TestCase[source]
ROW_DISPLAY = (u'name', u'purpose', u'testimplementation')
author_id
automated
bugid
comments
cycle
endcondition
functionalarea
get_all_results(session)[source]
classmethod get_by_implementation(dbsession, implementation)[source]
classmethod get_by_name(dbsession, name)[source]
get_data(session)[source]
get_latest_result(session)[source]
id
interactive
lastchange
lastchangeauthor_id
name
passcriteria
prerequisites
priority
procedure
purpose
reference
reference_id
reviewer_id
startcondition
status
tester_id
testimplementation
time_estimate
valid
class pycopia.db.models.TestEquipment[source]

Binds equipment and a test environment. Also specifies the unit under test.

ROW_DISPLAY = (u'equipment', u'UUT')
UUT
environment
environment_id
equipment
equipment_id
id
roles
class pycopia.db.models.TestJob[source]
ROW_DISPLAY = (u'name', u'schedule')
environment
environment_id
id
isscheduled
name
parameters
reportname
schedule
schedule_id
suite
testsuite_id
user
user_id
class pycopia.db.models.TestResult(**kwargs)[source]
ROW_DISPLAY = (u'testsuite', u'testcase', u'testimplementation', u'tester', u'result', u'starttime')
arguments
build
build_id
diagnostic
endtime
environment
environment_id
classmethod get_latest_results(session, user=None)[source]

Returns last 10 TestRunner (top-level) results. Optionally filtered by user.

classmethod get_latest_run(session, user)[source]

Return the last Runner (top-level) TestResult for the User.

id
note
objecttype
parent_id
reportfilename
result
resultslocation
starttime
subresults
testcase
testcase_id
tester
tester_id
testimplementation
testsuite
testsuite_id
testversion
valid
class pycopia.db.models.TestResultData[source]
ROW_DISPLAY = (u'note',)
data
id
note
test_results_id
testresult
class pycopia.db.models.TestSuite[source]
ROW_DISPLAY = (u'name', u'suiteimplementation')
components
classmethod get_by_implementation(dbsession, implementation)[source]
classmethod get_by_name(dbsession, name)[source]
get_latest_result(session)[source]
classmethod get_latest_results(session)[source]
classmethod get_suites(session)[source]
id
lastchange
lastchangeauthor_id
name
project
project_id
purpose
subsuites
suiteimplementation
testcases
valid
class pycopia.db.models.Trap(timestamp, trap)[source]
ROW_DISPLAY = (u'timestamp', u'value')
id
timestamp
trap
class pycopia.db.models.User[source]
ROW_DISPLAY = (u'username', u'first_name', u'last_name', u'email')
address_id
authservice
date_joined
email
first_name
full_name[source]
classmethod get_by_username(dbsession, username)[source]
get_session_key()[source]
groups
id
is_active
is_staff
is_superuser
last_login
last_name
middle_name
password
permissions
set_last_login()[source]
username
class pycopia.db.models.UserMessage[source]
ROW_DISPLAY = (u'user', u'message')
id
message
user
user_id
pycopia.db.models.class_names()[source]
pycopia.db.models.create(klass, **kwargs)[source]
pycopia.db.models.create_sessionmaker(url=None)[source]
pycopia.db.models.create_user(session, pwent)[source]

Create a new user with a default password and name taken from the password entry (from the passwd module).

pycopia.db.models.get_choices(session, modelclass, colname, order_by=None)[source]

Get possible choices for a field.

Returns a list of tuples, (id/value, name/label) of available choices.

pycopia.db.models.get_column_metadata(class_, colname)[source]
pycopia.db.models.get_key()[source]
pycopia.db.models.get_metadata(class_)[source]

Returns a list of MetaDataTuple structures.

pycopia.db.models.get_metadata_iterator(class_)[source]
pycopia.db.models.get_metadata_map(class_)[source]
pycopia.db.models.get_primary_key(class_)[source]

Return the primary key column.

pycopia.db.models.get_primary_key_name(class_)[source]

Return name or names of primary key column. Return None if not defined.

pycopia.db.models.get_primary_key_value(dbrow)[source]
pycopia.db.models.get_rowdisplay(class_)[source]
pycopia.db.models.get_session()[source]
pycopia.db.models.update(inst, **kwargs)[source]

Importers

NMAP Scan Importer

Import nmap XML output into the network model.

Even though nmap reports discovered hosts as hosts, they are actually interfaces. This importer creates unattached interfaces. A user/administrator will have to go and assign created interfaces to hosts.

class pycopia.db.importers.nmap.ContentHandler(dburl=None)[source]

SAX content handler.

Manages state and adds interface records when enough host data is collected.

notationDecl(name, publicId, systemId)[source]

Handle a notation declaration event.

processingInstruction(target, data)[source]

handle: xml version=”1.0” encoding=”ISO-8859-1”?

pycopia.db.importers.nmap.add_interface(session, attribs)[source]

Add new interface, don’t duplicate existing one. Also try connecting to equipment if possible.

pycopia.db.importers.nmap.get_network(session, ipnet)[source]

Returns a Network model object. Creates one if necessary.

Test Case importer

class pycopia.db.importers.testcases.TestCaseData[source]

Collect TestCase record data here.

Call create() at the end when all data collected.

create()[source]

Create and save new TestCase with data collected so far.

set_from_TestCase(testcase)[source]

Extract available data from Test instance.

update(dbtestcase)[source]

Update a given TestCase instance to the values contained in this holder.

pycopia.db.importers.testcases.do_Test(testinstance)[source]

Process a core.Test instance outside of a TestEntry (no args).

pycopia.db.importers.testcases.do_TestEntry(entry)[source]

Import from a core.TestEntry instance.

This object represents a test instance, with arguments.

pycopia.db.importers.testcases.do_TestSuite(suite)[source]

Import from a core.TestSuite instance.

Arguments:
suite: an instance of core.TestSuite, or subclass.
Returns:
A database record that maps to the original suite object, populated with the contents of the suite (also imported).
pycopia.db.importers.testcases.do_module(mod, config)[source]

Import objects in the given module.

pycopia.db.importers.testcases.get_TestEntry_instance(string, config)[source]

Return a TestEntry instance from a string representing a test class plus arguments.

pycopia.db.importers.testcases.set_debug(state)[source]

Change state of global debug flag.

pycopia.db.importers.testcases.set_force(state)[source]

Change state of global “forceful” flag.

Table Of Contents

Previous topic

Pycopia SNMP package

Next topic

Pycopia net package