vas 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +174 -0
- data/NOTICE +5 -0
- data/README.md +26 -0
- data/Rakefile +20 -0
- data/lib/vas.rb +103 -0
- data/lib/vas/gemfire/agent_configuration.rb +28 -0
- data/lib/vas/gemfire/agent_instances.rb +49 -0
- data/lib/vas/gemfire/agent_live_configurations.rb +29 -0
- data/lib/vas/gemfire/agent_logs.rb +38 -0
- data/lib/vas/gemfire/agent_node_instances.rb +38 -0
- data/lib/vas/gemfire/agent_pending_configurations.rb +38 -0
- data/lib/vas/gemfire/application_code.rb +54 -0
- data/lib/vas/gemfire/application_code_images.rb +76 -0
- data/lib/vas/gemfire/cache_server_configuration.rb +28 -0
- data/lib/vas/gemfire/cache_server_instances.rb +57 -0
- data/lib/vas/gemfire/cache_server_live_configurations.rb +29 -0
- data/lib/vas/gemfire/cache_server_logs.rb +38 -0
- data/lib/vas/gemfire/cache_server_node_instances.rb +46 -0
- data/lib/vas/gemfire/cache_server_pending_configurations.rb +38 -0
- data/lib/vas/gemfire/disk_stores.rb +63 -0
- data/lib/vas/gemfire/gemfire.rb +47 -0
- data/lib/vas/gemfire/groups.rb +50 -0
- data/lib/vas/gemfire/installation_images.rb +38 -0
- data/lib/vas/gemfire/installations.rb +53 -0
- data/lib/vas/gemfire/live_application_codes.rb +29 -0
- data/lib/vas/gemfire/locator_configuration.rb +28 -0
- data/lib/vas/gemfire/locator_instances.rb +109 -0
- data/lib/vas/gemfire/locator_live_configurations.rb +29 -0
- data/lib/vas/gemfire/locator_logs.rb +38 -0
- data/lib/vas/gemfire/locator_node_instances.rb +53 -0
- data/lib/vas/gemfire/locator_pending_configurations.rb +38 -0
- data/lib/vas/gemfire/nodes.rb +61 -0
- data/lib/vas/gemfire/pending_application_codes.rb +34 -0
- data/lib/vas/gemfire/statistics.rb +66 -0
- data/lib/vas/rabbitmq/configuration.rb +28 -0
- data/lib/vas/rabbitmq/groups.rb +42 -0
- data/lib/vas/rabbitmq/installation_images.rb +38 -0
- data/lib/vas/rabbitmq/installations.rb +43 -0
- data/lib/vas/rabbitmq/instances.rb +53 -0
- data/lib/vas/rabbitmq/live_configurations.rb +29 -0
- data/lib/vas/rabbitmq/logs.rb +38 -0
- data/lib/vas/rabbitmq/node_instances.rb +38 -0
- data/lib/vas/rabbitmq/nodes.rb +50 -0
- data/lib/vas/rabbitmq/pending_configurations.rb +38 -0
- data/lib/vas/rabbitmq/plugin_images.rb +67 -0
- data/lib/vas/rabbitmq/plugins.rb +85 -0
- data/lib/vas/rabbitmq/rabbitmq.rb +45 -0
- data/lib/vas/shared/collection.rb +46 -0
- data/lib/vas/shared/configuration.rb +59 -0
- data/lib/vas/shared/groups.rb +74 -0
- data/lib/vas/shared/installation_images.rb +62 -0
- data/lib/vas/shared/installations.rb +67 -0
- data/lib/vas/shared/instances.rb +74 -0
- data/lib/vas/shared/logs.rb +89 -0
- data/lib/vas/shared/mutable_collection.rb +27 -0
- data/lib/vas/shared/node_instances.rb +58 -0
- data/lib/vas/shared/nodes.rb +70 -0
- data/lib/vas/shared/pending_configuration.rb +40 -0
- data/lib/vas/shared/resource.rb +44 -0
- data/lib/vas/shared/security.rb +51 -0
- data/lib/vas/shared/state_resource.rb +44 -0
- data/lib/vas/tc_server/applications.rb +89 -0
- data/lib/vas/tc_server/configuration.rb +29 -0
- data/lib/vas/tc_server/groups.rb +42 -0
- data/lib/vas/tc_server/installation_images.rb +38 -0
- data/lib/vas/tc_server/installations.rb +54 -0
- data/lib/vas/tc_server/instances.rb +102 -0
- data/lib/vas/tc_server/live_configurations.rb +29 -0
- data/lib/vas/tc_server/logs.rb +38 -0
- data/lib/vas/tc_server/node_applications.rb +76 -0
- data/lib/vas/tc_server/node_instances.rb +55 -0
- data/lib/vas/tc_server/node_revisions.rb +55 -0
- data/lib/vas/tc_server/nodes.rb +50 -0
- data/lib/vas/tc_server/pending_configurations.rb +38 -0
- data/lib/vas/tc_server/revision_images.rb +67 -0
- data/lib/vas/tc_server/revisions.rb +71 -0
- data/lib/vas/tc_server/tc_server.rb +50 -0
- data/lib/vas/tc_server/template_images.rb +67 -0
- data/lib/vas/tc_server/templates.rb +70 -0
- data/lib/vas/util/client.rb +159 -0
- data/lib/vas/util/link_utils.rb +43 -0
- data/lib/vas/vas_exception.rb +32 -0
- data/lib/vas/vfabric/agent_image.rb +50 -0
- data/lib/vas/vfabric/nodes.rb +47 -0
- data/lib/vas/vfabric/v_fabric.rb +34 -0
- data/lib/vas/vfabric_administration_server.rb +50 -0
- metadata +213 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# vFabric Administration Server Ruby API
|
|
3
|
+
# Copyright (c) 2012 VMware, Inc. All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#++
|
|
17
|
+
|
|
18
|
+
module Shared
|
|
19
|
+
|
|
20
|
+
class Collection < Shared::Resource
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
attr_reader :entry_class
|
|
24
|
+
|
|
25
|
+
def initialize(location, client, type, entry_class) #:nodoc:
|
|
26
|
+
super(location, client)
|
|
27
|
+
@type = type
|
|
28
|
+
@entry_class = entry_class
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
public
|
|
32
|
+
|
|
33
|
+
# Gets the items in the collection from the server. Calls the block once for each item.
|
|
34
|
+
def each # :yields: item
|
|
35
|
+
items = client.get(location)[@type]
|
|
36
|
+
|
|
37
|
+
if (!items.nil?)
|
|
38
|
+
client.get(location)[@type].each { |item|
|
|
39
|
+
yield entry_class.new(Util::LinkUtils.get_self_link_href(item), client)
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# vFabric Administration Server Ruby API
|
|
3
|
+
# Copyright (c) 2012 VMware, Inc. All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#++
|
|
17
|
+
|
|
18
|
+
module Shared
|
|
19
|
+
|
|
20
|
+
class Configuration < Shared::Resource
|
|
21
|
+
|
|
22
|
+
# The path of the configuration
|
|
23
|
+
attr_reader :path
|
|
24
|
+
|
|
25
|
+
# The size of the configuration
|
|
26
|
+
attr_reader :size
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
attr_reader :content_location
|
|
30
|
+
|
|
31
|
+
def initialize(location, client, instance_type, instance_class) #:nodoc:
|
|
32
|
+
super(location, client)
|
|
33
|
+
|
|
34
|
+
@path = details["path"]
|
|
35
|
+
@size = details["size"]
|
|
36
|
+
|
|
37
|
+
@instance_location = Util::LinkUtils.get_link_href(details, instance_type)
|
|
38
|
+
@content_location = Util::LinkUtils.get_link_href(details, "content")
|
|
39
|
+
|
|
40
|
+
@instance_class = instance_class
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
public
|
|
44
|
+
# Retrieves the configuration's content and passes it to the block
|
|
45
|
+
def content(&block)
|
|
46
|
+
client.get_stream(@content_location, &block)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# The instance that owns the configuration
|
|
50
|
+
def instance
|
|
51
|
+
@instance_class.new(@instance_location, client)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def to_s #:nodoc:
|
|
55
|
+
"#<#{self.class} name='#@path' size=#@size>"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# vFabric Administration Server Ruby API
|
|
3
|
+
# Copyright (c) 2012 VMware, Inc. All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#++
|
|
17
|
+
|
|
18
|
+
module Shared
|
|
19
|
+
|
|
20
|
+
class Groups < MutableCollection
|
|
21
|
+
|
|
22
|
+
def initialize(location, client, group_class) #:nodoc:
|
|
23
|
+
super(location, client, "groups", group_class)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Creates a Group named +name+ from the given +nodes+.
|
|
27
|
+
def create(name, nodes)
|
|
28
|
+
node_locations = []
|
|
29
|
+
nodes.each { |node| node_locations << node.location }
|
|
30
|
+
entry_class.new(client.post(location, {:name => name, :nodes => node_locations}, "group"), client)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
class Group < Shared::Resource
|
|
36
|
+
|
|
37
|
+
# The group's installations
|
|
38
|
+
attr_reader :installations
|
|
39
|
+
|
|
40
|
+
# The name of the group
|
|
41
|
+
attr_reader :name
|
|
42
|
+
|
|
43
|
+
def initialize(location, client, nodes_class, installations_class) #:nodoc:#
|
|
44
|
+
super(location, client)
|
|
45
|
+
@name = details["name"]
|
|
46
|
+
@installations = installations_class.new(Util::LinkUtils.get_link_href(details, "installations"), client)
|
|
47
|
+
@nodes_class = nodes_class
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# An array of the group's nodes
|
|
51
|
+
def nodes
|
|
52
|
+
nodes = []
|
|
53
|
+
Util::LinkUtils.get_link_hrefs(client.get(location), "node").each { |node_location| nodes << @nodes_class.new(node_location, client)}
|
|
54
|
+
nodes
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def to_s #:nodoc:
|
|
58
|
+
"#<#{self.class} name='#@name'>"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class MutableGroup < Group
|
|
64
|
+
|
|
65
|
+
# Updates the group to contain the given +nodes+.
|
|
66
|
+
def update(nodes)
|
|
67
|
+
node_locations = []
|
|
68
|
+
nodes.each { |node| node_locations << node.location }
|
|
69
|
+
client.post(location, {:nodes => node_locations})
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# vFabric Administration Server Ruby API
|
|
3
|
+
# Copyright (c) 2012 VMware, Inc. All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#++
|
|
17
|
+
|
|
18
|
+
module Shared
|
|
19
|
+
|
|
20
|
+
class InstallationImages < MutableCollection
|
|
21
|
+
|
|
22
|
+
def initialize(location, client, installation_image_class) #:nodoc:
|
|
23
|
+
super(location, client, "installation-images", installation_image_class)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Creates an installation image with the version +version+ by uploading the file at the given +path+.
|
|
27
|
+
def create(path, version)
|
|
28
|
+
entry_class.new(client.post_image(location, path, { :version => version }), client)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class InstallationImage < Resource
|
|
34
|
+
|
|
35
|
+
# The installation image's version
|
|
36
|
+
attr_reader :version
|
|
37
|
+
|
|
38
|
+
# The installation image's size
|
|
39
|
+
attr_reader :size
|
|
40
|
+
|
|
41
|
+
def initialize(location, client, installation_class) #:nodoc:
|
|
42
|
+
super(location, client)
|
|
43
|
+
@version = details["version"]
|
|
44
|
+
@size = details["size"]
|
|
45
|
+
@installation_class = installation_class
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def installations
|
|
49
|
+
installations = []
|
|
50
|
+
Util::LinkUtils.get_link_hrefs(client.get(location), "installation").each { |installation_location|
|
|
51
|
+
installations << @installation_class.new(installation_location, client)
|
|
52
|
+
}
|
|
53
|
+
installations
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def to_s #:nodoc:
|
|
57
|
+
"#<#{self.class} version='#@version'>"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# vFabric Administration Server Ruby API
|
|
3
|
+
# Copyright (c) 2012 VMware, Inc. All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#++
|
|
17
|
+
|
|
18
|
+
module Shared
|
|
19
|
+
|
|
20
|
+
class Installations < Shared::MutableCollection
|
|
21
|
+
|
|
22
|
+
def initialize(location, client, installation_class) #:nodoc:
|
|
23
|
+
super(location, client, "installations", installation_class)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Creates an installation from the +installation_image+
|
|
27
|
+
def create(installation_image)
|
|
28
|
+
entry_class.new(client.post(location, { :image => installation_image.location }, "installation"), client)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class Installation < Shared::Resource
|
|
34
|
+
|
|
35
|
+
# The installation's version
|
|
36
|
+
attr_reader :version
|
|
37
|
+
|
|
38
|
+
# The installation image that was used to create the installation
|
|
39
|
+
attr_reader :installation_image
|
|
40
|
+
|
|
41
|
+
# The group that contains the installation
|
|
42
|
+
attr_reader :group
|
|
43
|
+
|
|
44
|
+
def initialize(location, client, installation_image_class, group_class) #:nodoc:
|
|
45
|
+
super(location, client)
|
|
46
|
+
|
|
47
|
+
@version = details["version"]
|
|
48
|
+
@installation_image = installation_image_class.new(Util::LinkUtils.get_link_href(details, "installation-image"), client)
|
|
49
|
+
@group = group_class.new(Util::LinkUtils.get_link_href(details, "group"), client)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def to_s #:nodoc:
|
|
53
|
+
"#<#{self.class} version='#@version'>"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
def retrieve_instances(instance_rel, instance_class)
|
|
58
|
+
instances = []
|
|
59
|
+
Util::LinkUtils.get_link_hrefs(client.get(location), instance_rel).each { |instance_location|
|
|
60
|
+
instances << instance_class.new(instance_location, client)
|
|
61
|
+
}
|
|
62
|
+
instances
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# vFabric Administration Server Ruby API
|
|
3
|
+
# Copyright (c) 2012 VMware, Inc. All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#++
|
|
17
|
+
|
|
18
|
+
module Shared
|
|
19
|
+
|
|
20
|
+
class Instance < Shared::StateResource
|
|
21
|
+
|
|
22
|
+
# The instance's name
|
|
23
|
+
attr_reader :name
|
|
24
|
+
|
|
25
|
+
# The instance's live configurations
|
|
26
|
+
attr_reader :live_configurations
|
|
27
|
+
|
|
28
|
+
# The instance's pending configurations
|
|
29
|
+
attr_reader :pending_configurations
|
|
30
|
+
|
|
31
|
+
# The group that contains this instance
|
|
32
|
+
attr_reader :group
|
|
33
|
+
|
|
34
|
+
# An array of the instance's individual node instances
|
|
35
|
+
attr_reader :node_instances
|
|
36
|
+
|
|
37
|
+
def initialize(location, client,
|
|
38
|
+
group_class,
|
|
39
|
+
installation_class,
|
|
40
|
+
live_configurations_class,
|
|
41
|
+
pending_configurations_class,
|
|
42
|
+
node_instance_class,
|
|
43
|
+
node_instance_type) #:nodoc:
|
|
44
|
+
super(location, client)
|
|
45
|
+
|
|
46
|
+
@name = details["name"]
|
|
47
|
+
@live_configurations = live_configurations_class.new(Util::LinkUtils.get_link_href(details, "live-configurations"), client)
|
|
48
|
+
@pending_configurations = pending_configurations_class.new(Util::LinkUtils.get_link_href(details, "pending-configurations"), client)
|
|
49
|
+
@group = group_class.new(Util::LinkUtils.get_link_href(details, "group"), client)
|
|
50
|
+
@installation_class = installation_class
|
|
51
|
+
@node_instance_class = node_instance_class
|
|
52
|
+
@node_instance_type = node_instance_type
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# The installation that this instance is using
|
|
56
|
+
def installation
|
|
57
|
+
@installation_class.new(Util::LinkUtils.get_link_href(client.get(location), 'installation'), client)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# An array of the instance's individual node instances
|
|
61
|
+
def node_instances
|
|
62
|
+
node_instances = []
|
|
63
|
+
Util::LinkUtils.get_link_hrefs(client.get(location), @node_instance_type).each {
|
|
64
|
+
|node_instance_location| node_instances << @node_instance_class.new(node_instance_location, client)}
|
|
65
|
+
node_instances
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def to_s #:nodoc:
|
|
69
|
+
"#<#{self.class} name='#@name'>"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# vFabric Administration Server Ruby API
|
|
3
|
+
# Copyright (c) 2012 VMware, Inc. All Rights Reserved.
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#++
|
|
17
|
+
|
|
18
|
+
module Shared
|
|
19
|
+
|
|
20
|
+
# Used to enumerate a node instance's logs
|
|
21
|
+
class Logs < Shared::MutableCollection
|
|
22
|
+
|
|
23
|
+
def initialize(location, client, log_class) #:nodoc:
|
|
24
|
+
super(location, client, 'logs', log_class)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# A log file in a node instance
|
|
30
|
+
class Log < Shared::Resource
|
|
31
|
+
|
|
32
|
+
# The name of the log
|
|
33
|
+
attr_reader :name
|
|
34
|
+
|
|
35
|
+
# The node instance that the log belongs to
|
|
36
|
+
attr_reader :instance
|
|
37
|
+
|
|
38
|
+
def initialize(location, client, instance_type, instance_class) #:nodoc:
|
|
39
|
+
super(location, client)
|
|
40
|
+
|
|
41
|
+
@name = details['name']
|
|
42
|
+
@content_location = Util::LinkUtils.get_link_href(details, 'content')
|
|
43
|
+
@instance = instance_class.new(Util::LinkUtils.get_link_href(details, instance_type), client)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# The Log's content. The content that is passed to the block can be controlled using +options+.
|
|
47
|
+
#
|
|
48
|
+
# Recognized options are:
|
|
49
|
+
#
|
|
50
|
+
# start_line:: The start point, in lines, of the content to pass to the block. Omitting the parameter will result
|
|
51
|
+
# in content from the start of the file being passed. If the provided value is greater than the
|
|
52
|
+
# number of lines in the file, no content will be passed.
|
|
53
|
+
# end_line:: The end point, in lines, of the content to pass to the block. Omitting the parameter will result in
|
|
54
|
+
# content up to the end of the file being passed. If the provided value is greater than the number of
|
|
55
|
+
# lines in the file, content up to and including the last line in the file will be passed.
|
|
56
|
+
def content(options = {}, &block)
|
|
57
|
+
query=""
|
|
58
|
+
if (!options[:start_line].nil?)
|
|
59
|
+
query << "start-line=#{options[:start_line]}"
|
|
60
|
+
end
|
|
61
|
+
if (!options[:end_line].nil?)
|
|
62
|
+
if (query.length > 0)
|
|
63
|
+
query << '&'
|
|
64
|
+
end
|
|
65
|
+
query << "end-line=#{options[:end_line]}"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
if (query.length > 0)
|
|
69
|
+
client.get_stream("#{@content_location}?#{query}", &block)
|
|
70
|
+
else
|
|
71
|
+
client.get_stream(@content_location, &block)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# The size of the log
|
|
76
|
+
def size
|
|
77
|
+
client.get(location)['size']
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# The last_modified stamp of the log
|
|
81
|
+
def last_modified
|
|
82
|
+
client.get(location)['last-modified']
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def to_s #:nodoc:
|
|
86
|
+
"#<#{self.class} name='#@name' size'#@size' services='#@last_modified'>"
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|