From 59b785c082bdc5737a5fed9d94f9b77ef585bd1d Mon Sep 17 00:00:00 2001 From: sangy14 Date: Wed, 20 May 2015 08:41:50 +0000 Subject: [PATCH 1/7] Added support to list role sizes --- fog-azure.gemspec | 2 +- lib/fog/azure/compute.rb | 2 ++ lib/fog/azure/docs/getting_started.md | 9 +++++ lib/fog/azure/requests/compute/role_sizes.rb | 18 ++++++++++ tests/requests/compute/role_sizes_tests.rb | 36 ++++++++++++++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lib/fog/azure/requests/compute/role_sizes.rb create mode 100644 tests/requests/compute/role_sizes_tests.rb diff --git a/fog-azure.gemspec b/fog-azure.gemspec index 06f66f3..97bbfa6 100644 --- a/fog-azure.gemspec +++ b/fog-azure.gemspec @@ -48,5 +48,5 @@ Gem::Specification.new do |spec| spec.add_dependency 'fog-core', '~> 1.27' spec.add_dependency 'fog-json', '~> 1.0' spec.add_dependency 'fog-xml', '~> 0.1' - spec.add_dependency 'azure', '~>0.6' + spec.add_dependency 'azure', '~>0.7.0.pre' end diff --git a/lib/fog/azure/compute.rb b/lib/fog/azure/compute.rb index 80b269c..eb09b3b 100644 --- a/lib/fog/azure/compute.rb +++ b/lib/fog/azure/compute.rb @@ -45,6 +45,7 @@ class Azure < Fog::Service request :create_database_server request :delete_database request :firewall_rules + request :role_sizes model_path "fog/azure/models/compute" model :server @@ -85,6 +86,7 @@ def initialize(options) @stg_svc = ::Azure::StorageManagementService.new @image_svc = ::Azure::VirtualMachineImageManagementService.new @db_svc = ::Azure::SqlDatabaseManagementService.new + @base_svc = ::Azure::BaseManagementService.new end end end diff --git a/lib/fog/azure/docs/getting_started.md b/lib/fog/azure/docs/getting_started.md index c493e23..1e4d931 100644 --- a/lib/fog/azure/docs/getting_started.md +++ b/lib/fog/azure/docs/getting_started.md @@ -162,3 +162,12 @@ image.locations image.category image.os_type ``` + +## Listing rolesizes + +```ruby +azure.role_sizes.each do | role_size| +puts role_size +end +``` + diff --git a/lib/fog/azure/requests/compute/role_sizes.rb b/lib/fog/azure/requests/compute/role_sizes.rb new file mode 100644 index 0000000..0f1119f --- /dev/null +++ b/lib/fog/azure/requests/compute/role_sizes.rb @@ -0,0 +1,18 @@ +module Fog + module Compute + class Azure + class Real + def role_sizes + @base_svc.list_role_sizes + end + end + + class Mock + def role_sizes + role_sizes = ["A10", "A11", "A5", "A6", "A7", "A8", "A9", "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "ExtraLarge", "ExtraSmall", "Large", "Medium", "Small", "Standard_D1", "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_DS1", "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS2", "Standard_DS3", "Standard_DS4", "Standard_G1", "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5"] + role_sizes + end + end + end + end +end diff --git a/tests/requests/compute/role_sizes_tests.rb b/tests/requests/compute/role_sizes_tests.rb new file mode 100644 index 0000000..7482d8c --- /dev/null +++ b/tests/requests/compute/role_sizes_tests.rb @@ -0,0 +1,36 @@ +# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +Shindo.tests("Fog::Compute[:azure] | role_sizes request", ["azure", "compute"]) do + + tests("#role_sizes") do + role_sizes = Fog::Compute[:azure].role_sizes + + test "returns an Array of strings" do + role_sizes.is_a? Array + end + + test("should return records") do + role_sizes.size >= 1 + end + + end +end From 83f04682452b55122722712120d0b4479b3e30dc Mon Sep 17 00:00:00 2001 From: sangy14 Date: Wed, 3 Jun 2015 09:05:47 +0000 Subject: [PATCH 2/7] modified base url for azure api in docs --- lib/fog/azure/docs/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/azure/docs/getting_started.md b/lib/fog/azure/docs/getting_started.md index 1e4d931..1c34673 100644 --- a/lib/fog/azure/docs/getting_started.md +++ b/lib/fog/azure/docs/getting_started.md @@ -24,7 +24,7 @@ azure = Fog::Compute.new( :provider => 'Azure', :azure_sub_id => '35a2461c-22ac-1111-5ed2-11165d755ba4', :azure_pem => 'c:/path/abc.pem', - :azure_api_url => 'usnorth.management.core.windows.net' + :azure_api_url => 'management.core.windows.net' ) ``` From feee57e92b7a8959b379f429718c59988d1500f6 Mon Sep 17 00:00:00 2001 From: sangy14 Date: Mon, 29 Jun 2015 12:47:30 +0000 Subject: [PATCH 3/7] added documentation for vm creation key-value pairs --- lib/fog/azure/docs/getting_started.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/fog/azure/docs/getting_started.md b/lib/fog/azure/docs/getting_started.md index 1c34673..be87819 100644 --- a/lib/fog/azure/docs/getting_started.md +++ b/lib/fog/azure/docs/getting_started.md @@ -58,7 +58,31 @@ server = azure.servers.create( :storage_account_name => 'fogstorage' ) ``` - +Following key value pairs can be used while creating a server. + + --------- ------------------------------------------------------------------------------------------------------------------------------------------------------- +| key | Description of values | Example | + ----------------------------------------------------------------------------------------------------------------------------------------------------------------- +| :vm_name | Name of the VM to be given. It should be unique. | "fog-server" | +| :vm_user | User name for the VM | "foguser" | +| :image | Image to be used for creation of VM. | "0b11de9248dd4d87b18621318e037d37__RightImage-Ubuntu-12.04-x64-v13.4"| +| :password | Password to be used for authenticating above User name. | "password@123" | +| :location | Data center location to be used for creation of VM. | "West Europe" | +| :storage_account_name | Storage account to be used for creation of VM.(Optional) | "fog-storage" | +| :winrm_transport | Winrm transport protocol either 'http' or 'https'.(Optional) | "https" or "http" | +| :cloud_service_name | Cloud service name.(Optional) | "fog-server" | +| :deployment_name | Deployment name.(Optional) | "fog-server" | +| :tcp_endpoints | Tcp end point.It should be comma separated list in the format | "80:8081,443:9443" | +| | :.(Optional) | | +| :private_key_file | Path of private key file.(Optional) | "c:/path/id_rsa" | +| :certificate_file | Path of certificate file.(Optional) | "c:/path/cert.cert" | +| :ssh_port | Ssh port to be used.(Optional) | "25" | +| :vm_size | Vm size.(Optional) | "Standard_A1" | +| :affinity_group_name | Affinity group name.(Optional) | "fog-server-group" | +| :virtual_network_name | Virtual network name.(Optional) | "fog-server-network" | +| :subnet_name | Subnet name.(Optional) | "fog-server-subnet" | +| :availability_set_name| Availability set name.(Optional) | "fog-server-availability" | + ----------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Retrieve a single record From 50ce103301a55f2eb5ebc99f063c7f0c19bace42 Mon Sep 17 00:00:00 2001 From: sangy14 Date: Mon, 29 Jun 2015 12:57:07 +0000 Subject: [PATCH 4/7] added documentation for vm creation key-value pairs --- lib/fog/azure/docs/getting_started.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/fog/azure/docs/getting_started.md b/lib/fog/azure/docs/getting_started.md index be87819..8ac2590 100644 --- a/lib/fog/azure/docs/getting_started.md +++ b/lib/fog/azure/docs/getting_started.md @@ -60,9 +60,8 @@ server = azure.servers.create( ``` Following key value pairs can be used while creating a server. - --------- ------------------------------------------------------------------------------------------------------------------------------------------------------- | key | Description of values | Example | - ----------------------------------------------------------------------------------------------------------------------------------------------------------------- +| --------------------- |:----------------------------------------------------------------:| --------------------------------------------------------------------:| | :vm_name | Name of the VM to be given. It should be unique. | "fog-server" | | :vm_user | User name for the VM | "foguser" | | :image | Image to be used for creation of VM. | "0b11de9248dd4d87b18621318e037d37__RightImage-Ubuntu-12.04-x64-v13.4"| @@ -82,7 +81,6 @@ Following key value pairs can be used while creating a server. | :virtual_network_name | Virtual network name.(Optional) | "fog-server-network" | | :subnet_name | Subnet name.(Optional) | "fog-server-subnet" | | :availability_set_name| Availability set name.(Optional) | "fog-server-availability" | - ----------------------------------------------------------------------------------------------------------------------------------------------------------------- ## Retrieve a single record From 6361bf4e2e0b63df1d4e54bfad73661f817ca674 Mon Sep 17 00:00:00 2001 From: sangy14 Date: Mon, 29 Jun 2015 13:02:47 +0000 Subject: [PATCH 5/7] added documentation for vm creation key-value pairs --- lib/fog/azure/docs/getting_started.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/fog/azure/docs/getting_started.md b/lib/fog/azure/docs/getting_started.md index 8ac2590..62a1cf6 100644 --- a/lib/fog/azure/docs/getting_started.md +++ b/lib/fog/azure/docs/getting_started.md @@ -61,7 +61,7 @@ server = azure.servers.create( Following key value pairs can be used while creating a server. | key | Description of values | Example | -| --------------------- |:----------------------------------------------------------------:| --------------------------------------------------------------------:| +| --------------------- |:----------------------------------------------------------------:|:-------------------------------------------------------------------- | | :vm_name | Name of the VM to be given. It should be unique. | "fog-server" | | :vm_user | User name for the VM | "foguser" | | :image | Image to be used for creation of VM. | "0b11de9248dd4d87b18621318e037d37__RightImage-Ubuntu-12.04-x64-v13.4"| @@ -71,8 +71,7 @@ Following key value pairs can be used while creating a server. | :winrm_transport | Winrm transport protocol either 'http' or 'https'.(Optional) | "https" or "http" | | :cloud_service_name | Cloud service name.(Optional) | "fog-server" | | :deployment_name | Deployment name.(Optional) | "fog-server" | -| :tcp_endpoints | Tcp end point.It should be comma separated list in the format | "80:8081,443:9443" | -| | :.(Optional) | | +| :tcp_endpoints | Tcp end point.It should be comma separated list in the format :.(Optional) | "80:8081,443:9443" | | :private_key_file | Path of private key file.(Optional) | "c:/path/id_rsa" | | :certificate_file | Path of certificate file.(Optional) | "c:/path/cert.cert" | | :ssh_port | Ssh port to be used.(Optional) | "25" | From 34893f32cd476974a1aef8208d2b1dc153e95146 Mon Sep 17 00:00:00 2001 From: sangy14 Date: Mon, 29 Jun 2015 13:07:03 +0000 Subject: [PATCH 6/7] added documentation for vm creation key-value pairs --- lib/fog/azure/docs/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/azure/docs/getting_started.md b/lib/fog/azure/docs/getting_started.md index 62a1cf6..624c4a2 100644 --- a/lib/fog/azure/docs/getting_started.md +++ b/lib/fog/azure/docs/getting_started.md @@ -71,7 +71,7 @@ Following key value pairs can be used while creating a server. | :winrm_transport | Winrm transport protocol either 'http' or 'https'.(Optional) | "https" or "http" | | :cloud_service_name | Cloud service name.(Optional) | "fog-server" | | :deployment_name | Deployment name.(Optional) | "fog-server" | -| :tcp_endpoints | Tcp end point.It should be comma separated list in the format :.(Optional) | "80:8081,443:9443" | +| :tcp_endpoints | Tcp end point.It should be comma separated list in the format (publicport):(privateport).(Optional) | "80:8081,443:9443" | | :private_key_file | Path of private key file.(Optional) | "c:/path/id_rsa" | | :certificate_file | Path of certificate file.(Optional) | "c:/path/cert.cert" | | :ssh_port | Ssh port to be used.(Optional) | "25" | From 642d64ff30a94930f37ce51cf6ff344d97306d74 Mon Sep 17 00:00:00 2001 From: sangy14 Date: Tue, 30 Jun 2015 12:38:36 +0000 Subject: [PATCH 7/7] changes to doc --- lib/fog/azure/docs/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fog/azure/docs/getting_started.md b/lib/fog/azure/docs/getting_started.md index 624c4a2..ba7df2c 100644 --- a/lib/fog/azure/docs/getting_started.md +++ b/lib/fog/azure/docs/getting_started.md @@ -75,7 +75,7 @@ Following key value pairs can be used while creating a server. | :private_key_file | Path of private key file.(Optional) | "c:/path/id_rsa" | | :certificate_file | Path of certificate file.(Optional) | "c:/path/cert.cert" | | :ssh_port | Ssh port to be used.(Optional) | "25" | -| :vm_size | Vm size.(Optional) | "Standard_A1" | +| :vm_size | Vm/Role size.(Optional) | "Standard_A1" | | :affinity_group_name | Affinity group name.(Optional) | "fog-server-group" | | :virtual_network_name | Virtual network name.(Optional) | "fog-server-network" | | :subnet_name | Subnet name.(Optional) | "fog-server-subnet" |