|
[00:19] <dgarstang1> hey how does that hostname thing work? |
|
[00:22] <harlowja> so usually datasources provide metadata and read it in |
|
[00:22] <harlowja> and all these modules get activated, they get passed the data from config and metadata and all that |
|
[00:22] <harlowja> and then they just use it to do whatever the module wants to do |
|
[00:23] <harlowja> in this case it calls into a distro specific object (since setting the hostname is distro dependent) and sets it |
|
[00:24] <dgarstang1> harlowja: so.... it doesn't actually set the hostname? |
|
[00:24] <harlowja> the module has access to this distrobution specific object, it asks that object to set the hostname |
|
[00:24] <dgarstang1> cuz... the hostname format is a highly specific thing isn't it? |
|
[00:24] <harlowja> not the hostname format |
|
[00:24] <harlowja> the way to set it seems to be |
|
[00:24] <harlowja> different in freebsd, ubuntu, rhel |
|
[00:25] <harlowja> rhel has a /etc/syconfig file |
|
[00:25] <harlowja> ubuntu has a different one |
|
[00:25] <dgarstang1> lemme try a different angle... where does it get the source of the hostname? |
|
[00:25] <harlowja> from the datasource |
|
[00:25] <harlowja> http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/__init__.py#L164 |
|
[00:26] <harlowja> the datasource gets it from some location |
|
[00:26] <harlowja> *datasource specific |
|
[00:26] <harlowja> which u would think in the GCE datasource would be there metadata server |
|
[00:26] <dgarstang1> yes, but where in the data source? what key? |
|
[00:26] <harlowja> see above function |
|
[00:27] <harlowja> basically datasources when they fetch there data populate self.metadata |
|
[00:27] <dgarstang1> 'local-hostname' ? |
|
[00:27] <dgarstang1> is this stuff documented somewhere? |
|
[00:27] <dgarstang1> how would I have known it's local-hostname and not hostname? |
|
[00:29] <dgarstang1> man I am confused |
|
[00:29] <dgarstang1> http://cloudinit.readthedocs.org/en/latest/topics/modules.html .... nothing. No modules. |
|
[00:30] <dgarstang1> for 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.html |
|
[00:31] <harlowja> dgarstang1 its not in any cloud-init i know about, seems to have been a debian specific patch |
|
[00:31] <harlowja> so its not in the upstream cloud-init, so wouldn't be on cloudinit.readthedocs.org |
|
[00:31] <dgarstang1> harlowja: ok, how about docs on the set_hostname module? |
|
[00:31] <harlowja> probably not as good as it could be |
|
[00:32] <dgarstang1> http://cloudinit.readthedocs.org/en/latest/topics/datasources.html#ec2 ... 'Metadata is accessible via the following URL:'... how's that relevant? |
|
[00:32] <dgarstang1> isn't cloud-init supposed to abstract that so I can't see it and don't care? |
|
[00:33] <dgarstang1> I'd really liketo know how the set_hostname module works, like what key in the metadata it reas |
|
[00:33] <harlowja> python 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 process |
|
[00:34] <dgarstang1> ah the old read the code reply. :) |
|
[00:34] <dgarstang1> code always lacks context |
|
[00:35] <dgarstang1> like, 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:37] <harlowja> dgarstang1 not really, there is a baseclass for datasources in __init__ |
|
[00:37] <dgarstang1> so maybe I need to read this source file, but ... wait... there's a module called update_hostname, which isn't here |
|
[00:37] <harlowja> the function is in this baseclass |
|
[00:37] <harlowja> right, modules != datasources |
|
[00:38] <dgarstang1> harlowja: so where's the code for set_hostname? |
|
[00:38] <harlowja> it isn't in 1 place, it begins its life in the update_hostname module |
|
[00:38] <dgarstang1> in that case, docs would be nice. :) |
|
[00:39] <harlowja> sure, i'd much appreciate them also, but not enough time in the day :) |
|
[00:39] <dgarstang1> or, 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 section |
|
[00:39] <harlowja> sure, or feel free to keep on asking questions and we can provide answers, and presto a doc that u can then submit ;) |
|
[00:40] <dgarstang1> harlowja: well, I dunno |
|
[00:40] <harlowja> i understand how this is not ideal, but it is what it is |
|
[00:40] <dgarstang1> I'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 all |
|
[00:40] <harlowja> prior 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:41] <harlowja> dgarstang1 its specific to a datasource |
|
[00:41] <harlowja> since different datasource retrieve it differently |
|
[00:41] <dgarstang1> ok |
|
[00:42] <harlowja> so 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] <dgarstang1> So, ec2 ds doesn't even have a set_hostname http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/DataSourceEc2.py |
|
[00:42] <harlowja> dgarstang1 right, thats what inheritence is for |
|
[00:42] <dgarstang1> in fact, it's got almost nothing |
|
[00:42] <harlowja> base class usually provide most of the functionality |
|
[00:43] <dgarstang1> ic |
|
[00:43] <harlowja> most datasources just provide def get_data(self): |
|
[00:43] <harlowja> which is there special way of reading |
|
[00:43] <harlowja> *which is the thing that varies |
|
[00:44] <dgarstang1> Ok, so there's no set_hostname in DataSource either... http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/__init__.py |
|
[00:44] <harlowja> ah, my fault, thought u mean get_hostname |
|
[00:44] <harlowja> right, so datasources provide the data that other parts of cloud-init use |
|
[00:44] <harlowja> so it wouldn't make sense for a datasource to set anything |
|
[00:45] <dgarstang1> well, the default cloud_init_modules has set_hostname, amongst oters |
|
[00:45] <harlowja> yes, modules (one of those is set_hostname) != datasourcs |
|
[00:45] <dgarstang1> it doesnt make sense for a data source to set anything? who does? |
|
[00:45] <dgarstang1> the set_hostname module? where's the code for that? |
|
[00:45] <harlowja> http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/config/cc_set_hostname.py |
|
[00:46] <dgarstang1> well that doesn't tell me what metadata it wants to use. |
|
[00:46] <dgarstang1> ugh |
|
[00:47] <harlowja> util.get_hostname_fqdn |
|
[00:48] <dgarstang1> still not seeing it, sorry |
|
[00:48] <harlowja> which itself will eventually call into the datasource get_hostname |
|
[00:49] <harlowja> so set_hostname calls first util.get_hostname_fqdn which eventually calls into datasource get_hostname (the base class) |
|
[00:49] <harlowja> so that tells u where it comes from |
|
[00:49] <harlowja> the base class then looks in a few places |
|
[00:49] <harlowja> http://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/sources/__init__.py#L164 |
|
[00:49] <harlowja> lhost = self.metadata['local-hostname'] |
|
[00:49] <harlowja> line 186 |
|
[00:50] <harlowja> then that module asks the distrobution specific object to set the hostname to this value |
|
[00:50] <harlowja> which will then do whatever distribution specific thing to set the hostname |
|
[00:51] <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] <dgarstang1> kk, thanks |
|
[00:52] <harlowja> np |
|
[00:52] <harlowja> so in the end it becomes a question what is the GCE datasource doing :) |
|
[00:52] <harlowja> and since i'm not sure where that code is, hard to know :-P |
|
=== harlowja is now known as harlowja_away |
|
|