azure 0.6.3 → 0.6.4
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.
- checksums.yaml +4 -4
- data/ChangeLog.txt +7 -0
- data/README.md +52 -35
- data/lib/azure/base_management/management_http_request.rb +1 -1
- data/lib/azure/cloud_service_management/cloud_service.rb +1 -1
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +8 -10
- data/lib/azure/cloud_service_management/serialization.rb +9 -8
- data/lib/azure/storage_management/storage_management_service.rb +2 -2
- data/lib/azure/version.rb +1 -1
- data/lib/azure/virtual_machine_image_management/serialization.rb +4 -6
- data/lib/azure/virtual_machine_image_management/virtual_machine_disk.rb +0 -2
- data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +0 -2
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +4 -9
- data/lib/azure/virtual_machine_management/serialization.rb +19 -4
- data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +118 -68
- data/test/integration/cloud_service/Cloud_Create_test.rb +44 -0
- data/test/integration/cloud_service/Cloud_Delete_test.rb +44 -0
- data/test/integration/vm/VM_Create_test.rb +56 -10
- data/test/integration/vm/VM_Operations_test.rb +3 -4
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +30 -30
- data/test/unit/cloud_service_management/serialization_test.rb +20 -20
- data/test/unit/virtual_machine_image_management/serialization_test.rb +6 -6
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +20 -20
- data/test/unit/virtual_machine_management/serialization_test.rb +26 -14
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +80 -75
- metadata +4 -2
@@ -0,0 +1,44 @@
|
|
1
|
+
#-------------------------------------------------------------------------
|
2
|
+
# Copyright 2013 Microsoft Open Technologies, Inc.
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#--------------------------------------------------------------------------
|
15
|
+
require 'integration/test_helper'
|
16
|
+
|
17
|
+
describe Azure::CloudServiceManagementService do
|
18
|
+
|
19
|
+
subject { Azure::CloudServiceManagementService.new }
|
20
|
+
|
21
|
+
let(:options) do
|
22
|
+
{
|
23
|
+
location: 'West US',
|
24
|
+
description: 'Test'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
before do
|
29
|
+
Loggerx.expects(:puts).returns(nil).at_least(0)
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#delete_cloud_service' do
|
33
|
+
before do
|
34
|
+
@cloud_name = random_string('test-service-cloud', 10)
|
35
|
+
subject.create_cloud_service(@cloud_name, options)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'Deletes the cloud service in Windows Azure.' do
|
39
|
+
subject.delete_cloud_service(@cloud_name)
|
40
|
+
present = subject.get_cloud_service(@cloud_name)
|
41
|
+
assert_equal present, false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -50,7 +50,7 @@ describe Azure::VirtualMachineManagementService do
|
|
50
50
|
{
|
51
51
|
storage_account_name: storage_account_name,
|
52
52
|
cloud_service_name: cloud_service_name,
|
53
|
-
vm_size: '
|
53
|
+
vm_size: 'Basic_A0'
|
54
54
|
}
|
55
55
|
end
|
56
56
|
|
@@ -67,27 +67,73 @@ describe Azure::VirtualMachineManagementService do
|
|
67
67
|
|
68
68
|
describe '#deployment' do
|
69
69
|
|
70
|
+
describe '#add_role' do
|
71
|
+
before do
|
72
|
+
@vm_obj = subject.create_virtual_machine(params, options)
|
73
|
+
params[:cloud_service_name] = options[:cloud_service_name]
|
74
|
+
options.delete(:cloud_service_name)
|
75
|
+
params.delete(:location)
|
76
|
+
params[:vm_name] = "add-#{virtual_machine_name}"
|
77
|
+
sleep 30
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should add role to existing storage account and cloud service' do
|
81
|
+
vm = subject.add_role(params, options)
|
82
|
+
vm.cloud_service_name.must_equal params[:cloud_service_name]
|
83
|
+
vm.vm_name.must_equal params[:vm_name]
|
84
|
+
vm.deployment_name.must_equal @vm_obj.deployment_name
|
85
|
+
vm.os_type.must_equal 'Linux'
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should add role and create new storage account' do
|
89
|
+
params[:vm_name] = "Add-storage-#{virtual_machine_name}"
|
90
|
+
vm = subject.add_role(params)
|
91
|
+
vm.cloud_service_name.must_equal params[:cloud_service_name]
|
92
|
+
vm.vm_name.must_equal params[:vm_name].downcase
|
93
|
+
vm.deployment_name.must_equal @vm_obj.deployment_name
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#virtual_network' do
|
98
|
+
before do
|
99
|
+
options[:virtual_network_name] = 'v-net'
|
100
|
+
affinity_gorup_name = random_string('affinity-group-', 10)
|
101
|
+
Azure::BaseManagementService.new.create_affinity_group(
|
102
|
+
affinity_gorup_name,
|
103
|
+
params[:location],
|
104
|
+
'AG1'
|
105
|
+
) rescue nil
|
106
|
+
vnet_service = Azure::VirtualNetworkManagementService
|
107
|
+
vnet_service.new.set_network_configuration(
|
108
|
+
options[:virtual_network_name],
|
109
|
+
affinity_gorup_name,
|
110
|
+
['172.16.0.0/12']
|
111
|
+
) rescue nil
|
112
|
+
subject.create_virtual_machine(params, options)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should provision virtual machine in a existing virtual network' do
|
116
|
+
virtual_machine = subject.get_virtual_machine(virtual_machine_name, cloud_service_name)
|
117
|
+
virtual_machine.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
118
|
+
virtual_machine.vm_name.must_equal virtual_machine_name
|
119
|
+
virtual_machine.virtual_network_name.must_equal options[:virtual_network_name]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
70
123
|
it 'should set options hash with valid cloud_service_name, deployment_name, storage_account_name and virtual network' do
|
71
124
|
csn = options[:cloud_service_name]
|
72
125
|
options[:availability_set_name] = 'aval-set-test'
|
73
|
-
vm = subject.create_virtual_machine(params, options
|
126
|
+
vm = subject.create_virtual_machine(params, options)
|
74
127
|
vm.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
75
128
|
vm.cloud_service_name.wont_be_nil
|
76
129
|
vm.vm_name.must_equal virtual_machine_name
|
77
130
|
vm.deployment_name.wont_be_nil
|
78
131
|
vm.deployment_name.must_equal vm.cloud_service_name
|
79
132
|
vm.os_type.must_equal 'Linux'
|
80
|
-
vm.role_size.must_equal '
|
133
|
+
vm.role_size.must_equal 'Basic_A0'
|
81
134
|
vm.availability_set_name.must_equal 'aval-set-test'
|
82
135
|
options[:storage_account_name].wont_be_nil
|
83
136
|
assert_match(/^#{params[:vm_name] + '-service'}*/, csn)
|
84
|
-
# Test for add role
|
85
|
-
params[:vm_name] = 'test-add-role-vm'
|
86
|
-
vm = subject.create_virtual_machine(params, options, true)
|
87
|
-
vm.cloud_service_name.must_equal csn
|
88
|
-
vm.vm_name.must_equal params[:vm_name]
|
89
|
-
vm.deployment_name.wont_be_nil
|
90
|
-
vm.os_type.must_equal 'Linux'
|
91
137
|
end
|
92
138
|
|
93
139
|
it 'should creates http and https enabled winrm virtual machine without certificate.' do
|
@@ -64,7 +64,7 @@ describe Azure::VirtualMachineManagementService do
|
|
64
64
|
before do
|
65
65
|
subject.shutdown_virtual_machine(vm_name, csn)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it 'starts virtual machine' do
|
69
69
|
subject.start_virtual_machine(vm_name, csn)
|
70
70
|
vm = subject.get_virtual_machine(vm_name, csn)
|
@@ -107,9 +107,8 @@ describe Azure::VirtualMachineManagementService do
|
|
107
107
|
|
108
108
|
describe '#add_data_disk' do
|
109
109
|
it 'add data disk to virtual machine' do
|
110
|
-
lun = rand(1..15)
|
111
110
|
others = { disk_size: 100 }
|
112
|
-
subject.add_data_disk(vm_name, csn
|
111
|
+
subject.add_data_disk(vm_name, csn, others)
|
113
112
|
dms = VirtualMachineDiskManagementService.new
|
114
113
|
disks = dms.list_virtual_machine_disks
|
115
114
|
disks = disks.select { |x| (/#{csn}/ =~ x.name) && x.os_type.empty? }
|
@@ -119,7 +118,7 @@ describe Azure::VirtualMachineManagementService do
|
|
119
118
|
end
|
120
119
|
|
121
120
|
describe 'Add, Update, Delete endpoints' do
|
122
|
-
|
121
|
+
|
123
122
|
it 'should add endpoints to virtual machine.' do
|
124
123
|
ep1 = {
|
125
124
|
name: 'endpoint-1',
|
@@ -12,73 +12,73 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require
|
15
|
+
require 'test_helper'
|
16
16
|
|
17
17
|
describe Azure::CloudServiceManagementService do
|
18
18
|
|
19
19
|
subject { Azure::CloudServiceManagementService.new }
|
20
|
-
let(:request_path) {'/services/hostedservices'}
|
21
|
-
let(:cloud_services_xml) { Fixtures[
|
20
|
+
let(:request_path) { '/services/hostedservices' }
|
21
|
+
let(:cloud_services_xml) { Fixtures['list_cloud_services'] }
|
22
22
|
let(:method) { :get }
|
23
|
-
let(:mock_request){ mock
|
24
|
-
let(:response)
|
25
|
-
response = mock
|
23
|
+
let(:mock_request) { mock }
|
24
|
+
let(:response) do
|
25
|
+
response = mock
|
26
26
|
response.stubs(:body).returns(cloud_services_xml)
|
27
27
|
response
|
28
|
-
|
28
|
+
end
|
29
29
|
let(:response_body) { Nokogiri::XML response.body }
|
30
30
|
|
31
|
-
before
|
31
|
+
before do
|
32
32
|
Loggerx.expects(:puts).returns(nil).at_least(0)
|
33
|
-
|
33
|
+
end
|
34
34
|
|
35
|
-
describe
|
36
|
-
before
|
35
|
+
describe '#list_cloud_services' do
|
36
|
+
before do
|
37
37
|
ManagementHttpRequest.stubs(:new).with(method, request_path, nil).returns(mock_request)
|
38
38
|
mock_request.expects(:call).returns(response_body)
|
39
|
-
|
40
|
-
|
41
|
-
it
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'assembles a URI for the request' do
|
42
42
|
subject.list_cloud_services
|
43
43
|
end
|
44
|
-
|
45
|
-
it
|
44
|
+
|
45
|
+
it 'sets the properties of the CloudService instance' do
|
46
46
|
cloud_service = subject.list_cloud_services.first
|
47
47
|
cloud_service.name.must_equal 'cloud-service-1'
|
48
48
|
end
|
49
|
-
|
50
|
-
it
|
49
|
+
|
50
|
+
it 'returns a list of cloud services for the subscription' do
|
51
51
|
results = subject.list_cloud_services
|
52
52
|
results.must_be_kind_of Array
|
53
53
|
results.length.must_equal 2
|
54
54
|
results.first.must_be_kind_of Azure::CloudServiceManagement::CloudService
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
58
|
-
describe
|
59
|
-
before
|
57
|
+
|
58
|
+
describe '#get_cloud_service' do
|
59
|
+
before do
|
60
60
|
ManagementHttpRequest.stubs(:new).with(method, request_path, nil).returns(mock_request)
|
61
61
|
mock_request.expects(:call).returns(response_body)
|
62
|
-
|
63
|
-
|
64
|
-
it
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'assembles a URI for the request' do
|
65
65
|
subject.get_cloud_service 'cloud-service-1'
|
66
66
|
end
|
67
|
-
|
68
|
-
it
|
67
|
+
|
68
|
+
it 'returns true if found cloud service with given name' do
|
69
69
|
result = subject.get_cloud_service 'cloud-service-1'
|
70
70
|
result.must_equal true
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "returns false if cloud service with given name doesn't exists" do
|
74
74
|
result = subject.get_cloud_service 'cloud-service-3'
|
75
75
|
result.must_equal false
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
80
|
-
|
81
|
-
it
|
79
|
+
describe '#create_cloud_service' do
|
80
|
+
|
81
|
+
it 'Create cloud service return message if cloud service exists of given name.' do
|
82
82
|
ManagementHttpRequest.any_instance.expects(:call).returns response_body
|
83
83
|
msg = subject.create_cloud_service 'cloud-service-1'
|
84
84
|
assert_match(/^Cloud service cloud-service-1 already exists*/, msg)
|
@@ -59,7 +59,7 @@ describe Azure::CloudServiceManagement::Serialization do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#cloud_services_to_xml' do
|
62
|
-
let(:cloud_service_name) {'cloud-service'}
|
62
|
+
let(:cloud_service_name) { 'cloud-service' }
|
63
63
|
|
64
64
|
it 'accepts an name and options hash' do
|
65
65
|
subject.cloud_services_to_xml cloud_service_name
|
@@ -68,9 +68,9 @@ describe Azure::CloudServiceManagement::Serialization do
|
|
68
68
|
it 'uses name for label if label not provided' do
|
69
69
|
results = subject.cloud_services_to_xml(
|
70
70
|
cloud_service_name,
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
|
72
|
+
location: 'East Asia'
|
73
|
+
|
74
74
|
)
|
75
75
|
|
76
76
|
doc = Nokogiri::XML(results)
|
@@ -80,10 +80,10 @@ describe Azure::CloudServiceManagement::Serialization do
|
|
80
80
|
it 'uses label when label is provided' do
|
81
81
|
results = subject.cloud_services_to_xml(
|
82
82
|
cloud_service_name,
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
|
84
|
+
location: 'East Asia',
|
85
|
+
label: 'My Label'
|
86
|
+
|
87
87
|
)
|
88
88
|
|
89
89
|
doc = Nokogiri::XML(results)
|
@@ -92,7 +92,7 @@ describe Azure::CloudServiceManagement::Serialization do
|
|
92
92
|
|
93
93
|
it 'serializes the argument to xml' do
|
94
94
|
results = subject.cloud_services_to_xml(
|
95
|
-
cloud_service_name,
|
95
|
+
cloud_service_name, location: 'West US'
|
96
96
|
)
|
97
97
|
results.must_be_kind_of String
|
98
98
|
doc = Nokogiri::XML results
|
@@ -103,10 +103,10 @@ describe Azure::CloudServiceManagement::Serialization do
|
|
103
103
|
it 'uses affinity_group if provided and ignores location' do
|
104
104
|
results = subject.cloud_services_to_xml(
|
105
105
|
cloud_service_name,
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
|
107
|
+
affinity_group_name: 'my-affinity-group',
|
108
|
+
location: 'West US'
|
109
|
+
|
110
110
|
)
|
111
111
|
results.must_be_kind_of String
|
112
112
|
doc = Nokogiri::XML results
|
@@ -119,9 +119,9 @@ describe Azure::CloudServiceManagement::Serialization do
|
|
119
119
|
it 'uses location when affinity group not provided' do
|
120
120
|
results = subject.cloud_services_to_xml(
|
121
121
|
cloud_service_name,
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
|
123
|
+
location: 'East Asia'
|
124
|
+
|
125
125
|
)
|
126
126
|
|
127
127
|
doc = Nokogiri::XML(results)
|
@@ -137,9 +137,9 @@ describe Azure::CloudServiceManagement::Serialization do
|
|
137
137
|
}
|
138
138
|
results = subject.cloud_services_to_xml(
|
139
139
|
cloud_service_name,
|
140
|
-
|
141
|
-
|
142
|
-
|
140
|
+
|
141
|
+
extended_properties: xtended_props
|
142
|
+
|
143
143
|
)
|
144
144
|
|
145
145
|
doc = Nokogiri::XML(results)
|
@@ -159,7 +159,7 @@ describe Azure::CloudServiceManagement::Serialization do
|
|
159
159
|
it 'serializes the options hash to xml' do
|
160
160
|
results = subject.cloud_services_to_xml(
|
161
161
|
cloud_service_name,
|
162
|
-
|
162
|
+
location: 'East US'
|
163
163
|
)
|
164
164
|
doc = Nokogiri::XML results
|
165
165
|
doc.css('Location').text.must_equal 'East US'
|
@@ -12,24 +12,24 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require
|
15
|
+
require 'test_helper'
|
16
16
|
|
17
17
|
describe Azure::VirtualMachineImageManagement::Serialization do
|
18
18
|
subject { Azure::VirtualMachineImageManagement::Serialization }
|
19
19
|
|
20
|
-
let(:virtual_machine_images_from_xml) { Fixtures[
|
20
|
+
let(:virtual_machine_images_from_xml) { Fixtures['list_images'] }
|
21
21
|
|
22
|
-
describe
|
22
|
+
describe '#virtual_machine_images_from_xml' do
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'accepts an XML string' do
|
25
25
|
subject.virtual_machine_images_from_xml Nokogiri::XML(virtual_machine_images_from_xml)
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
28
|
+
it 'returns an Array of VirtualMachineImageService instances' do
|
29
29
|
results = subject.virtual_machine_images_from_xml Nokogiri::XML(virtual_machine_images_from_xml)
|
30
30
|
results.must_be_kind_of Array
|
31
31
|
results[0].must_be_kind_of Azure::VirtualMachineImageManagement::VirtualMachineImage
|
32
32
|
results.count.must_equal 12
|
33
33
|
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb
CHANGED
@@ -12,48 +12,48 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require
|
15
|
+
require 'test_helper'
|
16
16
|
|
17
17
|
describe Azure::VirtualMachineImageManagementService do
|
18
18
|
|
19
19
|
subject { Azure::VirtualMachineImageManagementService.new }
|
20
20
|
|
21
|
-
let(:request_path) {'/services/images'}
|
22
|
-
let(:images_xml) { Fixtures[
|
21
|
+
let(:request_path) { '/services/images' }
|
22
|
+
let(:images_xml) { Fixtures['list_images'] }
|
23
23
|
let(:method) { :get }
|
24
|
-
let(:mock_request){ mock
|
25
|
-
let(:response)
|
26
|
-
response = mock
|
24
|
+
let(:mock_request) { mock }
|
25
|
+
let(:response) do
|
26
|
+
response = mock
|
27
27
|
response.stubs(:body).returns(images_xml)
|
28
28
|
response
|
29
|
-
|
29
|
+
end
|
30
30
|
let(:response_body) { Nokogiri::XML response.body }
|
31
31
|
|
32
|
-
before
|
32
|
+
before do
|
33
33
|
Loggerx.expects(:puts).returns(nil).at_least(0)
|
34
|
-
|
35
|
-
|
36
|
-
describe
|
37
|
-
|
38
|
-
before
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#list_virtual_machine_images' do
|
37
|
+
|
38
|
+
before do
|
39
39
|
ManagementHttpRequest.stubs(:new).with(
|
40
40
|
method,
|
41
41
|
request_path,
|
42
42
|
nil
|
43
43
|
).returns(mock_request)
|
44
44
|
mock_request.expects(:call).returns(response_body)
|
45
|
-
|
46
|
-
|
47
|
-
it
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'assembles a URI for the request' do
|
48
48
|
subject.list_virtual_machine_images
|
49
49
|
end
|
50
|
-
|
51
|
-
it
|
50
|
+
|
51
|
+
it 'sets the properties of the virtual machine images' do
|
52
52
|
virtual_machine_image = subject.list_virtual_machine_images.first
|
53
53
|
virtual_machine_image.name.must_equal 'RightImage-CentOS-6.2-x64-v5.8.8.1'
|
54
54
|
end
|
55
55
|
|
56
|
-
it
|
56
|
+
it 'returns a list of virtual machine images from server' do
|
57
57
|
results = subject.list_virtual_machine_images
|
58
58
|
results.must_be_kind_of Array
|
59
59
|
results.length.must_equal 12
|
@@ -61,5 +61,5 @@ describe Azure::VirtualMachineImageManagementService do
|
|
61
61
|
results.first.must_be_kind_of image_klass
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
end
|