azurex 0.6.5 → 0.6.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6f9d12b83d338df45827df63b1627a5fc556b56
4
- data.tar.gz: 0b1851e3d7bd14bb66e1a1fdfa2cfb6c0d6ef0e7
3
+ metadata.gz: c96ccd80aafb20085d1e9b30e35c0546542f1ef1
4
+ data.tar.gz: c383e6867d9e57d804bdb2d2134fad00a56b4250
5
5
  SHA512:
6
- metadata.gz: 91ed977a7c75814f5e9998aeedebdf4c454f9153a53c894a28433b847677ae8e9af4885bcdb52a9451796d386f2af8088a1c3dc21b604b538de69cf206c2ff3b
7
- data.tar.gz: 9263653f9252e419f2d01fd2a5155e87ef8826a0c54855407c584a93ef0980376ebc09c736a92f43f0da15e2154656a4a85950ab593b232378882a2712c6c35a
6
+ metadata.gz: 6c8d74bd5d0fa9754e3b30071a5c4e984235418cbd365d99537670b75c2ed091b62e9bd29112b92fc8abb9e076f1f6973657adddb56efa16d38b034775a07c44
7
+ data.tar.gz: 48b7d6a731e96eacf0eb477e9b7d334a157e17176da345450de705d2e4425e2d4c57381c7265499b9023171bcff579f0cc3d60f052414553c40f327d9230c7df
data/README.md CHANGED
@@ -446,6 +446,23 @@ options = {
446
446
  }
447
447
  virtual_machine_service.create_virtual_machine(params,options)
448
448
 
449
+ #API usage to add new roles under cloud service creating VM. Example is an Ubuntu 14.04 VM with CustomData
450
+ params = {
451
+ :vm_name => 'vm_name',
452
+ :cloud_service_name => 'cloud_service_name',
453
+ :vm_user => 'azureuser',
454
+ :image => 'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04-LTS-amd64-server-20140724-en-us-30GB',
455
+ :password => 'ComplexPassword',
456
+ }
457
+ options = {
458
+ :storage_account_name => 'storage',
459
+ :private_key_file => '/home/data/private_key.key', #required for ssh
460
+ :certificate_file => '/home/data/pub_key.pem', #required for ssh
461
+ :vm_size => 'Small', #valid choices are (ExtraSmall Small Medium Large ExtraLarge A5 A6 A7 Basic_A0 Basic_A1 Basic_A2 Basic_A3 Basic_A4)
462
+ :custom_data => "#!/bin/sh\n\necho \"this is a shell script\" > /tmp/output\n",
463
+ }
464
+ virtual_machine_service.add_role(params, options)
465
+
449
466
  #API usage to add new roles under cloud service creating VM
450
467
  #API add_role create multiple roles under the same cloud service. Atleast a single deployment should be created under a hosted service.
451
468
  params = {
data/lib/azure/version.rb CHANGED
@@ -17,7 +17,7 @@ module Azure
17
17
  class Version
18
18
  MAJOR = 0 unless defined? MAJOR
19
19
  MINOR = 6 unless defined? MINOR
20
- UPDATE = 5 unless defined? UPDATE
20
+ UPDATE = 6 unless defined? UPDATE
21
21
  PRE = nil unless defined? PRE
22
22
 
23
23
  class << self
@@ -28,4 +28,4 @@ module Azure
28
28
  end
29
29
  end
30
30
  end
31
- end
31
+ end
@@ -148,6 +148,7 @@ module Azure
148
148
  end
149
149
  end
150
150
  end
151
+ add_custom_data(xml, options)
151
152
  end
152
153
  elsif options[:os_type] == 'Windows'
153
154
  xml.ConfigurationSet('i:type' => 'WindowsProvisioningConfigurationSet') do
@@ -174,10 +175,21 @@ module Azure
174
175
  end
175
176
  end
176
177
  xml.AdminUsername params[:vm_user]
178
+ add_custom_data(xml, options)
177
179
  end
178
180
  end
179
181
  end
180
182
 
183
+ def self.add_custom_data(xml, options)
184
+ if options[:custom_data]
185
+ custom_data = options[:custom_data]
186
+ unless custom_data.chomp[/==$/]
187
+ custom_data = Base64.encode64(custom_data)
188
+ end
189
+ xml.CustomData custom_data
190
+ end
191
+ end
192
+
181
193
  def self.default_endpoints_to_xml(xml, options)
182
194
  os_type = options[:os_type]
183
195
  used_ports = options[:existing_ports]
@@ -79,6 +79,7 @@ module Azure
79
79
  # * +:storage_account_name+ - String. Name of storage account.
80
80
  # * +:cloud_service_name+ - String. Name of cloud service.
81
81
  # * +:deployment_name+ - String. A name for the deployment.
82
+ # * +:custom_data+ - String. Your custom data for the virtual machine. It will be base64 encoded as required. Cannot be longer than 64kb or Azure will reject it
82
83
  # * +:tcp_endpoints+ - String. Specifies the internal port and external/public port separated by a colon.
83
84
  # You can map multiple internal and external ports by separating them with a comma.
84
85
  # * +:ssh_private_key_file+ - String. Path of private key file.
@@ -53,6 +53,11 @@ kZS1mYWNlNSI+DQogICAgPEluc3RhbmNlcyBjb3VudD0iMSIgLz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWN
53
53
  <OsVersion/>
54
54
  <RoleType>PersistentVMRole</RoleType>
55
55
  <ConfigurationSets>
56
+ <ConfigurationSet i:type="LinuxProvisioningConfigurationSet">
57
+ <ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
58
+ <!-- Shell script: "#!/bin/sh\n\necho \"this is a shell script\" > /tmp/output\n" -->
59
+ <CustomData>IyEvYmluL3NoCgplY2hvICJ0aGlzIGlzIGEgc2hlbGwgc2NyaXB0IiA+IC90\nbXAvb3V0cHV0Cg==</CustomData>
60
+ </ConfigurationSet>
56
61
  <ConfigurationSet i:type="NetworkConfigurationSet">
57
62
  <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
58
63
  <InputEndpoints>
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #--------------------------------------------------------------------------
15
+ require 'base64'
15
16
  require 'test_helper'
16
17
 
17
18
  describe Azure::VirtualMachineManagement::Serialization do
@@ -19,6 +20,7 @@ describe Azure::VirtualMachineManagement::Serialization do
19
20
 
20
21
  let(:vm_xml) { Nokogiri::XML(Fixtures['virtual_machine']) }
21
22
  let(:csn) { 'cloud-service-1' }
23
+ CUSTOM_DATA = "#!/bin/sh\n\necho \"this is a shell script\" > /tmp/output\n"
22
24
 
23
25
  describe '#virtual_machines_from_xml' do
24
26
 
@@ -123,6 +125,7 @@ describe Azure::VirtualMachineManagement::Serialization do
123
125
  cloud_service_name: 'cloud-service-name',
124
126
  tcp_endpoints: '80,3389:3390,85:85',
125
127
  availability_set_name: 'aval-set',
128
+ custom_data: CUSTOM_DATA,
126
129
  winrm_https_port: '5988',
127
130
  winrm_transport: ['http','https']
128
131
  }
@@ -173,6 +176,15 @@ describe Azure::VirtualMachineManagement::Serialization do
173
176
  local_port: '5986'
174
177
  )
175
178
  end
179
+
180
+ it "returns an XML file with the CustomData encoded" do
181
+ params[:certificate] = {fingerprint: 'CFB8C256D2986559C630547F2D0'}
182
+ options[:os_type] = 'Linux'
183
+ result = subject.deployment_to_xml params, image, options
184
+ doc = Nokogiri::XML(result)
185
+ encoded_script = Base64.encode64(CUSTOM_DATA)
186
+ doc.css('Deployment RoleList Role ConfigurationSets ConfigurationSet CustomData').text.must_equal encoded_script
187
+ end
176
188
  end
177
189
 
178
190
  describe '#add_data_disk_to_xml' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azurex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-24 00:00:00.000000000 Z
12
+ date: 2014-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri