clinode 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Clinode
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1,42 @@
1
+ command :avail do |args|
2
+ helper.linode_config
3
+ ls = helper.linode
4
+ return if !ls
5
+
6
+ params = {}
7
+
8
+ case args
9
+ when "plans"
10
+ if options.has_key?(:planid)
11
+ params[:planid] = options[:planid]
12
+ end
13
+ puts ls.avail.linodeplans(params)
14
+ when "datacenters"
15
+ puts ls.avail.datacenters
16
+ when "distributions"
17
+ if options.has_key?(:distributionid)
18
+ params[:distributionid] = options[:distributionid]
19
+ end
20
+ puts ls.avail.distributions(params)
21
+ when "kernels"
22
+ if options.has_key?(:kernelid)
23
+ params[:kernelid] = options[:kernelid]
24
+ end
25
+ if options.has_key?(:isxen)
26
+ params[:isxen] = options[:isxen]
27
+ end
28
+ puts ls.avail.kernels(params)
29
+ when "stackscripts"
30
+ if options.has_key?(:distributionid)
31
+ params[:distributionid] = options[:distributionid]
32
+ end
33
+ if options.has_key?(:distributionvendor)
34
+ params[:distributionvendor] = options[:distributionvendor]
35
+ end
36
+ if options.has_key?(:keywords)
37
+ params[:keywords] = options[:keywords]
38
+ end
39
+ puts ls.avail.stackscripts(params)
40
+ end
41
+
42
+ end
@@ -0,0 +1,35 @@
1
+ command :dns do |args|
2
+ helper.linode_config
3
+ ls = helper.stackscript_linode
4
+ return if !ls
5
+
6
+ params = {}
7
+
8
+ case args
9
+ when "list"
10
+ if options.has_key?(:domainid)
11
+ params[:domainid] = options[:domainid]
12
+ end
13
+ puts ls.domain.list(params)
14
+ end
15
+
16
+ end
17
+
18
+ command :dns_resource do |args|
19
+ helper.linode_config
20
+ ls = helper.stackscript_linode
21
+ return if !ls
22
+
23
+ return if !options.has_key?(:domainid)
24
+
25
+ params = {:domainid => options[:domainid]}
26
+
27
+ case args
28
+ when "list"
29
+ if options.has_key?(:resourceid)
30
+ params[:resourceid] = options[:resourceid]
31
+ end
32
+ puts ls.domain.resource.list(params)
33
+ end
34
+
35
+ end
@@ -0,0 +1,7 @@
1
+ command :echo do
2
+ helper.linode_config
3
+ ls = helper.stackscript_linode
4
+ return if !ls
5
+
6
+ puts ls.test.echo(options)
7
+ end
@@ -14,3 +14,15 @@ helper :linode do
14
14
  Linode.new(:api_key => Clinode.options[:api_token])
15
15
  end
16
16
  end
17
+
18
+ helper :get_linode do
19
+
20
+ linode_config
21
+ ls = stackscript_linode
22
+ if ls
23
+ return ls
24
+ else
25
+ die "wtf"
26
+ end
27
+
28
+ end
@@ -0,0 +1,13 @@
1
+ flags :pending => "Only Pending"
2
+ command :job do |args|
3
+ ls = helper.get_linode
4
+
5
+ params = {:linodeid => args, :pendingonly => options[:pending]}
6
+
7
+ if options.has_key?(:jobid)
8
+ params[:jobid] = options[:jobid]
9
+ end
10
+
11
+ puts ls.job.list(params)
12
+
13
+ end
@@ -0,0 +1,10 @@
1
+ command :nodebalancer do |args|
2
+ helper.linode_config
3
+ ls = helper.stackscript_linode
4
+ return if !ls
5
+
6
+ case args
7
+ when "list"
8
+ puts ls.nodebalancer.list()
9
+ end
10
+ end
@@ -25,6 +25,18 @@ helper :stackscript_meta_update do |ls,stackscript_id,opts|
25
25
  ls.update(params)
26
26
  end
27
27
 
28
+ helper :stackscript_create do |ls,opts|
29
+ VALID_KEYS = [:label,:ispublic,:rev_note,:description]
30
+ params = opts.reject{|key,value| !VALID_KEYS.include?(key)}
31
+ params[:script] = File.read(Clinode.options[:file])
32
+ ls.create(params)
33
+ end
34
+
35
+ helper :stackscript_delete do |ls,stackscript_id|
36
+ ls.delete(:stackscriptid => stackscript_id)
37
+ puts "Stack Script #{stackscript_id} deleted."
38
+ end
39
+
28
40
  helper :stackscript_update do |ls,stackscript_id,filename|
29
41
  if File.exists?(filename)
30
42
  script = File.read(filename)
@@ -57,6 +69,7 @@ helper :stackscript_process do |ls,stackscript_id|
57
69
  end
58
70
 
59
71
  desc "List your stackscripts"
72
+ usage "commands allowed: list, upload, download, create"
60
73
  usage "--dir=<directory> stackscript directory to upload from/download to"
61
74
  usage "--label=<new label>"
62
75
  usage "--ispublic=true/false"
@@ -65,6 +78,7 @@ usage "--rev_note=<revision note>"
65
78
  flags :output => "Output the content of the stackscript only"
66
79
  flags :update => "Update the content of the stackscript"
67
80
  flags :meta_update => "Update the meta data of the stackscript"
81
+ flags :delete => "Delete the given stack script"
68
82
  command :stackscript do |arg|
69
83
  helper.linode_config
70
84
  ls = helper.stackscript_linode
@@ -79,12 +93,16 @@ command :stackscript do |arg|
79
93
  helper.stackscript_upload(ls)
80
94
  when "download"
81
95
  helper.stackscript_download(ls)
96
+ when "create"
97
+ helper.stackscript_create(ls,options)
82
98
  when /^\d+$/
83
99
  if options[:update]
84
100
  filename = "#{options[:dir]}/#{arg}_stack.sh"
85
101
  helper.stackscript_update(ls,arg,filename)
86
102
  elsif options[:meta_update]
87
103
  helper.stackscript_meta_update(ls,arg,options)
104
+ elsif options[:delete]
105
+ helper.stackscript_delete(ls,arg)
88
106
  else
89
107
  helper.stackscript_process(ls,arg)
90
108
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clinode
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aditya Sanghi
@@ -131,7 +131,12 @@ files:
131
131
  - lib/clinode/helper.rb
132
132
  - lib/clinode/ui.rb
133
133
  - lib/clinode/version.rb
134
+ - lib/commands/avail.rb
135
+ - lib/commands/dns.rb
136
+ - lib/commands/echo.rb
134
137
  - lib/commands/helpers.rb
138
+ - lib/commands/job.rb
139
+ - lib/commands/nodebalancer.rb
135
140
  - lib/commands/stackscript.rb
136
141
  homepage: http://me.adityasanghi.com
137
142
  licenses: []