polytrix 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.groc.json +7 -0
  4. data/.rspec +11 -0
  5. data/.rspec_parallel +10 -0
  6. data/Gemfile +23 -0
  7. data/README.md +48 -0
  8. data/Rakefile +143 -0
  9. data/Vagrantfile +41 -0
  10. data/features/0_identity_spec.rb +40 -0
  11. data/features/1_cloud_files_spec.rb +48 -0
  12. data/features/2_servers_spec.rb +19 -0
  13. data/features/features_helper.rb +46 -0
  14. data/features/helpers/cloudfiles_helper.rb +31 -0
  15. data/features/helpers/pacto_helper.rb +33 -0
  16. data/features/helpers/teardown_helper.rb +49 -0
  17. data/features/pacto/extensions/loaders/api_blueprint_loader.rb +63 -0
  18. data/features/pacto/extensions/loaders/simple_loader.rb +55 -0
  19. data/features/pacto/extensions/loaders/yaml_or_json_loader.rb +17 -0
  20. data/features/pacto/extensions/matchers.rb +38 -0
  21. data/features/phase2/feature_coverage_report.rb +109 -0
  22. data/features/phase2/run_all_features.rb +14 -0
  23. data/features/static_site/fixtures/index.html +6 -0
  24. data/lib/polytrix/challenge.rb +27 -0
  25. data/lib/polytrix/challenge_builder.rb +16 -0
  26. data/lib/polytrix/challenge_runner.rb +87 -0
  27. data/lib/polytrix/configuration.rb +31 -0
  28. data/lib/polytrix/core/file_finder.rb +43 -0
  29. data/lib/polytrix/core/implementor.rb +17 -0
  30. data/lib/polytrix/core/result_tracker.rb +25 -0
  31. data/lib/polytrix/documentation_generator.rb +18 -0
  32. data/lib/polytrix/manifest.rb +46 -0
  33. data/lib/polytrix/result.rb +9 -0
  34. data/lib/polytrix/rspec/documentation_formatter.rb +41 -0
  35. data/lib/polytrix/rspec.rb +75 -0
  36. data/lib/polytrix/runners/linux_challenge_runner.rb +22 -0
  37. data/lib/polytrix/runners/middleware/change_directory.rb +20 -0
  38. data/lib/polytrix/runners/middleware/feature_executor.rb +23 -0
  39. data/lib/polytrix/runners/middleware/pacto.rb +59 -0
  40. data/lib/polytrix/runners/middleware/setup_env_vars.rb +38 -0
  41. data/lib/polytrix/runners/windows_challenge_runner.rb +25 -0
  42. data/lib/polytrix/version.rb +3 -0
  43. data/lib/polytrix.rb +56 -0
  44. data/packer/.gitignore +3 -0
  45. data/packer/Berksfile +15 -0
  46. data/packer/Gemfile +5 -0
  47. data/packer/Vagrantfile +128 -0
  48. data/packer/cookbooks/drg/metadata.rb +27 -0
  49. data/packer/cookbooks/drg/recipes/admins.rb +22 -0
  50. data/packer/cookbooks/drg/recipes/default.rb +9 -0
  51. data/packer/cookbooks/drg/recipes/dotnet.rb +4 -0
  52. data/packer/cookbooks/drg/recipes/golang.rb +4 -0
  53. data/packer/cookbooks/drg/recipes/java.rb +5 -0
  54. data/packer/cookbooks/drg/recipes/php.rb +10 -0
  55. data/packer/cookbooks/drg/recipes/ruby.rb +29 -0
  56. data/packer/cookbooks/drg/recipes/system.rb +13 -0
  57. data/packer/create_box.sh +10 -0
  58. data/packer/http/preseed.cfg +87 -0
  59. data/packer/packer.json +91 -0
  60. data/packer/scripts/root_setup.sh +37 -0
  61. data/packer/scripts/setup.sh +32 -0
  62. data/pacto/config/pacto_server.rb +40 -0
  63. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/extensions.json +64 -0
  64. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/flavors/id.json +100 -0
  65. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/images/id.json +176 -0
  66. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers/id.json +189 -0
  67. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers.json +63 -0
  68. data/pacto/contracts/dns.api.rackspacecloud.com/v1.0/_tenant_id/domains.json +62 -0
  69. data/pacto/contracts/identity.api.rackspacecloud.com/v2.0/tokens.json +192 -0
  70. data/pacto/contracts/monitoring.api.rackspacecloud.com/v1.0/_tenant_id/account.json +39 -0
  71. data/pacto/contracts/ord.autoscale.api.rackspacecloud.com/v1.0/_tenant_id/groups.json +38 -0
  72. data/pacto/contracts/ord.blockstorage.api.rackspacecloud.com/v1/_tenant_id/volumes.json +30 -0
  73. data/pacto/contracts/ord.databases.api.rackspacecloud.com/v1.0/_tenant_id/instances.json +30 -0
  74. data/pacto/contracts/ord.loadbalancers.api.rackspacecloud.com/v1.0/_tenant_id/loadbalancers.json +114 -0
  75. data/pacto/contracts/ord.queues.api.rackspacecloud.com/v1/_tenant_id/queues.json +13 -0
  76. data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/os-networksv2.json +46 -0
  77. data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/servers/detail.json +230 -0
  78. data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account/container/object.json +15 -0
  79. data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account.json +43 -0
  80. data/pacto/contracts/storage101.ord1.clouddrive.com/v1/_mosso_id.json +44 -0
  81. data/pacto/pacto_server.rb +100 -0
  82. data/pacto/rackspace_uri_map.yaml +229 -0
  83. data/polytrix.gemspec +27 -0
  84. data/scripts/bootstrap +10 -0
  85. data/scripts/cibuild +4 -0
  86. data/sdks/fog/.gitignore +1 -0
  87. data/sdks/fog/Gemfile +5 -0
  88. data/sdks/fog/challenges/all_connections.rb +45 -0
  89. data/sdks/fog/challenges/authenticate_token.rb +15 -0
  90. data/sdks/fog/challenges/cdn_enable_container.rb +20 -0
  91. data/sdks/fog/challenges/create_a_container.rb +17 -0
  92. data/sdks/fog/challenges/create_server.rb +36 -0
  93. data/sdks/fog/challenges/get_object_metadata.rb +13 -0
  94. data/sdks/fog/challenges/list_containers.rb +10 -0
  95. data/sdks/fog/challenges/provision_scalable_webapp.rb +30 -0
  96. data/sdks/fog/challenges/upload_folder.rb +25 -0
  97. data/sdks/fog/scripts/bootstrap +4 -0
  98. data/sdks/fog/scripts/bootstrap.ps1 +1 -0
  99. data/sdks/fog/scripts/wrapper +2 -0
  100. data/sdks/fog/scripts/wrapper.ps1 +1 -0
  101. data/sdks/gophercloud/.gitignore +2 -0
  102. data/sdks/gophercloud/challenges/authenticate_token.go +23 -0
  103. data/sdks/gophercloud/scripts/bootstrap +6 -0
  104. data/sdks/gophercloud/scripts/wrapper +10 -0
  105. data/sdks/jclouds/.gitignore +1 -0
  106. data/sdks/jclouds/challenges/AuthenticateToken.java +115 -0
  107. data/sdks/jclouds/pom.xml +34 -0
  108. data/sdks/jclouds/scripts/bootstrap +3 -0
  109. data/sdks/jclouds/scripts/wrapper +7 -0
  110. data/sdks/openstack.net/.gitignore +4 -0
  111. data/sdks/openstack.net/.nuget/Microsoft.Build.dll +0 -0
  112. data/sdks/openstack.net/.nuget/NuGet.Config +6 -0
  113. data/sdks/openstack.net/.nuget/NuGet.exe +0 -0
  114. data/sdks/openstack.net/.nuget/NuGet.targets +136 -0
  115. data/sdks/openstack.net/Challenge.cs +10 -0
  116. data/sdks/openstack.net/RunChallenge.cs +19 -0
  117. data/sdks/openstack.net/challenges/AuthenticateToken.cs +24 -0
  118. data/sdks/openstack.net/challenges/Weird.cs +133 -0
  119. data/sdks/openstack.net/openstack.net.csproj +58 -0
  120. data/sdks/openstack.net/openstack.net.sln +27 -0
  121. data/sdks/openstack.net/openstack.net.userprefs +8 -0
  122. data/sdks/openstack.net/packages.config +6 -0
  123. data/sdks/openstack.net/scripts/bootstrap +2 -0
  124. data/sdks/openstack.net/scripts/bootstrap.ps1 +2 -0
  125. data/sdks/openstack.net/scripts/wrapper +7 -0
  126. data/sdks/openstack.net/scripts/wrapper.ps1 +1 -0
  127. data/sdks/php-opencloud/.gitignore +4 -0
  128. data/sdks/php-opencloud/challenges/all_connections.php +64 -0
  129. data/sdks/php-opencloud/challenges/authenticate_token.php +14 -0
  130. data/sdks/php-opencloud/challenges/create_server.php +39 -0
  131. data/sdks/php-opencloud/challenges/get_object_metadata.php +19 -0
  132. data/sdks/php-opencloud/composer.json +5 -0
  133. data/sdks/php-opencloud/scripts/bootstrap +4 -0
  134. data/sdks/php-opencloud/scripts/bootstrap.ps1 +2 -0
  135. data/sdks/php-opencloud/scripts/wrapper +2 -0
  136. data/sdks/php-opencloud/scripts/wrapper.ps1 +1 -0
  137. data/sdks/pkgcloud/.gitignore +1 -0
  138. data/sdks/pkgcloud/challenges/authenticate_token.js +17 -0
  139. data/sdks/pkgcloud/challenges/get_object_metadata.js +18 -0
  140. data/sdks/pkgcloud/scripts/bootstrap +2 -0
  141. data/sdks/pkgcloud/scripts/bootstrap.ps1 +1 -0
  142. data/sdks/pkgcloud/scripts/wrapper +2 -0
  143. data/sdks/pkgcloud/scripts/wrapper.ps1 +1 -0
  144. data/sdks/pyrax/.gitignore +2 -0
  145. data/sdks/pyrax/challenges/all_connections.py +61 -0
  146. data/sdks/pyrax/challenges/authenticate_token.py +17 -0
  147. data/sdks/pyrax/challenges/cdn_enable_container.py +22 -0
  148. data/sdks/pyrax/challenges/create_a_container.py +21 -0
  149. data/sdks/pyrax/challenges/create_server.py +35 -0
  150. data/sdks/pyrax/challenges/get_object_metadata.py +17 -0
  151. data/sdks/pyrax/challenges/upload_folder.py +32 -0
  152. data/sdks/pyrax/requirements.txt +21 -0
  153. data/sdks/pyrax/scripts/bootstrap +9 -0
  154. data/sdks/pyrax/scripts/bootstrap.ps1 +7 -0
  155. data/sdks/pyrax/scripts/wrapper +3 -0
  156. data/sdks/pyrax/scripts/wrapper.ps1 +2 -0
  157. data/spec/fixtures/factorial.py +18 -0
  158. data/spec/fixtures/polytrix.yml +16 -0
  159. data/spec/fixtures/src-doc/quine.md.erb +20 -0
  160. data/spec/polytrix/challenge_builder_spec.rb +16 -0
  161. data/spec/polytrix/challenge_runner_spec.rb +14 -0
  162. data/spec/polytrix/challenge_spec.rb +20 -0
  163. data/spec/polytrix/configuration_spec.rb +10 -0
  164. data/spec/polytrix/documentation_generator_spec.rb +36 -0
  165. data/spec/polytrix/file_finder_spec.rb +24 -0
  166. data/spec/polytrix/manifest_spec.rb +26 -0
  167. data/spec/polytrix/middleware/feature_executor_spec.rb +48 -0
  168. data/spec/polytrix_spec.rb +13 -0
  169. data/spec/rspec_spec.rb +17 -0
  170. data/spec/spec_helper.rb +7 -0
  171. metadata +325 -0
@@ -0,0 +1,64 @@
1
+ <?php
2
+ require 'vendor/autoload.php';
3
+ use OpenCloud\Rackspace;
4
+
5
+ $region = getenv('RAX_REGION');
6
+ $endpoint = getenv('RAX_AUTH_URL') . '/v2.0/';
7
+ $credentials = array(
8
+ 'username' => getenv('RAX_USERNAME'),
9
+ 'apiKey' => getenv('RAX_API_KEY')
10
+ );
11
+
12
+ $rackspace = new Rackspace($endpoint, $credentials);
13
+ $rackspace->Authenticate();
14
+
15
+ $compute = $rackspace->computeService('cloudServersOpenStack', $region);
16
+ $servers = $compute->serverList();
17
+ $networks = $compute->networkList();
18
+ // echo("Servers: ".var_export($servers));
19
+ // echo("Networks: ".var_export($networks));
20
+
21
+ $loadBalancerService = $rackspace->loadBalancerService('cloudLoadBalancers', $region);
22
+ $load_balancers = $loadBalancerService->loadBalancerList();
23
+ // echo("Cloud Load Balancers: ".var_export($load_balancers));
24
+
25
+ $cloudFilesService = $rackspace->objectStoreService('cloudFiles', $region);
26
+ $containers = $cloudFilesService->listContainers();
27
+ // echo("Cloud Files Containers: ".var_export($containers));
28
+
29
+ $databaseService = $rackspace->databaseService('cloudDatabases', $region);
30
+ $databases = $databaseService->instanceList();
31
+ // echo("Cloud Databases: ".var_export($databases));
32
+
33
+ $dnsService = $rackspace->dnsService('cloudDNS', $region);
34
+ $domains = $dnsService->domainList();
35
+ // Can I get zones?
36
+ // echo("Cloud DNS: $zones")
37
+ // echo('Cloud DNS: $domains');
38
+
39
+ $identityService = $rackspace->identityService();
40
+ $users = $identityService->getUsers();
41
+ // echo("Cloud Identity Users: ".var_export($users));
42
+
43
+ $monitoringService = $rackspace->cloudMonitoringService('cloudMonitoring', 'ORD', 'publicURL');
44
+ $checkTypes = $monitoringService->getCheckTypes();
45
+ // Can I get the account info?
46
+ // echo("Cloud Monitoring Account: $account")
47
+ // echo("Cloud Monitoring Check Types: ".var_export($checkTypes));
48
+
49
+ $blockStorageService = $rackspace->volumeService('cloudBlockStorage', 'DFW');
50
+ $volumes = $blockStorageService->volumeList(false);
51
+ // echo("Cloud Block Storage Volumes: ".var_export($volumes));
52
+
53
+ # Cloud Backup?
54
+
55
+ $autoscaleService = $rackspace->autoscaleService();
56
+ $groups = $autoscaleService->groupList();
57
+ // echo("Autoscale Scaling Groups: ".var_export($groups));
58
+
59
+ # Cloud Queues
60
+ $queuesService = $rackspace->queuesService('cloudQueues', $region);
61
+ $queues = $queuesService->listQueues();
62
+ // echo("Cloud Queues: ".var_export($queues));
63
+
64
+ ?>
@@ -0,0 +1,14 @@
1
+ <?php
2
+ require 'vendor/autoload.php';
3
+ use OpenCloud\Rackspace;
4
+
5
+ $endpoint = getenv('RAX_AUTH_URL') . '/v2.0/';
6
+ $credentials = array(
7
+ 'username' => getenv('RAX_USERNAME'),
8
+ 'apiKey' => getenv('RAX_API_KEY')
9
+ );
10
+
11
+ $rackspace = new Rackspace($endpoint, $credentials);
12
+ $rackspace->Authenticate();
13
+ echo('Authenticated')
14
+ ?>
@@ -0,0 +1,39 @@
1
+ <?php
2
+ require('vendor/autoload.php');
3
+ use OpenCloud\Rackspace;
4
+
5
+ $endpoint = getenv('RAX_AUTH_URL') . '/v2.0/';
6
+ $credentials = array(
7
+ 'username' => getenv('RAX_USERNAME'),
8
+ 'apiKey' => getenv('RAX_API_KEY')
9
+ );
10
+
11
+ $rackspace = new Rackspace($endpoint, $credentials);
12
+ $compute = $rackspace->computeService('cloudServersOpenStack', getenv('RAX_REGION'));
13
+
14
+ $image_id = getenv('SERVER1_IMAGE');
15
+ $flavor_id = getenv('SERVER1_FLAVOR');
16
+
17
+ // Create a server in DFW
18
+ $server = $compute->Server();
19
+ // create it
20
+ print("Creating server...");
21
+ $server->create(array(
22
+ 'name' => 'php-opencloud server',
23
+ // Using the image ID from ORD
24
+ 'image' => $compute->image($image_id),
25
+ // And a flavor that's too small
26
+ 'flavor' => $compute->flavor($flavor_id)
27
+ ));
28
+ print("requested, now waiting...\n");
29
+ print("ID=" . $server->id . "...\n");
30
+ $server->WaitFor("ACTIVE", 600, 'dot');
31
+ print("done\n");
32
+ exit(0);
33
+
34
+ function dot($server)
35
+ {
36
+ printf("%s %3d%%\n", $server->status, $server->progress);
37
+ }
38
+
39
+ ?>
@@ -0,0 +1,19 @@
1
+ <?php
2
+ require 'vendor/autoload.php';
3
+ use OpenCloud\Rackspace;
4
+
5
+ $region = getenv('RAX_REGION');
6
+ $endpoint = getenv('RAX_AUTH_URL') . '/v2.0/';
7
+ $credentials = array(
8
+ 'username' => getenv('RAX_USERNAME'),
9
+ 'apiKey' => getenv('RAX_API_KEY')
10
+ );
11
+ $directory = getenv('TEST_DIRECTORY');
12
+ $file = getenv('TEST_FILE');
13
+
14
+ $rackspace = new Rackspace($endpoint, $credentials);
15
+ $cloudFilesService = $rackspace->objectStoreService('cloudFiles', $region);
16
+ $container = $cloudFilesService->getContainer($directory);
17
+ $object = $container->getPartialObject($file);
18
+
19
+ ?>
@@ -0,0 +1,5 @@
1
+ {
2
+ "require": {
3
+ "rackspace/php-opencloud": "*"
4
+ }
5
+ }
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ wget --timestamping https://getcomposer.org/installer
3
+ php installer
4
+ php composer.phar update
@@ -0,0 +1,2 @@
1
+ php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
2
+ php composer.phar install
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ php $1
@@ -0,0 +1 @@
1
+ php "$args"
@@ -0,0 +1 @@
1
+ node_modules/
@@ -0,0 +1,17 @@
1
+ var pkgcloud = require('pkgcloud');
2
+
3
+ // create our client with your rackspace credentials
4
+ var client = pkgcloud.providers.rackspace.compute.createClient({
5
+ username: process.env.RAX_USERNAME,
6
+ apiKey: process.env.RAX_API_KEY,
7
+ authUrl: process.env.RAX_AUTH_URL,
8
+ region: process.env.RAX_REGION
9
+ });
10
+ client.auth(function(err) {
11
+ if (err) {
12
+ console.log(err.message);
13
+ process.exit(1);
14
+ } else {
15
+ console.log('Authenticated');
16
+ }
17
+ });
@@ -0,0 +1,18 @@
1
+ var pkgcloud = require('pkgcloud');
2
+
3
+ // create our client with your rackspace credentials
4
+ var storageClient = pkgcloud.providers.rackspace.storage.createClient({
5
+ username: process.env.RAX_USERNAME,
6
+ apiKey: process.env.RAX_API_KEY,
7
+ authUrl: process.env.RAX_AUTH_URL,
8
+ region: process.env.RAX_REGION
9
+ });
10
+
11
+ storageClient.getFile(process.env.TEST_DIRECTORY, process.env.TEST_FILE, function (err, server) {
12
+ if (err) {
13
+ console.dir(err);
14
+ return;
15
+ }
16
+
17
+ console.dir(server);
18
+ });
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ npm install pkgcloud
@@ -0,0 +1 @@
1
+ npm install pkgcloud
@@ -0,0 +1,2 @@
1
+ #!/bin/bash
2
+ node "$@"
@@ -0,0 +1 @@
1
+ node "$args"
@@ -0,0 +1,2 @@
1
+ pyrax_env/
2
+
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import pyrax
5
+
6
+ pyrax.set_setting("identity_type", "rackspace")
7
+ # Create the identity object
8
+ pyrax._create_identity()
9
+ # Change its endpoint
10
+ pyrax.identity.auth_endpoint = os.getenv('RAX_AUTH_URL') + '/v2.0/'
11
+
12
+ # Authenticate
13
+ pyrax.set_credentials(os.getenv('RAX_USERNAME'), os.getenv('RAX_API_KEY'))
14
+
15
+ print "Authenticated"
16
+
17
+ # Cloud Servers API - List Servers
18
+ cs = pyrax.cloudservers
19
+ print "Servers:", cs.servers.list()
20
+
21
+ # Networks API - List Networks
22
+ cnw = pyrax.cloud_networks
23
+ print "Networks:", cnw.list()
24
+
25
+ # Cloud Files API - List Files
26
+ cf = pyrax.cloudfiles
27
+ cf.http_log_debug = True
28
+ print "Cloud Files Containers:", cf.list_containers()
29
+
30
+ # Cloud Load Balancers
31
+ clb = pyrax.cloud_loadbalancers
32
+ print "Cloud Load Balancers:", clb.list()
33
+
34
+ # Cloud Database
35
+ cdb = pyrax.cloud_databases
36
+ print "Cloud Databases:", cdb.list()
37
+
38
+ # Cloud DNS
39
+ cdns = pyrax.cloud_dns
40
+ print "Cloud DNS:", cdns.list()
41
+
42
+ # Cloud Identity
43
+ # print "Cloud Identity Users:", pyrax.identity.list_users()
44
+
45
+ # Cloud Monitoring
46
+ cm = pyrax.cloud_monitoring
47
+ print "Cloud Monitoring Account:", cm.get_account()
48
+
49
+ # Cloud Block Storage
50
+ cbs = pyrax.cloud_blockstorage
51
+ print "Cloud Block Storage Volumes:", cbs.list()
52
+
53
+ # Cloud Backup?
54
+
55
+ # Autoscale
56
+ ax = pyrax.autoscale
57
+ print "Autoscale Scaling Groups:", ax.list()
58
+
59
+ # Cloud Queues
60
+ pq = pyrax.queues
61
+ print "Cloud Queues:", pq.list()
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import pyrax
5
+
6
+ pyrax.set_setting("identity_type", "rackspace")
7
+ # Create the identity object
8
+ pyrax._create_identity()
9
+ # Change its endpoint
10
+ endpoint = os.getenv('RAX_AUTH_URL')
11
+ if endpoint is not None:
12
+ pyrax.identity.auth_endpoint = os.getenv('RAX_AUTH_URL') + '/v2.0/'
13
+
14
+ # Authenticate
15
+ pyrax.set_credentials(os.getenv('RAX_USERNAME'), os.getenv('RAX_API_KEY'))
16
+
17
+ print "Authenticated"
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import pyrax
5
+
6
+ container_name = 'my-site'
7
+ folder_to_upload = os.getenv('TEST_DIRECTORY')
8
+ username = os.getenv('RAX_USERNAME')
9
+ api_key = os.getenv('RAX_API_KEY')
10
+ auth_endpoint = os.getenv('RAX_AUTH_URL')
11
+
12
+ pyrax.set_setting("identity_type", "rackspace")
13
+ # Create the identity object
14
+ pyrax._create_identity()
15
+ # Change its endpoint
16
+ pyrax.identity.auth_endpoint = auth_endpoint + '/v2.0/'
17
+
18
+ # Identity Connection - Authenticate
19
+ pyrax.set_credentials(username, api_key)
20
+
21
+ cf = pyrax.cloudfiles
22
+ cf.make_container_public(container_name, ttl=900)
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import pyrax
5
+
6
+ container_name = os.getenv('CONTAINER_NAME')
7
+ username = os.getenv('RAX_USERNAME')
8
+ api_key = os.getenv('RAX_API_KEY')
9
+ auth_endpoint = os.getenv('RAX_AUTH_URL')
10
+
11
+ pyrax.set_setting("identity_type", "rackspace")
12
+ # Create the identity object
13
+ pyrax._create_identity()
14
+ # Change its endpoint
15
+ pyrax.identity.auth_endpoint = auth_endpoint + '/v2.0/'
16
+
17
+ # Identity Connection - Authenticate
18
+ pyrax.set_credentials(username, api_key)
19
+
20
+ cf = pyrax.cloudfiles
21
+ cont = cf.create_container("my-site")
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import pyrax
5
+ # [Configure Pyrax](https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#pyrax-configuration)
6
+ # to use the Rackspace identity service.
7
+
8
+ pyrax.set_setting("identity_type", "rackspace")
9
+
10
+
11
+ # Change the authentication endpoint if requested, otherwise use the default
12
+ custom_endpoint = os.getenv('RAX_AUTH_URL')
13
+ if custom_endpoint is not None:
14
+ pyrax._create_identity()
15
+ # Pyrax requires the endpoint to contain the version
16
+ pyrax.identity.auth_endpoint = custom_endpoint + '/v2.0/'
17
+
18
+ # Set the region, needs to be done before authenticating.
19
+ pyrax.set_setting('region', os.getenv('RAX_REGION'))
20
+
21
+ # [Authenticate](https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#authenticating)
22
+ # using an API key.
23
+ pyrax.set_credentials(os.getenv('RAX_USERNAME'), os.getenv('RAX_API_KEY'))
24
+
25
+ # Get the flavor and image for the test scenario.
26
+ flavor = os.getenv('SERVER1_FLAVOR')
27
+ image = os.getenv('SERVER1_IMAGE')
28
+
29
+ # Create a [Cloud Servers](https://github.com/rackspace/pyrax/blob/master/docs/cloud_servers.md) connection.
30
+ cs = pyrax.cloudservers
31
+
32
+ # [Create a server](https://github.com/rackspace/pyrax/blob/master/docs/cloud_servers.md#creating-a-server)
33
+ server = cs.servers.create("Pyrax Server", image, flavor)
34
+ # and [wait for it to build](https://github.com/rackspace/pyrax/blob/master/docs/cloud_servers.md#waiting-for-server-completion).
35
+ pyrax.utils.wait_for_build(server, verbose=True)
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import pyrax
5
+
6
+ pyrax.set_setting("identity_type", "rackspace")
7
+ # Create the identity object
8
+ pyrax._create_identity()
9
+ # Change its endpoint
10
+ pyrax.identity.auth_endpoint = os.getenv('RAX_AUTH_URL') + '/v2.0/'
11
+
12
+ # Authenticate
13
+ pyrax.set_credentials(os.getenv('RAX_USERNAME'), os.getenv('RAX_API_KEY'))
14
+
15
+ # Cloud Files API - List Files
16
+ cf = pyrax.cloudfiles
17
+ cf.get_object_metadata(os.getenv('TEST_DIRECTORY'), os.getenv('TEST_FILE'))
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import pyrax
5
+ import time
6
+
7
+ container_name = 'my-site'
8
+ folder_to_upload = os.getenv('TEST_DIRECTORY')
9
+ username = os.getenv('RAX_USERNAME')
10
+ api_key = os.getenv('RAX_API_KEY')
11
+ auth_endpoint = os.getenv('RAX_AUTH_URL')
12
+
13
+ pyrax.set_setting("identity_type", "rackspace")
14
+ # Create the identity object
15
+ pyrax._create_identity()
16
+ # Change its endpoint
17
+ pyrax.identity.auth_endpoint = auth_endpoint + '/v2.0/'
18
+
19
+ # Identity Connection - Authenticate
20
+ pyrax.set_credentials(username, api_key)
21
+
22
+ cf = pyrax.cloudfiles
23
+ print 'Uploading folder'
24
+ upload_key, total_bytes = cf.upload_folder(folder_to_upload, container=container_name)
25
+ print "Total bytes to upload:", total_bytes
26
+ uploaded = 0
27
+ while uploaded < total_bytes:
28
+ uploaded = cf.get_uploaded(upload_key)
29
+ print "Progress: %4.2f%%" % ((uploaded * 100.0) / total_bytes)
30
+ time.sleep(1)
31
+
32
+ print 'Done uploading'
@@ -0,0 +1,21 @@
1
+ Babel==1.3
2
+ httplib2==0.8
3
+ iso8601==0.1.10
4
+ keyring==3.6
5
+ mock==1.0.1
6
+ os-diskconfig-python-novaclient-ext==0.1.2
7
+ os-networksv2-python-novaclient-ext==0.21
8
+ os-virtual-interfacesv2-python-novaclient-ext==0.15
9
+ pbr==0.6
10
+ prettytable==0.7.2
11
+ pyrax==1.6.4
12
+ python-novaclient==2.13.0
13
+ pytz==2014.1
14
+ rackspace-auth-openstack==1.3
15
+ rackspace-novaclient==1.4
16
+ rax-default-network-flags-python-novaclient-ext==0.2.3
17
+ rax-scheduled-images-python-novaclient-ext==0.2.1
18
+ requests==2.2.1
19
+ simplejson==3.3.3
20
+ six==1.6.1
21
+ wsgiref==0.1.2
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ virtualenv pyrax_env
4
+ source pyrax_env/bin/activate
5
+
6
+ # Slow!
7
+ pip -q install -r requirements.txt
8
+
9
+ # pip -q install pyrax
@@ -0,0 +1,7 @@
1
+ virtualenv pyrax_env
2
+ workon pyrax_env
3
+
4
+ # Slow!
5
+ # pip -q install -U pyrax
6
+
7
+ pip -q install pyrax
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+ source pyrax_env/bin/activate
3
+ python "$@"
@@ -0,0 +1,2 @@
1
+ workon pyrax_env
2
+ python "$args"
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env python
2
+ # Content above the snippet is ignored
3
+
4
+ print 'Hello, world!'
5
+
6
+ # {{snippet factorial}}
7
+ def factorial(n):
8
+ if n == 0:
9
+ return 1
10
+ else:
11
+ return n * factorial(n-1)
12
+ # {{endsnippet}}
13
+
14
+ # So is content below the snippet
15
+ print "{{snippet factorial_result}}"
16
+ print "The result of factorial(7) is:"
17
+ print " %d" % factorial(7)
18
+ print "{{endsnippet}}"
@@ -0,0 +1,16 @@
1
+ ---
2
+ global_env:
3
+ LOCALE: <%= ENV['LANG'] %>
4
+ FAVORITE_NUMBER: 5
5
+ suites:
6
+ Katas:
7
+ env:
8
+ NAME: 'Max'
9
+ samples:
10
+ - hello world
11
+ - quine
12
+ Tutorials:
13
+ env:
14
+ samples:
15
+ - deploying
16
+ - documenting
@@ -0,0 +1,20 @@
1
+ # Quines
2
+
3
+ This document is a small collection of quines. This documentation is generated from a [Polytrix](https://github.com/rackerlabs/polytrix) that validated each quine.
4
+
5
+ Examples for <%= scenario %> scenario:
6
+
7
+ <% Polytrix.implementors.each do |implementor| %>
8
+ ## <%= implementor %> <%#= implementor.name %>
9
+
10
+ Source:
11
+
12
+ ```<%#= implementor.language %>
13
+ <%#= implementor.sample_code_for scenario %>
14
+ ```
15
+
16
+ Output:
17
+ ```
18
+ <%#= implementor.result_for scenario %>
19
+ ```
20
+ <% end %>
@@ -0,0 +1,16 @@
1
+ module Polytrix
2
+ describe ChallengeBuilder do
3
+ let(:implementor) { Polytrix::Implementor.new :name => 'some_sdk', :basedir => 'spec/fixtures' }
4
+ subject(:builder) { described_class.new implementor }
5
+ let(:challenge) { challenge = builder.build :name => 'factorial', :vars => {} }
6
+
7
+ it 'builds a Challenge' do
8
+ expect(challenge).to be_an_instance_of Polytrix::Challenge
9
+ end
10
+
11
+ it 'finds the source' do
12
+ expected_file = Pathname.new 'spec/fixtures/factorial.py'
13
+ expect(challenge.source_file).to eq(expected_file)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Polytrix
2
+ describe ChallengeRunner do
3
+ subject(:runner) { ChallengeRunner.createRunner }
4
+ let(:challenge) do
5
+ Challenge.new :name => 'factorial', :source_file => 'spec/fixtures/factorial.py', :basedir => 'spec/fixtures'
6
+ end
7
+
8
+ describe '#run_challenge' do
9
+ it 'executes a challenge' do
10
+ expect(runner.run_challenge challenge).to be_an_instance_of Challenge
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ module Polytrix
2
+ describe Challenge do
3
+ subject(:challenge) do
4
+ implementor = Polytrix::Implementor.new :name => 'some_sdk', :basedir => 'spec/fixtures'
5
+ builder = Polytrix::ChallengeBuilder.new implementor
6
+ builder.build :name => 'factorial', :vars => {}
7
+ end
8
+
9
+ describe '#run' do
10
+ it 'executes the challenge and returns itself' do
11
+ expect(challenge.run).to be_an_instance_of Challenge
12
+ expect(challenge.run).to eq(challenge)
13
+ end
14
+
15
+ it 'stores the result' do
16
+ expect(challenge.run[:result]).to be_an_instance_of Result
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ module Polytrix
2
+ describe Configuration do
3
+ subject(:configuration) { Configuration.new }
4
+
5
+ it 'creates a logger' do
6
+ expect(configuration.logger).to be_kind_of Logger
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ module Polytrix
2
+ describe DocumentationGenerator do
3
+ let(:search_path) { 'spec/fixtures/src-doc' }
4
+ let(:bound_data) { double }
5
+ subject(:generator) { DocumentationGenerator.new(search_path) }
6
+
7
+ context 'when no documentation exists' do
8
+ it 'does nothing if there is no documentation for the scenario' do
9
+ expect(generator.process 'no_doc', bound_data).to be_nil
10
+ end
11
+ end
12
+
13
+ context 'when documentation does exist' do
14
+
15
+ let(:generated_doc) { generator.process 'Quine', bound_data }
16
+
17
+ it 'returns the generated document as a string' do
18
+ expect(generated_doc).to be_a(String)
19
+ end
20
+
21
+ context 'ERB processing' do
22
+ it 'processes scenario' do
23
+ expect(generated_doc).to include 'Examples for Quine scenario:'
24
+ end
25
+
26
+ it 'processes Polytrix.implementors' do
27
+ fail 'This test requires implementors' unless Polytrix.implementors
28
+
29
+ Polytrix.implementors.each do |implementor|
30
+ expect(generated_doc).to include "## #{implementor}"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end