Class: Fog::ApplicationGateway::AzureRM::Real
- Inherits:
-
Object
- Object
- Fog::ApplicationGateway::AzureRM::Real
- Defined in:
- lib/fog/azurerm/application_gateway.rb,
lib/fog/azurerm/requests/application_gateway/check_ag_exists.rb,
lib/fog/azurerm/requests/application_gateway/update_sku_attributes.rb,
lib/fog/azurerm/requests/application_gateway/get_application_gateway.rb,
lib/fog/azurerm/requests/application_gateway/stop_application_gateway.rb,
lib/fog/azurerm/requests/application_gateway/list_application_gateways.rb,
lib/fog/azurerm/requests/application_gateway/start_application_gateway.rb,
lib/fog/azurerm/requests/application_gateway/delete_application_gateway.rb,
lib/fog/azurerm/requests/application_gateway/create_or_update_application_gateway.rb,
lib/fog/azurerm/requests/application_gateway/update_subnet_id_in_gateway_ip_configuration.rb
Overview
Real class for Application Gateway Request
Instance Method Summary collapse
- #check_ag_exists(resource_group_name, application_gateway_name) ⇒ Object
- #create_or_update_application_gateway(gateway_params) ⇒ Object
- #delete_application_gateway(resource_group, name) ⇒ Object
- #get_application_gateway(resource_group_name, application_gateway_name) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #list_application_gateways(resource_group) ⇒ Object
- #start_application_gateway(resource_group, name) ⇒ Object
- #stop_application_gateway(resource_group, name) ⇒ Object
- #update_sku_attributes(gateway_params, sku_name, sku_capacity) ⇒ Object
- #update_subnet_id_in_gateway_ip_configuration(gateway_params, subnet_id) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fog/azurerm/application_gateway.rb', line 50 def initialize( = {}) begin require 'azure_mgmt_network' rescue LoadError => e retry if require('rubygems') raise e. end telemetry = "fog-azure-rm/#{Fog::AzureRM::VERSION}" [:environment] = 'AzureCloud' if [:environment].nil? credentials = Fog::Credentials::AzureRM.get_credentials([:tenant_id], [:client_id], [:client_secret], [:environment]) @network_client = ::Azure::ARM::Network::NetworkManagementClient.new(credentials, resource_manager_endpoint_url([:environment])) @network_client.subscription_id = [:subscription_id] @network_client.add_user_agent_information(telemetry) @tenant_id = [:tenant_id] @client_id = [:client_id] @client_secret = [:client_secret] @subscription_id = [:subscription_id] @environment = [:environment] end |
Instance Method Details
#check_ag_exists(resource_group_name, application_gateway_name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fog/azurerm/requests/application_gateway/check_ag_exists.rb', line 6 def check_ag_exists(resource_group_name, application_gateway_name) msg = "Checking Application Gateway: #{application_gateway_name}" Fog::Logger.debug msg begin @network_client.application_gateways.get(resource_group_name, application_gateway_name) Fog::Logger.debug "Application Gateway #{application_gateway_name} exists." true rescue MsRestAzure::AzureOperationError => e if resource_not_found?(e) Fog::Logger.debug "Application Gateway #{application_gateway_name} doesn't exist." false else raise_azure_exception(e, msg) end end end |
#create_or_update_application_gateway(gateway_params) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fog/azurerm/requests/application_gateway/create_or_update_application_gateway.rb', line 6 def create_or_update_application_gateway(gateway_params) msg = "Creating/Updated Application Gateway: #{gateway_params[:name]} in Resource Group: #{gateway_params[:resource_group]}." Fog::Logger.debug msg gateway = define_application_gateway(gateway_params) begin gateway_obj = @network_client.application_gateways.create_or_update(gateway_params[:resource_group], gateway_params[:name], gateway) rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end Fog::Logger.debug "Application Gateway #{gateway_params[:name]} created/updated successfully." gateway_obj end |
#delete_application_gateway(resource_group, name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/azurerm/requests/application_gateway/delete_application_gateway.rb', line 6 def delete_application_gateway(resource_group, name) msg = "Deleting Application_Gateway #{name} from Resource Group #{resource_group}." Fog::Logger.debug msg begin @network_client.application_gateways.delete(resource_group, name) rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end Fog::Logger.debug "Application Gateway #{name} Deleted Successfully." true end |
#get_application_gateway(resource_group_name, application_gateway_name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/azurerm/requests/application_gateway/get_application_gateway.rb', line 6 def get_application_gateway(resource_group_name, application_gateway_name) msg = "Getting Application Gateway: #{application_gateway_name} in Resource group: #{resource_group_name}" Fog::Logger.debug msg begin application_gateway = @network_client.application_gateways.get(resource_group_name, application_gateway_name) rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end Fog::Logger.debug "Getting application gateway #{application_gateway_name} successfully in Resource Group: #{resource_group_name}" application_gateway end |
#list_application_gateways(resource_group) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/azurerm/requests/application_gateway/list_application_gateways.rb', line 6 def list_application_gateways(resource_group) msg = "Getting list of Application-Gateway from Resource Group #{resource_group}." Fog::Logger.debug msg begin gateways = @network_client.application_gateways.list_as_lazy(resource_group) rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end gateways.value end |
#start_application_gateway(resource_group, name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/azurerm/requests/application_gateway/start_application_gateway.rb', line 5 def start_application_gateway(resource_group, name) msg = "Starting Application Gateway #{name} in Resource Group #{resource_group}" Fog::Logger.debug msg begin @network_client.application_gateways.start(resource_group, name) rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end Fog::Logger.debug "Successfully started Application Gateway #{name} in Resource Group #{resource_group}" true end |
#stop_application_gateway(resource_group, name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/azurerm/requests/application_gateway/stop_application_gateway.rb', line 5 def stop_application_gateway(resource_group, name) msg = "Stopping Application Gateway #{name} in Resource Group #{resource_group}" Fog::Logger.debug msg begin @network_client.application_gateways.stop(resource_group, name) rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end Fog::Logger.debug "Successfully stopped Application Gateway #{name} in Resource Group #{resource_group}" true end |
#update_sku_attributes(gateway_params, sku_name, sku_capacity) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/fog/azurerm/requests/application_gateway/update_sku_attributes.rb', line 6 def update_sku_attributes(gateway_params, sku_name, sku_capacity) msg = "Updating sku attributes for #{sku_name}" Fog::Logger.debug msg gateway_params[:sku_name] = sku_name if sku_name gateway_params[:sku_capacity] = sku_capacity if sku_capacity begin gateway = create_or_update_application_gateway(gateway_params) rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end Fog::Logger.debug "Sku #{sku_name} updated Successfully" gateway end |
#update_subnet_id_in_gateway_ip_configuration(gateway_params, subnet_id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/azurerm/requests/application_gateway/update_subnet_id_in_gateway_ip_configuration.rb', line 6 def update_subnet_id_in_gateway_ip_configuration(gateway_params, subnet_id) msg = 'Updating Subnet id of IP Configuration' Fog::Logger.debug msg gateway_params[:gateway_ip_configurations].each do |ip_configuration| ip_configuration[:subnet_id] = subnet_id end begin gateway = create_or_update_application_gateway(gateway_params) rescue MsRestAzure::AzureOperationError => e raise_azure_exception(e, msg) end Fog::Logger.debug 'IP Configuration updated Successfully' gateway end |