File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -126,5 +126,7 @@ Naming convention:
126
126
- ` jaddr <app_name> [unit_num] ` : display app or unit IP address.
127
127
- ` jreld <relation_name> <app_name> <unit_num> ` : display app and unit relation data.
128
128
- ` jclean ` : destroy all controllers
129
+ - ` jcontroller ` : display the controller your are connected to.
130
+ - ` jmodel ` : display the model your are connected to.
129
131
- ` wjst [interval_secs] [args_for_watch] ` : watch juju status, with optional interval
130
132
(default: 5s); you may pass additional arguments to ` watch ` .
Original file line number Diff line number Diff line change @@ -163,10 +163,40 @@ jreld() {
163
163
juju run " relation-get -r $relid - $2 " --unit $2 /$3
164
164
}
165
165
166
+ # Return Juju current controller
167
+ jcontroller () {
168
+ local controller=" $( awk ' /current-controller/ {print $2}' ~ /.local/share/juju/controllers.yaml) "
169
+ if [[ -z " $controller " ]]; then
170
+ return 1
171
+ fi
172
+
173
+ echo $controller
174
+ return 0
175
+ }
176
+
177
+ # Return Juju current model
178
+ jmodel () {
179
+ local yqbin=" $( whereis yq | awk ' {print $2}' ) "
180
+
181
+ if [[ -z " $yqbin " ]]; then
182
+ echo " --"
183
+ return 1
184
+ fi
185
+
186
+ local model=" $( yq e " .controllers.$( jcontroller) .current-model" < ~ /.local/share/juju/models.yaml | cut -d/ -f2) "
187
+
188
+ if [[ -z " $model " ]]; then
189
+ echo " --"
190
+ return 1
191
+ fi
192
+
193
+ echo $model
194
+ return 0
195
+ }
196
+
166
197
# Watch juju status, with optional interval (default: 5 sec)
167
198
wjst () {
168
199
local interval=" ${1:- 5} "
169
200
shift $(( $# > 0 ))
170
201
watch -n " $interval " --color juju status --relations --color " $@ "
171
202
}
172
-
You can’t perform that action at this time.
0 commit comments