{"action":"created","comment":{"url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/comments/44457397","id":44457397,"diff_hunk":"@@ -0,0 +1,136 @@\n+# The NXAPI provider for tacacs_global.\n+#\n+# October, 2015\n+#\n+# Copyright (c) 2014-2015 Cisco and/or its affiliates.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+#     http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS,\n+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+\n+require 'cisco_node_utils' if Puppet.features.cisco_node_utils?\n+begin\n+  require 'puppet_x/cisco/autogen'\n+rescue LoadError # seen on master, not on agent\n+  # See longstanding Puppet issues #4248, #7316, #14073, #14149, etc. Ugh.\n+  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..',\n+                                     'puppet_x', 'cisco', 'autogen.rb'))\n+end\n+\n+Puppet::Type.type(:tacacs_global).provide(:nxapi) do\n+  desc 'The Cisco NXAPI provider for tacacs_global.'\n+\n+  confine feature: :cisco_node_utils\n+  defaultfor operatingsystem: :nexus\n+\n+  mk_resource_methods\n+\n+  # The following properties are only valid when 'enable' is set to true\n+  ENABLED_ONLY_PROPS = [:timeout, :key, :key_format]\n+\n+  def initialize(value={})\n+    super(value)\n+    @tacacs_global = Cisco::TacacsServer.new(false)\n+    @property_flush = {}\n+    debug 'Created provider instance of tacacs_global'\n+  end\n+\n+  def self.get_properties(name)\n+    debug \"Checking instance, TacacsServer #{name}\"\n+\n+    v = Cisco::TacacsServer.new(false)\n+\n+    current_state = {}\n+    current_state[:name] = name\n+    current_state[:enable] = Cisco::TacacsServer.enabled ? :true : :false\n+\n+    if current_state[:enable].eql?(:true)\n+      current_state[:timeout] = v.timeout\n+      current_state[:key] = v.encryption_password\n+      current_state[:key_format] = v.encryption_type\n+    end\n+\n+    new(current_state)\n+  end # self.get_properties\n+\n+  def self.instances\n+    tacacsglobal = []\n+    tacacsglobal << get_properties('default')\n+    tacacsglobal\n+  end\n+\n+  def self.prefetch(resources)\n+    tacacs_global = instances\n+\n+    resources.keys.each do |id|\n+      provider = tacacs_global.find { |instance| instance.name == id }\n+      resources[id].provider = provider unless provider.nil?\n+    end\n+  end # self.prefetch\n+\n+  def munge_flush(val)\n+    if val.is_a?(String) && val.eql?('unset')\n+      nil\n+    elsif val.is_a?(Symbol) && val.eql?(:true)\n+      true\n+    elsif val.is_a?(Symbol) && val.eql?(:false)\n+      false\n+    elsif val.is_a?(Symbol)\n+      val.to_s\n+    else\n+      val\n+    end\n+  end\n+\n+  def validate\n+    fail ArgumentError,\n+         \"This provider only supports a namevar of 'default'\" unless @resource[:name].to_s == 'default'\n+\n+    fail ArgumentError,\n+         \"This provider does not support the 'retransmit_count' property.\" if @resource[:retransmit_count]\n+\n+    if @resource[:enable] && @resource[:enable].eql?(:false)\n+      invalid = []\n+      ENABLED_ONLY_PROPS.each do |prop|\n+        invalid << prop if @resource[prop]\n+      end\n+      fail ArgumentError, \"The 'enable' property must be set to true when specifying the following properties: #{invalid}\" unless invalid.empty?\n+    else\n+      fail ArgumentError,\n+           \"The 'key' property must be set when specifying 'key_format'.\" if @resource[:key_format] && !resource[:key]\n+      fail ArgumentError,\n+           \"The 'key_format' property must be set when specifying 'key'.\" if !@resource[:key_format] && resource[:key]\n+    end\n+  end\n+\n+  def exists?\n+    true\n+  end\n+\n+  def flush\n+    validate\n+\n+    # Handle enable setting\n+    if @resource[:enable]\n+      if @resource[:enable].eql?(:true)\n+        @tacacs_global.enable\n+      elsif @resource[:enable].eql?(:false)\n+        @tacacs_global.destroy\n+      end\n+    end\n+\n+    # Handle timeout setting\n+    @tacacs_global.timeout = @resource[:timeout] if @resource[:timeout]","path":"lib/puppet/provider/tacacs_global/nxapi.rb","position":131,"original_position":131,"commit_id":"fc9aac50d380b230d4ca6863779a593b319369c7","original_commit_id":"fc9aac50d380b230d4ca6863779a593b319369c7","user":{"login":"jonnytpuppet","id":10402750,"avatar_url":"https://avatars.githubusercontent.com/u/10402750?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnytpuppet","html_url":"https://github.com/jonnytpuppet","followers_url":"https://api.github.com/users/jonnytpuppet/followers","following_url":"https://api.github.com/users/jonnytpuppet/following{/other_user}","gists_url":"https://api.github.com/users/jonnytpuppet/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnytpuppet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnytpuppet/subscriptions","organizations_url":"https://api.github.com/users/jonnytpuppet/orgs","repos_url":"https://api.github.com/users/jonnytpuppet/repos","events_url":"https://api.github.com/users/jonnytpuppet/events{/privacy}","received_events_url":"https://api.github.com/users/jonnytpuppet/received_events","type":"User","site_admin":false},"body":"@hunsbea no, property_hash is not guaranteed to store the original values. Actually, the mk_resource_methods call will cause setter to be created at run-time that update property_hash with the new values.\r\n\r\nWhat we can do here, is save the original values in the constructor, and compare during flush. ","created_at":"2015-11-10T20:05:44Z","updated_at":"2015-11-10T20:05:44Z","html_url":"https://github.com/cisco/cisco-network-puppet-module/pull/51#discussion_r44457397","pull_request_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/51","_links":{"self":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/comments/44457397"},"html":{"href":"https://github.com/cisco/cisco-network-puppet-module/pull/51#discussion_r44457397"},"pull_request":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/51"}}},"pull_request":{"url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/51","id":49561973,"html_url":"https://github.com/cisco/cisco-network-puppet-module/pull/51","diff_url":"https://github.com/cisco/cisco-network-puppet-module/pull/51.diff","patch_url":"https://github.com/cisco/cisco-network-puppet-module/pull/51.patch","issue_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/issues/51","number":51,"state":"open","locked":false,"title":"Added NXOS provider for tacacs_global","user":{"login":"jonnytpuppet","id":10402750,"avatar_url":"https://avatars.githubusercontent.com/u/10402750?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnytpuppet","html_url":"https://github.com/jonnytpuppet","followers_url":"https://api.github.com/users/jonnytpuppet/followers","following_url":"https://api.github.com/users/jonnytpuppet/following{/other_user}","gists_url":"https://api.github.com/users/jonnytpuppet/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnytpuppet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnytpuppet/subscriptions","organizations_url":"https://api.github.com/users/jonnytpuppet/orgs","repos_url":"https://api.github.com/users/jonnytpuppet/repos","events_url":"https://api.github.com/users/jonnytpuppet/events{/privacy}","received_events_url":"https://api.github.com/users/jonnytpuppet/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-03T14:33:52Z","updated_at":"2015-11-10T20:05:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8b5836d7e530d115be3c424560b699781308a94","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/51/commits","review_comments_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/51/comments","review_comment_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/issues/51/comments","statuses_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/statuses/fc9aac50d380b230d4ca6863779a593b319369c7","head":{"label":"jonnytpuppet:add_tacacs_server_global","ref":"add_tacacs_server_global","sha":"fc9aac50d380b230d4ca6863779a593b319369c7","user":{"login":"jonnytpuppet","id":10402750,"avatar_url":"https://avatars.githubusercontent.com/u/10402750?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnytpuppet","html_url":"https://github.com/jonnytpuppet","followers_url":"https://api.github.com/users/jonnytpuppet/followers","following_url":"https://api.github.com/users/jonnytpuppet/following{/other_user}","gists_url":"https://api.github.com/users/jonnytpuppet/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnytpuppet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnytpuppet/subscriptions","organizations_url":"https://api.github.com/users/jonnytpuppet/orgs","repos_url":"https://api.github.com/users/jonnytpuppet/repos","events_url":"https://api.github.com/users/jonnytpuppet/events{/privacy}","received_events_url":"https://api.github.com/users/jonnytpuppet/received_events","type":"User","site_admin":false},"repo":{"id":43317277,"name":"cisco-network-puppet-module","full_name":"jonnytpuppet/cisco-network-puppet-module","owner":{"login":"jonnytpuppet","id":10402750,"avatar_url":"https://avatars.githubusercontent.com/u/10402750?v=3","gravatar_id":"","url":"https://api.github.com/users/jonnytpuppet","html_url":"https://github.com/jonnytpuppet","followers_url":"https://api.github.com/users/jonnytpuppet/followers","following_url":"https://api.github.com/users/jonnytpuppet/following{/other_user}","gists_url":"https://api.github.com/users/jonnytpuppet/gists{/gist_id}","starred_url":"https://api.github.com/users/jonnytpuppet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonnytpuppet/subscriptions","organizations_url":"https://api.github.com/users/jonnytpuppet/orgs","repos_url":"https://api.github.com/users/jonnytpuppet/repos","events_url":"https://api.github.com/users/jonnytpuppet/events{/privacy}","received_events_url":"https://api.github.com/users/jonnytpuppet/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jonnytpuppet/cisco-network-puppet-module","description":"","fork":true,"url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module","forks_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/forks","keys_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/teams","hooks_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/hooks","issue_events_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/issues/events{/number}","events_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/events","assignees_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/assignees{/user}","branches_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/branches{/branch}","tags_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/tags","blobs_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/statuses/{sha}","languages_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/languages","stargazers_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/stargazers","contributors_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/contributors","subscribers_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/subscribers","subscription_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/subscription","commits_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/contents/{+path}","compare_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/merges","archive_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/downloads","issues_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/issues{/number}","pulls_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/pulls{/number}","milestones_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/milestones{/number}","notifications_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/labels{/name}","releases_url":"https://api.github.com/repos/jonnytpuppet/cisco-network-puppet-module/releases{/id}","created_at":"2015-09-28T17:58:11Z","updated_at":"2015-09-28T17:58:12Z","pushed_at":"2015-11-10T14:16:38Z","git_url":"git://github.com/jonnytpuppet/cisco-network-puppet-module.git","ssh_url":"git@github.com:jonnytpuppet/cisco-network-puppet-module.git","clone_url":"https://github.com/jonnytpuppet/cisco-network-puppet-module.git","svn_url":"https://github.com/jonnytpuppet/cisco-network-puppet-module","homepage":null,"size":1059,"stargazers_count":0,"watchers_count":0,"language":"Ruby","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":"develop"}},"base":{"label":"cisco:develop","ref":"develop","sha":"c99bf26708aabc985592c5a6ff309d928f5a4747","user":{"login":"cisco","id":1376999,"avatar_url":"https://avatars.githubusercontent.com/u/1376999?v=3","gravatar_id":"","url":"https://api.github.com/users/cisco","html_url":"https://github.com/cisco","followers_url":"https://api.github.com/users/cisco/followers","following_url":"https://api.github.com/users/cisco/following{/other_user}","gists_url":"https://api.github.com/users/cisco/gists{/gist_id}","starred_url":"https://api.github.com/users/cisco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cisco/subscriptions","organizations_url":"https://api.github.com/users/cisco/orgs","repos_url":"https://api.github.com/users/cisco/repos","events_url":"https://api.github.com/users/cisco/events{/privacy}","received_events_url":"https://api.github.com/users/cisco/received_events","type":"Organization","site_admin":false},"repo":{"id":39565139,"name":"cisco-network-puppet-module","full_name":"cisco/cisco-network-puppet-module","owner":{"login":"cisco","id":1376999,"avatar_url":"https://avatars.githubusercontent.com/u/1376999?v=3","gravatar_id":"","url":"https://api.github.com/users/cisco","html_url":"https://github.com/cisco","followers_url":"https://api.github.com/users/cisco/followers","following_url":"https://api.github.com/users/cisco/following{/other_user}","gists_url":"https://api.github.com/users/cisco/gists{/gist_id}","starred_url":"https://api.github.com/users/cisco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cisco/subscriptions","organizations_url":"https://api.github.com/users/cisco/orgs","repos_url":"https://api.github.com/users/cisco/repos","events_url":"https://api.github.com/users/cisco/events{/privacy}","received_events_url":"https://api.github.com/users/cisco/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cisco/cisco-network-puppet-module","description":"","fork":false,"url":"https://api.github.com/repos/cisco/cisco-network-puppet-module","forks_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/forks","keys_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/teams","hooks_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/hooks","issue_events_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/issues/events{/number}","events_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/events","assignees_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/assignees{/user}","branches_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/branches{/branch}","tags_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/tags","blobs_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/git/refs{/sha}","trees_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/statuses/{sha}","languages_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/languages","stargazers_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/stargazers","contributors_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/contributors","subscribers_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/subscribers","subscription_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/subscription","commits_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/commits{/sha}","git_commits_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/git/commits{/sha}","comments_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/comments{/number}","issue_comment_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/issues/comments{/number}","contents_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/contents/{+path}","compare_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/merges","archive_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/downloads","issues_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/issues{/number}","pulls_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls{/number}","milestones_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/milestones{/number}","notifications_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/labels{/name}","releases_url":"https://api.github.com/repos/cisco/cisco-network-puppet-module/releases{/id}","created_at":"2015-07-23T12:06:48Z","updated_at":"2015-10-22T20:19:01Z","pushed_at":"2015-11-10T17:38:00Z","git_url":"git://github.com/cisco/cisco-network-puppet-module.git","ssh_url":"git@github.com:cisco/cisco-network-puppet-module.git","clone_url":"https://github.com/cisco/cisco-network-puppet-module.git","svn_url":"https://github.com/cisco/cisco-network-puppet-module","homepage":null,"size":1938,"stargazers_count":5,"watchers_count":5,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":3,"forks":19,"open_issues":3,"watchers":5,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/51"},"html":{"href":"https://github.com/cisco/cisco-network-puppet-module/pull/51"},"issue":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/issues/51"},"comments":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/issues/51/comments"},"review_comments":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/51/comments"},"review_comment":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/pulls/51/commits"},"statuses":{"href":"https://api.github.com/repos/cisco/cisco-network-puppet-module/statuses/fc9aac50d380b230d4ca6863779a593b319369c7"}}}}