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 +4 -4
- data/README.md +125 -8
- data/lib/rancher-metadata/api.rb +8 -0
- data/lib/rancher-metadata/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77f98d39db3280e7c314cab070c53c2adccbe429
|
4
|
+
data.tar.gz: d092becc850f73a3408f24a22f364c5afccff7b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
19
|
-
puts("Container
|
20
|
-
puts("Container
|
21
|
-
puts("Container
|
22
|
-
puts("Container
|
23
|
-
puts("Container
|
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 (
|
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
|
data/lib/rancher-metadata/api.rb
CHANGED
@@ -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)
|