fix bugs
Change-Id: Ic2d839670f9723e8f64fda37bd028e4a9ae3caf8
This commit is contained in:
parent
5150166d82
commit
6664d593a1
@ -33,7 +33,7 @@ def deploy(cluster_id, hosts_id_list, username=None):
|
||||
.. note::
|
||||
The function should be called out of database session.
|
||||
"""
|
||||
with util.lock('serialized_action') as lock:
|
||||
with util.lock('serialized_action', timeout=1000) as lock:
|
||||
if not lock:
|
||||
raise Exception('failed to acquire lock to deploy')
|
||||
|
||||
|
@ -90,9 +90,15 @@ def update_progress(cluster_hosts):
|
||||
|
||||
adapter = cluster.adapter
|
||||
os_installer = adapter.adapter_os_installer
|
||||
os_installer_name = os_installer.instance_name
|
||||
if os_installer:
|
||||
os_installer_name = os_installer.name
|
||||
else:
|
||||
os_installer_name = None
|
||||
package_installer = adapter.adapter_package_installer
|
||||
package_installer_name = package_installer.instance_name
|
||||
if package_installer:
|
||||
package_installer_name = package_installer.name
|
||||
else:
|
||||
package_installer_name = None
|
||||
|
||||
distributed_system_name = cluster.distributed_system_name
|
||||
os_name = cluster.os_name
|
||||
@ -103,6 +109,19 @@ def update_progress(cluster_hosts):
|
||||
hostids = [clusterhost.host.id for clusterhost in clusterhosts]
|
||||
cluster_hosts.update({clusterid: hostids})
|
||||
|
||||
logging.info(
|
||||
'update progress for '
|
||||
'os_installer_name %s,'
|
||||
'os_names %s,'
|
||||
'package_installer_name %s,'
|
||||
'distributed_systems %s,'
|
||||
'cluster_hosts %s',
|
||||
os_installer_name,
|
||||
os_names,
|
||||
package_installer_name,
|
||||
distributed_systems,
|
||||
cluster_hosts
|
||||
)
|
||||
progress_calculator.update_progress(
|
||||
os_installer_name,
|
||||
os_names,
|
||||
|
@ -29,9 +29,11 @@ from compass.db import models
|
||||
def lock(lock_name, blocking=True, timeout=10):
|
||||
redis_instance = redis.Redis()
|
||||
instance_lock = redis_instance.lock(lock_name, timeout=timeout)
|
||||
owned = False
|
||||
try:
|
||||
locked = instance_lock.acquire(blocking=blocking)
|
||||
if locked:
|
||||
owned = True
|
||||
logging.debug('acquired lock %s', lock_name)
|
||||
yield instance_lock
|
||||
else:
|
||||
@ -45,9 +47,13 @@ def lock(lock_name, blocking=True, timeout=10):
|
||||
yield None
|
||||
|
||||
finally:
|
||||
if owned:
|
||||
instance_lock.acquired_until = 0
|
||||
instance_lock.release()
|
||||
logging.debug('released lock %s', lock_name)
|
||||
else:
|
||||
logging.debug('nothing to release %s', lock_name)
|
||||
|
||||
|
||||
"""
|
||||
def update_cluster_hosts(cluster_hosts,
|
||||
|
@ -88,8 +88,8 @@ def get_subnet(
|
||||
)
|
||||
@utils.wrap_to_dict(RESP_FIELDS)
|
||||
def add_subnet(
|
||||
session, creator, subnet,
|
||||
exception_when_existing=True, **kwargs
|
||||
session, creator, exception_when_existing=True,
|
||||
subnet=None, **kwargs
|
||||
):
|
||||
"""Create a subnet."""
|
||||
return utils.add_db_object(
|
||||
|
@ -586,6 +586,7 @@ class ClusterHost(BASE, TimestampMixin, HelperMixin):
|
||||
host.state.state != 'SUCCESSFUL'
|
||||
):
|
||||
return host.state_dict()
|
||||
else:
|
||||
return self.state.to_dict()
|
||||
|
||||
def to_dict(self):
|
||||
@ -598,9 +599,11 @@ class ClusterHost(BASE, TimestampMixin, HelperMixin):
|
||||
'owner': self.owner,
|
||||
'clustername': self.clustername,
|
||||
'hostname': self.hostname,
|
||||
'name': self.name,
|
||||
'roles': [role.to_dict() for role in self.roles]
|
||||
'name': self.name
|
||||
})
|
||||
roles = self.roles
|
||||
if roles:
|
||||
dict_info['roles'] = [role.to_dict() for role in roles]
|
||||
return dict_info
|
||||
|
||||
|
||||
|
@ -89,9 +89,13 @@ class OSMatcher(object):
|
||||
|
||||
def match(self, os_installer_name, os_name):
|
||||
"""Check if the os matcher is acceptable."""
|
||||
if os_name is None:
|
||||
return False
|
||||
else:
|
||||
return all([
|
||||
self.name_ == os_installer_name,
|
||||
self.os_regex_.match(os_name)])
|
||||
self.os_regex_.match(os_name)
|
||||
])
|
||||
|
||||
def update_progress(self, fullname, progress):
|
||||
"""Update progress."""
|
||||
@ -123,9 +127,13 @@ class PackageMatcher(object):
|
||||
|
||||
def match(self, package_installer_name, target_system):
|
||||
"""Check if the package matcher is acceptable."""
|
||||
if package_installer_name is None:
|
||||
return False
|
||||
else:
|
||||
return all([
|
||||
self.name_.match(package_installer_name),
|
||||
self.target_system_ == target_system])
|
||||
self.target_system_ == target_system
|
||||
])
|
||||
|
||||
def update_progress(self, fullname, progress):
|
||||
"""Update progress."""
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "$host.name",
|
||||
"name": "$host.hostname",
|
||||
"hostname": "$host.hostname",
|
||||
"profile": "$host.profile",
|
||||
"gateway": "$host.gateway",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "$host.name",
|
||||
"name": "$host.hostname",
|
||||
"hostname": "$host.hostname",
|
||||
"profile": "$host.profile",
|
||||
"gateway": "$host.gateway",
|
||||
|
Loading…
x
Reference in New Issue
Block a user