yao 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 702078252e6e2c7094cc33a053772a8a41e97cf4a6687b95c8bbebdd5f6235f8
4
- data.tar.gz: c3ab7f4a0373020a23c6dffaae57509a3488f1c0de116682ca69365f30ba9be9
3
+ metadata.gz: c6afbe0b92d49d396c515350a1600b3459d4a294094ad791c5a6f0c8036ea01e
4
+ data.tar.gz: c8f252ae02d42ac1146e2668e65951e68a77a47de35c67d963d706ba6dd36ffb
5
5
  SHA512:
6
- metadata.gz: 8104f1077c1f3f0483a1ba79c89c94dbb766a09ca364c8a71dc83524b8a9300a1e85d17f9bd18415ed4da16abb84f5d4f0074a3ac4762d114f16d846b8659199
7
- data.tar.gz: b48cde484c266bff8d29218ecb53692d3f3ee3a014c363463f8fb4102e05c6cee504ecd8c13b7081100ca8367a7f31437dd90ff36423f2d2ad500154539e90bb
6
+ metadata.gz: 4164f302792447f21f755c86709fc17809cd722b1f37e76fd66cf849b0d49edeb1e24c5cf0369947e683398534ad952d43dd3bf0ded85becfba3fced434f1de9
7
+ data.tar.gz: 5302ff69a25fd1756c5ac92a1fa308a4a3c16eb3935167fe9cd0078520154d01a8eb33e240804601ea0a718cc70f593d07f225cf2c574d9ab35673a400a59127
data/lib/yao/resources.rb CHANGED
@@ -15,6 +15,7 @@ module Yao
15
15
  autoload :Keypair, "yao/resources/keypair"
16
16
  autoload :FloatingIP, "yao/resources/floating_ip"
17
17
  autoload :Network, "yao/resources/network"
18
+ autoload :NetworkingAgents, "yao/resources/networking_agents"
18
19
  autoload :Subnet, "yao/resources/subnet"
19
20
  autoload :Port, "yao/resources/port"
20
21
  autoload :Router, "yao/resources/router"
@@ -0,0 +1,13 @@
1
+ module Yao::Resources
2
+ class Amphora < Base
3
+ friendly_attributes :loadbalancer_id, :compute_id, :lb_network_ip, :vrrp_ip, :ha_ip, :vrrp_port_id,
4
+ :ha_port_id, :role, :status, :vrrp_interface, :vrrp_id,
5
+ :vrrp_priority, :cached_zone, :image_id, :compute_flavor
6
+
7
+ self.service = "load-balancer"
8
+ self.api_version = "v2"
9
+ self.resource_name = "amphorae"
10
+ self.resources_name = "amphorae"
11
+ self.resources_path = "octavia/amphorae"
12
+ end
13
+ end
@@ -19,7 +19,8 @@ module Yao::Resources
19
19
  end
20
20
  end
21
21
 
22
- self.service = "compute"
22
+ self.service = "image"
23
+ self.api_version = "v2"
23
24
  self.resource_name = "image"
24
25
  self.resources_name = "images"
25
26
 
@@ -1,7 +1,7 @@
1
1
  module Yao::Resources
2
2
  class LoadBalancer < Base
3
3
  friendly_attributes :provider, :description, :admin_state_up, :provisioning_status,
4
- :vip_address, :operationg_status, :name
4
+ :vip_address, :operating_status, :name
5
5
 
6
6
  map_attribute_to_resources listeners: LoadBalancerListener
7
7
  map_attribute_to_resources pools: LoadBalancerListener
@@ -12,5 +12,9 @@ module Yao::Resources
12
12
  self.service = "network"
13
13
  self.resource_name = "network"
14
14
  self.resources_name = "networks"
15
+
16
+ def ports
17
+ @ports ||= Yao::Port.list(network_id: id)
18
+ end
15
19
  end
16
20
  end
@@ -0,0 +1,30 @@
1
+ module Yao::Resources
2
+ class NetworkingAgents < Base
3
+
4
+ friendly_attributes :admin_state_up, :agent_type, :alive,
5
+ :availability_zone, :binary, :configurations,
6
+ :description, :heartbeat_timestamp, :host,
7
+ :resources_synced, :topic
8
+
9
+ self.service = "network"
10
+ self.resource_name = "agents"
11
+ self.resources_name = "agents"
12
+
13
+ # @return [Date]
14
+ def created_at
15
+ Time.parse(self["created_at"])
16
+ end
17
+
18
+ # @return [Date]
19
+ def started_at
20
+ Time.parse(self["started_at"])
21
+ end
22
+
23
+ # @return [Date]
24
+ def heartbeat_timestamp
25
+ Time.parse(self["heartbeat_timestamp"])
26
+ end
27
+
28
+ alias :state :admin_state_up
29
+ end
30
+ end
data/lib/yao/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yao
2
- VERSION = "0.10.1"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- module RestfullAccessibleStub
1
+ module RestfullyAccessibleStub
2
2
  def stub_get_request(url, resource_name)
3
3
  stub_request(:get, url)
4
4
  .with(
@@ -16,7 +16,7 @@ module RestfullAccessibleStub
16
16
  ).to_return(
17
17
  status: 200,
18
18
  headers: {'Content-Type' => 'application/json'},
19
- body: body.to_json
19
+ body: body.class == String ? body : body.to_json
20
20
  )
21
21
  end
22
22
 
@@ -0,0 +1,45 @@
1
+ class TestLoadBalancer < TestYaoResource
2
+ def test_loadbalancer
3
+ # https://docs.openstack.org/api-ref/load-balancer/v2/?expanded=list-amphora-detail,show-amphora-statistics-detail#list-amphora
4
+ params = {
5
+ "id": "6bd55cd3-802e-447e-a518-1e74e23bb106",
6
+ "load_balancer_id": "09eedfc6-2c55-41a8-a75c-2cd4e95212ca",
7
+ "compute_id": "f0f79f90-733d-417a-8d70-cc6be62cd54d",
8
+ "lb_network_ip": "192.168.1.2",
9
+ "vrrp_ip": "192.168.1.5",
10
+ "ha_ip": "192.168.1.10",
11
+ "vrrp_port_id": "ab2a8add-76a9-44bb-89f8-88430193cc83",
12
+ "ha_port_id": "19561fd3-5da5-46cc-bdd3-99bbdf7246e6",
13
+ "cert_expiration": "2019-09-19 00:34:51",
14
+ "cert_busy": 0,
15
+ "role": "MASTER",
16
+ "status": "ALLOCATED",
17
+ "vrrp_interface": "eth1",
18
+ "vrrp_id": 1,
19
+ "vrrp_priority": 100,
20
+ "cached_zone": "zone1",
21
+ "created_at": "2017-05-10T18:14:44",
22
+ "updated_at": "2017-05-10T23:08:12",
23
+ "image_id": "c1c2ad6f-1c1e-4744-8d1a-d0ef36289e74",
24
+ "compute_flavor": "5446a14a-abec-4455-bc0e-a34e5ff001a3"
25
+ }
26
+
27
+ amphora = Yao::Resources::Amphora.new(params)
28
+ assert_equal("6bd55cd3-802e-447e-a518-1e74e23bb106", amphora.id)
29
+ assert_equal("09eedfc6-2c55-41a8-a75c-2cd4e95212ca", amphora.load_balancer_id)
30
+ assert_equal("f0f79f90-733d-417a-8d70-cc6be62cd54d", amphora.compute_id)
31
+ assert_equal("192.168.1.2", amphora.lb_network_ip)
32
+ assert_equal("192.168.1.5", amphora.vrrp_ip)
33
+ assert_equal("192.168.1.10", amphora.ha_ip)
34
+ assert_equal("ab2a8add-76a9-44bb-89f8-88430193cc83", amphora.vrrp_port_id)
35
+ assert_equal("19561fd3-5da5-46cc-bdd3-99bbdf7246e6", amphora.ha_port_id)
36
+ assert_equal("MASTER", amphora.role)
37
+ assert_equal("ALLOCATED", amphora.status)
38
+ assert_equal("eth1", amphora.vrrp_interface)
39
+ assert_equal(1, amphora.vrrp_id)
40
+ assert_equal(100, amphora.vrrp_priority)
41
+ assert_equal("zone1", amphora.cached_zone)
42
+ assert_equal("c1c2ad6f-1c1e-4744-8d1a-d0ef36289e74", amphora.image_id)
43
+ assert_equal("5446a14a-abec-4455-bc0e-a34e5ff001a3", amphora.compute_flavor)
44
+ end
45
+ end
@@ -6,7 +6,7 @@ class TestLoadBalancer < TestYaoResource
6
6
  "admin_state_up" => true,
7
7
  "provisioning_status" => "ACTIVE",
8
8
  "vip_address" => "198.51.100.1",
9
- "operationg_status" => "ONLINE",
9
+ "operating_status" => "ONLINE",
10
10
  "name" => "greate loadbalancer",
11
11
  "created_at" => "2017-02-28T00:41:44",
12
12
  "updated_at" => "2017-02-28T00:43:30",
@@ -18,7 +18,7 @@ class TestLoadBalancer < TestYaoResource
18
18
  assert_equal(true, lb.admin_state_up)
19
19
  assert_equal("ACTIVE", lb.provisioning_status)
20
20
  assert_equal("198.51.100.1", lb.vip_address)
21
- assert_equal("ONLINE", lb.operationg_status)
21
+ assert_equal("ONLINE", lb.operating_status)
22
22
  assert_equal("greate loadbalancer", lb.name)
23
23
  assert_equal(Time.parse("2017-02-28T00:41:44"), lb.created)
24
24
  assert_equal(Time.parse("2017-02-28T00:43:30"), lb.updated)
@@ -1,4 +1,5 @@
1
1
  class TestNetwork < TestYaoResource
2
+ include RestfullyAccessibleStub
2
3
 
3
4
  def test_network
4
5
 
@@ -62,4 +63,71 @@ class TestNetwork < TestYaoResource
62
63
 
63
64
  assert_requested(stub)
64
65
  end
66
+
67
+ def test_ports
68
+ network_id = "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b"
69
+ # https://docs.openstack.org/api-ref/network/v2/?expanded=list-floating-ips-detail,list-ports-detail#list-ports
70
+ body = <<-JSON
71
+ {
72
+ "ports": [
73
+ {
74
+ "admin_state_up": true,
75
+ "allowed_address_pairs": [],
76
+ "binding:host_id": "devstack",
77
+ "binding:profile": {},
78
+ "binding:vif_details": {
79
+ "ovs_hybrid_plug": true,
80
+ "port_filter": true
81
+ },
82
+ "binding:vif_type": "ovs",
83
+ "binding:vnic_type": "normal",
84
+ "created_at": "2016-03-08T20:19:41",
85
+ "data_plane_status": null,
86
+ "description": "",
87
+ "device_id": "9ae135f4-b6e0-4dad-9e91-3c223e385824",
88
+ "device_owner": "network:router_gateway",
89
+ "dns_assignment": {
90
+ "hostname": "myport",
91
+ "ip_address": "172.24.4.2",
92
+ "fqdn": "myport.my-domain.org"
93
+ },
94
+ "dns_domain": "my-domain.org.",
95
+ "dns_name": "myport",
96
+ "extra_dhcp_opts": [],
97
+ "fixed_ips": [
98
+ {
99
+ "ip_address": "172.24.4.2",
100
+ "subnet_id": "008ba151-0b8c-4a67-98b5-0d2b87666062"
101
+ }
102
+ ],
103
+ "id": "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b",
104
+ "ip_allocation": "immediate",
105
+ "mac_address": "fa:16:3e:58:42:ed",
106
+ "name": "",
107
+ "network_id": "70c1db1f-b701-45bd-96e0-a313ee3430b3",
108
+ "port_security_enabled": true,
109
+ "project_id": "",
110
+ "revision_number": 1,
111
+ "security_groups": [],
112
+ "status": "ACTIVE",
113
+ "tenant_id": "",
114
+ "updated_at": "2016-03-08T20:19:41",
115
+ "qos_policy_id": "29d5e02e-d5ab-4929-bee4-4a9fc12e22ae",
116
+ "resource_request": {
117
+ "required": ["CUSTOM_PHYSNET_PUBLIC", "CUSTOM_VNIC_TYPE_NORMAL"],
118
+ "resources": {"NET_BW_EGR_KILOBIT_PER_SEC": 1000}
119
+ },
120
+ "tags": ["tag1,tag2"],
121
+ "tenant_id": "",
122
+ "uplink_status_propagation": false
123
+ }
124
+ ]
125
+ }
126
+ JSON
127
+ stub = stub_get_request_with_json_response("https://example.com:12345/ports?network_id=#{network_id}", body)
128
+ network = Yao::Network.new({"id" => network_id})
129
+ ports = network.ports
130
+ assert_equal(ports.first.id, "d80b1a3b-4fc1-49f3-952e-1e2ab7081d8b")
131
+ assert_requested(stub)
132
+ end
65
133
  end
@@ -0,0 +1,84 @@
1
+ class TestNetworkingAgents < TestYaoResource
2
+
3
+ def test_networking_agents
4
+
5
+ # https://docs.openstack.org/api-ref/network/v2/?expanded=list-all-agents-detail#list-all-agents
6
+ params = {
7
+ "binary" => "neutron-openvswitch-agent",
8
+ "description" => "aaa bbb ccc",
9
+ "availability_zone" => "zone",
10
+ "heartbeat_timestamp" => "2017-09-12 19:40:08",
11
+ "admin_state_up" => true,
12
+ "alive" => true,
13
+ "id" => "04c62b91-b799-48b7-9cd5-2982db6df9c6",
14
+ "topic" => "N/A",
15
+ "host" => "agenthost1",
16
+ "agent_type" => "Open vSwitch agent",
17
+ "started_at" => "2017-09-12 19:35:38",
18
+ "created_at" => "2017-09-12 19:35:38",
19
+ "resources_synced" => true,
20
+ "configurations" => {
21
+ "ovs_hybrid_plug" => true,
22
+ "in_distributed_mode" => false,
23
+ "datapath_type" => "system",
24
+ "vhostuser_socket_dir" => "/var/run/openvswitch",
25
+ "tunneling_ip" => "172.16.78.191",
26
+ "arp_responder_enabled" => false,
27
+ "devices" => 0,
28
+ "ovs_capabilities" => {
29
+ "datapath_types" => [
30
+ "netdev",
31
+ "system"
32
+ ],
33
+ "iface_types" => [
34
+ "geneve",
35
+ "gre",
36
+ "internal",
37
+ "ipsec_gre",
38
+ "lisp",
39
+ "patch",
40
+ "stt",
41
+ "system",
42
+ "tap",
43
+ "vxlan"
44
+ ]
45
+ },
46
+ "log_agent_heartbeats" => false,
47
+ "l2_population" => false,
48
+ "tunnel_types" => [
49
+ "vxlan"
50
+ ],
51
+ "extensions" => [
52
+ ],
53
+ "enable_distributed_routing" => false,
54
+ "bridge_mappings" => {
55
+ "public" => "br-ex"
56
+ }
57
+ }
58
+ }
59
+
60
+ agent = Yao::NetworkingAgents.new(params)
61
+
62
+ # friendly_attributes
63
+ assert_equal("04c62b91-b799-48b7-9cd5-2982db6df9c6", agent.id)
64
+ assert_equal(true, agent.admin_state_up)
65
+ assert_equal(true, agent.state) # alias
66
+ assert_equal("Open vSwitch agent", agent.agent_type)
67
+ assert_equal(true, agent.alive)
68
+ assert_equal("zone", agent.availability_zone)
69
+ assert_equal("neutron-openvswitch-agent", agent.binary)
70
+
71
+ # configurations is a complex Hash, so limit testing only one key.
72
+ assert_instance_of(Hash, agent.configurations)
73
+ assert_equal("172.16.78.191", agent.configurations['tunneling_ip'])
74
+
75
+ assert_equal("aaa bbb ccc", agent.description)
76
+ assert_equal("agenthost1", agent.host)
77
+ assert_equal(true, agent.resources_synced)
78
+ assert_equal("N/A", agent.topic)
79
+
80
+ assert_equal(Time.parse("2017-09-12 19:40:08"), agent.heartbeat_timestamp)
81
+ assert_equal(Time.parse("2017-09-12 19:35:38"), agent.created_at)
82
+ assert_equal(Time.parse("2017-09-12 19:35:38"), agent.started_at)
83
+ end
84
+ end
@@ -1,5 +1,5 @@
1
1
  class TestRestfullyAccesible < Test::Unit::TestCase
2
- include RestfullAccessibleStub
2
+ include RestfullyAccessibleStub
3
3
  class Test
4
4
  class << self
5
5
  attr_accessor :client
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yao
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio, KONDO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2019-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -84,6 +84,7 @@ files:
84
84
  - lib/yao/resources.rb
85
85
  - lib/yao/resources/action.rb
86
86
  - lib/yao/resources/aggregates.rb
87
+ - lib/yao/resources/amphora.rb
87
88
  - lib/yao/resources/base.rb
88
89
  - lib/yao/resources/compute_services.rb
89
90
  - lib/yao/resources/flavor.rb
@@ -101,6 +102,7 @@ files:
101
102
  - lib/yao/resources/meter.rb
102
103
  - lib/yao/resources/network.rb
103
104
  - lib/yao/resources/network_associationable.rb
105
+ - lib/yao/resources/networking_agents.rb
104
106
  - lib/yao/resources/old_sample.rb
105
107
  - lib/yao/resources/port.rb
106
108
  - lib/yao/resources/port_associationable.rb
@@ -132,6 +134,7 @@ files:
132
134
  - test/support/restfully_accesible_stub.rb
133
135
  - test/support/test_yao_resource.rb
134
136
  - test/yao/resources/test_aggregates.rb
137
+ - test/yao/resources/test_amphora.rb
135
138
  - test/yao/resources/test_base.rb
136
139
  - test/yao/resources/test_compute_services.rb
137
140
  - test/yao/resources/test_flavor.rb
@@ -147,6 +150,7 @@ files:
147
150
  - test/yao/resources/test_loadbalancer_pool_member.rb
148
151
  - test/yao/resources/test_meter.rb
149
152
  - test/yao/resources/test_network.rb
153
+ - test/yao/resources/test_networking_agents.rb
150
154
  - test/yao/resources/test_old_sample.rb
151
155
  - test/yao/resources/test_port.rb
152
156
  - test/yao/resources/test_project.rb
@@ -206,6 +210,7 @@ test_files:
206
210
  - test/support/restfully_accesible_stub.rb
207
211
  - test/support/test_yao_resource.rb
208
212
  - test/yao/resources/test_aggregates.rb
213
+ - test/yao/resources/test_amphora.rb
209
214
  - test/yao/resources/test_base.rb
210
215
  - test/yao/resources/test_compute_services.rb
211
216
  - test/yao/resources/test_flavor.rb
@@ -221,6 +226,7 @@ test_files:
221
226
  - test/yao/resources/test_loadbalancer_pool_member.rb
222
227
  - test/yao/resources/test_meter.rb
223
228
  - test/yao/resources/test_network.rb
229
+ - test/yao/resources/test_networking_agents.rb
224
230
  - test/yao/resources/test_old_sample.rb
225
231
  - test/yao/resources/test_port.rb
226
232
  - test/yao/resources/test_project.rb