API: Change the API cpu_info to be meaning ful.

Currently the API sample get '?' for the cpu_info, this is really
confusing, it even does not tell the type of the return.

Change it to be more meaningful.

Change-Id: I791beb7502f47dff646a46c08e818c29f9e6cd79
This commit is contained in:
yunhong jiang 2015-02-12 14:35:46 -08:00
parent 0a3201dc7e
commit ab437c0e90
18 changed files with 45 additions and 18 deletions

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": 0,
"host_ip": "1.1.1.1",

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": 0,
"free_disk_gb": 1028,

View File

@ -1,7 +1,7 @@
{
"hypervisors": [
{
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": null,
"free_disk_gb": 1028,

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": 0,
"free_disk_gb": 1028,

View File

@ -1,7 +1,7 @@
{
"hypervisors": [
{
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"status": "enabled",
"state": "up",

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"state": "up",
"status": "enabled",
"current_workload": 0,

View File

@ -1,7 +1,7 @@
{
"hypervisors": [
{
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"state": "up",
"status": "enabled",
"current_workload": 0,

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": 0,
"host_ip": "1.1.1.1",

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": 0,
"host_ip": "%(ip)s",

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": 0,
"free_disk_gb": 1028,

View File

@ -1,7 +1,7 @@
{
"hypervisors": [
{
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": null,
"host_ip": "%(ip)s",

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": 0,
"free_disk_gb": 1028,

View File

@ -1,7 +1,7 @@
{
"hypervisors": [
{
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"state": "up",
"status": "enabled",

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"disk_available_least": 0,
"state": "up",

View File

@ -1,7 +1,7 @@
{
"hypervisors": [
{
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"state": "up",
"status": "enabled",
"current_workload": 0,

View File

@ -1,6 +1,6 @@
{
"hypervisor": {
"cpu_info": "?",
"cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
"current_workload": 0,
"state": "up",
"status": "enabled",

View File

@ -12,7 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import collections
import mock
from oslo_serialization import jsonutils
from nova import db
from nova import objects
@ -86,8 +89,19 @@ class ExtendedHyervisorPciSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
def setUp(self):
super(ExtendedHyervisorPciSampleJsonTest, self).setUp()
cpu_info = collections.OrderedDict([
('arch', 'x86_64'),
('model', 'Nehalem'),
('vendor', 'Intel'),
('features', ['pge', 'clflush']),
('topology', {
'cores': 1,
'threads': 1,
'sockets': 4,
}),
])
self.fake_compute_node = objects.ComputeNode(
cpu_info="?",
cpu_info=jsonutils.dumps(cpu_info),
current_workload=0,
disk_available_least=0,
host_ip="1.1.1.1",

View File

@ -23,6 +23,7 @@ semantics of real hypervisor connections.
"""
import collections
import contextlib
from oslo_config import cfg
@ -392,6 +393,18 @@ class FakeDriver(driver.ComputeDriver):
Since we don't have a real hypervisor, pretend we have lots of
disk and ram.
"""
cpu_info = collections.OrderedDict([
('arch', 'x86_64'),
('model', 'Nehalem'),
('vendor', 'Intel'),
('features', ['pge', 'clflush']),
('topology', {
'cores': 1,
'threads': 1,
'sockets': 4,
}),
])
if nodename not in _FAKE_NODES:
return {}
@ -399,7 +412,7 @@ class FakeDriver(driver.ComputeDriver):
host_status['hypervisor_hostname'] = nodename
host_status['host_hostname'] = nodename
host_status['host_name_label'] = nodename
host_status['cpu_info'] = '?'
host_status['cpu_info'] = jsonutils.dumps(cpu_info)
return host_status
def ensure_filtering_rules_for_instance(self, instance, network_info):