right_link 5.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/actors/agent_manager.rb +88 -0
- data/actors/instance_scheduler.rb +321 -0
- data/actors/instance_services.rb +64 -0
- data/actors/instance_setup.rb +567 -0
- data/bin/cloud +25 -0
- data/bin/cook_runner +44 -0
- data/bin/deploy +120 -0
- data/bin/enroll +385 -0
- data/bin/rad +32 -0
- data/bin/rchk +29 -0
- data/bin/rnac +39 -0
- data/bin/rs_connect +33 -0
- data/bin/rs_log_level +31 -0
- data/bin/rs_ohai +28 -0
- data/bin/rs_reenroll +31 -0
- data/bin/rs_run_recipe +34 -0
- data/bin/rs_run_right_script +34 -0
- data/bin/rs_shutdown +33 -0
- data/bin/rs_tag +33 -0
- data/bin/rs_thunk +33 -0
- data/bin/rstat +31 -0
- data/bin/system +16 -0
- data/ext/Rakefile +18 -0
- data/init/config.yml +5 -0
- data/init/init.rb +79 -0
- data/lib/chef/ohai_setup.rb +51 -0
- data/lib/chef/plugins/cloud.rb +91 -0
- data/lib/chef/plugins/cloudstack.rb +23 -0
- data/lib/chef/plugins/ec2.rb +23 -0
- data/lib/chef/plugins/linux/block_device2.rb +24 -0
- data/lib/chef/plugins/rackspace.rb +23 -0
- data/lib/chef/plugins/rightscale.rb +125 -0
- data/lib/chef/plugins/windows/network.rb +114 -0
- data/lib/chef/plugins.rb +74 -0
- data/lib/chef/providers/dns_dnsmadeeasy_provider.rb +81 -0
- data/lib/chef/providers/dns_resource.rb +100 -0
- data/lib/chef/providers/executable_schedule_provider.rb +70 -0
- data/lib/chef/providers/executable_schedule_resource.rb +144 -0
- data/lib/chef/providers/remote_recipe_provider.rb +86 -0
- data/lib/chef/providers/remote_recipe_resource.rb +101 -0
- data/lib/chef/providers/right_link_tag_provider.rb +73 -0
- data/lib/chef/providers/right_link_tag_resource.rb +59 -0
- data/lib/chef/providers/right_script_provider.rb +190 -0
- data/lib/chef/providers/right_script_resource.rb +113 -0
- data/lib/chef/providers/rs_shutdown_provider.rb +75 -0
- data/lib/chef/providers/rs_shutdown_resource.rb +55 -0
- data/lib/chef/providers/server_collection_provider.rb +66 -0
- data/lib/chef/providers/server_collection_resource.rb +93 -0
- data/lib/chef/providers/windows/powershell_provider.rb +151 -0
- data/lib/chef/providers/windows/powershell_resource.rb +111 -0
- data/lib/chef/providers/windows/unsupported_provider.rb +51 -0
- data/lib/chef/right_providers.rb +55 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ChefNodeCmdlet.csproj +104 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ChefNodeCmdlet.dll-Help.xml +141 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/Exceptions.cs +182 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetChefNodeCommand.cs +58 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetChefNodeRequest.cs +46 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetChefNodeResponse.cs +45 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetCurrentResourceCommand.cs +58 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetCurrentResourceRequest.cs +46 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetCurrentResourceResponse.cs +45 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNewResourceCommand.cs +58 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNewResourceRequest.cs +46 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNewResourceResponse.cs +45 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNextActionCommand.cs +178 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNextActionRequest.cs +67 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNextActionResponse.cs +58 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNodeValueCommandBase.cs +142 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNodeValueRequestBase.cs +64 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/GetNodeValueResponseBase.cs +69 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/JsonTransport.cs +110 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/PipeClient.cs +158 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/PipeServer.cs +142 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/Properties/AssemblyInfo.cs +16 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ProtocolConstants.cs +55 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ProtocolUtilities.cs +77 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/ReadMe.txt +53 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetChefNodeCommand.cs +59 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetChefNodeRequest.cs +46 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetChefNodeResponse.cs +58 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetCurrentResourceCommand.cs +59 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetCurrentResourceRequest.cs +46 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetCurrentResourceResponse.cs +40 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNewResourceCommand.cs +59 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNewResourceRequest.cs +46 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNewResourceResponse.cs +40 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNodeValueCommandBase.cs +293 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNodeValueRequestBase.cs +75 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/SetNodeValueResponseBase.cs +45 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet/Transport.cs +91 -0
- data/lib/chef/windows/ChefNodeCmdlet/ChefNodeCmdlet.sln +35 -0
- data/lib/chef/windows/ChefNodeCmdlet/TestChefNodeCmdlet/Program.cs +374 -0
- data/lib/chef/windows/ChefNodeCmdlet/TestChefNodeCmdlet/Properties/AssemblyInfo.cs +16 -0
- data/lib/chef/windows/ChefNodeCmdlet/TestChefNodeCmdlet/TestChefNodeCmdlet.csproj +65 -0
- data/lib/chef/windows/ChefNodeCmdlet/TestNextActionCmdlet/Program.cs +136 -0
- data/lib/chef/windows/ChefNodeCmdlet/TestNextActionCmdlet/Properties/AssemblyInfo.cs +36 -0
- data/lib/chef/windows/ChefNodeCmdlet/TestNextActionCmdlet/ReadMe.txt +46 -0
- data/lib/chef/windows/ChefNodeCmdlet/TestNextActionCmdlet/TestNextActionCmdlet.csproj +68 -0
- data/lib/chef/windows/bin/Newtonsoft.Json.dll +0 -0
- data/lib/chef/windows/chef_node_server.rb +463 -0
- data/lib/chef/windows/dynamic_powershell_provider.rb +296 -0
- data/lib/chef/windows/pipe_server.rb +283 -0
- data/lib/chef/windows/powershell_host.rb +285 -0
- data/lib/chef/windows/powershell_pipe_server.rb +136 -0
- data/lib/chef/windows/powershell_provider_base.rb +92 -0
- data/lib/chef/windows/scripts/run_loop.ps1 +105 -0
- data/lib/clouds/cloud.rb +557 -0
- data/lib/clouds/cloud_factory.rb +250 -0
- data/lib/clouds/cloud_utilities.rb +244 -0
- data/lib/clouds/clouds/azure.rb +106 -0
- data/lib/clouds/clouds/cloudstack.rb +114 -0
- data/lib/clouds/clouds/ec2.rb +113 -0
- data/lib/clouds/clouds/eucalyptus.rb +46 -0
- data/lib/clouds/clouds/google.rb +102 -0
- data/lib/clouds/clouds/none.rb +76 -0
- data/lib/clouds/clouds/openstack.rb +30 -0
- data/lib/clouds/clouds/rackspace-ng.rb +54 -0
- data/lib/clouds/clouds/rackspace.rb +78 -0
- data/lib/clouds/clouds/softlayer.rb +91 -0
- data/lib/clouds/metadata_formatter.rb +108 -0
- data/lib/clouds/metadata_provider.rb +128 -0
- data/lib/clouds/metadata_source.rb +87 -0
- data/lib/clouds/metadata_sources/certificate_metadata_source.rb +207 -0
- data/lib/clouds/metadata_sources/config_drive_metadata_source.rb +129 -0
- data/lib/clouds/metadata_sources/file_metadata_source.rb +74 -0
- data/lib/clouds/metadata_sources/http_metadata_source.rb +277 -0
- data/lib/clouds/metadata_sources/selective_metadata_source.rb +122 -0
- data/lib/clouds/metadata_tree_climber.rb +144 -0
- data/lib/clouds/metadata_writer.rb +155 -0
- data/lib/clouds/metadata_writers/dictionary_metadata_writer.rb +72 -0
- data/lib/clouds/metadata_writers/ruby_metadata_writer.rb +76 -0
- data/lib/clouds/metadata_writers/shell_metadata_writer.rb +121 -0
- data/lib/clouds/register_clouds.rb +34 -0
- data/lib/clouds.rb +32 -0
- data/lib/gem_dependencies.rb +83 -0
- data/lib/git_hooks/commit-msg.rb +7 -0
- data/lib/instance/agent_config.rb +168 -0
- data/lib/instance/agent_watcher.rb +233 -0
- data/lib/instance/audit_cook_stub.rb +104 -0
- data/lib/instance/audit_proxy.rb +247 -0
- data/lib/instance/bundle_queue.rb +104 -0
- data/lib/instance/cook/agent_connection.rb +109 -0
- data/lib/instance/cook/audit_logger.rb +165 -0
- data/lib/instance/cook/audit_stub.rb +142 -0
- data/lib/instance/cook/ca-bundle.crt +2794 -0
- data/lib/instance/cook/chef_state.rb +211 -0
- data/lib/instance/cook/cook.rb +306 -0
- data/lib/instance/cook/cook_state.rb +298 -0
- data/lib/instance/cook/cookbook_path_mapping.rb +66 -0
- data/lib/instance/cook/cookbook_repo_retriever.rb +190 -0
- data/lib/instance/cook/executable_sequence.rb +765 -0
- data/lib/instance/cook/external_parameter_gatherer.rb +190 -0
- data/lib/instance/cook/repose_downloader.rb +349 -0
- data/lib/instance/cook/shutdown_request_proxy.rb +121 -0
- data/lib/instance/cook.rb +41 -0
- data/lib/instance/downloader.rb +208 -0
- data/lib/instance/duplicable.rb +67 -0
- data/lib/instance/exceptions.rb +49 -0
- data/lib/instance/executable_sequence_proxy.rb +278 -0
- data/lib/instance/instance_commands.rb +577 -0
- data/lib/instance/instance_state.rb +633 -0
- data/lib/instance/json_utilities.rb +102 -0
- data/lib/instance/login_manager.rb +533 -0
- data/lib/instance/login_user_manager.rb +522 -0
- data/lib/instance/message_encoder.rb +118 -0
- data/lib/instance/multi_thread_bundle_queue.rb +232 -0
- data/lib/instance/operation_context.rb +60 -0
- data/lib/instance/options_bag.rb +65 -0
- data/lib/instance/payload_formatter.rb +46 -0
- data/lib/instance/policy.rb +53 -0
- data/lib/instance/policy_audit.rb +100 -0
- data/lib/instance/policy_manager.rb +146 -0
- data/lib/instance/reenroll_manager.rb +104 -0
- data/lib/instance/right_scripts_cookbook.rb +181 -0
- data/lib/instance/shutdown_request.rb +221 -0
- data/lib/instance/single_thread_bundle_queue.rb +189 -0
- data/lib/instance/volume_management.rb +450 -0
- data/lib/instance.rb +50 -0
- data/lib/repo_conf_generators/apt_conf_generators.rb +106 -0
- data/lib/repo_conf_generators/gem_conf_generators.rb +80 -0
- data/lib/repo_conf_generators/rightscale_conf_generators.rb +254 -0
- data/lib/repo_conf_generators/rightscale_key.pub +17 -0
- data/lib/repo_conf_generators/yum_conf_generators.rb +225 -0
- data/lib/repo_conf_generators.rb +30 -0
- data/lib/run_shell.rb +28 -0
- data/scripts/agent_checker.rb +571 -0
- data/scripts/agent_controller.rb +247 -0
- data/scripts/agent_deployer.rb +148 -0
- data/scripts/bundle_runner.rb +336 -0
- data/scripts/cloud_controller.rb +176 -0
- data/scripts/log_level_manager.rb +142 -0
- data/scripts/ohai_runner.rb +33 -0
- data/scripts/reenroller.rb +193 -0
- data/scripts/server_importer.rb +293 -0
- data/scripts/shutdown_client.rb +183 -0
- data/scripts/system_configurator.rb +367 -0
- data/scripts/tagger.rb +381 -0
- data/scripts/thunker.rb +356 -0
- metadata +418 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
# = NOTICE
|
24
|
+
# This plugin is deprecated!
|
25
|
+
#
|
26
|
+
# This is an ohai plugin that checks the state of the instance to
|
27
|
+
# determine if the RightScale plaform is available and add RightScale
|
28
|
+
# configuration data to the chef node. This is the old way of doing things.
|
29
|
+
#
|
30
|
+
# Going forward we are passing in all RightScale configuration data via
|
31
|
+
# attributes called 'core-defined inputs'. You can read more on the wiki:
|
32
|
+
# http://rightscale.onconfluence.com/display/rightscale/Cloud+Independent+Attributes
|
33
|
+
#
|
34
|
+
# This plugin remains until all configuration data is migrated from user-data to
|
35
|
+
# core-defined inputs.
|
36
|
+
|
37
|
+
require 'json'
|
38
|
+
|
39
|
+
provides "rightscale"
|
40
|
+
|
41
|
+
class RightScale
|
42
|
+
MetaDataFile = "/var/spool/rackspace/user-data.txt"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Adds RightScale server FQDNs to the rightscale_deprecated servers Mash
|
46
|
+
#
|
47
|
+
# NOTE: This is a hack to convert the RS_(server) tokens into something more
|
48
|
+
# intuative. Hopefully this will be removed when we stop using EC2
|
49
|
+
# userdata.
|
50
|
+
#
|
51
|
+
# === Parameters
|
52
|
+
# key(String):: RightScale server token from user-data
|
53
|
+
# data(String)::: FQDN for the RightScale server
|
54
|
+
def add_server(key, data)
|
55
|
+
rightscale_deprecated[:server] = Mash.new unless rightscale_deprecated.has_key?(:server)
|
56
|
+
server_names = {
|
57
|
+
"RS_sketchy" => "sketchy",
|
58
|
+
"RS_syslog" => "syslog",
|
59
|
+
"RS_lumberjack" => "lumberjack",
|
60
|
+
"RS_server" => "core"
|
61
|
+
}
|
62
|
+
rightscale_deprecated[:server][server_names[key]] = data unless (server_names[key] == nil)
|
63
|
+
end
|
64
|
+
|
65
|
+
# ----------------------------------------
|
66
|
+
# cloud
|
67
|
+
# ----------------------------------------
|
68
|
+
require_plugin "cloud"
|
69
|
+
|
70
|
+
# Detect if RightScale platform is running on ec2 cloud
|
71
|
+
#
|
72
|
+
# === Returns
|
73
|
+
# true:: If ec2 Mash exists amd RightScale tokens found in user-data
|
74
|
+
# false:: Otherwise
|
75
|
+
def on_rightscale_ec2_platform?
|
76
|
+
return false if (ec2 == nil || ec2[:userdata].match(/RS_/) == nil) # only ec2 supported
|
77
|
+
true
|
78
|
+
end
|
79
|
+
|
80
|
+
# add all 'RS_' tokens in userdata, but perform translation for server names
|
81
|
+
def get_data_from_ec2_user_date
|
82
|
+
data_array = ec2[:userdata].split('&')
|
83
|
+
data_array.each do |d|
|
84
|
+
key, data = d.split('=')
|
85
|
+
rightscale_deprecated[key.sub(/RS_/,'')] = data unless add_server(key,data)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Adds rightscale_deprecated from ec2 user-data, if available
|
90
|
+
if on_rightscale_ec2_platform?
|
91
|
+
rightscale_deprecated Mash.new
|
92
|
+
get_data_from_ec2_user_date
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
# ----------------------------------------
|
97
|
+
# generic cloud
|
98
|
+
# ----------------------------------------
|
99
|
+
|
100
|
+
# Detect if RightScale platform is running on other cloud.
|
101
|
+
# currently only rackspace is supported.
|
102
|
+
#
|
103
|
+
# === Returns
|
104
|
+
# true:: If ec2 Mash exists amd RightScale tokens found in user-data
|
105
|
+
# false:: Otherwise
|
106
|
+
def on_rightscale_platform?
|
107
|
+
File.exists?(RightScale::MetaDataFile)
|
108
|
+
end
|
109
|
+
|
110
|
+
# add all 'RS_' tokens in medadata file, but perform translation for server names
|
111
|
+
def get_data
|
112
|
+
data_array = File.open(RightScale::MetaDataFile)
|
113
|
+
data_array.each do |d|
|
114
|
+
key, data = d.split('=')
|
115
|
+
key.strip!
|
116
|
+
data.strip!
|
117
|
+
rightscale_deprecated[key.sub(/RS_/,'')] = data unless add_server(key,data)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# Adds rightscale_deprecated from metadata file, if available
|
122
|
+
if on_rightscale_platform?
|
123
|
+
rightscale_deprecated Mash.new
|
124
|
+
get_data
|
125
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
#
|
2
|
+
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'ruby-wmi'
|
20
|
+
|
21
|
+
def encaps_lookup(encap)
|
22
|
+
return "Ethernet" if encap.eql?("Ethernet 802.3")
|
23
|
+
encap
|
24
|
+
end
|
25
|
+
|
26
|
+
def derive_bcast(ipaddr, ipmask, zero_bcast = false)
|
27
|
+
begin
|
28
|
+
ipaddr_int = ipaddr.split(".").collect{ |x| x.to_i}.pack("C4").unpack("N").first
|
29
|
+
ipmask_int = ipmask.split(".").collect{ |x| x.to_i}.pack("C4").unpack("N").first
|
30
|
+
if zero_bcast
|
31
|
+
bcast_int = ipaddr_int & ipmask_int
|
32
|
+
else
|
33
|
+
bcast_int = ipaddr_int | 2 ** 32 - ipmask_int - 1
|
34
|
+
end
|
35
|
+
bcast = [bcast_int].pack("N").unpack("C4").join(".")
|
36
|
+
return bcast
|
37
|
+
rescue
|
38
|
+
return nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
iface = Mash.new
|
43
|
+
iface_config = Mash.new
|
44
|
+
iface_instance = Mash.new
|
45
|
+
|
46
|
+
adapters = WMI::Win32_NetworkAdapterConfiguration.find(:all)
|
47
|
+
adapters.each do |adapter|
|
48
|
+
i = adapter.Index
|
49
|
+
iface_config[i] = Mash.new
|
50
|
+
adapter.properties_.each do |p|
|
51
|
+
iface_config[i][p.name.wmi_underscore.to_sym] = adapter[p.name]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
adapters = WMI::Win32_NetworkAdapter.find(:all)
|
56
|
+
adapters.each do |adapter|
|
57
|
+
i = adapter.Index
|
58
|
+
iface_instance[i] = Mash.new
|
59
|
+
adapter.properties_.each do |p|
|
60
|
+
iface_instance[i][p.name.wmi_underscore.to_sym] = adapter[p.name]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
iface_instance.keys.each do |i|
|
65
|
+
if iface_config[i][:ip_enabled] and iface_instance[i][:net_connection_id] and iface_instance[i][:interface_index]
|
66
|
+
cint = sprintf("0x%X", iface_instance[i][:interface_index])
|
67
|
+
iface[cint] = Mash.new
|
68
|
+
iface[cint][:configuration] = iface_config[i]
|
69
|
+
iface[cint][:instance] = iface_instance[i]
|
70
|
+
|
71
|
+
iface[cint][:counters] = Mash.new
|
72
|
+
iface[cint][:addresses] = Mash.new
|
73
|
+
iface[cint][:configuration][:ip_address].each_index do |i|
|
74
|
+
begin
|
75
|
+
if iface[cint][:configuration][:ip_address][i] =~ /./
|
76
|
+
iface[cint][:addresses][iface[cint][:configuration][:ip_address][i]] = {
|
77
|
+
"family" => "inet",
|
78
|
+
"netmask" => iface[cint][:configuration][:ip_subnet][i],
|
79
|
+
"broadcast" => derive_bcast( iface[cint][:configuration][:ip_address][i],
|
80
|
+
iface[cint][:configuration][:ip_subnet][i],
|
81
|
+
iface[cint][:configuration][:ip_use_zero_broadcast]
|
82
|
+
)
|
83
|
+
}
|
84
|
+
end
|
85
|
+
rescue
|
86
|
+
end
|
87
|
+
end
|
88
|
+
iface[cint][:configuration][:mac_address].each do |mac_addr|
|
89
|
+
iface[cint][:addresses][mac_addr] = {
|
90
|
+
"family" => "lladdr"
|
91
|
+
}
|
92
|
+
end
|
93
|
+
iface[cint][:mtu] = iface[cint][:configuration][:mtu]
|
94
|
+
iface[cint][:type] = iface[cint][:instance][:adapter_type]
|
95
|
+
iface[cint][:arp] = {}
|
96
|
+
iface[cint][:encapsulation] = encaps_lookup(iface[cint][:instance][:adapter_type])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
cint=nil
|
101
|
+
from("arp /a").split("\n").each do |line|
|
102
|
+
if line == ""
|
103
|
+
cint = nil
|
104
|
+
end
|
105
|
+
if line =~ /^Interface:\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+[-]+\s+0x([a-fA-F0-9]+)/
|
106
|
+
cint = sprintf("0x%X", $2.hex)
|
107
|
+
end
|
108
|
+
next unless iface[cint]
|
109
|
+
if line =~ /^\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+([a-fA-F0-9\:-]+)/
|
110
|
+
iface[cint][:arp][$1] = $2.gsub("-",":").downcase
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
network["interfaces"] = iface
|
data/lib/chef/plugins.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
EXCLUDED_OHAI_PLUGINS = [ 'linux::block_device' ]
|
24
|
+
|
25
|
+
# Not for the feint of hearts:
|
26
|
+
# We need to disable the linux block device plugin because it can cause
|
27
|
+
# deadlocks (see description of LinuxBlockDevice below).
|
28
|
+
# So monkey patch Ohai to add the concept of excluded plugins and add
|
29
|
+
# the linux block device plugin to the excluded list.
|
30
|
+
require 'ohai'
|
31
|
+
|
32
|
+
module Ohai
|
33
|
+
class System
|
34
|
+
alias :require_all_plugins :require_plugin
|
35
|
+
def require_plugin(plugin_name, force=false)
|
36
|
+
unless EXCLUDED_OHAI_PLUGINS.include?(plugin_name)
|
37
|
+
require_all_plugins(plugin_name, force)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
module RightScale
|
44
|
+
|
45
|
+
# Preload content of /sys/block to avoid deadlocks when loading from
|
46
|
+
# a different thread (issue with async IO and sysfs):
|
47
|
+
# - File.read('/sys/block/...') will hang if run in a multithread ruby
|
48
|
+
# process because it will use async IO
|
49
|
+
# - `cat /sys/block/...` will deadlock with the `uptime` command ran
|
50
|
+
# from agents's hearbeat callback
|
51
|
+
class LinuxBlockDevice
|
52
|
+
def self.info
|
53
|
+
@@info
|
54
|
+
end
|
55
|
+
if RightScale::Platform.linux? && File.exists?("/sys/block")
|
56
|
+
@@info = Hash.new
|
57
|
+
Dir["/sys/block/*"].each do |block_device_dir|
|
58
|
+
dir = File.basename(block_device_dir)
|
59
|
+
@@info[dir] = Hash.new
|
60
|
+
%w{size removable}.each do |check|
|
61
|
+
if File.exists?("/sys/block/#{dir}/#{check}")
|
62
|
+
@@info[dir][check] = File.read("/sys/block/#{dir}/#{check}").chomp
|
63
|
+
end
|
64
|
+
end
|
65
|
+
%w{model rev state timeout vendor}.each do |check|
|
66
|
+
if File.exists?("/sys/block/#{dir}/device/#{check}")
|
67
|
+
@@info[dir][check] = File.read("/sys/block/#{dir}/device/#{check}").chomp
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
class Chef
|
24
|
+
class Provider
|
25
|
+
class DnsMadeEasy < Chef::Provider
|
26
|
+
|
27
|
+
# No concept of a 'current' resource for DNS registration, this is a no-op
|
28
|
+
#
|
29
|
+
# === Return
|
30
|
+
# true:: Always return true
|
31
|
+
def load_current_resource
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
# Register DNS with DNS Made Easy service
|
36
|
+
# This relies on 'curl' being available on the system
|
37
|
+
#
|
38
|
+
# === Return
|
39
|
+
# true:: Always return true
|
40
|
+
#
|
41
|
+
# === Raise
|
42
|
+
# Chef::Exceptions::Dns:: DNS registration request returned an error
|
43
|
+
def action_register
|
44
|
+
Chef::Log.info("Updating DNS for #{@new_resource.name} to point to #{@new_resource.ip_address}")
|
45
|
+
query="username=#{@new_resource.user}&password=#{@new_resource.passwd}&id=#{@new_resource.name}&ip=#{@new_resource.ip_address}"
|
46
|
+
Chef::Log.debug("QUERY: #{query}")
|
47
|
+
result = post_change(query)
|
48
|
+
if result =~ /success|error-record-ip-same/
|
49
|
+
Chef::Log.info("DNSID #{@new_resource.name} set to this instance IP: #{@new_resource.ip_address}")
|
50
|
+
else
|
51
|
+
raise(Chef::Exceptions::Dns, "#{self.class.name}: Error setting #{@new_resource.name} to instance IP: #{@new_resource.ip_address}: Result: #{result}")
|
52
|
+
end
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
# Make the HTTPS request using 'curl'
|
57
|
+
#
|
58
|
+
# === Parameters
|
59
|
+
# query(String):: Query string used to build request
|
60
|
+
#
|
61
|
+
# === Return
|
62
|
+
# res(String):: Response content
|
63
|
+
def post_change(query)
|
64
|
+
# use double-quotes for Window but use single-quotes for security
|
65
|
+
# reasons in Linux.
|
66
|
+
curl_options = '-S -s --retry 7 -k -o - -g -f'
|
67
|
+
dns_made_easy_url = 'https://www.dnsmadeeasy.com/servlet/updateip'
|
68
|
+
if !!(RUBY_PLATFORM =~ /mswin/)
|
69
|
+
res = `curl #{curl_options} \"#{dns_made_easy_url}?#{query}\"`
|
70
|
+
else
|
71
|
+
res = `curl #{curl_options} '#{dns_made_easy_url}?#{query}'`
|
72
|
+
end
|
73
|
+
return res
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# self-register
|
81
|
+
Chef::Platform.platforms[:default].merge!(:dns => Chef::Provider::DnsMadeEasy)
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
|
24
|
+
## Set DNS for given id to the current address of this node
|
25
|
+
#
|
26
|
+
#dns "my.domain.id.com" do
|
27
|
+
# user "account_user_name"
|
28
|
+
# passwd "account_password"
|
29
|
+
# addressing :public | :private (:public default)
|
30
|
+
#end
|
31
|
+
|
32
|
+
class Chef
|
33
|
+
class Resource
|
34
|
+
|
35
|
+
# RightScript chef resource.
|
36
|
+
# Set DNS for given id to the current address of this node
|
37
|
+
#
|
38
|
+
# === Example
|
39
|
+
#dns "my.domain.id.com" do
|
40
|
+
# user "account_user_name"
|
41
|
+
# passwd "account_password"
|
42
|
+
# ip_address "nnn.nnn.nnn.nnn"
|
43
|
+
#end
|
44
|
+
#
|
45
|
+
class Dns < Chef::Resource
|
46
|
+
|
47
|
+
# Initialize DNS resource with default values
|
48
|
+
#
|
49
|
+
# === Parameters
|
50
|
+
# name(String):: FQDN or Id for server
|
51
|
+
# collection(Array):: Collection of included recipes
|
52
|
+
# node(Chef::Node):: Node where resource will be used
|
53
|
+
def initialize(name, run_context=nil)
|
54
|
+
super(name, run_context)
|
55
|
+
@resource_name = :dns
|
56
|
+
@dns_id = nil
|
57
|
+
@user = nil
|
58
|
+
@passwd = nil
|
59
|
+
@ip_address = nil
|
60
|
+
@action = :register
|
61
|
+
end
|
62
|
+
|
63
|
+
# (String) username for dns provider account
|
64
|
+
def user(arg=nil)
|
65
|
+
set_or_return(
|
66
|
+
:user,
|
67
|
+
arg,
|
68
|
+
:kind_of => [ String ]
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
# (String) password for dns provider account
|
73
|
+
def passwd(arg=nil)
|
74
|
+
set_or_return(
|
75
|
+
:passwd,
|
76
|
+
arg,
|
77
|
+
:kind_of => [ String ]
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
# (String) IP address in the format ddd.ddd.ddd.ddd
|
82
|
+
def ip_address(arg=nil)
|
83
|
+
set_or_return(
|
84
|
+
:ip_address,
|
85
|
+
arg,
|
86
|
+
:regex => /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Define the Dns exception type
|
95
|
+
class Chef
|
96
|
+
class Exceptions
|
97
|
+
class Dns < RuntimeError; end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2009-2011 RightScale Inc
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
# To install the chef gem:
|
24
|
+
# sudo gem sources -a http://gems.opscode.com
|
25
|
+
# sudo gem install chef ohai
|
26
|
+
|
27
|
+
require 'fileutils'
|
28
|
+
class Chef
|
29
|
+
class Provider
|
30
|
+
|
31
|
+
# Executable Schedule chef provider.
|
32
|
+
class ExecutableSchedule < Chef::Provider
|
33
|
+
|
34
|
+
# Initialize underlying Chef cron provider with existing entries
|
35
|
+
#
|
36
|
+
# === Return
|
37
|
+
# true:: Always return true
|
38
|
+
def load_current_resource
|
39
|
+
@original_cron_provider = Chef::Provider::Cron.new(@new_resource.cron_resource, @run_context)
|
40
|
+
@original_cron_provider.load_current_resource
|
41
|
+
@current_resource = @original_cron_provider.current_resource
|
42
|
+
true
|
43
|
+
end
|
44
|
+
|
45
|
+
# Create cron entries if they don't exist yet
|
46
|
+
#
|
47
|
+
# === Return
|
48
|
+
# true:: Always return true
|
49
|
+
def action_create
|
50
|
+
@original_cron_provider.action_create
|
51
|
+
@new_resource.updated_by_last_action(@original_cron_provider.new_resource.updated_by_last_action?)
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
# Delete existing cron entries, do nothing if they don't exist
|
56
|
+
#
|
57
|
+
# === Return
|
58
|
+
# true:: Always return true
|
59
|
+
def action_delete
|
60
|
+
@original_cron_provider.action_delete
|
61
|
+
@new_resource.updated_by_last_action(@original_cron_provider.new_resource.updated_by_last_action?)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# self-register
|
70
|
+
Chef::Platform.platforms[:default].merge!(:executable_schedule => Chef::Provider::ExecutableSchedule)
|