aviator 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.travis.yml +1 -0
- data/README.md +35 -8
- data/README.md.orig +217 -0
- data/aviator.gemspec +3 -3
- data/lib/aviator/openstack/compute/v2/public/change_admin_password.rb +54 -0
- data/lib/aviator/openstack/compute/v2/public/create_image.rb +56 -0
- data/lib/aviator/openstack/compute/v2/public/create_server.rb +64 -0
- data/lib/aviator/openstack/compute/v2/public/delete_server.rb +39 -0
- data/lib/aviator/openstack/compute/v2/public/get_server.rb +39 -0
- data/lib/aviator/openstack/compute/v2/public/list_addresses.rb +48 -0
- data/lib/aviator/openstack/compute/v2/public/list_flavors.rb +55 -0
- data/lib/aviator/openstack/compute/v2/public/reboot_server.rb +51 -0
- data/lib/aviator/openstack/compute/v2/public/rebuild_server.rb +63 -0
- data/lib/aviator/openstack/compute/v2/public/root.rb +34 -0
- data/lib/aviator/openstack/compute/v2/public/update_server.rb +55 -0
- data/lib/aviator/version.rb +1 -1
- data/test/aviator/core/service_test.rb +3 -15
- data/test/aviator/core/session_test.rb +3 -3
- data/test/aviator/openstack/compute/v2/public/change_admin_password_test.rb +141 -0
- data/test/aviator/openstack/compute/v2/public/create_image_test.rb +146 -0
- data/test/aviator/openstack/compute/v2/public/create_server_test.rb +177 -0
- data/test/aviator/openstack/compute/v2/public/delete_server_test.rb +131 -0
- data/test/aviator/openstack/compute/v2/public/get_server_test.rb +138 -0
- data/test/aviator/openstack/compute/v2/public/list_addresses_test.rb +161 -0
- data/test/aviator/openstack/compute/v2/public/list_flavors_test.rb +160 -0
- data/test/aviator/openstack/compute/v2/public/list_images_test.rb +1 -1
- data/test/aviator/openstack/compute/v2/public/reboot_server_test.rb +137 -0
- data/test/aviator/openstack/compute/v2/public/rebuild_server_test.rb +183 -0
- data/test/aviator/openstack/compute/v2/public/root_test.rb +106 -0
- data/test/aviator/openstack/compute/v2/public/update_server_test.rb +144 -0
- data/test/aviator/openstack/identity/v2/admin/create_tenant_test.rb +1 -1
- data/test/cassettes/core/service/i_default_session_data_/sets_the_service_s_default_session_data.yml +18 -17
- data/test/cassettes/core/service/i_request/accepts_an_endpoint_type_option_for_selecting_a_specific_request.yml +31 -30
- data/test/cassettes/core/service/i_request/can_find_the_correct_request_based_on_bootstrapped_session_data.yml +18 -17
- data/test/cassettes/core/service/i_request/can_find_the_correct_request_based_on_non-bootstrapped_session_data.yml +29 -27
- data/test/cassettes/core/service/i_request/can_find_the_correct_request_if_api_version_is_not_defined_but_can_be_inferred_from_host_uri.yml +18 -17
- data/test/cassettes/core/service/i_request/uses_the_default_session_data_if_session_data_is_not_provided.yml +29 -27
- data/test/cassettes/core/session/c_load/creates_a_new_instance_from_the_given_session_dump.yml +18 -17
- data/test/cassettes/core/session/c_load/uses_the_loaded_auth_info_for_its_services.yml +18 -17
- data/test/cassettes/core/session/c_new/directs_log_entries_to_the_given_log_file.yml +18 -17
- data/test/cassettes/core/session/i_authenticate/authenticates_against_the_auth_service_indicated_in_the_config_file.yml +18 -17
- data/test/cassettes/core/session/i_authenticate/authenticates_against_the_auth_service_using_the_credentials_in_the_given_block.yml +10 -10
- data/test/cassettes/core/session/i_authenticate/raises_an_AuthenticationError_when_authentication_fails.yml +3 -3
- data/test/cassettes/core/session/i_authenticate/updates_the_session_data_of_its_service_objects.yml +36 -34
- data/test/cassettes/core/session/i_dump/serializes_the_session_data_for_caching.yml +18 -17
- data/test/cassettes/core/session/i_load/returns_itself.yml +18 -17
- data/test/cassettes/core/session/i_load/updates_the_session_data_of_its_service_objects.yml +36 -34
- data/test/cassettes/core/session/i_validate/returns_false_if_session_is_no_longer_valid.yml +20 -19
- data/test/cassettes/core/session/i_validate/returns_true_if_session_is_still_valid.yml +22 -21
- data/test/cassettes/core/session/i_xxx_service/returns_an_instance_of_the_indicated_service.yml +18 -17
- data/test/cassettes/openstack/compute/v2/public/change_admin_password/leads_to_a_valid_response_when_invalid_server_id_is_provided.yml +97 -0
- data/test/cassettes/openstack/compute/v2/public/change_admin_password/leads_to_a_valid_response_when_valid_params_are_provided.yml +132 -0
- data/test/cassettes/openstack/compute/v2/public/change_admin_password/returns_the_correct_value_for_body_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/change_admin_password/returns_the_correct_value_for_headers_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/change_admin_password/returns_the_correct_value_for_http_method_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/change_admin_password/returns_the_correct_value_for_url_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/create_image/leads_to_a_valid_response_when_invalid_server_id_is_provided.yml +97 -0
- data/test/cassettes/openstack/compute/v2/public/create_image/leads_to_a_valid_response_when_valid_params_are_provided.yml +132 -0
- data/test/cassettes/openstack/compute/v2/public/create_image/returns_the_correct_value_for_body_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/create_image/returns_the_correct_value_for_headers_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/create_image/returns_the_correct_value_for_http_method_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/create_image/returns_the_correct_value_for_url_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_parameters_are_provided.yml +182 -0
- data/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_adminPass_parameter_is_provided.yml +182 -0
- data/test/cassettes/openstack/compute/v2/public/create_server/leads_to_a_valid_response_when_the_flavorRef_parameter_is_invalid.yml +135 -0
- data/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_body_.yml +142 -0
- data/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_headers_.yml +142 -0
- data/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_http_method_.yml +142 -0
- data/test/cassettes/openstack/compute/v2/public/create_server/returns_the_correct_value_for_url_.yml +222 -0
- data/test/cassettes/openstack/compute/v2/public/delete_server/leads_to_a_valid_response_when_invalid_server_id_is_provided.yml +96 -0
- data/test/cassettes/openstack/compute/v2/public/delete_server/leads_to_a_valid_response_when_valid_server_id_is_provided.yml +131 -0
- data/test/cassettes/openstack/compute/v2/public/delete_server/returns_the_correct_value_for_body_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/delete_server/returns_the_correct_value_for_headers_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/delete_server/returns_the_correct_value_for_http_method_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/delete_server/returns_the_correct_value_for_url_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/get_server/leads_to_a_valid_response_when_a_valid_server_id_is_provided.yml +145 -0
- data/test/cassettes/openstack/compute/v2/public/get_server/leads_to_a_valid_response_when_an_invalid_server_id_is_provided.yml +96 -0
- data/test/cassettes/openstack/compute/v2/public/get_server/returns_the_correct_value_for_body_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/get_server/returns_the_correct_value_for_headers_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/get_server/returns_the_correct_value_for_http_method_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/get_server/returns_the_correct_value_for_url_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/list_addresses/leads_to_a_valid_response_when_a_networkID_parameter_is_provided.yml +167 -0
- data/test/cassettes/openstack/compute/v2/public/list_addresses/leads_to_a_valid_response_when_a_valid_server_id_is_provided.yml +132 -0
- data/test/cassettes/openstack/compute/v2/public/list_addresses/leads_to_a_valid_response_when_an_invalid_server_id_is_provided.yml +96 -0
- data/test/cassettes/openstack/compute/v2/public/list_addresses/returns_the_correct_value_for_body_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/list_addresses/returns_the_correct_value_for_headers_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/list_addresses/returns_the_correct_value_for_http_method_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/list_addresses/returns_the_correct_value_for_url_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/list_flavors/leads_to_a_valid_response_when_no_parameters_are_provided.yml +104 -0
- data/test/cassettes/openstack/compute/v2/public/list_flavors/leads_to_a_valid_response_when_the_details_filter_is_provided.yml +111 -0
- data/test/cassettes/openstack/compute/v2/public/list_flavors/leads_to_a_valid_response_when_the_minDisk_filter_is_provided.yml +146 -0
- data/test/cassettes/openstack/compute/v2/public/list_flavors/returns_the_correct_value_for_body_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/list_flavors/returns_the_correct_value_for_headers_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/list_flavors/returns_the_correct_value_for_http_method_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/list_flavors/returns_the_correct_value_for_url_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_no_parameters_are_provided.yml +32 -31
- data/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_parameters_are_invalid.yml +23 -22
- data/test/cassettes/openstack/compute/v2/public/list_images/leads_to_a_valid_response_when_parameters_are_valid.yml +32 -31
- data/test/cassettes/openstack/compute/v2/public/list_images/returns_the_correct_value_for_body_.yml +18 -17
- data/test/cassettes/openstack/compute/v2/public/list_images/returns_the_correct_value_for_headers_.yml +18 -17
- data/test/cassettes/openstack/compute/v2/public/list_images/returns_the_correct_value_for_http_method_.yml +18 -17
- data/test/cassettes/openstack/compute/v2/public/list_images/returns_the_correct_value_for_url_.yml +18 -17
- data/test/cassettes/openstack/compute/v2/public/list_servers/leads_to_a_valid_response_when_no_parameters_are_provided.yml +39 -38
- data/test/cassettes/openstack/compute/v2/public/list_servers/leads_to_a_valid_response_when_parameters_are_invalid.yml +37 -35
- data/test/cassettes/openstack/compute/v2/public/list_servers/leads_to_a_valid_response_when_parameters_are_valid.yml +42 -39
- data/test/cassettes/openstack/compute/v2/public/list_servers/returns_the_correct_value_for_body_.yml +32 -30
- data/test/cassettes/openstack/compute/v2/public/list_servers/returns_the_correct_value_for_headers_.yml +32 -30
- data/test/cassettes/openstack/compute/v2/public/list_servers/returns_the_correct_value_for_http_method_.yml +32 -30
- data/test/cassettes/openstack/compute/v2/public/list_servers/returns_the_correct_value_for_url_.yml +32 -30
- data/test/cassettes/openstack/compute/v2/public/reboot_server/leads_to_a_valid_response_when_invalid_server_id_is_provided.yml +97 -0
- data/test/cassettes/openstack/compute/v2/public/reboot_server/leads_to_a_valid_response_when_valid_params_are_provided.yml +130 -0
- data/test/cassettes/openstack/compute/v2/public/reboot_server/returns_the_correct_value_for_body_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/reboot_server/returns_the_correct_value_for_headers_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/reboot_server/returns_the_correct_value_for_http_method_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/reboot_server/returns_the_correct_value_for_url_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/rebuild_server/leads_to_a_valid_response_when_invalid_image_id_is_provided.yml +133 -0
- data/test/cassettes/openstack/compute/v2/public/rebuild_server/leads_to_a_valid_response_when_invalid_server_id_is_provided.yml +167 -0
- data/test/cassettes/openstack/compute/v2/public/rebuild_server/leads_to_a_valid_response_when_valid_params_are_provided.yml +216 -0
- data/test/cassettes/openstack/compute/v2/public/rebuild_server/returns_the_correct_value_for_body_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/rebuild_server/returns_the_correct_value_for_headers_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/rebuild_server/returns_the_correct_value_for_http_method_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/rebuild_server/returns_the_correct_value_for_url_.yml +63 -0
- data/test/cassettes/openstack/compute/v2/public/root/leads_to_a_valid_response_when_no_parameters_are_provided.yml +101 -0
- data/test/cassettes/openstack/compute/v2/public/root/returns_the_correct_value_for_body_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/root/returns_the_correct_value_for_headers_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/root/returns_the_correct_value_for_http_method_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/root/returns_the_correct_value_for_url_.yml +62 -0
- data/test/cassettes/openstack/compute/v2/public/update_server/leads_to_a_valid_response_when_invalid_server_id_is_provided.yml +96 -0
- data/test/cassettes/openstack/compute/v2/public/update_server/leads_to_a_valid_response_when_valid_server_id_is_provided.yml +142 -0
- data/test/cassettes/openstack/compute/v2/public/update_server/returns_the_correct_value_for_body_.yml +142 -0
- data/test/cassettes/openstack/compute/v2/public/update_server/returns_the_correct_value_for_headers_.yml +142 -0
- data/test/cassettes/openstack/compute/v2/public/update_server/returns_the_correct_value_for_http_method_.yml +142 -0
- data/test/cassettes/openstack/compute/v2/public/update_server/returns_the_correct_value_for_url_.yml +142 -0
- data/test/cassettes/openstack/identity/v2/admin/create_tenant/leads_to_a_valid_response_when_params_are_invalid.yml +21 -20
- data/test/cassettes/openstack/identity/v2/admin/create_tenant/leads_to_a_valid_response_when_params_are_valid.yml +25 -24
- data/test/cassettes/openstack/identity/v2/public/create_token/leads_to_a_valid_response_when_parameters_are_invalid.yml +3 -3
- data/test/cassettes/openstack/identity/v2/public/create_token/leads_to_a_valid_response_when_parameters_are_valid.yml +10 -10
- data/test/cassettes/openstack/identity/v2/public/create_token/leads_to_a_valid_response_when_provided_with_a_token.yml +28 -27
- data/test/environment.yml.example +16 -9
- data/test/environment.yml.travis-ci +19 -14
- data/test/support/vcr_setup.rb +35 -10
- data/test/test_helper.rb +3 -1
- metadata +180 -52
- data/test/cassettes/openstack/compute/v2/public/list_images/returns_the_correct_value_for_body.yml +0 -63
- data/test/cassettes/openstack/compute/v2/public/list_images/returns_the_correct_value_for_headers.yml +0 -63
- data/test/cassettes/openstack/compute/v2/public/list_images/returns_the_correct_value_for_url.yml +0 -63
- data/test/cassettes/openstack/identity/v2/admin/create_tenant/leads_to_a_valid_response_when_provided_with_invalid_params.yml +0 -97
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
NzI1YmNkNTM4YzhkNGUyMzczZTZiNGY4MzI4NTg3YzcyOTdkZjc3Nw==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
M2Q4OTRjZWQwNDAwYjI5YzI2NjM3YzQzNjQ5ZGE3ZjYxYzUxYzBjMQ==
|
|
7
|
+
SHA512:
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
ZTY1ZTYxNzZjOWRlMzk2NThjYmMzZjFkZjg1ZmZhYWM3MDk2YWQ3NTUxNjJl
|
|
10
|
+
MDg4ZWM2ZTFkMTNiYzM1ZDUzODE0YTQ0YjgyMmUzOGM3NjQ0MmMwM2E5NGIx
|
|
11
|
+
NGYyNjJkZjdjNDc1NGY3NTA5ZTgxYWY0MmZkZDgyYzFkMjA2ODg=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
NGUxNTE0MjY1ZjBjMzA1Mjg3ZDIyMjAwYzc4ODBmZTQ2N2ZlM2IwZmQ3ODFl
|
|
14
|
+
ZmI2NjVhZTQzMjU4M2JlZWExZGViYTllNGI5YjQxMzY3Mjk2NjZkYjFlMmYw
|
|
15
|
+
NWMxMGIyMjE2ZmMxMmM4NDAwYzViYTU2NjJiMjhhZTI3ZTRhNjc=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# Aviator
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.org/aviator/aviator)
|
|
4
|
+
[](https://coveralls.io/r/aviator/aviator?branch=master)
|
|
5
|
+
[](https://codeclimate.com/github/aviator/aviator)
|
|
6
|
+
[](http://badge.fury.io/rb/aviator)
|
|
7
|
+
[](https://gemnasium.com/aviator/aviator)
|
|
7
8
|
|
|
8
9
|
A lightweight library for communicating with the OpenStack API.
|
|
9
10
|
|
|
@@ -14,6 +15,10 @@ Add this line to your application's Gemfile:
|
|
|
14
15
|
|
|
15
16
|
gem 'aviator'
|
|
16
17
|
|
|
18
|
+
Or if you want to live on the edge:
|
|
19
|
+
|
|
20
|
+
gem 'aviator', :git => 'git@github.com:aviator/aviator.git', :branch => 'develop'
|
|
21
|
+
|
|
17
22
|
And then execute:
|
|
18
23
|
|
|
19
24
|
$ bundle
|
|
@@ -25,7 +30,7 @@ Or install it yourself as:
|
|
|
25
30
|
## Usage
|
|
26
31
|
|
|
27
32
|
```ruby
|
|
28
|
-
require 'aviator
|
|
33
|
+
require 'aviator'
|
|
29
34
|
|
|
30
35
|
# Create a new session. See 'Configuration' below for the config file format.
|
|
31
36
|
session = Aviator::Session.new(
|
|
@@ -52,7 +57,7 @@ session.authenticate do |credentials|
|
|
|
52
57
|
end
|
|
53
58
|
|
|
54
59
|
# Serialize the session information for caching. The output is in plaintext JSON which
|
|
55
|
-
# contains sensitive information
|
|
60
|
+
# contains sensitive information. You are responsible for securing that.
|
|
56
61
|
str = session.dump
|
|
57
62
|
|
|
58
63
|
# Create a new Session object from a session dump. This DOES NOT create a new token.
|
|
@@ -67,7 +72,7 @@ session = Aviator::Session.load(str)
|
|
|
67
72
|
# a brand new session object.
|
|
68
73
|
session.load(other_session_dump)
|
|
69
74
|
|
|
70
|
-
# Depending on how old the loaded session dump is,
|
|
75
|
+
# Depending on how old the loaded session dump is, its session data may already be expired.
|
|
71
76
|
# Check if it's still current by calling Session#validate and reauthenticate as needed.
|
|
72
77
|
#
|
|
73
78
|
# IMPORTANT: The validator must be defined in the config file and it must refer to the
|
|
@@ -104,7 +109,7 @@ response = keystone.request(:list_tenants, endpoint_type: 'admin')
|
|
|
104
109
|
|
|
105
110
|
## Configuration
|
|
106
111
|
|
|
107
|
-
The configuration file is a simple YAML file
|
|
112
|
+
The configuration file is a simple YAML file that can have one or more environment definitions.
|
|
108
113
|
|
|
109
114
|
```
|
|
110
115
|
production:
|
|
@@ -176,6 +181,28 @@ Describe Keystone's create_tenant request
|
|
|
176
181
|
```bash
|
|
177
182
|
$ aviator describe openstack identity v2 admin create_tenant
|
|
178
183
|
```
|
|
184
|
+
|
|
185
|
+
The last command above will display:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
Request: create_tenant
|
|
189
|
+
|
|
190
|
+
Parameters:
|
|
191
|
+
(required) description
|
|
192
|
+
(required) enabled
|
|
193
|
+
(required) name
|
|
194
|
+
|
|
195
|
+
Sample Code:
|
|
196
|
+
session.identity_service.request(:create_tenant, endpoint_type: 'admin') do |params|
|
|
197
|
+
params['name'] = value
|
|
198
|
+
params['description'] = value
|
|
199
|
+
params['enabled'] = value
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
Links:
|
|
203
|
+
documentation:
|
|
204
|
+
http://docs.openstack.org/api/openstack-identity-service/2.0/content/
|
|
205
|
+
```
|
|
179
206
|
|
|
180
207
|
## Contributing
|
|
181
208
|
|
data/README.md.orig
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Aviator
|
|
2
|
+
|
|
3
|
+
[](https://travis-ci.org/aviator/aviator)
|
|
4
|
+
[](https://coveralls.io/r/aviator/aviator?branch=master)
|
|
5
|
+
[](https://codeclimate.com/github/aviator/aviator)
|
|
6
|
+
[](http://badge.fury.io/rb/aviator)
|
|
7
|
+
[](https://gemnasium.com/aviator/aviator)
|
|
8
|
+
<<<<<<< HEAD
|
|
9
|
+
|
|
10
|
+
=======
|
|
11
|
+
>>>>>>> develop
|
|
12
|
+
|
|
13
|
+
A lightweight library for communicating with the OpenStack API.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Add this line to your application's Gemfile:
|
|
19
|
+
|
|
20
|
+
gem 'aviator'
|
|
21
|
+
|
|
22
|
+
Or if you want to live on the edge:
|
|
23
|
+
|
|
24
|
+
gem 'aviator', :git => 'git@github.com:aviator/aviator.git', :branch => 'develop'
|
|
25
|
+
|
|
26
|
+
And then execute:
|
|
27
|
+
|
|
28
|
+
$ bundle
|
|
29
|
+
|
|
30
|
+
Or install it yourself as:
|
|
31
|
+
|
|
32
|
+
$ gem install aviator
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
require 'aviator'
|
|
38
|
+
|
|
39
|
+
# Create a new session. See 'Configuration' below for the config file format.
|
|
40
|
+
session = Aviator::Session.new(
|
|
41
|
+
config_file: 'path/to/aviator.yml',
|
|
42
|
+
environment: :production,
|
|
43
|
+
log_file: 'path/to/aviator.log'
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Authenticate against the auth service specified in :config_file. If no
|
|
47
|
+
# credentials are available in the config file, this line will throw an error.
|
|
48
|
+
session.authenticate
|
|
49
|
+
|
|
50
|
+
# You can re-authenticate anytime. Note that this creates a new token in the
|
|
51
|
+
# underlying environment while the old token is discarded by the Session object.
|
|
52
|
+
# Be aware of this fact as it might unnecessarily generate too many tokens.
|
|
53
|
+
#
|
|
54
|
+
# Notice how you can override the credentials in the config file. Also note that
|
|
55
|
+
# the keys used below (:username, :password, :tenantName) match the name as
|
|
56
|
+
# indicated in the official OpenStack documentation.
|
|
57
|
+
session.authenticate do |credentials|
|
|
58
|
+
credentials[:username] = myusername
|
|
59
|
+
credentials[:password] = mypassword
|
|
60
|
+
credentials[:tenantName] = tenantName
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Serialize the session information for caching. The output is in plaintext JSON which
|
|
64
|
+
# contains sensitive information. You are responsible for securing that.
|
|
65
|
+
str = session.dump
|
|
66
|
+
|
|
67
|
+
# Create a new Session object from a session dump. This DOES NOT create a new token.
|
|
68
|
+
# If you employed any form of encryption on the string, make sure to decrypt it first!
|
|
69
|
+
session = Aviator::Session.load(str)
|
|
70
|
+
|
|
71
|
+
# In some instances, Session::load is inefficient because it creates a new session object
|
|
72
|
+
# each time. In a web app environment, for instance, having to destroy and recreate the
|
|
73
|
+
# session object can take its toll on performance. In such a scenario, use Session#load
|
|
74
|
+
# (instance method, as opposed to class method). This will 'infect' an already existing
|
|
75
|
+
# session object with the supplied session dump and return itself instead of creating
|
|
76
|
+
# a brand new session object.
|
|
77
|
+
session.load(other_session_dump)
|
|
78
|
+
|
|
79
|
+
# Depending on how old the loaded session dump is, its session data may already be expired.
|
|
80
|
+
# Check if it's still current by calling Session#validate and reauthenticate as needed.
|
|
81
|
+
#
|
|
82
|
+
# IMPORTANT: The validator must be defined in the config file and it must refer to the
|
|
83
|
+
# name of a request that is known to Aviator. See 'Configuration' below for examples
|
|
84
|
+
session.authenticate unless session.validate
|
|
85
|
+
|
|
86
|
+
# If you want the newly created session to log its output, make sure to indicate it on load
|
|
87
|
+
session = Aviator::Session.load(str, log_file: 'path/to/aviator.log')
|
|
88
|
+
|
|
89
|
+
# Get a handle to the Identity Service.
|
|
90
|
+
keystone = session.identity_service
|
|
91
|
+
|
|
92
|
+
# Create a new tenant
|
|
93
|
+
response = keystone.request(:create_tenant) do |params|
|
|
94
|
+
params[:name] = 'Project'
|
|
95
|
+
params[:description] = 'My Project'
|
|
96
|
+
params[:enabled] = true
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Aviator uses parameter names as defined in the official OpenStack API doc. You can
|
|
100
|
+
# also access the params via dot notation (e.g. params.description) or by using a string
|
|
101
|
+
# for a hash key (e.g. params['description']). However, keep in mind that OpenStack
|
|
102
|
+
# parameters that have dashes and other characters that are not valid for method names
|
|
103
|
+
# and symbols can only be expressed as strings. E.g. params['changes-since']
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Be explicit about the endpoint type. Useful in those rare instances when
|
|
107
|
+
# the same request name means differently depending on the endpoint type.
|
|
108
|
+
# For example, in OpenStack, :list_tenants will return only the tenants the
|
|
109
|
+
# user is a member of in the public endpoint whereas the admin endpoint will
|
|
110
|
+
# return all tenants in the system.
|
|
111
|
+
response = keystone.request(:list_tenants, endpoint_type: 'admin')
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Configuration
|
|
115
|
+
|
|
116
|
+
The configuration file is a simple YAML file that can have one or more environment definitions.
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
production:
|
|
120
|
+
provider: openstack
|
|
121
|
+
auth_service:
|
|
122
|
+
name: identity
|
|
123
|
+
host_uri: http://my.openstackenv.org:5000
|
|
124
|
+
request: create_token
|
|
125
|
+
validator: list_tenants # Request to make for validating the session
|
|
126
|
+
api_version: v2 # Optional if version is indicated in host_uri
|
|
127
|
+
auth_credentials:
|
|
128
|
+
username: admin
|
|
129
|
+
password: mypassword
|
|
130
|
+
tenantName: myproject
|
|
131
|
+
|
|
132
|
+
development_1:
|
|
133
|
+
provider: openstack
|
|
134
|
+
auth_service:
|
|
135
|
+
name: identity
|
|
136
|
+
host_uri: http://devstack:5000/v2.0
|
|
137
|
+
request: create_token
|
|
138
|
+
validator: list_tenants
|
|
139
|
+
auth_credentials:
|
|
140
|
+
tokenId: 2c963f5512d067b24fdc312707c80c7a6d3d261b
|
|
141
|
+
tenantName: admin
|
|
142
|
+
|
|
143
|
+
development_2:
|
|
144
|
+
provider: openstack
|
|
145
|
+
auth_service:
|
|
146
|
+
name: identity
|
|
147
|
+
host_uri: http://devstack:5000/v2.0
|
|
148
|
+
request: create_token
|
|
149
|
+
validator: list_tenants
|
|
150
|
+
auth_credentials:
|
|
151
|
+
username: admin
|
|
152
|
+
password: mypassword
|
|
153
|
+
tenantName: myproject
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
A note on the validator: it can be any request as long as
|
|
157
|
+
|
|
158
|
+
1. It is defined in Aviator
|
|
159
|
+
1. Does not require any parameters
|
|
160
|
+
1. It returns an HTTP status 200 or 203 to indicate auth info validity.
|
|
161
|
+
1. It returns any other HTTP status to indicate that the auth info is invalid.
|
|
162
|
+
|
|
163
|
+
## CLI tools
|
|
164
|
+
|
|
165
|
+
List available providers. Includes only OpenStack for now.
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
$ aviator describe
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
List available services for OpenStack.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
$ aviator describe openstack
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
List available requests for Keystone
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
$ aviator describe openstack identity
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Describe Keystone's create_tenant request
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
$ aviator describe openstack identity v2 admin create_tenant
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
The last command above will display:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
Request: create_tenant
|
|
193
|
+
|
|
194
|
+
Parameters:
|
|
195
|
+
(required) description
|
|
196
|
+
(required) enabled
|
|
197
|
+
(required) name
|
|
198
|
+
|
|
199
|
+
Sample Code:
|
|
200
|
+
session.identity_service.request(:create_tenant, endpoint_type: 'admin') do |params|
|
|
201
|
+
params['name'] = value
|
|
202
|
+
params['description'] = value
|
|
203
|
+
params['enabled'] = value
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
Links:
|
|
207
|
+
documentation:
|
|
208
|
+
http://docs.openstack.org/api/openstack-identity-service/2.0/content/
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Contributing
|
|
212
|
+
|
|
213
|
+
1. Fork it
|
|
214
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
215
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
216
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
217
|
+
5. Create new Pull Request
|
data/aviator.gemspec
CHANGED
|
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.version = Aviator::VERSION
|
|
9
9
|
spec.authors = ["Mark Maglana"]
|
|
10
10
|
spec.email = ["mmaglana@gmail.com"]
|
|
11
|
-
spec.description = %q{
|
|
12
|
-
spec.summary = %q{
|
|
13
|
-
spec.homepage = "https://github.com/
|
|
11
|
+
spec.description = %q{ A lightweight Ruby library for the OpenStack API }
|
|
12
|
+
spec.summary = %q{ A lightweight Ruby library for the OpenStack API }
|
|
13
|
+
spec.homepage = "https://github.com/aviator/aviator"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Aviator
|
|
2
|
+
|
|
3
|
+
define_request :change_admin_password do
|
|
4
|
+
|
|
5
|
+
meta :provider, :openstack
|
|
6
|
+
meta :service, :compute
|
|
7
|
+
meta :api_version, :v2
|
|
8
|
+
meta :endpoint_type, :public
|
|
9
|
+
|
|
10
|
+
link 'documentation',
|
|
11
|
+
'http://docs.openstack.org/api/openstack-compute/2/content/Change_Password-d1e3234.html'
|
|
12
|
+
|
|
13
|
+
link 'additional spec',
|
|
14
|
+
'https://answers.launchpad.net/nova/+question/228462'
|
|
15
|
+
|
|
16
|
+
param :adminPass, required: true
|
|
17
|
+
param :id, required: true
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def body
|
|
21
|
+
p = {
|
|
22
|
+
changePassword: {
|
|
23
|
+
adminPass: params[:adminPass]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
p
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def headers
|
|
32
|
+
h = {}
|
|
33
|
+
|
|
34
|
+
unless self.anonymous?
|
|
35
|
+
h['X-Auth-Token'] = session_data[:access][:token][:id]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
h
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def http_method
|
|
43
|
+
:post
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def url
|
|
48
|
+
service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == service.to_s }
|
|
49
|
+
"#{ service_spec[:endpoints][0][:publicURL] }/servers/#{ params[:id] }/action"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module Aviator
|
|
2
|
+
|
|
3
|
+
define_request :create_image do
|
|
4
|
+
|
|
5
|
+
meta :provider, :openstack
|
|
6
|
+
meta :service, :compute
|
|
7
|
+
meta :api_version, :v2
|
|
8
|
+
meta :endpoint_type, :public
|
|
9
|
+
|
|
10
|
+
link 'documentation',
|
|
11
|
+
'http://docs.openstack.org/api/openstack-compute/2/content/Create_Image-d1e4655.html'
|
|
12
|
+
|
|
13
|
+
param :id, required: true
|
|
14
|
+
param :metadata, required: false
|
|
15
|
+
param :name, required: true
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def body
|
|
19
|
+
p = {
|
|
20
|
+
createImage: {
|
|
21
|
+
name: params[:name]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[:metadata].each do |key|
|
|
26
|
+
p[:createImage][key] = params[key] if params[key]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
p
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def headers
|
|
34
|
+
h = {}
|
|
35
|
+
|
|
36
|
+
unless self.anonymous?
|
|
37
|
+
h['X-Auth-Token'] = session_data[:access][:token][:id]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
h
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def http_method
|
|
45
|
+
:post
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def url
|
|
50
|
+
service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == service.to_s }
|
|
51
|
+
"#{ service_spec[:endpoints][0][:publicURL] }/servers/#{ params[:id] }/action"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
module Aviator
|
|
2
|
+
|
|
3
|
+
define_request :create_server do
|
|
4
|
+
|
|
5
|
+
meta :provider, :openstack
|
|
6
|
+
meta :service, :compute
|
|
7
|
+
meta :api_version, :v2
|
|
8
|
+
meta :endpoint_type, :public
|
|
9
|
+
|
|
10
|
+
link 'documentation',
|
|
11
|
+
'http://docs.openstack.org/api/openstack-compute/2/content/CreateServers.html'
|
|
12
|
+
|
|
13
|
+
param :accessIPv4, required: false
|
|
14
|
+
param :accessIPv6, required: false
|
|
15
|
+
param :adminPass, required: false
|
|
16
|
+
param :imageRef, required: true
|
|
17
|
+
param :flavorRef, required: true
|
|
18
|
+
param :metadata, required: false
|
|
19
|
+
param :name, required: true
|
|
20
|
+
param :networks, required: false
|
|
21
|
+
param :personality, required: false
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def body
|
|
25
|
+
p = {
|
|
26
|
+
server: {
|
|
27
|
+
flavorRef: params[:flavorRef],
|
|
28
|
+
imageRef: params[:imageRef],
|
|
29
|
+
name: params[:name]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[:adminPass, :metadata, :personality, :networks, :accessIPv4, :accessIPv6].each do |key|
|
|
34
|
+
p[:server][key] = params[key] if params[key]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
p
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def headers
|
|
42
|
+
h = {}
|
|
43
|
+
|
|
44
|
+
unless self.anonymous?
|
|
45
|
+
h['X-Auth-Token'] = session_data[:access][:token][:id]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
h
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def http_method
|
|
53
|
+
:post
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def url
|
|
58
|
+
service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == service.to_s }
|
|
59
|
+
"#{ service_spec[:endpoints][0][:publicURL] }/servers"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Aviator
|
|
2
|
+
|
|
3
|
+
define_request :delete_server do
|
|
4
|
+
|
|
5
|
+
meta :provider, :openstack
|
|
6
|
+
meta :service, :compute
|
|
7
|
+
meta :api_version, :v2
|
|
8
|
+
meta :endpoint_type, :public
|
|
9
|
+
|
|
10
|
+
link 'documentation',
|
|
11
|
+
'http://docs.openstack.org/api/openstack-compute/2/content/Delete_Server-d1e2883.html'
|
|
12
|
+
|
|
13
|
+
param :id, required: true
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def headers
|
|
17
|
+
h = {}
|
|
18
|
+
|
|
19
|
+
unless self.anonymous?
|
|
20
|
+
h['X-Auth-Token'] = session_data[:access][:token][:id]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
h
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def http_method
|
|
28
|
+
:delete
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def url
|
|
33
|
+
service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == service.to_s }
|
|
34
|
+
"#{ service_spec[:endpoints][0][:publicURL] }/servers/#{ params[:id] }"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Aviator
|
|
2
|
+
|
|
3
|
+
define_request :get_server do
|
|
4
|
+
|
|
5
|
+
meta :provider, :openstack
|
|
6
|
+
meta :service, :compute
|
|
7
|
+
meta :api_version, :v2
|
|
8
|
+
meta :endpoint_type, :public
|
|
9
|
+
|
|
10
|
+
link 'documentation',
|
|
11
|
+
'http://docs.openstack.org/api/openstack-compute/2/content/Get_Server_Details-d1e2623.html'
|
|
12
|
+
|
|
13
|
+
param :id, required: true
|
|
14
|
+
|
|
15
|
+
def headers
|
|
16
|
+
h = {}
|
|
17
|
+
|
|
18
|
+
unless self.anonymous?
|
|
19
|
+
h['X-Auth-Token'] = session_data[:access][:token][:id]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
h
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def http_method
|
|
27
|
+
:get
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def url
|
|
32
|
+
service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == service.to_s }
|
|
33
|
+
|
|
34
|
+
"#{ service_spec[:endpoints][0][:publicURL] }/servers/#{ params[:id] }"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Aviator
|
|
2
|
+
|
|
3
|
+
define_request :list_addresses do
|
|
4
|
+
|
|
5
|
+
meta :provider, :openstack
|
|
6
|
+
meta :service, :compute
|
|
7
|
+
meta :api_version, :v2
|
|
8
|
+
meta :endpoint_type, :public
|
|
9
|
+
|
|
10
|
+
link 'documentation',
|
|
11
|
+
'http://docs.openstack.org/api/openstack-compute/2/content/List_Addresses-d1e3014.html'
|
|
12
|
+
|
|
13
|
+
link 'documentation',
|
|
14
|
+
'http://docs.openstack.org/api/openstack-compute/2/content/List_Addresses_by_Network-d1e3118.html'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
param :id, required: true
|
|
18
|
+
param :networkID, required: false
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def headers
|
|
22
|
+
h = {}
|
|
23
|
+
|
|
24
|
+
unless self.anonymous?
|
|
25
|
+
h['X-Auth-Token'] = session_data[:access][:token][:id]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
h
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def http_method
|
|
33
|
+
:get
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def url
|
|
38
|
+
service_spec = session_data[:access][:serviceCatalog].find{|s| s[:type] == service.to_s }
|
|
39
|
+
|
|
40
|
+
url = "#{ service_spec[:endpoints][0][:publicURL] }/servers/#{ params[:id] }/ips"
|
|
41
|
+
url += "/#{ params[:networkID] }" if params[:networkID]
|
|
42
|
+
|
|
43
|
+
url
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|