fixed based on reviewer's comment.
1. erase wrapper function(remove/exists/mktempfile) from nova.utils. 2. nova-manage service describeresource(->describe_resource) 3. nova-manage service updateresource(->update_resource) 4. erase "my mistake print" statement Additional changes are made at: 1. nova.image.s3.show 2. nova.compute.api.create that's because instances cannot launched without this changes.
This commit is contained in:
@@ -574,7 +574,7 @@ class ServiceCommands(object):
|
||||
return
|
||||
db.service_update(ctxt, svc['id'], {'disabled': True})
|
||||
|
||||
def describeresource(self, host):
|
||||
def describe_resource(self, host):
|
||||
"""describe cpu/memory/hdd info for host."""
|
||||
|
||||
result = rpc.call(context.get_admin_context(),
|
||||
@@ -606,7 +606,7 @@ class ServiceCommands(object):
|
||||
val['memory_mb'],
|
||||
val['local_gb'])
|
||||
|
||||
def updateresource(self, host):
|
||||
def update_resource(self, host):
|
||||
"""update available vcpu/memory/disk info for host."""
|
||||
|
||||
ctxt = context.get_admin_context()
|
||||
@@ -618,9 +618,9 @@ class ServiceCommands(object):
|
||||
if len(service_refs) <= 0:
|
||||
raise exception.Invalid(_('%s is not compute node.') % host)
|
||||
|
||||
result = rpc.call(ctxt,
|
||||
db.queue_get_for(ctxt, FLAGS.compute_topic, host),
|
||||
{"method": "update_available_resource"})
|
||||
rpc.call(ctxt,
|
||||
db.queue_get_for(ctxt, FLAGS.compute_topic, host),
|
||||
{"method": "update_available_resource"})
|
||||
|
||||
|
||||
class LogCommands(object):
|
||||
|
||||
@@ -103,9 +103,9 @@ class API(base.Base):
|
||||
if not is_vpn:
|
||||
image = self.image_service.show(context, image_id)
|
||||
if kernel_id is None:
|
||||
kernel_id = image.get('kernelId', None)
|
||||
kernel_id = image.get('kernel_id', None)
|
||||
if ramdisk_id is None:
|
||||
ramdisk_id = image.get('ramdiskId', None)
|
||||
ramdisk_id = image.get('ramdisk_id', None)
|
||||
# No kernel and ramdisk for raw images
|
||||
if kernel_id == str(FLAGS.null_kernel):
|
||||
kernel_id = None
|
||||
|
||||
@@ -38,6 +38,8 @@ import datetime
|
||||
import random
|
||||
import string
|
||||
import socket
|
||||
import os
|
||||
import tempfile
|
||||
import time
|
||||
import functools
|
||||
|
||||
@@ -577,14 +579,17 @@ class ComputeManager(manager.Manager):
|
||||
@exception.wrap_exception
|
||||
def mktmpfile(self, context):
|
||||
"""make tmpfile under FLAGS.instance_path."""
|
||||
return utils.mktmpfile(FLAGS.instances_path)
|
||||
fd, name = tempfile.mkstemp(dir=FLAGS.instances_path)
|
||||
# No essential reason to write dateinfo. just for debugging reason.
|
||||
os.fdopen(fd, 'w').write(str(datetime.datetime.utcnow()))
|
||||
return name
|
||||
|
||||
@exception.wrap_exception
|
||||
def confirm_tmpfile(self, context, path):
|
||||
"""Confirm existence of the tmpfile given by path."""
|
||||
if not utils.exists(path):
|
||||
if not os.path.exists(path):
|
||||
raise exception.NotFound(_('%s not found') % path)
|
||||
return utils.remove(path)
|
||||
return os.remove(path)
|
||||
|
||||
@exception.wrap_exception
|
||||
def update_available_resource(self, context):
|
||||
@@ -683,7 +688,7 @@ class ComputeManager(manager.Manager):
|
||||
Post operations for live migration.
|
||||
Mainly, database updating.
|
||||
"""
|
||||
LOG.info('post_live_migration() is started..')
|
||||
LOG.info(_('post_live_migration() is started..'))
|
||||
instance_id = instance_ref['id']
|
||||
|
||||
# Detaching volumes.
|
||||
@@ -705,7 +710,7 @@ class ComputeManager(manager.Manager):
|
||||
# Not return if fixed_ip is not found, otherwise,
|
||||
# instance never be accessible..
|
||||
if None == fixed_ip:
|
||||
logging.warn('fixed_ip is not found for %s ' % i_name)
|
||||
LOG.warn(_('fixed_ip is not found for %s.') % i_name)
|
||||
self.db.fixed_ip_update(ctxt, fixed_ip, {'host': dest})
|
||||
|
||||
try:
|
||||
|
||||
@@ -229,12 +229,3 @@ def upgrade(migrate_engine):
|
||||
networks.create_column(networks_cidr_v6)
|
||||
networks.create_column(networks_ra_server)
|
||||
services.create_column(services_availability_zone)
|
||||
#services.create_column(services_vcpus)
|
||||
#services.create_column(services_memory_mb)
|
||||
#services.create_column(services_local_gb)
|
||||
#services.create_column(services_vcpus_used)
|
||||
#services.create_column(services_memory_mb_used)
|
||||
#services.create_column(services_local_gb_used)
|
||||
#services.create_column(services_hypervisor_type)
|
||||
#services.create_column(services_hypervisor_version)
|
||||
#services.create_column(services_cpu_info)
|
||||
|
||||
@@ -94,7 +94,7 @@ class S3ImageService(service.BaseImageService):
|
||||
if FLAGS.connection_type == 'fake':
|
||||
return {'imageId': 'bar'}
|
||||
result = self.index(context)
|
||||
result = [i for i in result if i['imageId'] == image_id]
|
||||
result = [i for i in result if i['id'] == image_id]
|
||||
if not result:
|
||||
raise exception.NotFound(_('Image %s could not be found')
|
||||
% image_id)
|
||||
|
||||
@@ -60,7 +60,6 @@ class SchedulerManager(manager.Manager):
|
||||
host = getattr(self.driver, driver_method)(elevated, *args,
|
||||
**kwargs)
|
||||
except AttributeError, e:
|
||||
print 'manager.attrerr', e
|
||||
host = self.driver.schedule(elevated, topic, *args, **kwargs)
|
||||
|
||||
rpc.cast(context,
|
||||
|
||||
@@ -337,24 +337,6 @@ def str_dict_replace(s, mapping):
|
||||
return s
|
||||
|
||||
|
||||
def mktmpfile(dir):
|
||||
"""create tmpfile under dir, and return filename."""
|
||||
filename = datetime.datetime.utcnow().strftime('%Y%m%d%H%M%S')
|
||||
fpath = os.path.join(dir, filename)
|
||||
open(fpath, 'a+').write(fpath + '\n')
|
||||
return fpath
|
||||
|
||||
|
||||
def exists(filename):
|
||||
"""check file path existence."""
|
||||
return os.path.exists(filename)
|
||||
|
||||
|
||||
def remove(filename):
|
||||
"""remove file."""
|
||||
return os.remove(filename)
|
||||
|
||||
|
||||
class LazyPluggable(object):
|
||||
"""A pluggable backend loaded lazily based on some value."""
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ def inject_data(image, key=None, net=None, partition=None, nbd=False):
|
||||
|
||||
def _link_device(image, nbd):
|
||||
"""Link image to device using loopback or nbd"""
|
||||
print '_link_device:0:', nbd, '::', image
|
||||
if nbd:
|
||||
device = _allocate_device()
|
||||
utils.execute('sudo qemu-nbd -c %s %s' % (device, image))
|
||||
|
||||
@@ -977,7 +977,7 @@ class LibvirtConnection(object):
|
||||
"""
|
||||
Update compute manager resource info on Service table.
|
||||
This method is called when nova-coompute launches, and
|
||||
whenever admin executes "nova-manage service updateresource".
|
||||
whenever admin executes "nova-manage service update_resource".
|
||||
|
||||
"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user