Merge lp:~jk0/nova/diagnostics-per-instance into lp:~hudson-openstack/nova/trunk

Proposed by Josh Kearney
Status: Merged
Approved by: Jay Pipes
Approved revision: 471
Merged at revision: 472
Proposed branch: lp:~jk0/nova/diagnostics-per-instance
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 78 lines (+33/-10)
2 files modified
nova/db/sqlalchemy/models.py (+32/-5)
nova/virt/xenapi/vm_utils.py (+1/-5)
To merge this branch: bzr merge lp:~jk0/nova/diagnostics-per-instance
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Vish Ishaya (community) Approve
Review via email: mp+44251@code.launchpad.net

Commit message

Added InstanceDiagnostics and InstanceActions DB models.

Description of the change

Added InstanceDiagnostics and InstanceActions DB models. I'm proposing this small merge now to get a validation before building anything on top of them yet.

To post a comment you must log in.
Revision history for this message
Vish Ishaya (vishvananda) wrote :

Discussion from irc:

jk0: it's for this BP: https://blueprints.launchpad.net/nova/+spec/diagnostics-per-instance
[10:13am] vishy: jk0: this ultimately needs to be a message passed back from compute
[10:14am] vishy: jk0: I'm not convinced that we want that stuff in a database long term
[10:14am] vishy: jk0: but i suppose it can go in there initially
[10:15am] jk0: I'd have to rethink how we'd do that
[10:16am] vishy: jk0: eday is working on that piece for the distributed data model
[10:16am] jk0: do you think we should hold off on this until that is in place?
[10:17am] jk0: or would it make sense to keep going and refactor later on
[10:17am] vishy: jk0: just make sure that it is easy to pass the relevant data as a message, since we're trying to stop computes from writing directly to the database.

I think moving ahead with this is fine for now as long as we have a clear way to pass the updates through the queue so that ultimately the computes are not writing directly to the db.

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

Hi!

23 + vbd_xvda_read = Column(Float)
24 + vbd_xvda_write = Column(Float)
25 + vbd_xvdb_read = Column(Float)
26 + vbd_xvdb_write = Column(Float)
27 + memory = Column(Float)
28 + memory_internal_free = Column(Float)
29 + cpu0 = Column(Float)
30 + vif_0_tx = Column(Float)
31 + vif_0_rx = Column(Float)

This seems very specific to the XenAPI. Any way to make it less specific? Also, adding columns for xvda and xvdb seems to be non-normalized... is this specific to the XenAPI or is this saying that 2 block devices named xvda and xvdb will *always* be present and will be the *only* block devices on an Instance?

Cheers!
jay

review: Needs Information
Revision history for this message
Josh Kearney (jk0) wrote :

Yeah, these columns are actually verbatim to what the XenAPI returns for an instance.

I'm not sure exactly how we're going to be setting up the block devices, so for now I can just remove those columns and give the others a more generic name.

470. By Josh Kearney

Make column names more generic

471. By Josh Kearney

Merged trunk

Revision history for this message
Jay Pipes (jaypipes) wrote :

w00t. :)

review: Approve
472. By Josh Kearney

PEP8 cleanup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/db/sqlalchemy/models.py'
2--- nova/db/sqlalchemy/models.py 2010-12-03 21:50:30 +0000
3+++ nova/db/sqlalchemy/models.py 2010-12-21 17:15:10 +0000
4@@ -22,7 +22,7 @@
5 import datetime
6
7 from sqlalchemy.orm import relationship, backref, object_mapper
8-from sqlalchemy import Column, Integer, String, schema
9+from sqlalchemy import Column, Integer, Float, String, schema
10 from sqlalchemy import ForeignKey, DateTime, Boolean, Text
11 from sqlalchemy.exc import IntegrityError
12 from sqlalchemy.ext.declarative import declarative_base
13@@ -226,6 +226,32 @@
14 # 'shutdown', 'shutoff', 'crashed'])
15
16
17+class InstanceDiagnostics(BASE, NovaBase):
18+ """Represents a guest VM's diagnostics"""
19+ __tablename__ = "instance_diagnostics"
20+ id = Column(Integer, primary_key=True)
21+ instance_id = Column(Integer, ForeignKey('instances.id'))
22+
23+ memory_available = Column(Float)
24+ memory_free = Column(Float)
25+ cpu_load = Column(Float)
26+ disk_read = Column(Float)
27+ disk_write = Column(Float)
28+ net_tx = Column(Float)
29+ net_rx = Column(Float)
30+
31+
32+class InstanceActions(BASE, NovaBase):
33+ """Represents a guest VM's actions and results"""
34+ __tablename__ = "instance_actions"
35+ id = Column(Integer, primary_key=True)
36+ instance_id = Column(Integer, ForeignKey('instances.id'))
37+
38+ action = Column(String(255))
39+ result = Column(Boolean)
40+ error = Column(Text)
41+
42+
43 class Volume(BASE, NovaBase):
44 """Represents a block storage device that can be attached to a vm."""
45 __tablename__ = 'volumes'
46@@ -526,10 +552,11 @@
47 it will never need to be called explicitly elsewhere.
48 """
49 from sqlalchemy import create_engine
50- models = (Service, Instance, Volume, ExportDevice, IscsiTarget, FixedIp,
51- FloatingIp, Network, SecurityGroup,
52- SecurityGroupIngressRule, SecurityGroupInstanceAssociation,
53- AuthToken, User, Project) # , Image, Host
54+ models = (Service, Instance, InstanceDiagnostics, InstanceActions,
55+ Volume, ExportDevice, IscsiTarget, FixedIp, FloatingIp,
56+ Network, SecurityGroup, SecurityGroupIngressRule,
57+ SecurityGroupInstanceAssociation, AuthToken, User,
58+ Project) # , Image, Host
59 engine = create_engine(FLAGS.sql_connection, echo=False)
60 for model in models:
61 model.metadata.create_all(engine)
62
63=== modified file 'nova/virt/xenapi/vm_utils.py'
64--- nova/virt/xenapi/vm_utils.py 2010-12-20 20:26:59 +0000
65+++ nova/virt/xenapi/vm_utils.py 2010-12-21 17:15:10 +0000
66@@ -229,11 +229,7 @@
67 try:
68 host = session.get_xenapi_host()
69 host_ip = session.get_xenapi().host.get_record(host)["address"]
70- metrics = session.get_xenapi().VM_guest_metrics.get_record(
71- record["guest_metrics"])
72- diags = {
73- "Kernel": metrics["os_version"]["uname"],
74- "Distro": metrics["os_version"]["name"]}
75+ diags = {}
76 xml = get_rrd(host_ip, record["uuid"])
77 if xml:
78 rrd = minidom.parseString(xml)