42 |
42 |
# ------------------------------------------------------------------------
|
43 |
43 |
# SshDriver constructor
|
44 |
44 |
# ------------------------------------------------------------------------
|
45 |
|
def initialize(hypervisor, threads, retries, localpoll)
|
|
45 |
def initialize(hypervisor, threads, retries, localpoll, localactions)
|
46 |
46 |
super(threads,true,retries)
|
47 |
47 |
|
48 |
48 |
@config = read_configuration
|
... | ... | |
59 |
59 |
|
60 |
60 |
@actions_path << "/remotes/vmm/#{hypervisor}"
|
61 |
61 |
|
62 |
|
@local_poll = localpoll
|
|
62 |
@local_poll = localpoll
|
|
63 |
@local_actions = localactions
|
63 |
64 |
end
|
64 |
65 |
|
65 |
66 |
# ------------------------------------------------------------------------ #
|
... | ... | |
106 |
107 |
end
|
107 |
108 |
|
108 |
109 |
def migrate(id, host, deploy_id, dest_host)
|
109 |
|
remotes_action("#{@remote_path}/migrate #{deploy_id} #{dest_host}",
|
110 |
|
id, host, :migrate, @remote_dir)
|
|
110 |
if @local_actions.include?('migrate')
|
|
111 |
local_action("#{@actions_path}/migrate_local #{host} #{deploy_id} #{dest_host}",
|
|
112 |
id, :migrate)
|
|
113 |
else
|
|
114 |
remotes_action("#{@remote_path}/migrate #{deploy_id} #{dest_host}",
|
|
115 |
id, host, :migrate, @remote_dir)
|
|
116 |
end
|
111 |
117 |
end
|
112 |
118 |
|
113 |
119 |
def poll(id, host, deploy_id, not_used)
|
114 |
120 |
if @local_poll != nil
|
115 |
121 |
local_action("#{@actions_path}/#{@local_poll} #{host} #{deploy_id}",
|
116 |
122 |
id, :poll)
|
|
123 |
elsif @local_actions.include?('poll')
|
|
124 |
local_action("#{@actions_path}/poll_local #{host} #{deploy_id}",
|
|
125 |
id, :poll)
|
117 |
126 |
else
|
118 |
127 |
remotes_action("#{@remote_path}/poll #{deploy_id}",
|
119 |
128 |
id, host, :poll, @remote_dir)
|
... | ... | |
127 |
136 |
opts = GetoptLong.new(
|
128 |
137 |
[ '--retries', '-r', GetoptLong::OPTIONAL_ARGUMENT ],
|
129 |
138 |
[ '--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT ],
|
130 |
|
[ '--localpoll', '-p', GetoptLong::REQUIRED_ARGUMENT ]
|
|
139 |
[ '--localpoll', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
|
140 |
[ '--local', '-L', GetoptLong::REQUIRED_ARGUMENT ]
|
131 |
141 |
)
|
132 |
142 |
|
133 |
|
hypervisor = ''
|
134 |
|
retries = 0
|
135 |
|
threads = 15
|
136 |
|
localpoll = nil
|
|
143 |
hypervisor = ''
|
|
144 |
retries = 0
|
|
145 |
threads = 15
|
|
146 |
localpoll = nil
|
|
147 |
localactions = []
|
137 |
148 |
|
138 |
149 |
begin
|
139 |
150 |
opts.each do |opt, arg|
|
... | ... | |
144 |
155 |
threads = arg.to_i
|
145 |
156 |
when '--localpoll'
|
146 |
157 |
localpoll = arg
|
|
158 |
when '--local'
|
|
159 |
arg.split(',').each do |action|
|
|
160 |
localactions.push(action)
|
|
161 |
end
|
147 |
162 |
end
|
148 |
163 |
end
|
149 |
164 |
rescue Exception => e
|
... | ... | |
156 |
171 |
exit(-1)
|
157 |
172 |
end
|
158 |
173 |
|
159 |
|
ssh_driver = SshDriver.new(hypervisor, threads, retries, localpoll)
|
|
174 |
ssh_driver = SshDriver.new(hypervisor, threads, retries, localpoll, localactions)
|
160 |
175 |
ssh_driver.start_driver
|
|
176 |
|
161 |
|
-
|