You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(#31) Improve how users can provide arguments to commands
Prior this commit, some commands did not accept some options as an
argument and instead only worked through a flag. This commit updates
that behavior to allow users to specify some options through arguments,
while leaving the ability to continue to specify those options through
flags. Command line arguments take precedence over flags. It also fixes
an issue where if a snapshot sha was nil, it would submit a request to
take a snapshot to vmpooler.
Copy file name to clipboardExpand all lines: lib/vmfloaty.rb
+14-10
Original file line number
Diff line number
Diff line change
@@ -74,7 +74,7 @@ def run
74
74
end
75
75
76
76
command:listdo |c|
77
-
c.syntax='floaty list [hostname]'
77
+
c.syntax='floaty list [options]'
78
78
c.summary='Shows a list of available vms from the pooler'
79
79
c.description=''
80
80
c.example'Filter the list on centos','floaty list centos --url http://vmpooler.example.com'
@@ -117,7 +117,7 @@ def run
117
117
end
118
118
119
119
command:querydo |c|
120
-
c.syntax='floaty query [options]'
120
+
c.syntax='floaty query [hostname] [options]'
121
121
c.summary='Get information about a given vm'
122
122
c.description=''
123
123
c.example'Get information about a sample host','floaty query hostname --url http://vmpooler.example.com'
@@ -134,7 +134,7 @@ def run
134
134
end
135
135
136
136
command:modifydo |c|
137
-
c.syntax='floaty modify [hostname]'
137
+
c.syntax='floaty modify [hostname] [options]'
138
138
c.summary='Modify a vms tags, TTL, and disk space'
139
139
c.description=''
140
140
c.example'Modifies myhost1 to have a TTL of 12 hours and adds a custom tag','floaty modify myhost1 --lifetime 12 --url https://myurl --token mytokenstring --tags \'{"tag":"myvalue"}\''
@@ -254,7 +254,7 @@ def run
254
254
end
255
255
256
256
command:snapshotdo |c|
257
-
c.syntax='floaty snapshot [options]'
257
+
c.syntax='floaty snapshot [hostname] [options]'
258
258
c.summary='Takes a snapshot of a given vm'
259
259
c.description=''
260
260
c.example'Takes a snapshot for a given host','floaty snapshot myvm.example.com --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl'
c.example'Reverts to a snapshot for a given host','floaty revert myvm.example.com --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl --snapshot n4eb4kdtp7rwv4x158366vd9jhac8btq'
279
+
c.example'Reverts to a snapshot for a given host','floaty revert myvm.example.com n4eb4kdtp7rwv4x158366vd9jhac8btq --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl'
280
280
c.option'--verbose','Enables verbose output'
281
281
c.option'--url STRING',String,'URL of vmpooler'
282
282
c.option'--token STRING',String,'Token for vmpooler'
@@ -286,7 +286,11 @@ def run
286
286
url=options.url ||= config['url']
287
287
hostname=args[0]
288
288
token=options.token || config['token']
289
-
snapshot_sha=options.snapshot
289
+
snapshot_sha=args[1] || options.snapshot
290
+
291
+
ifargs[1] && options.snapshot
292
+
STDERR.puts"Two snapshot arguments were given....using snapshot #{snapshot_sha}"
it"doesn't make a request to revert a vm if snapshot is not provided"do
179
+
expect{Pooler.revert(false,@vmpooler_url,'fq6qlpjlsskycq6','mytokenfile',nil)}.toraise_error(RuntimeError,"Snapshot SHA provided was nil, could not revert fq6qlpjlsskycq6")
0 commit comments