knife-joyent 0.0.1 → 0.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.
data/README.md CHANGED
@@ -1,27 +1,50 @@
1
1
  Knife Joyent
2
2
  ===
3
3
 
4
- This is a Knife plugin for Joyent CloudAPI. This plugin gives knife
5
- the ability to create, bootstrap, and manage servers on the Joyent Public Cloud
6
- as well as Cloud providers powered by Joyent's SmartDataCenter product.
4
+ This is a [Knife](http://wiki.opscode.com/display/chef/Knife) plugin for Joyent CloudAPI. This plugin gives knife
5
+ the ability to create, bootstrap, and manage servers on the [Joyent Public Cloud](http://www.joyentcloud.com/) as well as Cloud providers powered by Joyent's [SmartDataCenter](http://www.joyent.com/products/smartdatacenter/) product offering.
6
+
7
+ For more information on Joyent CloudAPI, see: [CloudAPI Documentation](api.joyentcloud.com/docs)
7
8
 
8
9
  ## Installation
9
10
 
10
- With chef already installed (> 0.10.0):
11
+ With chef already installed ``(> 0.10.0)``:
11
12
 
12
13
  gem install knife-joyent
13
14
 
14
15
  ## Usage
15
16
 
16
- For available commands:
17
+ For a list of commands:
17
18
 
18
19
  knife joyent --help
19
20
 
21
+ Currently available commands:
22
+
23
+ knife joyent flavor list <options>
24
+ knife joyent image list <options>
25
+ knife joyent key add -f <keyfile> -k <name>
26
+ knife joyent key delete <name>
27
+ knife joyent key list
28
+ knife joyent server create (options)
29
+ knife joyent server list <options>
30
+ knife joyent server reboot <server_id>
31
+ knife joyent server resize <server_id> -f <flavor>
32
+ knife joyent server start <server_id>
33
+ knife joyent server stop <server_id>
34
+ knife joyent snapshot create <server> <snapshot_name>
35
+ knife joyent snapshot delete <server> <snapshot_name>
36
+ knife joyent snapshot list <server_id>
37
+ knife joyent tag create <server_id> <tag> <value>
38
+ knife joyent tag delete <server_id> <tag>
39
+ knife joyent tag delete <server_id> -A
40
+ knife joyent tag list <server>
41
+
20
42
  ## Configuration
21
43
 
22
44
  The following options can be specified in your knife configuration file
45
+ ``knife.rb``
23
46
 
24
- ### Required
47
+ #### Required
25
48
 
26
49
  You can authenticate against CloudAPI using either:
27
50
 
@@ -36,12 +59,14 @@ or, your ssh key
36
59
  knife[:joyent_keyname] = "Name of key stored on Joyent"
37
60
  knife[:joyent_keyfile] = "/path/to/your/private/key"
38
61
 
39
- ### Optional
62
+ #### Optional
63
+
64
+ **joyent_api_url**
40
65
 
41
- # Specify a custom API endpoint, this is required if you want to specify
42
- # where you want to provision your machines, or if you are using knife with a
43
- # provider powered by SmartDataCenter.
44
- #
66
+ Specify a custom API endpoint, this is required if you want to specify
67
+ where you want to provision your machines, or if you are using knife with a
68
+ provider powered by [SmartDataCenter](http://www.joyent.com/products/smartdatacenter/).
69
+
45
70
  # Defaults to https://us-west-1.api.joyentcloud.com/
46
71
  knife[:joyent_api_url] = "https://us-sw-1.api.joyentcloud.com/"
47
72
 
@@ -22,7 +22,8 @@ module KnifeJoyent
22
22
  flavor_list << "#{flavor.disk/1024} GB"
23
23
  flavor_list << "#{flavor.swap/1024} GB"
24
24
  end
25
- puts ui.list(flavor_list, :columns_across, 4)
25
+
26
+ puts ui.list(flavor_list, :uneven_columns_across, 4)
26
27
  end
27
28
  end
28
29
  end
@@ -24,7 +24,7 @@ module KnifeJoyent
24
24
  images << i.type
25
25
  end
26
26
 
27
- puts ui.list(images, :columns_across, 5)
27
+ puts ui.list(images, :uneven_columns_across, 5)
28
28
  end
29
29
  end
30
30
  end
@@ -18,7 +18,7 @@ module KnifeJoyent
18
18
  keys << k.key[0..32] + '...'
19
19
  end
20
20
 
21
- puts ui.list(keys, :columns_across, 2)
21
+ puts ui.list(keys, :uneven_columns_across, 2)
22
22
 
23
23
  end
24
24
  end
@@ -14,24 +14,34 @@ module KnifeJoyent
14
14
  ui.color('Name', :bold),
15
15
  ui.color('State', :bold),
16
16
  ui.color('Type', :bold),
17
- ui.color('Dataset', :bold),
17
+ ui.color('Image', :bold),
18
18
  ui.color('IPs', :bold),
19
- ui.color('Memory', :bold),
19
+ ui.color('RAM', :bold),
20
20
  ui.color('Disk', :bold),
21
21
  ]
22
22
 
23
23
  self.connection.servers.sort_by(&:name).each do |s|
24
24
  servers << s.id.to_s
25
25
  servers << s.name
26
- servers << s.state
26
+
27
+ servers << case s.state
28
+ when 'running'
29
+ ui.color(s.state, :green)
30
+ when 'stopping'
31
+ when 'provisioning'
32
+ ui.color(s.state, :yellow)
33
+ when 'stopped'
34
+ ui.color(s.state, :red)
35
+ end
36
+
27
37
  servers << s.type
28
38
  servers << s.dataset
29
39
  servers << s.ips.join(" ")
30
- servers << s.memory.to_s
31
- servers << s.disk.to_s
40
+ servers << "#{s.memory/1024} GB".to_s
41
+ servers << "#{s.disk/1024} GB".to_s
32
42
  end
33
43
 
34
- puts ui.list(servers, :columns_across, 8)
44
+ puts ui.list(servers, :uneven_columns_across, 8)
35
45
  end
36
46
  end
37
47
  end
@@ -36,7 +36,7 @@ module KnifeJoyent
36
36
  snapshots << s.created.to_s
37
37
  end
38
38
 
39
- puts ui.list(snapshots, :columns_across, 3)
39
+ puts ui.list(snapshots, :uneven_columns_across, 3)
40
40
  rescue Fog::Compute::Joyent::Errors::NotFound
41
41
  puts ui.error("Server #{server} not found.")
42
42
  end
@@ -0,0 +1,38 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/base')
2
+
3
+ module KnifeJoyent
4
+ class JoyentTagCreate < Chef::Knife
5
+
6
+ include KnifeJoyent::Base
7
+
8
+ banner "knife joyent tag create <server_id> <tag> <value>"
9
+
10
+ def run
11
+ server = name_args[0]
12
+ tagkey = name_args[1]
13
+ tagvalue = name_args[2]
14
+
15
+ unless server || tagkey || tagvalue
16
+ show_usage
17
+ exit 1
18
+ end
19
+
20
+ tags = [
21
+ ui.color('Name', :bold),
22
+ ui.color('Value', :bold),
23
+ ]
24
+
25
+ self.connection.servers.get(server).add_tags({tagkey => tagvalue}).each do |k, v|
26
+ tags << k
27
+ tags << v
28
+ end
29
+
30
+ puts ui.color("Updated tags for #{server}", :cyan)
31
+ puts ui.list(tags, :uneven_columns_across, 2)
32
+ exit 0
33
+ rescue Excon::Errors::NotFound => e
34
+ puts ui.error("Server #{server} not found")
35
+ exit 1
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,62 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/base')
2
+
3
+ module KnifeJoyent
4
+ class JoyentTagDelete < Chef::Knife
5
+
6
+ include KnifeJoyent::Base
7
+
8
+ banner ["knife joyent tag delete <server_id> <tag>",
9
+ "knife joyent tag delete <server_id> -A"].join("\n")
10
+
11
+
12
+ option :all,
13
+ :short => "-A",
14
+ :long => "--all",
15
+ :boolean => true,
16
+ :description => "delete all tags on the machine"
17
+
18
+ def run
19
+ server_id = name_args[0]
20
+ tagname = name_args[1]
21
+ all = config[:all]
22
+
23
+ if !server_id || (all == false && !tagname) || (all && tagname)
24
+ show_usage
25
+ exit 1
26
+ end
27
+
28
+ begin
29
+ server = self.connection.servers.get(server_id)
30
+ rescue Excon::Errors::NotFound => e
31
+ puts ui.error("Server #{server_id} not found")
32
+ exit 1
33
+ end
34
+
35
+ if all
36
+ server.delete_all_tags
37
+ puts ui.color("Deleted all tags for #{server_id}", :cyan)
38
+ exit 0
39
+ else
40
+ begin
41
+ server.delete_tag(tagname)
42
+ rescue Excon::Errors::NotFound => e
43
+ puts ui.error("Tag #{tagname} on server #{server_id} not found")
44
+ exit 1
45
+ end
46
+
47
+ tags = [
48
+ ui.color('Name', :bold),
49
+ ui.color('Value', :bold),
50
+ ]
51
+
52
+ server.reload.tags.each do |k, v|
53
+ tags << k
54
+ tags << v
55
+ end
56
+ puts ui.color("Deleted tag #{tagname} for #{server_id}", :cyan)
57
+ puts ui.list(tags, :uneven_columns_across, 2)
58
+ end
59
+ exit 0
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/base')
2
+
3
+ module KnifeJoyent
4
+ class JoyentTagList < Chef::Knife
5
+
6
+ include KnifeJoyent::Base
7
+
8
+ banner "knife joyent tag list <server>"
9
+
10
+ def run
11
+ server = name_args.first
12
+
13
+ unless server
14
+ show_usage
15
+ exit 1
16
+ end
17
+
18
+ tags = [
19
+ ui.color('Name', :bold),
20
+ ui.color('Value', :bold),
21
+ ]
22
+
23
+ self.connection.servers.get(server).tags.each do |k, v|
24
+ tags << k
25
+ tags << v
26
+ end
27
+
28
+ puts ui.list(tags, :uneven_columns_across, 2)
29
+ exit 0
30
+ rescue Excon::Errors::NotFound => e
31
+ puts ui.error("Server #{server} not found")
32
+ exit 1
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module KnifeJoyent
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-joyent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kevin Chan
@@ -67,6 +67,9 @@ files:
67
67
  - lib/knife-joyent/joyent_snapshot_create.rb
68
68
  - lib/knife-joyent/joyent_snapshot_delete.rb
69
69
  - lib/knife-joyent/joyent_snapshot_list.rb
70
+ - lib/knife-joyent/joyent_tag_create.rb
71
+ - lib/knife-joyent/joyent_tag_delete.rb
72
+ - lib/knife-joyent/joyent_tag_list.rb
70
73
  - lib/knife-joyent/version.rb
71
74
  has_rdoc: true
72
75
  homepage: http://wiki.opscode.com/display/chef