Sha256: 97e6d22fc754e855495b878b89c5f5929e5e9ea542bcb0c638e748b58cd666ce

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 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"

    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

1 entries across 1 versions & 1 rubygems

Version Path
yao-0.8.0 lib/yao/resources/compute_services.rb