Sha256: 040cf905fe1d359f70ad5785918fcf3d7bbd4f2eed2d7ff9fd7b6a1701bb20de

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 KB

Contents

require 'azure/service_runtime/role_instance_endpoint'
require 'azure/service_runtime/local_resource'

module Azure
  module ServiceRuntime
    class RoleInstance
      attr_accessor :id, :role_name, :fault_domain, :update_domain, :endpoints, :configuration_settings, :local_resources
      alias :instance_endpoints :endpoints

      def initialize(node)
        self.id = node["id"]
        self.fault_domain = node["faultDomain"].to_i
        self.update_domain = node["updateDomain"].to_i
        self.role_name = node["roleName"]

        self.endpoints = node.css('Endpoints > Endpoint').inject({}) do |hash, endpoint_xml|
          endpoint = RoleInstanceEndpoint.new(endpoint_xml)
          hash[endpoint.name] = endpoint
          hash
        end

        self.configuration_settings = node.css('ConfigurationSettings > ConfigurationSetting').inject({}) do |hash, setting_xml|
          hash[setting_xml["name"]] = setting_xml["value"]
          hash
        end

        self.local_resources = node.css('LocalResources > LocalResource').inject({}) do |hash, local_resource_xml|
          local_resource = LocalResource.new(local_resource_xml)
          hash[local_resource.name] = local_resource
          hash
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 lib/azure/service_runtime/role_instance.rb
azure-0.1.0 lib/azure/service_runtime/role_instance.rb