{"action":"created","comment":{"url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/comments/97725917","pull_request_review_id":18340773,"id":97725917,"diff_hunk":"@@ -0,0 +1,169 @@\n+#${PMpre} NCM::Component::OpenNebula::Host${PMpost}\n+\n+use NCM::Component::OpenNebula::Commands;\n+use NCM::Component::OpenNebula::Ceph;\n+\n+=head1 NAME\n+\n+NCM::Component::OpenNebula::Host adds C<KVM> hosts support to\n+L<NCM::Component::OpenNebula>.\n+\n+=head2 Public methods\n+\n+=over\n+\n+=item manage_hosts\n+\n+Adds or removes C<Xen> or C<KVM> hosts.\n+\n+=cut\n+\n+sub manage_hosts\n+{\n+    my ($self, $one, $type, $resources, %protected) = @_;\n+    my ($new, $vnm_mad);\n+    my $hosts = $resources->{hosts};\n+    my @existhost = $one->get_hosts();\n+    my %newhosts = map { $_ => 1 } @$hosts;\n+    my (@rmhosts, @failedhost);\n+\n+    if (exists($resources->{host_ovs}) and $resources->{host_ovs}) {\n+        if ($type eq \"kvm\") {\n+            $vnm_mad = \"ovswitch\";\n+        } elsif ($type eq \"xen\") {\n+            $vnm_mad = \"ovswitch_brcompat\";\n+        }\n+    } else {\n+        $vnm_mad = \"dummy\";\n+    }\n+\n+    foreach my $t (@existhost) {\n+        # Remove the host only if there are no VMs running on it\n+        if (exists($protected{$t->name})) {\n+            $self->info(\"This resource $type is protected and can not be removed: \", $t->name);\n+        } elsif (exists($newhosts{$t->name})) {\n+            $self->debug(1, \"We can't remove this $type host. Is required by Quattor: \", $t->name);\n+        } elsif ($t->used()) {\n+            $self->debug(1, \"We can't remove this $type host. There are still running VMs: \", $t->name);\n+        } else {\n+            push(@rmhosts, $t->name);\n+            $t->delete();\n+        }\n+    }\n+\n+    if (@rmhosts) {\n+        $self->info(\"Removed $type hosts: \", join(',', @rmhosts));\n+    }\n+\n+    foreach my $host (@$hosts) {\n+        my %host_options = (\n+            'name'    => $host, \n+            'im_mad'  => $type, \n+            'vmm_mad' => $type, \n+            'vnm_mad' => $vnm_mad\n+        );\n+        # to keep the record of our cloud infrastructure\n+        # we include the host in ONE db even if it fails\n+        my @hostinstances = $one->get_hosts(qr{^$host$});\n+        if (scalar(@hostinstances) > 1) {\n+            $self->error(\"Found more than one host $host. Only the first host will be modified.\");\n+        }\n+        my $hostinstance = $hostinstances[0];\n+        if (exists($protected{$host})) {\n+            $self->info(\"This resource $type is protected and can not be created/updated: $host\");\n+        } elsif ($self->can_connect_to_host($host)) {\n+            my $output = $self->enable_node($one, $type, $host, $resources);","path":"ncm-opennebula/src/main/perl/OpenNebula/Host.pm","position":75,"original_position":75,"commit_id":"2f7b5287e362137728486e8e49930d9df2cc3526","original_commit_id":"2f7b5287e362137728486e8e49930d9df2cc3526","user":{"login":"stdweird","id":1517606,"avatar_url":"https://avatars.githubusercontent.com/u/1517606?v=3","gravatar_id":"","url":"https://api.github.com/users/stdweird","html_url":"https://github.com/stdweird","followers_url":"https://api.github.com/users/stdweird/followers","following_url":"https://api.github.com/users/stdweird/following{/other_user}","gists_url":"https://api.github.com/users/stdweird/gists{/gist_id}","starred_url":"https://api.github.com/users/stdweird/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stdweird/subscriptions","organizations_url":"https://api.github.com/users/stdweird/orgs","repos_url":"https://api.github.com/users/stdweird/repos","events_url":"https://api.github.com/users/stdweird/events{/privacy}","received_events_url":"https://api.github.com/users/stdweird/received_events","type":"User","site_admin":false},"body":"if you don't use `$output`, do `if ($self->enable_node($one, $type, $host, $resources)) {`","created_at":"2017-01-25T08:02:46Z","updated_at":"2017-01-25T08:10:57Z","html_url":"https://github.com/quattor/configuration-modules-core/pull/1009#discussion_r97725917","pull_request_url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/1009","_links":{"self":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/comments/97725917"},"html":{"href":"https://github.com/quattor/configuration-modules-core/pull/1009#discussion_r97725917"},"pull_request":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/1009"}}},"pull_request":{"url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/1009","id":100870473,"html_url":"https://github.com/quattor/configuration-modules-core/pull/1009","diff_url":"https://github.com/quattor/configuration-modules-core/pull/1009.diff","patch_url":"https://github.com/quattor/configuration-modules-core/pull/1009.patch","issue_url":"https://api.github.com/repos/quattor/configuration-modules-core/issues/1009","number":1009,"state":"open","locked":false,"title":"ncm-opennebula: Opennebula refactoring and AII code (WIP)","user":{"login":"alvarosimon","id":2225733,"avatar_url":"https://avatars.githubusercontent.com/u/2225733?v=3","gravatar_id":"","url":"https://api.github.com/users/alvarosimon","html_url":"https://github.com/alvarosimon","followers_url":"https://api.github.com/users/alvarosimon/followers","following_url":"https://api.github.com/users/alvarosimon/following{/other_user}","gists_url":"https://api.github.com/users/alvarosimon/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarosimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarosimon/subscriptions","organizations_url":"https://api.github.com/users/alvarosimon/orgs","repos_url":"https://api.github.com/users/alvarosimon/repos","events_url":"https://api.github.com/users/alvarosimon/events{/privacy}","received_events_url":"https://api.github.com/users/alvarosimon/received_events","type":"User","site_admin":false},"body":"**NOTE:** This is a big PR, the current OpenNebula AII is not longer required, the packages and methods were included into the component itself. The schema is still the same but now it also includes the aii schema and unittests. The RPC dictionary and XML data was updated to keep the old aii testing compatibility.\r\n\r\n**NOTE:** This PR also requires `OpenNebula-0.310.0`\r\n\r\n * Fix #978 : include ONE AII code and refactoring\r\n * Fix #1018 : aii VNET methods create new AR instead of an update\r\n * Fix https://github.com/quattor/aii/issues/230\r\n","created_at":"2017-01-10T13:11:19Z","updated_at":"2017-01-25T08:10:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"694352d87fbb5deaba6d43d63e2f6fdf9e0d09c8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/1009/commits","review_comments_url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/1009/comments","review_comment_url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quattor/configuration-modules-core/issues/1009/comments","statuses_url":"https://api.github.com/repos/quattor/configuration-modules-core/statuses/2f7b5287e362137728486e8e49930d9df2cc3526","head":{"label":"alvarosimon:opennebula_refactoring","ref":"opennebula_refactoring","sha":"2f7b5287e362137728486e8e49930d9df2cc3526","user":{"login":"alvarosimon","id":2225733,"avatar_url":"https://avatars.githubusercontent.com/u/2225733?v=3","gravatar_id":"","url":"https://api.github.com/users/alvarosimon","html_url":"https://github.com/alvarosimon","followers_url":"https://api.github.com/users/alvarosimon/followers","following_url":"https://api.github.com/users/alvarosimon/following{/other_user}","gists_url":"https://api.github.com/users/alvarosimon/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarosimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarosimon/subscriptions","organizations_url":"https://api.github.com/users/alvarosimon/orgs","repos_url":"https://api.github.com/users/alvarosimon/repos","events_url":"https://api.github.com/users/alvarosimon/events{/privacy}","received_events_url":"https://api.github.com/users/alvarosimon/received_events","type":"User","site_admin":false},"repo":{"id":23350876,"name":"configuration-modules-core","full_name":"alvarosimon/configuration-modules-core","owner":{"login":"alvarosimon","id":2225733,"avatar_url":"https://avatars.githubusercontent.com/u/2225733?v=3","gravatar_id":"","url":"https://api.github.com/users/alvarosimon","html_url":"https://github.com/alvarosimon","followers_url":"https://api.github.com/users/alvarosimon/followers","following_url":"https://api.github.com/users/alvarosimon/following{/other_user}","gists_url":"https://api.github.com/users/alvarosimon/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarosimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarosimon/subscriptions","organizations_url":"https://api.github.com/users/alvarosimon/orgs","repos_url":"https://api.github.com/users/alvarosimon/repos","events_url":"https://api.github.com/users/alvarosimon/events{/privacy}","received_events_url":"https://api.github.com/users/alvarosimon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alvarosimon/configuration-modules-core","description":"Node Configuration Manager Components for Everyone","fork":true,"url":"https://api.github.com/repos/alvarosimon/configuration-modules-core","forks_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/forks","keys_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/teams","hooks_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/hooks","issue_events_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/issues/events{/number}","events_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/events","assignees_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/assignees{/user}","branches_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/branches{/branch}","tags_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/tags","blobs_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/statuses/{sha}","languages_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/languages","stargazers_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/stargazers","contributors_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/contributors","subscribers_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/subscribers","subscription_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/subscription","commits_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/contents/{+path}","compare_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/merges","archive_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/downloads","issues_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/issues{/number}","pulls_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/pulls{/number}","milestones_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/milestones{/number}","notifications_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/labels{/name}","releases_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/releases{/id}","deployments_url":"https://api.github.com/repos/alvarosimon/configuration-modules-core/deployments","created_at":"2014-08-26T12:32:15Z","updated_at":"2016-03-14T10:57:07Z","pushed_at":"2017-01-24T13:11:31Z","git_url":"git://github.com/alvarosimon/configuration-modules-core.git","ssh_url":"git@github.com:alvarosimon/configuration-modules-core.git","clone_url":"https://github.com/alvarosimon/configuration-modules-core.git","svn_url":"https://github.com/alvarosimon/configuration-modules-core","homepage":"www.quattor.org","size":11487,"stargazers_count":0,"watchers_count":0,"language":"Perl","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"quattor:master","ref":"master","sha":"3138cd9214fe136a563e0de204b344c5c1b2a5f3","user":{"login":"quattor","id":1557169,"avatar_url":"https://avatars.githubusercontent.com/u/1557169?v=3","gravatar_id":"","url":"https://api.github.com/users/quattor","html_url":"https://github.com/quattor","followers_url":"https://api.github.com/users/quattor/followers","following_url":"https://api.github.com/users/quattor/following{/other_user}","gists_url":"https://api.github.com/users/quattor/gists{/gist_id}","starred_url":"https://api.github.com/users/quattor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quattor/subscriptions","organizations_url":"https://api.github.com/users/quattor/orgs","repos_url":"https://api.github.com/users/quattor/repos","events_url":"https://api.github.com/users/quattor/events{/privacy}","received_events_url":"https://api.github.com/users/quattor/received_events","type":"Organization","site_admin":false},"repo":{"id":6471233,"name":"configuration-modules-core","full_name":"quattor/configuration-modules-core","owner":{"login":"quattor","id":1557169,"avatar_url":"https://avatars.githubusercontent.com/u/1557169?v=3","gravatar_id":"","url":"https://api.github.com/users/quattor","html_url":"https://github.com/quattor","followers_url":"https://api.github.com/users/quattor/followers","following_url":"https://api.github.com/users/quattor/following{/other_user}","gists_url":"https://api.github.com/users/quattor/gists{/gist_id}","starred_url":"https://api.github.com/users/quattor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quattor/subscriptions","organizations_url":"https://api.github.com/users/quattor/orgs","repos_url":"https://api.github.com/users/quattor/repos","events_url":"https://api.github.com/users/quattor/events{/privacy}","received_events_url":"https://api.github.com/users/quattor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/quattor/configuration-modules-core","description":"Node Configuration Manager Components for Everyone","fork":false,"url":"https://api.github.com/repos/quattor/configuration-modules-core","forks_url":"https://api.github.com/repos/quattor/configuration-modules-core/forks","keys_url":"https://api.github.com/repos/quattor/configuration-modules-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quattor/configuration-modules-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quattor/configuration-modules-core/teams","hooks_url":"https://api.github.com/repos/quattor/configuration-modules-core/hooks","issue_events_url":"https://api.github.com/repos/quattor/configuration-modules-core/issues/events{/number}","events_url":"https://api.github.com/repos/quattor/configuration-modules-core/events","assignees_url":"https://api.github.com/repos/quattor/configuration-modules-core/assignees{/user}","branches_url":"https://api.github.com/repos/quattor/configuration-modules-core/branches{/branch}","tags_url":"https://api.github.com/repos/quattor/configuration-modules-core/tags","blobs_url":"https://api.github.com/repos/quattor/configuration-modules-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quattor/configuration-modules-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quattor/configuration-modules-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/quattor/configuration-modules-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quattor/configuration-modules-core/statuses/{sha}","languages_url":"https://api.github.com/repos/quattor/configuration-modules-core/languages","stargazers_url":"https://api.github.com/repos/quattor/configuration-modules-core/stargazers","contributors_url":"https://api.github.com/repos/quattor/configuration-modules-core/contributors","subscribers_url":"https://api.github.com/repos/quattor/configuration-modules-core/subscribers","subscription_url":"https://api.github.com/repos/quattor/configuration-modules-core/subscription","commits_url":"https://api.github.com/repos/quattor/configuration-modules-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/quattor/configuration-modules-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/quattor/configuration-modules-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/quattor/configuration-modules-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/quattor/configuration-modules-core/contents/{+path}","compare_url":"https://api.github.com/repos/quattor/configuration-modules-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quattor/configuration-modules-core/merges","archive_url":"https://api.github.com/repos/quattor/configuration-modules-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quattor/configuration-modules-core/downloads","issues_url":"https://api.github.com/repos/quattor/configuration-modules-core/issues{/number}","pulls_url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls{/number}","milestones_url":"https://api.github.com/repos/quattor/configuration-modules-core/milestones{/number}","notifications_url":"https://api.github.com/repos/quattor/configuration-modules-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quattor/configuration-modules-core/labels{/name}","releases_url":"https://api.github.com/repos/quattor/configuration-modules-core/releases{/id}","deployments_url":"https://api.github.com/repos/quattor/configuration-modules-core/deployments","created_at":"2012-10-31T09:08:07Z","updated_at":"2016-10-24T10:45:01Z","pushed_at":"2017-01-24T19:23:49Z","git_url":"git://github.com/quattor/configuration-modules-core.git","ssh_url":"git@github.com:quattor/configuration-modules-core.git","clone_url":"https://github.com/quattor/configuration-modules-core.git","svn_url":"https://github.com/quattor/configuration-modules-core","homepage":"www.quattor.org","size":11611,"stargazers_count":7,"watchers_count":7,"language":"Perl","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":34,"mirror_url":null,"open_issues_count":118,"forks":34,"open_issues":118,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/1009"},"html":{"href":"https://github.com/quattor/configuration-modules-core/pull/1009"},"issue":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/issues/1009"},"comments":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/issues/1009/comments"},"review_comments":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/1009/comments"},"review_comment":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/1009/commits"},"statuses":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/statuses/2f7b5287e362137728486e8e49930d9df2cc3526"}}}}
{"actor":{"display_login":"stdweird"}}