summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-08-17 17:58:52 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-08-17 17:58:52 -0700
commitcdcbd516f62290697643eecc56550460bd48ff14 (patch)
tree798d4da90b8025b041a3f2b5efe86f3e33e8ef53 /nova/compute
parent1cd448f907e132c451d6b27c64d16c17b7530952 (diff)
parent018ce9abbfb7047eff1e99379fba098a365e89eb (diff)
downloadnova-cdcbd516f62290697643eecc56550460bd48ff14.tar.gz
nova-cdcbd516f62290697643eecc56550460bd48ff14.tar.xz
nova-cdcbd516f62290697643eecc56550460bd48ff14.zip
merged trunk
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/disk.py4
-rw-r--r--nova/compute/model.py1
-rw-r--r--nova/compute/monitor.py35
-rw-r--r--nova/compute/service.py1
4 files changed, 27 insertions, 14 deletions
diff --git a/nova/compute/disk.py b/nova/compute/disk.py
index 1ffcca685..c340c5a79 100644
--- a/nova/compute/disk.py
+++ b/nova/compute/disk.py
@@ -24,6 +24,7 @@ Includes injection of SSH PGP keys into authorized_keys file.
import logging
import os
import tempfile
+
from twisted.internet import defer
from nova import exception
@@ -84,6 +85,7 @@ def partition(infile, outfile, local_bytes=0, local_type='ext2', execute=None):
yield execute('dd if=%s of=%s bs=%d seek=%d conv=notrunc,fsync'
% (infile, outfile, sector_size, primary_first))
+
@defer.inlineCallbacks
def inject_data(image, key=None, net=None, partition=None, execute=None):
"""Injects a ssh key and optionally net data into a disk image.
@@ -137,6 +139,7 @@ def inject_data(image, key=None, net=None, partition=None, execute=None):
# remove loopback
yield execute('sudo losetup -d %s' % device)
+
@defer.inlineCallbacks
def _inject_key_into_fs(key, fs, execute=None):
sshdir = os.path.join(os.path.join(fs, 'root'), '.ssh')
@@ -146,6 +149,7 @@ def _inject_key_into_fs(key, fs, execute=None):
keyfile = os.path.join(sshdir, 'authorized_keys')
yield execute('sudo tee -a %s' % keyfile, '\n' + key.strip() + '\n')
+
@defer.inlineCallbacks
def _inject_net_into_fs(net, fs, execute=None):
netfile = os.path.join(os.path.join(os.path.join(
diff --git a/nova/compute/model.py b/nova/compute/model.py
index 54d816a9c..baa41c3e0 100644
--- a/nova/compute/model.py
+++ b/nova/compute/model.py
@@ -231,6 +231,7 @@ class Daemon():
for x in cls.associated_to("host", hostname):
yield x
+
class SessionToken():
"""This is a short-lived auth token that is passed through web requests"""
diff --git a/nova/compute/monitor.py b/nova/compute/monitor.py
index 19e1a483d..268864900 100644
--- a/nova/compute/monitor.py
+++ b/nova/compute/monitor.py
@@ -24,14 +24,15 @@ Instance Monitoring:
in the object store.
"""
-import boto
-import boto.s3
import datetime
import logging
import os
-import rrdtool
import sys
import time
+
+import boto
+import boto.s3
+import rrdtool
from twisted.internet import defer
from twisted.internet import task
from twisted.application import service
@@ -41,13 +42,12 @@ from nova.virt import connection as virt_connection
FLAGS = flags.FLAGS
-flags.DEFINE_integer(
- 'monitoring_instances_delay', 5, 'Sleep time between updates')
-flags.DEFINE_integer(
- 'monitoring_instances_step', 300, 'Interval of RRD updates')
-flags.DEFINE_string(
- 'monitoring_rrd_path', '/var/nova/monitor/instances',
- 'Location of RRD files')
+flags.DEFINE_integer('monitoring_instances_delay', 5,
+ 'Sleep time between updates')
+flags.DEFINE_integer('monitoring_instances_step', 300,
+ 'Interval of RRD updates')
+flags.DEFINE_string('monitoring_rrd_path', '/var/nova/monitor/instances',
+ 'Location of RRD files')
RRD_VALUES = {
@@ -61,7 +61,7 @@ RRD_VALUES = {
'RRA:MAX:0.5:6:800',
'RRA:MAX:0.5:24:800',
'RRA:MAX:0.5:288:800',
- ],
+ ],
'net': [
'DS:rx:COUNTER:600:0:1250000',
'DS:tx:COUNTER:600:0:1250000',
@@ -73,7 +73,7 @@ RRD_VALUES = {
'RRA:MAX:0.5:6:800',
'RRA:MAX:0.5:24:800',
'RRA:MAX:0.5:288:800',
- ],
+ ],
'disk': [
'DS:rd:COUNTER:600:U:U',
'DS:wr:COUNTER:600:U:U',
@@ -85,12 +85,13 @@ RRD_VALUES = {
'RRA:MAX:0.5:6:800',
'RRA:MAX:0.5:24:800',
'RRA:MAX:0.5:444:800',
- ]
-}
+ ]
+ }
utcnow = datetime.datetime.utcnow
+
def update_rrd(instance, name, data):
"""
Updates the specified RRD file.
@@ -106,6 +107,7 @@ def update_rrd(instance, name, data):
'%d:%s' % (timestamp, data)
)
+
def init_rrd(instance, name):
"""
Initializes the specified RRD file.
@@ -124,6 +126,7 @@ def init_rrd(instance, name):
'--start', '0',
*RRD_VALUES[name]
)
+
def graph_cpu(instance, duration):
"""
@@ -148,6 +151,7 @@ def graph_cpu(instance, duration):
store_graph(instance.instance_id, filename)
+
def graph_net(instance, duration):
"""
Creates a graph of network usage for the specified instance and duration.
@@ -174,6 +178,7 @@ def graph_net(instance, duration):
)
store_graph(instance.instance_id, filename)
+
def graph_disk(instance, duration):
"""
@@ -202,6 +207,7 @@ def graph_disk(instance, duration):
store_graph(instance.instance_id, filename)
+
def store_graph(instance_id, filename):
"""
Transmits the specified graph file to internal object store on cloud
@@ -387,6 +393,7 @@ class InstanceMonitor(object, service.Service):
"""
Monitors the running instances of the current machine.
"""
+
def __init__(self):
"""
Initialize the monitoring loop.
diff --git a/nova/compute/service.py b/nova/compute/service.py
index b80ef3740..13507a1bb 100644
--- a/nova/compute/service.py
+++ b/nova/compute/service.py
@@ -29,6 +29,7 @@ import json
import logging
import os
import sys
+
from twisted.internet import defer
from twisted.internet import task