Class: Shared::Log

Inherits:
Resource show all
Defined in:
lib/vas/shared/logs.rb

Overview

A log file in a node instance

Instance Attribute Summary collapse

Attributes inherited from Resource

#location, #security

Instance Method Summary collapse

Constructor Details

#initialize(location, client, instance_type, instance_class) ⇒ Log

:nodoc:



38
39
40
41
42
43
44
# File 'lib/vas/shared/logs.rb', line 38

def initialize(location, client, instance_type, instance_class) #:nodoc:
  super(location, client)

  @name = details['name']
  @content_location = Util::LinkUtils.get_link_href(details, 'content')
  @instance = instance_class.new(Util::LinkUtils.get_link_href(details, instance_type), client)
end

Instance Attribute Details

#instanceObject (readonly)

The node instance that the log belongs to



36
37
38
# File 'lib/vas/shared/logs.rb', line 36

def instance
  @instance
end

#nameObject (readonly)

The name of the log



33
34
35
# File 'lib/vas/shared/logs.rb', line 33

def name
  @name
end

Instance Method Details

#content(options = {}, &block) ⇒ Object

The Log’s content. The content that is passed to the block can be controlled using options.

Recognized options are:

start_line

The start point, in lines, of the content to pass to the block. Omitting the parameter will result in content from the start of the file being passed. If the provided value is greater than the number of lines in the file, no content will be passed.

end_line

The end point, in lines, of the content to pass to the block. Omitting the parameter will result in content up to the end of the file being passed. If the provided value is greater than the number of lines in the file, content up to and including the last line in the file will be passed.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/vas/shared/logs.rb', line 56

def content(options = {}, &block)
  query=""
  if (!options[:start_line].nil?)
    query << "start-line=#{options[:start_line]}"
  end
  if (!options[:end_line].nil?)
    if (query.length > 0)
      query << '&'
    end
    query << "end-line=#{options[:end_line]}"
  end

  if (query.length > 0)
    client.get_stream("#{@content_location}?#{query}", &block)
  else
    client.get_stream(@content_location, &block)
  end
end

#last_modifiedObject

The last_modified stamp of the log



81
82
83
# File 'lib/vas/shared/logs.rb', line 81

def last_modified
  client.get(location)['last-modified']
end

#sizeObject

The size of the log



76
77
78
# File 'lib/vas/shared/logs.rb', line 76

def size
  client.get(location)['size']
end

#to_sObject

:nodoc:



85
86
87
# File 'lib/vas/shared/logs.rb', line 85

def to_s #:nodoc:
  "#<#{self.class} name='#@name' size'#@size' services='#@last_modified'>"
end