
[why] we have some providers: ipxe, container, libvirt all of them need register testbox info and consume job from scheduler [how] each method corresponds to a interface, so ensuring the independence of them. Signed-off-by: Xiao Shenwei <xiaoshenwei96@163.com> --- lib/sched_client.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/sched_client.rb b/lib/sched_client.rb index fec4b14..93f9ccd 100644 --- a/lib/sched_client.rb +++ b/lib/sched_client.rb @@ -16,4 +16,37 @@ class SchedClient resource = RestClient::Resource.new("http://#{@host}:#{@port}/submit_job") resource.post(job_json) end + + # scheduler API /boot.:boot_type/:parameter/:value + # boot_type parameter + # 1 ipxe mac + # 2 container hostname + # 3 libvirt mac + def consume_job(boot_type, parameter, value) + RestClient.get "http://#{@host}:#{@port}/boot.#{boot_type}/#{parameter}/#{value}" + end + + def register_mac2host(hostname, mac) + RestClient.put( + "http://#{@host}:#{@port}/set_host_mac?hostname=#{hostname}&mac=#{mac}", {} + ) + end + + def register_host2queues(hostname, queues) + RestClient.put( + "http://#{@host}:#{@port}/set_host2queues?host=#{hostname}&queues=#{queues}", {} + ) + end + + def delete_mac2host(mac) + RestClient.put( + "http://#{@host}:#{@port}/del_host_mac?mac=#{mac}", {} + ) + end + + def delete_host2queues(hostname) + RestClient.put( + "http://#{@host}:#{@port}/del_host2queues?host=#{hostname}", {} + ) + end end -- 2.23.0