yao 0.7.0 → 0.8.0
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 +4 -4
- data/.github/workflows/macos.yml +15 -0
- data/.github/workflows/ubuntu-rvm.yml +29 -0
- data/.github/workflows/ubuntu.yml +22 -0
- data/Gemfile +10 -2
- data/README.md +3 -3
- data/lib/yao/resources.rb +5 -0
- data/lib/yao/resources/action.rb +1 -1
- data/lib/yao/resources/compute_services.rb +46 -0
- data/lib/yao/resources/flavor.rb +1 -10
- data/lib/yao/resources/floating_ip.rb +6 -6
- data/lib/yao/resources/hypervisor.rb +6 -12
- data/lib/yao/resources/keypair.rb +22 -3
- data/lib/yao/resources/meter.rb +6 -7
- data/lib/yao/resources/network.rb +3 -1
- data/lib/yao/resources/network_associationable.rb +14 -0
- data/lib/yao/resources/old_sample.rb +5 -7
- data/lib/yao/resources/port.rb +6 -6
- data/lib/yao/resources/port_associationable.rb +14 -0
- data/lib/yao/resources/project.rb +16 -0
- data/lib/yao/resources/resource.rb +12 -7
- data/lib/yao/resources/restfully_accessible.rb +72 -35
- data/lib/yao/resources/role.rb +73 -18
- data/lib/yao/resources/router.rb +3 -1
- data/lib/yao/resources/sample.rb +1 -5
- data/lib/yao/resources/security_group.rb +3 -1
- data/lib/yao/resources/server.rb +4 -9
- data/lib/yao/resources/subnet.rb +5 -5
- data/lib/yao/resources/tenant.rb +1 -1
- data/lib/yao/resources/tenant_associationable.rb +17 -0
- data/lib/yao/resources/user.rb +15 -4
- data/lib/yao/resources/volume.rb +1 -10
- data/lib/yao/version.rb +1 -1
- data/test/config.rb +1 -0
- data/test/support/auth_stub.rb +1 -0
- data/test/support/test_yao_resource.rb +49 -0
- data/test/yao/resources/test_aggregates.rb +1 -4
- data/test/yao/resources/test_base.rb +1 -1
- data/test/yao/resources/test_compute_services.rb +118 -0
- data/test/yao/resources/test_flavor.rb +15 -9
- data/test/yao/resources/test_floating_ip.rb +24 -19
- data/test/yao/resources/test_host.rb +1 -1
- data/test/yao/resources/test_hypervisor.rb +17 -10
- data/test/yao/resources/test_image.rb +1 -1
- data/test/yao/resources/test_keypair.rb +3 -6
- data/test/yao/resources/test_loadbalancer.rb +1 -3
- data/test/yao/resources/test_loadbalancer_healthmonitor.rb +1 -3
- data/test/yao/resources/test_loadbalancer_listener.rb +1 -5
- data/test/yao/resources/test_loadbalancer_pool.rb +1 -3
- data/test/yao/resources/test_loadbalancer_pool_member.rb +1 -3
- data/test/yao/resources/test_meter.rb +13 -14
- data/test/yao/resources/test_network.rb +28 -1
- data/test/yao/resources/test_old_sample.rb +86 -0
- data/test/yao/resources/test_port.rb +29 -7
- data/test/yao/resources/test_project.rb +32 -0
- data/test/yao/resources/test_resource.rb +56 -0
- data/test/yao/resources/test_role.rb +255 -1
- data/test/yao/resources/test_role_assignment.rb +4 -6
- data/test/yao/resources/test_router.rb +26 -6
- data/test/yao/resources/test_sample.rb +61 -0
- data/test/yao/resources/test_security_group.rb +23 -1
- data/test/yao/resources/test_security_group_rule.rb +1 -1
- data/test/yao/resources/test_server.rb +34 -8
- data/test/yao/resources/test_subnet.rb +25 -6
- data/test/yao/resources/test_user.rb +73 -1
- data/test/yao/resources/test_volume.rb +31 -1
- data/test/yao/resources/test_volume_type.rb +1 -1
- data/test/yao/test_config.rb +21 -8
- data/test/yao/test_read_only.rb +3 -3
- data/yao.gemspec +0 -8
- metadata +22 -101
- data/.travis.yml +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97e6146fda8345c89f804cb55928c3011e8603999355e27e5416d13eb336e569
|
4
|
+
data.tar.gz: b47ac5d66e43b08e2482f157c13ff9fa45a335b8ac6992737d6554d08a2c4ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4066fa6911823b55df1b9e61d6796b3efa7719b7dc6afb4858b1daf28153bf16754aed5f4646fdbbbf8a80b540235f2cbf0d763c98e8ec428d1d8de7cb78077
|
7
|
+
data.tar.gz: 545be1baceecc9ad556b207f19e01dc2658a37321038225707643005f802cbbbfea57f7fba5ba581ad4df1d1a7f2c331d4168ff7ee13c181f2ffb2f7d43056ff
|
@@ -0,0 +1,15 @@
|
|
1
|
+
name: macos
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: macos-latest
|
8
|
+
steps:
|
9
|
+
- uses: actions/checkout@master
|
10
|
+
- name: Install dependencies
|
11
|
+
run: |
|
12
|
+
gem install bundler --no-document
|
13
|
+
bundle install
|
14
|
+
- name: Run test
|
15
|
+
run: bundle exec rake test
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: ubuntu-rvm
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [ 'ruby-head' ]
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@master
|
13
|
+
- name: Set up RVM
|
14
|
+
run: |
|
15
|
+
curl -sSL https://get.rvm.io | bash
|
16
|
+
- name: Set up Ruby
|
17
|
+
run: |
|
18
|
+
source $HOME/.rvm/scripts/rvm
|
19
|
+
rvm install ${{ matrix.ruby }} --binary
|
20
|
+
rvm --default use ${{ matrix.ruby }}
|
21
|
+
- name: Install dependencies
|
22
|
+
run: |
|
23
|
+
source $HOME/.rvm/scripts/rvm
|
24
|
+
gem install bundler --no-document
|
25
|
+
bundle install
|
26
|
+
- name: Run test
|
27
|
+
run: |
|
28
|
+
source $HOME/.rvm/scripts/rvm
|
29
|
+
bundle exec rake test
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: ubuntu
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby: [ '2.6.x', '2.5.x', '2.4.x' ]
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@master
|
13
|
+
- name: Set up Ruby
|
14
|
+
uses: actions/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
version: ${{ matrix.ruby }}
|
17
|
+
- name: Install dependencies
|
18
|
+
run: |
|
19
|
+
gem install bundler --no-document
|
20
|
+
bundle install
|
21
|
+
- name: Run test
|
22
|
+
run: bundle exec rake test
|
data/Gemfile
CHANGED
@@ -3,5 +3,13 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in yao.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
|
7
|
-
gem 'rubocop'
|
6
|
+
group :development do
|
7
|
+
gem 'rubocop'
|
8
|
+
gem "bundler", ">= 1.10"
|
9
|
+
gem "rake", "~> 10.0"
|
10
|
+
gem "test-unit", ">= 3"
|
11
|
+
gem "test-unit-rr"
|
12
|
+
gem "power_assert"
|
13
|
+
gem "pry"
|
14
|
+
gem "webmock"
|
15
|
+
end
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|

|
4
4
|
|
5
|
-
YAO is a Yet Another OpenStack API Wrapper that rocks!!
|
5
|
+
YAO is a Yet Another OpenStack API Wrapper that rocks!!
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -43,7 +43,7 @@ Yao.configure do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
Yao::Network.list # list up networks...
|
46
|
-
Yao::Server.
|
46
|
+
Yao::Server.list # list up instances...
|
47
47
|
```
|
48
48
|
|
49
49
|
If you want to override some of endpoints by service, you can do:
|
@@ -79,7 +79,7 @@ OpenStack.configure do
|
|
79
79
|
password "tonk0tsu-r@men"
|
80
80
|
end
|
81
81
|
|
82
|
-
OpenStack::Server.
|
82
|
+
OpenStack::Server.list # And let's go on
|
83
83
|
```
|
84
84
|
|
85
85
|
## Contributing
|
data/lib/yao/resources.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Yao
|
2
2
|
module Resources
|
3
3
|
require "yao/resources/base"
|
4
|
+
require "yao/resources/tenant_associationable"
|
5
|
+
require "yao/resources/port_associationable"
|
6
|
+
require "yao/resources/network_associationable"
|
4
7
|
|
5
8
|
autoload :Server, "yao/resources/server"
|
6
9
|
autoload :Flavor, "yao/resources/flavor"
|
@@ -27,6 +30,8 @@ module Yao
|
|
27
30
|
autoload :RoleAssignment, "yao/resources/role_assignment"
|
28
31
|
autoload :Volume, "yao/resources/volume"
|
29
32
|
autoload :VolumeType, "yao/resources/volume_type"
|
33
|
+
autoload :ComputeServices, "yao/resources/compute_services"
|
34
|
+
autoload :Project, "yao/resources/project"
|
30
35
|
|
31
36
|
autoload :Resource, "yao/resources/resource"
|
32
37
|
autoload :Meter, "yao/resources/meter"
|
data/lib/yao/resources/action.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
module Yao::Resources
|
2
|
+
class ComputeServices < Base
|
3
|
+
friendly_attributes :status, :binary, :host, :zone, :state, :disabled_reason, :forced_down
|
4
|
+
|
5
|
+
self.service = "compute"
|
6
|
+
self.resource_name = "service"
|
7
|
+
self.resources_name = "os-services"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def enable(host, binary)
|
11
|
+
params = {
|
12
|
+
"host" => host,
|
13
|
+
"binary" => binary,
|
14
|
+
}
|
15
|
+
put("enable", params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def disable(host, binary, reason = nil)
|
19
|
+
params = {
|
20
|
+
"host" => host,
|
21
|
+
"binary" => binary,
|
22
|
+
}
|
23
|
+
if reason
|
24
|
+
params["disabled_reason"] = reason
|
25
|
+
put("disable-log-reason", params)
|
26
|
+
else
|
27
|
+
put("disable", params)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @param path [String]
|
34
|
+
# @param params [Hash]
|
35
|
+
# @return [Yao::Resources::ComputeServices]
|
36
|
+
def put(path, params)
|
37
|
+
res = PUT(create_url(path), params) do |req|
|
38
|
+
req.body = params.to_json
|
39
|
+
req.headers['Content-Type'] = 'application/json'
|
40
|
+
end
|
41
|
+
resource_from_json(res.body)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/yao/resources/flavor.rb
CHANGED
@@ -17,15 +17,6 @@ module Yao::Resources
|
|
17
17
|
self.service = "compute"
|
18
18
|
self.resource_name = "flavor"
|
19
19
|
self.resources_name = "flavors"
|
20
|
-
|
21
|
-
class << self
|
22
|
-
def list_detail(query={})
|
23
|
-
return_resources(
|
24
|
-
resources_from_json(
|
25
|
-
GET([resources_path, "detail"].join("/"), query).body
|
26
|
-
)
|
27
|
-
)
|
28
|
-
end
|
29
|
-
end
|
20
|
+
self.resources_detail_available = true
|
30
21
|
end
|
31
22
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Yao::Resources
|
2
2
|
class FloatingIP < Base
|
3
|
+
|
4
|
+
include PortAssociationable
|
5
|
+
include TenantAssociationable
|
6
|
+
|
3
7
|
friendly_attributes :router_id, :description, :dns_domain, :dns_name,
|
4
|
-
:revision_number,
|
8
|
+
:revision_number,
|
5
9
|
:floating_network_id, :fixed_ip_address,
|
6
|
-
:floating_ip_address,
|
10
|
+
:floating_ip_address,
|
7
11
|
:status, :port_details, :tags, :port_forwardings
|
8
12
|
|
9
13
|
self.service = "network"
|
@@ -18,9 +22,5 @@ module Yao::Resources
|
|
18
22
|
@project ||= Yao::Tenant.get(project_id)
|
19
23
|
end
|
20
24
|
alias :tenant :project
|
21
|
-
|
22
|
-
def port
|
23
|
-
@port ||= Yao::Port.find(port_id)
|
24
|
-
end
|
25
25
|
end
|
26
26
|
end
|
@@ -22,26 +22,20 @@ module Yao::Resources
|
|
22
22
|
self.service = "compute"
|
23
23
|
self.resource_name = "os-hypervisor"
|
24
24
|
self.resources_name = "os-hypervisors"
|
25
|
+
self.resources_detail_available = true
|
25
26
|
|
26
27
|
class << self
|
27
|
-
|
28
|
-
return_resources(
|
29
|
-
resources_from_json(
|
30
|
-
GET([resources_path, "detail"].join("/"), query).body
|
31
|
-
)
|
32
|
-
)
|
33
|
-
end
|
34
|
-
|
28
|
+
# @return [Yao::Resources::Hypervisor::Statistics]
|
35
29
|
def statistics
|
36
30
|
json = GET([resources_path, "statistics"].join("/")).body
|
37
31
|
Yao::Resources::Hypervisor::Statistics.new(json["hypervisor_statistics"])
|
38
32
|
end
|
39
33
|
|
34
|
+
# @param id [String]
|
35
|
+
# @return [Yao::Resources::Hypervisor::Uptime]
|
40
36
|
def uptime(id)
|
41
|
-
|
42
|
-
|
43
|
-
)
|
44
|
-
Yao::Resources::Hypervisor::Uptime.new(res)
|
37
|
+
json = GET([resources_path, id, "uptime"].join("/")).body
|
38
|
+
Yao::Resources::Hypervisor::Uptime.new(json["hypervisor"])
|
45
39
|
end
|
46
40
|
end
|
47
41
|
|
@@ -6,10 +6,29 @@ module Yao::Resources
|
|
6
6
|
self.resource_name = "os-keypair"
|
7
7
|
self.resources_name = "os-keypairs"
|
8
8
|
|
9
|
+
# os-keypairs API returns very complicated JSON.
|
10
|
+
# For example.
|
11
|
+
# {
|
12
|
+
# "keypairs": [
|
13
|
+
# {
|
14
|
+
# "keypair": {
|
15
|
+
# "fingerprint": "...",
|
16
|
+
# }
|
17
|
+
# },
|
18
|
+
# {
|
19
|
+
# "keypair": {
|
20
|
+
# "fingerprint": "...",
|
21
|
+
# }
|
22
|
+
# },
|
23
|
+
# ]
|
24
|
+
#
|
25
|
+
# @param query [Hash]
|
26
|
+
# @return [Array<Yao::Resources::Keypairs>]
|
9
27
|
def self.list(query={})
|
10
|
-
|
11
|
-
|
12
|
-
|
28
|
+
res = GET(resources_name, query)
|
29
|
+
res.body['keypairs'].map { |attribute|
|
30
|
+
new(attribute['keypair'])
|
31
|
+
}
|
13
32
|
end
|
14
33
|
end
|
15
34
|
end
|
data/lib/yao/resources/meter.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module Yao::Resources
|
2
2
|
class Meter < Base
|
3
|
-
|
3
|
+
|
4
|
+
include TenantAssociationable
|
5
|
+
|
6
|
+
friendly_attributes :meter_id, :name, :user_id, :resource_id, :source, :type, :unit
|
4
7
|
|
5
8
|
def id
|
6
9
|
meter_id
|
@@ -10,10 +13,6 @@ module Yao::Resources
|
|
10
13
|
@resource ||= Yao::Resource.get(resource_id)
|
11
14
|
end
|
12
15
|
|
13
|
-
def tenant
|
14
|
-
@tenant ||= Yao::Tenant.get(project_id)
|
15
|
-
end
|
16
|
-
|
17
16
|
def user
|
18
17
|
@user ||= Yao::User.get(user_id)
|
19
18
|
end
|
@@ -25,11 +24,11 @@ module Yao::Resources
|
|
25
24
|
class << self
|
26
25
|
private
|
27
26
|
def resource_from_json(json)
|
28
|
-
json
|
27
|
+
new(json)
|
29
28
|
end
|
30
29
|
|
31
30
|
def resources_from_json(json)
|
32
|
-
json
|
31
|
+
new(json)
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Yao::Resources
|
2
2
|
class Network < Base
|
3
|
-
|
3
|
+
include TenantAssociationable
|
4
|
+
|
5
|
+
friendly_attributes :name, :status, :shared, :subnets, :admin_state_up
|
4
6
|
map_attribute_to_attribute "provider:physical_network" => :physical_network
|
5
7
|
map_attribute_to_attribute "provider:network_type" => :type
|
6
8
|
map_attribute_to_attribute "provider:segmentation_id" => :segmentation_id
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Yao::Resources
|
2
2
|
class OldSample < Base
|
3
|
+
include TenantAssociationable
|
4
|
+
|
3
5
|
friendly_attributes :counter_name, :counter_type, :counter_unit, :counter_volume,
|
4
|
-
:message_id, :
|
6
|
+
:message_id, :resource_id, :timestamp, :resource_metadata, :user_id,
|
5
7
|
:source
|
6
8
|
|
7
9
|
def recorded_at
|
@@ -10,17 +12,13 @@ module Yao::Resources
|
|
10
12
|
alias timestamp recorded_at
|
11
13
|
|
12
14
|
def id
|
13
|
-
|
15
|
+
message_id
|
14
16
|
end
|
15
17
|
|
16
18
|
def resource
|
17
19
|
@resource ||= Yao::Resource.get(resource_id)
|
18
20
|
end
|
19
21
|
|
20
|
-
def tenant
|
21
|
-
@tenant ||= Yao::Tenant.get(project_id)
|
22
|
-
end
|
23
|
-
|
24
22
|
def user
|
25
23
|
@user ||= Yao::User.get(user_id)
|
26
24
|
end
|
@@ -32,7 +30,7 @@ module Yao::Resources
|
|
32
30
|
def self.list(meter_name, query={})
|
33
31
|
cache_key = [meter_name, *query].join
|
34
32
|
cache[cache_key] = GET("#{self.api_version}/meters/#{meter_name}", query).body unless cache[cache_key]
|
35
|
-
|
33
|
+
new(cache[cache_key])
|
36
34
|
end
|
37
35
|
|
38
36
|
def self.cache
|
data/lib/yao/resources/port.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
module Yao::Resources
|
2
2
|
class Port < Base
|
3
|
+
|
4
|
+
include NetworkAssociationable
|
5
|
+
include TenantAssociationable
|
6
|
+
|
3
7
|
friendly_attributes :name, :mac_address, :status, :allowed_address_pairs,
|
4
8
|
:device_owner, :fixed_ips, :security_groups, :device_id,
|
5
|
-
:
|
9
|
+
:admin_state_up
|
6
10
|
map_attribute_to_attribute "binding:host_id" => :host_id
|
7
11
|
|
8
12
|
def primary_ip
|
@@ -10,11 +14,7 @@ module Yao::Resources
|
|
10
14
|
end
|
11
15
|
|
12
16
|
def primary_subnet
|
13
|
-
Yao::Subnet.find fixed_ips.first["subnet_id"]
|
14
|
-
end
|
15
|
-
|
16
|
-
def network
|
17
|
-
Yao::Network.find network_id
|
17
|
+
@subnet ||= Yao::Subnet.find fixed_ips.first["subnet_id"]
|
18
18
|
end
|
19
19
|
|
20
20
|
self.service = "network"
|