knife-azure 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/{readme.rdoc → README.rdoc} +68 -26
- data/lib/azure/connection.rb +3 -1
- data/lib/azure/deploy.rb +3 -0
- data/lib/azure/host.rb +2 -2
- data/lib/azure/image.rb +2 -2
- data/lib/azure/rest.rb +8 -3
- data/lib/azure/role.rb +1 -1
- data/lib/azure/storageaccount.rb +87 -0
- data/lib/chef/knife/azure_base.rb +19 -17
- data/lib/chef/knife/azure_image_list.rb +13 -10
- data/lib/chef/knife/azure_server_create.rb +45 -13
- data/lib/knife-azure/version.rb +1 -1
- metadata +208 -178
- data/Gemfile +0 -22
- data/Guardfile +0 -8
- data/Rakefile +0 -51
- data/knife-azure.gemspec +0 -106
- data/spec/functional/deploys_test.rb +0 -39
- data/spec/functional/host_test.rb +0 -22
- data/spec/functional/images_list_test.rb +0 -44
- data/spec/functional/role_test.rb +0 -16
- data/spec/integration/role_lifecycle_test.rb +0 -60
- data/spec/spec_helper.rb +0 -41
- data/spec/unit/assets/create_deployment.xml +0 -37
- data/spec/unit/assets/create_deployment_in_progress.xml +0 -1
- data/spec/unit/assets/create_host.xml +0 -7
- data/spec/unit/assets/create_role.xml +0 -54
- data/spec/unit/assets/list_deployments_for_service000.xml +0 -126
- data/spec/unit/assets/list_deployments_for_service001.xml +0 -166
- data/spec/unit/assets/list_deployments_for_service002.xml +0 -1
- data/spec/unit/assets/list_deployments_for_service003.xml +0 -1
- data/spec/unit/assets/list_disks.xml +0 -1
- data/spec/unit/assets/list_hosts.xml +0 -1
- data/spec/unit/assets/list_images.xml +0 -1
- data/spec/unit/assets/post_success.xml +0 -6
- data/spec/unit/deploys_list_spec.rb +0 -55
- data/spec/unit/disks_spec.rb +0 -44
- data/spec/unit/hosts_spec.rb +0 -55
- data/spec/unit/images_spec.rb +0 -35
- data/spec/unit/query_azure_mock.rb +0 -69
- data/spec/unit/roles_create_spec.rb +0 -82
- data/spec/unit/roles_list_spec.rb +0 -32
data/spec/unit/hosts_spec.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/query_azure_mock')
|
3
|
-
|
4
|
-
describe "hosts" do
|
5
|
-
include AzureSpecHelper
|
6
|
-
include QueryAzureMock
|
7
|
-
before 'setup connection' do
|
8
|
-
setup_query_azure_mock
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'get all hosts' do
|
12
|
-
specify {@connection.hosts.all.length.should be > 1}
|
13
|
-
it "entry fields should not be nil" do
|
14
|
-
items = @connection.hosts.all
|
15
|
-
items.each do |host|
|
16
|
-
host.name.should_not be_nil
|
17
|
-
host.url.should_not be_nil
|
18
|
-
host.label.should_not be_nil
|
19
|
-
host.dateCreated.should_not be_nil
|
20
|
-
host.description.should_not be_nil
|
21
|
-
host.location.should_not be_nil
|
22
|
-
host.dateModified.should_not be_nil
|
23
|
-
host.status.should_not be_nil
|
24
|
-
end
|
25
|
-
end
|
26
|
-
specify {@connection.hosts.exists("notExpectedName").should == false}
|
27
|
-
specify {@connection.hosts.exists("service001").should == true}
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'create a new host' do
|
31
|
-
it 'using explicit parameters it should pass in expected body' do
|
32
|
-
params = {:hosted_service_name=>'service003', 'hosted_service_description'=>'Explicitly created hosted service', 'hosted_service_location'=>'Windows Azure Preview'}
|
33
|
-
host = @connection.hosts.create(params)
|
34
|
-
@postname.should == 'hostedservices'
|
35
|
-
@postverb.should == 'post'
|
36
|
-
Nokogiri::XML(@postbody).should be_equivalent_to(Nokogiri::XML readFile('create_host.xml'))
|
37
|
-
end
|
38
|
-
it 'using default parameters it should pass in expected body' do
|
39
|
-
params = {:hosted_service_name=>'service003'}
|
40
|
-
host = @connection.hosts.create(params)
|
41
|
-
@postname.should == 'hostedservices'
|
42
|
-
@postverb.should == 'post'
|
43
|
-
Nokogiri::XML(@postbody).should be_equivalent_to(Nokogiri::XML readFile('create_host.xml'))
|
44
|
-
end
|
45
|
-
end
|
46
|
-
context 'delete a host' do
|
47
|
-
it 'should pass in correct name, verb, and body' do
|
48
|
-
@connection.hosts.delete('service001');
|
49
|
-
@deletename.should == 'hostedservices/service001'
|
50
|
-
@deleteverb.should == 'delete'
|
51
|
-
@deletebody.should == nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
data/spec/unit/images_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/query_azure_mock')
|
3
|
-
|
4
|
-
describe "images" do
|
5
|
-
include AzureSpecHelper
|
6
|
-
include QueryAzureMock
|
7
|
-
before 'setup connection' do
|
8
|
-
setup_query_azure_mock
|
9
|
-
end
|
10
|
-
|
11
|
-
context 'mock with actually retrieved values' do
|
12
|
-
it "should find strings" do
|
13
|
-
items = @connection.images.all
|
14
|
-
items.length.should be > 1
|
15
|
-
items.each do |image|
|
16
|
-
image.category.should_not be_nil
|
17
|
-
image.label.should_not be_nil
|
18
|
-
image.name.should_not be_nil
|
19
|
-
image.os.should_not be_nil
|
20
|
-
image.eula.should_not be_nil
|
21
|
-
image.description.should_not be_nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
it "should contain a linux image" do
|
25
|
-
items = @connection.images.all
|
26
|
-
foundLinux = false
|
27
|
-
items.each do |item|
|
28
|
-
if item.os == 'Linux'
|
29
|
-
foundLinux = true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
foundLinux.should == true
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
|
2
|
-
module QueryAzureMock
|
3
|
-
def setup_query_azure_mock
|
4
|
-
@getname = ''
|
5
|
-
@getverb = ''
|
6
|
-
@getbody = ''
|
7
|
-
|
8
|
-
@postname = ''
|
9
|
-
@postverb = ''
|
10
|
-
@postbody = ''
|
11
|
-
|
12
|
-
@deletename = ''
|
13
|
-
@deleteverb = ''
|
14
|
-
@deletebody = ''
|
15
|
-
@deletecount = 0
|
16
|
-
|
17
|
-
@receivedXML = Nokogiri::XML ''
|
18
|
-
@connection = Azure::Connection.new(TEST_PARAMS)
|
19
|
-
@connection.stub(:query_azure) do |name, verb, body|
|
20
|
-
Chef::Log.info 'calling web service:' + name
|
21
|
-
if verb == 'get' || verb == nil
|
22
|
-
retval = ''
|
23
|
-
if name == 'images'
|
24
|
-
retval = Nokogiri::XML readFile('list_images.xml')
|
25
|
-
elsif name == 'disks'
|
26
|
-
retval = Nokogiri::XML readFile('list_disks.xml')
|
27
|
-
elsif name == 'hostedservices'
|
28
|
-
retval = Nokogiri::XML readFile('list_hosts.xml')
|
29
|
-
elsif name == 'hostedservices/service001/deploymentslots/Production'
|
30
|
-
retval = Nokogiri::XML readFile('list_deployments_for_service001.xml')
|
31
|
-
elsif name == 'hostedservices/service002/deploymentslots/Production'
|
32
|
-
retval = Nokogiri::XML readFile('list_deployments_for_service002.xml')
|
33
|
-
elsif name == 'hostedservices/service003/deploymentslots/Production'
|
34
|
-
retval = Nokogiri::XML readFile('list_deployments_for_service003.xml')
|
35
|
-
else
|
36
|
-
Chef::Log.warn 'unknown get value:' + name
|
37
|
-
end
|
38
|
-
@getname = name
|
39
|
-
@getverb = verb
|
40
|
-
@getbody = body
|
41
|
-
elsif verb == 'post'
|
42
|
-
if name == 'hostedservices'
|
43
|
-
retval = Nokogiri::XML readFile('post_success.xml')
|
44
|
-
@receivedXML = body
|
45
|
-
elsif name == 'hostedservices/unknown_yet/deployments'
|
46
|
-
retval = Nokogiri::XML readFile('post_success.xml')
|
47
|
-
@receivedXML = body
|
48
|
-
elsif name == 'hostedservices/service001/deployments/deployment001/roles'
|
49
|
-
retval = Nokogiri::XML readFile('post_success.xml')
|
50
|
-
@receivedXML = body
|
51
|
-
else
|
52
|
-
Chef::Log.warn 'unknown post value:' + name
|
53
|
-
end
|
54
|
-
@postname = name
|
55
|
-
@postverb = verb
|
56
|
-
@postbody = body
|
57
|
-
elsif verb == 'delete'
|
58
|
-
@deletename = name
|
59
|
-
@deleteverb = verb
|
60
|
-
@deletebody = body
|
61
|
-
@deletecount += 1
|
62
|
-
else
|
63
|
-
Chef::Log.warn 'unknown verb:' + verb
|
64
|
-
end
|
65
|
-
retval
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/query_azure_mock')
|
3
|
-
|
4
|
-
describe "roles" do
|
5
|
-
include AzureSpecHelper
|
6
|
-
include QueryAzureMock
|
7
|
-
before do
|
8
|
-
setup_query_azure_mock
|
9
|
-
end
|
10
|
-
context 'delete a role' do
|
11
|
-
context 'when the role is not the only one in a deployment' do
|
12
|
-
it 'should pass in correct name, verb, and body' do
|
13
|
-
@connection.roles.delete('vm002');
|
14
|
-
@deletename.should == 'hostedservices/service001/deployments/deployment001/roles/vm002'
|
15
|
-
@deleteverb.should == 'delete'
|
16
|
-
@deletebody.should == nil
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
context 'delete a role' do
|
21
|
-
context 'when the role is the only one in a deployment' do
|
22
|
-
it 'should pass in correct name, verb, and body' do
|
23
|
-
@connection.roles.delete('vm01');
|
24
|
-
@deletename.should == 'hostedservices/service002/deployments/testrequest'
|
25
|
-
@deleteverb.should == 'delete'
|
26
|
-
@deletebody.should == nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
context 'create a new role' do
|
31
|
-
it 'should pass in expected body' do
|
32
|
-
submittedXML=Nokogiri::XML readFile('create_role.xml')
|
33
|
-
params = {
|
34
|
-
:hosted_service_name=>'service001',
|
35
|
-
:role_name=>'vm01',
|
36
|
-
:host_name=>'myVm',
|
37
|
-
:ssh_user=>'jetstream',
|
38
|
-
:ssh_password=>'jetstream1!',
|
39
|
-
:media_location_prefix=>'auxpreview104',
|
40
|
-
:os_disk_name=>'disk004Test',
|
41
|
-
:source_image=>'SUSE__OpenSUSE64121-03192012-en-us-15GB',
|
42
|
-
:role_size=>'ExtraSmall',
|
43
|
-
:tcp_endpoints=>'44:45,55:55',
|
44
|
-
:udp_endpoints=>'65:65,75'
|
45
|
-
|
46
|
-
}
|
47
|
-
deploy = @connection.deploys.create(params)
|
48
|
-
#this is a cheesy workaround to make equivalent-xml happy
|
49
|
-
# write and then re-read the xml
|
50
|
-
File.open(tmpFile('newRoleRcvd.xml'), 'w') {|f| f.write(@receivedXML) }
|
51
|
-
File.open(tmpFile('newRoleSbmt.xml'), 'w') {|f| f.write(submittedXML.to_xml) }
|
52
|
-
rcvd = Nokogiri::XML File.open(tmpFile('newRoleRcvd.xml'))
|
53
|
-
sbmt = Nokogiri::XML File.open(tmpFile('newRoleSbmt.xml'))
|
54
|
-
rcvd.should be_equivalent_to(sbmt).respecting_element_order.with_whitespace_intact
|
55
|
-
end
|
56
|
-
end
|
57
|
-
context 'create a new deployment' do
|
58
|
-
it 'should pass in expected body' do
|
59
|
-
submittedXML=Nokogiri::XML readFile('create_deployment.xml')
|
60
|
-
params = {
|
61
|
-
:hosted_service_name=>'unknown_yet',
|
62
|
-
:role_name=>'vm01',
|
63
|
-
:host_name=>'myVm',
|
64
|
-
:ssh_user=>'jetstream',
|
65
|
-
:ssh_password=>'jetstream1!',
|
66
|
-
:media_location_prefix=>'auxpreview104',
|
67
|
-
:os_disk_name=>'disk004Test',
|
68
|
-
:source_image=>'SUSE__OpenSUSE64121-03192012-en-us-15GB',
|
69
|
-
:role_size=>'ExtraSmall'
|
70
|
-
|
71
|
-
}
|
72
|
-
deploy = @connection.deploys.create(params)
|
73
|
-
#this is a cheesy workaround to make equivalent-xml happy
|
74
|
-
# write and then re-read the xml
|
75
|
-
File.open(tmpFile('newDeployRcvd.xml'), 'w') {|f| f.write(@receivedXML) }
|
76
|
-
File.open(tmpFile('newDeploySbmt.xml'), 'w') {|f| f.write(submittedXML.to_xml) }
|
77
|
-
rcvd = Nokogiri::XML File.open(tmpFile('newDeployRcvd.xml'))
|
78
|
-
sbmt = Nokogiri::XML File.open(tmpFile('newDeploySbmt.xml'))
|
79
|
-
rcvd.should be_equivalent_to(sbmt).respecting_element_order
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/query_azure_mock')
|
3
|
-
describe "roles" do
|
4
|
-
include AzureSpecHelper
|
5
|
-
include QueryAzureMock
|
6
|
-
before do
|
7
|
-
setup_query_azure_mock
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'show all roles' do
|
11
|
-
roles = @connection.roles.all
|
12
|
-
roles.each do |role|
|
13
|
-
role.name.should_not be_nil
|
14
|
-
end
|
15
|
-
roles.length.should == 4
|
16
|
-
end
|
17
|
-
specify {@connection.roles.exists('vm01').should == true}
|
18
|
-
specify {@connection.roles.exists('vm002').should == true}
|
19
|
-
specify {@connection.roles.exists('role001').should == true}
|
20
|
-
specify {@connection.roles.exists('role002').should == true}
|
21
|
-
specify {@connection.roles.exists('role002qqqqq').should == false}
|
22
|
-
|
23
|
-
it 'each role should have values' do
|
24
|
-
role = @connection.roles.find('vm01')
|
25
|
-
role.name.should_not be_nil
|
26
|
-
role.status.should_not be_nil
|
27
|
-
role.size.should_not be_nil
|
28
|
-
role.ipaddress.should_not be_nil
|
29
|
-
role.sshport.should_not be_nil
|
30
|
-
role.sshipaddress.should_not be_nil
|
31
|
-
end
|
32
|
-
end
|