Merge "fix bug" into dev/experimental

This commit is contained in:
Jenkins
2014-08-12 02:57:03 +00:00
committed by Gerrit Code Review
4 changed files with 34 additions and 30 deletions

View File

@@ -39,9 +39,10 @@ RESP_FIELDS = [
'created_at', 'updated_at' 'created_at', 'updated_at'
] ]
RESP_CLUSTERHOST_FIELDS = [ RESP_CLUSTERHOST_FIELDS = [
'id', 'host_id', 'machine_id', 'name', 'hostname', 'id', 'host_id', 'clusterhost_id', 'machine_id',
'name', 'hostname',
'cluster_id', 'clustername', 'location', 'tag', 'cluster_id', 'clustername', 'location', 'tag',
'networks', 'mac', 'networks', 'mac', 'switch_ip', 'port', 'switches',
'os_installed', 'distributed_system_installed', 'os_installed', 'distributed_system_installed',
'os_name', 'distributed_system_name', 'os_name', 'distributed_system_name',
'reinstall_os', 'reinstall_distributed_system', 'reinstall_os', 'reinstall_distributed_system',
@@ -557,7 +558,7 @@ def get_clusterhost(
return utils.get_db_object( return utils.get_db_object(
session, models.ClusterHost, session, models.ClusterHost,
exception_when_missing, exception_when_missing,
id=clusterhost_id clusterhost_id=clusterhost_id
) )
@@ -611,7 +612,7 @@ def del_clusterhost(session, deleter, clusterhost_id, **kwargs):
"""Delete cluster host.""" """Delete cluster host."""
clusterhost = utils.get_db_object( clusterhost = utils.get_db_object(
session, models.ClusterHost, session, models.ClusterHost,
id=clusterhost_id clusterhost_id=clusterhost_id
) )
return utils.del_db_object( return utils.del_db_object(
session, clusterhost session, clusterhost
@@ -657,7 +658,7 @@ def get_cluster_host_deployed_config(
def get_clusterhost_config(session, getter, clusterhost_id, **kwargs): def get_clusterhost_config(session, getter, clusterhost_id, **kwargs):
"""Get clusterhost config.""" """Get clusterhost config."""
return utils.get_db_object( return utils.get_db_object(
session, models.ClusterHost, id=clusterhost_id session, models.ClusterHost, clusterhost_id=clusterhost_id
) )
@@ -670,7 +671,7 @@ def get_clusterhost_config(session, getter, clusterhost_id, **kwargs):
def get_clusterhost_deployed_config(session, getter, clusterhost_id, **kwargs): def get_clusterhost_deployed_config(session, getter, clusterhost_id, **kwargs):
"""Get clusterhost deployed config.""" """Get clusterhost deployed config."""
return utils.get_db_object( return utils.get_db_object(
session, models.ClusterHost, id=clusterhost_id session, models.ClusterHost, clusterhost_id=clusterhost_id
) )
@@ -805,7 +806,7 @@ def update_clusterhost_config(
): ):
"""Update clusterhost config.""" """Update clusterhost config."""
clusterhost = utils.get_db_object( clusterhost = utils.get_db_object(
session, models.ClusterHost, id=clusterhost_id session, models.ClusterHost, clusterhost_id=clusterhost_id
) )
return _update_clusterhost_config( return _update_clusterhost_config(
session, updater, clusterhost, **kwargs session, updater, clusterhost, **kwargs
@@ -822,7 +823,7 @@ def update_clusterhost_deployed_config(
): ):
"""Update clusterhost deployed config.""" """Update clusterhost deployed config."""
clusterhost = utils.get_db_object( clusterhost = utils.get_db_object(
session, models.ClusterHost, id=clusterhost_id session, models.ClusterHost, clusterhost_id=clusterhost_id
) )
return _update_clusterhost_deployed_config( return _update_clusterhost_deployed_config(
session, updater, clusterhost, **kwargs session, updater, clusterhost, **kwargs
@@ -899,7 +900,7 @@ def patch_clusterhost_config(
): ):
"""patch clusterhost config.""" """patch clusterhost config."""
clusterhost = utils.get_db_object( clusterhost = utils.get_db_object(
session, models.ClusterHost, id=clusterhost_id session, models.ClusterHost, clusterhost_id=clusterhost_id
) )
return _patch_clusterhost_config( return _patch_clusterhost_config(
session, updater, clusterhost, **kwargs session, updater, clusterhost, **kwargs
@@ -967,7 +968,7 @@ def delete_cluster_host_config(
def delete_clusterhost_config(session, deleter, clusterhost_id): def delete_clusterhost_config(session, deleter, clusterhost_id):
"""Delet a clusterhost config.""" """Delet a clusterhost config."""
clusterhost = utils.get_db_object( clusterhost = utils.get_db_object(
session, models.ClusterHost, id=clusterhost_id session, models.ClusterHost, clusterhost_id=clusterhost_id
) )
return _delete_clusterhost_config( return _delete_clusterhost_config(
session, deleter, clusterhost session, deleter, clusterhost
@@ -1001,9 +1002,7 @@ def update_cluster_hosts(
if set_hosts is not None: if set_hosts is not None:
_set_clusterhosts(session, cluster, **set_hosts) _set_clusterhosts(session, cluster, **set_hosts)
return { return {
'hosts': [ 'hosts': cluster.clusterhosts
clusterhost.host for clusterhost in cluster.clusterhosts
]
} }
@@ -1075,7 +1074,7 @@ def review_cluster(session, reviewer, cluster_id, review={}, **kwargs):
utils.update_db_object(session, cluster, config_validated=True) utils.update_db_object(session, cluster, config_validated=True)
return { return {
'cluster': cluster, 'cluster': cluster,
'clusterhosts': clusterhosts 'hosts': clusterhosts
} }
@@ -1103,7 +1102,7 @@ def deploy_cluster(
clusterhosts = [] clusterhosts = []
for clusterhost in cluster.clusterhosts: for clusterhost in cluster.clusterhosts:
if ( if (
clusterhost.id in clusterhost_ids or clusterhost.clusterhost_id in clusterhost_ids or
clusterhost.host_id in host_ids clusterhost.host_id in host_ids
): ):
clusterhosts.append(clusterhost) clusterhosts.append(clusterhost)
@@ -1130,13 +1129,13 @@ def deploy_cluster(
'compass.tasks.deploy_cluster', 'compass.tasks.deploy_cluster',
( (
deployer.email, cluster_id, deployer.email, cluster_id,
[clusterhost.id for clusterhost in clusterhosts] [clusterhost.host_id for clusterhost in clusterhosts]
) )
) )
return { return {
'status': 'deploy action sent', 'status': 'deploy action sent',
'cluster': cluster, 'cluster': cluster,
'clusterhosts': clusterhosts 'hosts': clusterhosts
} }

View File

@@ -31,7 +31,8 @@ SUPPORTED_NETOWORK_FIELDS = [
'interface', 'ip', 'subnet', 'is_mgmt', 'is_promiscuous' 'interface', 'ip', 'subnet', 'is_mgmt', 'is_promiscuous'
] ]
RESP_FIELDS = [ RESP_FIELDS = [
'id', 'name', 'os_name', 'os_id', 'owner', 'mac', 'id', 'name', 'hostname', 'os_name', 'os_id', 'owner', 'mac',
'switch_ip', 'port', 'switches',
'reinstall_os', 'os_installed', 'tag', 'location', 'networks', 'reinstall_os', 'os_installed', 'tag', 'location', 'networks',
'created_at', 'updated_at' 'created_at', 'updated_at'
] ]

View File

@@ -366,10 +366,6 @@ def _output_validates(kwargs_validators, obj):
kwargs_validators[key](value) kwargs_validators[key](value)
def validate_outputs(kwargs_validators, obj):
return _output_validates(kwargs_validators, obj)
def output_validates(**kwargs_validators): def output_validates(**kwargs_validators):
def decorator(func): def decorator(func):
@functools.wraps(func) @functools.wraps(func)

View File

@@ -388,7 +388,10 @@ class ClusterHostState(BASE, StateMixin):
id = Column( id = Column(
Integer, Integer,
ForeignKey('clusterhost.id', onupdate='CASCADE', ondelete='CASCADE'), ForeignKey(
'clusterhost.id',
onupdate='CASCADE', ondelete='CASCADE'
),
primary_key=True primary_key=True
) )
@@ -413,7 +416,7 @@ class ClusterHost(BASE, TimestampMixin, HelperMixin):
"""ClusterHost table.""" """ClusterHost table."""
__tablename__ = 'clusterhost' __tablename__ = 'clusterhost'
id = Column(Integer, primary_key=True) clusterhost_id = Column('id', Integer, primary_key=True)
cluster_id = Column( cluster_id = Column(
Integer, Integer,
ForeignKey('cluster.id', onupdate='CASCADE', ondelete='CASCADE') ForeignKey('cluster.id', onupdate='CASCADE', ondelete='CASCADE')
@@ -591,18 +594,17 @@ class ClusterHost(BASE, TimestampMixin, HelperMixin):
def to_dict(self): def to_dict(self):
dict_info = self.host.to_dict() dict_info = self.host.to_dict()
dict_info.update(super(ClusterHost, self).to_dict()) dict_info.update(super(ClusterHost, self).to_dict())
state_dict = self.state_dict()
dict_info.update({ dict_info.update({
'distributed_system_name': self.distributed_system_name, 'distributed_system_name': self.distributed_system_name,
'distributed_system_installed': self.distributed_system_installed, 'distributed_system_installed': self.distributed_system_installed,
'reinstall_distributed_system': self.reinstall_distributed_system, 'reinstall_distributed_system': self.reinstall_distributed_system,
'owner': self.owner, 'owner': self.owner,
'clustername': self.clustername, 'clustername': self.clustername,
'hostname': self.hostname, 'name': self.name,
'name': self.name 'state': state_dict['state'],
'roles': self.roles
}) })
roles = self.roles
if roles:
dict_info['roles'] = [role.to_dict() for role in roles]
return dict_info return dict_info
@@ -776,15 +778,18 @@ class Host(BASE, TimestampMixin, HelperMixin):
def to_dict(self): def to_dict(self):
dict_info = self.machine.to_dict() dict_info = self.machine.to_dict()
dict_info.update(super(Host, self).to_dict()) dict_info.update(super(Host, self).to_dict())
state_dict = self.state_dict()
dict_info.update({ dict_info.update({
'machine_id': self.machine.id, 'machine_id': self.machine.id,
'owner': self.owner, 'owner': self.owner,
'os_installed': self.os_installed, 'os_installed': self.os_installed,
'hostname': self.name,
'networks': [ 'networks': [
host_network.to_dict() host_network.to_dict()
for host_network in self.host_networks for host_network in self.host_networks
], ],
'clusters': [cluster.to_dict() for cluster in self.clusters] 'clusters': [cluster.to_dict() for cluster in self.clusters],
'state': state_dict['state']
}) })
return dict_info return dict_info
@@ -922,6 +927,7 @@ class Cluster(BASE, TimestampMixin, HelperMixin):
self.put_package_config = { self.put_package_config = {
'roles': [role.name for role in adapter.roles] 'roles': [role.name for role in adapter.roles]
} }
super(Cluster, self).initialize()
def update(self): def update(self):
if self.reinstall_distributed_system: if self.reinstall_distributed_system:
@@ -1646,6 +1652,7 @@ class AdapterRole(BASE, HelperMixin):
self.description = self.name self.description = self.name
if not self.display_name: if not self.display_name:
self.display_name = self.name self.display_name = self.name
super(AdapterRole, self).initialize()
class PackageConfigMetadata(BASE, MetadataMixin): class PackageConfigMetadata(BASE, MetadataMixin):
@@ -1801,6 +1808,7 @@ class Adapter(BASE, HelperMixin):
def initialize(self): def initialize(self):
if not self.display_name: if not self.display_name:
self.display_name = self.name self.display_name = self.name
super(Adapter, self).initialize()
@property @property
def root_metadatas(self): def root_metadatas(self):