5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/fog/networking/services.rb', line 5
def self.connect_instances(instance_from, instance_to, port)
if instance_from == nil || instance_to == nil then
raise ArgumentError.new('Need to a Fog instance of both from and to');
end
registry = YAML.load_file( File.join(File.dirname(File.expand_path(__FILE__)), 'registry.yaml'))
if !registry[instance_to.class.to_s] then
raise ArgumentError.new("Fog::Networking does not currently support #{instance_to.class.to_s}")
end
if !registry[instance_from.class.to_s] then
raise ArgumentError.new("Fog::Networking does not currently support #{instance_from.class.to_s}")
end
service_to = Object.const_get(registry[instance_to.class.to_s]).new(instance_to)
service_to.prepare
service_from = Object.const_get(registry[instance_from.class.to_s]).new(instance_from)
service_from.prepare
service_to.connect(service_from.get_ip_address, port)
end
|