Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added nodeid field, an internal instance ID different from IaaS

  • Loading branch information...
commit 7c70b74139542929188bd89fcafa3d81b228e4dc 1 parent d8714ee
@timf timf authored
View
12 cloudminer/cloudminer.py
@@ -28,9 +28,10 @@ def __init__(self, source, name, key, timestamp, extra):
class _CYVM(object):
- def __init__(self, runname, iaasid, hostname, service_type, runlogdir, vmlogdir, events=None):
+ def __init__(self, runname, iaasid, nodeid, hostname, service_type, runlogdir, vmlogdir, events=None):
self.runname = runname
self.iaasid = iaasid
+ self.nodeid = nodeid
if events:
self.events = events
else:
@@ -49,6 +50,7 @@ def add_event(self, e):
Column('id', Integer, Sequence('event_id_seq'), primary_key=True),
Column('runname', String(50)),
Column('iaasid', String(50), unique=True),
+ Column('nodeid', String(128), unique=True),
Column('hostname', String(128)),
Column('service_type', String(128)),
Column('runlogdir', String(128)),
@@ -89,13 +91,13 @@ def __init__(self, dburl, module=None):
self.Session = sessionmaker(bind=self.engine)
self.session = self.Session()
- def add_cloudyvent_vm(self, runname, iaasid, hostname, service_type, runlogdir, vmlogdir):
+ def add_cloudyvent_vm(self, runname, iaasid, nodeid, hostname, service_type, 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, hostname, service_type, runlogdir, vmlogdir)
+ cyvm = _CYVM(runname, iaasid, nodeid, hostname, service_type, runlogdir, vmlogdir)
self.session.add(cyvm)
return True
else:
@@ -104,12 +106,12 @@ def add_cloudyvent_vm(self, runname, iaasid, hostname, service_type, runlogdir,
return False
- def add_cloudyvent(self, runname, iaasid, hostname, service_type, runlogdir, vmlogdir, cyv):
+ def add_cloudyvent(self, runname, iaasid, nodeid, hostname, service_type, 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, hostname, service_type, runlogdir, vmlogdir)
+ cyvm = _CYVM(runname, iaasid, nodeid, hostname, service_type, runlogdir, vmlogdir)
self.session.add(cyvm)
cyvm.hostname = hostname
cyvm.service_type = service_type
View
9 cloudminer/tests/test_filedb_cm.py
@@ -26,6 +26,7 @@ def setUp(self):
self.cdb = CloudMiner('sqlite:///' + self.filename)
self.runname = "runitk"
self.iaasid = "iceicebaby"
+ self.nodeid = "toocold"
self.service_type = "iaasid1"
self.hostname = "localhost"
self.runlogdir = ""
@@ -43,19 +44,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.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.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.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.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.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ cdb2.add_cloudyvent(self.runname, self.iaasid, self.nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
cdb2.commit()
rc = self.cdb.get_events_by_runname(self.runname)
@@ -68,7 +69,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.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.runlogdir, self.vmlogdir, cye)
cdb2 = CloudMiner('sqlite:///' + self.filename)
View
7 cloudminer/tests/test_iaasid_cm.py
@@ -23,6 +23,7 @@ def setUp(self):
self.cdb = CloudMiner('sqlite:///:memory:')
self.runname = "run1"
self.iaasid = "iceicebaby"
+ self.nodeid = "toocold"
self.service_type = "iaasid1"
self.hostname = "localhost"
self.runlogdir = ""
@@ -37,6 +38,7 @@ def test_iaas_query(self):
extras['hi'] = 'there'
runname = str(uuid.uuid1())
iaasid = str(uuid.uuid1())
+ nodeid = str(uuid.uuid1())
source = "src"
event_count = 10
@@ -44,7 +46,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, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(runname, iaasid, nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
# now get an IaaS object
@@ -60,8 +62,9 @@ def test_many_iaas_1_runname(self):
for i in range(0, vm_count):
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, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(runname, iaasid, nodeid, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
cyvm_a = self.cdb.get_events_by_runname(runname)
View
24 cloudminer/tests/test_simple_cm.py
@@ -23,6 +23,7 @@ def setUp(self):
self.cdb = CloudMiner('sqlite:///:memory:')
self.runname = "run1"
self.iaasid = "iaasid1"
+ self.nodeid = "nodeid1"
self.service_type = "iaasid1"
self.hostname = "localhost"
self.runlogdir = ""
@@ -33,20 +34,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.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.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.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.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.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.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
def test_simple_query(self):
@@ -56,7 +57,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.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.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
rc = self.cdb.get_events_by_runname(self.runname)
@@ -76,11 +77,12 @@ def test_man_run_query(self):
source2 = "src2"
name2 = "name2"
iaas2 = "iaas2"
+ nodeid2 = "nodeid2"
extras['hi'] = 'there'
cye = CYvent(source, name, key, datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(self.runname, self.iaasid, 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.runlogdir, self.vmlogdir, cye)
cye = CYvent(source2, name2, key2, datetime.datetime.now(), extras)
- self.cdb.add_cloudyvent(run2, iaas2, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
+ self.cdb.add_cloudyvent(run2, iaas2, nodeid2, self.hostname, self.service_type, self.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
rc = self.cdb.get_events_by_runname(self.runname)
@@ -99,22 +101,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.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.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
cdb2 = CloudMiner('sqlite:///:memory:')
- cdb2.add_cloudyvent(self.runname, self.iaasid, 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.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.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.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
cdb2 = CloudMiner('sqlite:///:memory:')
- cdb2.add_cloudyvent(self.runname, self.iaasid, 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.runlogdir, self.vmlogdir, cye)
cdb2.commit()
rc = self.cdb.get_events_by_runname(self.runname)
@@ -129,7 +131,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.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.runlogdir, self.vmlogdir, cye)
self.cdb.commit()
Please sign in to comment.
Something went wrong with that request. Please try again.