Change-Id: I4c83d333035abc54ef6246fe41f0eecd87d1e1f8
This commit is contained in:
xiaodongwang 2014-08-19 15:29:43 -07:00
parent 90ae66a7b5
commit 4f07db4ce8
3 changed files with 18 additions and 13 deletions

View File

@ -28,7 +28,7 @@ from compass.db import models
SUPPORTED_FIELDS = ['name', 'os_name', 'owner', 'mac']
SUPPORTED_MACHINE_HOST_FIELDS = ['mac', 'tag', 'location', 'os_name', 'os_id']
SUPPORTED_NETOWORK_FIELDS = [
'interface', 'ip', 'subnet', 'is_mgmt', 'is_promiscuous'
'interface', 'ip', 'is_mgmt', 'is_promiscuous'
]
RESP_FIELDS = [
'id', 'name', 'hostname', 'os_name', 'os_id', 'owner', 'mac',

View File

@ -359,17 +359,9 @@ class HostNetwork(BASE, TimestampMixin, HelperMixin):
def ip(self, value):
self.ip_int = int(netaddr.IPAddress(value))
@hybrid_property
def subnet(self):
return self.subnet.subnet
@subnet.expression
def subnet(cls):
return cls.subnet.subnet
@property
def netmask(self):
return str(netaddr.IPNetwork(self.subnet).netmask)
return str(netaddr.IPNetwork(self.subnet.subnet).netmask)
def update(self):
self.host.config_validated = False
@ -389,7 +381,7 @@ class HostNetwork(BASE, TimestampMixin, HelperMixin):
)
)
ip = netaddr.IPAddress(self.ip_int)
subnet = netaddr.IPNetwork(self.subnet)
subnet = netaddr.IPNetwork(self.subnet.subnet)
if ip not in subnet:
raise exception.InvalidParameter(
'ip %s is not in subnet %s' % (
@ -402,7 +394,7 @@ class HostNetwork(BASE, TimestampMixin, HelperMixin):
dict_info['ip'] = self.ip
dict_info['interface'] = self.interface
dict_info['netmask'] = self.netmask
dict_info['subnet'] = self.subnet
dict_info['subnet'] = self.subnet.subnet
return dict_info
@ -1649,7 +1641,7 @@ class AdapterOS(BASE, HelperMixin):
"""Adapter OS table."""
__tablename__ = 'adapter_os'
id = Column(Integer, primary_key=True)
adapter_os_id = Column('id', Integer, primary_key=True)
os_id = Column(
Integer,
ForeignKey(
@ -1733,6 +1725,17 @@ class OperatingSystem(BASE, HelperMixin):
dict_info.update(metadata.to_dict())
return dict_info
@property
def os_supported_adapters(self):
supported_adapters = self.supported_adapters
if supported_adapters:
return supported_adapters
parent = self.parent
if parent:
return parent.os_supported_adapters
else:
return []
class AdapterFlavorRole(BASE, HelperMixin):
"""Adapter flavor roles."""

View File

@ -58,6 +58,8 @@ TEST_CHEF_URL = "https://api.opscode.com/organizations/compasscheftest"
TEST_CLIENT_KEY_PATH = "/etc/compass/client.pem"
TEST_CLIENT_NAME = "graceyu"
PROGRESS_UPDATE_PID_FILE = '/var/run/progress_update.pid'
OS_INSTALLER_DIR = lazypy.delay(
lambda: os.path.join(CONFIG_DIR, 'os_installer')
)