knife-joyent 0.0.10 → 0.1.0
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 +3 -3
- data/knife-joyent.gemspec +3 -3
- data/lib/chef/knife/joyent_base.rb +60 -0
- data/lib/chef/knife/joyent_flavor_list.rb +20 -19
- data/lib/chef/knife/joyent_image_list.rb +23 -21
- data/lib/chef/knife/joyent_key_add.rb +39 -38
- data/lib/chef/knife/joyent_key_delete.rb +23 -22
- data/lib/chef/knife/joyent_key_list.rb +17 -16
- data/lib/chef/knife/joyent_server_create.rb +238 -151
- data/lib/chef/knife/joyent_server_delete.rb +58 -56
- data/lib/chef/knife/joyent_server_list.rb +47 -44
- data/lib/chef/knife/joyent_server_reboot.rb +24 -23
- data/lib/chef/knife/joyent_server_resize.rb +41 -40
- data/lib/chef/knife/joyent_server_start.rb +29 -27
- data/lib/chef/knife/joyent_server_stop.rb +28 -27
- data/lib/chef/knife/joyent_snapshot_create.rb +16 -15
- data/lib/chef/knife/joyent_snapshot_delete.rb +30 -29
- data/lib/chef/knife/joyent_snapshot_list.rb +34 -33
- data/lib/chef/knife/joyent_tag_create.rb +29 -27
- data/lib/chef/knife/joyent_tag_delete.rb +45 -43
- data/lib/chef/knife/joyent_tag_list.rb +26 -24
- data/lib/knife-joyent/version.rb +1 -1
- metadata +9 -9
- data/lib/chef/knife/base.rb +0 -58
data/README.md
CHANGED
@@ -72,9 +72,9 @@ provider powered by [SmartDataCenter](http://www.joyent.com/products/smartdatace
|
|
72
72
|
|
73
73
|
## Contributors
|
74
74
|
|
75
|
-
[Sean Omera](https://github.com/someara) - Opscode
|
76
|
-
[Eric Saxby](https://github.com/sax) - ModCloth
|
77
|
-
[Stephen Lauck](https://github.com/stephenlauck) - ModCloth
|
75
|
+
- [Sean Omera](https://github.com/someara) - Opscode
|
76
|
+
- [Eric Saxby](https://github.com/sax) - ModCloth
|
77
|
+
- [Stephen Lauck](https://github.com/stephenlauck) - ModCloth
|
78
78
|
|
79
79
|
## License
|
80
80
|
|
data/knife-joyent.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
3
|
require 'knife-joyent/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.add_dependency "fog", "~> 1.
|
20
|
-
s.add_dependency "chef", "
|
19
|
+
s.add_dependency "fog", "~> 1.6"
|
20
|
+
s.add_dependency "chef", ">= 0.10.10"
|
21
21
|
s.require_paths = ["lib"]
|
22
22
|
|
23
23
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'chef/knife'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
module JoyentBase
|
6
|
+
|
7
|
+
def self.included(includer)
|
8
|
+
includer.class_eval do
|
9
|
+
deps do
|
10
|
+
require 'fog'
|
11
|
+
require 'net/ssh/multi'
|
12
|
+
require 'readline'
|
13
|
+
require 'chef/json_compat'
|
14
|
+
end
|
15
|
+
|
16
|
+
option :joyent_username,
|
17
|
+
:short => '-U USERNAME',
|
18
|
+
:long => '--joyent-username USERNAME',
|
19
|
+
:description => 'Your Joyent username',
|
20
|
+
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_username] = key}
|
21
|
+
|
22
|
+
option :joyent_password,
|
23
|
+
:short => '-P PASSWORD',
|
24
|
+
:long => '--joyent-password PASSOWRD',
|
25
|
+
:description => 'Your Joyent password',
|
26
|
+
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_password] = key }
|
27
|
+
|
28
|
+
option :joyent_keyname,
|
29
|
+
:long => '--joyent-keyname name of ssh key for signature auth',
|
30
|
+
:description => 'name of ssh key for signature auth',
|
31
|
+
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_keyname] = key }
|
32
|
+
|
33
|
+
option :joyent_keyfile,
|
34
|
+
:long => '--joyent-keyfile path to ssh private key for signature auth',
|
35
|
+
:description => 'path to ssh private key for signature auth',
|
36
|
+
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_keyfile] = key }
|
37
|
+
|
38
|
+
option :joyent_api_url,
|
39
|
+
:short => "-L JOYENT_API_URL",
|
40
|
+
:long => "--joyent-api-url JOYENT_API_URL",
|
41
|
+
:description => "Joyent API URL",
|
42
|
+
:proc => Proc.new {|key| Chef::Config[:knife][:joyent_api_url] = key }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def connection
|
47
|
+
@connection ||= begin
|
48
|
+
connection = Fog::Compute.new(
|
49
|
+
:provider => 'Joyent',
|
50
|
+
:joyent_username => Chef::Config[:knife][:joyent_username],
|
51
|
+
:joyent_password => Chef::Config[:knife][:joyent_password],
|
52
|
+
:joyent_keyname => Chef::Config[:knife][:joyent_keyname],
|
53
|
+
:joyent_keyfile => Chef::Config[:knife][:joyent_keyfile],
|
54
|
+
:joyent_url => Chef::Config[:knife][:joyent_api_url]
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,29 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require 'chef/knife/joyent_base'
|
2
2
|
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class JoyentFlavorList < Knife
|
3
6
|
|
4
|
-
|
5
|
-
class JoyentFlavorList < Chef::Knife
|
7
|
+
include Knife::JoyentBase
|
6
8
|
|
7
|
-
|
9
|
+
banner "knife joyent flavor list <options>"
|
8
10
|
|
9
|
-
|
11
|
+
def run
|
12
|
+
flavor_list = [
|
13
|
+
ui.color('Name', :bold),
|
14
|
+
ui.color('RAM', :bold),
|
15
|
+
ui.color('Disk', :bold),
|
16
|
+
ui.color('Swap', :bold),
|
17
|
+
]
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
]
|
19
|
+
self.connection.flavors.sort_by(&:memory).each do |flavor|
|
20
|
+
flavor_list << flavor.name.to_s
|
21
|
+
flavor_list << "#{flavor.memory/1024} GB"
|
22
|
+
flavor_list << "#{flavor.disk/1024} GB"
|
23
|
+
flavor_list << "#{flavor.swap/1024} GB"
|
24
|
+
end
|
18
25
|
|
19
|
-
|
20
|
-
flavor_list << flavor.name.to_s
|
21
|
-
flavor_list << "#{flavor.memory/1024} GB"
|
22
|
-
flavor_list << "#{flavor.disk/1024} GB"
|
23
|
-
flavor_list << "#{flavor.swap/1024} GB"
|
26
|
+
puts ui.list(flavor_list, :uneven_columns_across, 4)
|
24
27
|
end
|
25
|
-
|
26
|
-
puts ui.list(flavor_list, :uneven_columns_across, 4)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -1,30 +1,32 @@
|
|
1
|
-
require
|
1
|
+
require 'chef/knife/joyent_base'
|
2
2
|
|
3
|
-
|
4
|
-
class
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class JoyentImageList < Knife
|
5
6
|
|
6
|
-
|
7
|
+
include Knife::JoyentBase
|
7
8
|
|
8
|
-
|
9
|
+
banner "knife joyent image list <options>"
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
def run
|
12
|
+
images = [
|
13
|
+
ui.color('ID', :bold),
|
14
|
+
ui.color('Name', :bold),
|
15
|
+
ui.color('Version', :bold),
|
16
|
+
ui.color('OS', :bold),
|
17
|
+
ui.color('Type', :bold),
|
18
|
+
]
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
self.connection.images.sort_by(&:name).each do |i|
|
21
|
+
images << i.id.to_s
|
22
|
+
images << i.name
|
23
|
+
images << i.version
|
24
|
+
images << i.os
|
25
|
+
images << i.type
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
+
puts ui.list(images, :uneven_columns_across, 5)
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -1,54 +1,55 @@
|
|
1
|
-
require
|
1
|
+
require 'chef/knife/joyent_base'
|
2
2
|
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class JoyentKeyAdd < Knife
|
3
6
|
|
4
|
-
|
5
|
-
class JoyentKeyAdd < Chef::Knife
|
7
|
+
include Knife::JoyentBase
|
6
8
|
|
7
|
-
|
9
|
+
banner "knife joyent key add -f <keyfile> -k <name>"
|
8
10
|
|
9
|
-
|
11
|
+
option :keyname,
|
12
|
+
:short => '-k KEY_NAME',
|
13
|
+
:long => '--keyname KEY_NAME',
|
14
|
+
:description => 'Name for identifying this key'
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
option :keyfile,
|
17
|
+
:short => '-f KEY_FILE',
|
18
|
+
:long => '--keyfile KEY_FILE',
|
19
|
+
:description => 'Full path to location of ssh public key'
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
:description => 'Full path to location of ssh public key'
|
21
|
+
def run
|
22
|
+
keyfile = config[:keyfile]
|
23
|
+
keyname = config[:keyname]
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
unless File.exists?(keyfile)
|
26
|
+
ui.error('keyfile specified does not exist')
|
27
|
+
exit 1
|
28
|
+
end
|
24
29
|
|
25
|
-
unless File.exists?(keyfile)
|
26
|
-
ui.error('keyfile specified does not exist')
|
27
|
-
exit 1
|
28
|
-
end
|
29
30
|
|
31
|
+
key = begin
|
32
|
+
File.read(keyfile)
|
33
|
+
rescue
|
34
|
+
puts ui.error('Unable to read contents of keyfile')
|
35
|
+
exit 1
|
36
|
+
end
|
30
37
|
|
31
|
-
key = begin
|
32
|
-
File.read(keyfile)
|
33
|
-
rescue
|
34
|
-
puts ui.error('Unable to read contents of keyfile')
|
35
|
-
exit 1
|
36
|
-
end
|
37
38
|
|
39
|
+
begin
|
40
|
+
r = self.connection.create_key(
|
41
|
+
:name => keyname,
|
42
|
+
:key => key
|
43
|
+
)
|
44
|
+
rescue Excon::Errors::Conflict => e
|
45
|
+
body = MultiJson.decode(e.response.body)
|
46
|
+
ui.error(body["message"])
|
47
|
+
exit 1
|
48
|
+
end
|
38
49
|
|
39
|
-
|
40
|
-
|
41
|
-
:name => keyname,
|
42
|
-
:key => key
|
43
|
-
)
|
44
|
-
rescue Excon::Errors::Conflict => e
|
45
|
-
body = MultiJson.decode(e.response.body)
|
46
|
-
ui.error(body["message"])
|
47
|
-
exit 1
|
50
|
+
puts ui.color('Created key: '+keyname, :cyan)
|
51
|
+
exit 0
|
48
52
|
end
|
49
|
-
|
50
|
-
puts ui.color('Created key: '+keyname, :cyan)
|
51
|
-
exit 0
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -1,33 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require 'chef/knife/joyent_base'
|
2
2
|
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class JoyentKeyDelete < Knife
|
3
6
|
|
4
|
-
|
5
|
-
class JoyentKeyDelete < Chef::Knife
|
7
|
+
include Knife::JoyentBase
|
6
8
|
|
7
|
-
|
9
|
+
banner "knife joyent key delete <name>"
|
8
10
|
|
9
|
-
|
11
|
+
def run
|
12
|
+
unless name_args.size === 1
|
13
|
+
show_usage
|
14
|
+
end
|
10
15
|
|
11
|
-
|
12
|
-
unless name_args.size === 1
|
13
|
-
show_usage
|
14
|
-
end
|
16
|
+
keyname = name_args.first
|
15
17
|
|
16
|
-
|
18
|
+
begin
|
19
|
+
self.connection.delete_key(keyname)
|
20
|
+
rescue Excon::Errors::NotFound => e
|
21
|
+
ui.error("Key [#{keyname}] does not exist.")
|
22
|
+
exit 1
|
23
|
+
rescue Excon::Errors::Conflict => e
|
24
|
+
body = MultiJson.decode(e.response.body)
|
25
|
+
ui.error(body["message"])
|
26
|
+
exit 1
|
27
|
+
end
|
17
28
|
|
18
|
-
|
19
|
-
|
20
|
-
rescue Excon::Errors::NotFound => e
|
21
|
-
ui.error("Key [#{keyname}] does not exist.")
|
22
|
-
exit 1
|
23
|
-
rescue Excon::Errors::Conflict => e
|
24
|
-
body = MultiJson.decode(e.response.body)
|
25
|
-
ui.error(body["message"])
|
26
|
-
exit 1
|
29
|
+
puts ui.color('Deleted key: '+keyname, :cyan)
|
30
|
+
exit 0
|
27
31
|
end
|
28
|
-
|
29
|
-
puts ui.color('Deleted key: '+keyname, :cyan)
|
30
|
-
exit 0
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -1,25 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require 'chef/knife/joyent_base'
|
2
2
|
|
3
|
-
|
4
|
-
class
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class JoyentKeyList < Knife
|
5
6
|
|
6
|
-
|
7
|
+
include Knife::JoyentBase
|
7
8
|
|
8
|
-
|
9
|
+
banner "knife joyent key list"
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
def run
|
12
|
+
keys = [
|
13
|
+
ui.color('Name', :bold),
|
14
|
+
ui.color('Key', :bold),
|
15
|
+
]
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
puts ui.list(keys, :uneven_columns_across, 2)
|
17
|
+
self.connection.keys.sort_by(&:name).each do |k|
|
18
|
+
keys << k.name
|
19
|
+
keys << k.key[0..32] + '...'
|
20
|
+
end
|
22
21
|
|
22
|
+
puts ui.list(keys, :uneven_columns_across, 2)
|
23
|
+
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|