virtualmaster 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.mdown CHANGED
@@ -48,8 +48,13 @@ VirtualMaster CLI can install your SSH keys to a remote machine automatically us
48
48
  Instance ready!
49
49
  Try to login using `ssh root@195.140.253.130'
50
50
 
51
- If you want to specify other key (ie. not ~/.ssh/id_rsa) use option `--identity IDENTITY_FILE`.
51
+ If you want to specify other key (ie. not ~/.ssh/id\_rsa) use option `--identity IDENTITY_FILE`.
52
52
 
53
53
  ## More information
54
54
 
55
- Additional topics are available in [the wiki](https://github.com/Virtualmaster/virtualmaster-cli/wiki).
55
+ Additional topics are available in [the wiki](https://github.com/Virtualmaster/virtualmaster-cli/wiki).
56
+
57
+ ## Changelog
58
+
59
+ * v0.0.5 - Added support for availability zones and instance levels
60
+ * v0.0.3 - First public release
data/lib/vmaster.rb CHANGED
@@ -2,6 +2,7 @@ require "vmaster/version"
2
2
  require "vmaster/helpers"
3
3
  require "vmaster/cli"
4
4
  require "commander/import"
5
+ require "vmaster/request.rb"
5
6
 
6
7
  # include commands
7
8
  require 'vmaster/config_command'
@@ -62,10 +62,10 @@ module VirtualMaster
62
62
  profile_list.first
63
63
  end
64
64
 
65
- def self.create_instance(name, image_id, profile_id)
65
+ def self.create_instance(name, image_id, profile_id, realm)
66
66
  api = VirtualMaster::CLI.api
67
67
 
68
- api.create_instance(image_id, :name => name, :hwp_id => profile_id)
68
+ api.create_instance(image_id, :name => name, :hwp_id => profile_id, :realm_id => realm)
69
69
  end
70
70
  end
71
71
  end
@@ -0,0 +1,12 @@
1
+ require 'rest_client'
2
+
3
+ #
4
+ # Monkey-patch RestClient.request to include User Agent
5
+ #
6
+ module RestClient
7
+ class Request
8
+ def default_headers
9
+ { :accept => '*/*; q=0.5, application/xml', :accept_encoding => 'gzip, deflate', "User-Agent" => "virtualmaster-cli/#{VirtualMaster::VERSION} #{RUBY_PLATFORM}" }
10
+ end
11
+ end
12
+ end
@@ -16,10 +16,14 @@ command :create do |c|
16
16
  c.option '--profile PROFILE', String, 'instance hardware profile'
17
17
  c.option '--copy-id', 'install public key on a machine'
18
18
  c.option '--identity IDENTITY', String, 'SSH identity to use (with --copy-id)'
19
+ c.option '--zone ZONE', String, 'Availability zone to launch instance i'
20
+ c.option '--level LEVEL', String, 'Instance level to use (personal, production)'
19
21
  c.option '--wait', 'wait for instance to become operational'
20
22
  c.action do |args, options|
21
23
  # default values
22
24
  options.default :identity => File.join(ENV['HOME'], '.ssh/id_rsa')
25
+ options.default :zone => "prague-l1"
26
+ options.default :level => "personal"
23
27
 
24
28
  name = args.shift || abort('Server name required')
25
29
 
@@ -58,8 +62,10 @@ command :create do |c|
58
62
  abort "Internal error: hardware profile not available" unless hwp
59
63
 
60
64
  say "Creating '#{profile_name}' instance (#{profile[:memory]} MB memory/#{profile[:storage]/1024} GB storage)"
61
-
62
- instance = VirtualMaster::Helpers.create_instance(name, image_id, hwp.id)
65
+
66
+ realm = "#{options.zone}-#{options.level}"
67
+
68
+ instance = VirtualMaster::Helpers.create_instance(name, image_id, hwp.id, realm)
63
69
 
64
70
  # TODO handle exceptions (invalid image/profile, limits, etc.)
65
71
 
@@ -122,12 +128,12 @@ command :list do |c|
122
128
  ip_address = "(not assigned)"
123
129
  end
124
130
 
125
- instances << [instance.name, instance.state, ip_address]
131
+ instances << [instance.name, instance.state, ip_address, instance.realm.id]
126
132
  end
127
133
 
128
134
  abort "No instances found" if instances.empty?
129
135
 
130
- table = Terminal::Table.new :headings => ['name','state','ip_address'], :rows => instances
136
+ table = Terminal::Table.new :headings => ['name','state','ip_address', 'zone'], :rows => instances
131
137
  puts table
132
138
  end
133
139
  end
@@ -136,6 +142,9 @@ def instance_action(action, args)
136
142
  name = args.shift || abort('server name required')
137
143
 
138
144
  instance = VirtualMaster::Helpers.get_instance(name)
145
+
146
+ abort "Invalid instance name!" if instance.nil?
147
+
139
148
  instance.send("#{action}!")
140
149
  end
141
150
 
@@ -1,3 +1,3 @@
1
1
  module VirtualMaster
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtualmaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-13 00:00:00.000000000 Z
12
+ date: 2012-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
16
- requirement: &70220237000360 !ruby/object:Gem::Requirement
16
+ requirement: &70140390251200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70220237000360
24
+ version_requirements: *70140390251200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: deltacloud-client
27
- requirement: &70220236995660 !ruby/object:Gem::Requirement
27
+ requirement: &70140390250700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.5.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70220236995660
35
+ version_requirements: *70140390250700
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: terminal-table
38
- requirement: &70220236993960 !ruby/object:Gem::Requirement
38
+ requirement: &70140255842280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.4.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70220236993960
46
+ version_requirements: *70140255842280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: net-ssh
49
- requirement: &70220236992760 !ruby/object:Gem::Requirement
49
+ requirement: &70140255840660 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.3.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70220236992760
57
+ version_requirements: *70140255840660
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70220236991620 !ruby/object:Gem::Requirement
60
+ requirement: &70140255839140 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '2'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70220236991620
68
+ version_requirements: *70140255839140
69
69
  description: Command line interface to VirtualMaster. Control your virtual infrastructure.
70
70
  email:
71
71
  - radim@laststation.net
@@ -83,6 +83,7 @@ files:
83
83
  - lib/vmaster/cli.rb
84
84
  - lib/vmaster/config_command.rb
85
85
  - lib/vmaster/helpers.rb
86
+ - lib/vmaster/request.rb
86
87
  - lib/vmaster/server_commands.rb
87
88
  - lib/vmaster/version.rb
88
89
  - spec/commands_spec.rb