Permalink
Browse files

Added 'parent' field to cloudminer database

  • Loading branch information...
1 parent 7c70b74 commit 1e2bf6dbd8e5d659c3359884cd6047a2a0c6b4d5 @timf timf committed Apr 6, 2011
View
@@ -28,7 +28,7 @@ def __init__(self, source, name, key, timestamp, extra):
class _CYVM(object):
- def __init__(self, runname, iaasid, nodeid, hostname, service_type, runlogdir, vmlogdir, events=None):
+ def __init__(self, runname, iaasid, nodeid, hostname, service_type, parent, runlogdir, vmlogdir, events=None):
self.runname = runname
self.iaasid = iaasid
self.nodeid = nodeid
@@ -38,6 +38,7 @@ def __init__(self, runname, iaasid, nodeid, hostname, service_type, runlogdir, v
self.events = []
self.hostname = hostname
self.service_type = service_type
+ self.parent = parent
self.vmlogdir = vmlogdir
self.runlogdir = runlogdir
@@ -53,6 +54,7 @@ def add_event(self, e):
Column('nodeid', String(128), unique=True),
Column('hostname', String(128)),
Column('service_type', String(128)),
+ Column('parent', String(128)),
Column('runlogdir', String(128)),
Column('vmlogdir', String(128)),
)
@@ -91,27 +93,29 @@ def __init__(self, dburl, module=None):
self.Session = sessionmaker(bind=self.engine)
self.session = self.Session()
- def add_cloudyvent_vm(self, runname, iaasid, nodeid, hostname, service_type, runlogdir, vmlogdir):
+ def add_cloudyvent_vm(self, runname, iaasid, nodeid, hostname, service_type, parent, runlogdir, vmlogdir):
"""Add VM to db
Return True if this is new.
"""
cyvm = self.get_by_iaasid(iaasid)
if not cyvm:
- cyvm = _CYVM(runname, iaasid, nodeid, hostname, service_type, runlogdir, vmlogdir)
+ cyvm = _CYVM(runname, iaasid, nodeid, hostname, service_type, parent, runlogdir, vmlogdir)
self.session.add(cyvm)
return True
else:
cyvm.hostname = hostname
cyvm.service_type = service_type
+ cyvm.nodeid = nodeid
+ cyvm.parent = parent
return False
- def add_cloudyvent(self, runname, iaasid, nodeid, hostname, service_type, runlogdir, vmlogdir, cyv):
+ def add_cloudyvent(self, runname, iaasid, nodeid, hostname, service_type, parent, runlogdir, vmlogdir, cyv):
# first see if we already have this iaasid. if not create it
cyvm = self.get_by_iaasid(iaasid)
if not cyvm:
- cyvm = _CYVM(runname, iaasid, nodeid, hostname, service_type, runlogdir, vmlogdir)
+ cyvm = _CYVM(runname, iaasid, nodeid, hostname, service_type, parent, runlogdir, vmlogdir)
self.session.add(cyvm)
cyvm.hostname = hostname
cyvm.service_type = service_type
@@ -159,6 +163,12 @@ def get_vms_by_type(self, runname, service_type):
_CYVM.service_type == service_type)).all()
return cyvm_a
+ def get_vms_by_parent(self, runname, parent):
+ cyvm_a = self.session.query(_CYVM).filter(and_(
+ _CYVM.runname == runname,
+ _CYVM.parent == parent)).all()
+ return cyvm_a
+
def commit(self):
self.session.commit()
@@ -27,6 +27,7 @@ def setUp(self):
self.runname = "runitk"
self.iaasid = "iceicebaby"
self.nodeid = "toocold"
+ self.parent = None
self.service_type = "iaasid1"
self.hostname = "localhost"
self.runlogdir = ""
@@ -44,19 +45,19 @@ def test_file_db(self):
name = "name1"
extras['hi'] = 'there'
cye = CYvent(source, name, key, datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
def test_multiply_cms_simple(self):
extras = {}
extras['hi'] = 'there'
cye = CYvent('src1', 'name1', 'key', datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
cye = CYvent('src1', 'name1', 'key2', datetime.datetime.now(), extras)
cdb2 = CloudMiner('sqlite:///' + self.filename)
- cdb2.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ cdb2.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
cdb2.commit()
rc = self.cdb.get_events_by_runname(self.runname)
@@ -69,7 +70,7 @@ def test_multiple_cms_commit(self):
extras = {}
extras['hi'] = 'there'
cye = CYvent('src1', 'name1', 'key', datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
cdb2 = CloudMiner('sqlite:///' + self.filename)
@@ -25,6 +25,7 @@ def setUp(self):
self.iaasid = "iceicebaby"
self.nodeid = "toocold"
self.service_type = "iaasid1"
+ self.parent = None
self.hostname = "localhost"
self.runlogdir = ""
self.vmlogdir = ""
@@ -46,7 +47,7 @@ def test_iaas_query(self):
for i in range(0, event_count):
name = str(uuid.uuid1())
cye = CYvent(source, name, 'key%d' % (i), datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(runname, iaasid, nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(runname, iaasid, nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
# now get an IaaS object
@@ -64,7 +65,7 @@ def test_many_iaas_1_runname(self):
iaasid = str(uuid.uuid1())
nodeid = str(uuid.uuid1())
cye = CYvent(source, name, 'key%d' % (i), datetime.datetime.now(), None)
- self.cdb.add_cloudyvent(runname, iaasid, nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(runname, iaasid, nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
cyvm_a = self.cdb.get_events_by_runname(runname)
@@ -25,6 +25,7 @@ def setUp(self):
self.iaasid = "iaasid1"
self.nodeid = "nodeid1"
self.service_type = "iaasid1"
+ self.parent = None
self.hostname = "localhost"
self.runlogdir = ""
self.vmlogdir = ""
@@ -34,20 +35,20 @@ def tearDown(self):
def test_simple_insert_with_extra_none(self):
cye = CYvent('src1', 'name1', 'key', datetime.datetime.now(), None)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
def test_simple_insert_with_extra(self):
extras = {}
extras['hi'] = 'there'
cye = CYvent('src1', 'name1', 'key', datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
def test_simple_insert_with_extra_empty(self):
extras = {}
cye = CYvent('src1', 'name1', 'key', datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
def test_simple_query(self):
@@ -57,7 +58,7 @@ def test_simple_query(self):
name = "name1"
extras['hi'] = 'there'
cye = CYvent(source, name, key, datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
rc = self.cdb.get_events_by_runname(self.runname)
@@ -80,9 +81,9 @@ def test_man_run_query(self):
nodeid2 = "nodeid2"
extras['hi'] = 'there'
cye = CYvent(source, name, key, datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
cye = CYvent(source2, name2, key2, datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(run2, iaas2, nodeid2, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(run2, iaas2, nodeid2, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
rc = self.cdb.get_events_by_runname(self.runname)
@@ -101,22 +102,22 @@ def test_multiply_cms_simple(self):
extras = {}
extras['hi'] = 'there'
cye = CYvent('src1', 'name1', 'key', datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
cdb2 = CloudMiner('sqlite:///:memory:')
- cdb2.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ cdb2.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
cdb2.commit()
def test_multiply_cms_simple(self):
extras = {}
extras['hi'] = 'there'
cye = CYvent('src1', 'name1', 'key', datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
cdb2 = CloudMiner('sqlite:///:memory:')
- cdb2.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ cdb2.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
cdb2.commit()
rc = self.cdb.get_events_by_runname(self.runname)
@@ -131,7 +132,7 @@ def test_get_by_type(self):
e_count = 10
for i in range(0, e_count):
cye = CYvent('src1', 'name%d' % (i), 'key%d' % (i), datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.parent, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
View
@@ -8,7 +8,7 @@
import sys
py_version = 2.5
-Version=0.1
+Version=0.2
if float("%d.%d" % sys.version_info[:2]) < py_version:
sys.stderr.write("Your Python version %d.%d.%d is not supported.\n" % sys.version_info[:3])
@@ -17,13 +17,12 @@
setup(name='cloudminer',
version=Version,
- description='An persistnace API for the cloudyvents API.',
+ description='Persistence API for the cloudyvents API.',
author='Nimbus Team',
- author_email='nimbusteam@mcs.anl.gov',
+ author_email='nimbus@mcs.anl.gov',
url='http://www.nimbusproject.org/',
packages=[ 'cloudminer', 'cloudminer.tests' ],
- long_description="""
-""",
+ long_description="",
license="Apache2",
install_requires = ["nose", "cloudyvents"],
)

0 comments on commit 1e2bf6d

Please sign in to comment.