Class: Fileshare
- Inherits:
-
Object
- Object
- Fileshare
- Defined in:
- lib/puppet/provider/fileshare/wmi/fileshare.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #comment ⇒ Object
- #comment=(string) ⇒ Object
- #create ⇒ Object
- #dacl ⇒ Object
- #delete ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(name) ⇒ Fileshare
constructor
A new instance of Fileshare.
- #maxcon ⇒ Object
- #maxcon=(int) ⇒ Object
- #sd=(sd) ⇒ Object
Constructor Details
#initialize(name) ⇒ Fileshare
Returns a new instance of Fileshare.
7 8 9 10 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 7 def initialize(name) @wmi_session = WIN32OLE.connect("winmgmts://localhost/root/cimv2") @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 5 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 5 def path @path end |
Instance Method Details
#comment ⇒ Object
32 33 34 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 32 def comment @wmi_session.get("Win32_Share='#{@name}'").description end |
#comment=(string) ⇒ Object
36 37 38 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 36 def comment=(string) @wmi_session.get("Win32_Share='#{@name}'").setshareinfo(maxcon, string) end |
#create ⇒ Object
12 13 14 15 16 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 12 def create wmi = WIN32OLE.connect("winmgmts:Win32_Share") creation = wmi.create(@path, @name, 0, nil, nil) evaluate_success(creation) end |
#dacl ⇒ Object
53 54 55 56 57 58 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 53 def dacl share = @wmi_session.get("Win32_LogicalShareSecuritySetting='#{@name}'") share.getsecuritydescriptor(4) returns = WIN32OLE::ARGV[0] #Retrospectively receives args from GetSecurityDescriptor return returns.DACL end |
#delete ⇒ Object
18 19 20 21 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 18 def delete deletion = @wmi_session.get("Win32_Share='#{@name}'").delete evaluate_success(deletion) end |
#exists? ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 23 def exists? begin @wmi_session.get("Win32_Share='#{@name}'") #Raises exception if share doesn't exist return true rescue return false end end |
#maxcon ⇒ Object
40 41 42 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 40 def maxcon @wmi_session.get("Win32_Share='#{@name}'").maximumallowed end |
#maxcon=(int) ⇒ Object
44 45 46 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 44 def maxcon=(int) @wmi_session.get("Win32_Share='#{@name}'").setshareinfo(int, comment) end |
#sd=(sd) ⇒ Object
48 49 50 51 |
# File 'lib/puppet/provider/fileshare/wmi/fileshare.rb', line 48 def sd=(sd) share = @wmi_session.get("Win32_LogicalShareSecuritySetting='#{@name}'") share.setsecuritydescriptor(sd) end |