rancher-metadata 0.17.1 → 0.17.2

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
  SHA1:
3
- metadata.gz: 2c5907bb0d7228b6b278cd1fd3b70ed34dcc0811
4
- data.tar.gz: 284bcdacc796db2e940eda27a2b31c1826420572
3
+ metadata.gz: 77f98d39db3280e7c314cab070c53c2adccbe429
4
+ data.tar.gz: d092becc850f73a3408f24a22f364c5afccff7b4
5
5
  SHA512:
6
- metadata.gz: 24c0a5d8cc6209297608271608ed772eeaabc34aa3729afd9a2763273ac20973f6d78ff2235c730744afd845105f24b71b08b790d58a326a42a1ac3fb3da2043
7
- data.tar.gz: 1e7ffc14ffac4d05de9abcc755a382c1447cb4b39ad09ec06ebc1ceecfbf4b06161f63d94af276ee6de4b7410d6b514d96df7b6930f8084f57859a475fdd31e7
6
+ metadata.gz: 4de8e940a4acc632abda9d33ddb8cac20103e2c97b22949b77446f43ce64f6efb2c445f75fcf39bb63cb2bb82c4ee937ccf3fddbf691afed559aa02b48ddffab
7
+ data.tar.gz: ccbd1a56b4df1fe59db574186b0b3ad14bad27363cf2b95ffd197b9825ef5d8d5fa11dc6c1a757a82f014ab2e15153e6fd7c587b88aa485ba32d9bd801879ff9
data/README.md CHANGED
@@ -15,19 +15,136 @@ gem install rancher-metadata
15
15
  require 'rancher-metadata'
16
16
  api = RancherMetadata::API.new({:api_url => "http://rancher-metadata/2015-12-19"})
17
17
 
18
- puts("Container ID: #{api.get_container_id}")
19
- puts("Container Service ID: #{api.get_container_service_id}")
20
- puts("Container IP: #{api.get_container_ip}")
21
- puts("Container Name: #{api.get_container_name}")
22
- puts("Container Service Name: #{api.get_container_service_name}")
23
- puts("Container Hostname: #{api.get_container_hostname}")
18
+ puts("Container create index: #{api.get_container_create_index}")
19
+ puts("Container service suffix: #{api.get_container_service_suffix}")
20
+ puts("Container ip: #{api.get_container_ip}")
21
+ puts("Container name: #{api.get_container_name}")
22
+ puts("Container service name: #{api.get_container_service_name}")
23
+ puts("Container hostname: #{api.get_container_hostname}")
24
24
 
25
25
  api.wait_service_containers() do |name, container|
26
- puts("Container #{name} is up (IP: #{container['primary_ip']}, Index: #{container['create_index']})")
26
+ puts("Container #{name} is up (ip: #{container['primary_ip']}, create index: #{container['create_index']}, service suffix: #{api.get_container_service_suffix(name))")
27
27
  end
28
28
 
29
- metadata = api.get_service_metadata()
29
+ metadata = api.get_service_metadata
30
30
  puts(metadata.inspect)
31
+
32
+ puts("Service scale size: #{api.get_service_scale_size}")
33
+ ```
34
+
35
+ Look up all containers:
36
+ ```
37
+ api.get_containers.each do |container|
38
+ puts(container)
39
+ end
40
+ ```
41
+
42
+ Look up all services:
43
+ ```
44
+ api.get_services.each do |service|
45
+ puts(service)
46
+ end
47
+ ```
48
+
49
+ Look up all stacks:
50
+ ```
51
+ api.get_stacks.each do |stack|:
52
+ puts(stack)
53
+ end
54
+ ```
55
+
56
+ Look up all hosts:
57
+ ```
58
+ api.get_hosts.each do |host|:
59
+ puts(host)
60
+ end
61
+ ```
62
+
63
+ Look up current container:
64
+ ```
65
+ puts(api.get_container)
66
+ ```
67
+
68
+ Look up a container by name:
69
+ ```
70
+ puts(api.get_container("my_container"))
71
+ ```
72
+
73
+ Look up a container's IP by name:
74
+ ```
75
+ puts("A container IP #{api.get_container_ip("container_name")}")
76
+ ```
77
+
78
+ Look up current service:
79
+ ```
80
+ puts(api.get_service)
81
+ ```
82
+
83
+ Look up a specific service running in the current stack:
84
+ ```
85
+ puts(api.get_service({:service_name => 'my_service'}))
86
+ ```
87
+
88
+ Look up a specific service running in another stack:
89
+ ```
90
+ puts(api.get_service({:service_name => 'my_service', :stack_name => 'my_stack'}))
91
+ ```
92
+
93
+ look up a specific service's containers running in the current stack:
94
+ ```
95
+ api.get_service_containers({:service_name => 'my_service'}).each do |container|
96
+ puts(container)
97
+ end
98
+ ```
99
+
100
+ Look up a specific service's containers running in an another stack:
101
+ ```
102
+ api.get_service_containers({:service_name => 'my_service', :stack_name => 'my_stack'}).each do |container|
103
+ puts(container)
104
+ end
105
+ ```
106
+
107
+ Look up current stack:
108
+ ```
109
+ puts(api.get_stack)
110
+ ```
111
+
112
+ Look up a specific stack by name:
113
+ ```
114
+ puts(api.get_stack("my_stack"))
115
+ ```
116
+
117
+ Look up services running in current stack:
118
+ ```
119
+ api.get_stack_services.each do |service|
120
+ puts(service)
121
+ end
122
+ ```
123
+
124
+ Look up services running in another stack:
125
+ ```
126
+ api.get_stack_services("my_stack").each do |service|
127
+ puts(service)
128
+ end
129
+ ```
130
+
131
+ Look up current host:
132
+ ```
133
+ puts(api.get_host())
134
+ ```
135
+
136
+ Look up a specific host by name:
137
+ ```
138
+ puts(api.get_host("my_host"))
139
+ ```
140
+
141
+ Returns true if the container is running in Rancher-managed network:
142
+ ```
143
+ if api.is_network_managed?
144
+ puts("I am running in the managed network")
145
+ else
146
+ puts("I am running in host-based networking")
147
+ end
31
148
  ```
32
149
 
33
150
  ## Contact
@@ -156,6 +156,10 @@ module RancherMetadata
156
156
  end
157
157
 
158
158
  def get_container_id(container_name = nil)
159
+ self.get_container_create_index(container_name)
160
+ end
161
+
162
+ def get_container_create_index(container_name = nil)
159
163
  i = self.get_container_field("create_index", container_name)
160
164
  i ? i.to_i : nil
161
165
  end
@@ -189,6 +193,10 @@ module RancherMetadata
189
193
  end
190
194
 
191
195
  def get_container_service_id(container_name = nil)
196
+ self.get_container_service_suffix(container_name)
197
+ end
198
+
199
+ def get_container_service_suffix(container_name = nil)
192
200
  index = nil
193
201
 
194
202
  service_suffix = self.get_container_field("service_suffix", container_name)
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module RancherMetadata
8
- VERSION = "0.17.1"
8
+ VERSION = "0.17.2"
9
9
 
10
10
  def self.version
11
11
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rancher-metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Cerutti