Sha256: f32a0128fd6e05155cdf01af5bc35e5238cb0f8510a25c490c5d17c47b6d09bf

Contents?: true

Size: 1.33 KB

Versions: 14

Compression:

Stored size: 1.33 KB

Contents

module Yao::Resources
  class ComputeServices < Base
    friendly_attributes  :status, :binary, :host, :zone, :state, :disabled_reason, :forced_down

    self.service        = "compute"
    self.resource_name  = "service"
    self.resources_name = "os-services"

    # return true if ComputeServices is enabled
    # @return [Bool]
    def enabled?
      status == 'enabled'
    end

    # return true if ComputeServices is disabled
    # @return [Bool]
    def disabled?
      status == 'disabled'
    end

    class << self
      def enable(host, binary)
        params = {
          "host" => host,
          "binary" => binary,
        }
        put("enable", params)
      end

      def disable(host, binary, reason = nil)
        params = {
          "host" => host,
          "binary" => binary,
        }
        if reason
          params["disabled_reason"] = reason
          put("disable-log-reason", params)
        else
          put("disable", params)
        end
      end

      private

      # @param path [String]
      # @param  params [Hash]
      # @return [Yao::Resources::ComputeServices]
      def put(path, params)
        res = PUT(create_url(path), params) do |req|
          req.body = params.to_json
          req.headers['Content-Type'] = 'application/json'
        end
        resource_from_json(res.body)
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
yao-0.13.4 lib/yao/resources/compute_services.rb
yao-0.13.3 lib/yao/resources/compute_services.rb
yao-0.13.2 lib/yao/resources/compute_services.rb
yao-0.13.1 lib/yao/resources/compute_services.rb
yao-0.13.0 lib/yao/resources/compute_services.rb
yao-0.12.0 lib/yao/resources/compute_services.rb
yao-0.11.3 lib/yao/resources/compute_services.rb
yao-0.11.2 lib/yao/resources/compute_services.rb
yao-0.11.1 lib/yao/resources/compute_services.rb
yao-0.11.0 lib/yao/resources/compute_services.rb
yao-0.10.1 lib/yao/resources/compute_services.rb
yao-0.10.0 lib/yao/resources/compute_services.rb
yao-0.9.1 lib/yao/resources/compute_services.rb
yao-0.9.0 lib/yao/resources/compute_services.rb