Top Level Namespace
Defined Under Namespace
Modules: GPUEater
Instance Method Summary collapse
- #clear_images ⇒ Object
- #clear_instance ⇒ Object
- #create_test_instance ⇒ Object
- #create_user_defined_image ⇒ Object
-
#gen ⇒ Object
test.
- #ssh_key_test ⇒ Object
- #test ⇒ Object
- #test_image ⇒ Object
- #test_instance ⇒ Object
- #test_networking ⇒ Object
Instance Method Details
#clear_images ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# 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 ⇒ Object
33 34 35 36 37 38 39 40 41 |
# 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 ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# 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 ⇒ Object
test
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# 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 ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 |
# 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 ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/test.rb', line 112 def test pd = ondemand_list image = pd.find_image "Ubuntu16.04 x64" ssh_key = pd.find_ssh_key "my_ssh_key2" product = pd.find_product "n1.p400" emergency_restart_instance(instance_list[0]); p image p ssh_key["id"] p product["id"] 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 end |
#test_image ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# 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 ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/test.rb', line 44 def test_instance puts "------------------------------------------" clear_instance() create_test_instance() clear_instance() puts "------------------------------------------" end |
#test_networking ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# 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 |