oc 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/oc/version.rb +1 -1
- data/lib/system/run/commands/domain.rb +101 -0
- data/lib/system/run/commands/droplets.rb +115 -3
- data/lib/system/run/commands/images.rb +22 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caf80ee1e449fbe352efeaf06c0fde1f4f9e3585
|
4
|
+
data.tar.gz: 85a5fe089756ccfe5d8e1f96324c1f6a58464f46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b077ce6e430d1301ff4e7d2e3bb1da8c4fb8d73ab332f7f3f592da7f44ed3d35f212c63478b7ec4f1c461877678e33b860cd4c2d716f9252f2140b6fdf685c
|
7
|
+
data.tar.gz: 474295c837e641d12d05edb455eaf5f47b9d73f9ecb6be4f9d4925e686ad3f715d9e861251e3cac83a272a12e0039e8aa8912ba79a7c55ebc9de5f43c6046226
|
data/lib/oc/version.rb
CHANGED
@@ -0,0 +1,101 @@
|
|
1
|
+
module Oc::Run
|
2
|
+
class Domain < Base
|
3
|
+
|
4
|
+
description "Show all domains"
|
5
|
+
syntax "co domain"
|
6
|
+
def run
|
7
|
+
result = barge.domain.all
|
8
|
+
if !result.success?
|
9
|
+
puts "#{result.error}".red
|
10
|
+
else
|
11
|
+
puts "Domains".yellow
|
12
|
+
rows = []
|
13
|
+
rows << [
|
14
|
+
'Name',
|
15
|
+
'TTL'
|
16
|
+
]
|
17
|
+
result.domains.each do |domain|
|
18
|
+
rows << [
|
19
|
+
domain.name.to_s.red,
|
20
|
+
domain.ttl
|
21
|
+
]
|
22
|
+
end
|
23
|
+
table = Terminal::Table.new :rows => rows
|
24
|
+
puts table
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
description "Show domain"
|
29
|
+
syntax "oc domain show [DOMAIN_NAME]"
|
30
|
+
def show(*args)
|
31
|
+
domain = args[0]
|
32
|
+
if domain.nil?
|
33
|
+
puts "Argument Error".red
|
34
|
+
puts "Usage".yellow
|
35
|
+
puts "$ oc domain show [DOMAIN_NAME]".yellow
|
36
|
+
else
|
37
|
+
result = barge.domain.show(domain.to_s)
|
38
|
+
if !result.success?
|
39
|
+
puts "#{result.message}".red
|
40
|
+
else
|
41
|
+
puts "Domain Information - #{domain}".yellow
|
42
|
+
rows = []
|
43
|
+
rows << [
|
44
|
+
'Name',
|
45
|
+
'TTL'
|
46
|
+
]
|
47
|
+
rows << [
|
48
|
+
result.domain.name.to_s.red,
|
49
|
+
result.domain.ttl
|
50
|
+
]
|
51
|
+
table = Terminal::Table.new :rows => rows
|
52
|
+
puts table
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
description "Destroy domain"
|
58
|
+
syntax "oc domain destroy [DOMAIN_NAME]"
|
59
|
+
def destroy(*args)
|
60
|
+
domain = args[0]
|
61
|
+
if domain.nil?
|
62
|
+
puts "Argument Error".red
|
63
|
+
puts "Usage".yellow
|
64
|
+
puts "$ oc domain destroy [DOMAIN_NAME]".yellow
|
65
|
+
else
|
66
|
+
result = barge.domain.destroy(domain.to_s)
|
67
|
+
if !result.success?
|
68
|
+
puts "#{result.message}".red
|
69
|
+
else
|
70
|
+
puts "Domain destroyed".green
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
description "Create domain record"
|
76
|
+
syntax "oc domain create [DOMAIN_NAME] [TYPE] [IP]"
|
77
|
+
def create(*args)
|
78
|
+
name = args[0]
|
79
|
+
type = args[1]
|
80
|
+
data = args[2]
|
81
|
+
if data.nil? or type.nil? or data.nil?
|
82
|
+
puts "Argument Error".red
|
83
|
+
puts "Usage".yellow
|
84
|
+
puts "$ oc domain create [DOMAIN_NAME] [TYPE] [IP]".yellow
|
85
|
+
else
|
86
|
+
result = barge.domain.create_record(name.to_s, {:type => name.to_s, :data => data.to_s})
|
87
|
+
if !result.success?
|
88
|
+
puts "#{result.message}".red
|
89
|
+
else
|
90
|
+
puts "Domain created".green
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def barge
|
97
|
+
puts "I'm thinking, please wait..".blue
|
98
|
+
Oc::Get.get_barge
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -6,8 +6,8 @@ module Oc::Run
|
|
6
6
|
end
|
7
7
|
|
8
8
|
description "Show Droplets"
|
9
|
-
syntax "oc
|
10
|
-
def
|
9
|
+
syntax "oc droplets"
|
10
|
+
def run
|
11
11
|
result = barge.droplet.all
|
12
12
|
if !result.success?
|
13
13
|
puts "Error: Please check your information".red
|
@@ -58,6 +58,24 @@ module Oc::Run
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
description "Destroy droplet"
|
62
|
+
syntax "oc droplets destroy [DROPLET_ID]"
|
63
|
+
def destroy(*args)
|
64
|
+
id = args[0]
|
65
|
+
if id.nil?
|
66
|
+
puts "Argument Error".red
|
67
|
+
puts "Usage".yellow
|
68
|
+
puts "$ oc droplets destroy [DROPLET_ID]".yellow
|
69
|
+
else
|
70
|
+
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
71
|
+
result = barge.droplet.destroy(id)
|
72
|
+
if !result.success?
|
73
|
+
puts "#{result.message}".red
|
74
|
+
else
|
75
|
+
puts "Droplet destroyed".green
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
61
79
|
|
62
80
|
description "Reboot droplet"
|
63
81
|
syntax "oc droplets reboot [DROPLET_ID]"
|
@@ -267,7 +285,6 @@ module Oc::Run
|
|
267
285
|
else
|
268
286
|
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
269
287
|
raise ArgumentError, "Argument Error - #{image_id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
270
|
-
|
271
288
|
result = barge.droplet.restore(id, image: image_id)
|
272
289
|
if !result.success?
|
273
290
|
puts "#{result.message}".red
|
@@ -337,6 +354,101 @@ module Oc::Run
|
|
337
354
|
end
|
338
355
|
end
|
339
356
|
|
357
|
+
description "Show droplet kernels"
|
358
|
+
syntax "oc droplets kernels [DROPLET_ID]"
|
359
|
+
def kernels(*args)
|
360
|
+
id = args[0]
|
361
|
+
if id.nil?
|
362
|
+
puts "Argument Error".red
|
363
|
+
puts "Usage".yellow
|
364
|
+
puts "$ oc droplets kernels [DROPLET_ID]"
|
365
|
+
else
|
366
|
+
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
367
|
+
result = barge.droplet.kernels(id)
|
368
|
+
if !result.success?
|
369
|
+
puts "#{result.message}".red
|
370
|
+
else
|
371
|
+
puts "Kernels".yellow
|
372
|
+
kernels = []
|
373
|
+
|
374
|
+
kernels << [
|
375
|
+
'ID',
|
376
|
+
'Name',
|
377
|
+
'Version'
|
378
|
+
]
|
379
|
+
|
380
|
+
result.kernels.each do |kernel|
|
381
|
+
kernels << [
|
382
|
+
kernel.id,
|
383
|
+
kernel.name.to_s.red,
|
384
|
+
kernel.version.to_s
|
385
|
+
]
|
386
|
+
end
|
387
|
+
table = Terminal::Table.new :rows => kernels
|
388
|
+
puts table
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
description "Change a droplet's kernel"
|
394
|
+
syntax "oc droplets change-kernel [DROPLET_ID] [KERNEL_ID]"
|
395
|
+
def change_kernel(*args)
|
396
|
+
id = args[0]
|
397
|
+
kernel_id = args[1]
|
398
|
+
if id.nil? or kernel_id.nil?
|
399
|
+
puts "Argument Error".red
|
400
|
+
puts "Usage".yellow
|
401
|
+
puts "$ oc droplets change-kernel [DROPLET_ID] [KERNEL_ID]"
|
402
|
+
else
|
403
|
+
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
404
|
+
raise ArgumentError, "Argument Error - #{kernel_id}" unless kernel_id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
405
|
+
result = barge.droplet.change_kernel(id, kernel: kernel_id)
|
406
|
+
if !result.success?
|
407
|
+
puts "#{result.message}".red
|
408
|
+
else
|
409
|
+
puts "Droplet kernel changed".green
|
410
|
+
end
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
description "Disable backups for a droplet"
|
415
|
+
syntax "oc droplets disable-backup [DROPLET_ID]"
|
416
|
+
def disable_backup(*args)
|
417
|
+
id = args[0]
|
418
|
+
if id.nil?
|
419
|
+
puts "Argument Error".red
|
420
|
+
puts "Usage".yellow
|
421
|
+
puts "$ oc droplets disable-backup [DROPLET_ID]"
|
422
|
+
else
|
423
|
+
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
424
|
+
result = barge.droplet.disable_backups(id)
|
425
|
+
if !result.success?
|
426
|
+
puts "#{result.message}".red
|
427
|
+
else
|
428
|
+
puts "Backup disabled".green
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
description "Enable private networking for a droplet"
|
434
|
+
syntax "oc droplets enable-private-network [DROPLET_ID]"
|
435
|
+
def enable_private_network(*args)
|
436
|
+
id = args[0]
|
437
|
+
if id.nil?
|
438
|
+
puts "Argument Error".red
|
439
|
+
puts "Usage".yellow
|
440
|
+
puts "$ oc droplets enable-private-network [DROPLET_ID]"
|
441
|
+
else
|
442
|
+
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
443
|
+
result = barge.droplet.enable_private_networking(id)
|
444
|
+
if !result.success?
|
445
|
+
puts "#{result.message}".red
|
446
|
+
else
|
447
|
+
puts "Backup disabled".green
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
340
452
|
private
|
341
453
|
def config(value)
|
342
454
|
@config ||= value
|
@@ -101,7 +101,7 @@ module Oc::Run
|
|
101
101
|
puts "$ oc images transfer [IMAGE_ID] [REGION_ID]".yellow
|
102
102
|
else
|
103
103
|
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
104
|
-
raise ArgumentError, "Argument Error - #{
|
104
|
+
raise ArgumentError, "Argument Error - #{region_id}" unless region_id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
105
105
|
result = barge.image.transfer(id, region: region_id)
|
106
106
|
if !result.success?
|
107
107
|
puts "#{result.message}".red
|
@@ -111,6 +111,27 @@ module Oc::Run
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
|
+
description "Update image"
|
115
|
+
syntax "oc images update [IMAGE_ID] [NEW_IMAGE_NAME]"
|
116
|
+
def update(*args)
|
117
|
+
id = args[0]
|
118
|
+
name = args[1]
|
119
|
+
if id.nil? or name.nil?
|
120
|
+
puts "Argument Error".red
|
121
|
+
puts "Usage".yellow
|
122
|
+
puts "$ oc images transfer [IMAGE_ID] [NAME]".yellow
|
123
|
+
else
|
124
|
+
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
|
125
|
+
result = barge.image.update(id, {:name => name})
|
126
|
+
if !result.success?
|
127
|
+
puts "#{result.message}".red
|
128
|
+
else
|
129
|
+
puts "Image updated".green
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
114
135
|
private
|
115
136
|
def barge
|
116
137
|
puts "I'm thinking, please wait..".blue
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sedat Ciftci
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/system/get.rb
|
129
129
|
- lib/system/run/base.rb
|
130
130
|
- lib/system/run/client.rb
|
131
|
+
- lib/system/run/commands/domain.rb
|
131
132
|
- lib/system/run/commands/droplets.rb
|
132
133
|
- lib/system/run/commands/images.rb
|
133
134
|
- lib/system/run/commands/info.rb
|