summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-01-16 10:56:06 -0800
committerTim Smith <tsmith@chef.io>2019-01-17 15:56:50 -0800
commitda9d29cb242cc47316f70a88ad9e15d2aa6d0cb5 (patch)
tree3e14e8449f779147a6d2f77e69d47b4a0c4803a2
parentaaf199ae2b5d44af59ccb738cf3e4a0f9c3ab40e (diff)
downloadchef-da9d29cb242cc47316f70a88ad9e15d2aa6d0cb5.tar.gz
windows_printer: prevent failures when deleting printers and using device_id property
We have a name_property of device_id for this resource but we weren't using it in the delete_printer method so if you used the name property the deletion would fail. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/windows_printer.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/resource/windows_printer.rb b/lib/chef/resource/windows_printer.rb
index 605b7b8521..8ddb085ee3 100644
--- a/lib/chef/resource/windows_printer.rb
+++ b/lib/chef/resource/windows_printer.rb
@@ -114,7 +114,7 @@ class Chef
port_name = "IP_#{new_resource.ipv4_address}"
- declare_resource(:powershell_script, "Creating printer: #{new_resource.name}") do
+ declare_resource(:powershell_script, "Creating printer: #{new_resource.device_id}") do
code <<-EOH
Set-WmiInstance -class Win32_Printer `
@@ -133,9 +133,9 @@ class Chef
end
def delete_printer
- declare_resource(:powershell_script, "Deleting printer: #{new_resource.name}") do
+ declare_resource(:powershell_script, "Deleting printer: #{new_resource.device_id}") do
code <<-EOH
- $printer = Get-WMIObject -class Win32_Printer -EnableAllPrivileges -Filter "name = '#{new_resource.name}'"
+ $printer = Get-WMIObject -class Win32_Printer -EnableAllPrivileges -Filter "name = '#{new_resource.device_id}'"
$printer.Delete()
EOH
end