Merge pull request #53 from opscode/adamed-OC-8170
OC-8170: Support new publishsettings format
This commit is contained in:
Коммит
57e2876120
|
@ -19,14 +19,14 @@ OR
|
|||
The management certificate is required for secure communication with the Windows Azure Platform via the REST APIs. These can be obtained from the publishsettings file. You need to download the .publishsettings file from the link given below. You can either provide the path to the .publishsettings file OR you can generate the management certificate yourself from the .publishsettings file.
|
||||
|
||||
===Management Certificate using the .publishsettings file
|
||||
Download the .publishsettings file from http://go.microsoft.com/fwlink/?LinkId=254432
|
||||
Download the .publishsettings file from https://manage.windowsazure.com/publishsettings/index?client=xplat
|
||||
|
||||
Set the option :azure_publish_settings_file by specifying the path to the downloaded .publishsettings file. The plugin provides this easy option and will save you the complexity of the second approach listed next.
|
||||
|
||||
===Management Certificate in the PEM format
|
||||
Follow these steps to generate the certificate in the PEM format
|
||||
|
||||
1. Download the settings file from http://go.microsoft.com/fwlink/?LinkId=254432
|
||||
1. Download the settings file from https://manage.windowsazure.com/publishsettings/index?client=xplat
|
||||
2. Extract the data from the ManagementCertificate field into a separate file named - cert.pfx
|
||||
3. Decode the certificate file :
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PublishData>
|
||||
<PublishProfile
|
||||
SchemaVersion="2.0"
|
||||
PublishMethod="AzureServiceManagementAPI">
|
||||
<Subscription
|
||||
ServiceManagementUrl="https://management.core.windows.net"
|
||||
Id="id1"
|
||||
Name="Name1"
|
||||
ManagementCertificate="MIIKDAIBAzCCCcwGCSqGSIb3DQEHAaCCCb0Eggm5MIIJtTCCBe4GCSqGSIb3DQEHAaCCBd8EggXbMIIF1zCCBdMGCyqGSIb3DQEMCgECoIIE7jCCBOowHAYKKoZIhvcNAQwBAzAOBAiLQ3BBLundVAICB9AEggTIOsts+JzxcjavAkuAlf4nfDbknQZS5pz9itLbrEM7PeXYj0xsJPnOYn/vq+ckpDDSRwezwPVlWmB6B6Gr9QFijqZ/c15OiKBkAiSBuM6OWAfr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QG0LmisYi31Cp2fbBpnwtk5VUYgKFjckm5sBqd260aKTv/A7Vw2fm0nTxCQTUh9/Z1yBv+m45tL7uxt8+UOVxZI2xR7qZ02vL1x8TIrB4sX0qaP1XGSQUYdtBTqOBwfJ3FswKjaAdV997pmkFo0q70aKmkHLd+byTXe+WbaYy7ww47fPcg0rbH6pw2Z6xGOwaH3Ab/UDsbRTE6225mN3rUPeuIA2RDO3hPgATaov4AEI8eYOlLCu4UaQEtMT1ptYpjaTYVNTIDEndxL5c9JVTzsNl/85cFSK7Wkg/Zx4vOfjEVBtLiNhH3ClAd76gP7Emgtu6yySl7e6O4f15obExIrbTdENp8f2tKxNkkcf7xJ8GcY06mxqUPZ0x5vnuZlzpihD4neZlyGOS5eGGJYd9ssCm6QIm/YGgTPat2q4HkgyjBydkO/x+splr3YFcZEhjEwdAwvra/T4S7pzl1sHNJdVyUE+WtXFUgswZB01GXaLw+2A/8wWiGHbbTXLXukk1Qr6oOpTenKQdJZivktYSHg+KoicS6XGRa4+ntyAh0rFx46i87y1QIOBunblns9iyBNPtvPES+lHqmuSTl81QH9WoTvC2bbN8LF0mKDe4ko4llSbWC6888lSQ95WeLB1KwLcABszLqfIgoClxR8IBCu9X4Ghzk8e7OAlg84LYs4ab5TE1B3B4axE0WGMVgnQSJtaVH2SANEB6iUvrJm2wt+MTY6/DWNqwdThtXkoVnrdTq+bawpMus/8HLgqa8rvyC42foap1PvndlCQTdtlPzWefRx/H5lcMOfNxU7picvn9NzhHeieoY3a912uNFfAvVf6LQsOGN+4/RkoCAZUg/PDt3BevG7VzhDklXbiU9mar49lGOLJqeKkNCCc/5edas8hm6uAMcq+FYgxYE9kgJw7QSCQQwNzAfMAcGBSsOAwIaBBRsGPeX29jWkCSGvcztDEMtG8X7MAQU5GdOKIBTEeo3fUWpwPcbtQauY1M=">
|
||||
</PublishProfile>
|
||||
</PublishData>
|
|
@ -125,9 +125,18 @@ class Chef
|
|||
begin
|
||||
doc = Nokogiri::XML(File.open(find_file(filename)))
|
||||
profile = doc.at_css("PublishProfile")
|
||||
management_cert = OpenSSL::PKCS12.new(Base64.decode64(profile.attribute("ManagementCertificate").value))
|
||||
subscription = profile.at_css("Subscription")
|
||||
#check given PublishSettings XML file format.Currently PublishSettings file have two different XML format
|
||||
if profile.attribute("SchemaVersion").nil?
|
||||
management_cert = OpenSSL::PKCS12.new(Base64.decode64(profile.attribute("ManagementCertificate").value))
|
||||
Chef::Config[:knife][:azure_api_host_name] = URI(profile.attribute("Url").value).host
|
||||
elsif profile.attribute("SchemaVersion").value == "2.0"
|
||||
management_cert = OpenSSL::PKCS12.new(Base64.decode64(subscription.attribute("ManagementCertificate").value))
|
||||
Chef::Config[:knife][:azure_api_host_name] = URI(subscription.attribute("ServiceManagementUrl").value).host
|
||||
else
|
||||
ui.error("Publish settings file Schema not supported - " + filename)
|
||||
end
|
||||
Chef::Config[:knife][:azure_mgmt_cert] = management_cert.certificate.to_pem + management_cert.key.to_pem
|
||||
Chef::Config[:knife][:azure_api_host_name] = URI(profile.attribute("Url").value).host
|
||||
Chef::Config[:knife][:azure_subscription_id] = doc.at_css("Subscription").attribute("Id").value
|
||||
rescue
|
||||
ui.error("Incorrect publish settings file - " + filename)
|
||||
|
|
|
@ -55,6 +55,13 @@ describe Chef::Knife::AzureBase do
|
|||
validate_cert()
|
||||
end
|
||||
|
||||
it "- should validate parse method for SchemaVersion2-0 publishsettings file" do
|
||||
@dummy.parse_publish_settings_file("azureValidSchemaVersion-2.0.publishsettings")
|
||||
Chef::Config[:knife][:azure_api_host_name].should == 'management.core.windows.net'
|
||||
Chef::Config[:knife][:azure_subscription_id].should == 'id1'
|
||||
validate_cert()
|
||||
end
|
||||
|
||||
it "- should validate settings file and subscrition id" do
|
||||
@dummy.config[:azure_subscription_id] = "azure_subscription_id"
|
||||
Chef::Config[:knife][:azure_publish_settings_file] = "azureValid.publishsettings"
|
||||
|
|
Загрузка…
Ссылка в новой задаче