fog-azure-0.0.2/0000755000175600017570000000000012731546707012465 5ustar pravipravifog-azure-0.0.2/LICENSE.md0000644000175600017570000000205412731546707014072 0ustar pravipraviThe 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. fog-azure-0.0.2/CONTRIBUTING.md0000644000175600017570000000153312731546707014720 0ustar pravipravi## Getting Involved New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another. ### Coding * Pick a task: * Offer feedback on open [pull requests](https://github.com/fog/fog-azure/pulls). * Review open [issues](https://github.com/fog/fog-azure/issues) for things to help on. * [Create an issue](https://github.com/fog/fog-azure/issues/new) to start a discussion on additions or features. * Fork the project, add your changes and tests to cover them in a topic branch. * Commit your changes and rebase against `fog/fog-azure` to ensure everything is up to date. * [Submit a pull request](https://github.com/fog/fog-azure/compare/) ### Non-Coding * Offer feedback on open [issues](https://github.com/fog/fog-azure/issues). * Organize or volunteer at events.fog-azure-0.0.2/CONTRIBUTORS.md0000644000175600017570000000011212731546707014736 0ustar pravipravi* Jeff Mendoza * Ranjan Kumar fog-azure-0.0.2/fog-azure.gemspec0000644000175600017570000000470712731546707015741 0ustar pravipravi# 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. # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'fog/azure/version' Gem::Specification.new do |spec| spec.name = "fog-azure" spec.version = Fog::AZURE::VERSION spec.authors = ["Jeff Mendoza", "Ranjan Kumar"] spec.email = ["jlm@jlm.name", "ranjankumar188@gmail.com"] spec.summary = %q{Module for the 'fog' gem to support Azure cloud services.} spec.description = %q{This library can be used as a module for `fog` or as standalone provider to use the Azure cloud services in applications..} spec.homepage = "http://github.com/fog/fog-azure" spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] #spec.add_development_dependency 'bundler', '~> 1.6' spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'shindo', '~> 0.3' # spec.add_development_dependency('azure', '~>0.6') 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' end fog-azure-0.0.2/tests/0000755000175600017570000000000012731546707013627 5ustar pravipravifog-azure-0.0.2/tests/helpers/0000755000175600017570000000000012731546707015271 5ustar pravipravifog-azure-0.0.2/tests/helpers/mock_helper.rb0000644000175600017570000000275412731546707020116 0ustar pravipravi# 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. # Use so you can run in mock mode from the command line # # FOG_MOCK=true fog if ENV["FOG_MOCK"] == "true" Fog.mock! end # if in mocked mode, fill in some fake credentials for us if Fog.mock? Fog.credentials = { :azure_sub_id => 'azure_sub_id', :azure_pem => 'path_of_pem' }.merge(Fog.credentials) end fog-azure-0.0.2/tests/helper.rb0000644000175600017570000000312012731546707015427 0ustar pravipravi# 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. require File.expand_path('../../lib/fog/azure', __FILE__) Bundler.require(:test) Excon.defaults.merge!(:debug_request => true, :debug_response => true) require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper')) # This overrides the default 600 seconds timeout during live test runs if Fog.mocking? Fog.timeout = ENV['FOG_TEST_TIMEOUT'] || 2000 Fog::Logger.warning "Setting default fog timeout to #{Fog.timeout} seconds" end fog-azure-0.0.2/tests/requests/0000755000175600017570000000000012731546707015502 5ustar pravipravifog-azure-0.0.2/tests/requests/compute/0000755000175600017570000000000012731546707017156 5ustar pravipravifog-azure-0.0.2/tests/requests/compute/images_tests.rb0000644000175600017570000000300312731546707022166 0ustar pravipravi# 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] | images request", ["azure", "compute"]) do tests("#list_images") do images = Fog::Compute[:azure].images test "returns a Array" do images.is_a? Array end test("should return valid image name") do images.first.name.is_a? String end test("should return records") do images.size >= 1 end end end fog-azure-0.0.2/tests/requests/compute/databases_tests.rb0000644000175600017570000000337212731546707022661 0ustar pravipravi# 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] | database request", ["azure", "compute"]) do tests("#list_db_servers") do databases = Fog::Compute[:azure].databases test "returns an Array of Database objects" do databases.is_a? Array end test "returns all databases as an array" do databases.all.is_a? Array end test("should return valid database name") do databases.all.first.name.is_a? String end test("should create a new database") do databases.create('AdvancedAdminU', 'NotARegPW!', 'South Central US').kind_of? ::Azure::SqlDatabaseManagement::SqlDatabase end end end fog-azure-0.0.2/tests/requests/compute/servers_tests.rb0000644000175600017570000000306312731546707022420 0ustar pravipravi# 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] | servers request", ["azure", "compute"]) do tests("#servers") do servers = Fog::Compute[:azure].servers servers = [fog_server] if servers.empty? test "returns a Array" do servers.is_a? Array end test("should return valid server name") do servers.first.name.is_a? String end test("should return records") do servers.size >= 1 end end end fog-azure-0.0.2/tests/requests/compute/storage_accounts_tests.rb0000644000175600017570000000322212731546707024267 0ustar pravipravi# 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] | storage accounts request", ["azure", "compute"]) do tests("#storage_accounts") do storage_accounts = Fog::Compute[:azure].storage_accounts storage_accounts = [storage_account] if storage_accounts.empty? test "returns a Array" do storage_accounts.is_a? Array end test("should return valid storage account name") do storage_accounts.first.name.is_a? String end test("should return records") do storage_accounts.size >= 1 end end end fog-azure-0.0.2/tests/azure_test_helper.rb0000644000175600017570000000464212731546707017706 0ustar pravipravi# 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. def azure_service Fog::Compute[:azure] end def vm_attributes image = azure_service.images.select{|image| image.os_type == "Linux"}.first location = image.locations.split(";").first { :image => image.name, :location => location, :vm_name => vm_name, :vm_user => "foguser", :password => "ComplexPassword!123", :storage_account_name => storage_name } end def vm_name "fog-test-server" end def storage_name "fogteststorageaccount" end def fog_server server = azure_service.servers.select { |s| s.vm_name == vm_name }.first unless server server = azure_service.servers.create( vm_attributes ) end server end def storage_account storage = azure_service.storage_accounts.select { |s| s.name == storage_name }.first unless storage storage = azure_service.storage_accounts.create( {:name => storage_name, :location => "West US"} ) end azure_service.storage_accounts.get(storage_name) end def vm_destroy server = azure_service.servers.select { |s| s.vm_name == vm_name }.first server.destroy if server end def storage_destroy storage = azure_service.storage_accounts.select { |s| s.name == storage_name }.first storage.destroy if storage end at_exit do unless Fog.mocking? storage_destroy vm_destroy end end fog-azure-0.0.2/tests/models/0000755000175600017570000000000012731546707015112 5ustar pravipravifog-azure-0.0.2/tests/models/compute/0000755000175600017570000000000012731546707016566 5ustar pravipravifog-azure-0.0.2/tests/models/compute/database_tests.rb0000644000175600017570000000427212731546707022106 0ustar pravipravi# 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] | database model", ["azure", "compute"]) do service = Fog::Compute[:azure] tests("The database model should") do db = service.databases.all.first tests("have the actions") do test("destroy") { db.respond_to? "destroy" } test("firewall_rules") { db.respond_to? "firewall_rules" } end tests("have attributes") do attributes = [ :name, :feature_name, :feature_value, :location, :administrator_login ] tests("The database model should respond to") do attributes.each do |attribute| test("#{attribute}") { db.respond_to? attribute } end end end test("should delete a database") do pending if Fog.mocking? db = service.databases.all.first # Gets a little tricky here because DB Server names are autogenerated # Have to be careful while running tests db_name = db.name db.destroy db = service.databases.select { |s| s.name == db_name }.first db.nil? end end end fog-azure-0.0.2/tests/models/compute/image_tests.rb0000644000175600017570000000363512731546707021426 0ustar pravipravi# 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] | image model", ["azure", "compute"]) do service = Fog::Compute[:azure] tests("The image model should") do image = service.images.first tests("have the action") do test("reload") { image.respond_to? "reload" } end tests("have attributes") do model_attribute_hash = image.attributes attributes = [ :name, :os_type ] tests("The image model should respond to") do attributes.each do |attribute| test("#{attribute}") { image.respond_to? attribute } end end tests("The attributes hash should have key") do attributes.each do |attribute| test("#{attribute}") { model_attribute_hash.key? attribute } end end end end end fog-azure-0.0.2/tests/models/compute/storage_account_tests.rb0000644000175600017570000000365512731546707023526 0ustar pravipravi# 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] | storage account model", ["azure", "compute"]) do storage = storage_account tests("The storage account model should") do tests("have the action") do test("reload") { storage.respond_to? "reload" } end tests("have attributes") do model_attribute_hash = storage.attributes attributes = [ :name, :location, :status ] tests("The storage account model should respond to") do attributes.each do |attribute| test("#{attribute}") { storage.respond_to? attribute } end end tests("The attributes hash should have key") do attributes.each do |attribute| test("#{attribute}") { model_attribute_hash.key? attribute } end end end end end fog-azure-0.0.2/tests/models/compute/server_tests.rb0000644000175600017570000000507312731546707021650 0ustar pravipravi# 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] | server model", ["azure", "compute"]) do server = fog_server tests("The server model should") do pending if Fog.mocking? tests("have the action") do test("reload") { server.respond_to? "reload" } %w{ destroy reboot shutdown start }.each do |action| test(action) { server.respond_to? action } end end tests("have attributes") do attributes = [ :vm_name, :status, :ipaddress, :cloud_service_name, :image, :location, :os_type, :storage_account_name ] tests("The server model should respond to") do attributes.each do |attribute| test("#{attribute}") { server.respond_to? attribute } end end end test("#reboot") do server.reboot server = fog_server %w(ReadyRole Provisioning RoleStateUnknown).include? server.status end test("#start") do server.start server = fog_server status = %w(ReadyRole Provisioning RoleStateUnknown) status.include? server.status end test("#shutdown") do server.shutdown server = fog_server %w(StoppedVM StoppedDeallocated).include? server.status end test("#destroy") do server.destroy server = azure_service.servers.select { |s| s.vm_name == vm_name }.first server.nil? end end end fog-azure-0.0.2/README.md0000644000175600017570000000110012731546707013734 0ustar pravipravi# Fog::Azure Module for the 'fog' gem to support Windows Azure ## Installation Add this line to your application's Gemfile: ```ruby gem 'fog-azure' ``` And then execute: $ bundle Or install it yourself as: $ gem install fog-azure ## Usage TODO: Write usage instructions here ## Contributing 1. Fork it ( https://github.com/fog/fog-azure/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request fog-azure-0.0.2/Gemfile0000644000175600017570000000234112731546707013760 0ustar pravipravi# 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. source 'https://rubygems.org' # Specify your gem's dependencies in fog-azure.gemspec gemspec fog-azure-0.0.2/lib/0000755000175600017570000000000012731546707013233 5ustar pravipravifog-azure-0.0.2/lib/fog/0000755000175600017570000000000012731546707014006 5ustar pravipravifog-azure-0.0.2/lib/fog/bin/0000755000175600017570000000000012731546707014556 5ustar pravipravifog-azure-0.0.2/lib/fog/bin/azure.rb0000644000175600017570000000546212731546707016240 0ustar pravipravi# 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. module Azure # deviates from other bin stuff to accomodate gem class << self def class_for(key) case key when :compute Fog::Compute::Azure else raise ArgumentError, "Unrecognized service: #{key}" end end def [](service) @@connections ||= Hash.new do |hash, key| hash[key] = case key when :compute Fog::Logger.warning("Azure[:compute] is not recommended, use Compute[:azure] for portability") Fog::Compute.new(:provider => 'Azure') else raise ArgumentError, "Unrecognized service: #{key.inspect}" end end @@connections[service] end def available? availability = true for service in services begin service = self.class_for(service) availability &&= service.requirements.all? { |requirement| Fog.credentials.include?(requirement) } rescue ArgumentError => e Fog::Logger.warning(e.message) availability = false rescue => e availability = false end end if availability for service in services for collection in self.class_for(service).collections unless self.respond_to?(collection) self.class_eval <<-EOS, __FILE__, __LINE__ def self.#{collection} self[:#{service}].#{collection} end EOS end end end end availability end def collections services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s} end def services Fog::Azure.services end end end fog-azure-0.0.2/lib/fog/azure/0000755000175600017570000000000012731546707015134 5ustar pravipravifog-azure-0.0.2/lib/fog/azure/version.rb0000644000175600017570000000227512731546707017154 0ustar pravipravi# 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. module Fog module AZURE VERSION = "0.0.2" end end fog-azure-0.0.2/lib/fog/azure/compute.rb0000644000175600017570000000623412731546707017142 0ustar pravipravi# 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. require "fog/azure/core" module Fog module Compute class Azure < Fog::Service requires :azure_sub_id requires :azure_pem recognizes :azure_api_url request_path "fog/azure/requests/compute" request :list_virtual_machines request :create_virtual_machine request :delete_virtual_machine request :get_storage_account request :create_storage_account request :list_storage_accounts request :delete_storage_account request :reboot_server request :shutdown_server request :start_server request :list_images request :list_databases request :create_database_server request :delete_database request :firewall_rules request :add_data_disk request :get_virtual_machine model_path "fog/azure/models/compute" model :server collection :servers model :storage_account collection :storage_accounts model :image collection :images model :database collection :databases class Mock def initialize(options={}) begin require "azure" rescue LoadError => e retry if require("rubygems") raise e.message end end end class Real def initialize(options) begin require "azure" rescue LoadError => e retry if require("rubygems") raise e.message end ::Azure.configure do |cfg| cfg.management_certificate = options[:azure_pem] cfg.subscription_id = options[:azure_sub_id] cfg.management_endpoint = options[:azure_api_url] || \ "https://management.core.windows.net" end @vm_svc = ::Azure::VirtualMachineManagementService.new @stg_svc = ::Azure::StorageManagementService.new @image_svc = ::Azure::VirtualMachineImageManagementService.new @db_svc = ::Azure::SqlDatabaseManagementService.new end end end end end fog-azure-0.0.2/lib/fog/azure/requests/0000755000175600017570000000000012731546707017007 5ustar pravipravifog-azure-0.0.2/lib/fog/azure/requests/compute/0000755000175600017570000000000012731546707020463 5ustar pravipravifog-azure-0.0.2/lib/fog/azure/requests/compute/list_virtual_machines.rb0000644000175600017570000000424312731546707025403 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def list_virtual_machines @vm_svc.list_virtual_machines end end class Mock def list_virtual_machines vm = ::Azure::VirtualMachineManagement::VirtualMachine.new vm.cloud_service_name = "cool-vm" vm.status = "ReadyRole" vm.ipaddress = "123.45.67.89" vm.vm_name = "cool-vm" vm.udp_endpoints = [] vm.hostname = "cool-vm" vm.deployment_name = "cool-vm" vm.deployment_status = "Running" vm.tcp_endpoints = [ {"Name"=>"http", "Vip"=>"123.45.67.89", "PublicPort"=>"80", "LocalPort"=>"80"}, {"Name"=>"SSH", "Vip"=>"123.45.67.89", "PublicPort"=>"22", "LocalPort"=>"22"} ] vm.role_size = "Medium" vm.os_type = "Linux" vm.disk_name = "cool-vm-cool-vm-0-20130207005053" vm.virtual_network_name = "" vm.image = "ImageName" [vm] end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/get_storage_account.rb0000644000175600017570000000262412731546707025033 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def get_storage_account(name) @stg_svc.get_storage_account_properties(name) end end class Mock def get_storage_account(name) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/list_images.rb0000644000175600017570000000324612731546707023315 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def list_images @image_svc.list_virtual_machine_images end end class Mock def list_images image = ::Azure::VirtualMachineImageManagement::VirtualMachineImage.new image.name = "Ubuntu-13_04-amd64-server-20130601-en-us-30GB" image.os_type = "Linux" image.category = "Public" image.locations = "East Asia;Southeast Asia;North Europe" [image] end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/create_database_server.rb0000644000175600017570000000325112731546707025466 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def create_database_server(login, password, location) @db_svc.create_server(login, password, location) end end class Mock def create_database_server(login, password, location) db = ::Azure::SqlDatabaseManagement::SqlDatabase.new db.name = 'Mock Database' db.location = location db.feature_name = 'Mock Database' db.feature_value = 'value' db end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/shutdown_server.rb0000644000175600017570000000255112731546707024254 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def shutdown_server(vm_name, cloud_service_name) @vm_svc.shutdown_virtual_machine(vm_name, cloud_service_name) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/add_data_disk.rb0000644000175600017570000000035312731546707023544 0ustar pravipravimodule Fog module Compute class Azure class Real def add_data_disk(vm_name, cloud_service_name, options) @vm_svc.add_data_disk(vm_name, cloud_service_name, options) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/delete_database.rb0000644000175600017570000000257212731546707024104 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def delete_database(name) @db_svc.delete_server(name) end end class Mock def delete_database(name) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/get_virtual_machine.rb0000644000175600017570000000215212731546707025021 0ustar pravipravimodule Fog module Compute class Azure class Real def get_virtual_machine(name, cloud_service_name) @vm_svc.get_virtual_machine(name, cloud_service_name) end end class Mock def get_virtual_machine(name, cloud_service_name) vm = ::Azure::VirtualMachineManagement::VirtualMachine.new vm.cloud_service_name = cloud_service_name vm.status = "ReadyRole" vm.ipaddress = "123.45.67.89" vm.vm_name = name vm.udp_endpoints = [] vm.hostname = "cool-vm" vm.deployment_name = "cool-vm" vm.deployment_status = "Running" vm.tcp_endpoints = [ {"Name"=>"http", "Vip"=>"123.45.67.89", "PublicPort"=>"80", "LocalPort"=>"80"}, {"Name"=>"SSH", "Vip"=>"123.45.67.89", "PublicPort"=>"22", "LocalPort"=>"22"} ] vm.role_size = "Medium" vm.os_type = "Linux" vm.disk_name = "cool-vm-cool-vm-0-20130207005053" vm.virtual_network_name = "" vm.image = "ImageName" vm end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/start_server.rb0000644000175600017570000000254312731546707023537 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def start_server(vm_name, cloud_service_name) @vm_svc.start_virtual_machine(vm_name, cloud_service_name) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/reboot_server.rb0000644000175600017570000000254612731546707023677 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def reboot_server(vm_name, cloud_service_name) @vm_svc.restart_virtual_machine(vm_name, cloud_service_name) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/list_storage_accounts.rb0000644000175600017570000000317212731546707025411 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def list_storage_accounts @stg_svc.list_storage_accounts end end class Mock def list_storage_accounts storage = ::Azure::StorageManagement::StorageAccount.new storage.name = "fogteststorageaccount" storage.status = "Created" storage.label = "Storage-Name" storage.location = "West US" [storage] end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/delete_storage_account.rb0000644000175600017570000000250112731546707025510 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def delete_storage_account(name) @stg_svc.delete_storage_account(name) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/firewall_rules.rb0000644000175600017570000000250012731546707024024 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def firewall_rules(name) @db_svc.list_sql_server_firewall_rules(name) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/list_databases.rb0000644000175600017570000000304412731546707023773 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def list_databases @db_svc.list_servers end end class Mock def list_databases db = ::Azure::SqlDatabaseManagement::SqlDatabase.new db.name = 'Mock Database' db.location = 'US East' db.feature_name = 'feature name' [db] end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/create_virtual_machine.rb0000644000175600017570000000266212731546707025513 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def create_virtual_machine(params, options) @vm_svc.create_virtual_machine(params, options) end end class Mock def create_virtual_machine(params, options) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/delete_virtual_machine.rb0000644000175600017570000000255612731546707025514 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def delete_virtual_machine(vm_name, cloud_service_name) @vm_svc.delete_virtual_machine(vm_name, cloud_service_name) end end end end end fog-azure-0.0.2/lib/fog/azure/requests/compute/create_storage_account.rb0000644000175600017570000000322412731546707025514 0ustar pravipravi# 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. module Fog module Compute class Azure class Real def create_storage_account(name, options) @stg_svc.create_storage_account(name, options) end end class Mock def create_storage_account(name, options) storage = ::Azure::StorageManagement::StorageAccount.new storage.name = name storage.status = "Created" storage.label = name storage.location = options[:location] storage end end end end end fog-azure-0.0.2/lib/fog/azure/models/0000755000175600017570000000000012731546707016417 5ustar pravipravifog-azure-0.0.2/lib/fog/azure/models/compute/0000755000175600017570000000000012731546707020073 5ustar pravipravifog-azure-0.0.2/lib/fog/azure/models/compute/databases.rb0000644000175600017570000000350312731546707022350 0ustar pravipravi# 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. require "fog/core/collection" require "fog/azure/models/compute/database" module Fog module Compute class Azure class Databases < Fog::Collection model Fog::Compute::Azure::Database def all() databases = [] service.list_databases.each do |account| hash = {} account.instance_variables.each do |var| hash[var.to_s.delete("@")] = account.instance_variable_get(var) end databases << hash end load(databases) end def create(login, password, location) service.create_database_server(login, password, location) end end end end end fog-azure-0.0.2/lib/fog/azure/models/compute/image.rb0000644000175600017570000000255712731546707021513 0ustar pravipravi# 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. require "fog/core/model" module Fog module Compute class Azure class Image < Fog::Model identity :name attribute :os_type attribute :category attribute :locations end end end end fog-azure-0.0.2/lib/fog/azure/models/compute/storage_accounts.rb0000644000175600017570000000354412731546707023771 0ustar pravipravi# 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. require "fog/core/collection" require "fog/azure/models/compute/storage_account" module Fog module Compute class Azure class StorageAccounts < Fog::Collection model Fog::Compute::Azure::StorageAccount def all() accounts = [] service.list_storage_accounts.each do |account| hash = {} account.instance_variables.each do |var| hash[var.to_s.delete("@")] = account.instance_variable_get(var) end accounts << hash end load(accounts) end def get(identity) all.find { |f| f.name == identity } rescue Fog::Errors::NotFound nil end end end end end fog-azure-0.0.2/lib/fog/azure/models/compute/database.rb0000644000175600017570000000315412731546707022167 0ustar pravipravi# 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. require "fog/core/model" module Fog module Compute class Azure class Database < Fog::Model identity :name attribute :feature_name attribute :feature_value attribute :location attribute :administrator_login def destroy requires :name service.delete_database(name) end def firewall_rules requires :name service.firewall_rules(name) end end end end end fog-azure-0.0.2/lib/fog/azure/models/compute/servers.rb0000644000175600017570000000477412731546707022125 0ustar pravipravi# 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. require "fog/core/collection" require "fog/azure/models/compute/server" module Fog module Compute class Azure class Servers < Fog::Collection model Fog::Compute::Azure::Server def all() servers = [] service.list_virtual_machines.each do |vm| hash = {} vm.instance_variables.each do |var| hash[var.to_s.delete("@")] = vm.instance_variable_get(var) end hash[:vm_user] = "azureuser" if hash[:vm_user].nil? servers << hash end load(servers) end def get(identity, cloud_service_name) all.find { |f| f.name == identity && f.cloud_service_name == cloud_service_name } rescue Fog::Errors::NotFound nil end def bootstrap(new_attributes = {}) defaults = { :vm_name => "fog-#{Time.now.to_i}", :vm_user => "azureuser", :image => "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_3-LTS-amd64-server-20131205-en-us-30GB", :location => "Central US", :private_key_file => File.expand_path("~/.ssh/id_rsa"), :vm_size => "Small", } server = create(defaults.merge(new_attributes)) server.wait_for { sshable? } unless server.private_key_file.nil? server end end end end end fog-azure-0.0.2/lib/fog/azure/models/compute/images.rb0000644000175600017570000000346112731546707021671 0ustar pravipravi# 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. require "fog/core/collection" require "fog/azure/models/compute/image" module Fog module Compute class Azure class Images < Fog::Collection model Fog::Compute::Azure::Image def all() images = [] service.list_images.each do |image| hash = {} image.instance_variables.each do |var| hash[var.to_s.delete("@")] = image.instance_variable_get(var) end images << hash end load(images) end def get(identity) all.find { |f| f.name == identity } rescue Fog::Errors::NotFound nil end end end end end fog-azure-0.0.2/lib/fog/azure/models/compute/server.rb0000644000175600017570000001415012731546707021727 0ustar pravipravi# 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. require "fog/compute/models/server" require "tempfile" module Fog module Compute class Azure class Server < Fog::Compute::Server # attr names are from azure identity :vm_name attribute :ipaddress attribute :deployment_status attribute :deployment_name attribute :status attribute :hostname attribute :cloud_service_name attribute :tcp_endpoints attribute :udp_endpoints attribute :virtual_network_name attribute :availability_set_name attribute :os_type attribute :disk_name attribute :image attribute :vm_user attribute :location attribute :private_key_file attribute :vm_size, :aliases => "role_size" attribute :storage_account_name, :type => :string attribute :password attribute :winrm_transport attribute :ssh_port attribute :affinity_group_name attribute :subnet_name attribute :certificate_file #helper functions for more common fog names def external_ip ipaddress end def public_ip_address ipaddress end def name vm_name end def state deployment_status end def username vm_user end def machine_type vm_size end def ready? state == "Running" end def destroy requires :vm_name requires :cloud_service_name service.delete_virtual_machine(vm_name, cloud_service_name) end def reboot requires :vm_name requires :cloud_service_name service.reboot_server(vm_name, cloud_service_name) end def shutdown requires :vm_name requires :cloud_service_name service.shutdown_server(vm_name, cloud_service_name) end def start requires :vm_name requires :cloud_service_name service.start_server(vm_name, cloud_service_name) end def save requires :vm_name requires :vm_user requires :image requires_one :location, :affinity_group_name #requires :vm_size if ! private_key_file.nil? && certificate_file.nil? key = OpenSSL::PKey.read File.read(private_key_file) cert = OpenSSL::X509::Certificate.new cert.version = 2 # cf. RFC 5280 - to make it a "v3" certificate cert.serial = 1 cert.subject = OpenSSL::X509::Name.parse "/CN=Fog" cert.issuer = cert.subject # root CA's are "self-signed" cert.public_key = key.public_key cert.not_before = Time.now cert.not_after = cert.not_before + 2 * 365 * 24 * 60 * 60 # 2 years validity ef = OpenSSL::X509::ExtensionFactory.new ef.subject_certificate = cert ef.issuer_certificate = cert cert.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true)) cert.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true)) cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false)) cert.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false)) cert.sign(key, OpenSSL::Digest::SHA256.new) cert_file = Tempfile.new(["cert", ".pem"]) cert_file.chmod(0600) cert_file.write(cert.to_pem) cert_file.close self.certificate_file = cert_file.path end if storage_account_name.nil? service.storage_accounts.each do |sa| if sa.location == location self.storage_account_name = sa.name break end end end if cloud_service_name.nil? self.cloud_service_name = vm_name end #API to start deployment params = { :vm_name => vm_name, :vm_user => vm_user, :image => image, :password => password, :location => location, } options = { :storage_account_name => storage_account_name, :winrm_transport => winrm_transport, :cloud_service_name => cloud_service_name, :deployment_name => deployment_name, :tcp_endpoints => tcp_endpoints, :private_key_file => private_key_file, :certificate_file => certificate_file, :ssh_port => ssh_port, :vm_size => vm_size, :affinity_group_name => affinity_group_name, :virtual_network_name => virtual_network_name, :subnet_name => subnet_name, :availability_set_name => availability_set_name, } service.create_virtual_machine(params, options) cert_file.unlink unless cert_file.nil? end end end end end fog-azure-0.0.2/lib/fog/azure/models/compute/storage_account.rb0000644000175600017570000000460312731546707023603 0ustar pravipravi# 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. require "fog/compute/models/server" require "tempfile" module Fog module Compute class Azure class StorageAccount < Fog::Model identity :name attribute :url attribute :description attribute :affinity_group attribute :location attribute :label attribute :status attribute :endpoints attribute :geo_replication_enabled attribute :geo_primary_region attribute :status_of_primary attribute :last_geo_failover_time attribute :geo_secondary_region attribute :status_of_secondary attribute :creation_time attribute :extended_properties def save requires :name requires_one :location, :affinity_group options = { :label => label, :location => location, :description => description, :affinity_group_name => affinity_group, :geo_replication_enabled => geo_replication_enabled, :extended_properties => extended_properties, } service.create_storage_account(name, options) end def destroy requires :name service.delete_storage_account(name) end end end end end fog-azure-0.0.2/lib/fog/azure/docs/0000755000175600017570000000000012731546707016064 5ustar pravipravifog-azure-0.0.2/lib/fog/azure/docs/getting_started.md0000644000175600017570000000520212731546707021574 0ustar pravipravi# Getting started with Fog::Compute and Azure (2014/11/21) You'll need a [ Management Portal](https://manage.windowsazure.com/) account and API key to use this. See http://msdn.microsoft.com/en-us/library/azure/ee460799.aspx. ## Setting credentials Fog uses `~/.fog` to store credentials. To add Azure as your default provider, simply add the following: :default: :azure_sub_id: subscription id :azure_pem: path-to-certificate ## Connecting, retrieving and managing server objects ```ruby require 'fog' require 'pp' 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' ) ``` ## Listing servers Listing servers and attributes: ```ruby azure.servers.each do |server| server.cloud_service_name server.vm_name server.status server.ipaddress server.image server.disk_name server.os_type end ``` ## Server creation and life-cycle management Creating a new server: ```ruby server = azure.servers.create( :image => '604889f8753c3__OpenLogic-CentOS', :location => 'West US', :vm_name => 'fog-server', :vm_user => "foguser", :password => "ComplexPassword!123", :storage_account_name => 'fogstorage' ) ``` ## Retrieve a single record Get a single server record: ```ruby server = azure.servers.get('vm-name') server.cloud_service_name server.vm_name server.status server.ipaddress server.image server.disk_name server.os_type ``` Rebooting a server: ```ruby server.reboot ``` Start a server: ```ruby server.start ``` Shutdown a server: ```ruby server.shutdown ``` Destroying the server: ```ruby server.destroy ``` ## Storage accounts creation and life-cycle management Creating a new storage account: ```ruby azure.storage_accounts.create( :name => 'storageaccountname', :location => 'West US' ) ``` ## Listing storage accounts Listing storage accounts and attributes: ```ruby azure.storage_accounts.each do |storage_acc| storage_acc.name storage_acc.location end ``` ## Retrieve a single record Get a single storage account record: ```ruby storage_acc = azure.storage_accounts.get('storageaccountname') server.name server.location server.endpoints ``` Destroying the storage account: ```ruby storage_acc.destroy ``` ## Listing images Listing images and attributes: ```ruby azure.images.each do |image| image.name image.os_type image.category image.locations end ``` ## Retrieve a single record Get a single image record: ```ruby image = azure.image.get('image_name') image.name image.locations image.category image.os_type ``` fog-azure-0.0.2/lib/fog/azure/core.rb0000644000175600017570000000236512731546707016417 0ustar pravipravi# 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. require "fog/core" module Fog module Azure extend Fog::Provider service(:compute, "Compute") end end fog-azure-0.0.2/lib/fog/azure.rb0000644000175600017570000000237112731546707015464 0ustar pravipravi# 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. require 'fog/azure/version' require 'fog/azure/core' require 'fog/azure/compute' module Fog module Azure end end fog-azure-0.0.2/Rakefile0000644000175600017570000000244312731546707014135 0ustar pravipravi# 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. require "bundler/gem_tasks" task :default => :test mock = ENV['FOG_MOCK'] || 'true' task :test do sh("export FOG_MOCK=#{mock} && bundle exec shindont") end fog-azure-0.0.2/.gitignore0000644000175600017570000000031012731546707014447 0ustar pravipravi*.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp *.bundle *.so *.o *.a mkmf.log gemfiles/*.lock