diff --git a/compass/db/api/cluster.py b/compass/db/api/cluster.py index 7200bfe9..2e0c54bb 100644 --- a/compass/db/api/cluster.py +++ b/compass/db/api/cluster.py @@ -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 ) ) diff --git a/compass/db/api/host.py b/compass/db/api/host.py index 2dd754c7..a039e424 100644 --- a/compass/db/api/host.py +++ b/compass/db/api/host.py @@ -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 ) ) diff --git a/compass/db/api/switch.py b/compass/db/api/switch.py index f21c550a..9efe3fe7 100644 --- a/compass/db/api/switch.py +++ b/compass/db/api/switch.py @@ -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' diff --git a/compass/db/models.py b/compass/db/models.py index 69fc0da3..c3a20ada 100644 --- a/compass/db/models.py +++ b/compass/db/models.py @@ -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() diff --git a/compass/deployment/installers/config_manager.py b/compass/deployment/installers/config_manager.py index 22b7c964..8d48bad6 100644 --- a/compass/deployment/installers/config_manager.py +++ b/compass/deployment/installers/config_manager.py @@ -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] diff --git a/compass/tests/deployment/installers/os_installers/cobbler/test_cobbler.py b/compass/tests/deployment/installers/os_installers/cobbler/test_cobbler.py index 1cd11728..bca11b4a 100644 --- a/compass/tests/deployment/installers/os_installers/cobbler/test_cobbler.py +++ b/compass/tests/deployment/installers/os_installers/cobbler/test_cobbler.py @@ -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, diff --git a/compass/tests/deployment/test_data/config_data.py b/compass/tests/deployment/test_data/config_data.py index 13127d39..84c0cfa7 100644 --- a/compass/tests/deployment/test_data/config_data.py +++ b/compass/tests/deployment/test_data/config_data.py @@ -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": { diff --git a/conf/templates/cobbler/CentOS-6.5-x86_64/system.tmpl b/conf/templates/cobbler/CentOS-6.5-x86_64/system.tmpl index 59214cc5..3db5e350 100644 --- a/conf/templates/cobbler/CentOS-6.5-x86_64/system.tmpl +++ b/conf/templates/cobbler/CentOS-6.5-x86_64/system.tmpl @@ -60,6 +60,6 @@ "timezone": "$timezone", "ignore_proxy": "$no_proxy", "local_repo": "$getVar('local_repo', '')", - "disk_num": 1 + "disk_num": "1" } } diff --git a/conf/templates/cobbler/Ubuntu-12.04-x86_64/system.tmpl b/conf/templates/cobbler/Ubuntu-12.04-x86_64/system.tmpl index 59214cc5..3db5e350 100644 --- a/conf/templates/cobbler/Ubuntu-12.04-x86_64/system.tmpl +++ b/conf/templates/cobbler/Ubuntu-12.04-x86_64/system.tmpl @@ -60,6 +60,6 @@ "timezone": "$timezone", "ignore_proxy": "$no_proxy", "local_repo": "$getVar('local_repo', '')", - "disk_num": 1 + "disk_num": "1" } } diff --git a/regtest/regtest.conf b/regtest/regtest.conf index efbfa51c..682425ff 100644 --- a/regtest/regtest.conf +++ b/regtest/regtest.conf @@ -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}"}