asperalm 0.9.11 → 0.9.12

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: 1a6cf473c810fe0c64733145c6460779125753f5
4
- data.tar.gz: 2119cec80ceb9e44586032f259410546abdb0cb3
3
+ metadata.gz: 60b4d6f70bd2b0c32afd7f177c3517ae37ba1860
4
+ data.tar.gz: c95ef609b130421619c59e8b90940003c1b0a93e
5
5
  SHA512:
6
- metadata.gz: 1abd5f6e953ad01e662828b57844e65062f0867de12580e3bcaae3bb1ce154f9166445a5c2eef3d2d724888db0b8521fad49b5d379c9e0525111687305f1bd92
7
- data.tar.gz: 1f8b8d2b4668d951e9a08e582d5eed601868568537dbe24171ab3933151298876d523a522fbecd7f5ce75f0dd8e8a81a2f175b3e810ae2e9a9d65ddb46a9a1a9
6
+ metadata.gz: b57f25b29420d477cd93be8ed12fc62809cabbd81eee5a06fcd55331c89c7b27c3459d28f641b072e186913c70abe3964b75a66ceb9f440b95f6c4d690ac37bd
7
+ data.tar.gz: 589ab31530fcb8676257d915eb2a84d22a75f4c8fda95519b3b580012690dfc6347e936a427bd5ee76ae425ba68535fffe79ce147fb2f16b9b1b331ddd9487e0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Asperalm - A Ruby library for Aspera transfers and "Amelia", the _Multi Layer IBM Aspera_ Command Line Tool
2
2
 
3
- Version : 0.9.11
3
+ Version : 0.9.12
4
4
 
5
5
 
6
6
  _Laurent/2016-2018_
@@ -37,7 +37,7 @@ Once the gem is installed, `mlia` shall be accessible:
37
37
 
38
38
  ```bash
39
39
  $ mlia --version
40
- 0.9.11
40
+ 0.9.12
41
41
  ```
42
42
 
43
43
  ## First use
@@ -913,9 +913,13 @@ A non complete list of commands used in unit tests:
913
913
  ```bash
914
914
  mlia
915
915
  mlia --no-default node --url=my_url_here --username=my_username_here --password=my_password_here --insecure=yes delete /500M.dat
916
- mlia --no-default node --url=my_url_here --username=my_username_here --password=my_password_here --insecure=yes upload --to-folder=/ --sources=@ts --ts=@json:'{"paths":[{"source":"500M.dat"}],"precalculate_job_size":true}' --transfer=node --transfer-info=@json:'{"url":"my_url_here","username":"my_username_here","password":"my_password_here"}'
916
+ mlia --no-default node --url=my_url_here --username=my_username_here --password=my_password_here --insecure=yes upload --to-folder=/Upload --sources=@ts --ts=@json:'{"paths":[{"source":"500M.dat"}],"remote_password":"demoaspera","precalculate_job_size":true}' --transfer=node --transfer-info=@json:'{"url":"my_url_here","username":"my_username_here","password":"my_password_here"}'
917
917
  mlia --version)
918
918
  mlia --version` TOOLNAME=$(EXENAME) erb README.erb.md > README.md
919
+ mlia -N server --url=my_url_here --username=my_username_here --password=my_password_here --format=nagios nagios transfer --to-folder=/Upload
920
+ mlia -N server --url=my_url_here --username=my_username_here --ssh-keys=~/.ssh/id_rsa --format=nagios nagios app_services
921
+ mlia -N server --url=my_url_here --username=my_username_here --ssh-keys=~/.ssh/id_rsa ctl all:status
922
+ mlia -N server --url=my_url_here --username=my_username_here --ssh-keys=~/.ssh/id_rsa nodeadmin -- -l
919
923
  mlia -Pnode_lmdk08 --url=my_url_here --username=my_username_here node acc create --value=@json:'{"id":"aoc_1","secret":"_my_pass_","storage":{"type":"local","path":"/"}}'
920
924
  mlia -Pnode_lmdk08 --url=my_url_here --username=my_username_here node acc delete --id=aoc_1
921
925
  mlia -h
@@ -957,14 +961,13 @@ mlia ats access_key --id=testkey3 delete
957
961
  mlia ats access_key create --cloud=aws --region=eu-west-1 --params=@json:'{"id":"testkey3","name":"laurent key AWS","storage":{"type":"aws_s3","bucket":"sedemo-ireland","credentials":{"access_key_id":"my_access_key_id_here","secret_access_key":"my_secret_access_key_here"},"path":"/laurent"}}'
958
962
  mlia ats access_key create --cloud=softlayer --region=ams --params=@json:'{"id":"testkey2","name":"laurent key","storage":{"type":"softlayer_swift","container":"laurent","credentials":{"api_key":"my_api_key_here","username":"my_username_here"},"path":"/"}}'
959
963
  mlia ats access_key list --fields=name,id,secret
964
+ mlia ats api_key create
965
+ mlia ats api_key instances
966
+ mlia ats api_key list
960
967
  mlia ats cluster clouds
961
968
  mlia ats cluster list
962
969
  mlia ats cluster show --cloud=aws --region=eu-west-1
963
970
  mlia ats cluster show --id=1f412ae7-869a-445c-9c05-02ad16813be2
964
- mlia ats credential cache list
965
- mlia ats credential info
966
- mlia ats credential list
967
- mlia ats credential subscriptions
968
971
  mlia client available
969
972
  mlia client connect id 'Aspera Connect for Windows' info
970
973
  mlia client connect id 'Aspera Connect for Windows' links id 'Windows Installer' download --to-folder=.
@@ -972,6 +975,7 @@ mlia client connect id 'Aspera Connect for Windows' links list
972
975
  mlia client connect list
973
976
  mlia client current
974
977
  mlia conf wiz https://sedemo.ibmaspera.com --config-file=todelete.txt --client-id=$(HIDE_CLIENT_ID) --client-secret=$(HIDE_CLIENT_SECRET)
978
+ mlia config export
975
979
  mlia config genkey sample_dest_folder/mykey
976
980
  mlia config id conf_name delete
977
981
  mlia config id conf_name initialize @json:'{"p1":"v1","p2":"v2"}'
@@ -984,6 +988,7 @@ mlia config open
984
988
  mlia config overview
985
989
  mlia config plugins
986
990
  mlia console transfer current list
991
+ mlia faspex nagios_check
987
992
  mlia faspex package list
988
993
  mlia faspex package list --fields=delivery_id --format=csv --box=sent|tail -n 1) --box=sent
989
994
  mlia faspex package recv --to-folder=sample_dest_folder --id=ALL --once-only=yes
@@ -997,6 +1002,7 @@ mlia node browse / -r
997
1002
  mlia node delete sample_dest_folder200KB.1
998
1003
  mlia node download --to-folder=sample_dest_folder --sources=@args sample_dest_folder200KB.1
999
1004
  mlia node info
1005
+ mlia node nagios_check
1000
1006
  mlia node service --id=service1 delete
1001
1007
  mlia node service create @json:'{"id":"service1","type":"WATCHD","run_as":{"user":"user1"}}'
1002
1008
  mlia node service list
@@ -1051,19 +1057,18 @@ mlia sync start --parameters=@json:'{"sessions":[{"name":"test","reset":true,"re
1051
1057
  ```bash
1052
1058
  $ mlia -h
1053
1059
  NAME
1054
- mlia -- a command line tool for Aspera Applications (v0.9.11)
1060
+ mlia -- a command line tool for Aspera Applications (v0.9.12)
1055
1061
 
1056
1062
  SYNOPSIS
1057
1063
  mlia COMMANDS [OPTIONS] [ARGS]
1058
1064
 
1059
1065
  DESCRIPTION
1060
1066
  Use Aspera application to perform operations on command line.
1061
- OAuth 2.0 is used for authentication in Files, Several authentication methods are provided.
1062
1067
  Documentation and examples: https://rubygems.org/gems/asperalm
1063
1068
  execute: mlia conf doc
1064
1069
 
1065
1070
  COMMANDS
1066
- First level commands: config
1071
+ First level commands:
1067
1072
  Note that commands can be written shortened (provided it is unique).
1068
1073
 
1069
1074
  OPTIONS
@@ -1075,20 +1080,20 @@ ARGS
1075
1080
  Some commands require mandatory arguments, e.g. a path.
1076
1081
 
1077
1082
  OPTIONS: global
1078
- --interactive=ENUM use interactive input of missing params: yes, no
1079
- --ask-options=ENUM ask even optional options: yes, no
1080
1083
  --table-style=VALUE table display style, current=:.:
1081
1084
  -h, --help Show this message.
1082
1085
  --show-config Display parameters used for the provided action.
1083
1086
  -r, --rest-debug more debug for HTTP calls
1084
1087
  -v, --version display version
1085
1088
  --display=ENUM output only some information: info, data, error
1089
+ --interactive=ENUM use interactive input of missing params: yes, no
1090
+ --ask-options=ENUM ask even optional options: yes, no
1086
1091
  --config-file=VALUE read parameters from file in YAML format, current=/Users/laurent/.aspera/mlia/config.yaml
1087
1092
  -N, --no-default do not load default configuration for plugin
1088
1093
  --ui=ENUM method to start browser: text, graphical
1089
1094
  --log-level=ENUM Log level: debug, info, warn, error, fatal, unknown
1090
1095
  --logger=ENUM log method: stderr, stdout, syslog
1091
- --format=ENUM output format: table, ruby, json, jsonpp, yaml, csv
1096
+ --format=ENUM output format: table, ruby, json, jsonpp, yaml, csv, nagios
1092
1097
  -P, --presetVALUE load the named option preset from current config file
1093
1098
  --fields=VALUE comma separated list of fields, or ALL, or DEF
1094
1099
  --select=VALUE select only some items in lists, extended value: hash (colum, value)
@@ -1117,7 +1122,7 @@ OPTIONS:
1117
1122
  --password=VALUE user's password
1118
1123
 
1119
1124
  COMMAND: node
1120
- SUBCOMMANDS: events, space, info, mkdir, mklink, mkfile, rename, delete, browse, upload, download, postprocess, stream, transfer, cleanup, forward, access_key, watch_folder, service, async, central, asperabrowser
1125
+ SUBCOMMANDS: nagios_check, events, space, info, mkdir, mklink, mkfile, rename, delete, browse, upload, download, postprocess, stream, transfer, cleanup, forward, access_key, watch_folder, service, async, central, asperabrowser
1121
1126
  OPTIONS:
1122
1127
  --url=VALUE URL of application, e.g. https://org.asperafiles.com
1123
1128
  --username=VALUE username to log in
@@ -1138,7 +1143,10 @@ OPTIONS:
1138
1143
  COMMAND: aspera
1139
1144
  SUBCOMMANDS: apiinfo, packages, files, faspexgw, admin, user, organization, workspace
1140
1145
  OPTIONS:
1141
- --ats-id=VALUE ATS key identifier (ats_xxx)
1146
+ --ibm-api-key=VALUE IBM API key, see https://console.bluemix.net/iam/#/apikeys
1147
+ --instance=VALUE ATS instance in bluemix
1148
+ --ats-key=VALUE ATS key identifier (ats_xxx)
1149
+ --ats-secret=VALUE ATS key secret
1142
1150
  --params=VALUE Parameters access key creation (@json:)
1143
1151
  --cloud=VALUE Cloud provider
1144
1152
  --region=VALUE Cloud region
@@ -1171,10 +1179,13 @@ OPTIONS:
1171
1179
  --filter-file=VALUE Ruby expression for filter at file level (cleanup)
1172
1180
 
1173
1181
  COMMAND: ats
1174
- SUBCOMMANDS: cluster, access_key
1182
+ SUBCOMMANDS: cluster, access_key, api_key
1175
1183
  OPTIONS:
1176
1184
  --secret=VALUE Access key secret
1177
- --ats-id=VALUE ATS key identifier (ats_xxx)
1185
+ --ibm-api-key=VALUE IBM API key, see https://console.bluemix.net/iam/#/apikeys
1186
+ --instance=VALUE ATS instance in bluemix
1187
+ --ats-key=VALUE ATS key identifier (ats_xxx)
1188
+ --ats-secret=VALUE ATS key secret
1178
1189
  --params=VALUE Parameters access key creation (@json:)
1179
1190
  --cloud=VALUE Cloud provider
1180
1191
  --region=VALUE Cloud region
@@ -1184,7 +1195,7 @@ SUBCOMMANDS: current, available, connect
1184
1195
  OPTIONS:
1185
1196
 
1186
1197
  COMMAND: faspex
1187
- SUBCOMMANDS: package, source, me, dropbox, recv_publink, v4, address_book
1198
+ SUBCOMMANDS: nagios_check, package, source, me, dropbox, recv_publink, v4, address_book, login_methods
1188
1199
  OPTIONS:
1189
1200
  --url=VALUE URL of application, e.g. https://org.asperafiles.com
1190
1201
  --username=VALUE username to log in
@@ -1245,15 +1256,15 @@ OPTIONS:
1245
1256
  --session-name=VALUE name of session to use for admin commands, by default first one
1246
1257
 
1247
1258
  COMMAND: server
1248
- SUBCOMMANDS: nodeadmin, userdata, configurator, download, upload, browse, delete, rename, ls, rm, mv, du, info, mkdir, cp, df, md5sum
1259
+ SUBCOMMANDS: nagios, nodeadmin, userdata, configurator, ctl, download, upload, browse, delete, rename, ls, rm, mv, du, info, mkdir, cp, df, md5sum
1249
1260
  OPTIONS:
1250
1261
  --url=VALUE URL of application, e.g. https://org.asperafiles.com
1251
1262
  --username=VALUE username to log in
1252
1263
  --password=VALUE user's password
1253
- --ssh-keys=VALUE PATH_ARRAY is @json:'["path1","path2"]'
1264
+ --ssh-keys=VALUE one ssh key at a time
1254
1265
 
1255
1266
  COMMAND: console
1256
- SUBCOMMANDS: transfer
1267
+ SUBCOMMANDS: transfer, nagios_check
1257
1268
  OPTIONS:
1258
1269
  --url=VALUE URL of application, e.g. https://org.asperafiles.com
1259
1270
  --username=VALUE username to log in
@@ -1931,21 +1942,49 @@ Aspera Shares supports the "node API" for the file transfer part. (Shares 1 and
1931
1942
 
1932
1943
  ## Aspera Transfer Service
1933
1944
 
1934
- Note that ATS is now part of Aspera on Cloud.
1945
+ ATS is usable either :
1946
+
1947
+ * from an AoC subscription : mlia aspera admin ats
1948
+
1949
+ * or from an IBM Cloud (bluemix) subscription : mlia ats
1935
1950
 
1936
- ### First time use
1951
+ ### IBM Cloud ATS : creation of api key
1937
1952
 
1938
- Using the ATS requires an "Aspera ID" (https://id.asperasoft.com/) and have a subscription associated to it.
1953
+ First get your IBM Cloud APIkey, as described here:
1954
+ [https://console.bluemix.net/docs/iam/userid_keys.html#userapikey](https://console.bluemix.net/docs/iam/userid_keys.html#userapikey)
1939
1955
 
1940
- On first execution, the user is asked to login to Aspera ID using a web browser. This creates an "ats_id" identifier (stored in a cache file).
1956
+ Execute:
1941
1957
 
1942
- When only one ats_id is created, it is taken by default. Else it shall be specified with --ats-id or using a [option preset](#lprt).
1958
+ ```
1959
+ $ mlia config id my_ibm_ats update --ibm-api-key=XXXX
1960
+ $ mlia config id default set ats my_ibm_ats
1961
+ $ mlia ats api_key instances
1962
+ :......................................:
1963
+ : instance :
1964
+ :......................................:
1965
+ : aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee :
1966
+ :......................................:
1967
+ $ mlia config id my_ibm_ats update --instance=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee
1968
+ $ mlia ats api_key create --ibm-api-key=XXXX --instance
1969
+ :......................................:
1970
+ : instance :
1971
+ :......................................:
1972
+ : aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee :
1973
+ :......................................:
1974
+ $ mlia ats api_key create
1975
+ :........:..............................................:
1976
+ : key : value :
1977
+ :........:..............................................:
1978
+ : id : ats_XXXXXXXXXXXXXXXXXXXXXXXX :
1979
+ : secret : YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY :
1980
+ :........:..............................................:
1981
+ $ mlia config id my_ibm_ats update --ats-key=ats_XXXXXXXXXXXXXXXXXXXXXXXX --ats-secret=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
1982
+ ```
1943
1983
 
1944
1984
  Note: access key API is described here: [https://ibm.ibmaspera.com/helpcenter/transfer-service](https://ibm.ibmaspera.com/helpcenter/transfer-service)
1945
1985
 
1946
1986
  and here: [https://developer.asperasoft.com/web/node/access-keys](https://developer.asperasoft.com/web/node/access-keys)
1947
1987
 
1948
-
1949
1988
  ### Examples
1950
1989
 
1951
1990
  Example: create access key on softlayer:
@@ -2319,9 +2358,15 @@ Gems, or remove your ed25519 key from your `.ssh` folder to solve the issue.
2319
2358
 
2320
2359
  # Release Notes
2321
2360
 
2361
+ * version 0.9.12
2362
+
2363
+ * add nagios commands
2364
+ * support of ATS for IBM Cloud, removed old version based on aspera id
2365
+
2322
2366
  * version 0.9.11
2323
2367
 
2324
2368
  * Breaking change: @stdin is now @stdin:
2369
+ * support of ATS for IBM Cloud, removed old version based on aspera id
2325
2370
 
2326
2371
 
2327
2372
  * version 0.9.10
data/lib/asperalm/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.11
1
+ 0.9.12
@@ -0,0 +1,41 @@
1
+ require 'asperalm/log'
2
+ require 'asperalm/rest'
3
+
4
+ module Asperalm
5
+ class AtsApi < Rest
6
+ # currently supported clouds
7
+ # Note to Aspera: shall be an API call
8
+ @@CLOUD_NAME={
9
+ :aws =>'Amazon Web Services',
10
+ :azure =>'Microsoft Azure',
11
+ :google =>'Google Cloud',
12
+ :limelight =>'Limelight',
13
+ :rackspace =>'Rackspace',
14
+ :softlayer =>'IBM Cloud'
15
+ }
16
+
17
+ def self.base_url;'https://ats.aspera.io';end
18
+
19
+ def initialize
20
+ super({:base_url=>AtsApi.base_url+'/pub/v1'})
21
+ # cache of server data
22
+ @all_servers_cache=nil
23
+ end
24
+
25
+ def cloud_names;@@CLOUD_NAME;end
26
+
27
+ # all available ATS servers
28
+ # NOTE to Aspera: an API shall be created to retrieve all servers at once
29
+ def all_servers
30
+ if @all_servers_cache.nil?
31
+ @all_servers_cache=[]
32
+ @@CLOUD_NAME.keys.each do |name|
33
+ read("servers/#{name.to_s.upcase}")[:data].each do |i|
34
+ @all_servers_cache.push(i)
35
+ end
36
+ end
37
+ end
38
+ return @all_servers_cache
39
+ end
40
+ end # AtsApi
41
+ end # Asperalm
@@ -8,6 +8,7 @@ require 'asperalm/persistency_file'
8
8
  require 'asperalm/log'
9
9
  require 'asperalm/rest'
10
10
  require 'asperalm/files_api'
11
+ require 'asperalm/nagios'
11
12
  require 'text-table'
12
13
  require 'fileutils'
13
14
  require 'singleton'
@@ -25,6 +26,7 @@ module Asperalm
25
26
  File.read(File.join(gem_root,@@GEM_NAME,'VERSION')).chomp
26
27
  end
27
28
 
29
+ attr_reader :plugin_env
28
30
  private
29
31
  # name of application, also foldername where config is stored
30
32
  @@PROGRAM_NAME = 'mlia'
@@ -76,22 +78,21 @@ module Asperalm
76
78
  @plugin_env[:transfer]=@transfer_mgr
77
79
  @config_plugin=Plugins::Config.new(@plugin_env,self.program_name,@@GEM_NAME,self.class.gem_version)
78
80
  @plugin_env[:config]=@config_plugin
81
+ # set application folder for modules
82
+ PersistencyFile.default_folder=@config_plugin.main_folder
79
83
  Oauth.persistency_folder=@config_plugin.main_folder
80
84
  ExtendedValue.instance.set_handler('preset',:reader,lambda{|v|@config_plugin.preset_by_name(v)})
81
- # set folders for temp files
82
85
  Fasp::Parameters.file_list_folder=File.join(@config_plugin.main_folder,'filelists')
83
- PersistencyFile.default_folder=@config_plugin.main_folder
84
86
  end
85
87
 
86
88
  # local options
87
- def init_options
89
+ def declare_options_initial
88
90
  @opt_mgr.parser.banner = "NAME\n\t#{self.program_name} -- a command line tool for Aspera Applications (v#{self.class.gem_version})\n\n"
89
91
  @opt_mgr.parser.separator "SYNOPSIS"
90
92
  @opt_mgr.parser.separator "\t#{self.program_name} COMMANDS [OPTIONS] [ARGS]"
91
93
  @opt_mgr.parser.separator ""
92
94
  @opt_mgr.parser.separator "DESCRIPTION"
93
95
  @opt_mgr.parser.separator "\tUse Aspera application to perform operations on command line."
94
- @opt_mgr.parser.separator "\tOAuth 2.0 is used for authentication in Files, Several authentication methods are provided."
95
96
  @opt_mgr.parser.separator "\tDocumentation and examples: #{@config_plugin.gem_url}"
96
97
  @opt_mgr.parser.separator "\texecute: #{self.program_name} conf doc"
97
98
  @opt_mgr.parser.separator ""
@@ -108,7 +109,6 @@ module Asperalm
108
109
  @opt_mgr.parser.separator "\tSome commands require mandatory arguments, e.g. a path.\n"
109
110
  @opt_mgr.parser.separator ""
110
111
  @opt_mgr.parser.separator "OPTIONS: global"
111
- @opt_mgr.declare_options_scan_env
112
112
  @opt_mgr.set_obj_attr(:table_style,self,:option_table_style)
113
113
  @opt_mgr.add_opt_simple(:table_style,"table display style, current=#{@option_table_style}")
114
114
  @opt_mgr.add_opt_switch(:help,"Show this message.","-h") { @option_help=true }
@@ -119,12 +119,12 @@ module Asperalm
119
119
  @opt_mgr.set_option(:display,:info)
120
120
  end
121
121
 
122
- def declare_global_options
122
+ def declare_options_global
123
123
  # handler must be set before declaration
124
124
  @opt_mgr.set_obj_attr(:log_level,Log.instance,:level)
125
+ @opt_mgr.set_obj_attr(:logger,Log.instance,:logger_type)
125
126
  @opt_mgr.set_obj_attr(:insecure,self,:option_insecure,:no)
126
127
  @opt_mgr.set_obj_attr(:flat_hash,self,:option_flat_hash)
127
- @opt_mgr.set_obj_attr(:logger,Log.instance,:logger_type)
128
128
  @opt_mgr.set_obj_attr(:ui,self,:option_ui)
129
129
  @opt_mgr.set_obj_attr(:preset,self,:option_preset)
130
130
  @opt_mgr.set_obj_attr(:use_product,Fasp::Installation.instance,:activated)
@@ -152,17 +152,6 @@ module Asperalm
152
152
  @opt_mgr.set_option(:once_only,:false)
153
153
  end
154
154
 
155
- # loads default parameters of plugin if no -P parameter
156
- # and if there is a section defined for the plugin in the "default" section
157
- # try to find: conffile[conffile["default"][plugin_str]]
158
- # @param plugin_name_sym : symbol for plugin name
159
- def add_plugin_default_preset(plugin_name_sym)
160
- default_config_name=@config_plugin.get_plugin_default_config_name(plugin_name_sym)
161
- Log.log.debug("add_plugin_default_preset:#{plugin_name_sym}:#{default_config_name}")
162
- @opt_mgr.add_option_preset(@config_plugin.preset_by_name(default_config_name),:unshift) unless default_config_name.nil?
163
- return nil
164
- end
165
-
166
155
  # @return the plugin instance, based on name
167
156
  # also loads the plugin options, and default values from conf file
168
157
  # @param plugin_name_sym : symbol for plugin name
@@ -176,7 +165,7 @@ module Asperalm
176
165
  env[:options].parser.separator "OPTIONS:"
177
166
  command_plugin.declare_options
178
167
  # load default params only if no param already loaded
179
- add_plugin_default_preset(plugin_name_sym)
168
+ @config_plugin.add_plugin_default_preset(plugin_name_sym)
180
169
  return command_plugin
181
170
  end
182
171
 
@@ -234,7 +223,7 @@ module Asperalm
234
223
  def self.result_success; return result_status('complete'); end
235
224
 
236
225
  # supported output formats
237
- def self.display_formats; [:table,:ruby,:json,:jsonpp,:yaml,:csv]; end
226
+ def self.display_formats; [:table,:ruby,:json,:jsonpp,:yaml,:csv,:nagios]; end
238
227
 
239
228
  # user output levels
240
229
  def self.display_levels; [:info,:data,:error]; end
@@ -263,25 +252,27 @@ module Asperalm
263
252
  raise "INTERNAL ERROR, result must be Hash (got: #{results.class}: #{results})" unless results.is_a?(Hash)
264
253
  raise "INTERNAL ERROR, result must have type" unless results.has_key?(:type)
265
254
  raise "INTERNAL ERROR, result must have data" unless results.has_key?(:data) or [:empty,:nothing].include?(results[:type])
266
-
255
+ res_data=results[:data]
267
256
  # comma separated list in string format
268
257
  user_asked_fields_list_str=@opt_mgr.get_option(:fields,:mandatory)
269
258
  display_format=@opt_mgr.get_option(:format,:mandatory)
270
259
  case display_format
260
+ when :nagios
261
+ Nagios.process(res_data)
271
262
  when :ruby
272
- display_message(:data,PP.pp(results[:data],''))
263
+ display_message(:data,PP.pp(res_data,''))
273
264
  when :json
274
- display_message(:data,JSON.generate(results[:data]))
265
+ display_message(:data,JSON.generate(res_data))
275
266
  when :jsonpp
276
- display_message(:data,JSON.pretty_generate(results[:data]))
267
+ display_message(:data,JSON.pretty_generate(res_data))
277
268
  when :yaml
278
- display_message(:data,results[:data].to_yaml)
269
+ display_message(:data,res_data.to_yaml)
279
270
  when :table,:csv
280
271
  case results[:type]
281
272
  when :object_list # goes to table display
282
- raise "internal error: unexpected type: #{results[:data].class}, expecting Array" unless results[:data].is_a?(Array)
273
+ raise "internal error: unexpected type: #{res_data.class}, expecting Array" unless res_data.is_a?(Array)
283
274
  # :object_list is an array of hash tables, where key=colum name
284
- table_rows_hash_val = results[:data]
275
+ table_rows_hash_val = res_data
285
276
  final_table_columns=nil
286
277
  if @option_flat_hash
287
278
  new_table_rows_hash_val=[]
@@ -308,9 +299,9 @@ module Asperalm
308
299
  end
309
300
  when :single_object # goes to table display
310
301
  # :single_object is a simple hash table (can be nested)
311
- raise "internal error: unexpected type: #{results[:data].class}, expecting Hash" unless results[:data].is_a?(Hash)
302
+ raise "internal error: unexpected type: #{res_data.class}, expecting Hash" unless res_data.is_a?(Hash)
312
303
  final_table_columns = results[:columns] || ['key','value']
313
- asked_fields=results[:data].keys
304
+ asked_fields=res_data.keys
314
305
  case user_asked_fields_list_str
315
306
  when FIELDS_DEFAULT;asked_fields=results[:fields] if results.has_key?(:fields)
316
307
  when FIELDS_ALL;# keep all
@@ -318,16 +309,16 @@ module Asperalm
318
309
  asked_fields=user_asked_fields_list_str.split(',')
319
310
  end
320
311
  if @option_flat_hash
321
- self.class.flatten_object(results[:data],results[:option_expand_last])
322
- self.class.flatten_name_value_list(results[:data])
312
+ self.class.flatten_object(res_data,results[:option_expand_last])
313
+ self.class.flatten_name_value_list(res_data)
323
314
  # first level keys are potentially changed
324
- asked_fields=results[:data].keys
315
+ asked_fields=res_data.keys
325
316
  end
326
- table_rows_hash_val=asked_fields.map { |i| { final_table_columns.first => i, final_table_columns.last => results[:data][i] } }
317
+ table_rows_hash_val=asked_fields.map { |i| { final_table_columns.first => i, final_table_columns.last => res_data[i] } }
327
318
  when :value_list # goes to table display
328
319
  # :value_list is a simple array of values, name of column provided in the :name
329
320
  final_table_columns = [results[:name]]
330
- table_rows_hash_val=results[:data].map { |i| { results[:name] => i } }
321
+ table_rows_hash_val=res_data.map { |i| { results[:name] => i } }
331
322
  when :empty # no table
332
323
  display_message(:info,'empty')
333
324
  return
@@ -336,15 +327,15 @@ module Asperalm
336
327
  return
337
328
  when :status # no table
338
329
  # :status displays a simple message
339
- display_message(:info,results[:data])
330
+ display_message(:info,res_data)
340
331
  return
341
332
  when :text # no table
342
333
  # :status displays a simple message
343
- display_message(:data,results[:data])
334
+ display_message(:data,res_data)
344
335
  return
345
336
  when :other_struct # no table
346
337
  # :other_struct is any other type of structure
347
- display_message(:data,PP.pp(results[:data],''))
338
+ display_message(:data,PP.pp(res_data,''))
348
339
  return
349
340
  else
350
341
  raise "unknown data type: #{results[:type]}"
@@ -389,8 +380,8 @@ module Asperalm
389
380
  if all_plugins
390
381
  # list plugins that have a "require" field, i.e. all but main plugin
391
382
  @config_plugin.plugins.keys.each do |plugin_name_sym|
392
- next if @config_plugin.plugins[plugin_name_sym][:require_stanza].nil?
393
- # override main option parser with a brand new
383
+ next if plugin_name_sym.eql?(Plugins::Config.name_sym)
384
+ # override main option parser with a brand new, to avoid having global options
394
385
  opt_mgr=Manager.new(self.program_name)
395
386
  opt_mgr.parser.banner = ""
396
387
  get_plugin_instance_with_options(plugin_name_sym,{:options=>opt_mgr})
@@ -432,7 +423,7 @@ module Asperalm
432
423
  def self.result_transfer(transfer_spec,options)
433
424
  # TODO: if not one shot, then wait for status
434
425
  statuses=self.instance.transfer_mgr.start(transfer_spec,options)
435
- raise "at least one transfer session failed" unless TransferAgent.all_session_success(statuses)
426
+ raise "at least one transfer session failed" unless TransferAgent.session_status(statuses).eql?(:success)
436
427
  return Main.result_nothing
437
428
  end
438
429
 
@@ -453,7 +444,8 @@ module Asperalm
453
444
  # give command line arguments to option manager (no parsing)
454
445
  @opt_mgr.add_cmd_line_options(argv)
455
446
  # declare initial options
456
- init_options
447
+ declare_options_initial
448
+ @opt_mgr.declare_options
457
449
  # declare options for config file location
458
450
  @config_plugin.declare_options
459
451
  # parse declared options
@@ -461,7 +453,7 @@ module Asperalm
461
453
  # load default config if it was not overriden on command line
462
454
  @config_plugin.read_config_file
463
455
  # declare general options
464
- declare_global_options
456
+ declare_options_global
465
457
  @transfer_mgr.declare_transfer_options
466
458
  @opt_mgr.parse_options!
467
459
  # find plugins, shall be after parse! ?
@@ -471,7 +463,7 @@ module Asperalm
471
463
  # help requested without command ? (plugins must be known here)
472
464
  exit_with_usage(true) if @option_help and @opt_mgr.command_or_arg_empty?
473
465
  # load global default options and process
474
- add_plugin_default_preset(Plugins::Config.name_sym)
466
+ @config_plugin.add_plugin_default_preset(Plugins::Config.name_sym)
475
467
  @opt_mgr.parse_options!
476
468
  # dual execution locking
477
469
  lock_port=@opt_mgr.get_option(:lock_port,:optional)
@@ -489,6 +481,7 @@ module Asperalm
489
481
  command_sym=@opt_mgr.get_next_command(@config_plugin.plugins.keys.dup.unshift(:help))
490
482
  end
491
483
  # main plugin is not dynamically instanciated
484
+ Log.log.debug(">>>#{Plugins::Config.name_sym.to_s}")
492
485
  case command_sym
493
486
  when :help
494
487
  exit_with_usage(true)
@@ -500,7 +493,7 @@ module Asperalm
500
493
  # parse plugin specific options
501
494
  @opt_mgr.parse_options!
502
495
  end
503
- # help requested ?
496
+ # help requested for current plugin
504
497
  exit_with_usage(false) if @option_help
505
498
  if @option_show_config
506
499
  display_results({:type=>:single_object,:data=>@opt_mgr.declared_options(false)})