ganeti_client 0.0.2 → 0.0.3

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.
data/README CHANGED
@@ -2,28 +2,16 @@
2
2
 
3
3
  1. Manually test the following methods + fix when bugs found
4
4
  1.1. redistribute_config
5
- 1.2. instance_create
6
5
  1.3. instance_delete
7
- 1.4. instance_reboot
8
- 1.5. instance_shutdown
9
- 1.6. instance_startup
10
6
  1.7. instance_reinstall
11
7
  1.8. instance_replace_disks
12
8
  1.9. instance_activate_disks
13
- 1.10. instance_create_tags
14
- 1.11. instance_delete_tags
15
9
  1.13. job_delete
16
- 1.14. node_evaluate
17
10
  1.15. node_migrate
18
11
  1.16. node_change_role
19
12
  1.17. node_get_storage
20
13
  1.18. node_modify_storage
21
14
  1.19. node_repair_storage
22
- 1.20. node_get_tags
23
- 1.21. node_create_tags
24
- 1.22. node_delete_tags
25
- 1.22. tags_create
26
- 1.23. tags_delete
27
15
  2. Add some error handling
28
16
  3. Make some code improvements
29
17
  4. Add better comments
@@ -47,7 +35,7 @@
47
35
 
48
36
  # now you should be able to access the api resources by using the client instance.
49
37
  # example:
50
- info = client.get_info
38
+ info = client.info_get
51
39
  => #<GanetiInfo:0x10151bb78>
52
40
 
53
41
  # most methods return an object. When you use .to_json on an object, you get the json object returned
data/lib/ganeti_client.rb CHANGED
@@ -32,7 +32,7 @@ require 'ganeti_client/client'
32
32
  require 'ganeti_client/ganeti_object'
33
33
 
34
34
 
35
- module GanetiClient
35
+ module Ganeti
36
36
 
37
37
 
38
38
  end
@@ -27,7 +27,7 @@
27
27
  # Copyright:: Copyright (c) 2010 Michaël Rigart
28
28
  # License:: Distributes under AGPL Licence
29
29
 
30
- module GanetiClient
30
+ module Ganeti
31
31
 
32
32
  # This class contains all active resources available in Ganeti RAPI
33
33
  class Client
@@ -85,6 +85,7 @@ module GanetiClient
85
85
  # Array of all available instances. The array items contain a GanetiInstance object
86
86
  def instances_get(bulk = 0)
87
87
  url = get_url("instances", {"bulk" => bulk})
88
+ body = JSON.generate({"bulk" => bulk})
88
89
  response_body = JSON.parse(send_request("GET", url))
89
90
 
90
91
  create_class("GanetiInstance")
@@ -103,12 +104,12 @@ module GanetiClient
103
104
  # excluded to not cause issues with rapi.
104
105
  #
105
106
  # Example:
106
- # info = {
107
- # 'hypervisor' => 'kvm' , 'disk_template' => 'plain',
108
- # 'pnode' => 'node.netronix.be', 'name' => 'vm1.netronix.be', 'os' => 'debootstrap+lucid',
109
- # 'vcpus' => '4', 'memory' => '4096', 'disks' => ['25600'],
110
- # 'kernel-path' => '/boot/vmlinuz-2.6-kvmU'
111
- # }
107
+ # info = {
108
+ # 'hypervisor' => 'kvm' , 'disk_template' => 'plain',
109
+ # 'pnode' => 'node.netronix.be', 'name' => 'vm1.netronix.be', 'os' => 'debootstrap+lucid',
110
+ # 'vcpus' => '4', 'memory' => '4096', 'disks' => [25600],
111
+ # 'kernel-path' => '/boot/vmlinuz-2.6-kvmU'
112
+ # }
112
113
  #
113
114
  # Parameters:
114
115
  # info: hash of data needed for the instance creation
@@ -120,7 +121,7 @@ module GanetiClient
120
121
  params = {
121
122
  'hypervisor' => info['hypervisor'], 'disk_template' => info['disk_template'],
122
123
  'pnode' => info['pnode'], 'name' => info['iname'], 'os' => info['os'],
123
- 'vcpus' => info['vcpus'], 'memory' => info['memory'], 'disks' => [info['size']]
124
+ 'vcpus' => info['vcpus'], 'memory' => info['memory'], 'disks' => info['disks']
124
125
  }
125
126
 
126
127
  # Add secondary node
@@ -202,7 +203,7 @@ module GanetiClient
202
203
  # dry_run: 0|1 (optional)
203
204
  #
204
205
  # Return:
205
- # ?
206
+ # job id
206
207
  def instance_reboot(name, type = "soft", ignore_secondaries = 0, dry_run = 0)
207
208
  url = get_url("instances/#{name}/reboot", {"type" => type, "ignore_secondaries" => ignore_secondaries, "dry_run" => 0})
208
209
  response_body = send_request("POST", url)
@@ -218,12 +219,12 @@ module GanetiClient
218
219
  # dry_run: 0|1 (optional)
219
220
  #
220
221
  # Return:
221
- # ?
222
+ # job id
222
223
  def instance_shutdown(name, dry_run = 0)
223
224
  url = get_url("instances/#{name}/shutdown", {"dry-run" => dry_run})
224
225
  response_body = send_request("PUT", url)
225
226
 
226
- return response_body
227
+ return response_body
227
228
  end
228
229
 
229
230
  # Startup an instance
@@ -235,11 +236,10 @@ module GanetiClient
235
236
  # dry_run: 0|1 (optional)
236
237
  #
237
238
  # Return:
238
- # ?
239
+ # job id
239
240
  def instance_startup(name, force = 0, dry_run=0)
240
241
  url = get_url("instances/#{name}/startup", {"force" => force, "dry-run" => dry_run})
241
- body = "" # force parameter
242
- response_body = send_request("PUT", url, body)
242
+ response_body = send_request("PUT", url)
243
243
 
244
244
  return response_body
245
245
  end
@@ -333,9 +333,9 @@ module GanetiClient
333
333
  # dry_run: 0|1 (optional)
334
334
  #
335
335
  # Return:
336
- # ?
336
+ # job id
337
337
  def instance_create_tags(name, tags, dry_run = 0)
338
- url = get_url("instances/#{name}/tags", {"tags" => tags, "dry-run" => dry_run})
338
+ url = get_url("instances/#{name}/tags", {'dry-run' => dry_run, 'tag' => tags})
339
339
  response_body = send_request("PUT", url)
340
340
 
341
341
  return response_body
@@ -349,9 +349,9 @@ module GanetiClient
349
349
  # dry_run: 0|1 (optional)
350
350
  #
351
351
  # Return:
352
- # ?
352
+ # job id
353
353
  def instance_delete_tags(name, tags, dry_run = 0)
354
- url = get_url("instances/#{name}/tags", {"tags" => tags, "dry-run" => dry_run})
354
+ url = get_url("instances/#{name}/tags", {'dry-run' => dry_run, 'tag' => tags})
355
355
  response_body = send_request("DELETE", url)
356
356
 
357
357
  return response_body
@@ -439,7 +439,7 @@ module GanetiClient
439
439
  # ?
440
440
  def job_delete(job_id)
441
441
  url = get_url("jobs/#{job_id}")
442
- response = send_request("DELETE", url)
442
+ response_body = send_request("DELETE", url)
443
443
 
444
444
  return response_body
445
445
  end
@@ -477,7 +477,10 @@ module GanetiClient
477
477
  # Example:
478
478
  # evacuate?iallocator=[iallocator]
479
479
  # evacuate?remote_node=[nodeX.example.com]
480
- def node_evauate(name, iallocator = "", remote_node = "")
480
+ #
481
+ # Return:
482
+ # job id
483
+ def node_evaluate(name, iallocator = "", remote_node = "")
481
484
  url = get_url("nodes/#{name}/evacuate", {"iallocator" => iallocator, "remote_node" => remote_node})
482
485
  response_body = send_request("POST", url)
483
486
 
@@ -570,9 +573,15 @@ module GanetiClient
570
573
  #
571
574
  # Example:
572
575
  # ["tag1","tag2", "tag3"]
576
+ #
577
+ # Parameters:
578
+ # name: name of node
579
+ #
580
+ # Return:
581
+ # array of tags
573
582
  def node_get_tags(name)
574
583
  url = get_url("nodes/#{name}/tags")
575
- response_body = send_request("GET", url)
584
+ response_body = JSON.parse(send_request("GET", url))
576
585
 
577
586
  return response_body
578
587
  end
@@ -582,8 +591,15 @@ module GanetiClient
582
591
  # It supports the dry-run argument
583
592
  #
584
593
  # The result will be a job id
594
+ #
595
+ # Parameters:
596
+ # name: node name
597
+ # tags: Array of tags
598
+ #
599
+ # Return:
600
+ # job id
585
601
  def node_create_tags(name, tags, dry_run = 0)
586
- url = get_url("nodes/#{name}/tags", {"tags" => tags, "dry-run" => dry_run})
602
+ url = get_url("nodes/#{name}/tags", {"tag" => tags, "dry-run" => dry_run})
587
603
  response_body = send_request("PUT", url)
588
604
 
589
605
  return response_body
@@ -594,8 +610,15 @@ module GanetiClient
594
610
  # /tags?tag=[tag]&tag=[tag]
595
611
  #
596
612
  # It supports the dry-run argument
613
+ #
614
+ # Parameters:
615
+ # name: node name
616
+ # tags: Array of tags
617
+ #
618
+ # Return:
619
+ # job id
597
620
  def node_delete_tags(name, tags, dry_run = 0)
598
- url = get_url("nodes/#{name}/tags", {"tags" => targs, "dry-run" => dry_run})
621
+ url = get_url("nodes/#{name}/tags", {"tag" => tags, "dry-run" => dry_run})
599
622
  response_body = send_request("DELETE", url)
600
623
 
601
624
  return response_body
@@ -620,6 +643,9 @@ module GanetiClient
620
643
  #
621
644
  # Example:
622
645
  # ["tag1", "tag2", "tag3"]
646
+ #
647
+ # Return:
648
+ # Array of tags
623
649
  def tags_get
624
650
  url = get_url("tags")
625
651
  response_body = JSON.parse(send_request("GET", url))
@@ -631,8 +657,14 @@ module GanetiClient
631
657
  # The request as a list of strings should be PUT to this URI. The result will be a job id
632
658
  #
633
659
  # It supports the dry-run argument
660
+ #
661
+ # Parameters
662
+ # tags: Array of tags
663
+ #
664
+ # Return:
665
+ # job id
634
666
  def tags_create(tags, dry_run = 0)
635
- url = get_url("tags", {"tags" => tags, "dry-run" => dry_run})
667
+ url = get_url("tags", {"tag" => tags, "dry-run" => dry_run})
636
668
  response_body = send_request("PUT", url)
637
669
 
638
670
  return response_body
@@ -643,8 +675,14 @@ module GanetiClient
643
675
  # /tags?tag=[tag]&tag=[tag]
644
676
  #
645
677
  # It supports the dry-run argument
678
+ #
679
+ # Parameters:
680
+ # tags: Array of tags
681
+ #
682
+ # Return:
683
+ # job id
646
684
  def tags_delete(tags, dry_run = 0)
647
- url = get_url("tags", {"tags" => tags, "dry-run" => dry_run})
685
+ url = get_url("tags", {"tag" => tags, "dry-run" => dry_run})
648
686
  response_body = send_request("DELETE", url)
649
687
 
650
688
  return response_body
@@ -710,7 +748,7 @@ module GanetiClient
710
748
 
711
749
  def create_class(class_name)
712
750
  unless(class_exists?(class_name))
713
- klass = Class.new GanetiClient::GanetiObject
751
+ klass = Class.new Ganeti::GanetiObject
714
752
  Object.const_set(class_name, klass)
715
753
  end
716
754
  end
@@ -1,4 +1,4 @@
1
- module GanetiClient
1
+ module Ganeti
2
2
  class GanetiObject
3
3
 
4
4
  attr_accessor :json_object
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ganeti_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Micha\xC3\xABl Rigart"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-15 00:00:00 +02:00
18
+ date: 2010-08-17 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21