summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Ireton <doug.ireton@nordstrom.com>2013-01-07 14:48:20 -0800
committerDoug Ireton <doug.ireton@nordstrom.com>2013-01-07 14:48:20 -0800
commited4eee5e0ce0cb3f44f4e78df1f0f1ce0b3cdde7 (patch)
treefa04ab273d83d19dad61b923b5f0e4ff298605ed
parent8d5b81b15ca751c439aef0dc8d9e1e7dea5a2682 (diff)
downloadmixlib-shellout-ed4eee5e0ce0cb3f44f4e78df1f0f1ce0b3cdde7.tar.gz
Polish printer and printer_port LWRPs
-rw-r--r--providers/printer.rb3
-rw-r--r--providers/printer_port.rb9
2 files changed, 7 insertions, 5 deletions
diff --git a/providers/printer.rb b/providers/printer.rb
index 3102988..95a2c85 100644
--- a/providers/printer.rb
+++ b/providers/printer.rb
@@ -65,11 +65,12 @@ def printer_exists?(name)
end
def create_printer
+
# Create the printer port first
windows_printer_port new_resource.ipv4_address do
end
- new_resource.port_name ||= "IP_#{ new_resource.ipv4_address }"
+ port_name = "IP_#{ new_resource.ipv4_address }"
powershell "Creating printer: #{ new_resource.name }" do
code <<-EOH
diff --git a/providers/printer_port.rb b/providers/printer_port.rb
index f0e9e1b..d6147f8 100644
--- a/providers/printer_port.rb
+++ b/providers/printer_port.rb
@@ -70,7 +70,7 @@ end
def create_printer_port
- new_resource.port_name ||= "IP_#{ new_resource.ipv4_address }"
+ port_name = new_resource.port_name || "IP_#{ new_resource.ipv4_address }"
# create the printer port using PowerShell
powershell "Creating printer port #{ new_resource.port_name }" do
@@ -79,7 +79,7 @@ def create_printer_port
Set-WmiInstance -class Win32_TCPIPPrinterPort `
-EnableAllPrivileges `
-Argument @{ HostAddress = "#{ new_resource.ipv4_address }";
- Name = "#{ new_resource.port_name }";
+ Name = "#{ port_name }";
Description = "#{ new_resource.port_description }";
PortNumber = "#{ new_resource.port_number }";
Protocol = "#{ new_resource.port_protocol }";
@@ -90,11 +90,12 @@ def create_printer_port
end
def delete_printer_port
- new_resource.port_name ||= "IP_#{ new_resource.ipv4_address }"
+
+ port_name = new_resource.port_name || "IP_#{ new_resource.ipv4_address }"
powershell "Deleting printer port: #{ new_resource.port_name }" do
code <<-EOH
- $port = Get-WMIObject -class Win32_TCPIPPrinterPort -EnableAllPrivileges -Filter "name = '#{ new_resource.port_name }'"
+ $port = Get-WMIObject -class Win32_TCPIPPrinterPort -EnableAllPrivileges -Filter "name = '#{ port_name }'"
$port.Delete()
EOH
end