Adds get_available_resource to hyperv driver
Fixes Bug #1048263 update_available_resource was changed to get_available_resource. This fix implements implements the method in the hyperv driver Change-Id: Id018877c563aab7f75618ada318b6422ab06c7b7
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -19,6 +19,7 @@ Test suite for the Hyper-V driver and related APIs.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
import uuid
|
||||||
@@ -151,6 +152,11 @@ class HyperVAPITestCase(basetestcase.BaseTestCase):
|
|||||||
finally:
|
finally:
|
||||||
super(HyperVAPITestCase, self).tearDown()
|
super(HyperVAPITestCase, self).tearDown()
|
||||||
|
|
||||||
|
def test_get_available_resource(self):
|
||||||
|
dic = self._conn.get_available_resource()
|
||||||
|
|
||||||
|
self.assertEquals(dic['hypervisor_hostname'], platform.node())
|
||||||
|
|
||||||
def test_list_instances(self):
|
def test_list_instances(self):
|
||||||
num_vms = self._hypervutils.get_vm_count()
|
num_vms = self._hypervutils.get_vm_count()
|
||||||
instances = self._conn.list_instances()
|
instances = self._conn.list_instances()
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ class HyperVDriver(driver.ComputeDriver):
|
|||||||
def poll_rescued_instances(self, timeout):
|
def poll_rescued_instances(self, timeout):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def update_available_resource(self, context, host):
|
def get_available_resource(self):
|
||||||
self._vmops.update_available_resource(context, host)
|
return self._vmops.get_available_resource()
|
||||||
|
|
||||||
def update_host_status(self):
|
def update_host_status(self):
|
||||||
"""See xenapi_conn.py implementation."""
|
"""See xenapi_conn.py implementation."""
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ Management class for basic VM operations.
|
|||||||
"""
|
"""
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from nova import db
|
from nova import db
|
||||||
@@ -555,23 +556,17 @@ class VMOps(baseops.BaseOps):
|
|||||||
LOG.info(_('Windows version: %s ') % version)
|
LOG.info(_('Windows version: %s ') % version)
|
||||||
return version
|
return version
|
||||||
|
|
||||||
def update_available_resource(self, context, host):
|
def get_available_resource(self):
|
||||||
"""Updates compute manager resource info on ComputeNode table.
|
"""Retrieve resource info.
|
||||||
|
|
||||||
This method is called as an periodic tasks and is used only
|
This method is called when nova-compute launches, and
|
||||||
in live migration currently.
|
as part of a periodic task.
|
||||||
|
|
||||||
:param ctxt: security context
|
:returns: dictionary describing resources
|
||||||
:param host: hostname that compute manager is currently running
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
LOG.info(_('get_available_resource called'))
|
||||||
|
|
||||||
try:
|
|
||||||
service_ref = db.service_get_all_compute_by_host(context, host)[0]
|
|
||||||
except exception.NotFound:
|
|
||||||
raise exception.ComputeServiceUnavailable(host=host)
|
|
||||||
|
|
||||||
# Updating host information
|
|
||||||
# TODO(alexpilotti) implemented cpu_info
|
# TODO(alexpilotti) implemented cpu_info
|
||||||
dic = {'vcpus': self._get_vcpu_total(),
|
dic = {'vcpus': self._get_vcpu_total(),
|
||||||
'memory_mb': self._get_memory_mb_total(),
|
'memory_mb': self._get_memory_mb_total(),
|
||||||
@@ -581,17 +576,10 @@ class VMOps(baseops.BaseOps):
|
|||||||
'local_gb_used': self._get_local_gb_used(),
|
'local_gb_used': self._get_local_gb_used(),
|
||||||
'hypervisor_type': "hyperv",
|
'hypervisor_type': "hyperv",
|
||||||
'hypervisor_version': self._get_hypervisor_version(),
|
'hypervisor_version': self._get_hypervisor_version(),
|
||||||
'cpu_info': "unknown",
|
'hypervisor_hostname': platform.node(),
|
||||||
'service_id': service_ref['id'],
|
'cpu_info': 'unknown'}
|
||||||
'disk_available_least': 1}
|
|
||||||
|
|
||||||
compute_node_ref = service_ref['compute_node']
|
return dic
|
||||||
if not compute_node_ref:
|
|
||||||
LOG.info(_('Compute_service record created for %s ') % host)
|
|
||||||
db.compute_node_create(context, dic)
|
|
||||||
else:
|
|
||||||
LOG.info(_('Compute_service record updated for %s ') % host)
|
|
||||||
db.compute_node_update(context, compute_node_ref[0]['id'], dic)
|
|
||||||
|
|
||||||
def _cache_image(self, fn, target, fname, cow=False, Size=None,
|
def _cache_image(self, fn, target, fname, cow=False, Size=None,
|
||||||
*args, **kwargs):
|
*args, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user