waz-cmd 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -4
- data/Gemfile +4 -4
- data/LICENSE +31 -31
- data/README.md +66 -66
- data/Rakefile +2 -2
- data/bin/waz +1 -0
- data/lib/waz-cmd/templates/show_affinity_group.erb +3 -3
- data/lib/waz-cmd/templates/show_history.erb +21 -21
- data/lib/waz-cmd/version.rb +5 -5
- data/lib/waz-cmd.rb +109 -109
- data/waz-cmd.gemspec +26 -26
- metadata +102 -72
data/.gitignore
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
*.gem
|
2
|
-
.bundle
|
3
|
-
Gemfile.lock
|
4
|
-
pkg/*
|
1
|
+
*.gem
|
2
|
+
.bundle
|
3
|
+
Gemfile.lock
|
4
|
+
pkg/*
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in waz-cmd.gemspec
|
4
|
-
gemspec
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in waz-cmd.gemspec
|
4
|
+
gemspec
|
data/LICENSE
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
Microsoft Public License (Ms-PL)
|
2
|
-
|
3
|
-
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
|
4
|
-
|
5
|
-
1. Definitions
|
6
|
-
|
7
|
-
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
|
8
|
-
|
9
|
-
A "contribution" is the original software, or any additions or changes to the software.
|
10
|
-
|
11
|
-
A "contributor" is any person that distributes its contribution under this license.
|
12
|
-
|
13
|
-
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
14
|
-
|
15
|
-
2. Grant of Rights
|
16
|
-
|
17
|
-
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
18
|
-
|
19
|
-
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
20
|
-
|
21
|
-
3. Conditions and Limitations
|
22
|
-
|
23
|
-
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
24
|
-
|
25
|
-
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
|
26
|
-
|
27
|
-
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
|
28
|
-
|
29
|
-
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
|
30
|
-
|
31
|
-
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
|
1
|
+
Microsoft Public License (Ms-PL)
|
2
|
+
|
3
|
+
This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
|
4
|
+
|
5
|
+
1. Definitions
|
6
|
+
|
7
|
+
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.
|
8
|
+
|
9
|
+
A "contribution" is the original software, or any additions or changes to the software.
|
10
|
+
|
11
|
+
A "contributor" is any person that distributes its contribution under this license.
|
12
|
+
|
13
|
+
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
|
14
|
+
|
15
|
+
2. Grant of Rights
|
16
|
+
|
17
|
+
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
|
18
|
+
|
19
|
+
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
|
20
|
+
|
21
|
+
3. Conditions and Limitations
|
22
|
+
|
23
|
+
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
|
24
|
+
|
25
|
+
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
|
26
|
+
|
27
|
+
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
|
28
|
+
|
29
|
+
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
|
30
|
+
|
31
|
+
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
|
data/README.md
CHANGED
@@ -1,66 +1,66 @@
|
|
1
|
-
Waz-Cmd
|
2
|
-
=======
|
3
|
-
|
4
|
-
Installation
|
5
|
-
------------
|
6
|
-
|
7
|
-
To install, just `gem install waz-cmd`
|
8
|
-
|
9
|
-
Example usage
|
10
|
-
-----------
|
11
|
-
|
12
|
-
c:\>waz generate certificates
|
13
|
-
Writing certificate to 'c:\users\smarx/.waz/cert.pem'
|
14
|
-
Writing certificate in .cer form to 'c:\users\smarx/.waz/cert.cer'
|
15
|
-
Writing key to 'c:\users\smarx/.waz/key.pem'
|
16
|
-
|
17
|
-
To use the new certificate, upload 'c:\users\smarx/.waz/cert.cer' as a management certificate in the Windows Azure portal (https://windows.azure.com)
|
18
|
-
|
19
|
-
c:\>waz set subscriptionId XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
20
|
-
|
21
|
-
c:\>waz deploy blobedit staging c:\repositories\smarxrole\packages\ExtraSmall.cspkg c:\repositories\smarxrole\packages\ServiceConfiguration.blobedit.cscfg
|
22
|
-
Waiting for operation to complete...
|
23
|
-
Operation succeeded (200)
|
24
|
-
|
25
|
-
c:\>waz show deployment blobedit staging
|
26
|
-
STAGING
|
27
|
-
Label: ExtraSmall.cspkg2011-07-0120:54:04
|
28
|
-
Name: 27efeebeb18e4eb582a2e8fa0883957e
|
29
|
-
Status: Running
|
30
|
-
Url: http://78a9fdb38bc442238739b1154ea78cda.cloudapp.net/
|
31
|
-
SDK version: #1.4.20407.2049
|
32
|
-
ROLES
|
33
|
-
WebRole (WA-GUEST-OS-2.5_201104-01)
|
34
|
-
2 Ready (use --expand to see details)
|
35
|
-
ENDPOINTS
|
36
|
-
157.55.181.17:80 on WebRole
|
37
|
-
|
38
|
-
c:\>waz swap blobedit
|
39
|
-
Waiting for operation to complete...
|
40
|
-
Operation succeeded (200)
|
41
|
-
|
42
|
-
c:\>waz show deployment blobedit production
|
43
|
-
PRODUCTION
|
44
|
-
Label: ExtraSmall.cspkg2011-07-0120:54:04
|
45
|
-
Name: 27efeebeb18e4eb582a2e8fa0883957e
|
46
|
-
Status: Running
|
47
|
-
Url: http://blobedit.cloudapp.net/
|
48
|
-
SDK version: #1.4.20407.2049
|
49
|
-
ROLES
|
50
|
-
WebRole (WA-GUEST-OS-2.5_201104-01)
|
51
|
-
2 Ready (use --expand to see details)
|
52
|
-
ENDPOINTS
|
53
|
-
157.55.181.17:80 on WebRole
|
54
|
-
|
55
|
-
c:\>waz show configuration blobedit production
|
56
|
-
WebRole
|
57
|
-
Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString: UseDevelopmentStorage=true
|
58
|
-
GitUrl: git://github.com/smarx/blobedit
|
59
|
-
DataConnectionString: DefaultEndpointsProtocol=http;AccountName=YOURACCOUNT;AccountKey=YOURKEY
|
60
|
-
ContainerName:
|
61
|
-
NumProcesses: 4
|
62
|
-
|
63
|
-
Documentation
|
64
|
-
-------------
|
65
|
-
|
66
|
-
Run `waz help` for full documentation.
|
1
|
+
Waz-Cmd
|
2
|
+
=======
|
3
|
+
|
4
|
+
Installation
|
5
|
+
------------
|
6
|
+
|
7
|
+
To install, just `gem install waz-cmd`
|
8
|
+
|
9
|
+
Example usage
|
10
|
+
-----------
|
11
|
+
|
12
|
+
c:\>waz generate certificates
|
13
|
+
Writing certificate to 'c:\users\smarx/.waz/cert.pem'
|
14
|
+
Writing certificate in .cer form to 'c:\users\smarx/.waz/cert.cer'
|
15
|
+
Writing key to 'c:\users\smarx/.waz/key.pem'
|
16
|
+
|
17
|
+
To use the new certificate, upload 'c:\users\smarx/.waz/cert.cer' as a management certificate in the Windows Azure portal (https://windows.azure.com)
|
18
|
+
|
19
|
+
c:\>waz set subscriptionId XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
20
|
+
|
21
|
+
c:\>waz deploy blobedit staging c:\repositories\smarxrole\packages\ExtraSmall.cspkg c:\repositories\smarxrole\packages\ServiceConfiguration.blobedit.cscfg
|
22
|
+
Waiting for operation to complete...
|
23
|
+
Operation succeeded (200)
|
24
|
+
|
25
|
+
c:\>waz show deployment blobedit staging
|
26
|
+
STAGING
|
27
|
+
Label: ExtraSmall.cspkg2011-07-0120:54:04
|
28
|
+
Name: 27efeebeb18e4eb582a2e8fa0883957e
|
29
|
+
Status: Running
|
30
|
+
Url: http://78a9fdb38bc442238739b1154ea78cda.cloudapp.net/
|
31
|
+
SDK version: #1.4.20407.2049
|
32
|
+
ROLES
|
33
|
+
WebRole (WA-GUEST-OS-2.5_201104-01)
|
34
|
+
2 Ready (use --expand to see details)
|
35
|
+
ENDPOINTS
|
36
|
+
157.55.181.17:80 on WebRole
|
37
|
+
|
38
|
+
c:\>waz swap blobedit
|
39
|
+
Waiting for operation to complete...
|
40
|
+
Operation succeeded (200)
|
41
|
+
|
42
|
+
c:\>waz show deployment blobedit production
|
43
|
+
PRODUCTION
|
44
|
+
Label: ExtraSmall.cspkg2011-07-0120:54:04
|
45
|
+
Name: 27efeebeb18e4eb582a2e8fa0883957e
|
46
|
+
Status: Running
|
47
|
+
Url: http://blobedit.cloudapp.net/
|
48
|
+
SDK version: #1.4.20407.2049
|
49
|
+
ROLES
|
50
|
+
WebRole (WA-GUEST-OS-2.5_201104-01)
|
51
|
+
2 Ready (use --expand to see details)
|
52
|
+
ENDPOINTS
|
53
|
+
157.55.181.17:80 on WebRole
|
54
|
+
|
55
|
+
c:\>waz show configuration blobedit production
|
56
|
+
WebRole
|
57
|
+
Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString: UseDevelopmentStorage=true
|
58
|
+
GitUrl: git://github.com/smarx/blobedit
|
59
|
+
DataConnectionString: DefaultEndpointsProtocol=http;AccountName=YOURACCOUNT;AccountKey=YOURKEY
|
60
|
+
ContainerName:
|
61
|
+
NumProcesses: 4
|
62
|
+
|
63
|
+
Documentation
|
64
|
+
-------------
|
65
|
+
|
66
|
+
Run `waz help` for full documentation.
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
Bundler::GemHelper.install_tasks
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
data/bin/waz
CHANGED
@@ -476,6 +476,7 @@ command 'deploy' do |c|
|
|
476
476
|
|
477
477
|
config = open(args[3], 'rt') { |f| f.read }
|
478
478
|
config = config[1..-1] if config[0].force_encoding('utf-8') == "\xEF\xBB\xBF".force_encoding('utf-8')
|
479
|
+
config = config[3..-1] if config[0..2].force_encoding('utf-8') == "\xEF\xBB\xBF".force_encoding('utf-8')
|
479
480
|
begin
|
480
481
|
make_call("services/hostedservices/#{args[0]}/deploymentslots/#{args[1]}", :post, options,
|
481
482
|
Nokogiri::XML::Builder.new(:encoding => 'utf-8') { |xml|
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= Base64.decode64 group['Label'] %>
|
2
|
-
Name: <%= group['Name'] %>
|
3
|
-
Location: <%= group['Location'] %>
|
1
|
+
<%= Base64.decode64 group['Label'] %>
|
2
|
+
Name: <%= group['Name'] %>
|
3
|
+
Location: <%= group['Location'] %>
|
@@ -1,21 +1,21 @@
|
|
1
|
-
% if history['SubscriptionOperation'].nil?
|
2
|
-
No history to display.
|
3
|
-
% else
|
4
|
-
% operations = history['SubscriptionOperation']
|
5
|
-
% operations = [operations] unless operations.kind_of? Array
|
6
|
-
% operations.each do |operation|
|
7
|
-
<%= $terminal.color operation['OperationName'], :bold %>
|
8
|
-
ID: <%= operation['OperationId'] %>
|
9
|
-
Parameters: <%= operation['OperationParameters']['OperationParameter'].sort{|a,b| a['a:Name'] <=> b['a:Name']}.map{|p| "#{p['a:Name']}=#{p['a:Value'].length > 30 ? '...' : p['a:Value']}"}.join ', ' %>
|
10
|
-
Status: <%= operation['OperationStatus']['Status'] %> (<%= operation['OperationStatus']['HttpStatusCode'] %>)
|
11
|
-
Start: <%= operation['OperationStartedTime'] %>
|
12
|
-
% if operation['OperationCompletedTime']
|
13
|
-
Completed: <%= operation['OperationCompletedTime'] %>
|
14
|
-
% end
|
15
|
-
% if operation['OperationCaller']['UsedServiceManagementApi'] == 'true'
|
16
|
-
Caller: <%= operation['OperationCaller']['ClientIP'] %> (<%= operation['OperationCaller']['SubscriptionCertificateThumbprint'] %>)
|
17
|
-
% else
|
18
|
-
Caller: <%= operation['OperationCaller']['UserEmailAddress'] %>
|
19
|
-
% end
|
20
|
-
% end
|
21
|
-
% end
|
1
|
+
% if history['SubscriptionOperation'].nil?
|
2
|
+
No history to display.
|
3
|
+
% else
|
4
|
+
% operations = history['SubscriptionOperation']
|
5
|
+
% operations = [operations] unless operations.kind_of? Array
|
6
|
+
% operations.each do |operation|
|
7
|
+
<%= $terminal.color operation['OperationName'], :bold %>
|
8
|
+
ID: <%= operation['OperationId'] %>
|
9
|
+
Parameters: <%= operation['OperationParameters']['OperationParameter'].sort{|a,b| a['a:Name'] <=> b['a:Name']}.map{|p| "#{p['a:Name']}=#{p['a:Value'].length > 30 ? '...' : p['a:Value']}"}.join ', ' %>
|
10
|
+
Status: <%= operation['OperationStatus']['Status'] %> (<%= operation['OperationStatus']['HttpStatusCode'] %>)
|
11
|
+
Start: <%= operation['OperationStartedTime'] %>
|
12
|
+
% if operation['OperationCompletedTime']
|
13
|
+
Completed: <%= operation['OperationCompletedTime'] %>
|
14
|
+
% end
|
15
|
+
% if operation['OperationCaller']['UsedServiceManagementApi'] == 'true'
|
16
|
+
Caller: <%= operation['OperationCaller']['ClientIP'] %> (<%= operation['OperationCaller']['SubscriptionCertificateThumbprint'] %>)
|
17
|
+
% else
|
18
|
+
Caller: <%= operation['OperationCaller']['UserEmailAddress'] %>
|
19
|
+
% end
|
20
|
+
% end
|
21
|
+
% end
|
data/lib/waz-cmd/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
module Waz
|
2
|
-
module Cmd
|
3
|
-
VERSION = "0.4.
|
4
|
-
end
|
5
|
-
end
|
1
|
+
module Waz
|
2
|
+
module Cmd
|
3
|
+
VERSION = "0.4.1"
|
4
|
+
end
|
5
|
+
end
|
data/lib/waz-cmd.rb
CHANGED
@@ -1,109 +1,109 @@
|
|
1
|
-
module Waz
|
2
|
-
module Cmd
|
3
|
-
begin
|
4
|
-
require 'faster_require' if RUBY_PLATFORM =~ /win32|mingw32/
|
5
|
-
rescue
|
6
|
-
puts 'WARNING: Waz will run faster on Windows if you install the "faster_require" gem.'
|
7
|
-
end
|
8
|
-
require 'rexml/document'
|
9
|
-
require 'rexml/xpath'
|
10
|
-
require 'iconv'
|
11
|
-
begin
|
12
|
-
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32|mingw32/
|
13
|
-
rescue
|
14
|
-
puts 'WARNING: Output will look weird on Windows unless you install the "win32console" gem.'
|
15
|
-
end
|
16
|
-
require 'openssl'
|
17
|
-
require 'rest_client'
|
18
|
-
require 'tilt'
|
19
|
-
require 'base64'
|
20
|
-
require 'yaml'
|
21
|
-
require 'crack'
|
22
|
-
require 'nokogiri'
|
23
|
-
|
24
|
-
def set_defaults(options)
|
25
|
-
options.default :pem => "#{ENV['HOME']}/.waz/cert.pem", :cer => "#{ENV['HOME']}/.waz/cert.cer", :key => "#{ENV['HOME']}/.waz/key.pem"
|
26
|
-
options.default :subscriptionId => $config['subscriptionId'] if $config['subscriptionId']
|
27
|
-
end
|
28
|
-
|
29
|
-
def make_call(path, method, options, body=nil)
|
30
|
-
headers = { 'x-ms-version' => '2011-06-01' }
|
31
|
-
headers['Content-Type'] = 'application/xml' unless body.nil?
|
32
|
-
options = {
|
33
|
-
:url => "https://management.core.windows.net/#{options.subscriptionId}/#{path}",
|
34
|
-
:method => method,
|
35
|
-
:headers => headers,
|
36
|
-
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read(options.pem)),
|
37
|
-
:ssl_client_key => OpenSSL::PKey::RSA.new(File.read(options.key))
|
38
|
-
}
|
39
|
-
options[:payload] = body unless body.nil?
|
40
|
-
if block_given?
|
41
|
-
yield RestClient::Request.execute options
|
42
|
-
else
|
43
|
-
Crack::XML.parse RestClient::Request.execute options
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def arrayize(x)
|
48
|
-
return [] if x.nil?
|
49
|
-
return x if x.kind_of?(Array)
|
50
|
-
return [x]
|
51
|
-
end
|
52
|
-
|
53
|
-
def restar_instance(star)
|
54
|
-
command "re#{star} instance" do |c|
|
55
|
-
c.syntax = "waz re#{star} instance <application> <production|staging> <instance> [options]"
|
56
|
-
c.description = "Re#{star} the specified instance"
|
57
|
-
c.action do |args, options|
|
58
|
-
set_defaults options
|
59
|
-
raise 'Subscription ID is required' unless options.subscriptionId
|
60
|
-
raise 'Application name is required' unless args[0]
|
61
|
-
raise 'Deployment name is required' unless args[1]
|
62
|
-
raise 'Instance name is required' unless args[2]
|
63
|
-
make_call("services/hostedservices/#{args[0]}/deploymentslots/#{args[1]}/roleinstances/#{args[2]}?comp=re#{star}", :post, options, '') do |response|
|
64
|
-
wait_for_completion options, response.headers[:x_ms_request_id]
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def startstop(verb, status)
|
71
|
-
command verb do |c|
|
72
|
-
c.syntax = "waz #{verb} <application> <production|staging> [options]"
|
73
|
-
c.description = "#{verb.capitalize} the deployment in the specified slot of the specified application"
|
74
|
-
c.action do |args, options|
|
75
|
-
set_defaults options
|
76
|
-
raise 'Subscription ID is required' unless options.subscriptionId
|
77
|
-
raise 'Application name is required' unless args[0]
|
78
|
-
raise 'Deployment slot is required' unless args[1]
|
79
|
-
|
80
|
-
make_call("services/hostedservices/#{args[0]}/deploymentslots/#{args[1]}/?comp=status", :post, options,
|
81
|
-
Nokogiri::XML::Builder.new(:encoding => 'utf-8') { |xml|
|
82
|
-
xml.UpdateDeploymentStatus('xmlns' => 'http://schemas.microsoft.com/windowsazure') {
|
83
|
-
xml.Status status
|
84
|
-
}
|
85
|
-
}.to_xml) do |response|
|
86
|
-
wait_for_completion options, response.headers[:x_ms_request_id]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def wait_for_completion(options, requestId)
|
93
|
-
puts 'Waiting for operation to complete...'
|
94
|
-
done = false
|
95
|
-
while not done
|
96
|
-
status = make_call("operations/#{requestId}", :get, options)['Operation']
|
97
|
-
done = status['Status'] != 'InProgress'
|
98
|
-
if done
|
99
|
-
puts "Operation #{status['Status'].downcase} (#{status['HttpStatusCode']})"
|
100
|
-
if status['Error']
|
101
|
-
puts "#{status['Error']['Code']}: #{status['Error']['Message']}"
|
102
|
-
end
|
103
|
-
else
|
104
|
-
sleep 10
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
1
|
+
module Waz
|
2
|
+
module Cmd
|
3
|
+
begin
|
4
|
+
require 'faster_require' if RUBY_PLATFORM =~ /win32|mingw32/
|
5
|
+
rescue LoadError
|
6
|
+
puts 'WARNING: Waz will run faster on Windows if you install the "faster_require" gem.'
|
7
|
+
end
|
8
|
+
require 'rexml/document'
|
9
|
+
require 'rexml/xpath'
|
10
|
+
require 'iconv'
|
11
|
+
begin
|
12
|
+
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32|mingw32/
|
13
|
+
rescue LoadError
|
14
|
+
puts 'WARNING: Output will look weird on Windows unless you install the "win32console" gem.'
|
15
|
+
end
|
16
|
+
require 'openssl'
|
17
|
+
require 'rest_client'
|
18
|
+
require 'tilt'
|
19
|
+
require 'base64'
|
20
|
+
require 'yaml'
|
21
|
+
require 'crack'
|
22
|
+
require 'nokogiri'
|
23
|
+
|
24
|
+
def set_defaults(options)
|
25
|
+
options.default :pem => "#{ENV['HOME']}/.waz/cert.pem", :cer => "#{ENV['HOME']}/.waz/cert.cer", :key => "#{ENV['HOME']}/.waz/key.pem"
|
26
|
+
options.default :subscriptionId => $config['subscriptionId'] if $config['subscriptionId']
|
27
|
+
end
|
28
|
+
|
29
|
+
def make_call(path, method, options, body=nil)
|
30
|
+
headers = { 'x-ms-version' => '2011-06-01' }
|
31
|
+
headers['Content-Type'] = 'application/xml' unless body.nil?
|
32
|
+
options = {
|
33
|
+
:url => "https://management.core.windows.net/#{options.subscriptionId}/#{path}",
|
34
|
+
:method => method,
|
35
|
+
:headers => headers,
|
36
|
+
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read(options.pem)),
|
37
|
+
:ssl_client_key => OpenSSL::PKey::RSA.new(File.read(options.key))
|
38
|
+
}
|
39
|
+
options[:payload] = body unless body.nil?
|
40
|
+
if block_given?
|
41
|
+
yield RestClient::Request.execute options
|
42
|
+
else
|
43
|
+
Crack::XML.parse RestClient::Request.execute options
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def arrayize(x)
|
48
|
+
return [] if x.nil?
|
49
|
+
return x if x.kind_of?(Array)
|
50
|
+
return [x]
|
51
|
+
end
|
52
|
+
|
53
|
+
def restar_instance(star)
|
54
|
+
command "re#{star} instance" do |c|
|
55
|
+
c.syntax = "waz re#{star} instance <application> <production|staging> <instance> [options]"
|
56
|
+
c.description = "Re#{star} the specified instance"
|
57
|
+
c.action do |args, options|
|
58
|
+
set_defaults options
|
59
|
+
raise 'Subscription ID is required' unless options.subscriptionId
|
60
|
+
raise 'Application name is required' unless args[0]
|
61
|
+
raise 'Deployment name is required' unless args[1]
|
62
|
+
raise 'Instance name is required' unless args[2]
|
63
|
+
make_call("services/hostedservices/#{args[0]}/deploymentslots/#{args[1]}/roleinstances/#{args[2]}?comp=re#{star}", :post, options, '') do |response|
|
64
|
+
wait_for_completion options, response.headers[:x_ms_request_id]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def startstop(verb, status)
|
71
|
+
command verb do |c|
|
72
|
+
c.syntax = "waz #{verb} <application> <production|staging> [options]"
|
73
|
+
c.description = "#{verb.capitalize} the deployment in the specified slot of the specified application"
|
74
|
+
c.action do |args, options|
|
75
|
+
set_defaults options
|
76
|
+
raise 'Subscription ID is required' unless options.subscriptionId
|
77
|
+
raise 'Application name is required' unless args[0]
|
78
|
+
raise 'Deployment slot is required' unless args[1]
|
79
|
+
|
80
|
+
make_call("services/hostedservices/#{args[0]}/deploymentslots/#{args[1]}/?comp=status", :post, options,
|
81
|
+
Nokogiri::XML::Builder.new(:encoding => 'utf-8') { |xml|
|
82
|
+
xml.UpdateDeploymentStatus('xmlns' => 'http://schemas.microsoft.com/windowsazure') {
|
83
|
+
xml.Status status
|
84
|
+
}
|
85
|
+
}.to_xml) do |response|
|
86
|
+
wait_for_completion options, response.headers[:x_ms_request_id]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def wait_for_completion(options, requestId)
|
93
|
+
puts 'Waiting for operation to complete...'
|
94
|
+
done = false
|
95
|
+
while not done
|
96
|
+
status = make_call("operations/#{requestId}", :get, options)['Operation']
|
97
|
+
done = status['Status'] != 'InProgress'
|
98
|
+
if done
|
99
|
+
puts "Operation #{status['Status'].downcase} (#{status['HttpStatusCode']})"
|
100
|
+
if status['Error']
|
101
|
+
puts "#{status['Error']['Code']}: #{status['Error']['Message']}"
|
102
|
+
end
|
103
|
+
else
|
104
|
+
sleep 10
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/waz-cmd.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "waz-cmd/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "waz-cmd"
|
7
|
-
s.version = Waz::Cmd::VERSION
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["Steve Marx"]
|
10
|
-
s.email = ["Steve.Marx@microsoft.com"]
|
11
|
-
s.homepage = "http://github.com/smarx/waz-cmd"
|
12
|
-
s.summary = %q{Command-line tool to manage Windows Azure applications and storage accounts.}
|
13
|
-
s.description = %q{This gem allows you to perform most of the available operations in the Windows Azure Service Management API from a friendly commandline tool.}
|
14
|
-
|
15
|
-
s.files = `git ls-files`.split("\n")
|
16
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
-
s.require_paths = ["lib"]
|
19
|
-
|
20
|
-
s.add_dependency('commander')
|
21
|
-
s.add_dependency('tilt')
|
22
|
-
s.add_dependency('crack')
|
23
|
-
s.add_dependency('nokogiri')
|
24
|
-
s.add_dependency('waz-storage')
|
25
|
-
s.add_dependency('uuidtools')
|
26
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "waz-cmd/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "waz-cmd"
|
7
|
+
s.version = Waz::Cmd::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Steve Marx"]
|
10
|
+
s.email = ["Steve.Marx@microsoft.com"]
|
11
|
+
s.homepage = "http://github.com/smarx/waz-cmd"
|
12
|
+
s.summary = %q{Command-line tool to manage Windows Azure applications and storage accounts.}
|
13
|
+
s.description = %q{This gem allows you to perform most of the available operations in the Windows Azure Service Management API from a friendly commandline tool.}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency('commander', '4.0.4')
|
21
|
+
s.add_dependency('tilt')
|
22
|
+
s.add_dependency('crack')
|
23
|
+
s.add_dependency('nokogiri')
|
24
|
+
s.add_dependency('waz-storage')
|
25
|
+
s.add_dependency('uuidtools')
|
26
|
+
end
|
metadata
CHANGED
@@ -1,91 +1,112 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: waz-cmd
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 4
|
8
|
+
- 1
|
9
|
+
version: 0.4.1
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Steve Marx
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2011-09-22 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: commander
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
requirements:
|
26
|
+
- - "="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 4
|
30
|
+
- 0
|
31
|
+
- 4
|
32
|
+
version: 4.0.4
|
22
33
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
26
36
|
name: tilt
|
27
|
-
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
33
46
|
type: :runtime
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
37
49
|
name: crack
|
38
|
-
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
52
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
44
59
|
type: :runtime
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
48
62
|
name: nokogiri
|
49
|
-
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
55
72
|
type: :runtime
|
56
|
-
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
73
|
+
version_requirements: *id004
|
74
|
+
- !ruby/object:Gem::Dependency
|
59
75
|
name: waz-storage
|
60
|
-
|
76
|
+
prerelease: false
|
77
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
78
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
66
85
|
type: :runtime
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
86
|
+
version_requirements: *id005
|
87
|
+
- !ruby/object:Gem::Dependency
|
70
88
|
name: uuidtools
|
71
|
-
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
72
91
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
77
98
|
type: :runtime
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
Windows Azure Service Management API from a friendly commandline tool.
|
82
|
-
email:
|
99
|
+
version_requirements: *id006
|
100
|
+
description: This gem allows you to perform most of the available operations in the Windows Azure Service Management API from a friendly commandline tool.
|
101
|
+
email:
|
83
102
|
- Steve.Marx@microsoft.com
|
84
|
-
executables:
|
103
|
+
executables:
|
85
104
|
- waz
|
86
105
|
extensions: []
|
106
|
+
|
87
107
|
extra_rdoc_files: []
|
88
|
-
|
108
|
+
|
109
|
+
files:
|
89
110
|
- .gitignore
|
90
111
|
- Gemfile
|
91
112
|
- LICENSE
|
@@ -105,28 +126,37 @@ files:
|
|
105
126
|
- lib/waz-cmd/templates/show_storage.erb
|
106
127
|
- lib/waz-cmd/version.rb
|
107
128
|
- waz-cmd.gemspec
|
129
|
+
has_rdoc: true
|
108
130
|
homepage: http://github.com/smarx/waz-cmd
|
109
131
|
licenses: []
|
132
|
+
|
110
133
|
post_install_message:
|
111
134
|
rdoc_options: []
|
112
|
-
|
135
|
+
|
136
|
+
require_paths:
|
113
137
|
- lib
|
114
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
139
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
|
120
|
-
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
version: "0"
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
147
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
version: "0"
|
126
154
|
requirements: []
|
155
|
+
|
127
156
|
rubyforge_project:
|
128
|
-
rubygems_version: 1.
|
157
|
+
rubygems_version: 1.3.7
|
129
158
|
signing_key:
|
130
159
|
specification_version: 3
|
131
160
|
summary: Command-line tool to manage Windows Azure applications and storage accounts.
|
132
161
|
test_files: []
|
162
|
+
|