MuranoCLI 2.1.1 → 2.2.1
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/README.markdown +17 -17
- data/Rakefile +21 -9
- data/TODO.taskpaper +6 -5
- data/bin/murano +2 -2
- data/lib/MrMurano/Account.rb +15 -5
- data/lib/MrMurano/ReCommander.rb +52 -0
- data/lib/MrMurano/Solution-File.rb +1 -1
- data/lib/MrMurano/commands/postgresql.rb +115 -1
- data/lib/MrMurano/commands/productDevice.rb +3 -0
- data/lib/MrMurano/commands/productDeviceIdCmds.rb +3 -0
- data/lib/MrMurano/http.rb +8 -1
- data/lib/MrMurano/version.rb +1 -1
- data/lib/MrMurano.rb +1 -0
- data/spec/Http_spec.rb +1 -1
- data/spec/cmd_common.rb +0 -12
- data/spec/cmd_help_spec.rb +25 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b78d9ce452b2b23947f59e64fc31dc8d9b8b577e
|
4
|
+
data.tar.gz: 87bc747d1e7e6cb6e053bfaa6880e81c537abf85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 063e8c71e99d835b8432a9616d660a98dea0610e5d8e42f4903acf723b6115fc99c004afc9bf8476854f6d6b0c37b7c3ff6c95b09e48b2b62a56e45f6568867d
|
7
|
+
data.tar.gz: 9f380017ea3d6c31b411efe6a5cd55413cd3e9d3415a17131c99b231e872ca9189b7a3ebea04e0b598fecbdd3607b4bfaee1e465b03bffe0e63d4f7c877e4b2e
|
data/README.markdown
CHANGED
@@ -39,8 +39,8 @@ There are a few steps and pieces to getting a solution with a product up and
|
|
39
39
|
running in Murano. Here is the list.
|
40
40
|
|
41
41
|
- Pick a business: `murano business list`
|
42
|
-
|
43
|
-
|
42
|
+
If this is the first time you've run `murano` it will ask for your Murano username
|
43
|
+
and password.
|
44
44
|
- Set it: `murano config business.id ZZZZZZZZZ`
|
45
45
|
- Create a product: `murano product create myawesomeproduct --save`
|
46
46
|
- Add resource aliases to specs/resources.yaml
|
@@ -58,24 +58,24 @@ Then deploy with `murano syncup`
|
|
58
58
|
|
59
59
|
When upgrading from a 1.\* version to a 2.0, you should uninstall the old versions
|
60
60
|
first.
|
61
|
-
```
|
62
|
-
> gem uninstall MuranoCLI
|
61
|
+
```sh
|
62
|
+
> gem uninstall MuranoCLI MrMurano
|
63
63
|
```
|
64
64
|
|
65
65
|
And then install:
|
66
66
|
|
67
|
-
```
|
67
|
+
```sh
|
68
68
|
> gem install MuranoCLI
|
69
69
|
```
|
70
70
|
Or
|
71
|
-
```
|
71
|
+
```sh
|
72
72
|
> gem update MuranoCLI
|
73
73
|
```
|
74
74
|
|
75
75
|
You will likely need to be root for the above commands. If you would rather not
|
76
76
|
install as root, you can install gems in the user directory.
|
77
77
|
|
78
|
-
```
|
78
|
+
```sh
|
79
79
|
> gem install MuranoCLI --user-install
|
80
80
|
```
|
81
81
|
|
@@ -128,12 +128,12 @@ CORS options inline.
|
|
128
128
|
|
129
129
|
```yaml
|
130
130
|
routes:
|
131
|
-
|
131
|
+
cors: my_cors_file.json
|
132
132
|
```
|
133
133
|
OR:
|
134
134
|
```yaml
|
135
135
|
routes:
|
136
|
-
|
136
|
+
cors: {"origin": true}
|
137
137
|
```
|
138
138
|
|
139
139
|
Then use `murano cors set` to push these options up to your solution.
|
@@ -191,12 +191,12 @@ could be:
|
|
191
191
|
--#EVENT device datapoint
|
192
192
|
local stamped = nil
|
193
193
|
if data.api == "record" then
|
194
|
-
|
194
|
+
stamped = tostring(data.value[1]) .. 's'
|
195
195
|
end
|
196
196
|
Tsdb.write{
|
197
|
-
|
198
|
-
|
199
|
-
|
197
|
+
tags = {sn=data.device_sn},
|
198
|
+
metrics = {[data.alias] = tonumber(data.value[2])},
|
199
|
+
ts = stamped
|
200
200
|
}
|
201
201
|
```
|
202
202
|
|
@@ -211,7 +211,7 @@ and `.murano.prod`. Then write the `.env` file to point at the system you're
|
|
211
211
|
currently working on.
|
212
212
|
|
213
213
|
The files for this are then:
|
214
|
-
```
|
214
|
+
```sh
|
215
215
|
cat >> .murano.dev <<EOF
|
216
216
|
[solution]
|
217
217
|
id=AAAAAAAA
|
@@ -295,9 +295,9 @@ the shell and are for testing the user facing components. A subset of the comma
|
|
295
295
|
tests work with the live Murano servers (`--tag needs_password`).
|
296
296
|
|
297
297
|
To use the live tests, the following environment variables need to be set:
|
298
|
-
- `
|
299
|
-
|
300
|
-
- `
|
298
|
+
- `MURANO_CONFIGFILE` : A Config with the user.name, business.id, and net.host for
|
299
|
+
the intergration tests.
|
300
|
+
- `MURANO_PASSWORD` : Password for the user.name above.
|
301
301
|
|
302
302
|
A free account on Murano is sufficient for these tests.
|
303
303
|
|
data/Rakefile
CHANGED
@@ -23,6 +23,20 @@ task :echo do
|
|
23
23
|
puts builtGem
|
24
24
|
end
|
25
25
|
|
26
|
+
desc "display remind of how to release"
|
27
|
+
task :release_reminder do
|
28
|
+
puts <<EOR
|
29
|
+
git flow release start <newversion>
|
30
|
+
gvim lib/MrMurano/version.rb
|
31
|
+
git commit -a -m 'version bump'
|
32
|
+
git flow release finish <newversion>
|
33
|
+
# When editing message for tag, add release notes.
|
34
|
+
rake git:all
|
35
|
+
# Wait for all tests to complete.
|
36
|
+
# if all passed: rake gemit
|
37
|
+
EOR
|
38
|
+
end
|
39
|
+
|
26
40
|
desc "Prints a cmd to test this in another directory"
|
27
41
|
task :testwith do
|
28
42
|
pwd=Dir.pwd.sub(Dir.home, '~')
|
@@ -33,26 +47,24 @@ desc 'Run RSpec'
|
|
33
47
|
task :rspec do
|
34
48
|
Dir.mkdir("report") unless File.directory?("report")
|
35
49
|
rv=RUBY_VERSION.gsub(/\./,'_')
|
36
|
-
sh %{rspec --format html --out report/index-#{rv}.html --format
|
50
|
+
sh %{rspec --format html --out report/index-#{rv}.html --format documentation}
|
37
51
|
end
|
38
52
|
task :test => [:test_clean_up, :rspec]
|
39
53
|
|
40
54
|
desc "Clean out junk from prior hot tests"
|
41
55
|
task :test_clean_up do
|
42
|
-
if not ENV['
|
43
|
-
not ENV['MURANO_BUSINESS'].nil? and
|
44
|
-
not ENV['MURANO_PASSWORD'].nil? then
|
56
|
+
if not ENV['MURANO_CONFIGFILE'].nil? then
|
45
57
|
|
46
|
-
ids = `ruby -Ilib bin/murano product list --idonly
|
58
|
+
ids = `ruby -Ilib bin/murano product list --idonly`.chomp
|
47
59
|
puts "Found prodcuts #{ids}; deleteing"
|
48
60
|
ids.split.each do |id|
|
49
|
-
sh %{ruby -Ilib bin/murano product delete #{id}
|
61
|
+
sh %{ruby -Ilib bin/murano product delete #{id}}
|
50
62
|
end
|
51
63
|
|
52
|
-
ids = `ruby -Ilib bin/murano solution list --idonly
|
64
|
+
ids = `ruby -Ilib bin/murano solution list --idonly`.chomp
|
53
65
|
puts "Found solutions #{ids}; deleteing"
|
54
66
|
ids.split.each do |id|
|
55
|
-
sh %{ruby -Ilib bin/murano solution delete #{id}
|
67
|
+
sh %{ruby -Ilib bin/murano solution delete #{id}}
|
56
68
|
end
|
57
69
|
end
|
58
70
|
end
|
@@ -153,7 +165,7 @@ if Gem.win_platform? then
|
|
153
165
|
task :murano_exe_test => ['murano.exe'] do
|
154
166
|
Dir.mkdir("report") unless File.directory?("report")
|
155
167
|
ENV['CI_MR_EXE'] = '1'
|
156
|
-
sh %{rspec --format html --out report/murano_exe.html --format
|
168
|
+
sh %{rspec --format html --out report/murano_exe.html --format documentation --tag cmd}
|
157
169
|
end
|
158
170
|
task :test => [:murano_exe_test]
|
159
171
|
|
data/TODO.taskpaper
CHANGED
@@ -3,6 +3,9 @@ Readme:
|
|
3
3
|
- Look into using VCR for testing. @pri(low)
|
4
4
|
|
5
5
|
Commands:
|
6
|
+
- Add hooks. @done(2017-03-31)
|
7
|
+
- Add default options for commands. @done(2017-03-31)
|
8
|
+
So you can say to always -V syncup, and nothing else.
|
6
9
|
- Init command. @done(2016-11-28)
|
7
10
|
- Empty sub-commands should return help. @done(2016-11-21)
|
8
11
|
There are a bunch of empty sub-commands that prefix another layer. Such as
|
@@ -86,13 +89,12 @@ Config:
|
|
86
89
|
- Think about adding dev,staging,prod system; how would that work? @done(2016-09-16)
|
87
90
|
|
88
91
|
SyncUpDown:
|
89
|
-
- Document the hash keys for an item. @pri(high)
|
92
|
+
- Document the hash keys for an item. @pri(high) @done(2017-03-30)
|
90
93
|
Also consider turning that hash into a Struct
|
91
94
|
- Allow specifying local files to limit actions to. @done(2017-03-03)
|
92
95
|
|
93
96
|
SolutionBase:
|
94
|
-
- All network traffic is serialized. Make some parallel.
|
95
|
-
This might break some things.
|
97
|
+
- All network traffic is serialized. Make some parallel. not doing this. @done(2017-03-30)
|
96
98
|
- Errors from the server should be displayed prettier. @done(2016-09-26)
|
97
99
|
- JSON parse should use symbols for keys. @done(2016-09-01)
|
98
100
|
- Add the --curl verbose option. @done(2016-08-12)
|
@@ -103,8 +105,7 @@ Windows:
|
|
103
105
|
- Look into http://ocra.rubyforge.org for building an exec. @pri(high) @done(2016-12-21)
|
104
106
|
|
105
107
|
Bundles:
|
106
|
-
- Revisit this idea. Its complexity may not be worth its value.
|
107
|
-
- Test syncdown behavor.
|
108
|
+
- Revisit this idea. Its complexity may not be worth its value. @done(2017-03-30)
|
108
109
|
- Work on design @done(2016-08-09)
|
109
110
|
Thinking of something like VIM bundles. A directory of directories. Each with a
|
110
111
|
manafest file? (maybe) A Bundle is a group of modules, endpoints, static files
|
data/bin/murano
CHANGED
@@ -52,8 +52,8 @@ $project.load
|
|
52
52
|
|
53
53
|
# Basic command support is:
|
54
54
|
# - read/write config file in [Project, User, System] (all are optional)
|
55
|
-
# - Introspection for tab completion.
|
56
|
-
# - Look for tools in PATH that are +x and "mr-foo..."
|
55
|
+
# - TODO: Introspection for tab completion.
|
56
|
+
# - TODO: Look for tools in PATH that are +x and "mr-foo..."
|
57
57
|
|
58
58
|
|
59
59
|
# Look for plug-ins
|
data/lib/MrMurano/Account.rb
CHANGED
@@ -143,7 +143,7 @@ module MrMurano
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def new_account(email, name, company="")
|
146
|
-
post('
|
146
|
+
post('key/', {
|
147
147
|
:email=>email,
|
148
148
|
:name=>name,
|
149
149
|
:company=>company,
|
@@ -152,11 +152,11 @@ module MrMurano
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def reset_account(email)
|
155
|
-
post('
|
155
|
+
post('key/', { :email=>email, :source=>'reset' })
|
156
156
|
end
|
157
157
|
|
158
158
|
def accept_account(token, password)
|
159
|
-
post("
|
159
|
+
post("key/#{token}", {:password=>password})
|
160
160
|
end
|
161
161
|
|
162
162
|
def businesses
|
@@ -165,11 +165,21 @@ module MrMurano
|
|
165
165
|
end
|
166
166
|
|
167
167
|
def new_business(name)
|
168
|
-
post('
|
168
|
+
post('business/', {:name=>name})
|
169
169
|
end
|
170
170
|
|
171
171
|
def delete_business(id)
|
172
|
-
delete("
|
172
|
+
delete("business/#{id}")
|
173
|
+
end
|
174
|
+
|
175
|
+
def has_projects?(id)
|
176
|
+
ret = get("business/#{id}/overview")
|
177
|
+
return false unless ret.kind_of? Hash
|
178
|
+
return false unless ret.has_key? :tier
|
179
|
+
tier = ret[:tier]
|
180
|
+
return false unless tier.kind_of? Hash
|
181
|
+
return false unless tier.has_key? :enableProjects
|
182
|
+
return tier[:enableProjects]
|
173
183
|
end
|
174
184
|
|
175
185
|
def products
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
module MrMurano
|
3
|
+
class Hooked
|
4
|
+
include Verbose
|
5
|
+
attr :section
|
6
|
+
|
7
|
+
def initialize(section)
|
8
|
+
@section = section
|
9
|
+
end
|
10
|
+
|
11
|
+
def check_run_pre_hook
|
12
|
+
prehook = $cfg["#{section}.pre-hook"]
|
13
|
+
return if prehook.nil?
|
14
|
+
return if prehook.empty?
|
15
|
+
verbose "calling pre-hook: #{prehook}"
|
16
|
+
system(prehook)
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_run_post_hook
|
20
|
+
posthook = $cfg["#{section}.post-hook"]
|
21
|
+
return if posthook.nil?
|
22
|
+
return if posthook.empty?
|
23
|
+
verbose "calling post-hook: #{posthook}"
|
24
|
+
system(posthook)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Commander
|
31
|
+
class Runner
|
32
|
+
alias :old_run_active_command :run_active_command
|
33
|
+
def run_active_command
|
34
|
+
section = active_command.name
|
35
|
+
hooked = MrMurano::Hooked.new(section)
|
36
|
+
hooked.check_run_pre_hook
|
37
|
+
|
38
|
+
old_run_active_command
|
39
|
+
|
40
|
+
hooked.check_run_post_hook
|
41
|
+
end
|
42
|
+
|
43
|
+
alias :old_parse_global_options :parse_global_options
|
44
|
+
def parse_global_options
|
45
|
+
defopts = ($cfg["#{active_command.name}.options"] or '').split
|
46
|
+
@args.push( *defopts )
|
47
|
+
old_parse_global_options
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# vim: set ai et sw=2 ts=2 :
|
@@ -93,7 +93,7 @@ module MrMurano
|
|
93
93
|
# Most of these pull into ram. So maybe just go with that. Would guess that
|
94
94
|
# truely large static content is rare, and we can optimize/fix that later.
|
95
95
|
|
96
|
-
file = HTTP::FormData::File.new(local.to_s, {:
|
96
|
+
file = HTTP::FormData::File.new(local.to_s, {:content_type=>remote[:mime_type]})
|
97
97
|
form = HTTP::FormData.create(:file=>file)
|
98
98
|
req = Net::HTTP::Put.new(uri)
|
99
99
|
set_def_headers(req)
|
@@ -10,6 +10,10 @@ module MrMurano
|
|
10
10
|
def query(query)
|
11
11
|
call(:query, :post, {:sql=>query})
|
12
12
|
end
|
13
|
+
|
14
|
+
def queries(query)
|
15
|
+
call(:queries, :post, {:sql=>query})
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
@@ -17,11 +21,23 @@ command :postgresql do |c|
|
|
17
21
|
c.syntax = %{murano postgresql <SQL Commands>}
|
18
22
|
c.summary = %{Query the relational database}
|
19
23
|
|
24
|
+
c.option '-f', '--file FILE', %{File of SQL commands}
|
20
25
|
c.option '-o', '--output FILE', %{Download to file instead of STDOUT}
|
21
26
|
|
22
27
|
c.action do |args,options|
|
23
28
|
pg = MrMurano::Postgresql.new
|
24
|
-
|
29
|
+
if options.file then
|
30
|
+
sqls = File.read(options.file)
|
31
|
+
|
32
|
+
ret = pg.queries sqls
|
33
|
+
else
|
34
|
+
ret = pg.query args.join(' ')
|
35
|
+
end
|
36
|
+
|
37
|
+
unless ret[:error].nil? then
|
38
|
+
pg.error "Returned error: #{ret[:error]}"
|
39
|
+
exit 1
|
40
|
+
end
|
25
41
|
|
26
42
|
io=nil
|
27
43
|
if options.output then
|
@@ -29,6 +45,7 @@ command :postgresql do |c|
|
|
29
45
|
end
|
30
46
|
|
31
47
|
pg.outf(ret, io) do |dd, ios|
|
48
|
+
dd = dd[:result]
|
32
49
|
pg.tabularize({
|
33
50
|
:headers=>dd[:columns],
|
34
51
|
:rows=>dd[:rows]
|
@@ -38,4 +55,101 @@ command :postgresql do |c|
|
|
38
55
|
|
39
56
|
end
|
40
57
|
end
|
58
|
+
|
59
|
+
command 'postgresql migrate' do |c|
|
60
|
+
c.syntax = %{murano postgresql migrate (up|down) <level>}
|
61
|
+
c.summary = %{Run database migration scripts.
|
62
|
+
|
63
|
+
|
64
|
+
The names of the script files must be in the "<level>-<name>-<up|down>.sql"
|
65
|
+
format.
|
66
|
+
|
67
|
+
The current version of the migrations (last <level> ran) will be stored in an
|
68
|
+
extra table in your database. (__murano_cli_migrate__)
|
69
|
+
|
70
|
+
}
|
71
|
+
|
72
|
+
c.option '--dir DIR', %{Directory where migrations live}
|
73
|
+
|
74
|
+
c.action do |args,options|
|
75
|
+
options.default :dir => File.join($cfg['location.base'], 'sql-migrations')
|
76
|
+
|
77
|
+
direction = args.shift
|
78
|
+
if direction =~ /down/i then
|
79
|
+
direction = 'down'
|
80
|
+
else
|
81
|
+
direction = 'up'
|
82
|
+
end
|
83
|
+
|
84
|
+
want_version = args.first
|
85
|
+
|
86
|
+
pg = MrMurano::Postgresql.new
|
87
|
+
|
88
|
+
# get current version of DB.
|
89
|
+
ret = pg.queries %{
|
90
|
+
CREATE TABLE IF NOT EXISTS __murano_cli_migrate__ (version integer);
|
91
|
+
SELECT version FROM __murano_cli_migrate__;
|
92
|
+
}.gsub(/^\s+/,'')
|
93
|
+
unless ret[:error].nil? then
|
94
|
+
pp ret
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
pg.debug "create/select: #{ret}"
|
98
|
+
current_version = (((((ret[:result] or []).last or {})[:rows] or []).first or []).first or 0).to_i
|
99
|
+
|
100
|
+
# Get migrations
|
101
|
+
migrations = Dir[File.join(options.dir, "*-#{direction}.sql")].sort
|
102
|
+
if migrations.empty? then
|
103
|
+
pg.error "No migrations to run."
|
104
|
+
exit 1
|
105
|
+
end
|
106
|
+
migrations.reverse! if direction == 'down'
|
107
|
+
|
108
|
+
if want_version.nil? then
|
109
|
+
want_version, _ = File.basename(migrations.last).split('-')
|
110
|
+
end
|
111
|
+
want_version = want_version.to_i
|
112
|
+
pg.verbose "Will migrate from version #{current_version} to #{want_version}"
|
113
|
+
if direction == 'down' then
|
114
|
+
if want_version >= current_version then
|
115
|
+
say "Nothing to do."
|
116
|
+
exit 0
|
117
|
+
end
|
118
|
+
else
|
119
|
+
if want_version <= current_version then
|
120
|
+
say "Nothing to do."
|
121
|
+
exit 0
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Select migrations between current and desired
|
126
|
+
migrations.select! do |m|
|
127
|
+
mvrs, _ = File.basename(m).split('-')
|
128
|
+
mvrs = mvrs.to_i
|
129
|
+
mvrs > current_version and mvrs <= want_version
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
# Run migrations.
|
134
|
+
migrations.each do |m|
|
135
|
+
mvrs, _ = File.basename(m).split('-')
|
136
|
+
pg.verbose "Running migration: #{File.basename(m)}"
|
137
|
+
unless $cfg['tool.dry'] then
|
138
|
+
pg.query 'BEGIN;'
|
139
|
+
ret = pg.queries File.read(m)
|
140
|
+
unless ret[:error].nil? then
|
141
|
+
pg.query 'ROLLBACK;'
|
142
|
+
pg.error "Migrations failed at level #{mvrs}"
|
143
|
+
pg.error "Because: #{ret[:error]}"
|
144
|
+
exit 5
|
145
|
+
else
|
146
|
+
pg.queries %{INSERT INTO __murano_cli_migrate__ values (#{mvrs});
|
147
|
+
DELETE FROM __murano_cli_migrate__ WHERE version <> #{mvrs};
|
148
|
+
COMMIT;}.gsub(/^\s+/,'')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
41
155
|
# vim: set ai et sw=2 ts=2 :
|
@@ -33,6 +33,7 @@ command 'product device read' do |c|
|
|
33
33
|
|
34
34
|
end
|
35
35
|
end
|
36
|
+
alias_command 'device list', 'product device list'
|
36
37
|
|
37
38
|
command 'product device twee' do |c|
|
38
39
|
c.syntax = %{murano product device twee <identifier>}
|
@@ -64,6 +65,7 @@ command 'product device twee' do |c|
|
|
64
65
|
io.close unless io.nil?
|
65
66
|
end
|
66
67
|
end
|
68
|
+
alias_command 'device twee', 'product device twee'
|
67
69
|
|
68
70
|
command 'product device delete' do |c|
|
69
71
|
c.syntax = %{murano product device delete <identifier>}
|
@@ -77,6 +79,7 @@ command 'product device delete' do |c|
|
|
77
79
|
prd.outf ret unless ret.empty?
|
78
80
|
end
|
79
81
|
end
|
82
|
+
alias_command 'device delete', 'product device delete'
|
80
83
|
|
81
84
|
# XXX cannot call this here, since 'sn list' doesn't exist yet.
|
82
85
|
#alias_command 'product device list', 'sn list'
|
@@ -25,6 +25,7 @@ command 'product device list' do |c|
|
|
25
25
|
io.close unless io.nil?
|
26
26
|
end
|
27
27
|
end
|
28
|
+
alias_command 'device list', 'product device list'
|
28
29
|
|
29
30
|
command 'product device enable' do |c|
|
30
31
|
c.syntax = %{murano product device enable [<sn>|--file <sns>]}
|
@@ -52,6 +53,7 @@ the activation call within this time, it will need to be enabled again.
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
56
|
+
alias_command 'device enable', 'product device enable'
|
55
57
|
|
56
58
|
command 'product device activate' do |c|
|
57
59
|
c.syntax = %{murano product device activate <sn>}
|
@@ -78,6 +80,7 @@ CIK again.
|
|
78
80
|
|
79
81
|
end
|
80
82
|
end
|
83
|
+
alias_command 'device activate', 'product device activate'
|
81
84
|
|
82
85
|
alias_command 'sn list', 'product device list'
|
83
86
|
alias_command 'sn enable', 'product device enable'
|
data/lib/MrMurano/http.rb
CHANGED
@@ -7,7 +7,8 @@ module MrMurano
|
|
7
7
|
module Http
|
8
8
|
def token
|
9
9
|
return @token unless @token.nil?
|
10
|
-
|
10
|
+
acc = Account.new
|
11
|
+
@token = acc.token
|
11
12
|
raise "Not logged in!" if @token.nil?
|
12
13
|
@token
|
13
14
|
end
|
@@ -108,6 +109,12 @@ module MrMurano
|
|
108
109
|
end
|
109
110
|
else
|
110
111
|
showHttpError(request, response)
|
112
|
+
return {} if response.body.nil?
|
113
|
+
begin
|
114
|
+
return JSON.parse(response.body, json_opts)
|
115
|
+
rescue
|
116
|
+
return response.body
|
117
|
+
end
|
111
118
|
end
|
112
119
|
end
|
113
120
|
end
|
data/lib/MrMurano/version.rb
CHANGED
data/lib/MrMurano.rb
CHANGED
data/spec/Http_spec.rb
CHANGED
@@ -191,7 +191,7 @@ RSpec.describe MrMurano::Http do
|
|
191
191
|
idhttp = instance_double('Net::HTTP')
|
192
192
|
expect(idhttp).to receive(:request).once.and_return(@rsp)
|
193
193
|
expect(@tst).to receive(:http).once.and_return(idhttp)
|
194
|
-
expect(@rsp).to receive(:body).and_return(%{{"statusCode": 123, "message": "gone"}})
|
194
|
+
expect(@rsp).to receive(:body).exactly(3).times.and_return(%{{"statusCode": 123, "message": "gone"}})
|
195
195
|
|
196
196
|
@tst.workit(@req)
|
197
197
|
expect($stdout.string).to eq('')
|
data/spec/cmd_common.rb
CHANGED
@@ -45,18 +45,6 @@ RSpec.shared_context "CI_CMD" do
|
|
45
45
|
ENV['HOME'] = hdir
|
46
46
|
Dir.chdir(hdir) do
|
47
47
|
Dir.mkdir('.murano')
|
48
|
-
unless ENV['MURANO_USER'].nil? then
|
49
|
-
File.open(File.join('.murano', 'config'), 'a') do |io|
|
50
|
-
io << "[user]\n"
|
51
|
-
io << "name = #{ENV['MURANO_USER']}\n"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
unless ENV['MURANO_BUSINESS'].nil? then
|
55
|
-
File.open(File.join('.murano', 'config'), 'a') do |io|
|
56
|
-
io << "[business]\n"
|
57
|
-
io << "id = #{ENV['MURANO_BUSINESS']}\n"
|
58
|
-
end
|
59
|
-
end
|
60
48
|
@tmpdir = File.join(hdir, 'project')
|
61
49
|
Dir.mkdir(@tmpdir)
|
62
50
|
Dir.chdir(@tmpdir) do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open3'
|
3
|
+
require 'pathname'
|
4
|
+
require 'cmd_common'
|
5
|
+
|
6
|
+
RSpec.describe 'murano help', :cmd do
|
7
|
+
include_context "CI_CMD"
|
8
|
+
|
9
|
+
it "no args" do
|
10
|
+
out, err, status = Open3.capture3(capcmd('murano'))
|
11
|
+
expect(err).to eq('')
|
12
|
+
expect(out).to_not eq('')
|
13
|
+
expect(status.exitstatus).to eq(0)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "as --help" do
|
17
|
+
out, err, status = Open3.capture3(capcmd('murano', '--help'))
|
18
|
+
expect(err).to eq('')
|
19
|
+
expect(out).to_not eq('')
|
20
|
+
expect(status.exitstatus).to eq(0)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
# vim: set ai et sw=2 ts=2 :
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MuranoCLI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Conrad Tadpol Tilstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -268,6 +268,7 @@ files:
|
|
268
268
|
- lib/MrMurano/Product-Resources.rb
|
269
269
|
- lib/MrMurano/Product.rb
|
270
270
|
- lib/MrMurano/ProjectFile.rb
|
271
|
+
- lib/MrMurano/ReCommander.rb
|
271
272
|
- lib/MrMurano/Solution-Cors.rb
|
272
273
|
- lib/MrMurano/Solution-Endpoint.rb
|
273
274
|
- lib/MrMurano/Solution-File.rb
|
@@ -357,6 +358,7 @@ files:
|
|
357
358
|
- spec/cmd_cors_spec.rb
|
358
359
|
- spec/cmd_device_spec.rb
|
359
360
|
- spec/cmd_domain_spec.rb
|
361
|
+
- spec/cmd_help_spec.rb
|
360
362
|
- spec/cmd_init_spec.rb
|
361
363
|
- spec/cmd_keystore_spec.rb
|
362
364
|
- spec/cmd_password_spec.rb
|
@@ -457,6 +459,7 @@ test_files:
|
|
457
459
|
- spec/cmd_cors_spec.rb
|
458
460
|
- spec/cmd_device_spec.rb
|
459
461
|
- spec/cmd_domain_spec.rb
|
462
|
+
- spec/cmd_help_spec.rb
|
460
463
|
- spec/cmd_init_spec.rb
|
461
464
|
- spec/cmd_keystore_spec.rb
|
462
465
|
- spec/cmd_password_spec.rb
|