rubineti 1.0.2

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.
Files changed (40) hide show
  1. data/.rvmrc +1 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +33 -0
  4. data/LICENSE +4 -0
  5. data/README.md +44 -0
  6. data/Rakefile +22 -0
  7. data/VERSION +1 -0
  8. data/lib/ganeti.rb +6 -0
  9. data/lib/rubineti/compute/cluster.rb +74 -0
  10. data/lib/rubineti/compute/instances.rb +245 -0
  11. data/lib/rubineti/compute/jobs.rb +42 -0
  12. data/lib/rubineti/compute/node.rb +140 -0
  13. data/lib/rubineti/compute.rb +125 -0
  14. data/lib/rubineti.rb +2 -0
  15. data/rubineti.gemspec +106 -0
  16. data/test/fixtures/cassettes/cluster_info.yml +96 -0
  17. data/test/fixtures/cassettes/cluster_oses.yml +32 -0
  18. data/test/fixtures/cassettes/cluster_redistribute_config.yml +32 -0
  19. data/test/fixtures/cassettes/cluster_version.yml +30 -0
  20. data/test/fixtures/cassettes/instance_create.yml +32 -0
  21. data/test/fixtures/cassettes/instance_delete.yml +30 -0
  22. data/test/fixtures/cassettes/instance_info.yml +30 -0
  23. data/test/fixtures/cassettes/instance_list.yml +93 -0
  24. data/test/fixtures/cassettes/instance_reboot.yml +32 -0
  25. data/test/fixtures/cassettes/instance_reinstall.yml +32 -0
  26. data/test/fixtures/cassettes/instance_shutdown.yml +32 -0
  27. data/test/fixtures/cassettes/instance_startup.yml +32 -0
  28. data/test/fixtures/cassettes/instances.yml +95 -0
  29. data/test/fixtures/cassettes/job_list.yml +135 -0
  30. data/test/fixtures/cassettes/jobs.yml +35 -0
  31. data/test/fixtures/cassettes/node_list.yml +55 -0
  32. data/test/fixtures/cassettes/node_role_list.yml +30 -0
  33. data/test/fixtures/cassettes/nodes.yml +39 -0
  34. data/test/lib/rubineti/compute/test_cluster.rb +71 -0
  35. data/test/lib/rubineti/compute/test_instances.rb +202 -0
  36. data/test/lib/rubineti/compute/test_jobs.rb +41 -0
  37. data/test/lib/rubineti/compute/test_node.rb +77 -0
  38. data/test/lib/rubineti/test_compute.rb +92 -0
  39. data/test/support.rb +35 -0
  40. metadata +225 -0
@@ -0,0 +1,32 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :put
5
+ uri: https://fake:credentials@ganeti.primary:5080/2/instances/invalid_instance_name/shutdown?dry-run=1
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ content-type:
11
+ - application/json
12
+ connection:
13
+ - keep-alive
14
+ keep-alive:
15
+ - 30
16
+ response: !ruby/struct:VCR::Response
17
+ status: !ruby/struct:VCR::ResponseStatus
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ date:
22
+ - Mon, 29 Nov 2010 01:08:31 GMT
23
+ content-type:
24
+ - application/json
25
+ content-length:
26
+ - "7"
27
+ server:
28
+ - Ganeti 2.1.2.1
29
+ body: |
30
+ "6253"
31
+
32
+ http_version: "1.1"
@@ -0,0 +1,32 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :put
5
+ uri: https://fake:credentials@ganeti.primary:5080/2/instances/invalid_instance_name/startup?dry-run=1
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ content-type:
11
+ - application/json
12
+ connection:
13
+ - keep-alive
14
+ keep-alive:
15
+ - 30
16
+ response: !ruby/struct:VCR::Response
17
+ status: !ruby/struct:VCR::ResponseStatus
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ date:
22
+ - Mon, 29 Nov 2010 01:08:58 GMT
23
+ content-type:
24
+ - application/json
25
+ content-length:
26
+ - "7"
27
+ server:
28
+ - Ganeti 2.1.2.1
29
+ body: |
30
+ "6254"
31
+
32
+ http_version: "1.1"
@@ -0,0 +1,95 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://fake:credentials@ganeti.primary:5080/2/instances?bulk=1
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ connection:
11
+ - keep-alive
12
+ keep-alive:
13
+ - 30
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ date:
20
+ - Mon, 29 Nov 2010 01:28:59 GMT
21
+ content-type:
22
+ - application/json
23
+ content-length:
24
+ - "1476"
25
+ server:
26
+ - Ganeti 2.1.2.1
27
+ body: |
28
+ [
29
+ {
30
+ "admin_state": true,
31
+ "beparams": {
32
+ "auto_balance": true,
33
+ "memory": 128,
34
+ "vcpus": 1
35
+ },
36
+ "ctime": 1290993813.312603,
37
+ "disk.sizes": [
38
+ 10240
39
+ ],
40
+ "disk_template": "plain",
41
+ "disk_usage": 10240,
42
+ "hvparams": {
43
+ "acpi": true,
44
+ "boot_order": "disk",
45
+ "cdrom_image_path": "",
46
+ "disk_cache": "default",
47
+ "disk_type": "paravirtual",
48
+ "initrd_path": "",
49
+ "kernel_args": "ro",
50
+ "kernel_path": "/boot/vmlinuz-2.6.35-22-server",
51
+ "kvm_flag": "",
52
+ "nic_type": "paravirtual",
53
+ "root_path": "/dev/vda1",
54
+ "security_domain": "",
55
+ "security_model": "none",
56
+ "serial_console": true,
57
+ "usb_mouse": "",
58
+ "use_localtime": false,
59
+ "vnc_bind_address": "",
60
+ "vnc_password_file": "",
61
+ "vnc_tls": false,
62
+ "vnc_x509_path": "",
63
+ "vnc_x509_verify": false
64
+ },
65
+ "mtime": 1290993956.3699579,
66
+ "name": "compute1.cloud-internal.gln.atti.com",
67
+ "network_port": 11008,
68
+ "nic.bridges": [
69
+ "br0"
70
+ ],
71
+ "nic.ips": [
72
+ null
73
+ ],
74
+ "nic.links": [
75
+ "br0"
76
+ ],
77
+ "nic.macs": [
78
+ "aa:00:00:3e:9c:1e"
79
+ ],
80
+ "nic.modes": [
81
+ "bridged"
82
+ ],
83
+ "oper_ram": 128,
84
+ "oper_state": true,
85
+ "os": "debootstrap+default",
86
+ "pnode": "g2.cloud-internal.gln.atti.com",
87
+ "serial_no": 2,
88
+ "snodes": [],
89
+ "status": "running",
90
+ "tags": [],
91
+ "uuid": "abd19091-9941-4dae-9991-39f740ec0b95"
92
+ }
93
+ ]
94
+
95
+ http_version: "1.1"
@@ -0,0 +1,135 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://fake:credentials@ganeti.primary:5080/2/jobs/5253
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ connection:
11
+ - keep-alive
12
+ keep-alive:
13
+ - 30
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ date:
20
+ - Sat, 27 Nov 2010 07:46:10 GMT
21
+ content-type:
22
+ - application/json
23
+ content-length:
24
+ - "2051"
25
+ server:
26
+ - Ganeti 2.1.2.1
27
+ body: |
28
+ {
29
+ "end_ts": [
30
+ 1290843969,
31
+ 414593
32
+ ],
33
+ "id": "5253",
34
+ "oplog": [
35
+ [
36
+ [
37
+ 1,
38
+ [
39
+ 1290843955,
40
+ 36962
41
+ ],
42
+ "message",
43
+ "* creating instance disks..."
44
+ ],
45
+ [
46
+ 2,
47
+ [
48
+ 1290843957,
49
+ 236658
50
+ ],
51
+ "message",
52
+ "adding instance compute1.cloud-internal.gln.atti.com to cluster config"
53
+ ],
54
+ [
55
+ 3,
56
+ [
57
+ 1290843957,
58
+ 803064
59
+ ],
60
+ "message",
61
+ " - INFO: Waiting for instance compute1.cloud-internal.gln.atti.com to sync disks."
62
+ ],
63
+ [
64
+ 4,
65
+ [
66
+ 1290843968,
67
+ 121252
68
+ ],
69
+ "message",
70
+ " - INFO: Instance compute1.cloud-internal.gln.atti.com's disks are in sync."
71
+ ]
72
+ ]
73
+ ],
74
+ "opresult": [
75
+ [
76
+ "OpExecError",
77
+ [
78
+ "There are some degraded disks for this instance"
79
+ ]
80
+ ]
81
+ ],
82
+ "ops": [
83
+ {
84
+ "OP_ID": "OP_INSTANCE_CREATE",
85
+ "beparams": {},
86
+ "debug_level": 0,
87
+ "disk_template": "drbd",
88
+ "disks": [
89
+ {
90
+ "size": 10240
91
+ }
92
+ ],
93
+ "dry_run": false,
94
+ "file_driver": "loop",
95
+ "file_storage_dir": null,
96
+ "force_variant": false,
97
+ "hvparams": {},
98
+ "hypervisor": "kvm",
99
+ "iallocator": null,
100
+ "identify_defaults": false,
101
+ "instance_name": "compute1.cloud-internal.gln.atti.com",
102
+ "ip_check": true,
103
+ "mode": "create",
104
+ "name_check": true,
105
+ "nics": [
106
+ {}
107
+ ],
108
+ "no_install": false,
109
+ "os_type": "debootstrap+default",
110
+ "pnode": "g2.cloud-internal.gln.atti.com",
111
+ "snode": "g1.cloud-internal.gln.atti.com",
112
+ "src_node": null,
113
+ "src_path": null,
114
+ "start": true,
115
+ "wait_for_sync": true
116
+ }
117
+ ],
118
+ "opstatus": [
119
+ "error"
120
+ ],
121
+ "received_ts": [
122
+ 1290843951,
123
+ 652133
124
+ ],
125
+ "start_ts": [
126
+ 1290843951,
127
+ 712062
128
+ ],
129
+ "status": "error",
130
+ "summary": [
131
+ "INSTANCE_CREATE(compute1.cloud-internal.gln.atti.com)"
132
+ ]
133
+ }
134
+
135
+ http_version: "1.1"
@@ -0,0 +1,35 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://fake:credentials@ganeti.primary:5080/2/jobs
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ connection:
11
+ - keep-alive
12
+ keep-alive:
13
+ - 30
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ date:
20
+ - Sat, 27 Nov 2010 07:46:08 GMT
21
+ content-type:
22
+ - application/json
23
+ content-length:
24
+ - "56"
25
+ server:
26
+ - Ganeti 2.1.2.1
27
+ body: |
28
+ [
29
+ {
30
+ "id": "5253",
31
+ "uri": "/2/jobs/5253"
32
+ }
33
+ ]
34
+
35
+ http_version: "1.1"
@@ -0,0 +1,55 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://fake:credentials@ganeti.primary:5080/2/nodes/g1.cloud-internal.gln.atti.com
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ connection:
11
+ - keep-alive
12
+ keep-alive:
13
+ - 30
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ date:
20
+ - Mon, 29 Nov 2010 08:59:52 GMT
21
+ content-type:
22
+ - application/json
23
+ content-length:
24
+ - "509"
25
+ server:
26
+ - Ganeti 2.1.2.1
27
+ body: |
28
+ {
29
+ "cnodes": 1,
30
+ "csockets": 1,
31
+ "ctime": null,
32
+ "ctotal": 2,
33
+ "dfree": 51204,
34
+ "drained": false,
35
+ "dtotal": 51204,
36
+ "master_candidate": true,
37
+ "mfree": 5439,
38
+ "mnode": 502,
39
+ "mtime": null,
40
+ "mtotal": 5725,
41
+ "name": "g1.cloud-internal.gln.atti.com",
42
+ "offline": false,
43
+ "pinst_cnt": 0,
44
+ "pinst_list": [],
45
+ "pip": "192.168.22.35",
46
+ "role": "M",
47
+ "serial_no": 1,
48
+ "sinst_cnt": 0,
49
+ "sinst_list": [],
50
+ "sip": "192.168.22.35",
51
+ "tags": [],
52
+ "uuid": "049d0f85-7a2c-45b1-bd67-cca4034346cf"
53
+ }
54
+
55
+ http_version: "1.1"
@@ -0,0 +1,30 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://fake:credentials@ganeti.primary:5080/2/nodes/g1.cloud-internal.gln.atti.com/role
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ connection:
11
+ - keep-alive
12
+ keep-alive:
13
+ - 30
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ date:
20
+ - Mon, 29 Nov 2010 09:01:43 GMT
21
+ content-type:
22
+ - application/json
23
+ content-length:
24
+ - "9"
25
+ server:
26
+ - Ganeti 2.1.2.1
27
+ body: |
28
+ "master"
29
+
30
+ http_version: "1.1"
@@ -0,0 +1,39 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: https://fake:credentials@ganeti.primary:5080/2/nodes
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/json
10
+ connection:
11
+ - keep-alive
12
+ keep-alive:
13
+ - 30
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ date:
20
+ - Mon, 29 Nov 2010 08:57:29 GMT
21
+ content-type:
22
+ - application/json
23
+ content-length:
24
+ - "215"
25
+ server:
26
+ - Ganeti 2.1.2.1
27
+ body: |
28
+ [
29
+ {
30
+ "id": "g1.cloud-internal.gln.atti.com",
31
+ "uri": "/2/nodes/g1.cloud-internal.gln.atti.com"
32
+ },
33
+ {
34
+ "id": "g2.cloud-internal.gln.atti.com",
35
+ "uri": "/2/nodes/g2.cloud-internal.gln.atti.com"
36
+ }
37
+ ]
38
+
39
+ http_version: "1.1"
@@ -0,0 +1,71 @@
1
+ require "support"
2
+
3
+ describe Rubineti::Compute do
4
+ describe Rubineti::Cluster do
5
+ describe "#cluster_features" do
6
+ it "is not implemented" do
7
+ out, err = capture_io { Connection.cluster_features }
8
+
9
+ err.must_match Not_Implemented_Matcher
10
+ end
11
+ end
12
+
13
+ describe "#cluster_info" do
14
+ it "returns a Hash" do
15
+ VCR.use_cassette "cluster_info" do
16
+ response = Connection.cluster_info
17
+
18
+ response.must_be_kind_of Hash
19
+ end
20
+ end
21
+ end
22
+
23
+ describe "#cluster_redistribute_config" do
24
+ it "returns a job_id" do
25
+ VCR.use_cassette "cluster_redistribute_config" do
26
+ Connection.cluster_redistribute_config.must_match Job_Matcher
27
+ end
28
+ end
29
+ end
30
+
31
+ describe "#cluser_tags_create" do
32
+ it "is not implemented" do
33
+ out, err = capture_io { Connection.cluster_tags_create }
34
+
35
+ err.must_match Not_Implemented_Matcher
36
+ end
37
+ end
38
+
39
+ describe "#cluser_tags_delete" do
40
+ it "is not implemented" do
41
+ out, err = capture_io { Connection.cluster_tags_create }
42
+
43
+ err.must_match Not_Implemented_Matcher
44
+ end
45
+ end
46
+
47
+ describe "#cluser_tags_list" do
48
+ it "is not implemented" do
49
+ out, err = capture_io { Connection.cluster_tags_list }
50
+
51
+ err.must_match Not_Implemented_Matcher
52
+ end
53
+ end
54
+
55
+ describe "#cluser_version" do
56
+ it "returns a version string" do
57
+ VCR.use_cassette "cluster_version" do
58
+ Connection.cluster_version.must_equal 2
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "#cluser_os_list" do
64
+ it "returns an Array" do
65
+ VCR.use_cassette "cluster_oses" do
66
+ Connection.cluster_os_list.size.must_equal 1
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end