{"action":"created","issue":{"url":"https://api.github.com/repos/projectcalico/libcalico/issues/57","labels_url":"https://api.github.com/repos/projectcalico/libcalico/issues/57/labels{/name}","comments_url":"https://api.github.com/repos/projectcalico/libcalico/issues/57/comments","events_url":"https://api.github.com/repos/projectcalico/libcalico/issues/57/events","html_url":"https://github.com/projectcalico/libcalico/issues/57","id":118410250,"number":57,"title":"The hostname argument for auto_assign_ips is not respected","user":{"login":"plwhite","id":8448749,"avatar_url":"https://avatars.githubusercontent.com/u/8448749?v=3","gravatar_id":"","url":"https://api.github.com/users/plwhite","html_url":"https://github.com/plwhite","followers_url":"https://api.github.com/users/plwhite/followers","following_url":"https://api.github.com/users/plwhite/following{/other_user}","gists_url":"https://api.github.com/users/plwhite/gists{/gist_id}","starred_url":"https://api.github.com/users/plwhite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plwhite/subscriptions","organizations_url":"https://api.github.com/users/plwhite/orgs","repos_url":"https://api.github.com/users/plwhite/repos","events_url":"https://api.github.com/users/plwhite/events{/privacy}","received_events_url":"https://api.github.com/users/plwhite/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-11-23T15:52:16Z","updated_at":"2015-12-03T19:23:10Z","closed_at":null,"body":"When you call `auto_assign_ips`,  there is an optional `hostname` argument (defaulting to the hostname of this server). In principle, that means that you can have a name for a server used in IPAM that is not the same as the server hostname. Unfortunately, if you don't set it to the hostname of this server, then it doesn't work, which makes it a bit pointless.\r\n\r\nThe underlying issue is that `_auto_assign_block` is called, and that raises an exception if the block in question does not match the server hostname (not the `hostname` parameter). One fix would be to remove that check, but that seems a bit crazy (it's a valid check). Another fix would be to pass the supplied hostname down to `_auto_assign_block`, which I think is probably the correct fix.\r\n\r\nI can probably put together a PR for this, but it'd be good to get confirmation that you agree with my analysis in case I've misunderstood how to use the interface.\r\n\r\nHere's a stack trace of what happened when I tried this (`dummy-0000` is the hostname of the box, not what I passed, and this is build 0.3.0) : \r\n\r\n    Traceback (most recent call last):\r\n      File \"./host-agent.py\", line 532, in <module>\r\n        main()\r\n      File \"./host-agent.py\", line 374, in main\r\n        do_ipam(name)\r\n      File \"./host-agent.py\", line 342, in do_ipam\r\n        hostname=name)\r\n      File \"/usr/local/lib/python2.7/site-packages/pycalico/ipam.py\", line 409, in auto_assign_ips   \r\n        attributes, pool[0], hostname)\r\n      File \"/usr/local/lib/python2.7/site-packages/pycalico/ipam.py\", line 484, in _auto_assign\r\n        attributes)\r\n      File \"/usr/local/lib/python2.7/site-packages/pycalico/ipam.py\", line 538, in _auto_assign_block\r\n        affinity_check=affinity_check)\r\n      File \"/usr/local/lib/python2.7/site-packages/pycalico/block.py\", line 169, in auto_assign\r\n        self.host_affinity)\r\n    pycalico.block.NoHostAffinityWarning: Host affinity is dummy-0000\r\n"},"comment":{"url":"https://api.github.com/repos/projectcalico/libcalico/issues/comments/161753517","html_url":"https://github.com/projectcalico/libcalico/issues/57#issuecomment-161753517","issue_url":"https://api.github.com/repos/projectcalico/libcalico/issues/57","id":161753517,"user":{"login":"robbrockbank","id":3227729,"avatar_url":"https://avatars.githubusercontent.com/u/3227729?v=3","gravatar_id":"","url":"https://api.github.com/users/robbrockbank","html_url":"https://github.com/robbrockbank","followers_url":"https://api.github.com/users/robbrockbank/followers","following_url":"https://api.github.com/users/robbrockbank/following{/other_user}","gists_url":"https://api.github.com/users/robbrockbank/gists{/gist_id}","starred_url":"https://api.github.com/users/robbrockbank/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robbrockbank/subscriptions","organizations_url":"https://api.github.com/users/robbrockbank/orgs","repos_url":"https://api.github.com/users/robbrockbank/repos","events_url":"https://api.github.com/users/robbrockbank/events{/privacy}","received_events_url":"https://api.github.com/users/robbrockbank/received_events","type":"User","site_admin":false},"created_at":"2015-12-03T19:23:10Z","updated_at":"2015-12-03T19:23:10Z","body":"Yup that's correct Peter.\r\n\r\nI've discussed with @tomdee.  I'm intending to fix up as per option (3) - but the naming used in the etcd keys and values with still say \"host\" even though it's really the affinity_id."}}