magellan-cli 0.4.4 → 0.5.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/Gemfile.lock +17 -1
- data/README.md +14 -80
- data/Rakefile +9 -0
- data/lib/magellan/cli/base.rb +3 -3
- data/lib/magellan/cli/command.rb +8 -2
- data/lib/magellan/cli/locales/en.yml +74 -46
- data/lib/magellan/cli/locales/ja.yml +74 -46
- data/lib/magellan/cli/messaging/base.rb +75 -0
- data/lib/magellan/cli/messaging/http.rb +49 -0
- data/lib/magellan/cli/messaging/mqtt.rb +21 -0
- data/lib/magellan/cli/messaging.rb +18 -0
- data/lib/magellan/cli/reference_generator.rb +23 -6
- data/lib/magellan/cli/resources/base.rb +11 -10
- data/lib/magellan/cli/resources/client_version.rb +3 -2
- data/lib/magellan/cli/resources/cloudsql.rb +4 -4
- data/lib/magellan/cli/resources/deletable.rb +1 -1
- data/lib/magellan/cli/resources/organization.rb +1 -1
- data/lib/magellan/cli/resources/project.rb +2 -2
- data/lib/magellan/cli/resources/stage.rb +16 -16
- data/lib/magellan/cli/resources/team.rb +2 -2
- data/lib/magellan/cli/resources/transaction_router.rb +1 -1
- data/lib/magellan/cli/resources/worker.rb +5 -4
- data/lib/magellan/cli/version.rb +1 -1
- data/lib/magellan/cli.rb +2 -0
- data/magellan-cli.gemspec +1 -0
- data/reference/en/client_version.md +83 -0
- data/reference/en/cloudsql.md +93 -0
- data/reference/en/container.md +65 -0
- data/reference/en/image.md +65 -0
- data/reference/en/index.md +63 -0
- data/reference/en/organization.md +83 -0
- data/reference/en/project.md +92 -0
- data/reference/en/stage.md +181 -0
- data/reference/en/team.md +74 -0
- data/reference/en/worker.md +107 -0
- data/reference/ja/client_version.md +83 -0
- data/reference/ja/cloudsql.md +93 -0
- data/reference/ja/container.md +65 -0
- data/reference/ja/image.md +65 -0
- data/reference/ja/index.md +63 -0
- data/reference/ja/organization.md +83 -0
- data/reference/ja/project.md +92 -0
- data/reference/ja/stage.md +181 -0
- data/reference/ja/team.md +74 -0
- data/reference/ja/worker.md +107 -0
- data/spec/magellan/cli/messaging/http_headers.json +5 -0
- data/spec/magellan/cli/messaging/http_headers.yml +3 -0
- data/spec/magellan/cli/messaging/http_spec.rb +43 -0
- metadata +45 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a862c5cf1dedeb965c1b9b903d17a1fe41012b3
|
4
|
+
data.tar.gz: f7d879a8989894ac2d11fa04991ffa968052d672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2800d3ce556d12eb77ec5849229e51a9e08044ce93a8a187f70d8160871a8c48bc270831f782ae21124b6ab5a95e6e54a75cb5d67872b64c53e62b83798d4fd
|
7
|
+
data.tar.gz: 3e7b3d6f48da5e07015d7c72e44e3cfb14ce8512a2109d4ab11d143672c3a03c95cdc76ce4a7c0126324eaac3464d6022a9de49a03fe2c2b3d68067137b811b7
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
magellan-cli (0.
|
4
|
+
magellan-cli (0.5.0)
|
5
5
|
activesupport (~> 4.1.4)
|
6
6
|
groovenauts-thor
|
7
7
|
httpclient (~> 2.5)
|
8
8
|
i18n
|
9
|
+
libmagellan (~> 0.2.2)
|
9
10
|
nokogiri
|
10
11
|
psych (>= 2.0.0, <= 2.0.8)
|
11
12
|
text-table (~> 1.2.3)
|
@@ -19,6 +20,7 @@ GEM
|
|
19
20
|
minitest (~> 5.1)
|
20
21
|
thread_safe (~> 0.1)
|
21
22
|
tzinfo (~> 1.1)
|
23
|
+
addressable (2.3.6)
|
22
24
|
binding_of_caller (0.7.2)
|
23
25
|
debug_inspector (>= 0.0.1)
|
24
26
|
byebug (2.7.0)
|
@@ -30,14 +32,23 @@ GEM
|
|
30
32
|
debugger-linecache (1.2.0)
|
31
33
|
diff-lcs (1.2.5)
|
32
34
|
docile (1.1.5)
|
35
|
+
faraday (0.9.1)
|
36
|
+
multipart-post (>= 1.2, < 3)
|
33
37
|
groovenauts-thor (0.19.1)
|
34
38
|
httpclient (2.6.0.1)
|
35
39
|
i18n (0.7.0)
|
36
40
|
json (1.8.2)
|
41
|
+
jwt (1.2.0)
|
42
|
+
libmagellan (0.2.2)
|
43
|
+
activesupport
|
44
|
+
mqtt (~> 0.3.1)
|
45
|
+
signet (~> 0.5.0)
|
37
46
|
method_source (0.8.2)
|
38
47
|
mini_portile (0.6.2)
|
39
48
|
minitest (5.5.1)
|
49
|
+
mqtt (0.3.1)
|
40
50
|
multi_json (1.10.1)
|
51
|
+
multipart-post (2.0.0)
|
41
52
|
nokogiri (1.6.5)
|
42
53
|
mini_portile (~> 0.6.0)
|
43
54
|
pry (0.9.12.6)
|
@@ -64,6 +75,11 @@ GEM
|
|
64
75
|
rspec-mocks (3.0.4)
|
65
76
|
rspec-support (~> 3.0.0)
|
66
77
|
rspec-support (3.0.4)
|
78
|
+
signet (0.5.1)
|
79
|
+
addressable (>= 2.2.3)
|
80
|
+
faraday (>= 0.9.0.rc5)
|
81
|
+
jwt (>= 0.1.5)
|
82
|
+
multi_json (>= 1.0.0)
|
67
83
|
simplecov (0.9.1)
|
68
84
|
docile (~> 1.1.0)
|
69
85
|
multi_json (~> 1.0)
|
data/README.md
CHANGED
@@ -19,8 +19,22 @@ Or install it yourself as:
|
|
19
19
|
$ gem install magellan-cli
|
20
20
|
|
21
21
|
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
- [Getting Started](http://devcenter.magellanic-clouds.com/getting-started/)
|
25
|
+
- [Reference en](reference/en/index.md)
|
26
|
+
- [Reference ja](reference/ja/index.md)
|
27
|
+
|
28
|
+
|
22
29
|
## generate reference pages
|
23
30
|
|
31
|
+
```
|
32
|
+
LANG=en DEST=. SUBDIR=reference/$LANG bundle exec rake reference
|
33
|
+
LANG=ja DEST=. SUBDIR=reference/$LANG bundle exec rake reference
|
34
|
+
```
|
35
|
+
|
36
|
+
|
37
|
+
|
24
38
|
```
|
25
39
|
export DEVCENTER_DIR=/path/to/magellan-devcenter.github.io
|
26
40
|
LANG=en DEST=$DEVCENTER_DIR SUBDIR=reference/magellan-cli/$LANG bundle exec rake reference
|
@@ -40,86 +54,6 @@ open http://localhost:4000/reference/magellan-cli/ja
|
|
40
54
|
After check the pages, you can commit the .md files to magellan-devcenter.github.io repogitory.
|
41
55
|
|
42
56
|
|
43
|
-
## Usage
|
44
|
-
|
45
|
-
### All-in-one patterns
|
46
|
-
|
47
|
-
#### 1. [API Server terminal] initialize Database
|
48
|
-
|
49
|
-
```
|
50
|
-
bundle exec rake db:drop db:create db:migrate db:seed
|
51
|
-
```
|
52
|
-
|
53
|
-
|
54
|
-
#### 2. [API Server terminal] start API server and delayed_job daemon
|
55
|
-
|
56
|
-
```
|
57
|
-
bundle exec bin/delayed_job start
|
58
|
-
bundle exec bin/delayed_job status
|
59
|
-
bundle exec rails s
|
60
|
-
```
|
61
|
-
|
62
|
-
|
63
|
-
#### 3. [cli terminal] Load Magellan.yml
|
64
|
-
|
65
|
-
```
|
66
|
-
magellan-cli project load 1 path/to/Magellan.yml
|
67
|
-
```
|
68
|
-
|
69
|
-
#### 4. [cli terminal] create and configure Host Instance
|
70
|
-
|
71
|
-
```
|
72
|
-
magellan-cli host_instance sample_launch_options > launch_options.json
|
73
|
-
magellan-cli host_instance create 1 gce magellan-gce-sandbox1 launch_options.json
|
74
|
-
magellan-cli stage configure 1
|
75
|
-
```
|
76
|
-
|
77
|
-
#### 5. [API Server terminal]
|
78
|
-
|
79
|
-
Modify Host Instance config, if you need.
|
80
|
-
|
81
|
-
#### 6. [cli terminal] confirm Host Instance data
|
82
|
-
|
83
|
-
```
|
84
|
-
magellan-cli host_instance show 1
|
85
|
-
```
|
86
|
-
|
87
|
-
#### 7. [cli terminal] start stage inculding VmInstances and ContainerInstances
|
88
|
-
|
89
|
-
```
|
90
|
-
magellan-cli stage start 1
|
91
|
-
```
|
92
|
-
|
93
|
-
|
94
|
-
#### 8. [cli terminal] wait for stage working
|
95
|
-
|
96
|
-
check status of stage, host_instance and container_instance
|
97
|
-
|
98
|
-
```
|
99
|
-
magellan-cli stage list
|
100
|
-
magellan-cli host_instance list
|
101
|
-
magellan-cli container_instance list
|
102
|
-
```
|
103
|
-
|
104
|
-
|
105
|
-
#### 9. [cli terminal] connection check
|
106
|
-
|
107
|
-
```
|
108
|
-
irb
|
109
|
-
|
110
|
-
require 'json'
|
111
|
-
host_ip = JSON.parse(`magellan-cli host_instance show 1`)["public_ip"]
|
112
|
-
require 'libmagellan'
|
113
|
-
lm = Libmagellan.new(host: host_ip, port: 80,
|
114
|
-
consumer_key: "groovenauts.app1",
|
115
|
-
consumer_secret: "test")
|
116
|
-
puts Libmagellan::VERSION
|
117
|
-
lm.request("/ping").body
|
118
|
-
# => "pong\n"
|
119
|
-
lm.request("/hello/index").body
|
120
|
-
# => "{\"hello\":\"world\"}"
|
121
|
-
```
|
122
|
-
|
123
57
|
|
124
58
|
|
125
59
|
## Contributing
|
data/Rakefile
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# bundler が thor をまるごと抱えているという恐ろしい状態で、
|
3
|
+
# 暫定修正版である groovenauts-thorの修正が反映されない事態が発生していましたが、
|
4
|
+
# ここで先にrequireすればサブコマンドのhelpも正しく動くのでひとまずこのまま行きます。
|
5
|
+
# bundler・・・
|
6
|
+
# https://github.com/bundler/bundler/tree/master/lib/bundler/vendor
|
7
|
+
require 'thor'
|
8
|
+
require 'thor/command'
|
9
|
+
|
1
10
|
require "bundler/gem_tasks"
|
2
11
|
require "rspec/core/rake_task"
|
3
12
|
|
data/lib/magellan/cli/base.rb
CHANGED
@@ -5,9 +5,9 @@ require 'thor'
|
|
5
5
|
module Magellan
|
6
6
|
module Cli
|
7
7
|
class Base < Thor
|
8
|
-
class_option :
|
9
|
-
class_option :
|
10
|
-
class_option :
|
8
|
+
class_option :version, type: :boolean, aliases: "-v", desc: I18n.t(:version, scope: [:base, :class_option])
|
9
|
+
class_option :verbose, type: :boolean, aliases: "-V", desc: I18n.t(:verbose, scope: [:base, :class_option])
|
10
|
+
class_option :dryrun , type: :boolean, aliases: "-D", desc: I18n.t(:dryrun , scope: [:base, :class_option])
|
11
11
|
|
12
12
|
no_commands do
|
13
13
|
|
data/lib/magellan/cli/command.rb
CHANGED
@@ -56,7 +56,12 @@ module Magellan
|
|
56
56
|
subcommand name, ::Magellan::Cli::Resources.const_get(classname)
|
57
57
|
end
|
58
58
|
|
59
|
-
|
59
|
+
Messaging::MAPPING.each do |classname, name|
|
60
|
+
desc "#{name} SUBCOMMAND ...ARGS", I18n.t(name.to_sym, scope: [:command, :cmd, :messaging])
|
61
|
+
subcommand name, ::Magellan::Cli::Messaging.const_get(classname)
|
62
|
+
end
|
63
|
+
|
64
|
+
COMMAND_ORDER = %w[login] + Resources::MAPPING.values + Messaging::MAPPING.values
|
60
65
|
|
61
66
|
#desc "direct SUBCOMMAND ...ARGS", "Send request directly"
|
62
67
|
#subcommand "direct", ::Magellan::Cli::Direct
|
@@ -87,8 +92,9 @@ module Magellan
|
|
87
92
|
d = {"user" => cli.login_auth["email"] }
|
88
93
|
Resources::MAPPING.each do |classname, name|
|
89
94
|
klass = ::Magellan::Cli::Resources.const_get(classname)
|
95
|
+
attr = klass.caption_attr
|
90
96
|
if val = selections[ klass.parameter_name ]
|
91
|
-
d[name] = val[
|
97
|
+
d[name] = val[attr] ? val[attr] : val.inspect
|
92
98
|
end
|
93
99
|
end
|
94
100
|
log_info YAML.dump(d)
|
@@ -17,11 +17,18 @@ en:
|
|
17
17
|
${MAGELLAN_CLI_CONFIG_FILE}.
|
18
18
|
cmd:
|
19
19
|
help: "Describe available commands or one specific command"
|
20
|
+
class_option:
|
21
|
+
version: "Show the program version"
|
22
|
+
verbose: "Show additional logging information"
|
23
|
+
dryrun: "Do a dry run without executing actions"
|
20
24
|
command:
|
21
25
|
cmd:
|
22
26
|
manage_resource: "Manage %{resource}"
|
23
27
|
login: "Login to the Magellan server"
|
24
28
|
info: "Show login user and selected resources"
|
29
|
+
messaging:
|
30
|
+
http: "Send messages by using HTTP"
|
31
|
+
mqtt: "Publish and get messages by using MQTT"
|
25
32
|
cmd_login:
|
26
33
|
email: "email address for login"
|
27
34
|
password: "password for login"
|
@@ -39,53 +46,74 @@ en:
|
|
39
46
|
login:
|
40
47
|
check_login_auth:
|
41
48
|
not_logged_in: "Not logined yet. type `%{command} login`."
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
client_version:
|
57
|
-
cmd:
|
58
|
-
create: "Create a new %{resource_name} with VERSION"
|
59
|
-
delete: "Delete the %{resource_name} specified by VERSION"
|
60
|
-
stage:
|
61
|
-
cmd:
|
62
|
-
planning: "Switch to planning to build next released version"
|
63
|
-
current: "Switch to current released version"
|
64
|
-
prepare: "Prepare the %{containers_name}"
|
65
|
-
repair: "Repair the %{resource_name} status"
|
66
|
-
release_now: "Release the changes now"
|
67
|
-
logs: "Fetch the logs of the %{workers_name}"
|
68
|
-
set_container_num: "Set the number of %{containers_name} for the selected %{image_name}"
|
69
|
-
reload: "Reload the last selections"
|
70
|
-
cmd_release_now:
|
71
|
-
async: "-A async mode. release_now returns soon"
|
72
|
-
interval: "-i polling interval(seconds)"
|
73
|
-
timeout: "-t timeout(seconds)"
|
74
|
-
cloudsql:
|
75
|
-
cmd_create:
|
76
|
-
async: "-A async mode. release_now returns soon"
|
77
|
-
interval: "-i polling interval(seconds)"
|
78
|
-
timeout: "-t timeout(seconds)"
|
79
|
-
team:
|
80
|
-
cmd:
|
81
|
-
create: "Create a new %{resource_name} with NAME and ROLE"
|
82
|
-
invite: "Invite a user to the %{resource_name}"
|
83
|
-
worker:
|
84
|
-
cmd:
|
85
|
-
create: "Create a new %{resource_name} with NAME and IMAGE"
|
86
|
-
update: "Update the ATTRIBUTES(filename or JSON) of the selected %{resource_name}"
|
87
|
-
prepare_images: "Prepare the %{images_name} for the selected %{worker_name}"
|
49
|
+
messaging:
|
50
|
+
http:
|
51
|
+
ping: "Send a HTTP request to check connection"
|
52
|
+
get: "Send a HTTP request with GET method"
|
53
|
+
delete: "Send a HTTP request with DELETE method"
|
54
|
+
post: "Send a HTTP request with POST method"
|
55
|
+
put: "Send a HTTP request with PUT method"
|
56
|
+
patch: "Send a HTTP request with PATCH method"
|
57
|
+
common_options:
|
58
|
+
headers: "JSON style string or .yml or .json file path which has content"
|
59
|
+
body: "String or file path which has body"
|
60
|
+
mqtt:
|
61
|
+
pub: "Publish a message with a topic"
|
62
|
+
get: "Get a message"
|
88
63
|
reference:
|
89
64
|
commands: "Commands"
|
90
65
|
global_options: "Global Options"
|
91
66
|
details: "Details"
|
67
|
+
resources:
|
68
|
+
base:
|
69
|
+
default_query:
|
70
|
+
not_selected: "No %{label} selected"
|
71
|
+
get_first_result:
|
72
|
+
not_found: "%{name} not found by using %{query}"
|
73
|
+
common:
|
74
|
+
cmd:
|
75
|
+
create: "Create a new %{resource_name} with NAME"
|
76
|
+
delete: "Delete the %{resource_name} specified by NAME"
|
77
|
+
update: "Update the ATTRIBUTES of the selected %{resource_name}"
|
78
|
+
list: "Show a list of the %{res_names}"
|
79
|
+
show: "Show the detail of the %{res_name} specified by ID"
|
80
|
+
select: "Select the %{res_name} by NAME"
|
81
|
+
deselect: "Deselect the %{res_name}"
|
82
|
+
client_version:
|
83
|
+
cmd:
|
84
|
+
select: "Select the %{resource_name} by VERSION"
|
85
|
+
create: "Create a new %{resource_name} with VERSION"
|
86
|
+
delete: "Delete the %{resource_name} specified by VERSION"
|
87
|
+
stage:
|
88
|
+
cmd:
|
89
|
+
create: "Create a new %{resource_name} with Name and Type"
|
90
|
+
planning: "Switch to planning to build next released version"
|
91
|
+
current: "Switch to current released version"
|
92
|
+
prepare: "Prepare the %{containers_name}"
|
93
|
+
repair: "Repair the %{resource_name} status"
|
94
|
+
release_now: "Release the changes now"
|
95
|
+
logs: "Fetch the logs of the %{workers_name}"
|
96
|
+
set_container_num: "Set the number of %{containers_name} for the selected %{image_name}"
|
97
|
+
reload: "Reload the last selections"
|
98
|
+
cmd_create:
|
99
|
+
type: "-t development|staging|production. specify Stage Type"
|
100
|
+
cmd_release_now:
|
101
|
+
async: "-A async mode. release_now returns soon"
|
102
|
+
interval: "-i polling interval(seconds)"
|
103
|
+
timeout: "-t timeout(seconds)"
|
104
|
+
cloudsql:
|
105
|
+
cmd_create:
|
106
|
+
async: "-A async mode. release_now returns soon"
|
107
|
+
interval: "-i polling interval(seconds)"
|
108
|
+
timeout: "-t timeout(seconds)"
|
109
|
+
team:
|
110
|
+
cmd:
|
111
|
+
create: "Create a new %{resource_name} with NAME and ROLE"
|
112
|
+
invite: "Invite a user to the %{resource_name}"
|
113
|
+
worker:
|
114
|
+
cmd:
|
115
|
+
create: "Create a new %{resource_name} with NAME and IMAGE"
|
116
|
+
update: "Update the ATTRIBUTES(filename or JSON) of the selected %{resource_name}"
|
117
|
+
prepare_images: "Prepare the %{images_name} for the selected %{worker_name}"
|
118
|
+
cmd_create:
|
119
|
+
attributes_yaml: "path to YAML file which defines attributes"
|
@@ -15,11 +15,18 @@ ja:
|
|
15
15
|
パスへ移動してください。
|
16
16
|
cmd:
|
17
17
|
help: "利用可能なコマンドの一覧か特定のコマンドの説明を表示します"
|
18
|
+
class_option:
|
19
|
+
version: "バージョンを表示します"
|
20
|
+
verbose: "追加のログ情報を表示します"
|
21
|
+
dryrun: "登録や削除などのシステムには反映させずにアクションを実行します"
|
18
22
|
command:
|
19
23
|
cmd:
|
20
24
|
manage_resource: "%{resource}を操作します"
|
21
25
|
login: "MAGELLANのサーバにログインします"
|
22
26
|
info: "ログイン情報と選択されているリソースを表示します"
|
27
|
+
messaging:
|
28
|
+
http: "HTTPを使ってメッセージを送信します"
|
29
|
+
mqtt: "MQTTを使ってメッセージを送受信します"
|
23
30
|
cmd_login:
|
24
31
|
email: "ログインするアカウントのメールアドレス"
|
25
32
|
password: "ログインするアカウントのパスワード"
|
@@ -37,53 +44,74 @@ ja:
|
|
37
44
|
login:
|
38
45
|
check_login_auth:
|
39
46
|
not_logged_in: "ログインしていません。`%{command} login` を実行してログインしてください"
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
client_version:
|
55
|
-
cmd:
|
56
|
-
create: "VERSIONを指定して%{resource_name}を登録します"
|
57
|
-
delete: "VERSIONを指定して%{resource_name}を削除します"
|
58
|
-
stage:
|
59
|
-
cmd:
|
60
|
-
planning: "次回リリースのステージの計画に切り替えます"
|
61
|
-
current: "現在リリースされているステージの情報に切り替えます"
|
62
|
-
prepare: "%{containers_name}を準備します"
|
63
|
-
repair: "%{resource_name}の状態を修正します"
|
64
|
-
release_now: "すぐにリリースを開始します"
|
65
|
-
logs: "%{workers_name}のログを表示します"
|
66
|
-
set_container_num: "選択された%{image_name}の%{containers_name}の数を設定します"
|
67
|
-
reload: "最後にselectされたものをロードし直します"
|
68
|
-
cmd_release_now:
|
69
|
-
async: "-A 非同期モード。リリースの終了を待たずにコマンドを終了します"
|
70
|
-
interval: "-i 状態を取得する間隔を秒で指定します"
|
71
|
-
timeout: "-t タイムアウトを秒で指定します"
|
72
|
-
cloudsql:
|
73
|
-
cmd_create:
|
74
|
-
async: "-A 非同期モード。リリースの終了を待たずにコマンドを終了します"
|
75
|
-
interval: "-i 状態を取得する間隔を秒で指定します"
|
76
|
-
timeout: "-t タイムアウトを秒で指定します"
|
77
|
-
team:
|
78
|
-
cmd:
|
79
|
-
create: "NAMEとROLEを指定して%{resource_name}を登録します"
|
80
|
-
invite: "%{resource_name}にユーザを招待します"
|
81
|
-
worker:
|
82
|
-
cmd:
|
83
|
-
create: "NAMEとIMAGEを指定して%{resource_name}を登録します"
|
84
|
-
update: "選択した%{resource_name}の属性を指定したATTRIBUTESで更新します。ATTRIBUTESにはYAMLのファイル名かJSON文字列を指定可能です"
|
85
|
-
prepare_images: "選択された%{worker_name}の%{images_name}を準備します"
|
47
|
+
messaging:
|
48
|
+
http:
|
49
|
+
ping: "接続確認のリクエストを送信します"
|
50
|
+
get: "GETメソッドを使ってHTTPリクエストを送信します"
|
51
|
+
delete: "GETメソッドを使ってHTTPリクエストを送信します"
|
52
|
+
post: "POSTメソッドを使ってHTTPリクエストを送信します"
|
53
|
+
put: "PUTメソッドを使ってHTTPリクエストを送信します"
|
54
|
+
patch: "PATCHメソッドを使ってHTTPリクエストを送信します"
|
55
|
+
common_options:
|
56
|
+
headers: "JSON形式の文字列か、拡張子が.ymlのYAML形式のファイルへのパス、あるいは拡張子が.jsonのJSON形式のファイルへのパス"
|
57
|
+
body: "内容を表す文字列か、内容を保持するファイルへのパス"
|
58
|
+
mqtt:
|
59
|
+
pub: "TOPICを指定してメッセージを配信します"
|
60
|
+
get: "メッセージを取得します"
|
86
61
|
reference:
|
87
62
|
commands: "コマンドの一覧"
|
88
63
|
global_options: "共通オプション"
|
89
64
|
details: "コマンドの詳細"
|
65
|
+
resources:
|
66
|
+
base:
|
67
|
+
default_query:
|
68
|
+
not_selected: "%{label}が選択されていません"
|
69
|
+
get_first_result:
|
70
|
+
not_found: "%{name}は見つかりませんでした。クエリ %{query}"
|
71
|
+
common:
|
72
|
+
cmd:
|
73
|
+
create: "NAMEを指定して%{resource_name}を登録します"
|
74
|
+
delete: "NAMEを指定して%{resource_name}を削除します"
|
75
|
+
update: "選択した%{resource_name}の属性を指定したATTRIBUTESで更新します"
|
76
|
+
list: "%{res_names} の一覧を表示します"
|
77
|
+
show: "IDで指定された%{res_name}の詳細を表示します"
|
78
|
+
select: "NAMEを指定して%{res_name}を選択します"
|
79
|
+
deselect: "%{res_name}の選択を解除します"
|
80
|
+
client_version:
|
81
|
+
cmd:
|
82
|
+
select: "VERSIONを指定して%{resource_name}を選択します"
|
83
|
+
create: "VERSIONを指定して%{resource_name}を登録します"
|
84
|
+
delete: "VERSIONを指定して%{resource_name}を削除します"
|
85
|
+
stage:
|
86
|
+
cmd:
|
87
|
+
create: "NAMEとTYPEを指定して%{resource_name}を登録します"
|
88
|
+
planning: "次回リリースのステージの計画に切り替えます"
|
89
|
+
current: "現在リリースされているステージの情報に切り替えます"
|
90
|
+
prepare: "%{containers_name}を準備します"
|
91
|
+
repair: "%{resource_name}の状態を修正します"
|
92
|
+
release_now: "すぐにリリースを開始します"
|
93
|
+
logs: "%{workers_name}のログを表示します"
|
94
|
+
set_container_num: "選択された%{image_name}の%{containers_name}の数を設定します"
|
95
|
+
reload: "最後にselectされたものをロードし直します"
|
96
|
+
cmd_create:
|
97
|
+
type: "-t development|staging|production いづれかのTYPEを指定してください"
|
98
|
+
cmd_release_now:
|
99
|
+
async: "-A 非同期モード。リリースの終了を待たずにコマンドを終了します"
|
100
|
+
interval: "-i 状態を取得する間隔を秒で指定します"
|
101
|
+
timeout: "-t タイムアウトを秒で指定します"
|
102
|
+
cloudsql:
|
103
|
+
cmd_create:
|
104
|
+
async: "-A 非同期モード。リリースの終了を待たずにコマンドを終了します"
|
105
|
+
interval: "-i 状態を取得する間隔を秒で指定します"
|
106
|
+
timeout: "-t タイムアウトを秒で指定します"
|
107
|
+
team:
|
108
|
+
cmd:
|
109
|
+
create: "NAMEとROLEを指定して%{resource_name}を登録します"
|
110
|
+
invite: "%{resource_name}にユーザを招待します"
|
111
|
+
worker:
|
112
|
+
cmd:
|
113
|
+
create: "NAMEとIMAGEを指定して%{resource_name}を登録します"
|
114
|
+
update: "選択した%{resource_name}の属性を指定したATTRIBUTESで更新します。ATTRIBUTESにはYAMLのファイル名かJSON文字列を指定可能です"
|
115
|
+
prepare_images: "選択された%{worker_name}の%{images_name}を準備します"
|
116
|
+
cmd_create:
|
117
|
+
attributes_yaml: "属性を定義するYAMLファイルへのパス"
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require "magellan/cli/messaging"
|
2
|
+
|
3
|
+
require 'libmagellan'
|
4
|
+
require 'json'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
module Magellan
|
8
|
+
module Cli
|
9
|
+
module Messaging
|
10
|
+
class Base < Magellan::Cli::Http
|
11
|
+
include Magellan::Cli::FileAccess
|
12
|
+
|
13
|
+
no_commands do
|
14
|
+
def core
|
15
|
+
@core ||= build_core
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def find(klass, id = nil)
|
21
|
+
id ||= load_selection(klass.parameter_name)["id"]
|
22
|
+
r = get_json("/admin/#{klass.resource_key}/#{id}.json")
|
23
|
+
end
|
24
|
+
|
25
|
+
DEFAULT_MAGELLAN_HTTP_SERVER_URL = "https://nebula-001-web.magellanic-clouds.com".freeze
|
26
|
+
DEFAULT_MAGELLAN_MQTT_SERVER_HOST = "nebula-001-mqtt.magellanic-clouds.com".freeze
|
27
|
+
DEFAULT_MAGELLAN_MQTT_SERVER_PORT = 1883
|
28
|
+
|
29
|
+
def build_core
|
30
|
+
proj = find(Resources::Project)
|
31
|
+
client_version = load_selection(Resources::ClientVersion.parameter_name)["version"]
|
32
|
+
options = {
|
33
|
+
consumer_key: proj["consumer_key"],
|
34
|
+
consumer_secret: proj["consumer_secret"],
|
35
|
+
client_version: client_version,
|
36
|
+
mqtt_host: ENV["MAGELLAN_MQTT_SERVER_HOST"] || DEFAULT_MAGELLAN_MQTT_SERVER_HOST,
|
37
|
+
mqtt_port: ENV["MAGELLAN_MQTT_SERVER_PORT"] || DEFAULT_MAGELLAN_MQTT_SERVER_PORT,
|
38
|
+
}
|
39
|
+
uri = ENV["MAGELLAN_HTTP_SERVER_URL"] || DEFAULT_MAGELLAN_HTTP_SERVER_URL
|
40
|
+
log_verbose("HTTP URL : #{uri.inspect}")
|
41
|
+
log_verbose("HTTP options: #{options.inspect}")
|
42
|
+
Libmagellan::Core.new(uri, options)
|
43
|
+
end
|
44
|
+
|
45
|
+
def try_reading_file(value)
|
46
|
+
return nil if value.nil?
|
47
|
+
if File.readable?(value)
|
48
|
+
return File.read(value)
|
49
|
+
else
|
50
|
+
return value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def try_reading_hash(value)
|
55
|
+
return nil if value.nil?
|
56
|
+
obj =
|
57
|
+
if File.readable?(value)
|
58
|
+
case File.extname(value)
|
59
|
+
when ".json" then JSON.parse(File.read(value))
|
60
|
+
when ".yml" then YAML.load_file(value)
|
61
|
+
else raise "Unsupported file type: #{value.inspect}, .json and .yml are supported."
|
62
|
+
end
|
63
|
+
else
|
64
|
+
JSON.parse(value)
|
65
|
+
end
|
66
|
+
raise "#{value.inspect} contains #{obj.class.name} but it must be a Hash" unless obj.is_a?(Hash)
|
67
|
+
return obj
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "magellan/cli/messaging"
|
2
|
+
|
3
|
+
module Magellan
|
4
|
+
module Cli
|
5
|
+
module Messaging
|
6
|
+
class Http < Magellan::Cli::Messaging::Base
|
7
|
+
|
8
|
+
desc "ping", I18n.t(:ping, scope: [:messaging, :http])
|
9
|
+
def ping
|
10
|
+
res = core.ping
|
11
|
+
puts_res(res)
|
12
|
+
end
|
13
|
+
|
14
|
+
COMMAND_ORDER = %w[get post put patch delete ping]
|
15
|
+
|
16
|
+
[:get, :delete].each do |m|
|
17
|
+
desc "#{m} PATH", I18n.t(m, scope: [:messaging, :http])
|
18
|
+
method_option :headers, aliases: "-H", desc: I18n.t(:headers, scope: [:messaging, :http, :common_options])
|
19
|
+
module_eval(<<-EOM, __FILE__, __LINE__ + 1)
|
20
|
+
def #{m}(path, headers = nil)
|
21
|
+
res = core.request(path, :#{m}, nil, try_reading_hash(headers) || {})
|
22
|
+
puts_res(res)
|
23
|
+
end
|
24
|
+
EOM
|
25
|
+
end
|
26
|
+
|
27
|
+
[:post, :put, :patch].each do |m|
|
28
|
+
desc "#{m} PATH", I18n.t(m, scope: [:messaging, :http])
|
29
|
+
method_option :body , aliases: "-d", desc: I18n.t(:body , scope: [:messaging, :http, :common_options])
|
30
|
+
method_option :headers, aliases: "-H", desc: I18n.t(:headers, scope: [:messaging, :http, :common_options])
|
31
|
+
module_eval(<<-EOM, __FILE__, __LINE__ + 1)
|
32
|
+
def #{m}(path, body, headers = nil)
|
33
|
+
res = core.request(path, :#{m}, try_reading_file(body), try_reading_hash(headers) || {})
|
34
|
+
puts_res(res)
|
35
|
+
end
|
36
|
+
EOM
|
37
|
+
end
|
38
|
+
|
39
|
+
no_commands do
|
40
|
+
def puts_res(res)
|
41
|
+
color = (res.code =~ /\A2\d\d\z/) ? "32" : "31"
|
42
|
+
puts "\e[#{color}m#{res.body.strip}\e[0m"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "magellan/cli/messaging"
|
2
|
+
|
3
|
+
module Magellan
|
4
|
+
module Cli
|
5
|
+
module Messaging
|
6
|
+
class Mqtt < Magellan::Cli::Messaging::Base
|
7
|
+
|
8
|
+
desc "pub TOPIC PAYLOAD", I18n.t(:pub, scope: [:messaging, :mqtt])
|
9
|
+
def pub(topic, payload)
|
10
|
+
core.publish(topic, try_reading_file(payload))
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "get [TOPIC]", I18n.t(:get, scope: [:messaging, :mqtt])
|
14
|
+
def get(topic = nil)
|
15
|
+
core.get_message(topic)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|