azure 0.6.1 → 0.6.2

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.
@@ -4,7 +4,7 @@
4
4
  <Category>RightScale with Linux</Category>
5
5
  <Label>RightImage CentOS 6.2 x64 v5.8.8.1</Label>
6
6
  <LogicalSizeInGB>10</LogicalSizeInGB>
7
- <Name>0b11de9248dd4d87b18621318e037d37__RightImage-CentOS-6.2-x64-v5.8.8.1</Name>
7
+ <Name>RightImage-CentOS-6.2-x64-v5.8.8.1</Name>
8
8
  <OS>Linux</OS>
9
9
  <Eula>http://support.rightscale.com/12-Guides/RightLink/RightLink_End_User_License_Agreeement;http://www.rightscale.com/privacy_policy.php</Eula>
10
10
  <Description>CentOS 6.3 with RightLink 5.8.</Description>
@@ -105,4 +105,9 @@ kZS1mYWNlNSI+DQogICAgPEluc3RhbmNlcyBjb3VudD0iMSIgLz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWN
105
105
  <EndTime>2013-04-13T08:00:00Z</EndTime>
106
106
  <Status>PersistentVMUpdateCompleted</Status>
107
107
  </PersistentVMDowntime>
108
+ <VirtualIPs>
109
+ <VirtualIP>
110
+ <Address>137.116.17.187</Address>
111
+ </VirtualIP>
112
+ </VirtualIPs>
108
113
  </Deployment>
@@ -61,106 +61,107 @@ describe Azure::VirtualMachineManagementService do
61
61
  }
62
62
  end
63
63
 
64
-
65
64
  before do
66
65
  Loggerx.expects(:puts).returns(nil).at_least(0)
67
-
68
66
  end
69
67
 
70
68
  describe '#deployment' do
71
69
 
72
70
  it 'should set options hash with valid cloud_service_name, deployment_name, storage_account_name and virtual network' do
73
- cloud_name = options[:cloud_service_name]
71
+ csn = options[:cloud_service_name]
74
72
  options[:availability_set_name] = 'aval-set-test'
75
- subject.create_virtual_machine(params, options, false)
76
- virtual_machine = subject.get_virtual_machine(virtual_machine_name, cloud_name)
77
- virtual_machine.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
78
- virtual_machine.cloud_service_name.wont_be_nil
79
- virtual_machine.vm_name.must_equal virtual_machine_name
80
- virtual_machine.deployment_name.wont_be_nil
81
- virtual_machine.deployment_name.must_equal virtual_machine.cloud_service_name
82
- virtual_machine.os_type.must_equal 'Linux'
83
- virtual_machine.role_size.must_equal 'Small'
84
- virtual_machine.availability_set_name.must_equal 'aval-set-test'
73
+ vm = subject.create_virtual_machine(params, options, false)
74
+ vm.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
75
+ vm.cloud_service_name.wont_be_nil
76
+ vm.vm_name.must_equal virtual_machine_name
77
+ vm.deployment_name.wont_be_nil
78
+ vm.deployment_name.must_equal vm.cloud_service_name
79
+ vm.os_type.must_equal 'Linux'
80
+ vm.role_size.must_equal 'Small'
81
+ vm.availability_set_name.must_equal 'aval-set-test'
85
82
  options[:storage_account_name].wont_be_nil
86
- assert_match(/^#{params[:vm_name] + '-service'}*/, cloud_name)
83
+ assert_match(/^#{params[:vm_name] + '-service'}*/, csn)
87
84
  # Test for add role
88
85
  params[:vm_name] = 'test-add-role-vm'
89
86
  options[:ssh_port] = 2222
90
87
  vm = subject.create_virtual_machine(params, options, true)
91
- vm.cloud_service_name.must_equal cloud_name
88
+ vm.cloud_service_name.must_equal csn
92
89
  vm.vm_name.must_equal params[:vm_name]
93
- virtual_machine.deployment_name.wont_be_nil
94
- virtual_machine.os_type.must_equal 'Linux'
90
+ vm.deployment_name.wont_be_nil
91
+ vm.os_type.must_equal 'Linux'
95
92
  end
96
93
 
97
94
  it 'should creates http and https enabled winrm virtual machine without certificate.' do
98
95
  default_options.merge!(winrm_transport: %w(https http))
99
- subject.create_virtual_machine(windows_params, default_options)
100
- result = subject.get_virtual_machine(virtual_machine_name, cloud_service_name)
96
+ result = subject.create_virtual_machine(windows_params, default_options)
101
97
  result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
102
- assert_equal(result.os_type, 'Windows', 'Error in the OS type of VI created')
98
+ assert_equal(result.os_type, 'Windows')
103
99
  tcp_endpoints_names = []
104
100
  result.tcp_endpoints.each do |tcp_endpoint|
105
- tcp_endpoints_names << tcp_endpoint['Name']
101
+ tcp_endpoints_names << tcp_endpoint[:name]
106
102
  end
107
- tcp_endpoints_names.must_include 'WinRm-Https'
103
+ tcp_endpoints_names.must_include 'PowerShell'
108
104
  tcp_endpoints_names.must_include 'WinRm-Http'
109
105
  sleep 30
110
106
  end
111
107
 
112
108
  it 'should creates https enabled winrm virtual machine using certificate.' do
113
- default_options.merge!(winrm_transport: ['https'], private_key_file: private_key, certificate_file: certificate)
114
- subject.create_virtual_machine(windows_params, default_options)
115
- result = subject.get_virtual_machine(virtual_machine_name, cloud_service_name)
109
+ default_options.merge!(
110
+ winrm_transport: ['https'],
111
+ private_key_file: private_key,
112
+ certificate_file: certificate
113
+ )
114
+ result = subject.create_virtual_machine(windows_params, default_options)
116
115
  result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
117
- assert_equal(result.os_type, 'Windows', 'Error in the OS type of VI created')
116
+ assert_equal(result.os_type, 'Windows')
118
117
  tcp_endpoints_names = []
119
118
  result.tcp_endpoints.each do |tcp_endpoint|
120
- tcp_endpoints_names << tcp_endpoint['Name']
119
+ tcp_endpoints_names << tcp_endpoint[:name]
121
120
  end
122
- tcp_endpoints_names.must_include 'WinRm-Https'
121
+ tcp_endpoints_names.must_include 'PowerShell'
123
122
  end
124
123
 
125
124
  it 'should creates windows virtual machine without winrm.' do
126
125
  default_options.merge!(winrm_transport: ['none'])
127
- subject.create_virtual_machine(windows_params, default_options)
128
- result = subject.get_virtual_machine(virtual_machine_name, cloud_service_name)
126
+ result = subject.create_virtual_machine(windows_params, default_options)
129
127
  result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
130
- assert_equal(result.os_type, 'Windows', 'Error in the OS type of VI created')
128
+ assert_equal(result.os_type, 'Windows')
131
129
  tcp_endpoints_names = []
132
130
  result.tcp_endpoints.each do |tcp_endpoint|
133
131
  tcp_endpoints_names << tcp_endpoint['Name']
134
132
  end
135
- assert (!tcp_endpoints_names.include? 'WinRm-Https')
136
- assert (!tcp_endpoints_names.include? 'WinRm-Http')
133
+ assert !tcp_endpoints_names.include?('PowerShell')
134
+ assert !tcp_endpoints_names.include?('WinRm-Http')
137
135
  end
138
136
 
139
137
  it 'created linux virtual machine should be accessible using password and certificate' do
140
- default_options.merge!(private_key_file: private_key, certificate_file: certificate)
141
- subject.create_virtual_machine(params, default_options)
142
- result = subject.get_virtual_machine(virtual_machine_name, cloud_service_name)
138
+ default_options.merge!(
139
+ private_key_file: private_key,
140
+ certificate_file: certificate
141
+ )
142
+ result = subject.create_virtual_machine(params, default_options)
143
143
  result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
144
- assert_equal(result.os_type, 'Linux', 'Error in the OS type of VI created')
144
+ assert_equal(result.os_type, 'Linux')
145
145
  sleep 30
146
146
  end
147
147
 
148
- it 'throws Runtime error as port value is beyond or less than actual range' do
148
+ it 'throws error as port value is beyond or less than actual range' do
149
149
  default_options.merge!(tcp_endpoints: '80,166535:166535')
150
150
  msg = subject.create_virtual_machine(params, default_options)
151
- assert_match(/invalid. Allowed values are 'a number between 1 to 65535'./i, msg)
151
+ error_msg = "invalid. Allowed values are 'a number between 1 to 65535'."
152
+ assert_match(/#{error_msg}/i, msg)
152
153
 
153
154
  default_options.merge!(tcp_endpoints: '80,0:0')
154
155
  msg = subject.create_virtual_machine(params, default_options)
155
- assert_match(/invalid. Allowed values are 'a number between 1 to 65535'./i, msg)
156
-
156
+ assert_match(/#{error_msg}/i, msg)
157
157
  cloud_service.delete_cloud_service(cloud_service_name)
158
158
  end
159
159
 
160
160
  it 'throws error when multiple VMs created under same DNS' do
161
161
  subject.create_virtual_machine(params, default_options)
162
162
  msg = subject.create_virtual_machine(windows_params, default_options)
163
- assert_match(/The specified deployment slot Production is occupied./i, msg)
163
+ error_msg = 'The specified deployment slot Production is occupied.'
164
+ assert_match(/#{error_msg}/i, msg)
164
165
  end
165
166
 
166
167
  it 'throws SystemExit error when vm_user not provided' do
@@ -195,10 +196,11 @@ describe Azure::VirtualMachineManagementService do
195
196
  cloud_service.delete_cloud_service(cloud_service_name)
196
197
  end
197
198
 
198
- it 'error thrown when invalid Virtual Machine name for Windows OS provided' do
199
+ it 'error thrown when invalid VM name given for Windows OS' do
199
200
  windows_params.merge!(vm_name: 'MSServerInstnce01')
200
201
  msg = subject.create_virtual_machine(windows_params, default_options)
201
- assert_match(/The computer name cannot be more than 15 characters long, be entirely numeric, or contain the following characters/i, msg)
202
+ error_msg = 'The computer name cannot be more than 15 characters long'
203
+ assert_match(/#{error_msg}/i, msg)
202
204
  cloud_service.delete_cloud_service(cloud_service_name)
203
205
  end
204
206
 
@@ -12,44 +12,44 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #--------------------------------------------------------------------------
15
- require "integration/test_helper"
15
+ require 'integration/test_helper'
16
16
 
17
17
  describe Azure::VirtualMachineManagementService do
18
18
 
19
19
  subject { Azure::VirtualMachineManagementService.new }
20
20
  let(:names) { VirtualMachineNameHelper.name }
21
- let(:virtual_machine_name) { names.first}
22
- let(:cloud_service_name) { names.last }
23
- let(:username) {'admin'}
24
- before {
21
+ let(:virtual_machine_name) { names.first }
22
+ let(:csn) { names.last }
23
+ let(:username) { 'admin' }
24
+ before do
25
25
  Loggerx.expects(:puts).at_least_once.returns(nil)
26
26
  params = {
27
- :vm_name => virtual_machine_name,
28
- :vm_user => 'user',
29
- :image => LinuxImage.name,
30
- :password => 'User123',
31
- :location => LinuxImageLocation
27
+ vm_name: virtual_machine_name,
28
+ vm_user: 'user',
29
+ image: LinuxImage.name,
30
+ password: 'User123',
31
+ location: LinuxImageLocation
32
32
  }
33
33
  options = {
34
- :storage_account_name => StorageAccountName,
35
- :cloud_service_name => cloud_service_name,
34
+ storage_account_name: StorageAccountName,
35
+ cloud_service_name: csn,
36
36
  }
37
37
  subject.create_virtual_machine(params, options)
38
38
  sleep 60
39
- }
39
+ end
40
40
 
41
- describe "#delete_virtual_machine" do
41
+ describe '#delete_virtual_machine' do
42
42
 
43
- it "delete existing virtual machine and cloud service" do
44
- subject.delete_virtual_machine(virtual_machine_name, cloud_service_name)
43
+ it 'delete existing virtual machine and cloud service' do
44
+ subject.delete_virtual_machine(virtual_machine_name, csn)
45
45
  sleep 60
46
- vm = subject.get_virtual_machine(virtual_machine_name, cloud_service_name)
46
+ vm = subject.get_virtual_machine(virtual_machine_name, csn)
47
47
  vm.must_be_nil
48
- cloud_presence = Azure::CloudServiceManagementService.new.get_cloud_service(cloud_service_name)
48
+ cloud_service = Azure::CloudServiceManagementService.new
49
+ cloud_presence = cloud_service.get_cloud_service(csn)
49
50
  cloud_presence.must_equal false
50
51
  end
51
52
 
52
53
  end
53
54
 
54
55
  end
55
-
@@ -0,0 +1,174 @@
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::VirtualMachineManagementService do
18
+ let(:vm_name) { 'test-operation-vm' }
19
+ let(:csn) { vm_name + '-service-qwert' }
20
+ subject { Azure::VirtualMachineManagementService.new }
21
+
22
+ before do
23
+ Loggerx.expects(:puts).returns(nil).at_least(0)
24
+ params = {
25
+ vm_name: vm_name,
26
+ vm_user: 'user',
27
+ image: LinuxImage.name,
28
+ password: 'User123',
29
+ location: LinuxImageLocation
30
+ }
31
+ options = {
32
+ storage_account_name: StorageAccountName,
33
+ cloud_service_name: csn,
34
+ }
35
+ vm = subject.get_virtual_machine(vm_name, csn)
36
+ if vm.nil?
37
+ subject.create_virtual_machine(params, options)
38
+ sleep 60 # Wait to finish provision.
39
+ end
40
+ end
41
+
42
+ describe 'Operations on virtual machine' do
43
+
44
+ describe '#shutdown_virtual_machine' do
45
+ it 'shuts down virtual machine' do
46
+ subject.shutdown_virtual_machine(vm_name, csn)
47
+ vm = subject.get_virtual_machine(vm_name, csn)
48
+ %w(StoppedVM StoppedDeallocated).must_include vm.status
49
+
50
+ msg = subject.shutdown_virtual_machine(vm_name, csn)
51
+ emsg = 'Cannot perform the shutdown operation on a stopped virtual machine'
52
+ assert_match(/#{emsg}/, msg)
53
+ end
54
+
55
+ it 'raises an error if virtual machine doesn\'t exists' do
56
+ name = 'test-shutdown'
57
+ msg = subject.shutdown_virtual_machine(name, csn)
58
+ assert_match(/Cannot find virtual machine \"#{name}\" under cloud service \"#{csn}\"/, msg)
59
+ end
60
+
61
+ end
62
+
63
+ describe '#start_virtual_machine' do
64
+ before do
65
+ subject.shutdown_virtual_machine(vm_name, csn)
66
+ end
67
+
68
+ it 'starts virtual machine' do
69
+ subject.start_virtual_machine(vm_name, csn)
70
+ vm = subject.get_virtual_machine(vm_name, csn)
71
+ statuses = %w(ReadyRole Provisioning CreatingVM RoleStateUnknown)
72
+ statuses.must_include vm.status
73
+ end
74
+
75
+ end
76
+
77
+ describe '#restart_virtual_machine' do
78
+ before do
79
+ subject.restart_virtual_machine(vm_name, csn)
80
+ end
81
+
82
+ it 'restarts virtual machine' do
83
+ vm = subject.get_virtual_machine(vm_name, csn)
84
+ %w(ReadyRole Provisioning RoleStateUnknown).must_include vm.status
85
+ end
86
+ end
87
+
88
+ describe '#get_virtual_machine' do
89
+ it 'should return virtual machine object' do
90
+ vm = subject.get_virtual_machine(vm_name, csn)
91
+ vm.vm_name.must_equal vm_name
92
+ vm.cloud_service_name.must_equal csn
93
+ end
94
+ end
95
+
96
+ describe '#list_virtual_machines' do
97
+ it 'returns a list of virtual machines' do
98
+ vms = subject.list_virtual_machines
99
+ vms.wont_be_nil
100
+ vms.must_be_kind_of Array
101
+ vm = vms.first
102
+ vm.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
103
+ vm_names = vms.map(&:vm_name)
104
+ vm_names.must_include vm.vm_name
105
+ end
106
+ end
107
+
108
+ describe '#add_data_disk' do
109
+ it 'add data disk to virtual machine' do
110
+ lun = rand(1..15)
111
+ others = { disk_size: 100 }
112
+ subject.add_data_disk(vm_name, csn , lun, others)
113
+ dms = VirtualMachineDiskManagementService.new
114
+ disks = dms.list_virtual_machine_disks
115
+ disks = disks.select { |x| (/#{csn}/ =~ x.name) && x.os_type.empty? }
116
+ assert_operator disks.size, :>=, 1
117
+ disks.first.size.must_equal others[:disk_size].to_s
118
+ end
119
+ end
120
+
121
+ describe 'Add, Update, Delete endpoints' do
122
+
123
+ it 'should add endpoints to virtual machine.' do
124
+ ep1 = {
125
+ name: 'endpoint-1',
126
+ public_port: 777,
127
+ local_port: 777,
128
+ protocol: 'UDP',
129
+ }
130
+ ep2 = {
131
+ name: 'endpoint-2',
132
+ public_port: 888,
133
+ local_port: 889,
134
+ protocol: 'UDP',
135
+ load_balancer_name: 'lb',
136
+ load_balancer: { protocol: 'http', path: 'mypath' }
137
+ }
138
+ subject.update_endpoints(vm_name, csn, ep1, ep2)
139
+ vm = subject.get_virtual_machine(vm_name, csn)
140
+ vm.udp_endpoints.size.must_equal 2
141
+ vm.udp_endpoints.first[:name].must_equal 'endpoint-1'
142
+ vm.udp_endpoints.last[:name].must_equal 'endpoint-2'
143
+ end
144
+
145
+ it 'should update existing endpoints of virtual machine.' do
146
+ ep1 = {
147
+ name: 'SSH',
148
+ public_port: 2222,
149
+ local_port: 22,
150
+ protocol: 'TCP',
151
+ }
152
+ subject.update_endpoints(vm_name, csn, ep1)
153
+ vm = subject.get_virtual_machine(vm_name, csn)
154
+ vm.tcp_endpoints.size.must_equal 1
155
+ vm.tcp_endpoints.first[:name].must_equal 'SSH'
156
+ vm.tcp_endpoints.first[:public_port].must_equal '2222'
157
+ end
158
+
159
+ it 'should delete endpoint of virtual machine.' do
160
+ subject.delete_endpoint(vm_name, csn, 'SSH')
161
+ vm = subject.get_virtual_machine(vm_name, csn)
162
+ vm.tcp_endpoints.size.must_equal 0
163
+ ep1 = {
164
+ name: 'SSH',
165
+ public_port: 22,
166
+ local_port: 22,
167
+ protocol: 'TCP',
168
+ }
169
+ subject.update_endpoints(vm_name, csn, ep1)
170
+ end
171
+ end
172
+
173
+ end
174
+ end # end
@@ -28,7 +28,7 @@ class VirtualMachineNameGenerator
28
28
  vm_name = random_text('test-')
29
29
  cloud_name = random_text(vm_name + '-service-')
30
30
  @names << [vm_name, cloud_name]
31
- return vm_name, cloud_name
31
+ [vm_name, cloud_name]
32
32
  end
33
33
 
34
34
  def clean
@@ -44,43 +44,31 @@ class VirtualMachineNameGenerator
44
44
  virtual_machine_service = Azure::VirtualMachineManagementService.new
45
45
  virtualmachines = virtual_machine_service.list_virtual_machines
46
46
  azure_cloud_service = Azure::CloudServiceManagementService.new
47
- virtualmachines.each do |virtualmachine|
48
- if virtualmachine.vm_name.include?('test-') &&\
49
- virtualmachine.cloud_service_name.include?(
50
- virtualmachine.vm_name + '-service-'
51
- )
52
- begin
53
- azure_cloud_service.delete_cloud_service_deployment(
54
- virtualmachine.cloud_service_name
55
- )
56
- azure_cloud_service.delete_cloud_service(
57
- virtualmachine.cloud_service_name
58
- )
59
- rescue
60
- end
47
+ virtualmachines.each do |vm|
48
+ vm_name = vm.vm_name + '-service-'
49
+ csn = vm.cloud_service_name
50
+ if vm.vm_name.include?('test-') && csn.include?(vm_name)
51
+ azure_cloud_service.delete_cloud_service_deployment(csn) rescue nil
61
52
  end
62
53
  end
54
+
63
55
  # Delete cloud services
64
- Azure::BaseManagementService.new
65
56
  cloud_services = azure_cloud_service.list_cloud_services
66
57
  cloud_services.each do |cloud_service|
67
- if cloud_service.name.include?('test-') &&\
68
- cloud_service.name.include?('-service-')
69
- azure_cloud_service.delete_cloud_service(
70
- cloud_service.name
71
- ) rescue nil
58
+ csn = cloud_service.name
59
+ if csn.include?('test-') && csn.include?('-service-')
60
+ azure_cloud_service.delete_cloud_service(csn) rescue nil
72
61
  end
73
62
  end
74
63
 
75
64
  # Delete disks
76
- disk_management_service = Azure::VirtualMachineImageManagement::VirtualMachineDiskManagementService.new
77
- disks = disk_management_service.list_virtual_machine_disks
65
+ disk_service = VirtualMachineDiskManagementService.new
66
+ sleep 60
67
+ disks = disk_service.list_virtual_machine_disks
78
68
  disks.each do |disk|
79
- if disk.name.include?('-service-') &&\
80
- disk.name.include?('test-') && !disk.attached
81
- disk_management_service.delete_virtual_machine_disk(
82
- disk.name
83
- ) rescue nil
69
+ name = disk.name
70
+ if name.include?('-service-') && name.include?('test-') && !disk.attached
71
+ disk_service.delete_virtual_machine_disk(name) rescue nil
84
72
  end
85
73
  end
86
74
 
@@ -94,16 +82,13 @@ class VirtualMachineNameGenerator
94
82
  end
95
83
 
96
84
  # Delete affinity groups
97
- affinity_group_service = Azure::BaseManagementService.new
98
- affinity_groups = affinity_group_service.list_affinity_groups
85
+ ag_service = Azure::BaseManagementService.new
86
+ affinity_groups = ag_service.list_affinity_groups
99
87
  affinity_groups.each do |affinity_group|
100
88
  if affinity_group.name.include?('affinity-group-')
101
- affinity_group_service.delete_affinity_group(
102
- affinity_group.name
103
- ) rescue nil
89
+ ag_service.delete_affinity_group(affinity_group.name) rescue nil
104
90
  end
105
91
  end
106
-
107
92
  end
108
93
  end
109
94