{"action":"created","comment":{"url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/comments/51131084","id":51131084,"diff_hunk":"@@ -0,0 +1,866 @@\n+# #\n+\n+# Software subject to following license(s):\n+#   Apache 2 License (http://www.opensource.org/licenses/apache2.0)\n+#   Copyright (c) Responsible Organization\n+#\n+\n+# #\n+# Current developer(s):\n+#   Jindrich Novy <jindrich.novy@morganstanley.com>\n+#\n+\n+# #\n+# Author(s): Jindrich Novy\n+#\n+\n+package NCM::Component::spma::yumng;\n+\n+#\n+# a few standard statements, mandatory for all components\n+#\n+use strict;\n+use warnings;\n+use NCM::Component;\n+our $EC  = LC::Exception::Context->new->will_store_all;\n+our @ISA = qw(NCM::Component);\n+use EDG::WP4::CCM::Element qw(unescape);\n+\n+use CAF::Process;\n+use CAF::FileWriter;\n+use Set::Scalar;\n+use File::Path qw(mkpath rmtree);\n+use LWP::Simple;\n+use Text::Glob qw(match_glob);\n+\n+use constant HOSTNAME            => \"/system/network/hostname\";\n+use constant DOMAINNAME          => \"/system/network/domainname\";\n+use constant REPOS_DIR           => \"/etc/yum.repos.d\";\n+use constant REPOS_TREE          => \"/software/repositories\";\n+use constant PKGS_TREE           => \"/software/packages\";\n+use constant GROUPS_TREE         => \"/software/groups/names\";\n+use constant CMP_TREE            => \"/software/components/spma\";\n+use constant YUM_PACKAGE_LIST    => \"/etc/yum/pluginconf.d/versionlock.list\";\n+use constant YUM_CONF_FILE       => \"/etc/yum.conf\";\n+use constant RPM_QUERY_INSTALLED => qw(rpm -qa --nosignature --nodigest --qf %{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\\n);\n+use constant RPM_QUERY_INSTALLED_NAMES => qw(rpm -qa --nosignature --nodigest --qf %{EPOCH}:%{NAME}\\n);\n+use constant REPO_AVAIL_PKGS     => qw(repoquery -C --show-duplicates --all --qf %{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH});\n+use constant YUM_PLUGIN_OPTS     => \"--disableplugin=\\* --enableplugin=fastestmirror --enableplugin=versionlock --enableplugin=priorities\";\n+use constant YUM_TEST_CHROOT     => qw(/tmp/spma_yum_testroot);\n+use constant SPMA                => \"/software/components/spma\";\n+use constant SPMAPROXY           => \"/software/components/spma/proxy\";\n+\n+our $NoActionSupported = 1;\n+\n+# If user packages are not allowed, removes any repositories present\n+# in the system that are not listed in $allowed_repos.\n+sub cleanup_old_repos\n+{\n+    my ( $self, $repo_dir, $allowed_repos, $allow_user_pkgs ) = @_;\n+\n+    return 1 if $allow_user_pkgs;\n+\n+    my $dir;\n+    if ( !opendir( $dir, $repo_dir ) ) {\n+        $self->error(\"Unable to read repositories in $repo_dir\");\n+        return 0;\n+    }\n+\n+    my $current = Set::Scalar->new( map( m{(.*)\\.repo$}, readdir($dir) ) );\n+\n+    closedir($dir);\n+    my $allowed = Set::Scalar->new( map( $_->{name}, @$allowed_repos ) );\n+    my $rm = $current - $allowed;\n+    foreach my $i (@$rm) {\n+        # We use $f here to make Devel::Cover happy\n+\tif ($i =~ m/^[\\w-]+$/) {\n+\t    my $f = \"$repo_dir/$i.repo\";\n+\t    $self->verbose(\"Unlinking outdated repository $f\");\n+\t    if ( !unlink($f) ) {\n+\t\t$self->error(\"Unable to remove outdated repository $i: $!\");\n+\t\treturn 0;\n+\t    }\n+\t} else {\n+\t    return 0;\n+\t}\n+    }\n+    return 1;\n+}\n+\n+=pod\n+\n+=head2 C<execute_yum_command>\n+\n+Executes C<$command> for reason C<$why>. Optionally with standard\n+input C<$stdin>.  The command may be executed even under --noaction if\n+C<$keeps_state> has a true value.\n+\n+If the command is executed, this method returns its standard output\n+upon success or C<undef> in case of error.  If the command is not\n+executed the method always returns a true value (usually 1, but don't\n+rely on this!).\n+\n+Yum-based commands require annoying error handling: they may exit 0\n+even upon errors.  In those cases, we have to detect errors by looking\n+at stderr.  This method just encapsulates all that logic, keeping the\n+callers clean.\n+\n+=cut\n+\n+my $os_major = \"\";","path":"ncm-spma/src/main/perl/spma/yumng.pm","position":110,"original_position":110,"commit_id":"a641181f16d17af9131a76dab170e70325d164bf","original_commit_id":"a641181f16d17af9131a76dab170e70325d164bf","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":"i'm sorry, but i can't let you do this :smile:. define them where needed, unless they are truly intended to be used as class variables in instead of convenient way to redefine them.","created_at":"2016-01-28T14:49:42Z","updated_at":"2016-01-28T14:49:42Z","html_url":"https://github.com/quattor/configuration-modules-core/pull/695#discussion_r51131084","pull_request_url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/695","_links":{"self":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/comments/51131084"},"html":{"href":"https://github.com/quattor/configuration-modules-core/pull/695#discussion_r51131084"},"pull_request":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/695"}}},"pull_request":{"url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/695","id":57504013,"html_url":"https://github.com/quattor/configuration-modules-core/pull/695","diff_url":"https://github.com/quattor/configuration-modules-core/pull/695.diff","patch_url":"https://github.com/quattor/configuration-modules-core/pull/695.patch","issue_url":"https://api.github.com/repos/quattor/configuration-modules-core/issues/695","number":695,"state":"open","locked":false,"title":"WIP: yumng - Jan 2016","user":{"login":"ned21","id":278425,"avatar_url":"https://avatars.githubusercontent.com/u/278425?v=3","gravatar_id":"","url":"https://api.github.com/users/ned21","html_url":"https://github.com/ned21","followers_url":"https://api.github.com/users/ned21/followers","following_url":"https://api.github.com/users/ned21/following{/other_user}","gists_url":"https://api.github.com/users/ned21/gists{/gist_id}","starred_url":"https://api.github.com/users/ned21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ned21/subscriptions","organizations_url":"https://api.github.com/users/ned21/orgs","repos_url":"https://api.github.com/users/ned21/repos","events_url":"https://api.github.com/users/ned21/events{/privacy}","received_events_url":"https://api.github.com/users/ned21/received_events","type":"User","site_admin":false},"body":"Another sync of our internal development efforts on yumng.\r\n\r\nThis code was forked from 14.10 and we had to make some schema changes it's becoming more difficult to sync back. Can we aim to get this merged at the workshop so at least we don't fall further behind?","created_at":"2016-01-28T13:48:16Z","updated_at":"2016-01-28T14:49:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":{"url":"https://api.github.com/repos/quattor/configuration-modules-core/milestones/12","html_url":"https://github.com/quattor/configuration-modules-core/milestones/16.4","labels_url":"https://api.github.com/repos/quattor/configuration-modules-core/milestones/12/labels","id":1147837,"number":12,"title":"16.4","description":null,"creator":{"login":"jrha","id":323309,"avatar_url":"https://avatars.githubusercontent.com/u/323309?v=3","gravatar_id":"","url":"https://api.github.com/users/jrha","html_url":"https://github.com/jrha","followers_url":"https://api.github.com/users/jrha/followers","following_url":"https://api.github.com/users/jrha/following{/other_user}","gists_url":"https://api.github.com/users/jrha/gists{/gist_id}","starred_url":"https://api.github.com/users/jrha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrha/subscriptions","organizations_url":"https://api.github.com/users/jrha/orgs","repos_url":"https://api.github.com/users/jrha/repos","events_url":"https://api.github.com/users/jrha/events{/privacy}","received_events_url":"https://api.github.com/users/jrha/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":0,"state":"open","created_at":"2015-06-03T16:16:39Z","updated_at":"2016-01-28T13:48:16Z","due_on":"2016-04-29T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/695/commits","review_comments_url":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/695/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/695/comments","statuses_url":"https://api.github.com/repos/quattor/configuration-modules-core/statuses/a641181f16d17af9131a76dab170e70325d164bf","head":{"label":"ned21:yum-ng-jan2016","ref":"yum-ng-jan2016","sha":"a641181f16d17af9131a76dab170e70325d164bf","user":{"login":"ned21","id":278425,"avatar_url":"https://avatars.githubusercontent.com/u/278425?v=3","gravatar_id":"","url":"https://api.github.com/users/ned21","html_url":"https://github.com/ned21","followers_url":"https://api.github.com/users/ned21/followers","following_url":"https://api.github.com/users/ned21/following{/other_user}","gists_url":"https://api.github.com/users/ned21/gists{/gist_id}","starred_url":"https://api.github.com/users/ned21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ned21/subscriptions","organizations_url":"https://api.github.com/users/ned21/orgs","repos_url":"https://api.github.com/users/ned21/repos","events_url":"https://api.github.com/users/ned21/events{/privacy}","received_events_url":"https://api.github.com/users/ned21/received_events","type":"User","site_admin":false},"repo":{"id":9676040,"name":"configuration-modules-core","full_name":"ned21/configuration-modules-core","owner":{"login":"ned21","id":278425,"avatar_url":"https://avatars.githubusercontent.com/u/278425?v=3","gravatar_id":"","url":"https://api.github.com/users/ned21","html_url":"https://github.com/ned21","followers_url":"https://api.github.com/users/ned21/followers","following_url":"https://api.github.com/users/ned21/following{/other_user}","gists_url":"https://api.github.com/users/ned21/gists{/gist_id}","starred_url":"https://api.github.com/users/ned21/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ned21/subscriptions","organizations_url":"https://api.github.com/users/ned21/orgs","repos_url":"https://api.github.com/users/ned21/repos","events_url":"https://api.github.com/users/ned21/events{/privacy}","received_events_url":"https://api.github.com/users/ned21/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ned21/configuration-modules-core","description":"Core NCM components for Quattor","fork":true,"url":"https://api.github.com/repos/ned21/configuration-modules-core","forks_url":"https://api.github.com/repos/ned21/configuration-modules-core/forks","keys_url":"https://api.github.com/repos/ned21/configuration-modules-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ned21/configuration-modules-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ned21/configuration-modules-core/teams","hooks_url":"https://api.github.com/repos/ned21/configuration-modules-core/hooks","issue_events_url":"https://api.github.com/repos/ned21/configuration-modules-core/issues/events{/number}","events_url":"https://api.github.com/repos/ned21/configuration-modules-core/events","assignees_url":"https://api.github.com/repos/ned21/configuration-modules-core/assignees{/user}","branches_url":"https://api.github.com/repos/ned21/configuration-modules-core/branches{/branch}","tags_url":"https://api.github.com/repos/ned21/configuration-modules-core/tags","blobs_url":"https://api.github.com/repos/ned21/configuration-modules-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ned21/configuration-modules-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ned21/configuration-modules-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/ned21/configuration-modules-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ned21/configuration-modules-core/statuses/{sha}","languages_url":"https://api.github.com/repos/ned21/configuration-modules-core/languages","stargazers_url":"https://api.github.com/repos/ned21/configuration-modules-core/stargazers","contributors_url":"https://api.github.com/repos/ned21/configuration-modules-core/contributors","subscribers_url":"https://api.github.com/repos/ned21/configuration-modules-core/subscribers","subscription_url":"https://api.github.com/repos/ned21/configuration-modules-core/subscription","commits_url":"https://api.github.com/repos/ned21/configuration-modules-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/ned21/configuration-modules-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/ned21/configuration-modules-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/ned21/configuration-modules-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/ned21/configuration-modules-core/contents/{+path}","compare_url":"https://api.github.com/repos/ned21/configuration-modules-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ned21/configuration-modules-core/merges","archive_url":"https://api.github.com/repos/ned21/configuration-modules-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ned21/configuration-modules-core/downloads","issues_url":"https://api.github.com/repos/ned21/configuration-modules-core/issues{/number}","pulls_url":"https://api.github.com/repos/ned21/configuration-modules-core/pulls{/number}","milestones_url":"https://api.github.com/repos/ned21/configuration-modules-core/milestones{/number}","notifications_url":"https://api.github.com/repos/ned21/configuration-modules-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ned21/configuration-modules-core/labels{/name}","releases_url":"https://api.github.com/repos/ned21/configuration-modules-core/releases{/id}","deployments_url":"https://api.github.com/repos/ned21/configuration-modules-core/deployments","created_at":"2013-04-25T16:21:09Z","updated_at":"2015-01-13T10:57:12Z","pushed_at":"2016-01-28T13:44:00Z","git_url":"git://github.com/ned21/configuration-modules-core.git","ssh_url":"git@github.com:ned21/configuration-modules-core.git","clone_url":"https://github.com/ned21/configuration-modules-core.git","svn_url":"https://github.com/ned21/configuration-modules-core","homepage":null,"size":9299,"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":"ed5b7ec642145963527422af9e264bb195debc72","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-01-11T13:45:42Z","pushed_at":"2016-01-28T13:48:16Z","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":10935,"stargazers_count":7,"watchers_count":7,"language":"Perl","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":86,"forks":31,"open_issues":86,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/695"},"html":{"href":"https://github.com/quattor/configuration-modules-core/pull/695"},"issue":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/issues/695"},"comments":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/issues/695/comments"},"review_comments":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/pulls/695/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/695/commits"},"statuses":{"href":"https://api.github.com/repos/quattor/configuration-modules-core/statuses/a641181f16d17af9131a76dab170e70325d164bf"}}}}