nocloud-datasource with numeric hostname
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Expired
|
Undecided
|
Unassigned |
Bug Description
When I use nocloud datasource with numeric hostname like 1234,
it shows errors as follow,
2020-07-01 06:37:49,018 - util.py[DEBUG]: Getting data from <class 'cloudinit.
Traceback (most recent call last):
File "/usr/lib/
if s.update_
File "/usr/lib/
result = self.get_data()
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
local_hostname = self.get_hostname()
File "/usr/lib/
if util.is_
File "/usr/lib/
toks = instr.split('.')
AttributeError: 'int' object has no attribute 'split'
In get_hostname function in cloudinit/
601 else:
602 # if there is an ipv4 address in 'local-hostname', then
603 # make up a hostname (LP: #475354) in format ip-xx.xx.xx.xx
604 lhost = self.metadata[
605 if net.is_
606 toks = []
607 if resolve_ip:
608 toks = util.gethostbya
609
610 if toks:
611 toks = str(toks)
612 else:
613 toks = ["ip-%s" % lhost.replace(".", "-")]
614 else:
615 toks = lhost.split(".")
before utilize lhost, it needs to convert to string type like
-> net.is_
-> str(lhost)
because when hostname is numeric only, lhost type would be integer by default in python.
Thanks for filing this bug and making cloud-init better.
RFC 1123 says hostname can start with digits and contain only digits. https:/ /tools. ietf.org/ html/rfc1123
I think this is a fair feature/bug request.