azure-fix 0.7.0.pre3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.env_sample +13 -0
- data/.gitignore +30 -0
- data/.travis.yml +13 -0
- data/ChangeLog.txt +56 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +202 -0
- data/README.md +702 -0
- data/Rakefile +121 -0
- data/azure.gemspec +51 -0
- data/bin/pfxer +35 -0
- data/lib/azure.rb +147 -0
- data/lib/azure/base_management/affinity_group.rb +32 -0
- data/lib/azure/base_management/base_management_service.rb +220 -0
- data/lib/azure/base_management/location.rb +27 -0
- data/lib/azure/base_management/management_http_request.rb +172 -0
- data/lib/azure/base_management/serialization.rb +135 -0
- data/lib/azure/base_management/sql_management_http_request.rb +35 -0
- data/lib/azure/blob/auth/shared_access_signature.rb +147 -0
- data/lib/azure/blob/blob.rb +32 -0
- data/lib/azure/blob/blob_service.rb +1452 -0
- data/lib/azure/blob/block.rb +31 -0
- data/lib/azure/blob/container.rb +32 -0
- data/lib/azure/blob/serialization.rb +285 -0
- data/lib/azure/client.rb +31 -0
- data/lib/azure/client_services.rb +98 -0
- data/lib/azure/cloud_service_management/cloud_service.rb +38 -0
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +135 -0
- data/lib/azure/cloud_service_management/serialization.rb +118 -0
- data/lib/azure/configurable.rb +290 -0
- data/lib/azure/core/auth/authorizer.rb +36 -0
- data/lib/azure/core/auth/shared_key.rb +118 -0
- data/lib/azure/core/auth/shared_key_lite.rb +48 -0
- data/lib/azure/core/auth/signer.rb +51 -0
- data/lib/azure/core/error.rb +21 -0
- data/lib/azure/core/filtered_service.rb +45 -0
- data/lib/azure/core/http/debug_filter.rb +36 -0
- data/lib/azure/core/http/http_error.rb +86 -0
- data/lib/azure/core/http/http_filter.rb +53 -0
- data/lib/azure/core/http/http_request.rb +173 -0
- data/lib/azure/core/http/http_response.rb +96 -0
- data/lib/azure/core/http/retry_policy.rb +74 -0
- data/lib/azure/core/http/signer_filter.rb +33 -0
- data/lib/azure/core/service.rb +46 -0
- data/lib/azure/core/signed_service.rb +45 -0
- data/lib/azure/core/utility.rb +244 -0
- data/lib/azure/default.rb +126 -0
- data/lib/azure/http_client.rb +85 -0
- data/lib/azure/queue/message.rb +30 -0
- data/lib/azure/queue/queue.rb +28 -0
- data/lib/azure/queue/queue_service.rb +570 -0
- data/lib/azure/queue/serialization.rb +105 -0
- data/lib/azure/service/access_policy.rb +26 -0
- data/lib/azure/service/cors.rb +11 -0
- data/lib/azure/service/cors_rule.rb +15 -0
- data/lib/azure/service/enumeration_results.rb +21 -0
- data/lib/azure/service/logging.rb +32 -0
- data/lib/azure/service/metrics.rb +31 -0
- data/lib/azure/service/retention_policy.rb +25 -0
- data/lib/azure/service/serialization.rb +299 -0
- data/lib/azure/service/signed_identifier.rb +30 -0
- data/lib/azure/service/storage_service.rb +86 -0
- data/lib/azure/service/storage_service_properties.rb +37 -0
- data/lib/azure/service_bus/action.rb +21 -0
- data/lib/azure/service_bus/auth/shared_access_signer.rb +44 -0
- data/lib/azure/service_bus/auth/wrap_service.rb +90 -0
- data/lib/azure/service_bus/auth/wrap_signer.rb +77 -0
- data/lib/azure/service_bus/brokered_message.rb +124 -0
- data/lib/azure/service_bus/brokered_message_serializer.rb +159 -0
- data/lib/azure/service_bus/correlation_filter.rb +45 -0
- data/lib/azure/service_bus/empty_rule_action.rb +30 -0
- data/lib/azure/service_bus/false_filter.rb +38 -0
- data/lib/azure/service_bus/filter.rb +21 -0
- data/lib/azure/service_bus/interval.rb +104 -0
- data/lib/azure/service_bus/queue.rb +230 -0
- data/lib/azure/service_bus/relay.rb +88 -0
- data/lib/azure/service_bus/resource.rb +109 -0
- data/lib/azure/service_bus/rule.rb +98 -0
- data/lib/azure/service_bus/rule_aspect.rb +34 -0
- data/lib/azure/service_bus/serialization.rb +161 -0
- data/lib/azure/service_bus/service_bus_service.rb +899 -0
- data/lib/azure/service_bus/sql_filter.rb +50 -0
- data/lib/azure/service_bus/sql_rule_action.rb +50 -0
- data/lib/azure/service_bus/subscription.rb +184 -0
- data/lib/azure/service_bus/topic.rb +187 -0
- data/lib/azure/service_bus/true_filter.rb +38 -0
- data/lib/azure/sql_database_management/errors.rb +11 -0
- data/lib/azure/sql_database_management/firewall_rule.rb +30 -0
- data/lib/azure/sql_database_management/serialization.rb +99 -0
- data/lib/azure/sql_database_management/sql_database_management_service.rb +211 -0
- data/lib/azure/sql_database_management/sql_server.rb +32 -0
- data/lib/azure/storage_management/serialization.rb +204 -0
- data/lib/azure/storage_management/storage_account.rb +48 -0
- data/lib/azure/storage_management/storage_management_service.rb +207 -0
- data/lib/azure/table/auth/shared_key.rb +59 -0
- data/lib/azure/table/auth/shared_key_lite.rb +44 -0
- data/lib/azure/table/batch.rb +330 -0
- data/lib/azure/table/batch_response.rb +118 -0
- data/lib/azure/table/edmtype.rb +127 -0
- data/lib/azure/table/entity.rb +31 -0
- data/lib/azure/table/guid.rb +24 -0
- data/lib/azure/table/query.rb +112 -0
- data/lib/azure/table/serialization.rb +108 -0
- data/lib/azure/table/table_service.rb +563 -0
- data/lib/azure/version.rb +31 -0
- data/lib/azure/virtual_machine_image_management/serialization.rb +70 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_disk.rb +25 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +25 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +83 -0
- data/lib/azure/virtual_machine_management/serialization.rb +459 -0
- data/lib/azure/virtual_machine_management/virtual_machine.rb +44 -0
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +552 -0
- data/lib/azure/virtual_network_management/serialization.rb +193 -0
- data/lib/azure/virtual_network_management/virtual_network.rb +37 -0
- data/lib/azure/virtual_network_management/virtual_network_management_service.rb +108 -0
- data/test/fixtures/32px-fulls-black.jpg +0 -0
- data/test/fixtures/affinity_group.xml +33 -0
- data/test/fixtures/all_containers.xml +20 -0
- data/test/fixtures/all_tables.xml +22 -0
- data/test/fixtures/container_acl.xml +11 -0
- data/test/fixtures/create_sql_database_server.xml +2 -0
- data/test/fixtures/create_storage_desc_error.xml +5 -0
- data/test/fixtures/create_storage_extendedprop_error.xml +8 -0
- data/test/fixtures/create_storage_extendedpropname_error.xml +6 -0
- data/test/fixtures/create_storage_full_error.xml +6 -0
- data/test/fixtures/create_storage_label_error.xml +5 -0
- data/test/fixtures/create_storage_location_error.xml +5 -0
- data/test/fixtures/create_storage_name_error.xml +6 -0
- data/test/fixtures/create_table_response_entry.xml +15 -0
- data/test/fixtures/delete_storage_container_error.xml +5 -0
- data/test/fixtures/delete_storage_error.xml +5 -0
- data/test/fixtures/deployment_error.xml +5 -0
- data/test/fixtures/empty_xml_file +0 -0
- data/test/fixtures/get_storage_account_error.xml +5 -0
- data/test/fixtures/get_storage_account_properties.xml +34 -0
- data/test/fixtures/get_storage_account_properties_new.xml +32 -0
- data/test/fixtures/http_error.xml +5 -0
- data/test/fixtures/insert_entity_response_entry.xml +25 -0
- data/test/fixtures/list_affinity_groups.xml +22 -0
- data/test/fixtures/list_blobs.xml +121 -0
- data/test/fixtures/list_block_all_with_none_committed.xml +22 -0
- data/test/fixtures/list_blocks_all.xml +23 -0
- data/test/fixtures/list_blocks_committed.xml +13 -0
- data/test/fixtures/list_cloud_services.xml +39 -0
- data/test/fixtures/list_containers.xml +38 -0
- data/test/fixtures/list_firewall_management_endpoint.xml +27 -0
- data/test/fixtures/list_locations.xml +212 -0
- data/test/fixtures/list_os_images.xml +110 -0
- data/test/fixtures/list_page_ranges.xml +11 -0
- data/test/fixtures/list_sql_database.xml +24 -0
- data/test/fixtures/list_sql_server_firewall.xml +23 -0
- data/test/fixtures/list_storage_account_single.xml +25 -0
- data/test/fixtures/list_storage_accounts.xml +48 -0
- data/test/fixtures/list_virtual_networks.xml +92 -0
- data/test/fixtures/list_vm_images.xml +21 -0
- data/test/fixtures/logging.xml +11 -0
- data/test/fixtures/management_certificate.pfx +0 -0
- data/test/fixtures/messages.xml +12 -0
- data/test/fixtures/metrics.xml +10 -0
- data/test/fixtures/privatekey.key +28 -0
- data/test/fixtures/query_entities_empty_response.xml +7 -0
- data/test/fixtures/query_entities_response.xml +45 -0
- data/test/fixtures/queue_service_properties.xml +22 -0
- data/test/fixtures/queue_service_properties_original.xml +19 -0
- data/test/fixtures/queues.xml +16 -0
- data/test/fixtures/retention_policy.xml +5 -0
- data/test/fixtures/sb_default_create_queue_response.xml +23 -0
- data/test/fixtures/sb_default_create_relay_response.xml +15 -0
- data/test/fixtures/sb_default_create_topic_response.xml +18 -0
- data/test/fixtures/sb_get_access_token_response.txt +1 -0
- data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +9 -0
- data/test/fixtures/storage_service_keys.xml +8 -0
- data/test/fixtures/storage_service_properties.xml +55 -0
- data/test/fixtures/update_storage_account.xml +16 -0
- data/test/fixtures/update_storage_error.xml +5 -0
- data/test/fixtures/updated_storage_accounts.xml +55 -0
- data/test/fixtures/virtual_machine.xml +116 -0
- data/test/fixtures/windows_virtual_machine.xml +106 -0
- data/test/integration/affinity_group/Affinity_test.rb +55 -0
- data/test/integration/affinity_group/Create_Affinity_test.rb +64 -0
- data/test/integration/affinity_group/Delete_Affinity_test.rb +56 -0
- data/test/integration/affinity_group/List_Affinity_test.rb +41 -0
- data/test/integration/affinity_group/Update_Affinity_test.rb +87 -0
- data/test/integration/blob/blob_gb18030_test.rb +199 -0
- data/test/integration/blob/blob_metadata_test.rb +75 -0
- data/test/integration/blob/blob_pages_test.rb +119 -0
- data/test/integration/blob/blob_properties_test.rb +77 -0
- data/test/integration/blob/block_blob_test.rb +254 -0
- data/test/integration/blob/container/container_acl_test.rb +69 -0
- data/test/integration/blob/container/container_metadata_test.rb +50 -0
- data/test/integration/blob/container/create_container_test.rb +60 -0
- data/test/integration/blob/container/delete_container_test.rb +39 -0
- data/test/integration/blob/container/get_container_properties_test.rb +48 -0
- data/test/integration/blob/container/list_containers_test.rb +79 -0
- data/test/integration/blob/container/root_container_test.rb +55 -0
- data/test/integration/blob/copy_blob_test.rb +113 -0
- data/test/integration/blob/create_blob_snapshot_test.rb +80 -0
- data/test/integration/blob/create_page_blob_test.rb +83 -0
- data/test/integration/blob/delete_blob_test.rb +159 -0
- data/test/integration/blob/get_blob_test.rb +65 -0
- data/test/integration/blob/informative_errors_test.rb +39 -0
- data/test/integration/blob/lease/acquire_lease_test.rb +36 -0
- data/test/integration/blob/lease/break_lease_test.rb +40 -0
- data/test/integration/blob/lease/release_lease_test.rb +40 -0
- data/test/integration/blob/lease/renew_lease_test.rb +42 -0
- data/test/integration/blob/list_blobs_test.rb +113 -0
- data/test/integration/cloud_service/Cloud_Create_test.rb +45 -0
- data/test/integration/cloud_service/Cloud_Delete_test.rb +45 -0
- data/test/integration/database/create_sql_server_firewall_test.rb +81 -0
- data/test/integration/database/create_sql_server_test.rb +53 -0
- data/test/integration/database/delete_sql_server_firewall_test.rb +64 -0
- data/test/integration/database/delete_sql_server_test.rb +45 -0
- data/test/integration/database/list_sql_server_firewall_test.rb +44 -0
- data/test/integration/database/list_sql_servers_test.rb +44 -0
- data/test/integration/database/reset_password_sql_server_test.rb +53 -0
- data/test/integration/location/Location_List_test.rb +39 -0
- data/test/integration/location/RoleSize_List_test.rb +35 -0
- data/test/integration/queue/clear_messages_test.rb +42 -0
- data/test/integration/queue/create_message_test.rb +75 -0
- data/test/integration/queue/create_queue_test.rb +50 -0
- data/test/integration/queue/delete_message_test.rb +67 -0
- data/test/integration/queue/delete_queue_test.rb +45 -0
- data/test/integration/queue/informative_errors_test.rb +42 -0
- data/test/integration/queue/list_messages_encoded_test.rb +79 -0
- data/test/integration/queue/list_messages_test.rb +79 -0
- data/test/integration/queue/list_queues_test.rb +43 -0
- data/test/integration/queue/peek_messages_test.rb +59 -0
- data/test/integration/queue/queue_gb18030_test.rb +131 -0
- data/test/integration/queue/queue_metadata_test.rb +40 -0
- data/test/integration/queue/update_message_test.rb +74 -0
- data/test/integration/service_bus/informative_errors_test.rb +37 -0
- data/test/integration/service_bus/queues_scenario_test.rb +200 -0
- data/test/integration/service_bus/queues_test.rb +266 -0
- data/test/integration/service_bus/relay_test.rb +132 -0
- data/test/integration/service_bus/rules_test.rb +145 -0
- data/test/integration/service_bus/sb_queue_gb18030_test.rb +182 -0
- data/test/integration/service_bus/scenario_test.rb +101 -0
- data/test/integration/service_bus/subscriptions_test.rb +211 -0
- data/test/integration/service_bus/topics_scenario_test.rb +406 -0
- data/test/integration/service_bus/topics_test.rb +129 -0
- data/test/integration/storage_management/storage_management_test.rb +185 -0
- data/test/integration/table/create_table_test.rb +36 -0
- data/test/integration/table/delete_entity_batch_test.rb +107 -0
- data/test/integration/table/delete_entity_test.rb +94 -0
- data/test/integration/table/delete_table_test.rb +40 -0
- data/test/integration/table/get_table_test.rb +37 -0
- data/test/integration/table/informative_errors_test.rb +39 -0
- data/test/integration/table/insert_entity_batch_test.rb +100 -0
- data/test/integration/table/insert_entity_test.rb +88 -0
- data/test/integration/table/insert_or_merge_entity_batch_test.rb +159 -0
- data/test/integration/table/insert_or_merge_entity_test.rb +143 -0
- data/test/integration/table/insert_or_replace_entity_batch_test.rb +152 -0
- data/test/integration/table/insert_or_replace_entity_test.rb +137 -0
- data/test/integration/table/merge_entity_batch_test.rb +128 -0
- data/test/integration/table/merge_entity_test.rb +113 -0
- data/test/integration/table/query_entities_test.rb +196 -0
- data/test/integration/table/query_tables_test.rb +43 -0
- data/test/integration/table/query_test.rb +251 -0
- data/test/integration/table/table_acl_test.rb +52 -0
- data/test/integration/table/table_gb18030_test.rb +355 -0
- data/test/integration/table/update_entity_batch_test.rb +149 -0
- data/test/integration/table/update_entity_test.rb +131 -0
- data/test/integration/test_helper.rb +40 -0
- data/test/integration/vm/VM_Create_test.rb +262 -0
- data/test/integration/vm/VM_Delete_test.rb +53 -0
- data/test/integration/vm/VM_Operations_test.rb +172 -0
- data/test/integration/vm_image/virtual_machine_disk_test.rb +37 -0
- data/test/integration/vm_image/virtual_machine_image_test.rb +37 -0
- data/test/integration/vnet/Virtual_Network_Create_test.rb +116 -0
- data/test/integration/vnet/Virtual_Network_list_test.rb +48 -0
- data/test/support/env.rb +19 -0
- data/test/support/fixtures.rb +36 -0
- data/test/support/name_generator.rb +168 -0
- data/test/support/stubs.rb +42 -0
- data/test/support/virtual_machine_name_generator.rb +102 -0
- data/test/support/virtual_network_helper.rb +73 -0
- data/test/test_helper.rb +47 -0
- data/test/unit/affinity_group/affinity_group_test.rb +189 -0
- data/test/unit/affinity_group/serialization_test.rb +87 -0
- data/test/unit/base_management/base_management_service_test.rb +19 -0
- data/test/unit/base_management/location_test.rb +56 -0
- data/test/unit/base_management/role_size_test.rb +50 -0
- data/test/unit/blob/auth/shared_access_signature_test.rb +71 -0
- data/test/unit/blob/blob_service_test.rb +1970 -0
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +94 -0
- data/test/unit/cloud_service_management/serialization_test.rb +169 -0
- data/test/unit/config/azure_test.rb +112 -0
- data/test/unit/config/client_test.rb +37 -0
- data/test/unit/core/auth/shared_key_lite_test.rb +51 -0
- data/test/unit/core/auth/shared_key_test.rb +58 -0
- data/test/unit/core/auth/signer_test.rb +30 -0
- data/test/unit/core/http/http_error_test.rb +61 -0
- data/test/unit/core/http/http_request_test.rb +138 -0
- data/test/unit/core/http/http_response_test.rb +20 -0
- data/test/unit/core/http/retry_policy_test.rb +23 -0
- data/test/unit/core/utility_test.rb +122 -0
- data/test/unit/database/serialization_test.rb +94 -0
- data/test/unit/database/sql_database_server_service_test.rb +341 -0
- data/test/unit/http_client_test.rb +74 -0
- data/test/unit/service/serialization_test.rb +533 -0
- data/test/unit/service/storage_service_test.rb +297 -0
- data/test/unit/storage_management/serialization_test.rb +244 -0
- data/test/unit/storage_management/storage_management_service_test.rb +247 -0
- data/test/unit/table/edmtype_test.rb +108 -0
- data/test/unit/virtual_machine_image_management/serialization_test.rb +50 -0
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +114 -0
- data/test/unit/virtual_machine_management/serialization_test.rb +316 -0
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +480 -0
- data/test/unit/vnet/serialization_test.rb +187 -0
- data/test/unit/vnet/virtual_network_management_service_test.rb +131 -0
- metadata +579 -0
data/Rakefile
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
require 'rake/testtask'
|
|
16
|
+
require 'rubygems/package_task'
|
|
17
|
+
require 'dotenv/tasks'
|
|
18
|
+
|
|
19
|
+
gem_spec = eval(File.read('./azure.gemspec'))
|
|
20
|
+
Gem::PackageTask.new(gem_spec) do |pkg|
|
|
21
|
+
pkg.need_zip = false
|
|
22
|
+
pkg.need_tar = false
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
namespace :test do
|
|
26
|
+
task :require_environment => :dotenv do
|
|
27
|
+
unset_environment = [
|
|
28
|
+
ENV.fetch('AZURE_STORAGE_ACCOUNT', nil),
|
|
29
|
+
ENV.fetch('AZURE_STORAGE_ACCESS_KEY', nil),
|
|
30
|
+
ENV.fetch('AZURE_SERVICEBUS_NAMESPACE', nil),
|
|
31
|
+
ENV.fetch('AZURE_SERVICEBUS_ACCESS_KEY', nil),
|
|
32
|
+
ENV.fetch('AZURE_MANAGEMENT_CERTIFICATE', nil),
|
|
33
|
+
ENV.fetch('AZURE_SUBSCRIPTION_ID', nil)
|
|
34
|
+
].include?(nil)
|
|
35
|
+
|
|
36
|
+
abort '[ABORTING] Configure your environment to run the integration tests' if unset_environment
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
Rake::TestTask.new :unit do |t|
|
|
40
|
+
t.pattern = 'test/unit/**/*_test.rb'
|
|
41
|
+
t.verbose = true
|
|
42
|
+
t.libs = %w(lib test)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
namespace :unit do
|
|
46
|
+
def component_task(component)
|
|
47
|
+
Rake::TestTask.new component do |t|
|
|
48
|
+
t.pattern = "test/unit/#{component}/**/*_test.rb"
|
|
49
|
+
t.verbose = true
|
|
50
|
+
t.libs = %w(lib test)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
component_task :affinity_group
|
|
55
|
+
component_task :base_management
|
|
56
|
+
component_task :blob
|
|
57
|
+
component_task :cloud_service_management
|
|
58
|
+
component_task :core
|
|
59
|
+
component_task :database
|
|
60
|
+
component_task :service
|
|
61
|
+
component_task :storage_management
|
|
62
|
+
component_task :table
|
|
63
|
+
component_task :virtual_machine_image_management
|
|
64
|
+
component_task :virtual_machine_management
|
|
65
|
+
component_task :vnet
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
Rake::TestTask.new :integration do |t|
|
|
69
|
+
t.test_files = Dir['test/integration/**/*_test.rb'].reject do |path|
|
|
70
|
+
path.include?('database')
|
|
71
|
+
end
|
|
72
|
+
t.verbose = true
|
|
73
|
+
t.libs = %w(lib test)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
task :integration => :require_environment
|
|
77
|
+
|
|
78
|
+
namespace :integration do
|
|
79
|
+
def component_task(component)
|
|
80
|
+
Rake::TestTask.new component do |t|
|
|
81
|
+
t.pattern = "test/integration/#{component}/**/*_test.rb"
|
|
82
|
+
t.verbose = true
|
|
83
|
+
t.libs = %w(lib test)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
task component => 'test:require_environment'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
component_task :affinity_group
|
|
90
|
+
component_task :blob
|
|
91
|
+
component_task :database
|
|
92
|
+
component_task :location
|
|
93
|
+
component_task :queue
|
|
94
|
+
component_task :service_bus
|
|
95
|
+
component_task :storage_management
|
|
96
|
+
component_task :table
|
|
97
|
+
component_task :vm
|
|
98
|
+
component_task :vm_image
|
|
99
|
+
component_task :vnet
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
task :cleanup => :require_environment do
|
|
103
|
+
$:.unshift 'lib'
|
|
104
|
+
require 'azure'
|
|
105
|
+
|
|
106
|
+
Azure.configure do |config|
|
|
107
|
+
config.access_key = ENV.fetch('AZURE_STORAGE_ACCESS_KEY')
|
|
108
|
+
config.account_name = ENV.fetch('AZURE_STORAGE_ACCOUNT')
|
|
109
|
+
config.acs_namespace = ENV.fetch('AZURE_SERVICEBUS_NAMESPACE')
|
|
110
|
+
config.sb_access_key = ENV.fetch('AZURE_SERVICEBUS_ACCESS_KEY')
|
|
111
|
+
config.management_certificate = ENV.fetch('AZURE_MANAGEMENT_CERTIFICATE')
|
|
112
|
+
config.management_endpoint = ENV.fetch('AZURE_MANAGEMENT_ENDPOINT')
|
|
113
|
+
config.sql_database_management_endpoint = ENV.fetch('AZURE_SQL_DATABASE_MANAGEMENT_ENDPOINT')
|
|
114
|
+
config.subscription_id = ENV.fetch('AZURE_SUBSCRIPTION_ID')
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
task :test => %w(test:unit test:integration)
|
|
120
|
+
|
|
121
|
+
task :default => :test
|
data/azure.gemspec
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
require 'date'
|
|
16
|
+
|
|
17
|
+
require File.expand_path('../lib/azure/version', __FILE__)
|
|
18
|
+
|
|
19
|
+
Gem::Specification.new do |s|
|
|
20
|
+
s.name = 'azure-fix'
|
|
21
|
+
s.version = Azure::Version
|
|
22
|
+
s.authors = ['Microsoft Corporation', 'AppFog']
|
|
23
|
+
s.email = 'azureruby@microsoft.com'
|
|
24
|
+
s.description = 'Microsoft Azure Client Library for Ruby'
|
|
25
|
+
s.summary = 'Official ruby client library to consume Microsoft Azure services.'
|
|
26
|
+
s.homepage = 'http://github.com/azure/azure-sdk-for-ruby'
|
|
27
|
+
s.license = 'Apache License, Version 2.0'
|
|
28
|
+
s.files = `git ls-files`.split("\n")
|
|
29
|
+
s.bindir = 'bin'
|
|
30
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
31
|
+
|
|
32
|
+
s.required_ruby_version = '>= 1.9.3'
|
|
33
|
+
|
|
34
|
+
s.add_runtime_dependency('addressable', '~> 2.3')
|
|
35
|
+
s.add_runtime_dependency('faraday', '~> 0.9')
|
|
36
|
+
s.add_runtime_dependency('faraday_middleware', '~> 0.10')
|
|
37
|
+
s.add_runtime_dependency('json', '~> 1.8')
|
|
38
|
+
s.add_runtime_dependency('mime-types', '< 2.0')
|
|
39
|
+
s.add_runtime_dependency('nokogiri', '~> 1.6')
|
|
40
|
+
s.add_runtime_dependency('systemu', '~> 2.6')
|
|
41
|
+
s.add_runtime_dependency('thor', '~> 0.19')
|
|
42
|
+
s.add_runtime_dependency('uuid', '~> 2.0')
|
|
43
|
+
|
|
44
|
+
s.add_development_dependency('dotenv', '~> 2.0')
|
|
45
|
+
s.add_development_dependency('minitest', '~> 5')
|
|
46
|
+
s.add_development_dependency('minitest-reporters', '~> 1')
|
|
47
|
+
s.add_development_dependency('mocha', '~> 1.0')
|
|
48
|
+
s.add_development_dependency('rake', '~> 10.0')
|
|
49
|
+
s.add_development_dependency('timecop', '~> 0.7')
|
|
50
|
+
s.add_development_dependency('yard', '~> 0.8')
|
|
51
|
+
end
|
data/bin/pfxer
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env ruby -U
|
|
2
|
+
|
|
3
|
+
require 'azure'
|
|
4
|
+
require 'thor'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
7
|
+
module Azure
|
|
8
|
+
class Pfxer < Thor
|
|
9
|
+
desc 'transform', 'Transforms a publish settings file from Azure into a .pfx'
|
|
10
|
+
|
|
11
|
+
long_desc <<-TRANSFORM
|
|
12
|
+
|
|
13
|
+
`transform` will create a .pfx file from an Azure publish settings file. The publish settings file contains a
|
|
14
|
+
pfx, but the pfx is base64 encode within the publish settings xml structure. This is here to make that a little
|
|
15
|
+
easier.
|
|
16
|
+
|
|
17
|
+
TRANSFORM
|
|
18
|
+
|
|
19
|
+
option :in, required: true, desc: 'Path to publish settings file'
|
|
20
|
+
option :out, desc: 'Path to where you want your .pfx'
|
|
21
|
+
def transform
|
|
22
|
+
path = File.expand_path(options[:in])
|
|
23
|
+
if File.exists?(path)
|
|
24
|
+
pub_settings_xml = Nokogiri::XML(File.read(path))
|
|
25
|
+
b64_pfx = pub_settings_xml.css('PublishData PublishProfile Subscription')[0]['ManagementCertificate']
|
|
26
|
+
pfx = Base64.decode64(b64_pfx)
|
|
27
|
+
file_name = File.basename(path, '.publishsettings').downcase.gsub(' ', '_')
|
|
28
|
+
out_path = options[:out] || File.join(File.dirname(path), file_name + '.pfx')
|
|
29
|
+
File.binwrite(File.expand_path(out_path), pfx)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Azure::Pfxer.start(ARGV)
|
data/lib/azure.rb
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
require 'rubygems'
|
|
17
|
+
require 'nokogiri'
|
|
18
|
+
require 'base64'
|
|
19
|
+
require 'openssl'
|
|
20
|
+
require 'uri'
|
|
21
|
+
require 'rexml/document'
|
|
22
|
+
require 'addressable/uri'
|
|
23
|
+
require 'faraday'
|
|
24
|
+
require 'faraday_middleware'
|
|
25
|
+
|
|
26
|
+
module Azure
|
|
27
|
+
autoload :Client, 'azure/client'
|
|
28
|
+
autoload :ClientServices, 'azure/client_services'
|
|
29
|
+
autoload :Configurable, 'azure/configurable'
|
|
30
|
+
autoload :Default, 'azure/default'
|
|
31
|
+
autoload :HttpClient, 'azure/http_client'
|
|
32
|
+
autoload :Version, 'azure/version'
|
|
33
|
+
|
|
34
|
+
# helpers because the naming is far too verbose
|
|
35
|
+
autoload :BaseManagementService, 'azure/base_management/base_management_service'
|
|
36
|
+
autoload :CloudServiceManagementService, 'azure/cloud_service_management/cloud_service_management_service'
|
|
37
|
+
autoload :SqlDatabaseManagementService, 'azure/sql_database_management/sql_database_management_service'
|
|
38
|
+
autoload :StorageManagementService, 'azure/storage_management/storage_management_service'
|
|
39
|
+
autoload :VirtualMachineImageManagementService, 'azure/virtual_machine_image_management/virtual_machine_image_management_service'
|
|
40
|
+
autoload :VirtualMachineManagementService, 'azure/virtual_machine_management/virtual_machine_management_service'
|
|
41
|
+
autoload :VirtualNetworkManagementService, 'azure/virtual_network_management/virtual_network_management_service'
|
|
42
|
+
|
|
43
|
+
module BaseManagement
|
|
44
|
+
autoload :ManagementHttpRequest, 'azure/base_management/management_http_request'
|
|
45
|
+
autoload :SqlManagementHttpRequest, 'azure/base_management/sql_management_http_request'
|
|
46
|
+
autoload :BaseManagementService, 'azure/base_management/base_management_service'
|
|
47
|
+
autoload :Location, 'azure/base_management/location'
|
|
48
|
+
autoload :AffinityGroup, 'azure/base_management/affinity_group'
|
|
49
|
+
autoload :Serialization, 'azure/base_management/serialization'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
module Blob
|
|
53
|
+
autoload :BlobService, 'azure/blob/blob_service'
|
|
54
|
+
autoload :Blob, 'azure/blob/blob'
|
|
55
|
+
autoload :Block, 'azure/blob/block'
|
|
56
|
+
autoload :Container, 'azure/blob/container'
|
|
57
|
+
autoload :Serialization, 'azure/blob/serialization'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
module CloudServiceManagement
|
|
61
|
+
autoload :CloudServiceManagementService, 'azure/cloud_service_management/cloud_service_management_service'
|
|
62
|
+
autoload :CloudService, 'azure/cloud_service_management/cloud_service'
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
module Core
|
|
66
|
+
autoload :Utility, 'azure/core/utility'
|
|
67
|
+
autoload :Logger, 'azure/core/utility'
|
|
68
|
+
autoload :Error, 'azure/core/error'
|
|
69
|
+
autoload :Service, 'azure/core/service'
|
|
70
|
+
autoload :FilteredService, 'azure/core/filtered_service'
|
|
71
|
+
autoload :SignedService, 'azure/core/signed_service'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
module Queue
|
|
75
|
+
autoload :QueueService, 'azure/queue/queue_service'
|
|
76
|
+
autoload :Message, 'azure/queue/message'
|
|
77
|
+
autoload :Queue, 'azure/queue/queue'
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
module ServiceBus
|
|
81
|
+
autoload :ServiceBusService, 'azure/service_bus/service_bus_service'
|
|
82
|
+
autoload :EmptyRuleAction, 'azure/service_bus/empty_rule_action'
|
|
83
|
+
autoload :SqlRuleAction, 'azure/service_bus/sql_rule_action'
|
|
84
|
+
autoload :SqlFilter, 'azure/service_bus/sql_filter'
|
|
85
|
+
autoload :TrueFilter, 'azure/service_bus/true_filter'
|
|
86
|
+
autoload :CorrelationFilter, 'azure/service_bus/correlation_filter'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
module SqlDatabaseManagement
|
|
90
|
+
autoload :SqlDatabaseManagementService, 'azure/sql_database_management/sql_database_management_service'
|
|
91
|
+
autoload :Serialization, 'azure/sql_database_management/serialization'
|
|
92
|
+
autoload :SqlServer, 'azure/sql_database_management/sql_server'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
module StorageManagement
|
|
96
|
+
autoload :StorageManagementService, 'azure/storage_management/storage_management_service'
|
|
97
|
+
autoload :Serialization, 'azure/storage_management/serialization'
|
|
98
|
+
autoload :StorageAccount, 'azure/storage_management/storage_account'
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
module Table
|
|
102
|
+
autoload :TableService, 'azure/table/table_service'
|
|
103
|
+
autoload :Batch, 'azure/table/batch'
|
|
104
|
+
autoload :Query, 'azure/table/query'
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
module VirtualMachineImageManagement
|
|
108
|
+
autoload :VirtualMachineImageManagementService, 'azure/virtual_machine_image_management/virtual_machine_image_management_service'
|
|
109
|
+
autoload :Serialization, 'azure/virtual_machine_image_management/serialization'
|
|
110
|
+
autoload :VirtualMachineImage, 'azure/virtual_machine_image_management/virtual_machine_image'
|
|
111
|
+
autoload :VirtualMachineDisk, 'azure/virtual_machine_image_management/virtual_machine_disk'
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
module VirtualMachineManagement
|
|
115
|
+
autoload :VirtualMachineManagementService, 'azure/virtual_machine_management/virtual_machine_management_service'
|
|
116
|
+
autoload :Serialization, 'azure/virtual_machine_management/serialization'
|
|
117
|
+
autoload :VirtualMachine, 'azure/virtual_machine_management/virtual_machine'
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
module VirtualNetworkManagement
|
|
121
|
+
autoload :VirtualNetworkManagementService, 'azure/virtual_network_management/virtual_network_management_service'
|
|
122
|
+
autoload :Serialization, 'azure/virtual_network_management/serialization'
|
|
123
|
+
autoload :VirtualNetwork, 'azure/virtual_network_management/virtual_network'
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
class << self
|
|
127
|
+
include Azure::Configurable
|
|
128
|
+
|
|
129
|
+
# API client based on configured options {Configurable}
|
|
130
|
+
#
|
|
131
|
+
# @return [Azure::Client] API wrapper
|
|
132
|
+
def client(options = {})
|
|
133
|
+
@client = Azure::Client.new(options) unless defined?(@client) && @client.same_options?(options)
|
|
134
|
+
@client
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
private
|
|
138
|
+
|
|
139
|
+
def method_missing(method_name, *args, &block)
|
|
140
|
+
return super unless client.respond_to?(method_name)
|
|
141
|
+
client.send(method_name, *args, &block)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
Azure.setup
|
|
147
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright 2013 Microsoft Open Technologies, Inc.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
module Azure
|
|
16
|
+
module BaseManagement
|
|
17
|
+
# Represents an AffinityGroup
|
|
18
|
+
class AffinityGroup
|
|
19
|
+
def initialize
|
|
20
|
+
yield self if block_given?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
attr_accessor :name
|
|
24
|
+
attr_accessor :label
|
|
25
|
+
attr_accessor :description
|
|
26
|
+
attr_accessor :location
|
|
27
|
+
attr_accessor :hosted_services
|
|
28
|
+
attr_accessor :storage_services
|
|
29
|
+
attr_accessor :capability
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
#-------------------------------------------------------------------------
|
|
2
|
+
# Copyright 2013 Microsoft Open Technologies, Inc.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
#--------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
require 'azure/base_management/serialization'
|
|
17
|
+
require 'azure/base_management/location'
|
|
18
|
+
require 'azure/base_management/affinity_group'
|
|
19
|
+
|
|
20
|
+
module Azure
|
|
21
|
+
module BaseManagement
|
|
22
|
+
|
|
23
|
+
# The base for all Azure management services
|
|
24
|
+
# @!attribute [rw] client
|
|
25
|
+
# The client contains the configuration scope and the ability to produce http agents.
|
|
26
|
+
# defaults to global client.
|
|
27
|
+
# @see Azure.client
|
|
28
|
+
# @return [Azure::Client]
|
|
29
|
+
class BaseManagementService
|
|
30
|
+
|
|
31
|
+
attr_accessor :client
|
|
32
|
+
|
|
33
|
+
# @param options [Hash] options including :client
|
|
34
|
+
def initialize(options = {})
|
|
35
|
+
@client = options[:client] || Azure.client
|
|
36
|
+
validate_configuration!
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Validate the configuration of the service.
|
|
40
|
+
# @return [void]
|
|
41
|
+
def validate_configuration!
|
|
42
|
+
subs_id = @client.subscription_id
|
|
43
|
+
error_message = 'Subscription ID not valid.'
|
|
44
|
+
raise ArgumentError.new(error_message) if subs_id.nil? || subs_id.empty?
|
|
45
|
+
|
|
46
|
+
m_ep = @client.management_endpoint
|
|
47
|
+
error_message = 'Management endpoint not valid.'
|
|
48
|
+
raise ArgumentError.new(error_message) if m_ep.nil? || m_ep.empty?
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Gets a list of regional data center locations from the server
|
|
52
|
+
# @return [Array<Azure::BaseManagement::Location>]
|
|
53
|
+
def list_locations
|
|
54
|
+
request = @client.management_request(:get, '/locations')
|
|
55
|
+
response = request.call
|
|
56
|
+
Serialization.locations_from_xml(response)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Gets a list of role sizes associated with the
|
|
60
|
+
# specified subscription.
|
|
61
|
+
# @return [Array<String>]
|
|
62
|
+
def list_role_sizes
|
|
63
|
+
role_sizes = []
|
|
64
|
+
locations = list_locations
|
|
65
|
+
locations.each do | location |
|
|
66
|
+
role_sizes << location.role_sizes
|
|
67
|
+
end
|
|
68
|
+
role_sizes.flatten.uniq.compact.sort
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Gets a lists the affinity groups associated with
|
|
72
|
+
# the specified subscription.
|
|
73
|
+
# @see http://msdn.microsoft.com/en-us/library/azure/ee460797.aspx
|
|
74
|
+
# @return [Array<Azure::BaseManagement::AffinityGroup>]
|
|
75
|
+
def list_affinity_groups
|
|
76
|
+
request_path = '/affinitygroups'
|
|
77
|
+
request = @client.management_request(:get, request_path)
|
|
78
|
+
response = request.call
|
|
79
|
+
Serialization.affinity_groups_from_xml(response)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Creates a new affinity group for the specified subscription.
|
|
83
|
+
#
|
|
84
|
+
# ==== Attributes
|
|
85
|
+
#
|
|
86
|
+
# * +name+ - String. Affinity Group name.
|
|
87
|
+
# * +location+ - String. The location where the affinity group will
|
|
88
|
+
# be created.
|
|
89
|
+
# * +label+ - String. Name for the affinity specified as a
|
|
90
|
+
# base-64 encoded string.
|
|
91
|
+
#
|
|
92
|
+
# ==== Options
|
|
93
|
+
#
|
|
94
|
+
# Accepted key/value pairs are:
|
|
95
|
+
# * +:description+ - String. A description for the affinity group.
|
|
96
|
+
# (optional)
|
|
97
|
+
#
|
|
98
|
+
# @see http://msdn.microsoft.com/en-us/library/azure/gg715317.aspx
|
|
99
|
+
#
|
|
100
|
+
# @return [void]
|
|
101
|
+
def create_affinity_group(name, location, label, options = {})
|
|
102
|
+
if name.nil? || name.strip.empty?
|
|
103
|
+
raise 'Affinity Group name cannot be empty'
|
|
104
|
+
elsif list_affinity_groups.map(&:name).include?(name)
|
|
105
|
+
raise Azure::Error::Error.new(
|
|
106
|
+
'ConflictError',
|
|
107
|
+
409,
|
|
108
|
+
"An affinity group #{name} already exists in the current subscription."
|
|
109
|
+
)
|
|
110
|
+
else
|
|
111
|
+
validate_location(location)
|
|
112
|
+
body = Serialization.affinity_group_to_xml(name,
|
|
113
|
+
location,
|
|
114
|
+
label,
|
|
115
|
+
options)
|
|
116
|
+
request_path = '/affinitygroups'
|
|
117
|
+
request = @client.management_request(:post, request_path, body)
|
|
118
|
+
request.call
|
|
119
|
+
Azure::Loggerx.info "Affinity Group #{name} is created."
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Updates the label and/or the description for an affinity group
|
|
124
|
+
# for the specified subscription.
|
|
125
|
+
#
|
|
126
|
+
# ==== Attributes
|
|
127
|
+
#
|
|
128
|
+
# * +name+ - String. Affinity Group name.
|
|
129
|
+
# * +label+ - String. Name for the affinity specified as a
|
|
130
|
+
# base-64 encoded string.
|
|
131
|
+
#
|
|
132
|
+
# ==== Options
|
|
133
|
+
#
|
|
134
|
+
# Accepted key/value pairs are:
|
|
135
|
+
# * +:description+ - String. A description for the affinity group.
|
|
136
|
+
# (optional)
|
|
137
|
+
#
|
|
138
|
+
# @see http://msdn.microsoft.com/en-us/library/azure/gg715316.aspx
|
|
139
|
+
#
|
|
140
|
+
# @return [void]
|
|
141
|
+
def update_affinity_group(name, label, options = {})
|
|
142
|
+
raise 'Label name cannot be empty' if label.nil? || label.empty?
|
|
143
|
+
if affinity_group(name)
|
|
144
|
+
body = Serialization.resource_to_xml(label, options)
|
|
145
|
+
request_path = "/affinitygroups/#{name}"
|
|
146
|
+
request = @client.management_request(:put, request_path, body)
|
|
147
|
+
request.call
|
|
148
|
+
Azure::Loggerx.info "Affinity Group #{name} is updated."
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Deletes an affinity group in the specified subscription
|
|
153
|
+
#
|
|
154
|
+
# ==== Attributes
|
|
155
|
+
#
|
|
156
|
+
# * +name+ - String. Affinity Group name.
|
|
157
|
+
#
|
|
158
|
+
# @see http://msdn.microsoft.com/en-us/library/azure/gg715314.aspx
|
|
159
|
+
#
|
|
160
|
+
# @return [void]
|
|
161
|
+
def delete_affinity_group(name)
|
|
162
|
+
if affinity_group(name)
|
|
163
|
+
request_path = "/affinitygroups/#{name}"
|
|
164
|
+
request = @client.management_request(:delete, request_path)
|
|
165
|
+
request.call
|
|
166
|
+
Azure::Loggerx.info "Deleted affinity group #{name}."
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Returns the system properties associated with the specified
|
|
171
|
+
# affinity group.
|
|
172
|
+
#
|
|
173
|
+
# ==== Attributes
|
|
174
|
+
#
|
|
175
|
+
# * +name+ - String. Affinity Group name.
|
|
176
|
+
#
|
|
177
|
+
# @see http://msdn.microsoft.com/en-us/library/azure/ee460789.aspx
|
|
178
|
+
#
|
|
179
|
+
# @return [Azure::BaseManagement::AffinityGroup]
|
|
180
|
+
def get_affinity_group(name)
|
|
181
|
+
if affinity_group(name)
|
|
182
|
+
request_path = "/affinitygroups/#{name}"
|
|
183
|
+
request = @client.management_request(:get, request_path)
|
|
184
|
+
response = request.call
|
|
185
|
+
Serialization.affinity_group_from_xml(response)
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
private
|
|
190
|
+
|
|
191
|
+
def affinity_group(affinity_group_name)
|
|
192
|
+
if affinity_group_name.nil? ||\
|
|
193
|
+
affinity_group_name.empty? ||\
|
|
194
|
+
!list_affinity_groups.map { |x| x.name.downcase }.include?(
|
|
195
|
+
affinity_group_name.downcase
|
|
196
|
+
)
|
|
197
|
+
error = Azure::Error::Error.new('AffinityGroupNotFound',
|
|
198
|
+
404,
|
|
199
|
+
'The affinity group does not exist.')
|
|
200
|
+
raise error
|
|
201
|
+
else
|
|
202
|
+
true
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def validate_location(location_name)
|
|
207
|
+
base_mgmt_service = Azure::BaseManagementService.new
|
|
208
|
+
locations = base_mgmt_service.list_locations.map(&:name)
|
|
209
|
+
unless locations.map(&:downcase).include?(location_name.downcase)
|
|
210
|
+
error = "Value '#{location_name}' specified for parameter"\
|
|
211
|
+
" 'location' is invalid."\
|
|
212
|
+
" Allowed values are #{locations.join(',')}"
|
|
213
|
+
raise error
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
Azure::BaseManagementService = Azure::BaseManagement::BaseManagementService
|