Merge "Add hypervisor_hostname to compute_nodes table and use it in XenServer."
This commit is contained in:
@@ -194,12 +194,12 @@ def compute_node_create(context, values):
|
|||||||
return IMPL.compute_node_create(context, values)
|
return IMPL.compute_node_create(context, values)
|
||||||
|
|
||||||
|
|
||||||
def compute_node_update(context, compute_id, values):
|
def compute_node_update(context, compute_id, values, auto_adjust=True):
|
||||||
"""Set the given properties on an computeNode and update it.
|
"""Set the given properties on an computeNode and update it.
|
||||||
|
|
||||||
Raises NotFound if computeNode does not exist.
|
Raises NotFound if computeNode does not exist.
|
||||||
"""
|
"""
|
||||||
return IMPL.compute_node_update(context, compute_id, values)
|
return IMPL.compute_node_update(context, compute_id, values, auto_adjust)
|
||||||
|
|
||||||
|
|
||||||
def compute_node_get_by_host(context, host):
|
def compute_node_get_by_host(context, host):
|
||||||
|
@@ -506,10 +506,11 @@ def compute_node_create(context, values, session=None):
|
|||||||
|
|
||||||
|
|
||||||
@require_admin_context
|
@require_admin_context
|
||||||
def compute_node_update(context, compute_id, values):
|
def compute_node_update(context, compute_id, values, auto_adjust):
|
||||||
"""Creates a new ComputeNode and populates the capacity fields
|
"""Creates a new ComputeNode and populates the capacity fields
|
||||||
with the most recent data."""
|
with the most recent data."""
|
||||||
session = get_session()
|
session = get_session()
|
||||||
|
if auto_adjust:
|
||||||
_adjust_compute_node_values_for_utilization(context, values, session)
|
_adjust_compute_node_values_for_utilization(context, values, session)
|
||||||
with session.begin(subtransactions=True):
|
with session.begin(subtransactions=True):
|
||||||
compute_ref = compute_node_get(context, compute_id, session=session)
|
compute_ref = compute_node_get(context, compute_id, session=session)
|
||||||
|
@@ -0,0 +1,33 @@
|
|||||||
|
# Copyright 2012 OpenStack, LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from sqlalchemy import *
|
||||||
|
|
||||||
|
|
||||||
|
meta = MetaData()
|
||||||
|
|
||||||
|
compute_nodes = Table("compute_nodes", meta, Column("id", Integer(),
|
||||||
|
primary_key=True, nullable=False))
|
||||||
|
|
||||||
|
hypervisor_hostname = Column("hypervisor_hostname", String(255))
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade(migrate_engine):
|
||||||
|
meta.bind = migrate_engine
|
||||||
|
compute_nodes.create_column(hypervisor_hostname)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade(migrate_engine):
|
||||||
|
meta.bind = migrate_engine
|
||||||
|
compute_nodes.drop_column(hypervisor_hostname)
|
@@ -135,6 +135,7 @@ class ComputeNode(BASE, NovaBase):
|
|||||||
local_gb_used = Column(Integer)
|
local_gb_used = Column(Integer)
|
||||||
hypervisor_type = Column(Text)
|
hypervisor_type = Column(Text)
|
||||||
hypervisor_version = Column(Integer)
|
hypervisor_version = Column(Integer)
|
||||||
|
hypervisor_hostname = Column(String(255))
|
||||||
|
|
||||||
# Free Ram, amount of activity (resize, migration, boot, etc) and
|
# Free Ram, amount of activity (resize, migration, boot, etc) and
|
||||||
# the number of running VM's are a good starting point for what's
|
# the number of running VM's are a good starting point for what's
|
||||||
|
@@ -181,6 +181,8 @@ class XenAPIConnection(driver.ComputeDriver):
|
|||||||
self._initiator = None
|
self._initiator = None
|
||||||
self._pool = pool.ResourcePool(self._session)
|
self._pool = pool.ResourcePool(self._session)
|
||||||
|
|
||||||
|
self._capture_dom0_hostname()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host_state(self):
|
def host_state(self):
|
||||||
if not self._host_state:
|
if not self._host_state:
|
||||||
@@ -194,6 +196,22 @@ class XenAPIConnection(driver.ComputeDriver):
|
|||||||
#e.g. to do session logout?
|
#e.g. to do session logout?
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _capture_dom0_hostname(self):
|
||||||
|
"""Find dom0's hostname and log it to the DB."""
|
||||||
|
ctxt = context.get_admin_context()
|
||||||
|
service = db.service_get_by_host_and_topic(ctxt, FLAGS.host, "compute")
|
||||||
|
|
||||||
|
try:
|
||||||
|
compute_node = db.compute_node_get_for_service(ctxt, service["id"])
|
||||||
|
except TypeError:
|
||||||
|
return
|
||||||
|
|
||||||
|
host_stats = self.get_host_stats()
|
||||||
|
|
||||||
|
db.compute_node_update(ctxt, compute_node["id"],
|
||||||
|
{"hypervisor_hostname": host_stats["host_hostname"]},
|
||||||
|
auto_adjust=False)
|
||||||
|
|
||||||
def list_instances(self):
|
def list_instances(self):
|
||||||
"""List VM instances"""
|
"""List VM instances"""
|
||||||
return self._vmops.list_instances()
|
return self._vmops.list_instances()
|
||||||
@@ -390,7 +408,6 @@ class XenAPIConnection(driver.ComputeDriver):
|
|||||||
:param host: hostname that compute manager is currently running
|
:param host: hostname that compute manager is currently running
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
|
service_ref = db.service_get_all_compute_by_host(ctxt, host)[0]
|
||||||
except exception.NotFound:
|
except exception.NotFound:
|
||||||
|
Reference in New Issue
Block a user