{"action":"created","issue":{"url":"https://api.github.com/repos/roboconf/roboconf-platform/issues/360","labels_url":"https://api.github.com/repos/roboconf/roboconf-platform/issues/360/labels{/name}","comments_url":"https://api.github.com/repos/roboconf/roboconf-platform/issues/360/comments","events_url":"https://api.github.com/repos/roboconf/roboconf-platform/issues/360/events","html_url":"https://github.com/roboconf/roboconf-platform/issues/360","id":91267549,"number":360,"title":"Messaging in agent is never configured on IaaS VMs (user-data not propagated)","user":{"login":"gibello","id":1230975,"avatar_url":"https://avatars.githubusercontent.com/u/1230975?v=3","gravatar_id":"","url":"https://api.github.com/users/gibello","html_url":"https://github.com/gibello","followers_url":"https://api.github.com/users/gibello/followers","following_url":"https://api.github.com/users/gibello/following{/other_user}","gists_url":"https://api.github.com/users/gibello/gists{/gist_id}","starred_url":"https://api.github.com/users/gibello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gibello/subscriptions","organizations_url":"https://api.github.com/users/gibello/orgs","repos_url":"https://api.github.com/users/gibello/repos","events_url":"https://api.github.com/users/gibello/events{/privacy}","received_events_url":"https://api.github.com/users/gibello/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/roboconf/roboconf-platform/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-26T14:36:35Z","updated_at":"2015-06-26T17:26:47Z","closed_at":null,"body":"When the DM deploys a new VM on a IaaS (eg. EC2), it passes configuration information across user-data. These informations should be used to configure the agent's messaging... but they are not, and the messaging points to localhost (default) although the user-data are properly updated (on EC2, can be checked by browsing http://169.254.169.254/latest/user-data on the VM).\r\nAs a consequence, the VM never gets in deployed/started state on the DM side (and remains \"being deployed\" forever), because no message arrives."},"comment":{"url":"https://api.github.com/repos/roboconf/roboconf-platform/issues/comments/115790230","html_url":"https://github.com/roboconf/roboconf-platform/issues/360#issuecomment-115790230","issue_url":"https://api.github.com/repos/roboconf/roboconf-platform/issues/360","id":115790230,"user":{"login":"vincent-zurczak","id":1104790,"avatar_url":"https://avatars.githubusercontent.com/u/1104790?v=3","gravatar_id":"","url":"https://api.github.com/users/vincent-zurczak","html_url":"https://github.com/vincent-zurczak","followers_url":"https://api.github.com/users/vincent-zurczak/followers","following_url":"https://api.github.com/users/vincent-zurczak/following{/other_user}","gists_url":"https://api.github.com/users/vincent-zurczak/gists{/gist_id}","starred_url":"https://api.github.com/users/vincent-zurczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vincent-zurczak/subscriptions","organizations_url":"https://api.github.com/users/vincent-zurczak/orgs","repos_url":"https://api.github.com/users/vincent-zurczak/repos","events_url":"https://api.github.com/users/vincent-zurczak/events{/privacy}","received_events_url":"https://api.github.com/users/vincent-zurczak/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T17:26:47Z","updated_at":"2015-06-26T17:26:47Z","body":"I thought about it...\r\n\r\nI explored 3 ideas.\r\n\r\n1 - Inject the config admin service in the agent.\r\nWhen it finds user data, it would update the configuration of the messaging bundle.\r\n\r\nPros: the messaging is configured.\r\nCons: @bourretp said it might not work (for security reasons, not anyone can modify the configuration of other bundles). Besides, we don't always know which messaging bundle has to be updated.\r\n\r\n2 - Add a new script in the distribution.\r\nWhen we install an agent on a IaaS VM, we already edit the agent's configuration to indicate we use this or that IaaS. We could have changed this and require to update or set a script that would get the user data and update the configuration. However, user data are not retrieved from the same location in all the IaaS. EC2 is similar to Openstack (same URL), but Azure uses another way. This solution would be very hard to implement.\r\n\r\n3 - Let the agent updates the configuration **file** of the messaging directly.\r\nIt appears to be possible. When we run a bundle, we can access Karaf's variables, including the KARAF_ETC directory. So, here is a suggestion...\r\n\r\nWe add a new method in [UserDataUtils](https://github.com/roboconf/roboconf-platform/blob/master/core/roboconf-agent/src/main/java/net/roboconf/agent/internal/misc/UserDataUtils.java).\r\n\r\n```java\r\npublic static void updateMessagingConfiguration( Map<String,String> msgData, String messagingType ) {\r\n\r\n     String etcDir = System.getProperty( \"karaf.etc\" );\r\n     if( ! Utils.isEmptyOrWhiteSpaces( etcDir )) {\r\n\r\n           // Find the *.cfg file that starts with \"net.roboconf.messaging.\"\r\n           // .... and that contains messagingType (e.g. rabbitmq).\r\n           // Update its content. Messaging clients are now configured independently of the agent / DM).\r\n     } else {\r\n           // Log something\r\n     }\r\n}\r\n```\r\n\r\nWe won't be able to add unit tests about it.\r\nThis is because they don't run in Karaf. However, we should an integration test about it.\r\nBTW, I made the test, we really get Karaf's ETC directory with ```System.getProperty( \"karaf.etc\" )```."}}