/srv/irclogs.ubuntu.com/2014/02/01/#cloud-init.txt

dgarstang1hey how does that hostname thing work?00:19
harlowjaso usually datasources provide metadata and read it in00:22
harlowjaand all these modules get activated, they get passed the data from config and metadata and all that00:22
harlowjaand then they just use it to do whatever the module wants to do00:22
harlowjain this case it calls into a distro specific object (since setting the hostname is distro dependent) and sets it00:23
dgarstang1harlowja: so.... it doesn't actually set the hostname?00:24
harlowjathe module has access to this distrobution specific object, it asks that object to set the hostname00:24
dgarstang1cuz... the hostname format is a highly specific thing isn't it? 00:24
harlowjanot the hostname format00:24
harlowjathe way to set it seems to be00:24
harlowjadifferent in freebsd, ubuntu, rhel00:24
harlowjarhel has a /etc/syconfig file00:25
harlowjaubuntu has a different one00:25
dgarstang1lemme try a different angle... where does it get the source of the hostname?00:25
harlowjafrom the datasource00:25
harlowjahttp://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/__init__.py#L16400:25
harlowjathe datasource gets it from some location00:26
harlowja*datasource specific00:26
harlowjawhich u would think in the GCE datasource would be there metadata server00:26
dgarstang1yes, but where in the data source? what key?00:26
harlowjasee above function00:26
harlowjabasically datasources when they fetch there data populate self.metadata00:27
dgarstang1'local-hostname' ?00:27
dgarstang1is this stuff documented somewhere?00:27
dgarstang1how would I have known it's local-hostname and not hostname?00:27
dgarstang1man I am confused00:29
dgarstang1http://cloudinit.readthedocs.org/en/latest/topics/modules.html .... nothing. No modules.00:29
dgarstang1for that matter, if GCE is in the latest version of cloudinit, where is it documented? There's no mention of it at http://cloudinit.readthedocs.org/en/latest/topics/datasources.html00:30
harlowjadgarstang1 its not in any cloud-init i know about, seems to have been a debian specific patch00:31
harlowjaso its not in the upstream cloud-init, so wouldn't be on cloudinit.readthedocs.org00:31
dgarstang1harlowja: ok, how about docs on the set_hostname module?00:31
harlowjaprobably not as good as it could be00:31
dgarstang1http://cloudinit.readthedocs.org/en/latest/topics/datasources.html#ec2 ... 'Metadata is accessible via the following URL:'... how's that relevant? 00:32
dgarstang1isn't cloud-init supposed to abstract that so I can't see it and don't care?00:32
dgarstang1I'd really liketo know how the set_hostname module works, like what key in the metadata it reas00:33
harlowjapython is pretty readible, so http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/__init__.py#L164 sorta describes the whole process00:33
dgarstang1ah the old read the code reply. :)00:34
dgarstang1code always lacks context00:34
dgarstang1like, if I am reading the code for cloudinit __init__, why does it have a get_hostname function there? wouldn't that be in the get_hostname module? Doesn't that mean it's in a different python file somewhere else?00:35
harlowjadgarstang1 not really, there is a baseclass for datasources in __init__00:37
dgarstang1so maybe I need to read this source file, but ... wait... there's a module called update_hostname, which isn't here00:37
harlowjathe function is in this baseclass00:37
harlowjaright, modules != datasources00:37
dgarstang1harlowja: so where's the code for set_hostname?00:38
harlowjait isn't in 1 place, it begins its life in the update_hostname module00:38
dgarstang1in that case, docs would be nice. :)00:38
harlowjasure, i'd much appreciate them also, but not enough time in the day :)00:39
dgarstang1or, we'll just keep doing what we are doing and hacking it, not fully using the features of cloud init, and reading the hostname from the metadata ourselves and setting it in a runcmd section00:39
harlowjasure, or feel free to keep on asking questions and we can provide answers, and presto a doc that u can then submit ;)00:39
dgarstang1harlowja: well, I dunno00:40
harlowjai understand how this is not ideal, but it is what it is00:40
dgarstang1I'd ask what metadata the hostname module uses, but I don't even know if that's specific to the data source, or a common attribute for all00:40
harlowjaprior to before i created http://cloudinit.readthedocs.org  it wasn't any better, but a collection of small improvements in the end makes it better for everyone :)00:40
harlowjadgarstang1 its specific to a datasource00:41
harlowjasince different datasource retrieve it differently00:41
dgarstang1ok00:41
harlowjaso this then involves the question of what is the GCE thing doing (which i haven't seen the code for, since it never seems to have appeared upstream?)00:42
dgarstang1So, ec2 ds doesn't even have a set_hostname http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/DataSourceEc2.py00:42
harlowjadgarstang1 right, thats what inheritence is for00:42
dgarstang1in fact, it's got almost nothing00:42
harlowjabase class usually provide most of the functionality00:42
dgarstang1ic00:43
harlowjamost datasources just provide def get_data(self):00:43
harlowjawhich is there special way of reading 00:43
harlowja*which is the thing that varies00:43
dgarstang1Ok, so there's no set_hostname in DataSource either... http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/__init__.py00:44
harlowjaah, my fault, thought u mean get_hostname00:44
harlowjaright, so datasources provide the data that other parts of cloud-init use00:44
harlowjaso it wouldn't make sense for a datasource to set anything00:44
dgarstang1well, the default cloud_init_modules has set_hostname, amongst oters00:45
harlowjayes, modules (one of those is set_hostname) != datasourcs00:45
dgarstang1it doesnt make sense for a data source to set anything? who does?00:45
dgarstang1the set_hostname module? where's the code for that?00:45
harlowjahttp://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/config/cc_set_hostname.py00:45
dgarstang1well that doesn't tell me what metadata it wants to use.00:46
dgarstang1ugh00:46
harlowjautil.get_hostname_fqdn 00:47
dgarstang1still not seeing it, sorry00:48
harlowjawhich itself will eventually call into the datasource get_hostname00:48
harlowjaso set_hostname calls first util.get_hostname_fqdn which eventually calls into datasource get_hostname (the base class)00:49
harlowjaso that tells u where it comes from00:49
harlowjathe base class then looks in a few places00:49
harlowjahttp://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/__init__.py#L16400:49
harlowjalhost = self.metadata['local-hostname']00:49
harlowjaline 18600:49
harlowjathen that module asks the distrobution specific object to set the hostname to this value00:50
harlowjawhich will then do whatever distribution specific thing to set the hostname00:50
harlowja self.metadata is populated by however the datasource fetches its data (which in your case would be whatever the gce datasource is doing)00:51
dgarstang1kk, thanks00:51
harlowjanp00:52
harlowjaso in the end it becomes a question what is the GCE datasource doing :)00:52
harlowjaand since i'm not sure where that code is, hard to know :-P00:52
=== harlowja is now known as harlowja_away

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!