~cgb-cs/appscale/appscale-main

« back to all changes in this revision

Viewing changes to AppController/doc/HelperFunctions.html

  • Committer: Chris Bunch
  • Date: 2012-02-26 03:20:57 UTC
  • Revision ID: cgb@cs.ucsb.edu-20120226032057-ad0cy0zgx4we4exc
adding in repo over app engine support, and tests for most of datastore repo on appscale and s3

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
          
149
149
          <li><a href="#method-c-setup_app">::setup_app</a></li>
150
150
          
 
151
          <li><a href="#method-c-shell">::shell</a></li>
 
152
          
151
153
          <li><a href="#method-c-shorten_to_n_items">::shorten_to_n_items</a></li>
152
154
          
153
155
          <li><a href="#method-c-sleep_until_port_is_closed">::sleep_until_port_is_closed</a></li>
203
205
        
204
206
          <li><a href="./CronHelper.html">CronHelper</a></li>
205
207
        
 
208
          <li><a href="./Datastore.html">Datastore</a></li>
 
209
        
 
210
          <li><a href="./DatastoreFactory.html">DatastoreFactory</a></li>
 
211
        
 
212
          <li><a href="./DatastoreRepoOnAppScale.html">DatastoreRepoOnAppScale</a></li>
 
213
        
 
214
          <li><a href="./DatastoreS3.html">DatastoreS3</a></li>
 
215
        
206
216
          <li><a href="./Djinn.html">Djinn</a></li>
207
217
        
208
218
          <li><a href="./DjinnJobData.html">DjinnJobData</a></li>
404
414
          <div class="method-source-code"
405
415
            id="application_port-source">
406
416
<pre>
407
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 791</span>
 
417
<span class="ruby-comment"># File lib/helperfunctions.rb, line 795</span>
408
418
def self.application_port(app_number, index, num_of_servers)
409
419
  <span class="ruby-constant">APP_START_PORT</span> + (app_number * num_of_servers) + index
410
420
end</pre>
441
451
          <div class="method-source-code"
442
452
            id="convert_fqdn_to_ip-source">
443
453
<pre>
444
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 373</span>
 
454
<span class="ruby-comment"># File lib/helperfunctions.rb, line 377</span>
445
455
def self.convert_fqdn_to_ip(host)
446
456
  return host if host =~ /#{IP_REGEX}/
447
457
 
483
493
          <div class="method-source-code"
484
494
            id="create_appscale_security_group-source">
485
495
<pre>
486
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 676</span>
 
496
<span class="ruby-comment"># File lib/helperfunctions.rb, line 680</span>
487
497
def self.create_appscale_security_group(infrastructure, group)
488
498
  <span class="ruby-constant">Djinn</span>.log_run(&quot;#{infrastructure}-add-group #{group} -d appscale 2&gt;&amp;1&quot;)
489
499
  <span class="ruby-constant">Djinn</span>.log_run(&quot;#{infrastructure}-authorize #{group} -p 1-65535 -P udp 2&gt;&amp;1&quot;)
520
530
          <div class="method-source-code"
521
531
            id="deserialize_info_from_tools-source">
522
532
<pre>
523
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 100</span>
 
533
<span class="ruby-comment"># File lib/helperfunctions.rb, line 104</span>
524
534
def self.deserialize_info_from_tools(ips) 
525
535
  nodes = {}
526
536
  <span class="ruby-comment"># FIXME: Here we make the string back into a hash using the crappy deserialization</span>
563
573
          <div class="method-source-code"
564
574
            id="does_image_have_location-3F-source">
565
575
<pre>
566
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 983</span>
 
576
<span class="ruby-comment"># File lib/helperfunctions.rb, line 987</span>
567
577
def self.does_image_have_location?(ip, location, key)
568
578
  ret_val = `ssh -i #{key} -o NumberOfPasswordPrompts=0 -o StrictHostkeyChecking=no 2&gt;&amp;1 root@#{ip} 'ls #{location}'; echo $?`.chomp[-1]
569
579
  return ret_val.chr == <span class="ruby-string">&quot;0&quot;</span>
598
608
          <div class="method-source-code"
599
609
            id="encrypt_password-source">
600
610
<pre>
601
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 949</span>
 
611
<span class="ruby-comment"># File lib/helperfunctions.rb, line 953</span>
602
612
def self.encrypt_password(user, pass)
603
613
  <span class="ruby-constant">Digest</span>::<span class="ruby-constant">SHA1</span>.hexdigest(user + pass)
604
614
end</pre>
632
642
          <div class="method-source-code"
633
643
            id="ensure_db_is_supported-source">
634
644
<pre>
635
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 999</span>
 
645
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1003</span>
636
646
def self.ensure_db_is_supported(ip, db, key)
637
647
  if self.does_image_have_location?(ip, &quot;/etc/appscale/#{VER_NUM}/#{db}&quot;, key)
638
648
    <span class="ruby-constant">Djinn</span>.log_debug(&quot;Image at #{ip} supports #{db}.&quot;)
673
683
          <div class="method-source-code"
674
684
            id="ensure_image_is_appscale-source">
675
685
<pre>
676
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 988</span>
 
686
<span class="ruby-comment"># File lib/helperfunctions.rb, line 992</span>
677
687
def self.ensure_image_is_appscale(ip, key)
678
688
  if self.does_image_have_location?(ip, <span class="ruby-string">&quot;/etc/appscale&quot;</span>, key)
679
689
    <span class="ruby-constant">Djinn</span>.log_debug(&quot;Image at #{ip} is an AppScale image.&quot;)
715
725
          <div class="method-source-code"
716
726
            id="expires_duration-source">
717
727
<pre>
718
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 923</span>
 
728
<span class="ruby-comment"># File lib/helperfunctions.rb, line 927</span>
719
729
def self.expires_duration input_string
720
730
  return nil if input_string.nil? || input_string.empty?
721
731
  <span class="ruby-comment"># Start with nil so we can distinguish between it not being set and 0</span>
759
769
          <div class="method-source-code"
760
770
            id="find_majority_item-source">
761
771
<pre>
762
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1071</span>
 
772
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1075</span>
763
773
def self.find_majority_item(array)
764
774
  count = {}
765
775
  array.each { |item|
808
818
          <div class="method-source-code"
809
819
            id="generate_location_config-source">
810
820
<pre>
811
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 795</span>
 
821
<span class="ruby-comment"># File lib/helperfunctions.rb, line 799</span>
812
822
def self.generate_location_config handler
813
823
  return <span class="ruby-string">&quot;&quot;</span> if !handler.key?(<span class="ruby-string">&quot;static_dir&quot;</span>) &amp;&amp; !handler.key?(<span class="ruby-string">&quot;static_files&quot;</span>)
814
824
 
857
867
          <div class="method-source-code"
858
868
            id="generate_makefile-source">
859
869
<pre>
860
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1010</span>
 
870
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1014</span>
861
871
def self.generate_makefile(code, input_loc)
862
872
  abort(<span class="ruby-string">&quot;code is nil&quot;</span>) if code.nil?
863
873
 
923
933
          <div class="method-source-code"
924
934
            id="generate_ssh_key-source">
925
935
<pre>
926
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 646</span>
 
936
<span class="ruby-comment"># File lib/helperfunctions.rb, line 650</span>
927
937
def self.generate_ssh_key(outputLocation, name, infrastructure)
928
938
  ec2_output = <span class="ruby-string">&quot;&quot;</span>
929
939
  loop {
983
993
          <div class="method-source-code"
984
994
            id="get_app_path-source">
985
995
<pre>
986
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 814</span>
 
996
<span class="ruby-comment"># File lib/helperfunctions.rb, line 818</span>
987
997
def self.get_app_path app_name
988
998
  &quot;/var/apps/#{app_name}/&quot;
989
999
end</pre>
1017
1027
          <div class="method-source-code"
1018
1028
            id="get_appscale_id-source">
1019
1029
<pre>
1020
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 238</span>
 
1030
<span class="ruby-comment"># File lib/helperfunctions.rb, line 242</span>
1021
1031
def self.get_appscale_id
1022
1032
  <span class="ruby-comment"># This needs to be ec2 or euca 2ools.</span>
1023
1033
  image_info = `ec2-describe-images`
1057
1067
          <div class="method-source-code"
1058
1068
            id="get_cache_path-source">
1059
1069
<pre>
1060
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 818</span>
 
1070
<span class="ruby-comment"># File lib/helperfunctions.rb, line 822</span>
1061
1071
def self.get_cache_path app_name
1062
1072
  <span class="ruby-constant">File</span>.join(get_app_path(app_name),<span class="ruby-string">&quot;cache&quot;</span>)
1063
1073
end</pre>
1091
1101
          <div class="method-source-code"
1092
1102
            id="get_cert-source">
1093
1103
<pre>
1094
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 248</span>
 
1104
<span class="ruby-comment"># File lib/helperfunctions.rb, line 252</span>
1095
1105
def self.get_cert(filename)
1096
1106
  return nil unless <span class="ruby-constant">File</span>.exists?(filename)
1097
1107
  <span class="ruby-constant">OpenSSL</span>::<span class="ruby-constant">X509</span>::<span class="ruby-constant">Certificate</span>.new(<span class="ruby-constant">File</span>.open(filename) { |f|
1128
1138
          <div class="method-source-code"
1129
1139
            id="get_cloud_ips-source">
1130
1140
<pre>
1131
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 749</span>
 
1141
<span class="ruby-comment"># File lib/helperfunctions.rb, line 753</span>
1132
1142
def self.get_cloud_ips(infrastructure, keyname)
1133
1143
  self.log_obscured_env
1134
1144
 
1176
1186
          <div class="method-source-code"
1177
1187
            id="get_hybrid_ips-source">
1178
1188
<pre>
1179
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 721</span>
 
1189
<span class="ruby-comment"># File lib/helperfunctions.rb, line 725</span>
1180
1190
def self.get_hybrid_ips(creds)
1181
1191
  <span class="ruby-constant">Djinn</span>.log_debug(&quot;creds are #{self.obscure_creds(creds).inspect}&quot;)
1182
1192
 
1234
1244
          <div class="method-source-code"
1235
1245
            id="get_ips-source">
1236
1246
<pre>
1237
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 385</span>
 
1247
<span class="ruby-comment"># File lib/helperfunctions.rb, line 389</span>
1238
1248
def self.get_ips(ips)
1239
1249
  abort(<span class="ruby-string">&quot;ips not even length array&quot;</span>) if ips.length % 2 != 0
1240
1250
  reported_public = []
1310
1320
          <div class="method-source-code"
1311
1321
            id="get_key-source">
1312
1322
<pre>
1313
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 255</span>
 
1323
<span class="ruby-comment"># File lib/helperfunctions.rb, line 259</span>
1314
1324
def self.get_key(filename)
1315
1325
  return nil unless <span class="ruby-constant">File</span>.exists?(filename)
1316
1326
  <span class="ruby-constant">OpenSSL</span>::<span class="ruby-constant">PKey</span>::<span class="ruby-constant">RSA</span>.new(<span class="ruby-constant">File</span>.open(filename) { |f|
1347
1357
          <div class="method-source-code"
1348
1358
            id="get_num_cpus-source">
1349
1359
<pre>
1350
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1058</span>
 
1360
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1062</span>
1351
1361
def self.get_num_cpus()
1352
1362
  return <span class="ruby-constant">Integer</span>(`cat /proc/cpuinfo | grep 'processor' | wc -l`.chomp)
1353
1363
end</pre>
1381
1391
          <div class="method-source-code"
1382
1392
            id="get_public_ips-source">
1383
1393
<pre>
1384
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 431</span>
 
1394
<span class="ruby-comment"># File lib/helperfunctions.rb, line 435</span>
1385
1395
def self.get_public_ips(ips)
1386
1396
  abort(<span class="ruby-string">&quot;ips not even length array&quot;</span>) if ips.length % 2 != 0
1387
1397
  reported_public = []
1438
1448
          <div class="method-source-code"
1439
1449
            id="get_random_alphanumeric-source">
1440
1450
<pre>
1441
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 937</span>
 
1451
<span class="ruby-comment"># File lib/helperfunctions.rb, line 941</span>
1442
1452
def self.get_random_alphanumeric(length=10)
1443
1453
  random = <span class="ruby-string">&quot;&quot;</span>
1444
1454
  possible = <span class="ruby-string">&quot;0123456789abcdefghijklmnopqrstuvxwyzABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;</span>
1482
1492
          <div class="method-source-code"
1483
1493
            id="get_relative_filename-source">
1484
1494
<pre>
1485
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 830</span>
 
1495
<span class="ruby-comment"># File lib/helperfunctions.rb, line 834</span>
1486
1496
def self.get_relative_filename filename, app_name
1487
1497
  filename[get_untar_dir(app_name).length..filename.length]
1488
1498
end</pre>
1516
1526
          <div class="method-source-code"
1517
1527
            id="get_remote_appscale_home-source">
1518
1528
<pre>
1519
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 227</span>
 
1529
<span class="ruby-comment"># File lib/helperfunctions.rb, line 231</span>
1520
1530
def self.get_remote_appscale_home(ip, key)
1521
1531
  cat = <span class="ruby-string">&quot;cat /etc/appscale/home&quot;</span>
1522
1532
  remote_cmd = &quot;ssh -i #{key} -o NumberOfPasswordPrompts=0 -o StrictHostkeyChecking=no 2&gt;&amp;1 root@#{ip} '#{cat}'&quot;
1557
1567
          <div class="method-source-code"
1558
1568
            id="get_secret-source">
1559
1569
<pre>
1560
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 262</span>
 
1570
<span class="ruby-comment"># File lib/helperfunctions.rb, line 266</span>
1561
1571
def self.get_secret(filename=&quot;#{APPSCALE_HOME}/.appscale/secret.key&quot;)
1562
1572
  filename = <span class="ruby-constant">File</span>.expand_path(filename)
1563
1573
  return nil unless <span class="ruby-constant">File</span>.exists?(filename)
1593
1603
          <div class="method-source-code"
1594
1604
            id="get_untar_dir-source">
1595
1605
<pre>
1596
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 823</span>
 
1606
<span class="ruby-comment"># File lib/helperfunctions.rb, line 827</span>
1597
1607
def self.get_untar_dir app_name
1598
1608
  <span class="ruby-constant">File</span>.join(get_app_path(app_name),<span class="ruby-string">&quot;app&quot;</span>)
1599
1609
end</pre>
1627
1637
          <div class="method-source-code"
1628
1638
            id="get_usage-source">
1629
1639
<pre>
1630
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 767</span>
 
1640
<span class="ruby-comment"># File lib/helperfunctions.rb, line 771</span>
1631
1641
def self.get_usage
1632
1642
  top_results = `top -n1 -d0 -b`
1633
1643
  usage = {}
1680
1690
          <div class="method-source-code"
1681
1691
            id="is_port_open-3F-source">
1682
1692
<pre>
1683
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 147</span>
 
1693
<span class="ruby-comment"># File lib/helperfunctions.rb, line 151</span>
1684
1694
def self.is_port_open?(ip, port, use_ssl=<span class="ruby-constant">DONT_USE_SSL</span>)
1685
1695
  begin
1686
1696
    <span class="ruby-constant">Timeout</span>::timeout(1) do
1736
1746
          <div class="method-source-code"
1737
1747
            id="kill_process-source">
1738
1748
<pre>
1739
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 113</span>
 
1749
<span class="ruby-comment"># File lib/helperfunctions.rb, line 117</span>
1740
1750
def self.kill_process(name)
1741
1751
  `ps ax | grep #{name} | grep -v grep | awk '{ print $1 }' | xargs -d '\n' kill -9`
1742
1752
end</pre>
1772
1782
          <div class="method-source-code"
1773
1783
            id="local_ip-source">
1774
1784
<pre>
1775
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 365</span>
 
1785
<span class="ruby-comment"># File lib/helperfunctions.rb, line 369</span>
1776
1786
def self.local_ip
1777
1787
  <span class="ruby-constant">UDPSocket</span>.open {|s| s.connect(<span class="ruby-string">&quot;64.233.187.99&quot;</span>, 1); s.addr.last }
1778
1788
end</pre>
1806
1816
          <div class="method-source-code"
1807
1817
            id="log_obscured_env-source">
1808
1818
<pre>
1809
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1046</span>
 
1819
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1050</span>
1810
1820
def self.log_obscured_env()
1811
1821
  env = `env`
1812
1822
 
1848
1858
          <div class="method-source-code"
1849
1859
            id="obscure_array-source">
1850
1860
<pre>
1851
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 960</span>
 
1861
<span class="ruby-comment"># File lib/helperfunctions.rb, line 964</span>
1852
1862
def self.obscure_array(array)
1853
1863
  return array.map {|s| 
1854
1864
    if <span class="ruby-constant">CLOUDY_CREDS</span>.include?(s)
1888
1898
          <div class="method-source-code"
1889
1899
            id="obscure_creds-source">
1890
1900
<pre>
1891
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 970</span>
 
1901
<span class="ruby-comment"># File lib/helperfunctions.rb, line 974</span>
1892
1902
def self.obscure_creds(creds)
1893
1903
  obscured = {}
1894
1904
  creds.each { |k, v|
1931
1941
          <div class="method-source-code"
1932
1942
            id="obscure_string-source">
1933
1943
<pre>
1934
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 953</span>
 
1944
<span class="ruby-comment"># File lib/helperfunctions.rb, line 957</span>
1935
1945
def self.obscure_string(string)
1936
1946
  return string if string.nil? or string.length &lt; 4
1937
1947
  last_four = string[string.length-4, string.length]
1968
1978
          <div class="method-source-code"
1969
1979
            id="parse_static_data-source">
1970
1980
<pre>
1971
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 834</span>
 
1981
<span class="ruby-comment"># File lib/helperfunctions.rb, line 838</span>
1972
1982
def self.parse_static_data app_name
1973
1983
  untar_dir = get_untar_dir(app_name)
1974
1984
 
2086
2096
          <div class="method-source-code"
2087
2097
            id="read_file-source">
2088
2098
<pre>
2089
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 91</span>
 
2099
<span class="ruby-comment"># File lib/helperfunctions.rb, line 95</span>
2090
2100
def self.read_file(location, chomp=true)
2091
2101
  file = <span class="ruby-constant">File</span>.open(location) { |f| f.read }
2092
2102
  if chomp
2125
2135
          <div class="method-source-code"
2126
2136
            id="run_app-source">
2127
2137
<pre>
2128
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 286</span>
 
2138
<span class="ruby-comment"># File lib/helperfunctions.rb, line 290</span>
2129
2139
def self.run_app(app_name, port, db_location, public_ip, private_ip, app_version, app_language, nginx_port, xmpp_ip)
2130
2140
  secret = <span class="ruby-constant">HelperFunctions</span>.get_secret    
2131
2141
 
2232
2242
          <div class="method-source-code"
2233
2243
            id="run_remote_command-source">
2234
2244
<pre>
2235
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 173</span>
 
2245
<span class="ruby-comment"># File lib/helperfunctions.rb, line 177</span>
2236
2246
def self.run_remote_command(ip, command, public_key_loc, want_output)
2237
2247
  <span class="ruby-constant">Djinn</span>.log_debug(&quot;ip is [#{ip}], command is [#{command}], public key is [#{public_key_loc}], want output? [#{want_output}]&quot;)
2238
2248
  public_key_loc = <span class="ruby-constant">File</span>.expand_path(public_key_loc)
2285
2295
          <div class="method-source-code"
2286
2296
            id="scp_file-source">
2287
2297
<pre>
2288
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 196</span>
 
2298
<span class="ruby-comment"># File lib/helperfunctions.rb, line 200</span>
2289
2299
def self.scp_file(local_file_loc, remote_file_loc, target_ip, private_key_loc)
2290
2300
  private_key_loc = <span class="ruby-constant">File</span>.expand_path(private_key_loc)
2291
2301
  `chmod 0600 #{private_key_loc}`
2346
2356
          <div class="method-source-code"
2347
2357
            id="set_creds_in_env-source">
2348
2358
<pre>
2349
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 458</span>
 
2359
<span class="ruby-comment"># File lib/helperfunctions.rb, line 462</span>
2350
2360
def self.set_creds_in_env(creds, cloud_num)
2351
2361
  <span class="ruby-constant">ENV</span>[<span class="ruby-string">'EC2_JVM_ARGS'</span>] = nil
2352
2362
 
2396
2406
          <div class="method-source-code"
2397
2407
            id="setup_app-source">
2398
2408
<pre>
2399
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 268</span>
 
2409
<span class="ruby-comment"># File lib/helperfunctions.rb, line 272</span>
2400
2410
def self.setup_app(app_name, untar=true)
2401
2411
  meta_dir = &quot;/var/apps/#{app_name}&quot;
2402
2412
  tar_dir = &quot;#{meta_dir}/app/&quot;
2423
2433
      </div>
2424
2434
 
2425
2435
    
 
2436
      <div id="shell-method" class="method-detail ">
 
2437
        <a name="method-c-shell"></a>
 
2438
 
 
2439
        
 
2440
        <div class="method-heading">
 
2441
          <span class="method-name">shell</span><span
 
2442
            class="method-args">(cmd)</span>
 
2443
          <span class="method-click-advice">click to toggle source</span>
 
2444
        </div>
 
2445
        
 
2446
 
 
2447
        <div class="method-description">
 
2448
          
 
2449
          
 
2450
          
 
2451
 
 
2452
          
 
2453
          <div class="method-source-code"
 
2454
            id="shell-source">
 
2455
<pre>
 
2456
<span class="ruby-comment"># File lib/helperfunctions.rb, line 87</span>
 
2457
def self.shell(cmd)
 
2458
  return `#{cmd}`
 
2459
end</pre>
 
2460
          </div>
 
2461
          
 
2462
        </div>
 
2463
 
 
2464
        
 
2465
 
 
2466
        
 
2467
      </div>
 
2468
 
 
2469
    
2426
2470
      <div id="shorten_to_n_items-method" class="method-detail ">
2427
2471
        <a name="method-c-shorten_to_n_items"></a>
2428
2472
 
2443
2487
          <div class="method-source-code"
2444
2488
            id="shorten_to_n_items-source">
2445
2489
<pre>
2446
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1062</span>
 
2490
<span class="ruby-comment"># File lib/helperfunctions.rb, line 1066</span>
2447
2491
def self.shorten_to_n_items(n, array)
2448
2492
  len = array.length
2449
2493
  if len &lt; n
2482
2526
          <div class="method-source-code"
2483
2527
            id="sleep_until_port_is_closed-source">
2484
2528
<pre>
2485
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 132</span>
 
2529
<span class="ruby-comment"># File lib/helperfunctions.rb, line 136</span>
2486
2530
def self.sleep_until_port_is_closed(ip, port, use_ssl=<span class="ruby-constant">DONT_USE_SSL</span>)
2487
2531
  sleep_time = 1
2488
2532
 
2527
2571
          <div class="method-source-code"
2528
2572
            id="sleep_until_port_is_open-source">
2529
2573
<pre>
2530
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 117</span>
 
2574
<span class="ruby-comment"># File lib/helperfunctions.rb, line 121</span>
2531
2575
def self.sleep_until_port_is_open(ip, port, use_ssl=<span class="ruby-constant">DONT_USE_SSL</span>)
2532
2576
  sleep_time = 1
2533
2577
 
2572
2616
          <div class="method-source-code"
2573
2617
            id="spawn_hybrid_vms-source">
2574
2618
<pre>
2575
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 478</span>
 
2619
<span class="ruby-comment"># File lib/helperfunctions.rb, line 482</span>
2576
2620
def self.spawn_hybrid_vms(creds, nodes)
2577
2621
  info = &quot;Spawning hybrid vms with creds #{self.obscure_creds(creds).inspect} and nodes #{nodes.inspect}&quot;
2578
2622
  <span class="ruby-constant">Djinn</span>.log_debug(info)
2651
2695
          <div class="method-source-code"
2652
2696
            id="spawn_vms-source">
2653
2697
<pre>
2654
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 527</span>
 
2698
<span class="ruby-comment"># File lib/helperfunctions.rb, line 531</span>
2655
2699
def self.spawn_vms(num_of_vms_to_spawn, job, image_id, instance_type, keyname,
2656
2700
  infrastructure, cloud, group)
2657
2701
  return [] if num_of_vms_to_spawn &lt; 1
2800
2844
          <div class="method-source-code"
2801
2845
            id="terminate_all_vms-source">
2802
2846
<pre>
2803
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 714</span>
 
2847
<span class="ruby-comment"># File lib/helperfunctions.rb, line 718</span>
2804
2848
def self.terminate_all_vms(infrastructure, keyname)
2805
2849
  self.log_obscured_env
2806
2850
  desc_instances = `#{infrastructure}-describe-instances`
2837
2881
          <div class="method-source-code"
2838
2882
            id="terminate_hybrid_vms-source">
2839
2883
<pre>
2840
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 693</span>
 
2884
<span class="ruby-comment"># File lib/helperfunctions.rb, line 697</span>
2841
2885
def self.terminate_hybrid_vms(creds)
2842
2886
  <span class="ruby-comment"># TODO: kill my own cloud last</span>
2843
2887
  <span class="ruby-comment"># otherwise could orphan other clouds</span>
2888
2932
          <div class="method-source-code"
2889
2933
            id="terminate_vms-source">
2890
2934
<pre>
2891
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 683</span>
 
2935
<span class="ruby-comment"># File lib/helperfunctions.rb, line 687</span>
2892
2936
def self.terminate_vms(nodes, infrastructure)
2893
2937
  instances = []
2894
2938
  nodes.each { |node|
2928
2972
          <div class="method-source-code"
2929
2973
            id="write_file-source">
2930
2974
<pre>
2931
 
<span class="ruby-comment"># File lib/helperfunctions.rb, line 87</span>
 
2975
<span class="ruby-comment"># File lib/helperfunctions.rb, line 91</span>
2932
2976
def self.write_file(location, contents)
2933
2977
  <span class="ruby-constant">File</span>.open(location, <span class="ruby-string">&quot;w+&quot;</span>) { |file| file.write(contents) }
2934
2978
end</pre>