summaryrefslogtreecommitdiff
path: root/providers
diff options
context:
space:
mode:
Diffstat (limited to 'providers')
-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