inetmgr 0.2.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +51 -0
- data/inetmgr.gemspec +22 -0
- data/lib/inetmgr.rb +23 -0
- data/lib/inetmgr/iis_configuration.rb +40 -0
- data/lib/inetmgr/iis_object.rb +52 -0
- data/lib/inetmgr/iis_object/application.rb +9 -0
- data/lib/inetmgr/iis_object/application_pool.rb +26 -0
- data/lib/inetmgr/iis_object/auto_start_provider.rb +3 -0
- data/lib/inetmgr/iis_object/binding_information.rb +8 -0
- data/lib/inetmgr/iis_object/site.rb +10 -0
- data/lib/inetmgr/iis_object/virtual_directory.rb +5 -0
- data/lib/inetmgr/iis_object_collection.rb +43 -0
- data/lib/rake/inetmgrtask.rb +74 -0
- data/nbproject/private/config.properties +0 -0
- data/nbproject/private/private.properties +4 -0
- data/nbproject/private/rake-d.txt +2 -0
- data/nbproject/project.properties +10 -0
- data/nbproject/project.xml +16 -0
- data/spec/application_pool_spec.rb +88 -0
- data/spec/application_spec.rb +38 -0
- data/spec/auto_start_provider_spec.rb +25 -0
- data/spec/iis_configuration_spec.rb +35 -0
- data/spec/site_spec.rb +34 -0
- data/spec/spec_env.rb +23 -0
- data/spec/virtual_directory_spec.rb +1 -0
- data/test/print_iis_config.rb +36 -0
- data/test/rakefile.rb +27 -0
- metadata +94 -0
data/README.rdoc
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
= About inetmgr
|
2
|
+
|
3
|
+
inetmgr is primarily a library that helps automate the configuration of IIS. It
|
4
|
+
provides a straightforward ruby-like interface on top of the configuration API,
|
5
|
+
which lets you inspect add/remove and modify various IIS objects like sites,
|
6
|
+
application pools, bindings, virtual directories, etc.
|
7
|
+
|
8
|
+
Additionally, intemgr provides some basic rake tasks that help adding IIS
|
9
|
+
deployment aspects to your build (& deploy) process.
|
10
|
+
|
11
|
+
== How to install
|
12
|
+
|
13
|
+
Get the gem:
|
14
|
+
|
15
|
+
> gem install inetmgr
|
16
|
+
|
17
|
+
That should do the trick. Another option would be forking the source from github:
|
18
|
+
|
19
|
+
> git clone git@github.com:typesafe/inetmgr.git inetmgr
|
20
|
+
|
21
|
+
== How to use
|
22
|
+
|
23
|
+
*Note*: inetmgr requires a Windows machine (well, duh) with IIS7+ and depends on
|
24
|
+
WIN32OLE (for the sake of wrapping), which should be available by default.
|
25
|
+
|
26
|
+
require 'inetmgr'
|
27
|
+
|
28
|
+
cfg = IisConfiguration.new
|
29
|
+
|
30
|
+
cfg.get_sites.each do |site|
|
31
|
+
puts 'site: #{site.name}'
|
32
|
+
end
|
33
|
+
|
34
|
+
cfg.application_pools.add { |p| p.name = "newPool" }
|
35
|
+
cfg.apply_changes
|
36
|
+
|
37
|
+
== License
|
38
|
+
|
39
|
+
Copyright (c) 2010 Gino Heyman
|
40
|
+
|
41
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
42
|
+
you may not use this file except in compliance with the License.
|
43
|
+
You may obtain a copy of the License at
|
44
|
+
|
45
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
46
|
+
|
47
|
+
Unless required by applicable law or agreed to in writing, software
|
48
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
49
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
50
|
+
See the License for the specific language governing permissions and
|
51
|
+
limitations under the License.
|
data/inetmgr.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
|
6
|
+
s.platform = 'mswin32'
|
7
|
+
s.name = "inetmgr"
|
8
|
+
s.version = "0.2.0"
|
9
|
+
s.summary = "A library for managing IIS configuration settings."
|
10
|
+
s.description = "inetmgr allows you to inspect/configure IIS configuration sections and elements."
|
11
|
+
|
12
|
+
s.required_ruby_version = '>= 1.8.7'
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
|
15
|
+
s.author = "Gino Heyman"
|
16
|
+
s.email = "gino.heyman@gmail.com"
|
17
|
+
s.homepage = "http://typesafe.be/inetmgr/"
|
18
|
+
|
19
|
+
s.files = FileList["**/**/*"].to_a
|
20
|
+
s.require_path = "lib"
|
21
|
+
|
22
|
+
end
|
data/lib/inetmgr.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'win32ole'
|
2
|
+
|
3
|
+
path = File.expand_path(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
requires =
|
6
|
+
[
|
7
|
+
'inetmgr/iis_object_collection.rb',
|
8
|
+
'inetmgr/iis_object.rb',
|
9
|
+
'inetmgr/iis_object/virtual_directory.rb',
|
10
|
+
'inetmgr/iis_object/application.rb',
|
11
|
+
'inetmgr/iis_object/binding_information.rb',
|
12
|
+
'inetmgr/iis_object/site.rb'
|
13
|
+
]
|
14
|
+
|
15
|
+
requires.each do |file|
|
16
|
+
require File.join(path, file)
|
17
|
+
end
|
18
|
+
|
19
|
+
Dir.glob(File.join(path, 'inetmgr/iis_object/*.rb')).each do |f|
|
20
|
+
require f unless requires.include?(f)
|
21
|
+
end
|
22
|
+
|
23
|
+
require File.join(path, 'inetmgr/iis_configuration.rb')
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
# Represents the local IIS configuration settings (meta base)
|
3
|
+
class IisConfiguration
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@admin_manager = WIN32OLE.new "Microsoft.ApplicationHost.WritableAdminManager"
|
7
|
+
@admin_manager.CommitPath = "MACHINE/WEBROOT/APPHOST";
|
8
|
+
end
|
9
|
+
|
10
|
+
# applies/commits all changes made since the creation of the
|
11
|
+
# IisConfiguration instance or the last time this method was called.
|
12
|
+
def apply_changes
|
13
|
+
@admin_manager.CommitChanges
|
14
|
+
end
|
15
|
+
|
16
|
+
# Gets all configured web sites.
|
17
|
+
def get_sites
|
18
|
+
s = get_config_section "system.applicationHost/sites"
|
19
|
+
IisObjectCollection.new s.Collection, :site, Site, lambda { |site| site.id = s.Collection.Count + 1 }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Gets all configure application pools.
|
23
|
+
def get_application_pools
|
24
|
+
s = get_config_section "system.applicationHost/applicationPools"
|
25
|
+
IisObjectCollection.new s.Collection, :add, ApplicationPool
|
26
|
+
end
|
27
|
+
|
28
|
+
# Gets all configured service auto start providers.
|
29
|
+
def get_auto_start_providers
|
30
|
+
s = get_config_section "system.applicationHost/serviceAutoStartProviders"
|
31
|
+
IisObjectCollection.new s.Collection, :add, AutoStartProvider
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def get_config_section section_name, path = "MACHINE/WEBROOT/APPHOST"
|
37
|
+
@admin_manager.GetAdminSection(section_name, path)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
class IisObject
|
3
|
+
|
4
|
+
def initialize element
|
5
|
+
@element = element
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.prop name, actual_name, setter = Proc.new { |v| v }, reader = Proc.new { |v| v }
|
9
|
+
define_method(name.to_s) do
|
10
|
+
reader.call(@element.Properties.Item(actual_name.to_s).Value)
|
11
|
+
end
|
12
|
+
|
13
|
+
define_method("#{name.to_s}=") do |val|
|
14
|
+
@element.Properties.Item(actual_name.to_s).Value = setter.call(val)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.collection name, item_name, type
|
19
|
+
define_method(name.to_s) do
|
20
|
+
IisObjectCollection.new @element.Collection, item_name.to_s, type
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.children name, item_name, type
|
25
|
+
define_method(name.to_s) do
|
26
|
+
IisObjectCollection.new @element.ChildElements.Item(name.to_s).Collection, item_name.to_s, type
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.child name, element_name, type
|
31
|
+
define_method(name.to_s) do
|
32
|
+
type.new @element.ChildElements.Item(element_name.to_s)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def element
|
37
|
+
@element
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def method_missing(symbol, *args)
|
43
|
+
name = symbol.to_s
|
44
|
+
if (/=$/.match(name))
|
45
|
+
@element.Properties.Item(name.sub(/=$/, '')).Value = args[0]
|
46
|
+
else
|
47
|
+
@element.Properties.Item(name).Value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
class ProcessModel < IisObject
|
3
|
+
|
4
|
+
end
|
5
|
+
|
6
|
+
class PeriodicRestart < IisObject
|
7
|
+
children :schedule, :schedule, IisObject
|
8
|
+
end
|
9
|
+
|
10
|
+
class Recycling < IisObject
|
11
|
+
child :periodic_restart, :periodicRestart, PeriodicRestart
|
12
|
+
end
|
13
|
+
|
14
|
+
class ApplicationPool < IisObject
|
15
|
+
|
16
|
+
prop :auto_start, :autoStart, Proc.new { |a| a == true ? "true" : "false" }, Proc.new {|value| value == "true" }
|
17
|
+
prop :runtime_version, :managedRuntimeVersion, Proc.new { |a| a }, Proc.new {|value| value }
|
18
|
+
prop :classic_pipeline, :managedPipelineMode, Proc.new { |a| a == true ? 1 : 0 }, Proc.new {|value| value.to_i == 1 }
|
19
|
+
prop :enable_32bit, :enable32BitAppOnWin64, Proc.new { |a| a }, Proc.new {|value| value }
|
20
|
+
prop :always_running, :startMode, Proc.new { |a| a == true ? "AlwaysRunning" : "OnDemand" },Proc.new {|value| value.to_i == 1 }
|
21
|
+
|
22
|
+
child :process_model, :processModel, ProcessModel
|
23
|
+
child :recycling, :recycling, Recycling
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Represents a collection of IIS configuration objects.
|
2
|
+
class IisObjectCollection
|
3
|
+
|
4
|
+
def initialize element, item_name, type, add_callback = nil
|
5
|
+
@collection_element = element
|
6
|
+
@item_name = item_name
|
7
|
+
@type = type
|
8
|
+
@add_callback = add_callback
|
9
|
+
end
|
10
|
+
|
11
|
+
def size
|
12
|
+
@collection_element.Count
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](index)
|
16
|
+
return @type.new @collection_element.Item index
|
17
|
+
end
|
18
|
+
|
19
|
+
def each
|
20
|
+
size.times { |i| yield self[i] }
|
21
|
+
end
|
22
|
+
|
23
|
+
def add
|
24
|
+
e = @collection_element.CreateNewElement @item_name.to_s
|
25
|
+
added = @type.new e
|
26
|
+
@add_callback.call added unless @add_callback.nil?
|
27
|
+
yield added
|
28
|
+
@collection_element.AddElement e
|
29
|
+
added
|
30
|
+
end
|
31
|
+
|
32
|
+
def find
|
33
|
+
size.times do |i|
|
34
|
+
instance = self[i]
|
35
|
+
return instance if yield(instance)
|
36
|
+
end
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
def remove(index)
|
41
|
+
@collection_element.DeleteElement index
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rake/tasklib'
|
2
|
+
|
3
|
+
module Inetmgr
|
4
|
+
|
5
|
+
class InetmgrTask < ::Rake::TaskLib
|
6
|
+
attr_accessor :name
|
7
|
+
|
8
|
+
def initialize(name, *args, &block)
|
9
|
+
@block = block
|
10
|
+
args = args.insert(0, name)
|
11
|
+
define name, args
|
12
|
+
end
|
13
|
+
|
14
|
+
def define(name, args)
|
15
|
+
task *args do |task, task_args|
|
16
|
+
@task_args = task_args
|
17
|
+
execute name.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def call_task_block(obj)
|
22
|
+
if !@block.nil?
|
23
|
+
if @block.arity == 1
|
24
|
+
@block.call(obj)
|
25
|
+
else
|
26
|
+
@block.call(obj, @task_args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_task(taskname, task_object_proc, &execute_body)
|
34
|
+
taskclass = :"Inetmgr_TaskFor_#{taskname}"
|
35
|
+
taskmethod = taskname.to_s.downcase.to_sym
|
36
|
+
|
37
|
+
Object.class_eval(<<-EOF, __FILE__, __LINE__)
|
38
|
+
def #{taskmethod}(name=:#{taskname}, *args, &block)
|
39
|
+
Inetmgr.const_get("#{taskclass}").new(name, *args, &block)
|
40
|
+
end
|
41
|
+
EOF
|
42
|
+
|
43
|
+
Inetmgr.class_eval do
|
44
|
+
const_set(taskclass, Class.new(Inetmgr::InetmgrTask) do
|
45
|
+
define_method :execute do |name|
|
46
|
+
task_object = task_object_proc.call
|
47
|
+
|
48
|
+
call_task_block(task_object)
|
49
|
+
execute_body.call(task_object) unless execute_body.nil?
|
50
|
+
end
|
51
|
+
end)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
create_task :application_pool, Proc.new { ApplicationPool.new } do |pool|
|
57
|
+
pool.create
|
58
|
+
end
|
59
|
+
|
60
|
+
create_task :application, Proc.new { Application.new } do |pool|
|
61
|
+
pool.create
|
62
|
+
end
|
63
|
+
|
64
|
+
create_task :site, Proc.new { Site.new } do |site|
|
65
|
+
site.create
|
66
|
+
end
|
67
|
+
|
68
|
+
create_task :auto_start_provider, Proc.new { AutoStartProvider.new } do |p|
|
69
|
+
p.create
|
70
|
+
end
|
71
|
+
|
72
|
+
create_task :virtual_directory, Proc.new { VirtualDirectory.new } do |dir|
|
73
|
+
dir.create
|
74
|
+
end
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
file.reference.inetmgr-lib=lib
|
2
|
+
file.reference.inetmgr-spec=spec
|
3
|
+
file.reference.inetmgr-test=test
|
4
|
+
javac.classpath=
|
5
|
+
main.file=
|
6
|
+
platform.active=Ruby
|
7
|
+
source.encoding=UTF-8
|
8
|
+
src.dir=${file.reference.inetmgr-lib}
|
9
|
+
test.spec.dir=spec
|
10
|
+
test.src.dir=${file.reference.inetmgr-test}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://www.netbeans.org/ns/project/1">
|
3
|
+
<type>org.netbeans.modules.ruby.rubyproject</type>
|
4
|
+
<configuration>
|
5
|
+
<data xmlns="http://www.netbeans.org/ns/ruby-project/1">
|
6
|
+
<name>inetmgr</name>
|
7
|
+
<source-roots>
|
8
|
+
<root id="src.dir"/>
|
9
|
+
</source-roots>
|
10
|
+
<test-roots>
|
11
|
+
<root id="test.spec.dir"/>
|
12
|
+
<root id="test.src.dir"/>
|
13
|
+
</test-roots>
|
14
|
+
</data>
|
15
|
+
</configuration>
|
16
|
+
</project>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_env'
|
2
|
+
|
3
|
+
describe "When adding a new application pool" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@pools = IisConfiguration.new.get_application_pools
|
7
|
+
@before_count = @pools.size
|
8
|
+
@pool = @pools.add do |p|
|
9
|
+
p.name = "tralala"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "it should be present in the application pool collection" do
|
14
|
+
@pools.size.should == @before_count + 1
|
15
|
+
end
|
16
|
+
|
17
|
+
it "the auto_start value should default to false" do
|
18
|
+
@pool.auto_start.should == false
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO: fix this -> it depends on the defaults in the config
|
22
|
+
it "the runtime_version value should default to 'v2.0'" do
|
23
|
+
@pool.runtime_version.should == "v2.0"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "the classic_pipeline value should default to false" do
|
27
|
+
@pool.classic_pipeline.should == false
|
28
|
+
end
|
29
|
+
|
30
|
+
it "the enable_32bit value should default to false" do
|
31
|
+
@pool.enable_32bit.should == false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "the always_running value should default to false" do
|
35
|
+
@pool.always_running.should == false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "When updating application pool" do
|
40
|
+
|
41
|
+
before(:all) do
|
42
|
+
|
43
|
+
@name = generate_random_name()
|
44
|
+
|
45
|
+
configure do |cfg|
|
46
|
+
|
47
|
+
pool = cfg.get_application_pools.add { |p| p.name = @name } # defaults
|
48
|
+
|
49
|
+
pool.auto_start = true
|
50
|
+
pool.runtime_version = "v4.0"
|
51
|
+
pool.classic_pipeline = true
|
52
|
+
pool.enable_32bit = true
|
53
|
+
pool.always_running = true
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
configure do |cfg|
|
58
|
+
@pool = cfg.get_application_pools.find { |p| p.name == @name }
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
it "the name should be changed" do
|
64
|
+
@pool.name.should == @name
|
65
|
+
end
|
66
|
+
|
67
|
+
it "the auto_start value should be changed" do
|
68
|
+
@pool.auto_start.should == false
|
69
|
+
end
|
70
|
+
|
71
|
+
it "the runtime_version value should be changed" do
|
72
|
+
@pool.runtime_version.should == "v4.0"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "the classic_pipeline value should be changed" do
|
76
|
+
@pool.classic_pipeline.should == true
|
77
|
+
end
|
78
|
+
|
79
|
+
it "the enable_32bit value should be changed" do
|
80
|
+
@pool.enable_32bit.should == true
|
81
|
+
end
|
82
|
+
|
83
|
+
it "the always_running value should be changed" do
|
84
|
+
puts @pool.startMode
|
85
|
+
@pool.always_running.should == true
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_env'
|
2
|
+
|
3
|
+
describe "When adding an Application to a site" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
|
7
|
+
configure do |cfg|
|
8
|
+
site = cfg.get_sites[0]
|
9
|
+
@app_name = "/#{generate_random_name}"
|
10
|
+
site.applications.add do|a|
|
11
|
+
a.path = @app_name
|
12
|
+
a.virtual_directories.add do |vd|
|
13
|
+
vd.path = @app_name
|
14
|
+
vd.physicalPath = "D:\\"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
configure do |cfg|
|
20
|
+
@site = cfg.get_sites[0]
|
21
|
+
@app = @site.applications.find {|a| a.path == @app_name}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "the app should be added" do
|
26
|
+
@app.should_not be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it "the app should contain the associated virtual directory" do
|
30
|
+
@app.virtual_directories.size.should == 1
|
31
|
+
end
|
32
|
+
|
33
|
+
it "the virtual directory physical path should be set" do
|
34
|
+
@app.virtual_directories[0].physicalPath.should == "D:\\"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_env'
|
2
|
+
|
3
|
+
describe "When adding an auto start provider" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
configure do |cfg|
|
7
|
+
@name = generate_random_name
|
8
|
+
@type = generate_random_name
|
9
|
+
@provider = cfg.get_auto_start_providers.add { |p| p.name = @name; p.type = @type }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "the provider should not be nil" do
|
14
|
+
@provider.should_not be_nil
|
15
|
+
end
|
16
|
+
|
17
|
+
it "the provider name should be set" do
|
18
|
+
@provider.name.should == @name
|
19
|
+
end
|
20
|
+
|
21
|
+
it "the provider type should be set" do
|
22
|
+
@provider.type.should == @type
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_env'
|
2
|
+
|
3
|
+
describe "When getting the configured application pools" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
configure do |cfg|
|
7
|
+
@pools = cfg.get_application_pools
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "at least one item should be returned" do
|
12
|
+
@pools.size > 1
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "When rolling back configuration changes" do
|
18
|
+
|
19
|
+
before(:all) do
|
20
|
+
configure false do |cfg|
|
21
|
+
cfg.get_application_pools.add do |p|
|
22
|
+
p.name = "foobar"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
configure false do |cfg|
|
26
|
+
@non_existing_pool = cfg.get_application_pools.find { |p| p.name == "foobar" }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "the changes should not be applied" do
|
31
|
+
@non_existing_pool.should be_nil
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
data/spec/site_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_env'
|
2
|
+
|
3
|
+
describe "When getting the configured sites" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
configure do |cfg|
|
7
|
+
@sites = cfg.get_sites
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "at least one item should be returned" do
|
12
|
+
@sites.size > 1
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "When adding a new site" do
|
18
|
+
|
19
|
+
before(:all) do
|
20
|
+
configure do |cfg|
|
21
|
+
@sites = cfg.get_sites
|
22
|
+
@site = @sites.add { |s| s.name = generate_random_name }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "the site should be created" do
|
27
|
+
@site.should_not be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "the site should have the highest id" do
|
31
|
+
@site.id.should == @sites.size
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/spec/spec_env.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'spec_env'
|
4
|
+
require 'uuid'
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "../lib/inetmgr"))
|
6
|
+
|
7
|
+
module RSpecExtensions
|
8
|
+
|
9
|
+
def configure(apply_changes = true)
|
10
|
+
cfg = IisConfiguration.new
|
11
|
+
yield cfg
|
12
|
+
cfg.apply_changes if apply_changes
|
13
|
+
end
|
14
|
+
|
15
|
+
def generate_random_name
|
16
|
+
UUID.generate(:compact).to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
Spec::Runner.configure do |config|
|
22
|
+
config.include RSpecExtensions
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'spec_env'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require '..\lib\inetmgr.rb'
|
2
|
+
|
3
|
+
cfg = IisConfiguration.new
|
4
|
+
|
5
|
+
sites = cfg.get_sites
|
6
|
+
pools = cfg.get_application_pools
|
7
|
+
|
8
|
+
pools.each do |p|
|
9
|
+
puts "\r\nPOOL: #{p.name}"
|
10
|
+
puts "----"
|
11
|
+
|
12
|
+
puts " - process_model:"
|
13
|
+
puts " - identityType: #{p.process_model.identityType}"
|
14
|
+
|
15
|
+
puts " - recycling:"
|
16
|
+
puts " - logEventOnRecycle: #{p.recycling.logEventOnRecycle}"
|
17
|
+
puts " - periodic_restart.schedulecount: #{p.recycling.periodic_restart.schedule.size}"
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
sites.each do |s|
|
22
|
+
|
23
|
+
puts "SITE: #{s.name} #{s.bindings.size}"
|
24
|
+
|
25
|
+
s.bindings.each do |b|
|
26
|
+
puts "binding: #{b.protocol} - #{b.binding_information}"
|
27
|
+
end
|
28
|
+
|
29
|
+
s.applications.each do |a|
|
30
|
+
puts " app: #{a.path}"
|
31
|
+
a.virtual_directories.each do |d|
|
32
|
+
puts " dir: #{d.path}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/test/rakefile.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require '../lib/inetmgr'
|
2
|
+
|
3
|
+
task :default => [:show_all_settings]
|
4
|
+
|
5
|
+
task :show_all_settings do
|
6
|
+
|
7
|
+
cfg = IisConfiguration.new
|
8
|
+
|
9
|
+
puts "APPLICATION POOLS:"
|
10
|
+
puts ""
|
11
|
+
puts "name |auto_start|runtime_version|classic_pipeline|always_running"
|
12
|
+
puts "------------------------------------------------------------------------------------"
|
13
|
+
cfg.get_application_pools.each do |p|
|
14
|
+
puts sprintf "%-25s|%-10s|%-15s|%-16s|%-s", p.name, p.auto_start, p.runtime_version, p.classic_pipeline, p.always_running
|
15
|
+
end
|
16
|
+
|
17
|
+
puts "SITES:"
|
18
|
+
puts ""
|
19
|
+
puts "name |auto_start"
|
20
|
+
puts "------------------------------------------"
|
21
|
+
cfg.get_sites.each do |s|
|
22
|
+
puts sprintf "%-25s|%-10s", s.name, s.auto_start
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: inetmgr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
|
+
platform: mswin32
|
11
|
+
authors:
|
12
|
+
- Gino Heyman
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-14 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: inetmgr allows you to inspect/configure IIS configuration sections and elements.
|
22
|
+
email: gino.heyman@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- inetmgr.gemspec
|
31
|
+
- lib/inetmgr/iis_configuration.rb
|
32
|
+
- lib/inetmgr/iis_object/application.rb
|
33
|
+
- lib/inetmgr/iis_object/application_pool.rb
|
34
|
+
- lib/inetmgr/iis_object/auto_start_provider.rb
|
35
|
+
- lib/inetmgr/iis_object/binding_information.rb
|
36
|
+
- lib/inetmgr/iis_object/site.rb
|
37
|
+
- lib/inetmgr/iis_object/virtual_directory.rb
|
38
|
+
- lib/inetmgr/iis_object.rb
|
39
|
+
- lib/inetmgr/iis_object_collection.rb
|
40
|
+
- lib/inetmgr.rb
|
41
|
+
- lib/rake/inetmgrtask.rb
|
42
|
+
- nbproject/private/config.properties
|
43
|
+
- nbproject/private/private.properties
|
44
|
+
- nbproject/private/rake-d.txt
|
45
|
+
- nbproject/project.properties
|
46
|
+
- nbproject/project.xml
|
47
|
+
- README.rdoc
|
48
|
+
- spec/application_pool_spec.rb
|
49
|
+
- spec/application_spec.rb
|
50
|
+
- spec/auto_start_provider_spec.rb
|
51
|
+
- spec/iis_configuration_spec.rb
|
52
|
+
- spec/site_spec.rb
|
53
|
+
- spec/spec_env.rb
|
54
|
+
- spec/virtual_directory_spec.rb
|
55
|
+
- test/print_iis_config.rb
|
56
|
+
- test/rakefile.rb
|
57
|
+
has_rdoc: true
|
58
|
+
homepage: http://typesafe.be/inetmgr/
|
59
|
+
licenses: []
|
60
|
+
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
segments:
|
72
|
+
- 1
|
73
|
+
- 8
|
74
|
+
- 7
|
75
|
+
version: 1.8.7
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 1
|
83
|
+
- 3
|
84
|
+
- 6
|
85
|
+
version: 1.3.6
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.3.7
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: A library for managing IIS configuration settings.
|
93
|
+
test_files: []
|
94
|
+
|