add ip and ignore hostname when hostname is not set

Change-Id: Ica03525178ba417cc48364091a958a55d977ecb3
This commit is contained in:
xiaodongwang 2014-10-08 14:56:39 -07:00
parent f8224c2617
commit 2c9fdc1237
10 changed files with 42 additions and 27 deletions

View File

@ -45,7 +45,7 @@ RESP_CLUSTERHOST_FIELDS = [
'cluster_id', 'clustername', 'location', 'tag',
'networks', 'mac', 'switch_ip', 'port', 'switches',
'os_installed', 'distributed_system_installed',
'os_name', 'distributed_system_name',
'os_name', 'distributed_system_name', 'ip',
'reinstall_os', 'reinstall_distributed_system',
'owner', 'cluster_id',
'created_at', 'updated_at'
@ -1240,7 +1240,7 @@ def validate_clusterhost(session, clusterhost):
def validate_cluster(session, cluster):
if not cluster.clusterhosts:
raise exception.InvalidParameter(
'%s does not have any hosts' % cluster.name
'cluster %s does not have any hosts' % cluster.name
)
flavor = cluster.flavor
if flavor:
@ -1267,15 +1267,15 @@ def validate_cluster(session, cluster):
missing_roles = necessary_roles - clusterhost_roles
if missing_roles:
raise exception.InvalidParameter(
'some roles %s are not assigned to any host in cluster %s' % (
list(missing_roles), cluster.name
'cluster %s have some roles %s not assigned to any host' % (
cluster.name, list(missing_roles)
)
)
for interface, subnets in interface_subnets.items():
if len(subnets) > 1:
raise exception.InvalidParameter(
'multi subnets %s in interface %s' % (
list(subnets), interface
'cluster %s multi subnets %s in interface %s' % (
cluster.name, list(subnets), interface
)
)

View File

@ -33,7 +33,7 @@ SUPPORTED_NETOWORK_FIELDS = [
]
RESP_FIELDS = [
'id', 'name', 'hostname', 'os_name', 'os_id', 'owner', 'mac',
'switch_ip', 'port', 'switches', 'os_installer',
'switch_ip', 'port', 'switches', 'os_installer', 'ip',
'reinstall_os', 'os_installed', 'tag', 'location', 'networks',
'created_at', 'updated_at'
]
@ -235,20 +235,24 @@ def is_host_editable(
def validate_host(session, host):
if not host.hostname:
raise exception.Invalidparameter(
'host %s does not set hostname' % host.name
)
if not host.host_networks:
raise exception.InvalidParameter(
'%s does not have any network' % host.name
'host %s does not have any network' % host.name
)
mgmt_interface_set = False
for host_network in host.host_networks:
if host_network.is_mgmt:
if mgmt_interface_set:
raise exception.InvalidParameter(
'%s multi interfaces set mgmt ' % host.name
'host %s multi interfaces set mgmt ' % host.name
)
if host_network.is_promiscuous:
raise exception.InvalidParameter(
'%s interface %s is mgmt but promiscuous' % (
'host %s interface %s is mgmt but promiscuous' % (
host.name, host_network.interface
)
)

View File

@ -92,7 +92,7 @@ RESP_MACHINES_FIELDS = [
RESP_MACHINES_HOSTS_FIELDS = [
'id', 'switch_id', 'switch_ip', 'machine_id', 'switch_machine_id',
'port', 'vlans', 'mac',
'ipmi_credentials', 'tag', 'location',
'ipmi_credentials', 'tag', 'location', 'ip',
'name', 'hostname', 'os_name', 'os_id', 'owner',
'os_installer', 'reinstall_os', 'os_installed',
'clusters', 'created_at', 'updated_at'

View File

@ -750,7 +750,7 @@ class ClusterHost(BASE, TimestampMixin, HelperMixin):
@hybrid_property
def hostname(self):
return self.host.name
return self.host.hostname
@hostname.expression
def hostname(cls):
@ -952,6 +952,17 @@ class Host(BASE, TimestampMixin, HelperMixin):
else:
return None
@hybrid_property
def hostname(self):
if self.name == str(self.id):
return None
else:
return self.name
@hostname.expression
def hostname(cls):
return cls.name
@property
def patched_os_config(self):
return self.os_config
@ -1046,7 +1057,7 @@ class Host(BASE, TimestampMixin, HelperMixin):
dict_info.update({
'machine_id': self.machine.id,
'os_installed': self.os_installed,
'hostname': self.name,
'hostname': self.hostname,
'ip': ip,
'networks': [
host_network.to_dict()

View File

@ -165,9 +165,9 @@ class BaseConfigManager(object):
return None
if const.DNS not in host_info:
name = host_info[const.NAME]
hostname = host_info[const.HOSTNAME]
domain = self.get_host_domain(host_id)
host_info[const.DNS] = '.'.join((name, domain))
host_info[const.DNS] = '.'.join((hostname, domain))
return host_info[const.DNS]

View File

@ -47,7 +47,7 @@ class TestCobblerInstaller(unittest2.TestCase):
"name": "server01.test",
"profile": "Ubuntu-12.04-x86_64",
"hostname": "server01",
"dns": "server01.test.ods.com",
"dns": "server01.ods.com",
"reinstall_os": True,
"networks": {
"vnet0": {
@ -91,7 +91,7 @@ class TestCobblerInstaller(unittest2.TestCase):
"https_proxy": "",
"ntp_server": "127.0.0.1",
"nameservers": ["127.0.0.1"],
"search_path": ["1.ods.com", "ods.com"],
"search_path": ["ods.com"],
"gateway": "10.145.88.1"
}
}
@ -137,14 +137,14 @@ class TestCobblerInstaller(unittest2.TestCase):
"profile": "Ubuntu-12.04-x86_64",
"gateway": "10.145.88.1",
"name_servers": ["127.0.0.1"],
"name_servers_search": "1.ods.com ods.com",
"name_servers_search": "ods.com",
"proxy": "http://127.0.0.1:3128",
"modify_interface": {
"ipaddress-vnet0": "12.234.32.100",
"netmask-vnet0": "255.255.255.0",
"management-vnet0": True,
"macaddress-vnet0": "00:0c:29:3e:60:e9",
"dns-vnet0": "server01.test.ods.com",
"dns-vnet0": "server01.ods.com",
"static-vnet0": True,
"ipaddress-vnet1": "172.16.1.1",
"netmask-vnet1": "255.255.255.0",
@ -196,7 +196,7 @@ class TestCobblerInstaller(unittest2.TestCase):
"https_proxy": "",
"ntp_server": "127.0.0.1",
"nameservers": ["127.0.0.1"],
"search_path": ["1.ods.com", "ods.com"],
"search_path": ["ods.com"],
"partition": {
"/var": {
"vol_percentage": 20,
@ -223,7 +223,7 @@ class TestCobblerInstaller(unittest2.TestCase):
"https_proxy": "",
"ntp_server": "127.0.0.1",
"nameservers": ["127.0.0.1"],
"search_path": ["1.ods.com", "ods.com"],
"search_path": ["ods.com"],
"partition": {
"/var": {
"vol_percentage": 30,
@ -253,7 +253,7 @@ class TestCobblerInstaller(unittest2.TestCase):
"https_proxy": "",
"ntp_server": "127.0.0.1",
"nameservers": ["127.0.0.1"],
"search_path": ["1.ods.com", "ods.com"],
"search_path": ["ods.com"],
"partition": {
"/var": {
"vol_percentage": 20,

View File

@ -201,7 +201,7 @@ cluster_test_config = {
"https_proxy": "",
"ntp_server": "127.0.0.1",
"dns_servers": ["127.0.0.1"],
"search_path": ["1.ods.com", "ods.com"]
"search_path": ["ods.com"]
},
"partition": {
"/var": {
@ -375,7 +375,7 @@ hosts_test_config = {
"https_proxy": "",
"ntp_server": "10.145.88.211",
"dns_servers": "10.145.88.211",
"search_path": "1.ods.com ods.com"
"search_path": "ods.com"
},
"partition": {
"/var": {

View File

@ -60,6 +60,6 @@
"timezone": "$timezone",
"ignore_proxy": "$no_proxy",
"local_repo": "$getVar('local_repo', '')",
"disk_num": 1
"disk_num": "1"
}
}

View File

@ -60,6 +60,6 @@
"timezone": "$timezone",
"ignore_proxy": "$no_proxy",
"local_repo": "$getVar('local_repo', '')",
"disk_num": 1
"disk_num": "1"
}
}

View File

@ -118,6 +118,6 @@ if [ -z "$HOST_NETWORKS" ]; then
export HOST_NETWORKS
fi
export NETWORK_MAPPING=${NETWORK_MAPPING:-"management=${MANAGEMENT_INTERFACE},tenant=${TENANT_INTERFACE},storage=${STORAGE_INTERFACE},public=${PUBLIC_INTERFACE}"}
export NETWORK_MAPPING=${NETWORK_MAPPING:-"management=${MANAGEMENT_INTERFACE},tenant=${TENANT_INTERFACE},storage=${STORAGE_INTERFACE},external=${PUBLIC_INTERFACE}"}
export DEPLOYMENT_TIMEOUT=${DEPLOYMENT_TIMEOUT:-"90"}
export DASHBOARD_URL=${DASHBOARD_URL:-"http://${MANAGEMENT_IP_START}"}