{"action":"created","issue":{"url":"https://api.github.com/repos/fog/fog-profitbricks/issues/7","labels_url":"https://api.github.com/repos/fog/fog-profitbricks/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/fog/fog-profitbricks/issues/7/comments","events_url":"https://api.github.com/repos/fog/fog-profitbricks/issues/7/events","html_url":"https://github.com/fog/fog-profitbricks/pull/7","id":62672738,"number":7,"title":"Server#attached_volumes fixed","user":{"login":"webhoernchen","id":316450,"avatar_url":"https://avatars.githubusercontent.com/u/316450?v=3","gravatar_id":"","url":"https://api.github.com/users/webhoernchen","html_url":"https://github.com/webhoernchen","followers_url":"https://api.github.com/users/webhoernchen/followers","following_url":"https://api.github.com/users/webhoernchen/following{/other_user}","gists_url":"https://api.github.com/users/webhoernchen/gists{/gist_id}","starred_url":"https://api.github.com/users/webhoernchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webhoernchen/subscriptions","organizations_url":"https://api.github.com/users/webhoernchen/orgs","repos_url":"https://api.github.com/users/webhoernchen/repos","events_url":"https://api.github.com/users/webhoernchen/events{/privacy}","received_events_url":"https://api.github.com/users/webhoernchen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-18T11:52:01Z","updated_at":"2015-03-18T15:30:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/fog/fog-profitbricks/pulls/7","html_url":"https://github.com/fog/fog-profitbricks/pull/7","diff_url":"https://github.com/fog/fog-profitbricks/pull/7.diff","patch_url":"https://github.com/fog/fog-profitbricks/pull/7.patch"},"body":"If a server has multiple volumes, then the method attached_volumes returns an array with the same values.\r\n\r\nExample:\r\ncompute.servers.get('server-id').attached_volumes\r\n[\r\n{\"boot_device\"=>\"true\", \"bus_type\"=>\"VIRTIO\", \"device_number\"=>1, \"size\"=>8, \"id\"=>\"volume-id\", \"name\"=>\"name\"}, \r\n{\"boot_device\"=>\"true\", \"bus_type\"=>\"VIRTIO\", \"device_number\"=>1, \"size\"=>8, \"id\"=>\"volume-id\", \"name\"=>\"name\"}, \r\n{\"boot_device\"=>\"true\", \"bus_type\"=>\"VIRTIO\", \"device_number\"=>1, \"size\"=>8, \"id\"=>\"volume-id\", \"name\"=>\"name\"}\r\n]\r\n\r\nBecause the storage hash is only created once and will be updated for each storage!\r\nThis patch will create a new storage hash for each storage, after the storage is added!\r\n[\r\n{\"boot_device\"=>\"false\", \"bus_type\"=>\"VIRTIO\", \"device_number\"=>2, \"size\"=>85, \"id\"=>\"volume-id-2\", \"name\"=>\"name-2\"}, \r\n{\"boot_device\"=>\"true\", \"bus_type\"=>\"VIRTIO\", \"device_number\"=>1, \"size\"=>10, \"id\"=>\"volume-id-1\", \"name\"=>\"root\"}, \r\n{\"boot_device\"=>\"false\", \"bus_type\"=>\"VIRTIO\", \"device_number\"=>3, \"size\"=>2, \"id\"=>\"volume-id-3\", \"name\"=>\"name-3\"}\r\n]"},"comment":{"url":"https://api.github.com/repos/fog/fog-profitbricks/issues/comments/83021878","html_url":"https://github.com/fog/fog-profitbricks/pull/7#issuecomment-83021878","issue_url":"https://api.github.com/repos/fog/fog-profitbricks/issues/7","id":83021878,"user":{"login":"webhoernchen","id":316450,"avatar_url":"https://avatars.githubusercontent.com/u/316450?v=3","gravatar_id":"","url":"https://api.github.com/users/webhoernchen","html_url":"https://github.com/webhoernchen","followers_url":"https://api.github.com/users/webhoernchen/followers","following_url":"https://api.github.com/users/webhoernchen/following{/other_user}","gists_url":"https://api.github.com/users/webhoernchen/gists{/gist_id}","starred_url":"https://api.github.com/users/webhoernchen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webhoernchen/subscriptions","organizations_url":"https://api.github.com/users/webhoernchen/orgs","repos_url":"https://api.github.com/users/webhoernchen/repos","events_url":"https://api.github.com/users/webhoernchen/events{/privacy}","received_events_url":"https://api.github.com/users/webhoernchen/received_events","type":"User","site_admin":false},"created_at":"2015-03-18T15:30:25Z","updated_at":"2015-03-18T15:30:25Z","body":"@plribeiro3000 I understand what you mine.\r\n\r\nI know `attached_volumes` is an attribute of the server, but the issue is in the parser! I just wanted to explain you my example.\r\n\r\nIf I understand the code correctly, the parser [GetAllServers](https://github.com/webhoernchen/fog-profitbricks/blob/master/lib/fog/profitbricks/parsers/compute/get_all_servers.rb) operates as follows:\r\n\r\nXML of the response:\r\n\r\n```xml\r\n<return>\r\n  <requestId>18257099</requestId>\r\n  <dataCenterId>dataCenterId</dataCenterId>\r\n  <dataCenterVersion>VERSION</dataCenterVersion>\r\n  <serverId>SERVER_ID</serverId>\r\n  <serverName>SERVER_NAME</serverName>\r\n  <cores>2</cores>\r\n  <ram>4096</ram>\r\n  <internetAccess>true</internetAccess>\r\n  <ips>IP</ips>\r\n  <connectedStorages>\r\n    <bootDevice>false</bootDevice>\r\n    <busType>VIRTIO</busType>\r\n    <deviceNumber>2</deviceNumber>\r\n    <size>85</size>\r\n    <storageId>STORAGE_ID_1</storageId>\r\n    <storageName>STORAGE_NAME_1</storageName>\r\n  </connectedStorages>\r\n  <connectedStorages>\r\n    <bootDevice>true</bootDevice>\r\n    <busType>VIRTIO</busType>\r\n    <deviceNumber>1</deviceNumber>\r\n    <size>10</size>\r\n    <storageId>STORAGE_ID_2</storageId>\r\n    <storageName>STORAGE_NAME_2</storageName>\r\n  </connectedStorages>\r\n  <connectedStorages>\r\n    <bootDevice>false</bootDevice>\r\n    <busType>VIRTIO</busType>\r\n    <deviceNumber>3</deviceNumber>\r\n    <size>2</size>\r\n    <storageId>STORAGE_ID_3</storageId>\r\n    <storageName>STORAGE_NAME_3</storageName>\r\n  </connectedStorages>\r\n  ...\r\n</return>\r\n```\r\n\r\nThe parser will set the value at the end of each element!\r\n\r\nAt the end of the first connectedStorages the @storage variable will have the attributes above (example: `{'storageName' => 'STORAGE_NAME_1'}`). The `@storage` hash will be added to the array @server['connectedStorages'].\r\n\r\nAt the end of the second connectedStorages the `@storage` hash is overwritten with the new values, but the hash is the same ruby object with the same object_id as in the first part. After the @storage hash will be added to the array `@server['connectedStorages']` a second time, there are 2 array items of the same hash object in the array!\r\n\r\nAt the end of the third connectedStorages the @storage hash is overwritten, too. After the @storage hash will be added to the array `@server['connectedStorages']` a third time, there are 3 array items of the same hash object in the array!\r\n\r\nShort example:\r\n```ruby \r\n[\r\n{'storageName' => 'STORAGE_NAME_3'}, \r\n{'storageName' => 'STORAGE_NAME_3'}, \r\n{'storageName' => 'STORAGE_NAME_3'}\r\n```\r\n\r\nAfter the @storage hash is added to `@server['connectedStorages']` the `@storage` variable must be set to a new hash! If not the attributes are overwritten!\r\n\r\nHave a look at the bottom of [GetAllServers](https://github.com/webhoernchen/fog-profitbricks/blob/master/lib/fog/profitbricks/parsers/compute/get_all_servers.rb#L48).\r\nThe `@server` is set to a new hash, too!"}}