cloudstack_client 0.2.16 → 0.3.0

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: 5a54023e0e305d388823c7303ffe6c803c2a59bc
4
- data.tar.gz: ed2dded3f88230f3bbc02b408cf19cf8ab1e30ca
3
+ metadata.gz: 51a94d65a1efd0ff25d7cdbc51627a62d25781b1
4
+ data.tar.gz: 84db0fba9cfa87d85be3f4c1affd7d25fd0b8f0b
5
5
  SHA512:
6
- metadata.gz: 6d49a959f95b0494611ab4acccc30789b0983bcc8da2b16ce835b050db28bbeae581c91818dca0e7a78ffb74329a9725a2d7d305fbbf69ca5afa1b42db976c27
7
- data.tar.gz: 2f95d6a9754c727f2834ed4c246ff82912ad2ea0b21e68bb92be37f5cda07a756ffe45a555a34056bd1aba96f5fdc2937321ffc824dbf1cc91a057b55b59973c
6
+ metadata.gz: ad0b46608886df58b30662b7a895d767504c6aaada4de03020f3ee101903454febd922cc8de87a7f8f5698f679618bd829d6af88b60ce9b65ced48782f99507c
7
+ data.tar.gz: 17b665a3290a0da0c67b5a220b42311f52878884a1b47de69480ef1c57f2800dfad43105be97fee9ea02aebb9ed87e25b164b4bc90294f10f35cb20bfb111bd2
@@ -5,12 +5,20 @@ module CloudstackClient
5
5
  ##
6
6
  # Finds the server with the specified name.
7
7
 
8
- def get_server(name, project_id=nil)
8
+ def get_server(name, args = {})
9
9
  params = {
10
10
  'command' => 'listVirtualMachines',
11
11
  'name' => name
12
12
  }
13
- params['projectid'] = project_id if project_id
13
+ params['projectid'] = args[:project_id] if args[:project_id]
14
+
15
+ if args[:account]
16
+ if account = list_accounts({name: args[:account]}).first
17
+ params['domainid'] = account["domainid"]
18
+ params['account'] = args[:account]
19
+ end
20
+ end
21
+
14
22
  json = send_request(params)
15
23
  machines = json['virtualmachine']
16
24
 
@@ -236,8 +244,8 @@ module CloudstackClient
236
244
  # Stops the server with the specified name.
237
245
  #
238
246
 
239
- def stop_server(name, forced=nil, project_id=nil, async=true)
240
- server = get_server(name, project_id)
247
+ def stop_server(name, args = {})
248
+ server = get_server(name, args)
241
249
  if !server || !server['id']
242
250
  puts "Error: Virtual machine '#{name}' does not exist"
243
251
  exit 1
@@ -247,17 +255,17 @@ module CloudstackClient
247
255
  'command' => 'stopVirtualMachine',
248
256
  'id' => server['id']
249
257
  }
250
- params['forced'] = true if forced
258
+ params['forced'] = true if args[:forced]
251
259
 
252
- async ? send_async_request(params)['virtualmachine'] : send_request(params)
260
+ args[:async] ? send_async_request(params)['virtualmachine'] : send_request(params)
253
261
  end
254
262
 
255
263
  ##
256
264
  # Start the server with the specified name.
257
265
  #
258
266
 
259
- def start_server(name, project_id=nil, async=true)
260
- server = get_server(name, project_id)
267
+ def start_server(name, args = {})
268
+ server = get_server(name, args)
261
269
  if !server || !server['id']
262
270
  puts "Error: Virtual machine '#{name}' does not exist"
263
271
  exit 1
@@ -268,15 +276,15 @@ module CloudstackClient
268
276
  'id' => server['id']
269
277
  }
270
278
 
271
- async ? send_async_request(params)['virtualmachine'] : send_request(params)
279
+ args[:async] ? send_async_request(params)['virtualmachine'] : send_request(params)
272
280
  end
273
281
 
274
282
  ##
275
283
  # Reboot the server with the specified name.
276
284
  #
277
285
 
278
- def reboot_server(name, project_id=nil, async=true)
279
- server = get_server(name, project_id)
286
+ def reboot_server(name, args = {})
287
+ server = get_server(name, args)
280
288
  if !server || !server['id']
281
289
  puts "Error: Virtual machine '#{name}' does not exist"
282
290
  exit 1
@@ -287,7 +295,7 @@ module CloudstackClient
287
295
  'id' => server['id']
288
296
  }
289
297
 
290
- async ? send_async_request(params)['virtualmachine'] : send_request(params)
298
+ args[:async] ? send_async_request(params)['virtualmachine'] : send_request(params)
291
299
  end
292
300
 
293
301
  ##
@@ -299,7 +307,7 @@ module CloudstackClient
299
307
  'command' => 'destroyVirtualMachine',
300
308
  'id' => id
301
309
  }
302
-
310
+
303
311
  async ? send_async_request(params)['virtualmachine'] : send_request(params)
304
312
  end
305
313
 
@@ -1,3 +1,3 @@
1
1
  module CloudstackClient
2
- VERSION = "0.2.16"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudstack_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.16
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nik Wolfgramm