From a9a7c85391d100a0e5b7fe51cecae3852836ebf2 Mon Sep 17 00:00:00 2001 From: Roberto Garza Date: Wed, 18 Feb 2015 15:12:37 -0600 Subject: [PATCH 1/8] generate md5 for current_resource.checksum --- metadata.rb | 2 +- providers/file.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.rb b/metadata.rb index 2c57c1a..6ad684f 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,6 +4,6 @@ license "Apache 2.0" description "Provides LWRP's for managing Rackspace Cloud resources." long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "0.1.1" +version "0.1.2" depends "xml" diff --git a/providers/file.rb b/providers/file.rb index 97d9e91..34fdc08 100644 --- a/providers/file.rb +++ b/providers/file.rb @@ -33,7 +33,7 @@ def load_current_resource if ::File.exists?(@current_resource.filename) @current_resource.exists = true - @current_resource.checksum = Chef::Digester.checksum_for_file(@current_resource.filename) + @current_resource.checksum = Chef::Digester.generate_md5_checksum_for_file(@current_resource.filename) else @current_resource.exists = false end From 4d32cf119c42095c20747374f236fb49e0653c80 Mon Sep 17 00:00:00 2001 From: Roberto Garza Date: Wed, 18 Feb 2015 15:53:52 -0600 Subject: [PATCH 2/8] printing md5sums --- providers/file.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/providers/file.rb b/providers/file.rb index 34fdc08..4094eec 100644 --- a/providers/file.rb +++ b/providers/file.rb @@ -51,6 +51,10 @@ def load_current_resource directory = get_directory(new_resource.directory) remote_file = directory.files.get(::File.basename(new_resource.filename)) + puts 'current file checksum: ' + current_resource.checksum + puts 'cloud files checksum: ' + remote_file.etag + + if !current_resource.exists || remote_file.etag != current_resource.checksum directory.files.get(::File.basename(new_resource.filename)) do |data, remaining, content_length| f.syswrite data From b13d9c4e76cbd481b24eb42648bf9e958f25a544 Mon Sep 17 00:00:00 2001 From: Roberto Garza Date: Wed, 18 Feb 2015 16:08:20 -0600 Subject: [PATCH 3/8] removing print statements --- providers/file.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/providers/file.rb b/providers/file.rb index 4094eec..34fdc08 100644 --- a/providers/file.rb +++ b/providers/file.rb @@ -51,10 +51,6 @@ def load_current_resource directory = get_directory(new_resource.directory) remote_file = directory.files.get(::File.basename(new_resource.filename)) - puts 'current file checksum: ' + current_resource.checksum - puts 'cloud files checksum: ' + remote_file.etag - - if !current_resource.exists || remote_file.etag != current_resource.checksum directory.files.get(::File.basename(new_resource.filename)) do |data, remaining, content_length| f.syswrite data From eaf27132a46a871353fa0bec75adc761b2d4c23f Mon Sep 17 00:00:00 2001 From: Roberto Garza Date: Fri, 20 Feb 2015 10:58:47 -0600 Subject: [PATCH 4/8] updating logic --- providers/file.rb | 4 ++-- resources/file.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/providers/file.rb b/providers/file.rb index 34fdc08..c69398b 100644 --- a/providers/file.rb +++ b/providers/file.rb @@ -33,7 +33,7 @@ def load_current_resource if ::File.exists?(@current_resource.filename) @current_resource.exists = true - @current_resource.checksum = Chef::Digester.generate_md5_checksum_for_file(@current_resource.filename) + @current_resource.md5sum = Chef::Digester.generate_md5_checksum_for_file(@current_resource.filename) else @current_resource.exists = false end @@ -51,7 +51,7 @@ def load_current_resource directory = get_directory(new_resource.directory) remote_file = directory.files.get(::File.basename(new_resource.filename)) - if !current_resource.exists || remote_file.etag != current_resource.checksum + if current_resource.exists && remote_file.etag != current_resource.md5sum directory.files.get(::File.basename(new_resource.filename)) do |data, remaining, content_length| f.syswrite data end diff --git a/resources/file.rb b/resources/file.rb index 070ce11..46332f3 100644 --- a/resources/file.rb +++ b/resources/file.rb @@ -27,6 +27,9 @@ attribute :rackspace_region, :kind_of => String, :default => "dfw" attribute :rackspace_auth_url, :kind_of => String attribute :filename, :kind_of => String, :name_attribute => true +attribute :group, :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ] +attribute :owner, :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ] +attribute :mode, :regex => /^0?\d{3,4}$/ attribute :directory, :kind_of => String, :required => true attribute :binmode, :kind_of => [ TrueClass, FalseClass ], :default => false From 02f8cd73067aee81dbf7da99766e24e71cdace68 Mon Sep 17 00:00:00 2001 From: Roberto Garza Date: Fri, 20 Feb 2015 11:08:12 -0600 Subject: [PATCH 5/8] updating conditionals --- providers/file.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/providers/file.rb b/providers/file.rb index c69398b..99d481e 100644 --- a/providers/file.rb +++ b/providers/file.rb @@ -55,10 +55,13 @@ def load_current_resource directory.files.get(::File.basename(new_resource.filename)) do |data, remaining, content_length| f.syswrite data end - converge_by("Moving new file with checksum to #{new_resource.filename}") do move_file(f.path, new_resource.filename) end + elsif !current_resource.exists + directory.files.get(::File.basename(new_resource.filename)) do |data, remaining, content_length| + f.syswrite data + end else f.unlink end From 03c6524b30028571b2557b89f2e79876f028aa5f Mon Sep 17 00:00:00 2001 From: Roberto Garza Date: Fri, 20 Feb 2015 11:10:25 -0600 Subject: [PATCH 6/8] version bump --- metadata.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.rb b/metadata.rb index 6ad684f..f2c90fa 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,6 +4,6 @@ license "Apache 2.0" description "Provides LWRP's for managing Rackspace Cloud resources." long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version "0.1.2" +version "0.1.3" depends "xml" From 1cf739a0d572a3f16005ae2b673aa4692311c1ab Mon Sep 17 00:00:00 2001 From: Roberto Garza Date: Fri, 20 Feb 2015 11:27:13 -0600 Subject: [PATCH 7/8] fixing typo --- providers/file.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/file.rb b/providers/file.rb index 99d481e..d823aed 100644 --- a/providers/file.rb +++ b/providers/file.rb @@ -33,7 +33,7 @@ def load_current_resource if ::File.exists?(@current_resource.filename) @current_resource.exists = true - @current_resource.md5sum = Chef::Digester.generate_md5_checksum_for_file(@current_resource.filename) + @current_resource.checksum = Chef::Digester.generate_md5_checksum_for_file(@current_resource.filename) else @current_resource.exists = false end @@ -51,7 +51,7 @@ def load_current_resource directory = get_directory(new_resource.directory) remote_file = directory.files.get(::File.basename(new_resource.filename)) - if current_resource.exists && remote_file.etag != current_resource.md5sum + if current_resource.exists && remote_file.etag != current_resource.checksum directory.files.get(::File.basename(new_resource.filename)) do |data, remaining, content_length| f.syswrite data end From 9a9b5caebd782e241f9015448d055861836145a4 Mon Sep 17 00:00:00 2001 From: Roberto Garza Date: Fri, 20 Feb 2015 11:58:12 -0600 Subject: [PATCH 8/8] removing unsupported ownership and mode attributes --- resources/file.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/resources/file.rb b/resources/file.rb index 46332f3..070ce11 100644 --- a/resources/file.rb +++ b/resources/file.rb @@ -27,9 +27,6 @@ attribute :rackspace_region, :kind_of => String, :default => "dfw" attribute :rackspace_auth_url, :kind_of => String attribute :filename, :kind_of => String, :name_attribute => true -attribute :group, :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ] -attribute :owner, :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ] -attribute :mode, :regex => /^0?\d{3,4}$/ attribute :directory, :kind_of => String, :required => true attribute :binmode, :kind_of => [ TrueClass, FalseClass ], :default => false