Public bug reported:
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.sources.DataSourceNoCloud.DataSourceNoCloud'> failed
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
733, in find_source
if s.update_metadata([EventType.BOOT_NEW_INSTANCE]):
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
622, in update_metadata
result = self.get_data()
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
259, in get_data
self.persist_instance_data()
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
289, in persist_instance_data
self._get_standardized_metadata())
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
209, in _get_standardized_metadata
local_hostname = self.get_hostname()
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
566, in get_hostname
if util.is_ipv4(lhost):
File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 544, in
is_ipv4
toks = instr.split('.')
AttributeError: 'int' object has no attribute 'split'
In get_hostname function in cloudinit/sources/__init__.py,
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['local-hostname']
605 if net.is_ipv4_address(lhost):
606 toks = []
607 if resolve_ip:
608 toks = util.gethostbyaddr(lhost)
609
610 if toks:
611 toks = str(toks).split('.')
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_ipv4_address(str(lhost))
-> str(lhost).split(".")
because when hostname is numeric only, lhost type would be integer by default
in python.
** Affects: cloud-init
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to cloud-init.
https://bugs.launchpad.net/bugs/1885880
Title:
nocloud-datasource with numeric hostname
Status in cloud-init:
New
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.sources.DataSourceNoCloud.DataSourceNoCloud'> failed
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
733, in find_source
if s.update_metadata([EventType.BOOT_NEW_INSTANCE]):
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
622, in update_metadata
result = self.get_data()
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
259, in get_data
self.persist_instance_data()
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
289, in persist_instance_data
self._get_standardized_metadata())
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
209, in _get_standardized_metadata
local_hostname = self.get_hostname()
File "/usr/lib/python2.7/site-packages/cloudinit/sources/__init__.py", line
566, in get_hostname
if util.is_ipv4(lhost):
File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 544, in
is_ipv4
toks = instr.split('.')
AttributeError: 'int' object has no attribute 'split'
In get_hostname function in cloudinit/sources/__init__.py,
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['local-hostname']
605 if net.is_ipv4_address(lhost):
606 toks = []
607 if resolve_ip:
608 toks = util.gethostbyaddr(lhost)
609
610 if toks:
611 toks = str(toks).split('.')
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_ipv4_address(str(lhost))
-> str(lhost).split(".")
because when hostname is numeric only, lhost type would be integer by default
in python.
To manage notifications about this bug go to:
https://bugs.launchpad.net/cloud-init/+bug/1885880/+subscriptions
--
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to : [email protected]
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help : https://help.launchpad.net/ListHelp

