summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChiradeep Vittal <chiradeep@chiradeep-lt2>2011-01-04 15:18:28 -0800
committerChiradeep Vittal <chiradeep@chiradeep-lt2>2011-01-04 15:18:28 -0800
commit468bc4745f002b521f21c5d621bdcb596b8ddfcd (patch)
tree6a30bc9c77fde37747580c480d92da4737e75842
parent1e28685abe25cc3c1ce4d81794ec8c373111fc13 (diff)
downloadnova-468bc4745f002b521f21c5d621bdcb596b8ddfcd.tar.gz
nova-468bc4745f002b521f21c5d621bdcb596b8ddfcd.tar.xz
nova-468bc4745f002b521f21c5d621bdcb596b8ddfcd.zip
Merge from trunk again -- get rid of twistd dependencies
-rw-r--r--nova/twistd.py39
-rw-r--r--nova/virt/hyperv.py30
-rw-r--r--nova/virt/images.py6
3 files changed, 38 insertions, 37 deletions
diff --git a/nova/twistd.py b/nova/twistd.py
index 22e2d06d3..1dd10dbb5 100644
--- a/nova/twistd.py
+++ b/nova/twistd.py
@@ -237,26 +237,25 @@ def serve(filename):
logging.getLogger('amqplib').setLevel(logging.WARN)
FLAGS.python = filename
FLAGS.no_save = True
- if sys.platform != 'win32':
- if not FLAGS.pidfile:
- FLAGS.pidfile = '%s.pid' % name
- elif FLAGS.pidfile.endswith('twistd.pid'):
- FLAGS.pidfile = FLAGS.pidfile.replace('twistd.pid',
- '%s.pid' % name)
- # NOTE(vish): if we're running nodaemon, redirect the log to stdout
- if FLAGS.nodaemon and not FLAGS.logfile:
- FLAGS.logfile = "-"
- if not FLAGS.logfile:
- FLAGS.logfile = '%s.log' % name
- elif FLAGS.logfile.endswith('twistd.log'):
- FLAGS.logfile = FLAGS.logfile.replace('twistd.log',
- '%s.log' % name)
- if FLAGS.logdir:
- FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile)
- if not FLAGS.prefix:
- FLAGS.prefix = name
- elif FLAGS.prefix.endswith('twisted'):
- FLAGS.prefix = FLAGS.prefix.replace('twisted', name)
+ if not FLAGS.pidfile:
+ FLAGS.pidfile = '%s.pid' % name
+ elif FLAGS.pidfile.endswith('twistd.pid'):
+ FLAGS.pidfile = FLAGS.pidfile.replace('twistd.pid',
+ '%s.pid' % name)
+ # NOTE(vish): if we're running nodaemon, redirect the log to stdout
+ if FLAGS.nodaemon and not FLAGS.logfile:
+ FLAGS.logfile = "-"
+ if not FLAGS.logfile:
+ FLAGS.logfile = '%s.log' % name
+ elif FLAGS.logfile.endswith('twistd.log'):
+ FLAGS.logfile = FLAGS.logfile.replace('twistd.log',
+ '%s.log' % name)
+ if FLAGS.logdir:
+ FLAGS.logfile = os.path.join(FLAGS.logdir, FLAGS.logfile)
+ if not FLAGS.prefix:
+ FLAGS.prefix = name
+ elif FLAGS.prefix.endswith('twisted'):
+ FLAGS.prefix = FLAGS.prefix.replace('twisted', name)
action = 'start'
if len(argv) > 1:
diff --git a/nova/virt/hyperv.py b/nova/virt/hyperv.py
index a254aaf8a..6aeeb0837 100644
--- a/nova/virt/hyperv.py
+++ b/nova/virt/hyperv.py
@@ -64,8 +64,6 @@ import os
import logging
import time
-from twisted.internet import defer
-
from nova import exception
from nova import flags
from nova.auth import manager
@@ -112,16 +110,20 @@ class HyperVConnection(object):
self._conn = wmi.WMI(moniker='//./root/virtualization')
self._cim_conn = wmi.WMI(moniker='//./root/cimv2')
+ def init_host(self):
+ #FIXME(chiradeep): implement this
+ logging.debug('In init host')
+ pass
+
def list_instances(self):
""" Return the names of all the instances known to Hyper-V. """
vms = [v.ElementName \
for v in self._conn.Msvm_ComputerSystem(['ElementName'])]
return vms
- @defer.inlineCallbacks
def spawn(self, instance):
""" Create a new VM and start it."""
- vm = yield self._lookup(instance.name)
+ vm = self._lookup(instance.name)
if vm is not None:
raise exception.Duplicate('Attempted to create duplicate name %s' %
instance.name)
@@ -130,18 +132,18 @@ class HyperVConnection(object):
project = manager.AuthManager().get_project(instance['project_id'])
#Fetch the file, assume it is a VHD file.
base_vhd_filename = os.path.join(FLAGS.instances_path,
- instance['str_id'])
+ instance.name)
vhdfile = "%s.vhd" % (base_vhd_filename)
- yield images.fetch(instance['image_id'], vhdfile, user, project)
+ images.fetch(instance['image_id'], vhdfile, user, project)
try:
- yield self._create_vm(instance)
+ self._create_vm(instance)
- yield self._create_disk(instance['name'], vhdfile)
- yield self._create_nic(instance['name'], instance['mac_address'])
+ self._create_disk(instance['name'], vhdfile)
+ self._create_nic(instance['name'], instance['mac_address'])
logging.debug('Starting VM %s ', instance.name)
- yield self._set_vm_state(instance['name'], 'Enabled')
+ self._set_vm_state(instance['name'], 'Enabled')
logging.info('Started VM %s ', instance.name)
except Exception as exn:
logging.error('spawn vm failed: %s', exn)
@@ -341,21 +343,19 @@ class HyperVConnection(object):
wmi_obj.Properties_.Item(prop).Value
return newinst
- @defer.inlineCallbacks
def reboot(self, instance):
"""Reboot the specified instance."""
- vm = yield self._lookup(instance.name)
+ vm = self._lookup(instance.name)
if vm is None:
raise exception.NotFound('instance not present %s' % instance.name)
self._set_vm_state(instance.name, 'Reboot')
- @defer.inlineCallbacks
def destroy(self, instance):
"""Destroy the VM. Also destroy the associated VHD disk files"""
logging.debug("Got request to destroy vm %s", instance.name)
- vm = yield self._lookup(instance.name)
+ vm = self._lookup(instance.name)
if vm is None:
- defer.returnValue(None)
+ return
vm = self._conn.Msvm_ComputerSystem(ElementName=instance.name)[0]
vs_man_svc = self._conn.Msvm_VirtualSystemManagementService()[0]
#Stop the VM first.
diff --git a/nova/virt/images.py b/nova/virt/images.py
index bd7426ad0..417197538 100644
--- a/nova/virt/images.py
+++ b/nova/virt/images.py
@@ -60,7 +60,9 @@ def _fetch_image_no_curl(url, path, headers):
while 1:
data = urlfile.read(chunk)
if not data:
- break f.write(data)
+ break
+ f.write(data)
+
urlopened = urllib2.urlopen(request)
urlretrieve(urlopened, path)
logging.debug("Finished retreving %s -- placed in %s", url, path)
@@ -68,7 +70,6 @@ def _fetch_image_no_curl(url, path, headers):
def _fetch_s3_image(image, path, user, project):
url = image_url(image)
-
# This should probably move somewhere else, like e.g. a download_as
# method on User objects and at the same time get rewritten to use
# a web client.
@@ -88,6 +89,7 @@ def _fetch_s3_image(image, path, user, project):
cmd = ['/usr/bin/curl', '--fail', '--silent', url]
for (k, v) in headers.iteritems():
cmd += ['-H', '%s: %s' % (k, v)]
+
cmd += ['-o', path]
cmd_out = ' '.join(cmd)
return utils.execute(cmd_out)