class Object
Public Instance Methods
clear_images()
click to toggle source
# File lib/test.rb, line 19 def clear_images g = GPUEater.new ls = g.registered_image_list p ls ls.each{|e| puts "+++++++++" puts e ret = g.delete_image(e); puts ret } puts "clear_images - done." end
clear_instance()
click to toggle source
# File lib/test.rb, line 7 def clear_instance g = GPUEater.new ls = g.instance_list p ls ls.each{|e| puts e ret = g.terminate_instance(e) puts ret } puts "clear_instance - done" end
create_test_instance()
click to toggle source
# File lib/test.rb, line 33 def create_test_instance g = GPUEater.new ps = g.ondemand_list() image = ps.find_image("Ubuntu16.04 x64") ssh_key = ps.find_ssh_key("guest") product = ps.find_product("a1.vegafe") ret = g.launch_ondemand_instance({"tag"=>"test_instance","product_id"=>product["id"], "ssh_key_id"=>ssh_key["id"], "image" => image["alias"]}); puts ret end
create_user_defined_image()
click to toggle source
# File lib/test.rb, line 57 def create_user_defined_image() g = GPUEater.new puts "registered_image_list" p g.registered_image_list() ins = g.instance_list().pop() puts ins ins['image_name'] = 'test_image' ret = g.create_image(ins) puts ret end
gen()
click to toggle source
test
# File lib/gpueater.rb, line 289 def gen ret = [] ret2 = [] st = open(__FILE__).read flg = false st.split("\n").each{|e| unless flg if e.include? "def " if e.include? "#@" name = e.split("def ")[1].split("#")[0].split("(")[0].strip name = name.gsub("self.","") name = name.split(";")[0] ret += ["# " + name] end end ret2 += [e] #puts e if e == "##@@ GEN @@##" flg = true end end } st2 = ret2.join("\n") fp = open(__FILE__,"w") fp.write(st2) fp.write("\n") fp.write(ret.join("\n")) fp.close end
ssh_key_test()
click to toggle source
# File lib/test.rb, line 123 def ssh_key_test key = generate_ssh_key keyname = 'my_ssh_key2' ssh_key_list().select{|e| delete_ssh_key(e) if e["name"] == keyname } register_ssh_key({"name"=>keyname,"public_key"=>key["public_key"]}) pem = File.join(@homedir,'.ssh',keyname+".pem") fp = open(pem,"w") fp.write(key["private_key"]) fp.close FileUtils.chmod(0600,pem) puts ssh_key_list end
test()
click to toggle source
# File lib/gpueater.rb, line 283 def test g = GPUEater.new #g.test g.payment_test end
test_image()
click to toggle source
# File lib/test.rb, line 70 def test_image puts "------------------------------------------" clear_images() clear_instance() g = GPUEater.new puts "image_list" p g.image_list() puts "registered_image_list" p g.registered_image_list() create_user_defined_image() puts "------------------------------------------" end
test_instance()
click to toggle source
# File lib/test.rb, line 44 def test_instance puts "------------------------------------------" clear_instance() create_test_instance() clear_instance() puts "------------------------------------------" end
test_networking()
click to toggle source
# File lib/test.rb, line 92 def test_networking puts "------------------------------------------" puts "Start networking test" g = GPUEater.new is = g.instance_list() if is.length > 0 ins = g.instance_list()[0] puts g.network_description(ins) ins['port'] = 9999 g.open_port(ins) puts g.port_list(ins) g.close_port(ins) puts g.port_list(ins) else puts "No instance" end puts "networking test - done." puts "------------------------------------------" end