lunanode 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +16 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.rubocop.yml +94 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +11 -0
- data/.yardopts +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +19 -0
- data/bin/console +8 -0
- data/bin/setup +8 -0
- data/lib/lunanode.rb +12 -0
- data/lib/lunanode/action_generator.rb +105 -0
- data/lib/lunanode/api.rb +172 -0
- data/lib/lunanode/api_actions.rb +41 -0
- data/lib/lunanode/api_actions/default/dns.rb +55 -0
- data/lib/lunanode/api_actions/default/email.rb +59 -0
- data/lib/lunanode/api_actions/default/floating.rb +19 -0
- data/lib/lunanode/api_actions/default/image.rb +31 -0
- data/lib/lunanode/api_actions/default/lb.rb +35 -0
- data/lib/lunanode/api_actions/default/monitor.rb +47 -0
- data/lib/lunanode/api_actions/default/network.rb +19 -0
- data/lib/lunanode/api_actions/default/plan.rb +11 -0
- data/lib/lunanode/api_actions/default/region.rb +11 -0
- data/lib/lunanode/api_actions/default/script.rb +11 -0
- data/lib/lunanode/api_actions/default/securitygroup.rb +35 -0
- data/lib/lunanode/api_actions/default/vm.rb +99 -0
- data/lib/lunanode/api_actions/default/volume.rb +47 -0
- data/lib/lunanode/api_actions/dns.rb +10 -0
- data/lib/lunanode/api_actions/email.rb +10 -0
- data/lib/lunanode/api_actions/floating.rb +10 -0
- data/lib/lunanode/api_actions/image.rb +17 -0
- data/lib/lunanode/api_actions/lb.rb +10 -0
- data/lib/lunanode/api_actions/monitor.rb +10 -0
- data/lib/lunanode/api_actions/network.rb +10 -0
- data/lib/lunanode/api_actions/plan.rb +10 -0
- data/lib/lunanode/api_actions/region.rb +10 -0
- data/lib/lunanode/api_actions/script.rb +10 -0
- data/lib/lunanode/api_actions/securitygroup.rb +10 -0
- data/lib/lunanode/api_actions/vm.rb +10 -0
- data/lib/lunanode/api_actions/volume.rb +10 -0
- data/lib/lunanode/api_error.rb +5 -0
- data/lib/lunanode/version.rb +4 -0
- data/lunanode.gemspec +33 -0
- data/lunanode_api_def.yaml +391 -0
- metadata +191 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lunanode
|
4
|
+
module APIActions
|
5
|
+
module Network
|
6
|
+
def network_list(region: nil)
|
7
|
+
action(:network, :list, region: region)
|
8
|
+
end
|
9
|
+
|
10
|
+
def network_create(region:, name:, subnet:, dns:)
|
11
|
+
action(:network, :create, region: region, name: name, subnet: subnet, dns: dns)
|
12
|
+
end
|
13
|
+
|
14
|
+
def network_delete(region:, net_id:)
|
15
|
+
action(:network, :delete, region: region, net_id: net_id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lunanode
|
4
|
+
module APIActions
|
5
|
+
module Securitygroup
|
6
|
+
def securitygroup_list
|
7
|
+
action(:securitygroup, :list)
|
8
|
+
end
|
9
|
+
|
10
|
+
def securitygroup_create(region:, name:)
|
11
|
+
action(:securitygroup, :create, region: region, name: name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def securitygroup_delete(region:, group_id:)
|
15
|
+
action(:securitygroup, :delete, region: region, group_id: group_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def securitygroup_rename(region:, group_id:, name:)
|
19
|
+
action(:securitygroup, :rename, region: region, group_id: group_id, name: name)
|
20
|
+
end
|
21
|
+
|
22
|
+
def securitygroup_rule_list(region:, group_id:)
|
23
|
+
action(:securitygroup, :rule_list, region: region, group_id: group_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def securitygroup_rule_insert(region:, group_id:, direction:, type:, protocol:, remote_type:, remote_value:, port_min: nil, port_max: nil, label: nil)
|
27
|
+
action(:securitygroup, :rule_insert, region: region, group_id: group_id, direction: direction, type: type, protocol: protocol, remote_type: remote_type, remote_value: remote_value, port_min: port_min, port_max: port_max, label: label)
|
28
|
+
end
|
29
|
+
|
30
|
+
def securitygroup_rule_delete(region:, group_id:, rule_id:)
|
31
|
+
action(:securitygroup, :rule_delete, region: region, group_id: group_id, rule_id: rule_id)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lunanode
|
4
|
+
module APIActions
|
5
|
+
module VM
|
6
|
+
def vm_start(vm_id:)
|
7
|
+
action(:vm, :start, vm_id: vm_id)
|
8
|
+
end
|
9
|
+
|
10
|
+
def vm_stop(vm_id:)
|
11
|
+
action(:vm, :stop, vm_id: vm_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def vm_reboot(vm_id:)
|
15
|
+
action(:vm, :reboot, vm_id: vm_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def vm_diskswap(vm_id:)
|
19
|
+
action(:vm, :diskswap, vm_id: vm_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
def vm_info(vm_id:)
|
23
|
+
action(:vm, :info, vm_id: vm_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def vm_delete(vm_id:)
|
27
|
+
action(:vm, :delete, vm_id: vm_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def vm_reimage(vm_id:, image_id:)
|
31
|
+
action(:vm, :reimage, vm_id: vm_id, image_id: image_id)
|
32
|
+
end
|
33
|
+
|
34
|
+
def vm_resize(vm_id:, plan_id:)
|
35
|
+
action(:vm, :resize, vm_id: vm_id, plan_id: plan_id)
|
36
|
+
end
|
37
|
+
|
38
|
+
def vm_rescue(vm_id:)
|
39
|
+
action(:vm, :rescue, vm_id: vm_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
def vm_vnc(vm_id:)
|
43
|
+
action(:vm, :vnc, vm_id: vm_id)
|
44
|
+
end
|
45
|
+
|
46
|
+
def vm_floatingip_add(vm_id:, ip: nil, private_ip: nil)
|
47
|
+
action(:vm, :floatingip_add, vm_id: vm_id, ip: ip, private_ip: private_ip)
|
48
|
+
end
|
49
|
+
|
50
|
+
def vm_floatingip_delete(vm_id:, ip: nil, keep: nil)
|
51
|
+
action(:vm, :floatingip_delete, vm_id: vm_id, ip: ip, keep: keep)
|
52
|
+
end
|
53
|
+
|
54
|
+
def vm_iplist(vm_id:)
|
55
|
+
action(:vm, :iplist, vm_id: vm_id)
|
56
|
+
end
|
57
|
+
|
58
|
+
def vm_ip_add(vm_id:, ip: nil)
|
59
|
+
action(:vm, :ip_add, vm_id: vm_id, ip: ip)
|
60
|
+
end
|
61
|
+
|
62
|
+
def vm_ip_delete(vm_id:, ip:)
|
63
|
+
action(:vm, :ip_delete, vm_id: vm_id, ip: ip)
|
64
|
+
end
|
65
|
+
|
66
|
+
def vm_securitygroup_add(vm_id:, group_id:)
|
67
|
+
action(:vm, :securitygroup_add, vm_id: vm_id, group_id: group_id)
|
68
|
+
end
|
69
|
+
|
70
|
+
def vm_securitygroup_remove(vm_id:, group_id:)
|
71
|
+
action(:vm, :securitygroup_remove, vm_id: vm_id, group_id: group_id)
|
72
|
+
end
|
73
|
+
|
74
|
+
def vm_create(hostname:, plan_id:, image_id:, region: nil, ip: nil, net_id: nil, securitygroups: nil, scripts: nil, volume_id: nil, volume_virtio: nil, key_id: nil, set_password: nil, affinity_group: nil)
|
75
|
+
action(:vm, :create, hostname: hostname, plan_id: plan_id, image_id: image_id, region: region, ip: ip, net_id: net_id, securitygroups: securitygroups, scripts: scripts, volume_id: volume_id, volume_virtio: volume_virtio, key_id: key_id, set_password: set_password, affinity_group: affinity_group)
|
76
|
+
end
|
77
|
+
|
78
|
+
def vm_snapshot(vm_id:, name:)
|
79
|
+
action(:vm, :snapshot, vm_id: vm_id, name: name)
|
80
|
+
end
|
81
|
+
|
82
|
+
def vm_list
|
83
|
+
action(:vm, :list)
|
84
|
+
end
|
85
|
+
|
86
|
+
def vm_shelve(vm_id:)
|
87
|
+
action(:vm, :shelve, vm_id: vm_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
def vm_unshelve(vm_id:)
|
91
|
+
action(:vm, :unshelve, vm_id: vm_id)
|
92
|
+
end
|
93
|
+
|
94
|
+
def vm_rename(vm_id:, hostname:)
|
95
|
+
action(:vm, :rename, vm_id: vm_id, hostname: hostname)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lunanode
|
4
|
+
module APIActions
|
5
|
+
module Volume
|
6
|
+
def volume_list(region:)
|
7
|
+
action(:volume, :list, region: region)
|
8
|
+
end
|
9
|
+
|
10
|
+
def volume_create(region:, label:, size:, image: nil, snapshot_id: nil)
|
11
|
+
action(:volume, :create, region: region, label: label, size: size, image: image, snapshot_id: snapshot_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
def volume_delete(region:, volume_id:)
|
15
|
+
action(:volume, :delete, region: region, volume_id: volume_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def volume_attach(region:, volume_id:, vm_id:, target:)
|
19
|
+
action(:volume, :attach, region: region, volume_id: volume_id, vm_id: vm_id, target: target)
|
20
|
+
end
|
21
|
+
|
22
|
+
def volume_detach(region:, volume_id:)
|
23
|
+
action(:volume, :detach, region: region, volume_id: volume_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def volume_info(region:, volume_id:)
|
27
|
+
action(:volume, :info, region: region, volume_id: volume_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
def volume_extend(region:, volume_id:, size:)
|
31
|
+
action(:volume, :extend, region: region, volume_id: volume_id, size: size)
|
32
|
+
end
|
33
|
+
|
34
|
+
def volume_snapshot_create(region:, volume_id:, label:)
|
35
|
+
action(:volume, :snapshot_create, region: region, volume_id: volume_id, label: label)
|
36
|
+
end
|
37
|
+
|
38
|
+
def volume_snapshot_delete(region:, snapshot_id:)
|
39
|
+
action(:volume, :snapshot_delete, region: region, snapshot_id: snapshot_id)
|
40
|
+
end
|
41
|
+
|
42
|
+
def volume_snapshot_list(region:)
|
43
|
+
action(:volume, :snapshot_list, region: region)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "lunanode/api_actions/default/image"
|
3
|
+
|
4
|
+
module Lunanode
|
5
|
+
module APIActions
|
6
|
+
module Image
|
7
|
+
# Contents may extend or overwrite methods from the default module.
|
8
|
+
|
9
|
+
# Filters {#image_list} results for user's account images only.
|
10
|
+
def image_list_mine(region: nil)
|
11
|
+
image_list(region: region).select do |image|
|
12
|
+
image[:image_id].to_i > 9999
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lunanode.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "lunanode/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "lunanode"
|
9
|
+
spec.version = Lunanode::VERSION
|
10
|
+
spec.authors = ["Tim Bellefleur"]
|
11
|
+
spec.email = ["nomoon@phoebus.ca"]
|
12
|
+
|
13
|
+
spec.summary = "Luna Node API for Ruby"
|
14
|
+
spec.homepage = "https://github.com/nomoon/lunanode"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
spec.required_ruby_version = ">= 2.1.0"
|
24
|
+
|
25
|
+
spec.add_dependency "rest-client", "~> 2.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
28
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
31
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
32
|
+
spec.add_development_dependency "rubocop", "~> 0.47"
|
33
|
+
end
|