Use split instead of find as split does not fail to provide a complete

component if no '.' is found.
This commit is contained in:
Simo Sorce 2008-05-15 11:33:07 -04:00
parent 58592c3b4f
commit 6119f83799
3 changed files with 3 additions and 3 deletions

View File

@ -175,7 +175,7 @@ def read_ip_address(host_name):
fstore.backup_file("/etc/hosts")
hosts_fd = open('/etc/hosts', 'r+')
hosts_fd.seek(0, 2)
hosts_fd.write(ip+'\t'+host_name+' '+host_name[:host_name.find('.')]+'\n')
hosts_fd.write(ip+'\t'+host_name+' '+host_name.split('.')[0]+'\n')
hosts_fd.close()
return ip

View File

@ -48,7 +48,7 @@ class BindInstance(service.Service):
self.ip_address = ip_address
self.realm = realm_name
self.domain = domain_name
self.host = fqdn[:fqdn.find(".")]
self.host = fqdn.split(".")[0]
self.__setup_sub_dict()

View File

@ -214,7 +214,7 @@ class DsInstance(service.Service):
self.backup_state("running", is_ds_running())
self.backup_state("serverid", self.serverid)
self.sub_dict['BASEDC'] = self.realm_name[:self.realm_name.find('.')].lower()
self.sub_dict['BASEDC'] = self.realm_name.split('.')[0].lower()
base_txt = ipautil.template_str(BASE_TEMPLATE, self.sub_dict)
logging.debug(base_txt)
base_fd = file("/var/lib/dirsrv/boot.ldif", "w")