├── .expeditor ├── config.yml ├── run_linux_tests.sh ├── update_version.sh └── verify.pipeline.yml ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── BUG_TEMPLATE.md │ ├── DESIGN_PROPOSAL.md │ ├── ENHANCEMENT_REQUEST_TEMPLATE.md │ └── SUPPORT_QUESTION.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ └── build.yml ├── .gitignore ├── .rspec ├── .rubocop.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Gemfile ├── Guardfile ├── LICENSE ├── README.md ├── Rakefile ├── VERSION ├── docs ├── ARM.md ├── bootstrap.md └── configuration.md ├── knife-azure.gemspec ├── lib ├── azure │ ├── azure_interface.rb │ ├── custom_errors.rb │ ├── helpers.rb │ └── resource_management │ │ ├── ARM_deployment_template.rb │ │ ├── ARM_interface.rb │ │ ├── vnet_config.rb │ │ └── windows_credentials.rb ├── chef │ └── knife │ │ ├── azurerm_server_create.rb │ │ ├── azurerm_server_delete.rb │ │ ├── azurerm_server_list.rb │ │ ├── azurerm_server_show.rb │ │ ├── bootstrap │ │ ├── bootstrapper.rb │ │ └── common_bootstrap_options.rb │ │ ├── bootstrap_azurerm.rb │ │ └── helpers │ │ └── azurerm_base.rb └── knife-azure │ └── version.rb ├── sonar-project.properties └── spec ├── functional ├── ag_test.rb ├── deploys_test.rb ├── host_test.rb ├── images_list_test.rb ├── role_test.rb └── vnet_test.rb ├── integration ├── azure_spec.rb └── config │ ├── azure_invalid.publishsettings │ └── environment.yml.sample ├── spec_helper.rb └── unit ├── assets ├── accessTokens.json ├── azure-profile-files │ ├── A_Bd_account_azure_profile.json │ ├── A_account_azure_profile.json │ ├── Ad_B_account_azure_profile.json │ └── B_account_azure_profile.json ├── bootstrap_azure_role_xmls │ ├── extensions_list.xml │ ├── parse_role_list_xml │ │ ├── role_list_1.xml │ │ └── role_list_2.xml │ ├── setup_extension │ │ ├── update_role.xml │ │ └── updated_role.xml │ └── update_role_xml_for_extension │ │ ├── input_role_1.xml │ │ ├── input_role_2.xml │ │ ├── input_role_3.xml │ │ ├── input_role_4.xml │ │ ├── output_role_1.xml │ │ ├── output_role_2.xml │ │ └── output_role_3.xml ├── client.pem ├── create_ag_for_new-ag.xml ├── create_deployment.xml ├── create_deployment_domain.xml ├── create_deployment_in_progress.xml ├── create_deployment_key.xml ├── create_deployment_virtual_network.xml ├── create_deployment_winrm.xml ├── create_host_affinity.xml ├── create_host_location.xml ├── create_role.xml ├── create_storageservice_for_service003.xml ├── create_storageservice_for_service004.xml ├── error_404.xml ├── extension_deployment_xml.xml ├── get_network.xml ├── get_service_certificate.xml ├── get_service_certificate_error.xml ├── key_rsa ├── key_rsa.pub ├── list_affinitygroups.xml ├── list_deployments_for_service000.xml ├── list_deployments_for_service001.xml ├── list_deployments_for_service002.xml ├── list_deployments_for_service003.xml ├── list_deployments_for_service004.xml ├── list_deployments_for_service005.xml ├── list_deployments_for_vmname.xml ├── list_disks.xml ├── list_disks_for_role002.xml ├── list_hosts.xml ├── list_images.xml ├── list_storageaccounts.xml ├── list_vnets.xml ├── post_success.xml ├── publish-settings-files │ ├── A_account.publishsettings │ ├── B_account.publishsettings │ ├── azureInvalid.publishsettings │ ├── azureValid.publishsettings │ └── azureValidSchemaVersion-2.0.publishsettings ├── secret_file ├── set_network_existing.xml └── set_network_new.xml ├── azurerm_base_spec.rb ├── azurerm_server_create_spec.rb ├── azurerm_server_delete_spec.rb ├── azurerm_server_list_spec.rb ├── azurerm_server_show_spec.rb ├── bootstrap_azurerm_spec.rb ├── query_azure_mock.rb └── windows_credentials_spec.rb /.expeditor/config.yml: -------------------------------------------------------------------------------- 1 | # Documentation available at https://expeditor.chef.io/docs/getting-started/ 2 | --- 3 | 4 | # Slack channel in Chef Software slack to send notifications about build failures, etc 5 | slack: 6 | notify_channel: 7 | - sustaining-notify 8 | - chef-ws-notify 9 | 10 | # This publish is triggered by the `built_in:publish_rubygems` artifact_action. 11 | rubygems: 12 | - knife-azure 13 | 14 | github: 15 | # This deletes the GitHub PR branch after successfully merged into the release branch 16 | delete_branch_on_merge: true 17 | # The tag format to use (e.g. v1.0.0) 18 | version_tag_format: "v{{version}}" 19 | # allow bumping the minor release via label 20 | minor_bump_labels: 21 | - "Expeditor: Bump Version Minor" 22 | # allow bumping the major release via label 23 | major_bump_labels: 24 | - "Expeditor: Bump Version Major" 25 | 26 | changelog: 27 | rollup_header: Changes not yet released to rubygems.org 28 | 29 | subscriptions: 30 | # These actions are taken, in order they are specified, anytime a Pull Request is merged. 31 | - workload: pull_request_merged:{{github_repo}}:{{release_branch}}:* 32 | actions: 33 | - built_in:bump_version: 34 | ignore_labels: 35 | - "Expeditor: Skip Version Bump" 36 | - "Expeditor: Skip All" 37 | - bash:.expeditor/update_version.sh: 38 | only_if: built_in:bump_version 39 | - built_in:update_changelog: 40 | ignore_labels: 41 | - "Expeditor: Skip Changelog" 42 | - "Expeditor: Skip All" 43 | - built_in:build_gem: 44 | only_if: built_in:bump_version 45 | 46 | - workload: project_promoted:{{agent_id}}:* 47 | actions: 48 | - built_in:rollover_changelog 49 | - built_in:publish_rubygems 50 | 51 | pipelines: 52 | - verify: 53 | description: Pull Request validation tests 54 | public: true 55 | -------------------------------------------------------------------------------- /.expeditor/run_linux_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # This script runs a passed in command, but first setups up the bundler caching on the repo 4 | 5 | set -ue 6 | 7 | export USER="root" 8 | export LANG=C.UTF-8 LANGUAGE=C.UTF-8 9 | 10 | echo "--- bundle install" 11 | 12 | bundle config --local path vendor/bundle 13 | bundle install --jobs=7 --retry=3 14 | 15 | echo "+++ bundle exec task" 16 | bundle exec $@ 17 | -------------------------------------------------------------------------------- /.expeditor/update_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # After a PR merge, Chef Expeditor will bump the PATCH version in the VERSION file. 4 | # It then executes this file to update any other files/components with that new version. 5 | # 6 | 7 | set -evx 8 | 9 | sed -i -r "s/^(\s*)VERSION = \".+\"/\1VERSION = \"$(cat VERSION)\"/" lib/knife-azure/version.rb 10 | 11 | # Once Expeditor finishes executing this script, it will commit the changes and push 12 | # the commit as a new tag corresponding to the value in the VERSION file. 13 | -------------------------------------------------------------------------------- /.expeditor/verify.pipeline.yml: -------------------------------------------------------------------------------- 1 | --- 2 | expeditor: 3 | cached_folders: 4 | - vendor 5 | defaults: 6 | buildkite: 7 | retry: 8 | automatic: 9 | limit: 1 10 | timeout_in_minutes: 30 11 | 12 | steps: 13 | 14 | - label: run-specs-ruby-3.1 15 | command: 16 | - .expeditor/run_linux_tests.sh rake 17 | expeditor: 18 | executor: 19 | docker: 20 | image: ruby:3.1-buster 21 | 22 | - label: run-specs-windows 23 | command: 24 | - bundle config --local path vendor/bundle 25 | - bundle config set --local without docs debug 26 | - bundle install --jobs=7 --retry=3 27 | - bundle exec rake spec 28 | expeditor: 29 | executor: 30 | docker: 31 | host_os: windows 32 | image: rubydistros/windows-2019:3.1 33 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Order is important. The last matching pattern has the most precedence. 2 | 3 | * @chef/msys-developers 4 | .expeditor/** @chef/jex-team 5 | README.md @chef/docs-team 6 | RELEASE_NOTES.md @chef/docs-team 7 | .github/ISSUE_TEMPLATE/** @chef/docs-team 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: � Bug Report 3 | about: If something isn't working as expected �. 4 | labels: "Status: Untriaged" 5 | --- 6 | 7 | # Version: 8 | 9 | [Version of the project installed] 10 | 11 | # Environment: 12 | 13 | [Details about the environment such as the Operating System, cookbook details, etc...] 14 | 15 | # Scenario: 16 | 17 | [What you are trying to achieve and you can't?] 18 | 19 | # Steps to Reproduce: 20 | 21 | [If you are filing an issue what are the things we need to do in order to repro your problem?] 22 | 23 | # Expected Result: 24 | 25 | [What are you expecting to happen as the consequence of above reproduction steps?] 26 | 27 | # Actual Result: 28 | 29 | [What actually happens after the reproduction steps?] 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/DESIGN_PROPOSAL.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Design Proposal 3 | about: I have a significant change I would like to propose and discuss before starting 4 | labels: "Status: Untriaged" 5 | --- 6 | 7 | ### When a Change Needs a Design Proposal 8 | 9 | A design proposal should be opened any time a change meets one of the following qualifications: 10 | 11 | - Significantly changes the user experience of a project in a way that impacts users. 12 | - Significantly changes the underlying architecture of the project in a way that impacts other developers. 13 | - Changes the development or testing process of the project such as a change of CI systems or test frameworks. 14 | 15 | ### Why We Use This Process 16 | 17 | - Allows all interested parties (including any community member) to discuss large impact changes to a project. 18 | - Serves as a durable paper trail for discussions regarding project architecture. 19 | - Forces design discussions to occur before PRs are created. 20 | - Reduces PR refactoring and rejected PRs. 21 | 22 | --- 23 | 24 | 25 | 26 | ## Motivation 27 | 28 | 33 | 34 | ## Specification 35 | 36 | 37 | 38 | ## Downstream Impact 39 | 40 | 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/ENHANCEMENT_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🚀 Enhancement Request 3 | about: I have a suggestion (and may want to implement it 🙂)! 4 | labels: "Status: Untriaged" 5 | --- 6 | 7 | ### Describe the Enhancement: 8 | 9 | 10 | ### Describe the Need: 11 | 12 | 13 | ### Current Alternative 14 | 15 | 16 | ### Can We Help You Implement This?: 17 | 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🤗 Support Question 3 | about: If you have a question 💬, please check out our Slack! 4 | --- 5 | 6 | We use GitHub issues to track bugs and feature requests. If you need help please post to our Mailing List or join the Chef Community Slack. 7 | 8 | * Chef Community Slack at http://community-slack.chef.io/. 9 | * Chef Mailing List https://discourse.chef.io/ 10 | 11 | 12 | Support issues opened here will be closed and redirected to Slack or Discourse. 13 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | 3 | [Please describe what this change achieves] 4 | 5 | ### Issues Resolved 6 | 7 | [List any existing issues this PR resolves, or any Discourse or 8 | StackOverflow discussions that are relevant] 9 | 10 | ### Check List 11 | 12 | - [ ] New functionality includes tests 13 | - [ ] All tests pass 14 | - [ ] All commits have been signed-off for the Developer Certificate of Origin. See 15 | - [ ] PR title is a worthy inclusion in the CHANGELOG -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: bundler 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "06:00" 8 | timezone: America/Los_Angeles 9 | open-pull-requests-limit: 10 10 | ignore: 11 | - dependency-name: activesupport 12 | versions: 13 | - 6.1.1 14 | - 6.1.2 15 | - 6.1.2.1 16 | - 6.1.3 17 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - main # or the name of your main branch 6 | - develop 7 | - 'release/**' 8 | pull_request: 9 | types: [opened, synchronize, reopened] 10 | jobs: 11 | build: 12 | runs-on: ip-range-controlled 13 | steps: 14 | - uses: actions/checkout@v3 15 | with: 16 | fetch-depth: 0 17 | - name: SonarQube Scan 18 | uses: sonarsource/sonarqube-scan-action@master 19 | env: 20 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 21 | SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} 22 | # If you wish to fail your job when the Quality Gate is red, uncomment the 23 | # following lines. This would typically be used to fail a deployment. 24 | # We do not recommend to use this in a pull request. Prefer using pull request 25 | # decoration instead. 26 | # - uses: sonarsource/sonarqube-quality-gate-action@main 27 | # timeout-minutes: 5 28 | # env: 29 | # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Do not include Gemfile.lock in a gem 2 | # http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/ 3 | Gemfile.lock 4 | vendor 5 | .bundle 6 | 7 | # OS X Metadata file 8 | .DS_Store 9 | 10 | # vim temporary files 11 | *.swp 12 | 13 | # ignore any private keys floating around 14 | *.pem 15 | 16 | pkg/ 17 | tmp/ 18 | 19 | # Ignore gem files 20 | *.gem 21 | 22 | # Ignore IDEA project files 23 | .idea/ 24 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format documentation 3 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | Naming/VariableName: 2 | Enabled: false 3 | 4 | # Offense count: 2 5 | Lint/Loop: 6 | Exclude: 7 | - 'lib/azure/resource_management/ARM_interface.rb' 8 | 9 | # Offense count: 14 10 | Lint/UselessAssignment: 11 | Exclude: 12 | - 'lib/azure/resource_management/ARM_deployment_template.rb' 13 | - 'lib/azure/resource_management/ARM_interface.rb' 14 | - 'lib/azure/resource_management/windows_credentials.rb' 15 | - 'lib/chef/knife/azurerm_server_create.rb' 16 | - 'lib/chef/knife/azurerm_server_delete.rb' 17 | - 'lib/chef/knife/helpers/azurerm_base.rb' 18 | - 'spec/unit/azurerm_server_delete_spec.rb' 19 | - 'spec/unit/azurerm_server_show_spec.rb' 20 | 21 | # Offense count: 1 22 | Style/NumericPredicate: 23 | Exclude: 24 | - 'spec/**/*' 25 | - 'lib/chef/knife/helpers/azurerm_base.rb' 26 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | Please refer to the Chef Community Code of Conduct at https://www.chef.io/code-of-conduct/ 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Please refer to https://github.com/chef/chef/blob/master/CONTRIBUTING.md 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | 5 | group :test do 6 | gem "chefstyle" 7 | gem "rake" 8 | gem "rspec", ">= 3.0" 9 | gem "rspec_junit_formatter" 10 | end 11 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | # A sample Guardfile 2 | # More info at https://github.com/guard/guard#readme 3 | 4 | guard :rspec, version: 2 do 5 | watch(%r{^spec/.+_spec\.rb$}) 6 | watch(%r{^lib/(.+)\.rb$}) # { |m| "spec/lib/#{m[1]}_spec.rb" } 7 | watch("spec/spec_helper.rb") { "spec" } 8 | end 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Knife Azure 2 | 3 | [![Gem Version](https://badge.fury.io/rb/knife-azure.svg)](https://rubygems.org/gems/knife-azure) 4 | [![Build status](https://badge.buildkite.com/7796bf2bd728a4a0ca714273e12ab2df436d6afccb862ea5bb.svg)](https://buildkite.com/chef-oss/chef-knife-azure-master-verify) 5 | 6 | **Umbrella Project**: [Knife](https://github.com/chef/chef-oss-practices/blob/master/projects/knife.md) 7 | 8 | **Project State**: [Active](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md#active) 9 | 10 | **Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days 11 | 12 | **Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days 13 | 14 | ## Description 15 | 16 | A [knife](http://docs.chef.io/knife.html) plugin to create, delete, and enumerate [Microsoft Azure](https://azure.microsoft.com) resources to be managed by Chef Infra. 17 | 18 | NOTE: You may also want to consider using the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli), this application is written by the Azure team and has many other integrations with Azure. If click [here](https://github.com/chef-partners/azure-chef-extension/blob/master/examples/azure-xplat-cli-examples.md) you'll see deeper examples of using the Chef extension and Azure. 19 | 20 | ## Installation 21 | 22 | knife-azure comes bundled with Chef Workstation, which can be installed via: 23 | 24 | ``` 25 | https://downloads.chef.io/chef-workstation/ 26 | ``` 27 | 28 | ## Modes 29 | 30 | `knife-azure 4.0` onwards removes the legacy `knife azure` commands that utilized the Azure Service Management API. This API was deprecated in March 2018. 31 | 32 | ## Configuration 33 | 34 | 1. [ARM Configuration](docs/configuration.md#arm-mode) 35 | 36 | ## Detailed Usage 37 | 38 | 1. [ARM Mode](docs/ARM.md) 39 | 40 | ## Bootstrap existing VM to install the Chef Infra Client using chef-extension 41 | 42 | We have added a utility to bootstrap existing VM. This will install the Chef Infra Client using chef extension on your VM. 43 | 44 | 1. [Bootstrap Doc for ARM Mode](docs/bootstrap.md#arm-mode) 45 | 46 | ## Contributing 47 | 48 | For information on contributing to this project see 49 | 50 | ## License 51 | 52 | Copyright:: Copyright 2010-2020, Chef Software, Inc. 53 | 54 | License:: Apache License, Version 2.0 55 | 56 | ```text 57 | Licensed under the Apache License, Version 2.0 (the "License"); 58 | you may not use this file except in compliance with the License. 59 | You may obtain a copy of the License at 60 | 61 | http://www.apache.org/licenses/LICENSE-2.0 62 | 63 | Unless required by applicable law or agreed to in writing, software 64 | distributed under the License is distributed on an "AS IS" BASIS, 65 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 66 | See the License for the specific language governing permissions and 67 | limitations under the License. 68 | ``` 69 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require "bundler/gem_tasks" 19 | require "rspec/core/rake_task" 20 | 21 | begin 22 | Bundler.setup(:default, :development) 23 | rescue Bundler::BundlerError => e 24 | warn e.message 25 | warn "Run `bundle install` to install missing gems" 26 | exit e.status_code 27 | end 28 | 29 | Bundler::GemHelper.install_tasks 30 | 31 | desc "Run specs" 32 | RSpec::Core::RakeTask.new(:spec) do |spec| 33 | spec.pattern = FileList["spec/unit/**/*_spec.rb"].to_a 34 | end 35 | 36 | RSpec::Core::RakeTask.new(:functional) do |spec| 37 | spec.pattern = FileList["spec/functional/**/*_test.rb"].to_a 38 | end 39 | 40 | RSpec::Core::RakeTask.new(:integration) do |spec| 41 | spec.pattern = FileList["spec/integration/**/*_test.rb"].to_a 42 | end 43 | 44 | RSpec::Core::RakeTask.new(:rcov) do |spec| 45 | spec.pattern = "spec/unit|functional/*_spec.rb" 46 | spec.rcov = true 47 | end 48 | 49 | begin 50 | require "chefstyle" 51 | require "rubocop/rake_task" 52 | desc "Run Chefstyle tests" 53 | RuboCop::RakeTask.new(:style) do |task| 54 | task.options += ["--display-cop-names", "--no-color"] 55 | end 56 | rescue LoadError 57 | puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed." 58 | end 59 | 60 | task default: %i{style spec} 61 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 4.0.0 -------------------------------------------------------------------------------- /docs/bootstrap.md: -------------------------------------------------------------------------------- 1 | # Bootstrap examples 2 | 3 | ## ARM mode 4 | 5 | Bootstrap existing Azure ARM VM using following command: 6 | 7 | ```knife bootstrap azurerm --azure-resource-group-name --azure-service-location ``` 8 | 9 | ```$ knife bootstrap azurerm myVMName --azure-resource-group-name myResourceGroup --azure-service-location 'westus'``` 10 | 11 | You can use other options like --azure-dns-name, --bootstrap-version with this command and there are many more options which can be used with this command. Use --help to identify more options. 12 | 13 | NOTE: This command only works for single VM bootstrap. 14 | -------------------------------------------------------------------------------- /docs/configuration.md: -------------------------------------------------------------------------------- 1 | # Configuration 2 | 3 | ## ARM mode 4 | 5 | ARM mode requires setting up a service principal for authentication and permissioning. For setting up a service principal from the command line please refer 6 | [Create service principal with PowerShell / Azure CLI 2.0](http://aka.ms/cli-service-principal) (preferred approach) or 7 | [Unattended Authentication](http://aka.ms/auth-unattended). For detailed explanation of authentication in Azure, 8 | see [Developer’s guide to auth with Azure Resource Manager API](http://aka.ms/arm-auth-dev-guide). 9 | 10 | After creating the service principal, you should have these 3 values, a client id (GUID), client secret(string) and tenant id (GUID). 11 | 12 | Be sure when you are creating the above user you change the example from `-o Reader` to `-o Contributor` otherwise you will not be able 13 | to spin up or delete machines. 14 | 15 | Put the following in your `knife.rb` 16 | 17 | ```ruby 18 | knife[:azure_tenant_id] # found via: tenantId=$(azure account show -s --json | jq -r '.[0].tenantId') 19 | knife[:azure_subscription_id] # found via: 20 | knife[:azure_client_id] # appId=$(azure ad app show --search --json | jq -r '.[0].appId') 21 | knife[:azure_client_secret] # password you set at initially 22 | ``` 23 | 24 | *Microsoft Azure encourages the use of Azure CLI 2.0. If you are still using [azure-xplat-cli](https://github.com/Azure/azure-xplat-cli) then you may simply run ```azure login``` and skip creating the service principal entirely.* 25 | 26 | ## Alternative Management Certificate Specification 27 | 28 | In addition to specifying the management certificate using the publishsettings 29 | file, you can also specify it in PEM format. Follow these steps to generate the certificate in the PEM format: 30 | 31 | 1. Download the settings file from https://manage.windowsazure.com/publishsettings/index?client=xplat 32 | 1. Extract the data from the ManagementCertificate field into a separate file named - cert.pfx 33 | 1. Decode the certificate file: 34 | 35 | ### On Linux/Mac(Homebrew) 36 | 37 | base64 -d cert.pfx > cert_decoded.pfx 38 | 39 | ### On Windows 40 | 41 | You can decode and extract the PFX file using powershell or a free windows base 64 decoder such as http://www.fourmilab.ch/webtools/base64/base64. zip, 42 | 43 | base64.exe -d cert.pfx -> cert_decoded.pfx 44 | 45 | 1. Convert the decoded PFX file to a PEM file 46 | 47 | #### On Linux/Mac(Homebrew) 48 | 49 | openssl pkcs12 -in cert_decoded.pfx -out managementCertificate.pem -nodes 50 | 51 | #### On Windows 52 | Use powershell & run following command. If openssl.exe is not already installed it can be downloaded from http://www.openssl.org/related/binaries.html (Note: openssl depends on Microsoft Visual C++ Redistributable package (x86) which must be installed for openssl to function properly). 53 | 54 | openssl base64 -d -A -in cert_decoded.pfx -out cert_decode.der 55 | 56 | openssl pkcs12 -in cert_decoded.der -out managementCertificate.pem -nodes 57 | 58 | You might be asked to enter a password which is usually blank. 59 | You might be also asked to enter a passphrase. Please enter the phrase of your choice. 60 | 61 | It is possible to generate your own certificates and upload them. More Detailed Documentation about the Management Certificates is available : https://www.windowsazure.com/en-us/manage/linux/common-tasks/manage-certificates/ 62 | -------------------------------------------------------------------------------- /knife-azure.gemspec: -------------------------------------------------------------------------------- 1 | $:.unshift(File.dirname(__FILE__) + "/lib") 2 | require "knife-azure/version" 3 | 4 | Gem::Specification.new do |s| 5 | s.name = "knife-azure" 6 | s.version = Knife::Azure::VERSION 7 | 8 | s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= 9 | s.authors = ["Barry Davis", "Chirag Jog"] 10 | s.summary = "A plugin to the Chef Infra knife tool for creating instances on the Microsoft Azure platform" 11 | s.description = s.summary 12 | s.email = "oss@chef.io" 13 | s.licenses = ["Apache 2.0"] 14 | s.extra_rdoc_files = [ 15 | "LICENSE", 16 | ] 17 | s.files = %w{LICENSE} + Dir.glob("lib/**/*") 18 | s.homepage = "https://github.com/chef/knife-azure" 19 | s.require_paths = ["lib"] 20 | s.required_ruby_version = ">= 3.1" 21 | 22 | s.add_dependency "knife", ">= 18.0" 23 | s.add_dependency "nokogiri", ">= 1.5.5" 24 | s.add_dependency "azure_mgmt_resources", "~> 0.17", ">= 0.17.2" 25 | s.add_dependency "azure_mgmt_compute", "~> 0.18", ">= 0.18.3" 26 | s.add_dependency "azure_mgmt_storage", "~> 0.20", ">= 0.20.0" 27 | s.add_dependency "azure_mgmt_network", "~> 0.18", ">= 0.18.2" 28 | s.add_dependency "listen", "~> 3.1" 29 | s.add_dependency "ipaddress" 30 | s.add_dependency "ffi" 31 | s.add_dependency "rb-readline" 32 | end 33 | -------------------------------------------------------------------------------- /lib/azure/azure_interface.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "custom_errors" 19 | require_relative "helpers" 20 | 21 | module Azure 22 | class AzureInterface 23 | include CustomErrors 24 | include Helpers 25 | 26 | attr_accessor :ui 27 | 28 | def initialize(options = {}); end 29 | 30 | def create_server(params = {}) 31 | AzureInterface.api_not_implemented(self) 32 | end 33 | 34 | def list_servers 35 | AzureInterface.api_not_implemented(self) 36 | end 37 | 38 | def delete_server(server_name) 39 | AzureInterface.api_not_implemented(self) 40 | end 41 | 42 | def list_images 43 | AzureInterface.api_not_implemented(self) 44 | end 45 | 46 | def show_server(server_name, resource_group = "") 47 | AzureInterface.api_not_implemented(self) 48 | end 49 | 50 | def create_vnet(params = {}) 51 | AzureInterface.api_not_implemented(self) 52 | end 53 | 54 | def list_vnets 55 | AzureInterface.api_not_implemented(self) 56 | end 57 | 58 | def list_internal_lb 59 | AzureInterface.api_not_implemented(self) 60 | end 61 | 62 | def create_internal_lb(params = {}) 63 | AzureInterface.api_not_implemented(self) 64 | end 65 | 66 | def list_affinity_groups 67 | AzureInterface.api_not_implemented(self) 68 | end 69 | 70 | def create_affinity_group(params = {}) 71 | AzureInterface.api_not_implemented(self) 72 | end 73 | 74 | def find_server(server_name) 75 | AzureInterface.api_not_implemented(self) 76 | end 77 | end 78 | end 79 | -------------------------------------------------------------------------------- /lib/azure/custom_errors.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | module CustomErrors 19 | class InterfaceNotImplementedError < NoMethodError 20 | end 21 | 22 | def self.included(klass) 23 | klass.send(:include, CustomErrors::Methods) 24 | klass.send(:extend, CustomErrors::Methods) 25 | end 26 | 27 | module Methods 28 | def api_not_implemented(klass) 29 | caller.first =~ /in \`(.+)\'/ 30 | method_name = $1 31 | raise CustomErrors::InterfaceNotImplementedError.new("#{klass.class.name} needs to implement '#{method_name}' for interface #{name}!") 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /lib/azure/helpers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: vasundhara.jagdale@clogeny.com 3 | # Copyright:: Copyright (c) Chef Software Inc. 4 | # License:: Apache License, Version 2.0 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | module Azure 20 | module Helpers 21 | def random_string(len = 10) 22 | (0...len).map { 65.+(rand(25)).chr }.join 23 | end 24 | 25 | def strip_non_ascii(string) 26 | string.gsub(/[^0-9a-z ]/i, "") 27 | end 28 | 29 | def display_list(ui = nil, columns = [], rows = []) 30 | columns = columns.map { |col| ui.color(col, :bold) } 31 | count = columns.count 32 | rows = columns.concat(rows) 33 | puts "" 34 | puts ui.list(rows, :uneven_columns_across, count) 35 | end 36 | 37 | def msg_pair(ui = nil, label = nil, value = nil, color = :cyan) 38 | if value && !value.to_s.empty? 39 | puts "#{ui.color(label, color)}: #{value}" 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/chef/knife/azurerm_server_delete.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Barry Davis (barryd@jetstreamsoftware.com) 3 | # Author:: Adam Jacob () 4 | # Author:: Seth Chisamore () 5 | # Copyright:: Copyright (c) Chef Software Inc. 6 | # License:: Apache License, Version 2.0 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | require_relative "helpers/azurerm_base" 22 | 23 | class Chef 24 | class Knife 25 | class AzurermServerDelete < Knife 26 | 27 | include Knife::AzurermBase 28 | 29 | deps do 30 | # These two are needed for the '--purge' deletion case 31 | require "chef/node" 32 | require "chef/api_client" 33 | include Knife::AzurermBase 34 | end 35 | 36 | banner "knife azurerm server delete SERVER [SERVER] (options)" 37 | 38 | option :purge, 39 | short: "-P", 40 | long: "--purge", 41 | boolean: true, 42 | default: false, 43 | description: "Destroy corresponding node and client on the Chef Server, in addition to destroying the Windows Azure node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)." 44 | 45 | option :chef_node_name, 46 | short: "-N NAME", 47 | long: "--node-name NAME", 48 | description: "The name of the node and client to delete, if it differs from the server name. Only has meaning when used with the '--purge' option." 49 | 50 | option :delete_resource_group, 51 | long: "--delete-resource-group", 52 | boolean: true, 53 | default: false, 54 | description: "Deletes corresponding resource group along with Virtual Machine." 55 | 56 | # Extracted from Chef::Knife.delete_object, because it has a 57 | # confirmation step built in... By specifying the '--purge' 58 | # flag (and also explicitly confirming the server destruction!) 59 | # the user is already making their intent known. It is not 60 | # necessary to make them confirm two more times. 61 | 62 | def destroy_item(klass, name, type_name) 63 | object = klass.load(name) 64 | object.destroy 65 | ui.warn("Deleted #{type_name} #{name}") 66 | rescue Net::HTTPServerException 67 | ui.warn("Could not find a #{type_name} named #{name} to delete!") 68 | end 69 | 70 | def run 71 | $stdout.sync = true 72 | # check azure cli version due to azure changed `azure` to `az` in azure-cli2.0 73 | get_azure_cli_version 74 | validate_arm_keys!(:azure_resource_group_name) 75 | @vm_name = @name_args[0] 76 | 77 | if config[:delete_resource_group] 78 | delete_resource_group 79 | else 80 | service.delete_server(config[:azure_resource_group_name], @vm_name) 81 | end 82 | 83 | if config[:purge] 84 | purge_node 85 | else 86 | ui.warn("Corresponding node and client for the #{@vm_name} server were not deleted and remain registered with the Chef Server") 87 | end 88 | rescue => error 89 | service.common_arm_rescue_block(error) 90 | end 91 | 92 | def delete_resource_group 93 | resource_group_name = config[:azure_resource_group_name] 94 | ui.warn "Deleting resource group will delete all the virtual_machines inside it." 95 | begin 96 | ui.confirm("Do you really want to delete resource group") 97 | rescue SystemExit # Need to handle this as confirming with N/n raises SystemExit exception 98 | server = nil # Cleanup is implicitly performed in other cloud plugins 99 | ui.warn "Resource group not deleted. Proceeding for server delete ..." 100 | service.delete_server(config[:azure_resource_group_name], @vm_name) 101 | exit 102 | end 103 | ui.info "Deleting Resource Group " + resource_group_name + " and Virtual Machine " + @vm_name + " .." 104 | service.delete_resource_group(config[:azure_resource_group_name]) 105 | ui.warn "Deleted resource_group_name #{resource_group_name} and #{@vm_name}" 106 | end 107 | 108 | def purge_node 109 | node_to_delete = config[:chef_node_name] || @vm_name 110 | if node_to_delete 111 | destroy_item(Chef::Node, node_to_delete, "node") 112 | destroy_item(Chef::ApiClient, node_to_delete, "client") 113 | else 114 | ui.warn("Node name to purge not provided. Corresponding client node will remain on Chef Server.") 115 | end 116 | end 117 | end 118 | end 119 | end 120 | -------------------------------------------------------------------------------- /lib/chef/knife/azurerm_server_list.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Adam Jacob () 3 | # Copyright:: Copyright (c) Chef Software Inc. 4 | # License:: Apache License, Version 2.0 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require_relative "helpers/azurerm_base" 20 | 21 | class Chef 22 | class Knife 23 | class AzurermServerList < Knife 24 | 25 | include Knife::AzurermBase 26 | 27 | banner "knife azurerm server list (options)" 28 | 29 | deps do 30 | include Knife::AzurermBase 31 | end 32 | 33 | def run 34 | $stdout.sync = true 35 | # check azure cli version due to azure changed `azure` to `az` in azure-cli2.0 36 | get_azure_cli_version 37 | validate_arm_keys! 38 | begin 39 | service.list_servers(config[:azure_resource_group_name]) 40 | rescue => error 41 | service.common_arm_rescue_block(error) 42 | end 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /lib/chef/knife/azurerm_server_show.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Meera Navale (meera.navale@msystechnologies.com) 3 | # Copyright:: Copyright (c) Chef Software Inc. 4 | # License:: Apache License, Version 2.0 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require_relative "helpers/azurerm_base" 20 | 21 | class Chef 22 | class Knife 23 | class AzurermServerShow < Knife 24 | 25 | include Knife::AzurermBase 26 | 27 | banner "knife azurerm server show SERVER (options)" 28 | 29 | deps do 30 | include Knife::AzurermBase 31 | end 32 | 33 | def run 34 | $stdout.sync = true 35 | # check azure cli version due to azure changed `azure` to `az` in azure-cli2.0 36 | get_azure_cli_version 37 | validate_arm_keys!(:azure_resource_group_name) 38 | begin 39 | service.show_server(@name_args[0], config[:azure_resource_group_name]) 40 | rescue => error 41 | service.common_arm_rescue_block(error) 42 | end 43 | end 44 | 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/chef/knife/bootstrap/bootstrapper.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com) 3 | # Copyright:: Copyright (c) Chef Software Inc. 4 | # License:: Apache License, Version 2.0 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | module Azure 20 | class ResourceManagement 21 | autoload :ARMInterface, "azure/resource_management/ARM_interface" 22 | end 23 | end 24 | 25 | class Chef 26 | class Knife 27 | class Bootstrap 28 | module Bootstrapper 29 | 30 | def get_chef_extension_name 31 | is_image_windows? ? "ChefClient" : "LinuxChefClient" 32 | end 33 | 34 | def get_chef_extension_publisher 35 | "Chef.Bootstrap.WindowsAzure" 36 | end 37 | 38 | def default_hint_options 39 | %w{ 40 | vm_name 41 | public_fqdn 42 | platform 43 | } 44 | end 45 | 46 | # get latest version 47 | def get_chef_extension_version(chef_extension_name = nil) 48 | if config[:azure_chef_extension_version] 49 | config[:azure_chef_extension_version] 50 | else 51 | chef_extension_name ||= get_chef_extension_name 52 | service.get_latest_chef_extension_version( 53 | azure_service_location: config[:azure_service_location], 54 | chef_extension_publisher: get_chef_extension_publisher, 55 | chef_extension: chef_extension_name 56 | ) 57 | end 58 | end 59 | 60 | def ohai_hints 61 | hint_values = config[:ohai_hints] 62 | if hint_values.casecmp("default") == 0 63 | default_hint_options 64 | else 65 | hint_values.split(",") 66 | end 67 | end 68 | 69 | def get_chef_extension_public_params 70 | pub_config = {} 71 | if config[:azure_extension_client_config] 72 | pub_config[:client_rb] = File.read(File.expand_path(config[:azure_extension_client_config])) 73 | else 74 | pub_config[:client_rb] = "chef_server_url \t #{Chef::Config[:chef_server_url].to_json}\nvalidation_client_name\t#{Chef::Config[:validation_client_name].to_json}" 75 | end 76 | 77 | pub_config[:runlist] = config[:run_list].empty? ? "" : config[:run_list].join(",").to_json 78 | pub_config[:custom_json_attr] = config[:json_attributes] || {} 79 | pub_config[:extendedLogs] = config[:extended_logs] ? "true" : "false" 80 | pub_config[:hints] = ohai_hints if @service.instance_of?(Azure::ResourceManagement::ARMInterface) && !config[:ohai_hints].nil? 81 | pub_config[:chef_daemon_interval] = config[:chef_daemon_interval] if config[:chef_daemon_interval] 82 | pub_config[:daemon] = config[:daemon] if config[:daemon] 83 | 84 | # bootstrap attributes 85 | pub_config[:bootstrap_options] = {} 86 | pub_config[:bootstrap_options][:environment] = config[:environment] if config[:environment] 87 | pub_config[:bootstrap_options][:chef_node_name] = config[:chef_node_name] if config[:chef_node_name] 88 | pub_config[:bootstrap_options][:chef_server_url] = Chef::Config[:chef_server_url] if Chef::Config[:chef_server_url] 89 | pub_config[:bootstrap_options][:validation_client_name] = Chef::Config[:validation_client_name] if Chef::Config[:validation_client_name] 90 | pub_config[:bootstrap_options][:node_verify_api_cert] = config[:node_verify_api_cert] ? "true" : "false" if config.key?(:node_verify_api_cert) 91 | pub_config[:bootstrap_options][:bootstrap_version] = config[:bootstrap_version] if config[:bootstrap_version] 92 | pub_config[:bootstrap_options][:node_ssl_verify_mode] = config[:node_ssl_verify_mode] if config[:node_ssl_verify_mode] 93 | pub_config[:bootstrap_options][:bootstrap_proxy] = config[:bootstrap_proxy] if config[:bootstrap_proxy] 94 | pub_config 95 | end 96 | 97 | def load_correct_secret 98 | secret_file = config[:encrypted_data_bag_secret_file] 99 | secret = config[:encrypted_data_bag_secret] 100 | 101 | secret_file = Chef::EncryptedDataBagItem.load_secret(secret_file) unless secret_file.nil? 102 | 103 | secret_file || secret 104 | end 105 | 106 | def create_node_and_client_pem 107 | client_builder ||= begin 108 | require "chef/knife/bootstrap/client_builder" 109 | Chef::Knife::Bootstrap::ClientBuilder.new( 110 | chef_config: Chef::Config, 111 | config: config, 112 | ui: ui 113 | ) 114 | end 115 | client_builder.run 116 | client_builder.client_path 117 | end 118 | 119 | def get_chef_extension_private_params 120 | pri_config = {} 121 | # validator less bootstrap support for bootstrap protocol cloud-api 122 | if Chef::Config[:validation_key] && File.exist?(File.expand_path(Chef::Config[:validation_key])) 123 | pri_config[:validation_key] = File.read(File.expand_path(Chef::Config[:validation_key])) 124 | else 125 | if Chef::VERSION.split(".").first.to_i == 11 126 | ui.error("Unable to find validation key. Please verify your configuration file for validation_key config value.") 127 | exit 1 128 | end 129 | if config[:server_count].to_i > 1 130 | node_name = config[:chef_node_name] 131 | 0.upto(config[:server_count].to_i - 1) do |count| 132 | config[:chef_node_name] = node_name + count.to_s 133 | key_path = create_node_and_client_pem 134 | pri_config[("client_pem" + count.to_s).to_sym] = File.read(key_path) 135 | end 136 | config[:chef_node_name] = node_name 137 | else 138 | key_path = create_node_and_client_pem 139 | if File.exist?(key_path) 140 | pri_config[:client_pem] = File.read(key_path) 141 | else 142 | ui.error('Unable to find client.pem at given path #{key_path}') 143 | exit 1 144 | end 145 | end 146 | end 147 | 148 | # SSL cert bootstrap support 149 | if config[:cert_path] 150 | if File.exist?(File.expand_path(config[:cert_path])) 151 | pri_config[:chef_server_crt] = File.read(File.expand_path(config[:cert_path])) 152 | else 153 | ui.error("Specified SSL certificate does not exist.") 154 | exit 1 155 | end 156 | end 157 | 158 | # encrypted_data_bag_secret key for encrypting/decrypting the data bags 159 | pri_config[:encrypted_data_bag_secret] = load_correct_secret 160 | 161 | pri_config 162 | end 163 | 164 | end 165 | end 166 | end 167 | end 168 | -------------------------------------------------------------------------------- /lib/chef/knife/bootstrap/common_bootstrap_options.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Aliasgar Batterywala (aliasgar.batterywala@clogeny.com) 3 | # Copyright:: Copyright (c) Chef Software Inc. 4 | # License:: Apache License, Version 2.0 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | class Chef 20 | class Knife 21 | class Bootstrap 22 | module CommonBootstrapOptions 23 | 24 | def self.included(includer) 25 | includer.class_eval do 26 | 27 | deps do 28 | require "chef/knife/bootstrap" 29 | Chef::Knife::Bootstrap.load_deps 30 | end 31 | 32 | option :azure_availability_set, 33 | long: "--azure-availability-set NAME", 34 | description: "Optional. Name of availability set to add virtual machine into." 35 | 36 | option :azure_extension_client_config, 37 | long: "--azure-extension-client-config CLIENT_PATH", 38 | description: "Optional. Path to a client.rb file for use by the bootstrapped node." 39 | 40 | option :azure_os_disk_name, 41 | short: "-o DISKNAME", 42 | long: "--azure-os-disk-name DISKNAME", 43 | description: "Optional. Specifies the friendly name of the disk containing the guest OS image in the image repository." 44 | 45 | option :azure_service_location, 46 | short: "-m LOCATION", 47 | long: "--azure-service-location LOCATION", 48 | description: "Required if not using an Affinity Group. Specifies the geographic location - the name of the data center location that is valid for your subscription. 49 | Eg: West US, East US, East Asia, Southeast Asia, North Europe, West Europe" 50 | 51 | option :azure_storage_account, 52 | short: "-a NAME", 53 | long: "--azure-storage-account NAME", 54 | description: "Required for advanced server-create option. 55 | A name for the storage account that is unique within Windows Azure. Storage account names must be 56 | between 3 and 24 characters in length and use numbers and lower-case letters only. 57 | This name is the DNS prefix name and can be used to access blobs, queues, and tables in the storage account. 58 | For example: http://ServiceName.blob.core.windows.net/mycontainer/" 59 | 60 | option :azure_vm_name, 61 | long: "--azure-vm-name NAME", 62 | description: "Required. Specifies the name for the virtual machine. 63 | The name must be unique within the ResourceGroup. 64 | The azure vm name cannot be more than 15 characters long" 65 | 66 | option :azure_vm_size, 67 | short: "-z SIZE", 68 | long: "--azure-vm-size SIZE", 69 | description: "Optional. Size of virtual machine. Default is Standard_A1_v2. 70 | Eg: Standard_A1_v2, Standard_F2, Standard_G1 etc.", 71 | default: "Standard_A1_v2" 72 | 73 | deprecated_option :bootstrap_protocol, 74 | replacement: :connection_protocol, 75 | long: "--bootstrap-protocol PROTOCOL" 76 | 77 | option :cert_passphrase, 78 | long: "--cert-passphrase PASSWORD", 79 | description: "SSL Certificate Password" 80 | 81 | option :cert_path, 82 | long: "--cert-path PATH", 83 | description: "SSL Certificate Path" 84 | 85 | option :chef_daemon_interval, 86 | long: "--chef-daemon-interval INTERVAL", 87 | description: "Optional. Provide this option when --connection-protocol is set to 'cloud-api'. 88 | It specifies the frequency (in minutes) at which the chef-service runs. 89 | Pass 0 if you don't want the chef-service to be installed on the target machine." 90 | 91 | option :daemon, 92 | long: "--daemon DAEMON", 93 | description: "Optional. Configures the chef-client service for unattended execution. Requires --connection-protocol to be 'cloud-api' and the node platform to be Windows. 94 | Options: 'none' or 'service' or 'task'. 95 | none - Currently prevents the chef-client service from being configured as a service. 96 | service - Configures the chef-client to run automatically in the background as a service. 97 | task - Configures the chef-client to run automatically in the background as a scheduled task." 98 | 99 | option :extended_logs, 100 | long: "--extended-logs", 101 | boolean: true, 102 | default: false, 103 | description: "Optional. Provide this option when --connection-protocol is set to 'cloud-api'. It shows chef converge logs in detail." 104 | 105 | option :tcp_endpoints, 106 | short: "-t PORT_LIST", 107 | long: "--tcp-endpoints PORT_LIST", 108 | description: "Comma-separated list of TCP local and public ports to open e.g. '80:80,433:5000'" 109 | 110 | option :thumbprint, 111 | long: "--thumbprint THUMBPRINT", 112 | description: "The thumprint of the ssl certificate" 113 | end 114 | end 115 | end 116 | end 117 | end 118 | end 119 | -------------------------------------------------------------------------------- /lib/chef/knife/bootstrap_azurerm.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author:: Nimisha Sharad (nimisha.sharad@clogeny.com) 3 | # Copyright:: Copyright (c) Chef Software Inc. 4 | # License:: Apache License, Version 2.0 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | require_relative "helpers/azurerm_base" 20 | require "chef/knife/bootstrap" 21 | require_relative "bootstrap/common_bootstrap_options" 22 | require_relative "bootstrap/bootstrapper" 23 | 24 | class Chef 25 | class Knife 26 | class BootstrapAzurerm < Knife::Bootstrap 27 | include Knife::AzurermBase 28 | include Knife::Bootstrap::CommonBootstrapOptions 29 | include Knife::Bootstrap::Bootstrapper 30 | 31 | deps do 32 | require "time" unless defined?(Time) 33 | include Knife::AzurermBase 34 | end 35 | 36 | banner "knife bootstrap azurerm SERVER (options)" 37 | 38 | # run() would be executing from parent class 39 | # Chef::Knife::Bootstrap, defined in core. 40 | # Required methods have been overridden here 41 | #### run() execution begins #### 42 | 43 | def plugin_setup!; end 44 | 45 | def validate_name_args!; end 46 | 47 | def plugin_validate_options! 48 | ui.log("Validating...") 49 | validate_arm_keys!(:azure_resource_group_name, :azure_service_location) 50 | end 51 | 52 | def plugin_create_instance! 53 | if @name_args.length == 1 54 | ui.log("Creating VirtualMachineExtension....") 55 | ext_params = set_ext_params 56 | vm_extension = service.create_vm_extension(ext_params) 57 | if vm_extension 58 | if ext_params[:chef_extension_public_param][:extendedLogs] == "true" 59 | service.fetch_chef_client_logs(ext_params[:azure_resource_group_name], ext_params[:azure_vm_name], ext_params[:chef_extension], Time.now) 60 | end 61 | ui.log("VirtualMachineExtension creation successfull.") 62 | ui.log("Virtual Machine Extension name is: #{vm_extension.name}") 63 | ui.log("Virtual Machine Extension ID is: #{vm_extension.id}") 64 | end 65 | else 66 | raise ArgumentError, "Please specify the SERVER name which needs to be bootstrapped via the Chef Extension." if @name_args.empty? 67 | raise ArgumentError, "Please specify only one SERVER name which needs to be bootstrapped via the Chef Extension." if @name_args.length > 1 68 | end 69 | rescue StandardError => error 70 | service.common_arm_rescue_block(error) 71 | end 72 | 73 | def plugin_finalize; end 74 | 75 | # Following methods are not required 76 | # 77 | def connect!; end 78 | 79 | def register_client; end 80 | 81 | def render_template; end 82 | 83 | def upload_bootstrap(content); end 84 | 85 | def perform_bootstrap(bootstrap_path); end 86 | 87 | #### run() execution ends #### 88 | 89 | def set_ext_params 90 | server = service.find_server(config[:azure_resource_group_name], name_args[0]) 91 | 92 | if server 93 | if service.extension_already_installed?(server) 94 | raise "Virtual machine #{server.name} already has Chef extension installed on it." 95 | else 96 | ext_params = {} 97 | case server.storage_profile.os_disk.os_type.downcase 98 | when "windows" 99 | ext_params[:chef_extension] = "ChefClient" 100 | when "linux" 101 | if %w{ubuntu debian rhel centos}.any? { |platform| server.storage_profile.image_reference.offer.downcase.include? platform } 102 | ext_params[:chef_extension] = "LinuxChefClient" 103 | else 104 | raise "Offer #{server.storage_profile.image_reference.offer} is not supported in the extension." 105 | end 106 | else 107 | raise "OS type #{server.storage_profile.os_disk.os_type} is not supported." 108 | end 109 | 110 | ext_params[:azure_resource_group_name] = config[:azure_resource_group_name] 111 | ext_params[:azure_vm_name] = @name_args[0] 112 | ext_params[:azure_service_location] = config[:azure_service_location] 113 | ext_params[:chef_extension_publisher] = get_chef_extension_publisher 114 | ext_params[:chef_extension_version] = get_chef_extension_version(ext_params[:chef_extension]) 115 | ext_params[:chef_extension_public_param] = get_chef_extension_public_params 116 | ext_params[:chef_extension_private_param] = get_chef_extension_private_params 117 | end 118 | else 119 | raise "The given server '#{@name_args[0]}' does not exist under resource group '#{config[:azure_resource_group_name]}'" 120 | end 121 | 122 | ext_params 123 | end 124 | end 125 | end 126 | end 127 | -------------------------------------------------------------------------------- /lib/knife-azure/version.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | module Knife 19 | module Azure 20 | VERSION = "4.0.0".freeze 21 | MAJOR, MINOR, TINY = VERSION.split(".") 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /sonar-project.properties: -------------------------------------------------------------------------------- 1 | sonar.projectKey=chef_knife-azure_AYci4eVJJ4YHsO5MtJTC -------------------------------------------------------------------------------- /spec/functional/ag_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "../spec_helper" 19 | 20 | describe "ags" do 21 | before(:all) do 22 | @connection = Azure::Connection.new(TEST_PARAMS) 23 | end 24 | 25 | it "create" do 26 | rsp = @connection.ags.create(azure_ag_name: "func-test-new-ag", 27 | azure_location: "West US") 28 | rsp.at_css("Status").should_not be_nil 29 | rsp.at_css("Status").content.should eq("Succeeded") 30 | end 31 | 32 | specify { @connection.ags.exists?("notexist").should eq(false) } 33 | specify { @connection.ags.exists?("func-test-new-ag").should eq(true) } 34 | 35 | it "run through" do 36 | @connection.ags.all.each do |ag| 37 | ag.name.should_not be_nil 38 | ag.location.should_not be_nil 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /spec/functional/deploys_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "../spec_helper" 19 | 20 | describe "deploys" do 21 | before(:all) do 22 | @connection = Azure::Connection.new(TEST_PARAMS) 23 | @deploys = @connection.deploys.all 24 | end 25 | 26 | specify { @deploys.length.should be > 0 } 27 | it "each deployment should have values" do 28 | @deploys.each do |deploy| 29 | deploy.name.should_not be_nil 30 | deploy.status.should_not be_nil 31 | deploy.url.should_not be_nil 32 | deploy.roles.length.should be > 0 33 | end 34 | end 35 | it "each role should have values" do 36 | @deploys.each do |deploy| 37 | Chef::Log.info "=============================" 38 | Chef::Log.info "hosted service: " + deploy.hostedservicename + " deployment: " + deploy.name 39 | deploy.roles.each do |role| 40 | role.name.should_not be_nil 41 | role.status.should_not be_nil 42 | role.size.should_not be_nil 43 | role.ipaddress.should_not be_nil 44 | role.sshport.should_not be_nil 45 | Chef::Log.info "=============================" 46 | Chef::Log.info "role: " + role.name 47 | Chef::Log.info "status: " + role.status 48 | Chef::Log.info "size: " + role.size 49 | Chef::Log.info "ip address: " + role.ipaddress 50 | Chef::Log.info "ssh port: " + role.sshport 51 | end 52 | end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /spec/functional/host_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "../spec_helper" 19 | 20 | describe "Connection" do 21 | 22 | before(:all) do 23 | @connection = Azure::Connection.new(TEST_PARAMS) 24 | @items = @connection.hosts.all 25 | end 26 | 27 | specify { @items.length.should be > 0 } 28 | specify { @connection.hosts.exists?("thisServiceShouldNotBeThere").should == false } 29 | specify { @connection.hosts.exists?("service002").should == true } 30 | it "looking for a specific host" do 31 | foundNamedHost = false 32 | @items.each do |host| 33 | next unless host.name == "service002" 34 | 35 | foundNamedHost = true 36 | end 37 | foundNamedHost.should == true 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /spec/functional/images_list_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "../spec_helper" 19 | 20 | describe "Connection" do 21 | 22 | before(:all) do 23 | @connection = Azure::Connection.new(TEST_PARAMS) 24 | @items = @connection.images.all 25 | end 26 | 27 | it "should be contain images" do 28 | @items.length.should be > 1 29 | end 30 | it "each image should have all fields valid" do 31 | @items.each do |image| 32 | image.category.should_not be_nil 33 | image.label.should_not be_nil 34 | image.name.should_not be_nil 35 | image.os.should_not be_nil 36 | end 37 | end 38 | 39 | # it "should get services" do 40 | # @demo.DemoGet 41 | # end 42 | # it "bad subscription should fail with ResourceNotFound" do 43 | # @demo.subscription = "ae2ff9b3-12b2-45cf-b58e-468bc7e29110xxxxx" 44 | # 45 | # expect{@demo.DemoGet}.to raise_error(RuntimeError, /ResourceNotFound/) 46 | # end 47 | # it "bad pem_path should fail with CertificateError" do 48 | # @demo.pem_file = "" 49 | # 50 | # expect{@demo.DemoGet}.to raise_error(OpenSSL::X509::CertificateError) 51 | # end 52 | # it "bad service_name should fail with " do 53 | # @demo.service_name = "" 54 | # 55 | # expect{@demo.DemoGet}.to raise_error(RuntimeError, /ResourceNotFound/) 56 | # end 57 | end 58 | -------------------------------------------------------------------------------- /spec/functional/role_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "../spec_helper" 19 | 20 | describe "roles" do 21 | before(:all) do 22 | @connection = Azure::Connection.new(TEST_PARAMS) 23 | @roles = @connection.roles.all 24 | end 25 | 26 | specify { @connection.roles.exists?("notexist").should == false } 27 | specify { @connection.roles.exists?("role126").should == true } 28 | it "run through roles" do 29 | @connection.roles.roles.each do |role| 30 | role.name.should_not be_nil 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /spec/functional/vnet_test.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "../spec_helper" 19 | 20 | describe "vnets" do 21 | before(:all) do 22 | @connection = Azure::Connection.new(TEST_PARAMS) 23 | @connection.ags.create(azure_ag_name: "func-test-agforvnet", 24 | azure_location: "West US") 25 | end 26 | 27 | it "create" do 28 | rsp = @connection.vnets.create( 29 | azure_vnet_name: "func-test-new-vnet", 30 | azure_ag_name: "func-test-agforvnet", 31 | azure_address_space: "10.0.0.0/16" 32 | ) 33 | rsp.at_css("Status").should_not be_nil 34 | rsp.at_css("Status").content.should eq("Succeeded") 35 | end 36 | 37 | specify { @connection.vnets.exists?("notexist").should eq(false) } 38 | specify { @connection.vnets.exists?("func-test-new-vnet").should eq(true) } 39 | 40 | it "run through" do 41 | @connection.vnets.all.each do |vnet| 42 | vnet.name.should_not be_nil 43 | vnet.affinity_group.should_not be_nil 44 | vnet.state.should_not be_nil 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /spec/integration/config/azure_invalid.publishsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /spec/integration/config/environment.yml.sample: -------------------------------------------------------------------------------- 1 | # FIXME For now we will fetch the creds from a config file 2 | AZ_SSH_USER: AZ_SSH_USER 3 | AZURE_SUBSCRIPTION_ID: AZURE_SUBSCRIPTION_ID 4 | AZURE_API_HOST_NAME: AZURE_API_HOST_NAME 5 | AZ_WINDOWS_SSH_USER: AZ_WINDOWS_SSH_USER 6 | AZ_WINDOWS_SSH_PASSWORD: AZ_WINDOWS_SSH_PASSWORD 7 | AZ_WINRM_USER: AZ_WINRM_USER 8 | AZ_WINRM_PASSWORD: AZ_WINRM_PASSWORD 9 | AZ_LINUX_IMAGE: AZ_LINUX_IMAGE 10 | AZ_LINUX_VM_SIZE: AZ_LINUX_VM_SIZE 11 | AZ_INVALID_VM_SIZE: AZ_INVALID_VM_SIZE 12 | AZ_WINDOWS_VM_SIZE: AZ_WINDOWS_VM_SIZE 13 | AZ_WINDOWS_IMAGE: AZ_WINDOWS_IMAGE 14 | AZ_WINDOWS_SSH_IMAGE: AZ_WINDOWS_SSH_IMAGE 15 | AZ_AVAILABILITY_ZONE: AZ_AVAILABILITY_ZONE -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) 2 | 3 | require "chef/knife/azurerm_server_list" 4 | require "chef/knife/azurerm_server_show" 5 | require "chef/knife/azurerm_server_delete" 6 | require "chef/knife/azurerm_server_create" 7 | require "chef/knife/bootstrap_azurerm" 8 | 9 | if Chef::Platform.windows? 10 | require "azure/resource_management/windows_credentials" 11 | end 12 | 13 | require "fileutils" unless defined?(FileUtils) 14 | require "knife-azure/version" 15 | 16 | def temp_dir 17 | @_temp_dir ||= Dir.mktmpdir 18 | end 19 | 20 | def tmpFile(filename) 21 | temp_dir + "/" + filename 22 | end 23 | 24 | class UnexpectedSystemExit < RuntimeError 25 | def self.from(system_exit) 26 | new(system_exit.message).tap { |e| e.set_backtrace(system_exit.backtrace) } 27 | end 28 | end 29 | 30 | RSpec.configure do |c| 31 | c.before(:each) do 32 | Chef::Config.reset 33 | end 34 | 35 | c.before(:all) do 36 | # Create an empty mock certificate file 37 | @cert_file = tmpFile("AzureLinuxCert.pem") 38 | FileUtils.touch(@cert_file) 39 | Chef::Log.init(tmpFile("debug.log")) 40 | Chef::Log.level = :debug 41 | end 42 | 43 | c.after(:all) do 44 | # Cleanup files and dirs 45 | FileUtils.rm_rf("#{temp_dir}") 46 | end 47 | 48 | c.around(:example) do |ex| 49 | 50 | ex.run 51 | rescue SystemExit => e 52 | raise UnexpectedSystemExit.from(e) 53 | 54 | end 55 | end 56 | 57 | TEST_PARAMS = { 58 | azure_subscription_id: "YOUR_SUBSCRIPTION_ID_HERE", 59 | azure_mgmt_cert: @cert_file, 60 | azure_api_host_name: "management-preview.core.windows-int.net", 61 | }.freeze 62 | 63 | module AzureSpecHelper 64 | def readFile(filename) 65 | File.read(File.dirname(__FILE__) + "/unit/assets/#{filename}") 66 | end 67 | 68 | def get_publish_settings_file_path(filename) 69 | File.dirname(__FILE__) + "/unit/assets/publish-settings-files/#{filename}" 70 | end 71 | end 72 | 73 | def is_config_present 74 | unless ENV["RUN_INTEGRATION_TESTS"] 75 | puts("\nPlease set RUN_INTEGRATION_TESTS environment variable to run integration tests") 76 | return false 77 | end 78 | 79 | unset_env_var = [] 80 | unset_config_options = [] 81 | is_config = true 82 | config_file_exist = File.exist?(File.expand_path("integration/config/environment.yml", __dir__)) 83 | azure_config = YAML.load(File.read(File.expand_path("integration/config/environment.yml", __dir__))) if config_file_exist 84 | 85 | %w{AZURE_PUBLISH_SETTINGS_FILE AZURE_MGMT_CERT AZURE_SUBSCRIPTION_ID AZURE_API_HOST_NAME}.each do |az_env_var| 86 | if ENV[az_env_var].nil? 87 | unset_env_var << az_env_var 88 | is_config = false 89 | end 90 | end 91 | 92 | err_msg = "\nPlease set #{unset_env_var.join(", ")} environment" 93 | err_msg = err_msg + ( unset_env_var.length > 1 ? " variables " : " variable " ) + "for integration tests." 94 | puts err_msg unless unset_env_var.empty? 95 | 96 | %w{AZ_SSH_USER AZ_SSH_PASSWORD AZ_WINDOWS_SSH_USER AZ_WINDOWS_SSH_PASSWORD AZ_WINRM_USER AZ_WINRM_PASSWORD AZ_LINUX_IMAGE AZ_LINUX_VM_SIZE AZ_INVALID_VM_SIZE AZ_WINDOWS_VM_SIZE AZ_WINDOWS_IMAGE AZ_WINDOWS_SSH_IMAGE AZURE_SERVICE_LOCATION}.each do |os_config_opt| 97 | option_value = ENV[os_config_opt] || (azure_config[os_config_opt] if azure_config) 98 | if option_value.nil? 99 | unset_config_options << os_config_opt 100 | is_config = false 101 | end 102 | end 103 | 104 | config_err_msg = "\nPlease set #{unset_config_options.join(", ")} config" 105 | config_err_msg = config_err_msg + ( unset_config_options.length > 1 ? " options in ../spec/integration/config/environment.yml or as environment variables" : " option in ../spec/integration/config/environment.yml or as environment variable" ) + " for integration tests." 106 | puts config_err_msg unless unset_config_options.empty? 107 | 108 | is_config 109 | end 110 | 111 | def get_gem_file_name 112 | "knife-azure-" + Knife::Azure::VERSION + ".gem" 113 | end 114 | 115 | def find_instance_id(instance_name, file) 116 | file.lines.each do |line| 117 | if line.include?("#{instance_name}") 118 | return "#{line}".split(" ")[2].strip 119 | end 120 | end 121 | end 122 | 123 | def delete_instance_cmd(vm_name) 124 | "knife azure server delete #{vm_name} --yes" 125 | end 126 | 127 | def create_node_name(name) 128 | @name_node = (name == "linux") ? "az-lnxtest#{SecureRandom.hex(4)}" : "az-wintest-#{SecureRandom.hex(4)}" 129 | end 130 | 131 | def init_azure_test 132 | init_test 133 | 134 | begin 135 | %w{azure_invalid.publishsettings}.each do |file_name| 136 | data_to_write = File.read(File.expand_path("../integration/config/#{file_name}", __FILE__)) 137 | File.open("#{temp_dir}/#{file_name}", "w") { |f| f.write(data_to_write) } 138 | end 139 | rescue 140 | puts "Error while creating file - azure invalid" 141 | end 142 | 143 | config_file_exist = File.exist?(File.expand_path("integration/config/environment.yml", __dir__)) 144 | azure_config = YAML.load(File.read(File.expand_path("integration/config/environment.yml", __dir__))) if config_file_exist 145 | 146 | %w{AZ_SSH_USER AZ_SSH_PASSWORD AZ_WINDOWS_SSH_USER AZ_WINDOWS_SSH_PASSWORD AZ_WINRM_USER AZ_WINRM_PASSWORD AZ_LINUX_IMAGE AZ_LINUX_VM_SIZE AZ_INVALID_VM_SIZE AZ_WINDOWS_VM_SIZE AZ_WINDOWS_IMAGE AZ_WINDOWS_SSH_IMAGE AZURE_SERVICE_LOCATION}.each do |az_config_opt| 147 | instance_variable_set("@#{az_config_opt.downcase}", (azure_config[az_config_opt] if azure_config) || ENV[az_config_opt]) 148 | end 149 | end 150 | 151 | def is_windows? 152 | (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil 153 | end 154 | 155 | RSpec.configure do |config| 156 | config.filter_run_excluding windows_only: true unless is_windows? 157 | end 158 | -------------------------------------------------------------------------------- /spec/unit/assets/accessTokens.json: -------------------------------------------------------------------------------- 1 | [{"tokenType":"Bearer","expiresIn":3599,"expiresOn":"2016-05-31T09:42:15.617Z","resource":"https://management.core.windows.net/","accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1iIxLjAifQ.hZjHXXjbSdMmMs9oSZxGKa62EnNG6jkTY4RSmq8dQMvmwHgDCF4KoT_sOIsrAJTVwXuCdxYa5Jr83sfydFwiO2QWWOaSgyRXGPouex4NXFI_LFdnRzhLBoN0ONwUWHrV12N4LBgHyNLiyfeZQJFCbD0LTcPdjh7qQZ5aVgcoz_CB33PGD_z2L_6ynWrlAoihLEmYD6vbebMDSSFazvzoVg","refreshToken":"FPbm0gXiszvV_cMwGkgACwMBZ26fWA6fH3ToRLTHYU3wvvTWiU74ukRhMHhv20OJOtZBOtbckh3kTMT7QvzUYfd4uHFzwAYCtsh2SOY-dCAA","userId":"xxx@outlook.com","identityProvider":"live.com","isMRRT":true,"_clientId":"dsff-8df-sd45e-34345f7b46","_authority":"https://login.microsoftonline.com/common"},{"tokenType":"Bearer","expiresIn":3600,"expiresOn":"2016-05-31T09:42:17.874Z","resource":"https://management.core.windows.net/","accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1iIxLjAifQ.hZjHXXjbSdMmMs9oSZxGKa62EnNG6jkTY4RSmq8dQMvmwHgDCF4KoT_sOIsrAJTVwXuCdxYa5Jr83sfydFwiO2QWWOaSgyRXGPouex4NXFI_LFdnRzhLBoN0ONwUWHrV12N4LBgHyNLiyfeZQJFCbD0LTcPdjh7qQZ5aVgcoz_CB33PGD_z2L_6ynWrlAoihLEmYD6vbebMDSSFazvzoVg","refreshToken":"FPbm0gXiszvV_cMwGkgACwMBZ26fWA6fH3ToRLTHYU3wvvTWiU74ukRhMHhv20OJOtZBOtbckh3kTMT7QvzUYfd4uHFzwAYCtsh2SOY-dCAA","userId":"xxx@outlook.com","identityProvider":"live.com","isMRRT":true,"_clientId":"dsff-8df-sd45e-34345f7b46","_authority":"https://login.microsoftonline.com/233xx-ewe3-fd33e-ds8f-0gfg432"}] 2 | -------------------------------------------------------------------------------- /spec/unit/assets/azure-profile-files/A_Bd_account_azure_profile.json: -------------------------------------------------------------------------------- 1 | { 2 | "environments": [], 3 | "subscriptions": [ 4 | { 5 | "id": "A_subscription_id", 6 | "name": "A_subscription_name", 7 | "managementCertificate": { 8 | "key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAsDwzIKrmhn5Ip8FlSWYh1SyXEWjF6bdqJyMTxRLoEJ9fxgXG\r\nWpUySs0ASKSZRvYJlo3cfVaYmDEAQhuvhvnuJxOOL+8fboZ/Tx+OBc7VkLsW2Y4d\r\nqyNYF5rEVrIIGdArTBTuUB/ZjCMCTu+YNhGpEqmA69bLWt8TjkjJa2BnjI0M8xmU\r\nrfeet3wiXp1fQCzLeB1cGfmWkkp+bWkX77sHUUIRfv0RMkoDKiI5m5mkirZf1xmW\r\n5g19RYVY2PJ0dYs3dPJEgbVGep3NFVCw9Xd6lPVtjJXbrTOOZgXHDy4ys/uiTrI7\r\nQlS57WkNatSfnxuPtf0VmSgNKKgFrkceoIpeXQIDAQABAoIBABKyKDhgePkun3WQ\r\nejbJq3AqfVI++7P6HbxOJ9RB17WfurDOvwawCjhOPCf4sjwJcOX0Yb44OBL5K85X\r\nkozuqbmihPSH2R1IDmxt7AqosRZcCqYEwhf8NWW3qPmLhHl8kINPOyLr5g/MTPvj\r\nxhGCWR3eNouOa19WCASRqzCFdya9SN+TabbR5o7Zs5Pk0zLv2WBJ0yfduk3K4n2t\r\n50SNxM2NChcsMjhAVc0SVSOgHENPn0rhhyuqlzbishBQcPcQqPtGZmjxX3OmOOwr\r\n+MLw9Dr9xQfoT/ahR/TsGr4tWPUNByEh812Aa4In0paYWVvJp3BzM0ABLNYGSYTi\r\nBsg6jl8CgYEA1bG3vByen0qpgFb80Xsq2p4qT5U7vRDBqDX6oziGXMy7OXpzjSFw\r\nG5kxIu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GA1UEAxMTV2luZG93cyBBenVyZSBUb29sczCC\r\nASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALA8MyCq5oZ+SKfBZUlmIdUs\r\nlxFoxem3aicjE8US6BCfX8YFxlqVMkrNAEikmUb2CZaN3H1WmJgxAEIbr4b57icT\r\nji/vH26Gf08fjgXO1ZC7FtmOHasjWBeaxFayCBnQK0wU7lAf2YwjAk7vmDYRqRKp\r\ngOvWy1rfE45IyWtgZ4yNDPMZlK33nrd8Il6dX0Asy3gdXBn5lpJKfm1pF++7B1FC\r\nEX79ETJKAyoiOZuZpIq2X9cZluYNfUWFWNjydHWLN3TyRIG1RnqdzRVQsPV3epT1\r\nbYyV260zjmYFxw8uMrP7ok6yO0JUue1pDWrUn58bj7X9FZkoDSioBa5HHqCKXl0C\r\nAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAOI7zWit8fWx/0VCKm4IhpXoTgUSaiSZe\r\nOqC9zvNdVnYc5HejGGPwMirUlIWN8DgY33gW32DV7oIMVKQZ6YIzv9XEBSsmPUum\r\no6ykAkWRig/hHiJOmjbUG8wwwS+3yjyF8C8VSmdZek4lIIdVY9HvSJyrfAGrE99U\r\nOpnOYLotN8mDRTdNBgvs0kie5S7nIaOnpQYFLLAPmDaCCsndzIu6kxIxKac+cSQ0\r\noyqN60erKRvCHiz2OGOJ73FQX8e4yR5HXMxDwqte3BzY/Hr8IHx31Q84De+OUnVe\r\nI0XWVEP+J/OLXbx8mT09klcPP7lq74OK66tm2LJQhJzrBEpZm8COxQ==\n-----END CERTIFICATE-----\n" 10 | }, 11 | "isDefault": false, 12 | "registeredProviders": [], 13 | "environmentName": "A_env_name", 14 | "managementEndpointUrl": "https://A.endpoint.net" 15 | }, 16 | { 17 | "id": "B_subscription_id", 18 | "name": "B_subscription_name", 19 | "managementCertificate": { 20 | "key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAsDwzIKrmhn5Ip8FlSWYh1SyXEWjF6bdqJyMT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1FC\r\nEX79ETJKAyoiOZuZpIq2X9cZluYNfUWFWNjydHWLN3TyRIG1RnqdzRVQsPV3epT1\r\nbYyV260zjmYFxw8uMrP7ok6yO0JUue1pDWrUn58bj7X9FZkoDSioBa5HHqCKXl0C\r\nAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAOI7zWit8fWx/0VCKm4IhpXoTgUSaiSZe\r\nOqC9zvNdVnYc5HejGGPwMirUlIWN8DgY33gW32DV7oIMVKQZ6YIzv9XEBSsmPUum\r\no6ykAkWRig/hHiJOmjbUG8wwwS+3yjyF8C8VSmdZek4lIIdVY9HvSJyrfAGrE99U\r\nOpnOYLotN8mDRTdNBgvs0kie5S7nIaOnpQYFLLAPmDaCCsndzIu6kxIxKac+cSQ0\r\noyqN60erKRvCHiz2OGOJ73FQX8e4yR5HXMxDwqte3BzY/Hr8IHx31Q84De+OUnVe\r\nI0XWVEP+J/OLXbx8mT09klcPP7lq74OK66tm2LJQhJzrBEpZm8COxQ==\n-----END CERTIFICATE-----\n" 22 | }, 23 | "isDefault": true, 24 | "registeredProviders": [], 25 | "environmentName": "B_env_name", 26 | "managementEndpointUrl": "https://B.endpoint.net/" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /spec/unit/assets/azure-profile-files/A_account_azure_profile.json: -------------------------------------------------------------------------------- 1 | { 2 | "environments": [], 3 | "subscriptions": [ 4 | { 5 | "id": "A_subscription_id", 6 | "name": "A_subscription_name", 7 | "managementCertificate": { 8 | "key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAsDwzIKrmhn5Ip8FlSWYh1SyXEWjF6bdqJyMTxRLoEJ9fxgXG\r\nWpUySs0ASKSZRvYJlo3cfVaYmDEAQhuvhvnuJxOOL+8fboZ/Tx+OBc7VkLsW2Y4d\r\nqyNYF5rEVrIIGdArTBTuUB/ZjCMCTu+YNhGpEqmA69bLWt8TjkjJa2BnjI0M8xmU\r\nrfeet3wiXp1fQCzLeB1cGfmWkkp+bWkX77s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TgUSaiSZe\r\nOqC9zvNdVnYc5HejGGPwMirUlIWN8DgY33gW32DV7oIMVKQZ6YIzv9XEBSsmPUum\r\no6ykAkWRig/hHiJOmjbUG8wwwS+3yjyF8C8VSmdZek4lIIdVY9HvSJyrfAGrE99U\r\nOpnOYLotN8mDRTdNBgvs0kie5S7nIaOnpQYFLLAPmDaCCsndzIu6kxIxKac+cSQ0\r\noyqN60erKRvCHiz2OGOJ73FQX8e4yR5HXMxDwqte3BzY/Hr8IHx31Q84De+OUnVe\r\nI0XWVEP+J/OLXbx8mT09klcPP7lq74OK66tm2LJQhJzrBEpZm8COxQ==\n-----END CERTIFICATE-----\n" 10 | }, 11 | "isDefault": true, 12 | "registeredProviders": [], 13 | "environmentName": "A_env_name", 14 | "managementEndpointUrl": "https://A.endpoint.net" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /spec/unit/assets/azure-profile-files/Ad_B_account_azure_profile.json: -------------------------------------------------------------------------------- 1 | { 2 | "environments": [], 3 | "subscriptions": [ 4 | { 5 | "id": "A_subscription_id", 6 | "name": "A_subscription_name", 7 | "managementCertificate": { 8 | "key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAsDwzIKrmhn5Ip8FlSWYh1SyXEWjF6bdqJyMTxRLoEJ9fxgXG\r\nWpUySs0ASKSZRvYJlo3cfVaYmDEAQhuvhvnuJxOOL+8fboZ/Tx+OBc7VkLsW2Y4d\r\nqyNYF5rEVrIIGdArTBTuUB/ZjCMCTu+YNhGpEqmA69bLWt8TjkjJa2BnjI0M8xmU\r\nrfeet3wiXp1fQCzLeB1cGfmWkkp+bWkX77sHUUIRfv0RMkoDKiI5m5mkirZf1xmW\r\n5g19RYVY2PJ0dYs3dPJEgbVGep3NFVCw9Xd6lPVtjJXbrTOOZgXHDy4ys/uiTrI7\r\nQlS57WkNatSfnxuPtf0VmSgNKKgFrkceoIpeXQIDAQABAoIBABKyKDhgePkun3WQ\r\nejbJq3AqfVI++7P6HbxOJ9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CsndzIu6kxIxKac+cSQ0\r\noyqN60erKRvCHiz2OGOJ73FQX8e4yR5HXMxDwqte3BzY/Hr8IHx31Q84De+OUnVe\r\nI0XWVEP+J/OLXbx8mT09klcPP7lq74OK66tm2LJQhJzrBEpZm8COxQ==\n-----END CERTIFICATE-----\n" 10 | }, 11 | "isDefault": true, 12 | "registeredProviders": [], 13 | "environmentName": "A_env_name", 14 | "managementEndpointUrl": "https://A.endpoint.net" 15 | }, 16 | { 17 | "id": "B_subscription_id", 18 | "name": "B_subscription_name", 19 | "managementCertificate": { 20 | "key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAsDwzIKrmhn5Ip8FlSWYh1SyXEWjF6bdqJyMTxRLoEJ9fxgXG\r\nWpUySs0ASKSZRvYJlo3cfVaYmDEAQhuvhvnuJxOOL+8fboZ/Tx+OBc7VkLsW2Y4d\r\nqyNYF5rEVrIIGdArTBTuUB/ZjCMCTu+YNhGpEqmA69bLWt8TjkjJa2BnjI0M8xmU\r\nrfeet3wiXp1fQCzLeB1cGfmWkkp+bWkX77sHUUIRfv0RMkoDKiI5m5mkirZf1xmW\r\n5g19RYVY2PJ0dYs3dPJEgbVGep3NFVCw9Xd6lPVtjJXbrTOOZgXHDy4ys/uiTrI7\r\nQlS57WkNatSfnxuPtf0VmSgNKKgFrkceoIpeXQIDAQABAoIBABKyKDhgePkun3WQ\r\nejbJq3AqfVI++7P6HbxOJ9RB17WfurDOvwawCjhOPCf4sjwJcOX0Yb44OBL5K85X\r\nkozuqbmihPSH2R1IDmxt7AqosRZcCqYEwhf8NWW3qPmLhHl8kINPOyLr5g/MTPvj\r\nxhGCWR3eNouOa19WCASRqzCFdya9SN+TabbR5o7Zs5Pk0zLv2WBJ0yfduk3K4n2t\r\n50SNxM2NChcsMjhAVc0SVSOgHENPn0rhhyuqlzbishBQcPcQqPtGZmjxX3OmOOwr\r\n+MLw9Dr9xQfoT/ahR/TsGr4tWPUNByEh812Aa4In0paYWVvJp3BzM0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DVQQDExNXaW5kb3dzIEF6dXJlIFRvb2xzMB4XDTEzMDUxNDA4NDM0NloX\r\nDTE0MDUxNDA4NDM0NlowHjEcMBoGA1UEAxMTV2luZG93cyBBenVyZSBUb29sczCC\r\nASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALA8MyCq5oZ+SKfBZUlmIdUs\r\nlxFoxem3aicjE8US6BCfX8YFxlqVMkrNAEikmUb2CZaN3H1WmJgxAEIbr4b57icT\r\nji/vH26Gf08fjgXO1ZC7FtmOHasjWBeaxFayCBnQK0wU7lAf2YwjAk7vmDYRqRKp\r\ngOvWy1rfE45IyWtgZ4yNDPMZlK33nrd8Il6dX0Asy3gdXBn5lpJKfm1pF++7B1FC\r\nEX79ETJKAyoiOZuZpIq2X9cZluYNfUWFWNjydHWLN3TyRIG1RnqdzRVQsPV3epT1\r\nbYyV260zjmYFxw8uMrP7ok6yO0JUue1pDWrUn58bj7X9FZkoDSioBa5HHqCKXl0C\r\nAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAOI7zWit8fWx/0VCKm4IhpXoTgUSaiSZe\r\nOqC9zvNdVnYc5HejGGPwMirUlIWN8DgY33gW32DV7oIMVKQZ6YIzv9XEBSsmPUum\r\no6ykAkWRig/hHiJOmjbUG8wwwS+3yjyF8C8VSmdZek4lIIdVY9HvSJyrfAGrE99U\r\nOpnOYLotN8mDRTdNBgvs0kie5S7nIaOnpQYFLLAPmDaCCsndzIu6kxIxKac+cSQ0\r\noyqN60erKRvCHiz2OGOJ73FQX8e4yR5HXMxDwqte3BzY/Hr8IHx31Q84De+OUnVe\r\nI0XWVEP+J/OLXbx8mT09klcPP7lq74OK66tm2LJQhJzrBEpZm8COxQ==\n-----END CERTIFICATE-----\n" 22 | }, 23 | "isDefault": false, 24 | "registeredProviders": [], 25 | "environmentName": "B_env_name", 26 | "managementEndpointUrl": "https://B.endpoint.net/" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /spec/unit/assets/azure-profile-files/B_account_azure_profile.json: -------------------------------------------------------------------------------- 1 | { 2 | "environments": [], 3 | "subscriptions": [ 4 | { 5 | "id": "B_subscription_id", 6 | "name": "B_subscription_name", 7 | "managementCertificate": { 8 | "key": "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAsDwzIKrmhn5Ip8FlSWYh1SyXEWjF6bdqJyMTxRLoEJ9fxgXG\r\nWpUySs0ASKSZRvYJlo3cfVaYmDEAQhuvhvnuJxOOL+8fboZ/Tx+OBc7VkLsW2Y4d\r\nqyNYF5rEVrIIGdArTBTuUB/ZjCMCTu+YNhGpEqmA69bLWt8TjkjJa2BnjI0M8xmU\r\nrfeet3wiXp1fQCzLeB1cGfmWkkp+bWkX77sHUUIRfv0RMkoDKiI5m5mkirZf1xmW\r\n5g19RYVY2PJ0dYs3dPJEgbVGep3NFVCw9Xd6lPVtjJXbrTOOZgXHDy4ys/uiTrI7\r\nQlS57WkNatSfnxuPtf0VmSgNKKgFrkceoIpeXQIDAQABAoIBABKyKDhgePkun3WQ\r\nejbJq3AqfVI++7P6HbxOJ9RB17WfurDOvwawCjhOPCf4sjwJcOX0Yb44OBL5K85X\r\nkozuqbmihPSH2R1IDmxt7AqosRZcCqYEwhf8NWW3qPmLhHl8kINPOyLr5g/MTPvj\r\nxhGCWR3eNouOa19WCASRqzCFdya9SN+TabbR5o7Zs5Pk0zLv2WBJ0yfduk3K4n2t\r\n50SNxM2NChcsMjhAVc0SVSOgHENPn0rhhyuqlzbishBQcPcQqPtGZmjxX3OmOOwr\r\n+MLw9Dr9xQfoT/ahR/TsGr4tWPUNByEh812Aa4In0paYWVvJp3BzM0ABLNYGSYTi\r\nBsg6jl8CgYEA1bG3vByen0qpgFb80Xsq2p4qT5U7vRDBqDX6oziGXMy7OXpzjSFw\r\nG5kxIuIxZL1o/T4L10ODsYFMG42YHGlCNT8la/0WPiNLQiq7wq24ASpHh/dNnozz\r\nTIb/v4dhemKDJW+TEehGpTm9eoD4bQkZm73rixpICEPOpO2YC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Foxem3aicjE8US6BCfX8YFxlqVMkrNAEikmUb2CZaN3H1WmJgxAEIbr4b57icT\r\nji/vH26Gf08fjgXO1ZC7FtmOHasjWBeaxFayCBnQK0wU7lAf2YwjAk7vmDYRqRKp\r\ngOvWy1rfE45IyWtgZ4yNDPMZlK33nrd8Il6dX0Asy3gdXBn5lpJKfm1pF++7B1FC\r\nEX79ETJKAyoiOZuZpIq2X9cZluYNfUWFWNjydHWLN3TyRIG1RnqdzRVQsPV3epT1\r\nbYyV260zjmYFxw8uMrP7ok6yO0JUue1pDWrUn58bj7X9FZkoDSioBa5HHqCKXl0C\r\nAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAOI7zWit8fWx/0VCKm4IhpXoTgUSaiSZe\r\nOqC9zvNdVnYc5HejGGPwMirUlIWN8DgY33gW32DV7oIMVKQZ6YIzv9XEBSsmPUum\r\no6ykAkWRig/hHiJOmjbUG8wwwS+3yjyF8C8VSmdZek4lIIdVY9HvSJyrfAGrE99U\r\nOpnOYLotN8mDRTdNBgvs0kie5S7nIaOnpQYFLLAPmDaCCsndzIu6kxIxKac+cSQ0\r\noyqN60erKRvCHiz2OGOJ73FQX8e4yR5HXMxDwqte3BzY/Hr8IHx31Q84De+OUnVe\r\nI0XWVEP+J/OLXbx8mT09klcPP7lq74OK66tm2LJQhJzrBEpZm8COxQ==\n-----END CERTIFICATE-----\n" 10 | }, 11 | "isDefault": true, 12 | "registeredProviders": [], 13 | "environmentName": "B_env_name", 14 | "managementEndpointUrl": "https://B.endpoint.net/" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/extensions_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Chef.Bootstrap.WindowsAzure 4 | LinuxChefClient 5 | 11.18.6.2 6 | 7 | Chef Extension that sets up chef-client on VM 8 | true 9 | http://www.getchef.com/about/ 10 | http://www.getchef.com/about/ 11 | http://www.getchef.com/ 12 | true 13 | 14 | 15 | Chef.Bootstrap.WindowsAzure 16 | LinuxChefClient 17 | 1207.12.3.0 18 | 19 | Chef Extension that sets up chef-client on VM 20 | true 21 | http://www.getchef.com/about/ 22 | http://www.getchef.com/about/ 23 | http://www.getchef.com/ 24 | true 25 | 26 | 27 | Chef.Bootstrap.WindowsAzure 28 | LinuxChefClient 29 | 1210.12.101.1001 30 | 31 | Chef Extension that sets up chef-client on VM 32 | true 33 | http://www.chef.io/about/ 34 | http://www.chef.io/about/ 35 | http://www.chef.io/ 36 | true 37 | 38 | 39 | Chef.Bootstrap.WindowsAzure 40 | LinuxChefClient 41 | 1210.12.102.1000 42 | 43 | Chef Extension that sets up chef-client on VM 44 | true 45 | http://www.chef.io/about/ 46 | http://www.chef.io/about/ 47 | http://www.chef.io/ 48 | true 49 | 50 | 51 | Chef.Bootstrap.WindowsAzure 52 | LinuxChefClient 53 | 1210.12.103.1000 54 | 55 | Chef Extension that sets up chef-client on VM 56 | true 57 | http://www.chef.io/about/ 58 | http://www.chef.io/about/ 59 | http://www.chef.io/ 60 | true 61 | 62 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/parse_role_list_xml/role_list_1.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-cnt 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 22 11 | SSH 12 | 22 13 | tcp 14 | 11.12.13.14 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ReadWrite 25 | test-vm-cnt-0-201304290754500763 26 | https://portalvhdsfgcxv403pxfdgbjwb.blob.core.windows.net/vhds/test-dns-test-vm-cnt-2012-01-11.vhd 27 | 842c8b9c6cvxzcvxzcv048xvbvge2323qe4c3__OpenLogic-CentOS-67-20140205 28 | Linux 29 | 30 | Small 31 | true 32 | 33 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/parse_role_list_xml/role_list_2.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-win 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 3389 11 | RDP 12 | 57666 13 | tcp 14 | 14.13.12.11 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ReadWrite 25 | test-vm-cnt-test-vm-win-0-201105240534190032 26 | https://portalvhdsdfsdjf5djfb3iwb.blob.core.windows.net/vhds/test-dns-test-vm-win-2015-01-30.vhd 27 | a6dfsdfwerfdfc0bc8f24rwefsd4ds01__Windows-Server-2012-R2-20141128-en.us-127GB.vhd 28 | Windows 29 | 30 | Small 31 | true 32 | 33 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/setup_extension/update_role.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NetworkConfiguration 6 | 7 | 8 | 22 9 | SSH 10 | 22 11 | tcp 12 | 11.12.13.14 13 | false 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | LinuxChefClient 22 | Chef.Bootstrap.WindowsAzure 23 | LinuxChefClient 24 | 1210.12 25 | 26 | 27 | PublicParams 28 | MyPublicParamsValue 29 | Public 30 | 31 | 32 | PrivateParams 33 | MyPrivateParamsValue 34 | Private 35 | 36 | 37 | Enable 38 | 39 | 40 | 41 | 42 | ReadWrite 43 | test-vm-cnt-0-201304290754500763 44 | https://portalvhdsfgcxv403pxfdgbjwb.blob.core.windows.net/vhds/test-dns-test-vm-cnt-2012-01-11.vhd 45 | 842c8b9c6cvxzcvxzcv048xvbvge2323qe4c3__OpenLogic-CentOS-67-20140205 46 | Linux 47 | 48 | Small 49 | true 50 | 51 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/setup_extension/updated_role.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-cnt 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 22 11 | SSH 12 | 22 13 | tcp 14 | 11.12.13.14 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | LinuxChefClient 24 | Chef.Bootstrap.WindowsAzure 25 | LinuxChefClient 26 | 1210.12 27 | 28 | 29 | PublicParams 30 | MyPublicParamsValue 31 | Public 32 | 33 | 34 | PrivateParams 35 | MyPrivateParamsValue 36 | Private 37 | 38 | 39 | Enable 40 | 41 | 42 | 43 | 44 | ReadWrite 45 | test-vm-cnt-0-201304290754500763 46 | https://portalvhdsfgcxv403pxfdgbjwb.blob.core.windows.net/vhds/test-dns-test-vm-cnt-2012-01-11.vhd 47 | 842c8b9c6cvxzcvxzcv048xvbvge2323qe4c3__OpenLogic-CentOS-67-20140205 48 | Linux 49 | 50 | Small 51 | true 52 | 53 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/update_role_xml_for_extension/input_role_1.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-cnt 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 22 11 | SSH 12 | 22 13 | tcp 14 | 11.12.13.14 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | ReadWrite 24 | test-vm-cnt-0-201304290754500763 25 | https://portalvhdsfgcxv403pxfdgbjwb.blob.core.windows.net/vhds/test-dns-test-vm-cnt-2012-01-11.vhd 26 | 842c8b9c6cvxzcvxzcv048xvbvge2323qe4c3__OpenLogic-CentOS-67-20140205 27 | Linux 28 | 29 | Small 30 | true 31 | 32 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/update_role_xml_for_extension/input_role_2.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-win 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 3389 11 | RDP 12 | 57666 13 | tcp 14 | 14.13.12.11 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | ReadWrite 25 | test-vm-cnt-test-vm-win-0-201105240534190032 26 | https://portalvhdsdfsdjf5djfb3iwb.blob.core.windows.net/vhds/test-dns-test-vm-win-2015-01-30.vhd 27 | a6dfsdfwerfdfc0bc8f24rwefsd4ds01__Windows-Server-2012-R2-20141128-en.us-127GB.vhd 28 | Windows 29 | 30 | Small 31 | true 32 | 33 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/update_role_xml_for_extension/input_role_3.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-win 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 3389 11 | RDP 12 | 57666 13 | tcp 14 | 14.13.12.11 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | BGInfo 24 | Microsoft.Compute 25 | BGInfo 26 | 1.* 27 | Enable 28 | 29 | 30 | 31 | 32 | ReadWrite 33 | test-vm-cnt-test-vm-win-0-201105240534190032 34 | https://portalvhdsdfsdjf5djfb3iwb.blob.core.windows.net/vhds/test-dns-test-vm-win-2015-01-30.vhd 35 | a6dfsdfwerfdfc0bc8f24rwefsd4ds01__Windows-Server-2012-R2-20141128-en.us-127GB.vhd 36 | Windows 37 | 38 | Small 39 | true 40 | 41 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/update_role_xml_for_extension/input_role_4.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-cnt 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 22 11 | SSH 12 | 22 13 | tcp 14 | 11.12.13.14 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | LinuxChefClient 24 | Chef.Bootstrap.WindowsAzure 25 | LinuxChefClient 26 | 1210.12 27 | 28 | 29 | PublicParams 30 | MyPublicParamsValue 31 | Public 32 | 33 | 34 | PrivateParams 35 | MyPrivateParamsValue 36 | Private 37 | 38 | 39 | Enable 40 | 41 | 42 | 43 | 44 | ReadWrite 45 | test-vm-cnt-0-201304290754500763 46 | https://portalvhdsfgcxv403pxfdgbjwb.blob.core.windows.net/vhds/test-dns-test-vm-cnt-2012-01-11.vhd 47 | 842c8b9c6cvxzcvxzcv048xvbvge2323qe4c3__OpenLogic-CentOS-67-20140205 48 | Linux 49 | 50 | Small 51 | true 52 | 53 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/update_role_xml_for_extension/output_role_1.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-cnt 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 22 11 | SSH 12 | 22 13 | tcp 14 | 11.12.13.14 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | ReadWrite 24 | test-vm-cnt-0-201304290754500763 25 | https://portalvhdsfgcxv403pxfdgbjwb.blob.core.windows.net/vhds/test-dns-test-vm-cnt-2012-01-11.vhd 26 | 842c8b9c6cvxzcvxzcv048xvbvge2323qe4c3__OpenLogic-CentOS-67-20140205 27 | Linux 28 | 29 | Small 30 | true 31 | LinuxChefClientChef.Bootstrap.WindowsAzureLinuxChefClient1210.12PublicParamsIk15UHVibGljUGFyYW1zVmFsdWUi 32 | PublicPrivateParamsIk15UHJpdmF0ZVBhcmFtc1ZhbHVlIg== 33 | Privateenable 34 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/update_role_xml_for_extension/output_role_2.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-win 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 3389 11 | RDP 12 | 57666 13 | tcp 14 | 14.13.12.11 15 | false 16 | 17 | 18 | 19 | 20 | 21 | ChefClientChef.Bootstrap.WindowsAzureChefClient1210.12PublicParamsIk15UHVibGljUGFyYW1zVmFsdWUi 22 | PublicPrivateParamsIk15UHJpdmF0ZVBhcmFtc1ZhbHVlIg== 23 | Privateenable 24 | 25 | 26 | ReadWrite 27 | test-vm-cnt-test-vm-win-0-201105240534190032 28 | https://portalvhdsdfsdjf5djfb3iwb.blob.core.windows.net/vhds/test-dns-test-vm-win-2015-01-30.vhd 29 | a6dfsdfwerfdfc0bc8f24rwefsd4ds01__Windows-Server-2012-R2-20141128-en.us-127GB.vhd 30 | Windows 31 | 32 | Small 33 | true 34 | 35 | -------------------------------------------------------------------------------- /spec/unit/assets/bootstrap_azure_role_xmls/update_role_xml_for_extension/output_role_3.xml: -------------------------------------------------------------------------------- 1 | 2 | test-vm-win 3 | 4 | PersistentVMRole 5 | 6 | 7 | NetworkConfiguration 8 | 9 | 10 | 3389 11 | RDP 12 | 57666 13 | tcp 14 | 14.13.12.11 15 | false 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | BGInfo 24 | Microsoft.Compute 25 | BGInfo 26 | 1.* 27 | Enable 28 | 29 | ChefClientChef.Bootstrap.WindowsAzureChefClient1210.12PublicParamsIk15UHVibGljUGFyYW1zVmFsdWUi 30 | PublicPrivateParamsIk15UHJpdmF0ZVBhcmFtc1ZhbHVlIg== 31 | Privateenable 32 | 33 | 34 | ReadWrite 35 | test-vm-cnt-test-vm-win-0-201105240534190032 36 | https://portalvhdsdfsdjf5djfb3iwb.blob.core.windows.net/vhds/test-dns-test-vm-win-2015-01-30.vhd 37 | a6dfsdfwerfdfc0bc8f24rwefsd4ds01__Windows-Server-2012-R2-20141128-en.us-127GB.vhd 38 | Windows 39 | 40 | Small 41 | true 42 | 43 | -------------------------------------------------------------------------------- /spec/unit/assets/client.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEogIBAAKCAQEAwWxIDXQc53yZJfMv2Piw+Umq+7GGV0tycmFk74ZgGgFs0Eeu 3 | rmkEGL2SAWU26jUtdcjyK9STi5yjRs0E+QcMv3wHnfiIHtRWfAt696imJcGiTzSK 4 | WIeVg+rRRg5LK3ocrnSmqPwzQs4MZqb2Uj5N1aAZxIT2CFLMuqF/EJmQv4UANzOz 5 | wADe9J7WHatd71EBSfo/Y7ak6fvoB3qvxPFPKKHzeX3ZNVeH2Fm4vVL19/qDtApC 6 | QUvU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ATE KEY----- -------------------------------------------------------------------------------- /spec/unit/assets/create_ag_for_new-ag.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | new-ag 4 | 5 | ag description 6 | West US 7 | 8 | -------------------------------------------------------------------------------- /spec/unit/assets/create_deployment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | unknown_yet 4 | Production 5 | 6 | 7 | 8 | vm01 9 | 10 | PersistentVMRole 11 | 12 | 13 | LinuxProvisioningConfiguration 14 | vm01 15 | jetstream 16 | jetstream1! 17 | false 18 | 19 | 20 | NetworkConfiguration 21 | 22 | 23 | 22 24 | SSH 25 | 22 26 | TCP 27 | 28 | 29 | 30 | 31 | 32 | 33 | disk004Test 34 | http://storageaccount001.blob.core.windows.net/vhds/disk004Test.vhd 35 | SUSE__OpenSUSE64121-03192012-en-us-15GB 36 | 37 | ExtraSmall 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /spec/unit/assets/create_deployment_domain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | unknown_yet 4 | Production 5 | 6 | 7 | 8 | vm-in-domain 9 | 10 | PersistentVMRole 11 | 12 | 13 | WindowsProvisioningConfiguration 14 | vm-in-domain 15 | 16 | false 17 | false 18 | 19 | 20 | vmtestad.com 21 | user2 22 | user2pass 23 | 24 | vmtestad.com 25 | 26 | 27 | 28 | 29 | Http 30 | 31 | 32 | 33 | user2 34 | 35 | 36 | NetworkConfiguration 37 | 38 | 39 | 5985 40 | WinRM 41 | 42 | TCP 43 | 44 | 45 | 46 | Subnet-1 47 | 48 | 49 | 50 | 51 | 52 | somediskname 53 | http://storageaccount001.blob.core.windows.net/vhds/somediskname.vhd 54 | Windows-Server-2012-Datacenter-201310.01-en.us-127GB 55 | 56 | Medium 57 | 58 | 59 | -------------------------------------------------------------------------------- /spec/unit/assets/create_deployment_in_progress.xml: -------------------------------------------------------------------------------- 1 | 878c6cd7-73d1-4527-949e-44eb7451547cInProgress 2 | 3 | unknown_yet 4 | Production 5 | 6 | 7 | 8 | vm01 9 | 10 | PersistentVMRole 11 | 12 | 13 | LinuxProvisioningConfiguration 14 | vm01 15 | jetstream 16 | true 17 | 18 | 19 | 20 | 103E86B8757517D8E3EEC406D7A9110C7EA6CE1C 21 | /home/jetstream/.ssh/authorized_keys 22 | 23 | 24 | 25 | 26 | 27 | NetworkConfiguration 28 | 29 | 30 | 22 31 | SSH 32 | 22 33 | TCP 34 | 35 | 36 | 37 | 38 | 39 | 40 | disk004Test 41 | http://storageaccount001.blob.core.windows.net/vhds/disk004Test.vhd 42 | SUSE__OpenSUSE64121-03192012-en-us-15GB 43 | 44 | ExtraSmall 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /spec/unit/assets/create_deployment_virtual_network.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | unknown_yet 4 | Production 5 | 6 | 7 | 8 | vm01 9 | 10 | PersistentVMRole 11 | 12 | 13 | LinuxProvisioningConfiguration 14 | vm01 15 | jetstream 16 | jetstream1! 17 | false 18 | 19 | 20 | NetworkConfiguration 21 | 22 | 23 | 22 24 | SSH 25 | 22 26 | TCP 27 | 28 | 29 | 30 | test-subnet 31 | 32 | 33 | 34 | 35 | 36 | disk004Test 37 | http://storageaccount001.blob.core.windows.net/vhds/disk004Test.vhd 38 | SUSE__OpenSUSE64121-03192012-en-us-15GB 39 | 40 | ExtraSmall 41 | 42 | 43 | test-network 44 | 45 | -------------------------------------------------------------------------------- /spec/unit/assets/create_deployment_winrm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | unknown_yet 4 | Production 5 | 6 | 7 | 8 | vm01 9 | 10 | PersistentVMRole 11 | 12 | 13 | WindowsProvisioningConfiguration 14 | vm01 15 | foobar 16 | false 17 | false 18 | 19 | 20 | LocalMachine 21 | My 22 | 7FCCD713CC390E3488290BF7A106AD267B5AC2A5 23 | 24 | 25 | 26 | 27 | 28 | 7FCCD713CC390E3488290BF7A106AD267B5AC2A5 29 | Https 30 | 31 | 32 | 33 | build 34 | 35 | 36 | 37 | oobeSystem 38 | 39 | 40 | Microsoft-Windows-Shell-Setup 41 | 42 | 43 | AutoLogon 44 | PEF1dG9Mb2dvbj48VXNlcm5hbWU+YnVpbGQ8L1VzZXJuYW1lPjxQYXNzd29y 45 | ZD48VmFsdWU+Zm9vYmFyPC9WYWx1ZT48UGxhaW5UZXh0PnRydWU8L1BsYWlu 46 | VGV4dD48L1Bhc3N3b3JkPjxMb2dvbkNvdW50PjE8L0xvZ29uQ291bnQ+PEVu 47 | YWJsZWQ+dHJ1ZTwvRW5hYmxlZD48L0F1dG9Mb2dvbj4K 48 | 49 | 50 | FirstLogonCommands 51 | PEZpcnN0TG9nb25Db21tYW5kcz48U3luY2hyb25vdXNDb21tYW5kIHdjbTph 52 | Y3Rpb249ImFkZCI+PE9yZGVyPjE8L09yZGVyPjxDb21tYW5kTGluZT5jbWQu 53 | ZXhlIC9jIHdpbnJtIHNldCB3aW5ybS9jb25maWcgQHtNYXhUaW1lb3V0bXM9 54 | IjE4MDAwMDAifTwvQ29tbWFuZExpbmU+PERlc2NyaXB0aW9uPkJ1bXAgV2lu 55 | Uk0gbWF4IHRpbWVvdXQgdG8gMTgwMDAwMCBtaWxsaXNlY29uZHM8L0Rlc2Ny 56 | aXB0aW9uPjwvU3luY2hyb25vdXNDb21tYW5kPjxTeW5jaHJvbm91c0NvbW1h 57 | bmQgd2NtOmFjdGlvbj0iYWRkIj48T3JkZXI+MjwvT3JkZXI+PENvbW1hbmRM 58 | aW5lPmNtZC5leGUgL2Mgd2lucm0gc2V0IHdpbnJtL2NvbmZpZy93aW5ycyBA 59 | e01heE1lbW9yeVBlclNoZWxsTUI9IjYwMCJ9PC9Db21tYW5kTGluZT48RGVz 60 | Y3JpcHRpb24+QnVtcCBXaW5STSBtYXggbWVtb3J5IHBlciBzaGVsbCB0byA2 61 | MDAgTUI8L0Rlc2NyaXB0aW9uPjwvU3luY2hyb25vdXNDb21tYW5kPjwvRmly 62 | c3RMb2dvbkNvbW1hbmRzPgo= 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | NetworkConfiguration 73 | 74 | 75 | 5986 76 | WinRM 77 | 78 | TCP 79 | 80 | 81 | 82 | 83 | 84 | 85 | disk_ce92083f-0041-4825-84b3-6ae8b3525b29 86 | http://chefci.blob.core.windows.net/vhds/disk_ce92083f-0041-4825-84b3-6ae8b3525b29.vhd 87 | a699494373c04fc0bc8f2bb1389d6106__Win2K8R2SP1-Datacenter-201502.01-en.us-127GB.vhd 88 | 89 | Medium 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /spec/unit/assets/create_host_affinity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | service003 4 | 6 | Explicitly created hosted service 7 | test-affinity 8 | 9 | -------------------------------------------------------------------------------- /spec/unit/assets/create_host_location.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | service003 4 | 6 | Explicitly created hosted service 7 | West US 8 | 9 | -------------------------------------------------------------------------------- /spec/unit/assets/create_role.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | vm01 4 | 5 | PersistentVMRole 6 | 7 | 8 | LinuxProvisioningConfiguration 9 | vm01 10 | jetstream 11 | jetstream1! 12 | false 13 | 14 | 15 | NetworkConfiguration 16 | 17 | 18 | 22 19 | SSH 20 | 22 21 | TCP 22 | 23 | 24 | 80 25 | HTTP 26 | 80 27 | TCP 28 | 29 | 30 | 3389 31 | Remote Desktop 32 | 3389 33 | TCP 34 | 35 | 36 | 993 37 | IMAPS 38 | 993 39 | TCP 40 | 41 | 42 | 44 43 | TCPEndpoint_chef_44 44 | 45 45 | TCP 46 | 47 | 48 | 65 49 | UDPEndpoint_chef_65 50 | 65 51 | UDP 52 | 53 | 54 | 75 55 | UDPEndpoint_chef_75 56 | 75 57 | UDP 58 | 59 | 60 | 61 | 62 | 63 | 64 | disk004Test 65 | http://storageaccount001.blob.core.windows.net/vhds/disk004Test.vhd 66 | SUSE__OpenSUSE64121-03192012-en-us-15GB 67 | 68 | ExtraSmall 69 | 70 | -------------------------------------------------------------------------------- /spec/unit/assets/create_storageservice_for_service003.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ka001testeurope 4 | 6 | Explicitly created storage service 7 | West US 8 | 9 | -------------------------------------------------------------------------------- /spec/unit/assets/create_storageservice_for_service004.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ka001testeurope 4 | 6 | Explicitly created storage service 7 | test-affinity-group 8 | 9 | -------------------------------------------------------------------------------- /spec/unit/assets/error_404.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 404 4 | The specified resource does not exist. 5 | -------------------------------------------------------------------------------- /spec/unit/assets/get_network.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 192.168.0.0/20 9 | 10 | 11 | 12 | 192.168.0.0/23 13 | 14 | 15 | 16 | 17 | 18 | 172.16.0.0/20 19 | 20 | 21 | 22 | 172.16.0.0/23 23 | 24 | 25 | 26 | 27 | 28 | 172.16.0.0/20 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /spec/unit/assets/get_service_certificate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | MIIFbzCCA1egAwIBAgICFAwwDQYJKoZIhvcNAQELBQAwSDETMBEGCgmSJomT8ixkARkWA29yZzEcMBoGCgmSJomT8ixkARkWDGtuaWZlLXBsdWdpbjETMBEGA1UEAwwKT3BzY29kZSBDQTAeFw0xNjExMTgwNzA5MTVaFw0xODExMTgwNzA5MTVaMEgxEzARBgoJkiaJk/IsZAEZFgNvcmcxHDAaBgoJkiaJk/IsZAEZFgxrbmlmZS1wbHVnaW4xEzARBgNVBAMMCk9wc2NvZGUgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/wq37ZvE0n5miEV2+wpZbk/JPIpB7tfa8bH4QnQMgoBFDPTMojgxxg/nrHYJB/nq3xsE6AnslO6OUfaeTPLkBkJE0IOBk0feakRj30enUdXsvlzMtF8oZd6lUTPrhHwFyJOmk3ctQk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hY7aM06NYu5Du72p/9jNA12TmR/ICKeGQC0c00fX6j3fdsX8kDp8th2+bv8CkJ8nLCNOkOln3kzUZqSTHQO2PBRWnaS8FIo24syDNtmLfQNoOi5ECjeZmSB/HVJCU1gyEFpmfuTCDQO1lk8Y1uUdtFGj2rW7bh3TG8qoWJq/ZcpPHHgT+sYQ3qkH47ZA1yAj42zo7yxmfPVxQRgEwQh5hU2k3Rvb/ePHiA5eJ1k8N6ZK1t5lq1iP1w6eDyky9X1mQxzlxgHVYBQ+wEZIi5EzJyOnBAK+Ey/qd/kEx/FoBOym+IG2fz8iZ4M 4 | -------------------------------------------------------------------------------- /spec/unit/assets/get_service_certificate_error.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 |   ResourceNotFound 4 |   The certificate was not found. 5 | -------------------------------------------------------------------------------- /spec/unit/assets/key_rsa: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEAy+po4KcyflJshuN1mDnBmYYkIrwATm4HF5dKnS+md5WAgRaz 3 | QmXq9AlQNe1EUwQ/UBL7/uvZQRnITlCgEvYCVZpMTbdvFFwdHRKRm7leT+7Qd9Z1 4 | EyyG3QZFE29RLmQImgEdoFsir1U2TxVRdIiJRhuxBf2nhg9tgOjUG9QDaxRrkPxo 5 | iV9rNaZGPe/UH7TKr75b9EeHNyUN1Ll7pgyZmFtDziU1Gwidd9lEubNausDdKTyw 6 | p2WMJrVsFYbCwq9iD9g5kKGjl+28uCcedJpOZj89DkKXF1NANFHBrKpcRWtQJ+G9 7 | nGwY8WxY7ZRZtslxpyuHaeFXqOD2ACKNoFsJJQIDAQABAoIBAQCuQQ6Gi9p2YHEl 8 | g9LF1vU+AId4tzd7zkJ5Qmwcjs+ueS9rIL7nCrkQ+bR1oOA2IPcJsm9tlJX/L80g 9 | P33LNjcgd86kyxA9Ucn/QhL0BCA4Jlg3UCiTzgUhc24sAYBaKFnBYRq0Ia0uL59N 10 | TWZiMxs7sgZAn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4wCQKpeSkj8mfrlee/bk5k/B+G47Dk7+tab+0p8B6lOWQ== 27 | -----END RSA PRIVATE KEY----- -------------------------------------------------------------------------------- /spec/unit/assets/key_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDL6mjgpzJ+UmyG43WYOcGZhiQivABObgcXl0qdL6Z3lYCBFrNCZer0CVA17URTBD9QEvv+69lBGchOUKAS9gJVmkxNt28UXB0dEpGbuV5P7tB31nUTLIbdBkUTb1EuZAiaAR2gWyKvVTZPFVF0iIlGG7EF/aeGD22A6NQb1ANrFGuQ/GiJX2s1pkY979QftMqvvlv0R4c3JQ3UuXumDJmYW0POJTUbCJ132US5s1q6wN0pPLCnZYwmtWwVhsLCr2IP2DmQoaOX7by4Jx50mk5mPz0OQpcXU0A0UcGsqlxFa1An4b2cbBjxbFjtlFm2yXGnK4dp4Veo4PYAIo2gWwkl jeffm@jemendoz-x230.redmond.corp.microsoft.com -------------------------------------------------------------------------------- /spec/unit/assets/list_affinitygroups.xml: -------------------------------------------------------------------------------- 1 | agnameagdescWest USPersistentVMRoleHighMemoryjm-affinity-groupWest USPersistentVMRoleHighMemorytesttestdescWest USPersistentVMRoleHighMemory -------------------------------------------------------------------------------- /spec/unit/assets/list_deployments_for_service000.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | service003 4 | Production 5 | 34f75bed486643d39affeb9f98d47227 6 | Running 7 | 8 | http://service003.cloudapp-preview.net/ 9 | PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJyb2xlMjA2Ij4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIxIiAvPg0KICA8L1JvbGU+DQo8L1NlcnZpY2VDb25maWd1cmF0aW9uPg== 10 | 11 | 12 | role206 13 | role206 14 | StoppedVM 15 | 0 16 | 0 17 | ExtraSmall 18 | 19 | 10.26.198.33 20 | 21 | 22 | SSH 23 | 65.52.251.57 24 | 49627 25 | 22 26 | tcp 27 | 28 | 29 | tcpport66 30 | 65.52.251.57 31 | 66 32 | 66 33 | tcp 34 | 35 | 36 | udpport77 37 | 65.52.251.57 38 | 77 39 | 77 40 | udp 41 | 42 | 43 | udpport88 44 | 65.52.251.57 45 | 88 46 | 88 47 | udp 48 | 49 | 50 | udpport99 51 | 65.52.251.57 52 | 99 53 | 99 54 | udp 55 | 56 | 57 | Stopped 58 | 59 | 60 | 1 61 | 62 | 63 | role206 64 | 65 | PersistentVMRole 66 | 67 | 68 | NetworkConfiguration 69 | 70 | 71 | 22 72 | SSH 73 | 49627 74 | tcp 75 | 65.52.251.57 76 | 77 | 78 | 66 79 | tcpport66 80 | 66 81 | tcp 82 | 65.52.251.57 83 | 84 | 85 | 77 86 | udpport77 87 | 77 88 | udp 89 | 65.52.251.57 90 | 91 | 92 | 88 93 | udpport88 94 | 88 95 | udp 96 | 65.52.251.57 97 | 98 | 99 | 99 100 | udpport99 101 | 99 102 | udp 103 | 65.52.251.57 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | ReadWrite 112 | service003-role206-0-20120528151407 113 | http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk_2012_05_28_08_13 114 | SUSE__OpenSUSE64121-03192012-en-us-15GB.vhd 115 | Linux 116 | 117 | ExtraSmall 118 | 119 | 120 | 121 | false 122 | false 123 | 2012-05-28T15:14:05Z 124 | 2012-05-28T16:29:06Z 125 | 126 | 127 | -------------------------------------------------------------------------------- /spec/unit/assets/list_deployments_for_service001.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | deployment001 4 | Production 5 | 2b1f2f0a4b414088a0ec64d583d9c4b3 6 | Running 7 | 8 | http://service001.cloudapp-preview.net/ 9 | PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJyb2xlMDAyIj4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIxIiAvPg0KICA8L1JvbGU+DQogIDxSb2xlIG5hbWU9InJvbGUwMDEiPg0KICAgIDxJbnN0YW5jZXMgY291bnQ9IjEiIC8+DQogIDwvUm9sZT4NCjwvU2VydmljZUNvbmZpZ3VyYXRpb24+ 10 | 11 | 12 | vm002 13 | vm002 14 | ReadyRole 15 | 0 16 | 0 17 | ExtraSmall 18 | 19 | 10.26.198.146 20 | 21 | 22 | tcpport66 23 | 65.52.251.57 24 | 66 25 | 66 26 | tcp 27 | 28 | 29 | SSH 30 | 65.52.249.191 31 | 22 32 | 22 33 | tcp 34 | 35 | 36 | Started 37 | myVm2 38 | 39 | 40 | role002 41 | role002 42 | RoleStateUnknown 43 | 0 44 | 0 45 | Small 46 | 47 | 10.26.196.201 48 | 49 | 50 | ssh 51 | 65.52.249.191 52 | 23 53 | 22 54 | tcp 55 | 56 | 57 | Started 58 | role002 59 | 60 | 61 | role001 62 | role001 63 | ReadyRole 64 | 0 65 | 0 66 | Small 67 | 68 | 10.26.196.254 69 | 70 | 71 | ssh 72 | 65.52.249.191 73 | 22 74 | 22 75 | tcp 76 | 77 | 78 | Started 79 | role001 80 | 81 | 82 | 1 83 | 84 | 85 | vm002 86 | WA-GUEST-OS-1.18_201203-01 87 | 88 | 89 | NetworkConfiguration 90 | 91 | 92 | 60657 93 | tcp 94 | 65.52.249.191 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | role002 103 | WA-GUEST-OS-1.18_201203-01 104 | PersistentVMRole 105 | 106 | 107 | NetworkConfiguration 108 | 109 | 110 | 22 111 | ssh 112 | 23 113 | tcp 114 | 65.52.249.191 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | ReadWrite 123 | deployment001-role002-0-201241722728 124 | http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk002b 125 | SUSE__OpenSUSE64121-03192012-en-us-15GB 126 | Linux 127 | 128 | Small 129 | 130 | 131 | role001 132 | WA-GUEST-OS-1.18_201203-01 133 | PersistentVMRole 134 | 135 | 136 | NetworkConfiguration 137 | 138 | 139 | 22 140 | ssh 141 | 22 142 | tcp 143 | 65.52.249.191 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | ReadWrite 152 | deployment001-role001-0-201241722113 153 | http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk001 154 | SUSE__OpenSUSE64121-03192012-en-us-15GB 155 | Linux 156 | 157 | Small 158 | 159 | 160 | 1.7 161 | false 162 | true 163 | 2012-04-17T22:01:10Z 164 | 2012-04-23T23:52:09Z 165 | 166 | 167 | lb_name 168 | 169 | Private 170 | vnet1 171 | 10.4.4.4 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /spec/unit/assets/list_deployments_for_service002.xml: -------------------------------------------------------------------------------- 1 | testrequestProduction0f6204c7b38b457a913be856a23e3142Runninghttp://service002.cloudapp-preview.net/PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJ2bTAxIj4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIxIiAvPg0KICA8L1JvbGU+DQo8L1NlcnZpY2VDb25maWd1cmF0aW9uPg==vm01vm01ReadyRole00ExtraSmall10.26.194.166SSH65.52.251.1445404722tcpStartedmyVm1vm01WA-GUEST-OS-1.18_201203-01PersistentVMRoleNetworkConfiguration22SSH54047tcp65.52.251.144ReadWritetestrequest-vm01-0-2012423214252http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk004TestSUSE__OpenSUSE64121-03192012-en-us-15GBLinuxExtraSmall1.7falsefalse2012-04-23T21:46:44Z2012-04-23T21:56:47ZResourceNotFoundNo deployments were found. 2 | 3 | deployment004 4 | Production 5 | 2b1f2f0a4b414088a0ec64d583d9c4b3 6 | Running 7 | 8 | http://service004.cloudapp-preview.net/ 9 | PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJyb2xlMDAyIj4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIxIiAvPg0KICA8L1JvbGU+DQogIDxSb2xlIG5hbWU9InJvbGUwMDEiPg0KICAgIDxJbnN0YW5jZXMgY291bnQ9IjEiIC8+DQogIDwvUm9sZT4NCjwvU2VydmljZUNvbmZpZ3VyYXRpb24+ 10 | 11 | 12 | ssh-vm 13 | ssh-vm 14 | ReadyRole 15 | 0 16 | 0 17 | ExtraSmall 18 | 19 | 10.26.198.146 20 | 21 | 22 | tcpport66 23 | 65.52.251.57 24 | 66 25 | 66 26 | tcp 27 | 28 | 29 | SSH 30 | 65.52.249.191 31 | 22 32 | 22 33 | tcp 34 | 35 | 36 | Started 37 | ssh-vm 38 | 39 | 40 | winrm-vm 41 | winrm-vm 42 | ReadyRole 43 | 0 44 | 0 45 | Small 46 | 47 | 10.26.196.254 48 | 49 | 50 | winrm 51 | 65.52.249.191 52 | 5985 53 | 5985 54 | tcp 55 | 56 | 57 | Remote Desktop 58 | 65.52.249.191 59 | 3389 60 | 3389 61 | tcp 62 | 63 | 64 | Started 65 | winrm-vm 66 | 67 | 68 | 1 69 | 70 | 71 | ssh-vm 72 | WA-GUEST-OS-1.18_201203-01 73 | 74 | 75 | NetworkConfiguration 76 | 77 | 78 | 60657 79 | tcp 80 | 65.52.249.191 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | winrm-vm 89 | WA-GUEST-OS-1.18_201203-01 90 | PersistentVMRole 91 | 92 | 93 | NetworkConfiguration 94 | 95 | 96 | 5985 97 | winrm 98 | 5985 99 | tcp 100 | 65.52.249.191 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | ReadWrite 109 | deployment004-winrm-vm-0-201241722113 110 | http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk001 111 | SUSE__OpenSUSE64121-03192012-en-us-15GB 112 | Linux 113 | 114 | Small 115 | 116 | 117 | 1.7 118 | false 119 | true 120 | 2012-04-17T22:01:10Z 121 | 2012-04-23T23:52:09Z 122 | 123 | 124 | -------------------------------------------------------------------------------- /spec/unit/assets/list_deployments_for_service005.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | adamed-winrm1 4 | 5 | PersistentVMRole 6 | 7 | 8 | NetworkConfiguration 9 | 10 | 11 | 5986 12 | PowerShell 13 | 5986 14 | tcp 15 | false 16 | 17 | 18 | 3389 19 | Remote Desktop 20 | 65365 21 | tcp 22 | false 23 | 24 | 25 | 26 | 27 | 28 | 29 | BGInfo 30 | Microsoft.Compute 31 | BGInfo 32 | 1.* 33 | Enable 34 | 35 | 36 | 37 | 38 | ReadWrite 39 | adamed-winrm1-adamed-winrm1-0-201502110739010645 40 | https://portalvhdsymd2l3vzqvy06.blob.core.windows.net/vhds/adamed-winrm1-adamed-winrm1-2015-02-11.vhd 41 | a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201412.01-en.us-127GB.vhd 42 | Windows 43 | 44 | Small 45 | 4BAE99A617B7B4F975C51A572CB8420F66477F4C 46 | true 47 | 48 | -------------------------------------------------------------------------------- /spec/unit/assets/list_deployments_for_vmname.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | deployment001 4 | Production 5 | 2b1f2f0a4b414088a0ec64d583d9c4b3 6 | Running 7 | 8 | http://vmname.cloudapp-preview.net/ 9 | PFNlcnZpY2VDb25maWd1cmF0aW9uIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL1NlcnZpY2VIb3N0aW5nLzIwMDgvMTAvU2VydmljZUNvbmZpZ3VyYXRpb24iPg0KICA8Um9sZSBuYW1lPSJyb2xlMDAyIj4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIxIiAvPg0KICA8L1JvbGU+DQogIDxSb2xlIG5hbWU9InJvbGUwMDEiPg0KICAgIDxJbnN0YW5jZXMgY291bnQ9IjEiIC8+DQogIDwvUm9sZT4NCjwvU2VydmljZUNvbmZpZ3VyYXRpb24+ 10 | 11 | 12 | vmname 13 | vmname 14 | ReadyRole 15 | 0 16 | 0 17 | ExtraSmall 18 | 19 | 10.26.198.146 20 | 21 | 22 | tcpport66 23 | 65.52.251.57 24 | 66 25 | 66 26 | tcp 27 | 28 | 29 | SSH 30 | 65.52.249.191 31 | 22 32 | 22 33 | tcp 34 | 35 | 36 | Started 37 | myVm2 38 | 39 | 40 | 1 41 | 42 | 43 | vmname 44 | WA-GUEST-OS-1.18_201203-01 45 | 46 | 47 | NetworkConfiguration 48 | 49 | 50 | 60657 51 | tcp 52 | 65.52.249.191 53 | 54 | 55 | lb_set2 56 | 443 57 | existing_lb 58 | 443 59 | 60 | /healthcheck2 61 | 443 62 | http 63 | 15 64 | 31 65 | 66 | tcp 67 | 23.102.63.187 68 | false 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 1.7 77 | false 78 | true 79 | 2012-04-17T22:01:10Z 80 | 2012-04-23T23:52:09Z 81 | 82 | 83 | -------------------------------------------------------------------------------- /spec/unit/assets/list_disks.xml: -------------------------------------------------------------------------------- 1 | LinuxWindows Azure Preview15http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk104service002-role104-0-201257233812SUSE__OpenSUSE64121-03192012-en-us-15GBLinuxWindows Azure Preview15http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk105service002-role105-0-201257235741SUSE__OpenSUSE64121-03192012-en-us-15GBLinuxWindows Azure Preview30http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk106service002-role106-0-20125801047OpenLogic__OpenLogic-CentOS-62-en-us-30GBLinuxWindows Azure Preview15http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk107service002-role107-0-20125814427SUSE__OpenSUSE64121-03192012-en-us-15GBLinuxWindows Azure Preview15http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk108service002-role108-0-201258152913SUSE__OpenSUSE64121-03192012-en-us-15GBLinuxWindows Azure Preview15http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk109service002-role109-0-201258165947SUSE__OpenSUSE64121-03192012-en-us-15GBservice002service002role119LinuxWindows Azure Preview30http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk119service002-role119-0-201258172212OpenLogic__OpenLogic-CentOS-62-en-us-30GBLinuxWindows Azure Preview30http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk120service002-role120-0-201258203045OpenLogic__OpenLogic-CentOS-62-en-us-30GBLinuxWindows Azure Preview15http://auxpreview104imagestore.blob.core.azure-preview.com/os-disks/disk104service002-role002-0-201257233812SUSE__OpenSUSE64121-03192012-en-us-15GB 2 | -------------------------------------------------------------------------------- /spec/unit/assets/list_hosts.xml: -------------------------------------------------------------------------------- 1 | https://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service001service001Explicitly created hosted serviceWindows Azure PreviewCreated2012-04-17T21:56:23Z2012-04-17T22:01:08Zhttps://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service002service002Explicitly created hosted serviceWindows Azure PreviewCreated2012-04-17T22:27:08Z2012-04-23T21:42:47Zhttps://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service003service003Explicitly created hosted serviceWindows Azure PreviewCreated2012-04-19T20:17:26Z2012-04-19T20:17:25Zhttps://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/service004service004Explicitly created hosted serviceWindows Azure PreviewCreated2012-04-17T21:56:23Z2012-04-17T22:01:08Zhttps://management-preview.core.windows-int.net/155a9851-88a8-49b4-98e4-58055f08f412/services/hostedservices/vmnamevmnameExplicitly created hosted serviceWindows Azure PreviewCreated2012-04-19T20:17:26Z2012-04-19T20:17:25Z -------------------------------------------------------------------------------- /spec/unit/assets/list_images.xml: -------------------------------------------------------------------------------- 1 | CanonicalEast AsiaCANONICAL__Canonical-Ubuntu-12-04-20120519-2012-05-19-en-us-30GB.vhdLinuxhttp://www.ubuntu.com/project/about-ubuntu/licensingUbuntu Server 12.04 (Precise Pangolin) 20120519 Cloud ImageMicrosoftEast Asia;Southeast Asia;North Europe;West Europe;East US;West US30MSFT__Windows-Server-2008-R2-SP1.11-29-2011Windowshttp://www.microsoft.comMicrosoft Windows Server 2008 R2 SP1MicrosoftEast Asia;Southeast Asia;North Europe;West Europe;East US;West US30MSFT__Windows-Server-2008-R2-SP1-with-SQL-Server-2012-Eval.11-29-2011Windowshttp://download.microsoft.com/download/A/A/7/AA73B8F4-5F4B-4C0B-94F4-FB238C92A916/ENU/SQL Server 2012 Evaluation.rtfMicrosoft Windows 2008 R2 Service Pack 1 with SQL Server 2012 Evaluation Edition (64-bit). This version has licensing restrictions and cannot be used in production. Use of this version is limited to 6 months.MicrosoftEast Asia;Southeast Asia;North Europe;West Europe;East US;West US30MSFT__Windows-Server-8-Beta.en-us.30GB.2012-03-22Windowshttp://msdn.microsoft.com/en-us/windows/apps/br229516The next release of Windows Server, Windows Server "8", offers businesses and hosting providers a scalable, dynamic, and multitenant-aware, cloud-optimized infrastructure. It securely connects across premises and allows IT Professionals to respond to business needs faster and more efficiently.MicrosoftEast Asia;Southeast Asia;North Europe;West Europe;East US;West US40MSFT__Windows-Server-8-Beta.2-17-2012Windowshttp://www.microsoft.comThe next release of Windows Server, Windows Server "8", offers businesses and hosting providers a scalable, dynamic, and multitenant-aware, cloud-optimized infrastructure. It securely connects across premises and allows IT Professionals to respond to business needs faster and more efficiently.MicrosoftEast Asia;Southeast Asia;North Europe;West Europe;East US;West US30MSFT__Windows-Server-2008-R2-SP1.en-us.30GB.2012-3-22Windowshttp://msdn.microsoft.com/en-us/windows/apps/br229516Microsoft Windows 2008 R2 Service Pack 1 for IAASOpenLogicEast Asia;Southeast Asia;North Europe;West Europe;East US;West USOpenLogic__OpenLogic-CentOS-62-20120509-en-us-30GB.vhdLinuxhttp://www.openlogic.com/azure/service-agreement.phpThis distribution of CentOS version 6.2 is provided by OpenLogic and contains an installation of the Basic Server packages.SUSEEast Asia;Southeast Asia;North Europe;West Europe;East US;West USSUSE__SUSE-Linux-Enterprise-Server-11SP2-20120521-en-us-30GB.vhdLinuxhttp://www.novell.com/licensing/eula/SUSE Linux Enterprise Server is a highly reliable, scalable, and secure server operating system, built to power mission-critical workloads in both physical and virtual environments. It is an affordable, interoperable, and manageable open source foundation. With it, enterprises can cost-effectively deliver core business services, enable secure networks, and simplify the management of their heterogeneous IT infrastructure, maximizing efficiency and value.SUSEEast Asia;West USSUSE__OpenSUSE64121-03192012-en-us-15GB.vhdLinuxhttp://www.novell.com/licensing/eula/OpenSUSE Linux 64 Bits (IAAS M1 Preview) 2 | -------------------------------------------------------------------------------- /spec/unit/assets/list_storageaccounts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | storage-service-address 5 | storage-service-name 6 | 7 | description 8 | affinity-group 9 | service-location 10 | 11 | status 12 | 13 | storage-service-blob-endpoint 14 | storage-service-queue-endpoint 15 | storage-service-table-endpoint 16 | 17 | 18 | 19 | property-name 20 | property-value 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /spec/unit/assets/list_vnets.xml: -------------------------------------------------------------------------------- 1 | jm-vnet-testdba15bb3-6a60-4fd3-bc86-c79af3301f66jm-affinity-groupCreated192.168.0.0/20Subnet-1192.168.0.0/23vnet-test-2ee225a95-04be-4943-ae5e-f0ec2a5d522btestCreated172.16.0.0/20Subnet-1172.16.0.0/23vnname5d77967b-d740-44e0-aa72-5f21b045060bagnameCreated10.0.0.0/16 -------------------------------------------------------------------------------- /spec/unit/assets/post_success.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 878c6cd7-73d1-4527-949e-44eb7451547c 4 | Succeeded 5 | 200 6 | 7 | -------------------------------------------------------------------------------- /spec/unit/assets/publish-settings-files/A_account.publishsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /spec/unit/assets/publish-settings-files/B_account.publishsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /spec/unit/assets/publish-settings-files/azureInvalid.publishsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /spec/unit/assets/publish-settings-files/azureValid.publishsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /spec/unit/assets/publish-settings-files/azureValidSchemaVersion-2.0.publishsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /spec/unit/assets/secret_file: -------------------------------------------------------------------------------- 1 | PgIxStCmMDsuIw3ygRhmdMtStpc9EMiWisQXoP -------------------------------------------------------------------------------- /spec/unit/assets/set_network_existing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 192.168.0.0/20 9 | 10 | 11 | 12 | 192.168.0.0/23 13 | 14 | 15 | 16 | 17 | 18 | 172.16.0.0/20 19 | 20 | 21 | 22 | 172.16.0.0/23 23 | 24 | 25 | 26 | 27 | 192.168.0.0/20 28 | 192.168.0.0/20 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /spec/unit/assets/set_network_new.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 192.168.0.0/20 9 | 10 | 11 | 12 | 192.168.0.0/23 13 | 14 | 15 | 16 | 17 | 18 | 172.16.0.0/20 19 | 20 | 21 | 22 | 172.16.0.0/23 23 | 24 | 25 | 26 | 27 | 28 | 172.16.0.0/20 29 | 30 | 10.0.0.0/1610.0.0.0/16 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /spec/unit/azurerm_server_delete_spec.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "../spec_helper" 19 | require_relative "query_azure_mock" 20 | 21 | describe Chef::Knife::AzurermServerDelete do 22 | include AzureSpecHelper 23 | include QueryAzureMock 24 | 25 | describe "delete server without deleting resource group" do 26 | before do 27 | @arm_server_instance = create_arm_instance(Chef::Knife::AzurermServerDelete) 28 | allow(@arm_server_instance.service.ui).to receive(:confirm).and_return(true) 29 | @compute_client = double("ComputeManagementClient") 30 | 31 | @service = @arm_server_instance.service 32 | 33 | @arm_server_instance.config[:azure_resource_group_name] = "test-rg-group" 34 | @arm_server_instance.name_args = ["VM001"] 35 | 36 | @server_detail = double("server", name: "VM001", hardware_profile: double, storage_profile: double(os_disk: double)) 37 | allow(@server_detail.hardware_profile).to receive(:vm_size).and_return("10") 38 | allow(@server_detail.storage_profile.os_disk).to receive(:os_type).and_return("Linux") 39 | allow_any_instance_of(Chef::Knife::AzurermBase).to receive(:get_azure_cli_version).and_return("1.0.0") 40 | end 41 | 42 | it "deletes server" do 43 | server = double("server") 44 | delete_server = double("delete") 45 | allow(delete_server).to receive(:nil?).and_return("false") 46 | 47 | expect(@arm_server_instance).to receive(:validate_arm_keys!).with(:azure_resource_group_name) 48 | allow(@arm_server_instance.service).to receive(:compute_management_client).and_return(@compute_client) 49 | allow(@compute_client).to receive_message_chain(:virtual_machines, :get).with("test-rg-group", "VM001").and_return(@server_detail) 50 | 51 | expect(@service).to receive(:msg_pair).with(@service.ui, "VM Name", "VM001") 52 | expect(@service).to receive(:msg_pair).with(@service.ui, "VM Size", "10") 53 | expect(@service).to receive(:msg_pair).with(@service.ui, "VM OS", "Linux") 54 | allow(@compute_client).to receive_message_chain(:virtual_machines, :delete).with("test-rg-group", "VM001").and_return(delete_server) 55 | expect(@service.ui).to receive(:info).once 56 | expect(@service.ui).to receive(:warn).twice 57 | @arm_server_instance.run 58 | end 59 | 60 | it "does nothing if the server is not found" do 61 | server = double("server", name: "VM002") 62 | expect(@arm_server_instance).to receive(:validate_arm_keys!).with(:azure_resource_group_name) 63 | expect(@arm_server_instance.service).to receive(:compute_management_client).and_return(@compute_client) 64 | expect(@compute_client).to receive_message_chain(:virtual_machines, :get).with("test-rg-group", "VM001").and_return(server) 65 | expect(@service.ui).to receive(:warn).once 66 | @arm_server_instance.run 67 | end 68 | 69 | it "destroys the corresponding node and client if --purge is given" do 70 | expect(@arm_server_instance).to receive(:validate_arm_keys!).with(:azure_resource_group_name) 71 | allow(@service).to receive(:delete_server) 72 | @arm_server_instance.config[:purge] = true 73 | expect(@arm_server_instance).to receive(:destroy_item).twice 74 | @arm_server_instance.run 75 | end 76 | 77 | it "rescues exception if the delete process fails" do 78 | expect(@arm_server_instance).to receive(:validate_arm_keys!).with(:azure_resource_group_name) 79 | allow(@service).to receive(:delete_server).and_raise(MsRestAzure::AzureOperationError, "ResourceNotFound") 80 | allow(@service.ui).to receive(:error).twice 81 | @arm_server_instance.run 82 | end 83 | end 84 | 85 | describe "delete respective resource group along with server" do 86 | before do 87 | @arm_server_instance = create_arm_instance(Chef::Knife::AzurermServerDelete) 88 | allow(@arm_server_instance.service.ui).to receive(:confirm).and_return(true) 89 | allow_any_instance_of(Chef::Knife::AzurermBase).to receive(:get_azure_cli_version).and_return("1.0.0") 90 | @resource_client = double("ResourceManagementClient") 91 | @service = @arm_server_instance.service 92 | 93 | @arm_server_instance.config[:azure_resource_group_name] = "test-rg-group" 94 | @arm_server_instance.config[:delete_resource_group] = true 95 | @arm_server_instance.name_args = ["VM001"] 96 | end 97 | 98 | it "destroys the corresponding resource group if --delete-resource-group option is given" do 99 | server = double("server") 100 | allow(server).to receive(:nil?).and_return("false") 101 | @arm_server_instance.config[:delete_resource_group] = true 102 | allow(@arm_server_instance.service.ui).to receive(:confirm).and_return(true) 103 | 104 | expect(@arm_server_instance).to receive(:validate_arm_keys!).with(:azure_resource_group_name) 105 | expect(@arm_server_instance.service).to receive(:resource_management_client).and_return(@resource_client) 106 | expect(@resource_client).to receive_message_chain(:resource_groups, :delete).with("test-rg-group").and_return(server) 107 | expect(@service.ui).to receive(:warn).thrice 108 | expect(@service.ui).to receive(:info).twice 109 | 110 | @arm_server_instance.run 111 | end 112 | end 113 | end 114 | -------------------------------------------------------------------------------- /spec/unit/azurerm_server_list_spec.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) Chef Software Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require_relative "../spec_helper" 19 | require_relative "query_azure_mock" 20 | 21 | describe Chef::Knife::AzurermServerList do 22 | include AzureSpecHelper 23 | include QueryAzureMock 24 | 25 | before do 26 | @arm_server_instance = create_arm_instance(Chef::Knife::AzurermServerList) 27 | @service = @arm_server_instance.service 28 | 29 | @compute_client = double("ComputeManagementClient") 30 | 31 | @server1 = double("server1", name: "MyVM1", id: double, location: "west-us") 32 | allow(@server1.id).to receive(:split).and_return(["", "subscriptions", "subscription_id", "resourcegroups", "myresourcegroup1", "Microsoft.compute", "virtualmachines", "MyVM1"]) 33 | allow(@server1.id.split[4]).to receive(:downcase).and_return("myresourcegroup1") 34 | allow(@server1).to receive(:provisioning_state).and_return("running") 35 | allow(@server1).to receive_message_chain( 36 | :storage_profile, :os_disk, :os_type 37 | ).and_return("linux") 38 | 39 | @server2 = double("server2", name: "MyVM2", id: double, location: "west-us") 40 | allow(@server2.id).to receive(:split).and_return(["", "subscriptions", "subscription_id", "resourcegroups", "myresourcegroup2", "Microsoft.compute", "virtualmachines", "MyVM2"]) 41 | allow(@server2.id.split[4]).to receive(:downcase).and_return("myresourcegroup2") 42 | allow(@server2).to receive(:provisioning_state).and_return("running") 43 | allow(@server2).to receive_message_chain( 44 | :storage_profile, :os_disk, :os_type 45 | ).and_return("linux") 46 | 47 | @server3 = double("server3", name: "MyVM3", id: double, location: "west-us") 48 | allow(@server3.id).to receive(:split).and_return(["", "subscriptions", "subscription_id", "resourcegroups", "myresourcegroup1", "Microsoft.compute", "virtualmachines", "MyVM3"]) 49 | allow(@server3.id.split[4]).to receive(:downcase).and_return("myresourcegroup1") 50 | allow(@server3).to receive(:provisioning_state).and_return("running") 51 | allow(@server3).to receive_message_chain( 52 | :storage_profile, :os_disk, :os_type 53 | ).and_return("windows") 54 | 55 | allow(@arm_server_instance.service).to receive( 56 | :compute_management_client 57 | ).and_return(@compute_client) 58 | allow_any_instance_of(Chef::Knife::AzurermBase).to receive(:get_azure_cli_version).and_return("1.0.0") 59 | end 60 | 61 | context "resource_group_name is not given" do 62 | before do 63 | @arm_server_instance.config.delete(:azure_resource_group_name) 64 | end 65 | 66 | it "should display only labels if there are no servers" do 67 | expect(@compute_client).to receive_message_chain( 68 | :virtual_machines, :list_all 69 | ).and_return([]) 70 | expect(@arm_server_instance.service).to receive(:display_list).with( 71 | @arm_server_instance.service.ui, 72 | ["VM Name", "Resource Group Name", "Location", "Provisioning State", "OS Type"], 73 | [] 74 | ) 75 | @arm_server_instance.run 76 | end 77 | 78 | it "should display VM Name, Location, Provisioning State and OS Type for all the VMs irrespective of the resource_group" do 79 | output_row = [@server1.name, @server1.id.split[4], @server1.location, @server1.provisioning_state, @server1.storage_profile.os_disk.os_type, 80 | @server2.name, @server2.id.split[4], @server2.location, @server2.provisioning_state, @server2.storage_profile.os_disk.os_type, 81 | @server3.name, @server3.id.split[4], @server3.location, @server3.provisioning_state, @server3.storage_profile.os_disk.os_type 82 | ] 83 | expect(@compute_client).to receive_message_chain( 84 | :virtual_machines, :list_all 85 | ).and_return( 86 | [@server1, @server2, @server3] 87 | ) 88 | expect(@arm_server_instance.service).to receive(:display_list).with( 89 | @arm_server_instance.service.ui, 90 | ["VM Name", "Resource Group Name", "Location", "Provisioning State", "OS Type"], 91 | output_row 92 | ) 93 | @arm_server_instance.run 94 | end 95 | end 96 | 97 | context "resource_group_name is given" do 98 | before do 99 | @arm_server_instance.config[:azure_resource_group_name] = "myresourcegroup1" 100 | end 101 | 102 | it "should display only labels if there are no servers under the given resource_group" do 103 | expect(@compute_client).to receive_message_chain( 104 | :virtual_machines, :list 105 | ).and_return([]) 106 | expect(@arm_server_instance.service).to receive(:display_list).with( 107 | @arm_server_instance.service.ui, 108 | ["VM Name", "Resource Group Name", "Location", "Provisioning State", "OS Type"], 109 | [] 110 | ) 111 | @arm_server_instance.run 112 | end 113 | 114 | it "should display VM Name, Location, Provisioning State and OS Type for all the VMs existing under the given resource_group" do 115 | output_row = [@server1.name, @server1.id.split[4], @server1.location, @server1.provisioning_state, @server1.storage_profile.os_disk.os_type, 116 | @server3.name, @server3.id.split[4], @server3.location, @server3.provisioning_state, @server3.storage_profile.os_disk.os_type 117 | ] 118 | expect(@compute_client).to receive_message_chain( 119 | :virtual_machines, :list 120 | ).and_return( 121 | [@server1, @server3] 122 | ) 123 | expect(@arm_server_instance.service).to receive(:display_list).with( 124 | @arm_server_instance.service.ui, 125 | ["VM Name", "Resource Group Name", "Location", "Provisioning State", "OS Type"], 126 | output_row 127 | ) 128 | @arm_server_instance.run 129 | end 130 | end 131 | end 132 | --------------------------------------------------------------------------------