vas 0.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.md +1 -1
  2. data/lib/vas.rb +44 -1
  3. data/lib/vas/gemfire/agent_instances.rb +4 -3
  4. data/lib/vas/gemfire/agent_live_configurations.rb +3 -3
  5. data/lib/vas/gemfire/agent_node_instances.rb +2 -2
  6. data/lib/vas/gemfire/agent_node_live_configurations.rb +39 -0
  7. data/lib/vas/gemfire/application_code.rb +13 -12
  8. data/lib/vas/gemfire/application_code_images.rb +13 -11
  9. data/lib/vas/gemfire/cache_server_instances.rb +20 -12
  10. data/lib/vas/gemfire/cache_server_live_configurations.rb +3 -3
  11. data/lib/vas/gemfire/cache_server_node_instances.rb +16 -9
  12. data/lib/vas/gemfire/cache_server_node_live_configurations.rb +39 -0
  13. data/lib/vas/gemfire/disk_stores.rb +19 -11
  14. data/lib/vas/gemfire/gemfire.rb +4 -4
  15. data/lib/vas/gemfire/groups.rb +17 -10
  16. data/lib/vas/gemfire/installations.rb +12 -3
  17. data/lib/vas/gemfire/live_application_codes.rb +2 -2
  18. data/lib/vas/gemfire/locator_instances.rb +23 -13
  19. data/lib/vas/gemfire/locator_live_configurations.rb +3 -3
  20. data/lib/vas/gemfire/locator_node_instances.rb +22 -14
  21. data/lib/vas/gemfire/locator_node_live_configurations.rb +39 -0
  22. data/lib/vas/gemfire/nodes.rb +27 -6
  23. data/lib/vas/gemfire/pending_application_codes.rb +7 -2
  24. data/lib/vas/gemfire/statistics.rb +18 -11
  25. data/lib/vas/rabbitmq/groups.rb +6 -4
  26. data/lib/vas/rabbitmq/installations.rb +14 -6
  27. data/lib/vas/rabbitmq/instances.rb +9 -6
  28. data/lib/vas/rabbitmq/live_configurations.rb +3 -3
  29. data/lib/vas/rabbitmq/node_instances.rb +2 -2
  30. data/lib/vas/rabbitmq/node_live_configurations.rb +39 -0
  31. data/lib/vas/rabbitmq/nodes.rb +11 -8
  32. data/lib/vas/rabbitmq/plugin_images.rb +14 -7
  33. data/lib/vas/rabbitmq/plugins.rb +29 -20
  34. data/lib/vas/rabbitmq/rabbitmq.rb +4 -4
  35. data/lib/vas/shared/collection.rb +34 -11
  36. data/lib/vas/shared/configuration.rb +16 -9
  37. data/lib/vas/shared/deletable.rb +34 -0
  38. data/lib/vas/shared/groups.rb +26 -15
  39. data/lib/vas/shared/installation_images.rb +18 -10
  40. data/lib/vas/shared/installations.rb +22 -22
  41. data/lib/vas/shared/instance.rb +40 -19
  42. data/lib/vas/shared/live_configuration.rb +42 -0
  43. data/lib/vas/shared/logs.rb +27 -14
  44. data/lib/vas/shared/mutable_collection.rb +13 -5
  45. data/lib/vas/shared/node_configuration.rb +74 -0
  46. data/lib/vas/shared/node_instances.rb +32 -14
  47. data/lib/vas/shared/nodes.rb +37 -14
  48. data/lib/vas/shared/{pending_configuration.rb → pending_configurations.rb} +4 -2
  49. data/lib/vas/shared/resource.rb +12 -2
  50. data/lib/vas/shared/security.rb +11 -4
  51. data/lib/vas/shared/state_resource.rb +1 -1
  52. data/lib/vas/sqlfire/agent_instances.rb +98 -0
  53. data/lib/vas/sqlfire/agent_live_configurations.rb +39 -0
  54. data/lib/vas/sqlfire/agent_logs.rb +39 -0
  55. data/lib/vas/sqlfire/agent_node_instances.rb +54 -0
  56. data/lib/vas/sqlfire/agent_node_live_configurations.rb +39 -0
  57. data/lib/vas/sqlfire/agent_pending_configurations.rb +39 -0
  58. data/lib/vas/sqlfire/groups.rb +58 -0
  59. data/lib/vas/sqlfire/installation_images.rb +39 -0
  60. data/lib/vas/sqlfire/installations.rb +61 -0
  61. data/lib/vas/sqlfire/locator_instances.rb +210 -0
  62. data/lib/vas/sqlfire/locator_live_configurations.rb +39 -0
  63. data/lib/vas/sqlfire/locator_logs.rb +39 -0
  64. data/lib/vas/sqlfire/locator_node_instances.rb +91 -0
  65. data/lib/vas/sqlfire/locator_node_live_configurations.rb +39 -0
  66. data/lib/vas/sqlfire/locator_pending_configurations.rb +39 -0
  67. data/lib/vas/sqlfire/nodes.rb +73 -0
  68. data/lib/vas/sqlfire/server_instances.rb +192 -0
  69. data/lib/vas/sqlfire/server_live_configurations.rb +39 -0
  70. data/lib/vas/sqlfire/server_logs.rb +39 -0
  71. data/lib/vas/sqlfire/server_node_instances.rb +86 -0
  72. data/lib/vas/sqlfire/server_node_live_configurations.rb +39 -0
  73. data/lib/vas/sqlfire/server_pending_configurations.rb +39 -0
  74. data/lib/vas/sqlfire/sqlfire.rb +44 -0
  75. data/lib/vas/tc_server/applications.rb +32 -21
  76. data/lib/vas/tc_server/configuration.rb +1 -1
  77. data/lib/vas/tc_server/groups.rb +7 -4
  78. data/lib/vas/tc_server/installations.rb +16 -6
  79. data/lib/vas/tc_server/instances.rb +25 -13
  80. data/lib/vas/tc_server/live_configurations.rb +11 -1
  81. data/lib/vas/tc_server/logs.rb +4 -2
  82. data/lib/vas/tc_server/node_applications.rb +21 -17
  83. data/lib/vas/tc_server/node_instances.rb +23 -9
  84. data/lib/vas/tc_server/node_live_configurations.rb +39 -0
  85. data/lib/vas/tc_server/node_revisions.rb +15 -10
  86. data/lib/vas/tc_server/nodes.rb +15 -8
  87. data/lib/vas/tc_server/revision_images.rb +16 -10
  88. data/lib/vas/tc_server/revisions.rb +20 -16
  89. data/lib/vas/tc_server/tc_server.rb +5 -5
  90. data/lib/vas/tc_server/template_images.rb +13 -7
  91. data/lib/vas/tc_server/templates.rb +21 -13
  92. data/lib/vas/util/client.rb +15 -6
  93. data/lib/vas/vfabric/agent_image.rb +1 -1
  94. data/lib/vas/vfabric/nodes.rb +4 -11
  95. data/lib/vas/vfabric/v_fabric.rb +2 -2
  96. data/lib/vas/vfabric_administration_server.rb +37 -6
  97. data/lib/vas/web_server/configuration.rb +29 -0
  98. data/lib/vas/web_server/groups.rb +44 -0
  99. data/lib/vas/web_server/installation_images.rb +54 -0
  100. data/lib/vas/web_server/installations.rb +52 -0
  101. data/lib/vas/web_server/instances.rb +65 -0
  102. data/lib/vas/web_server/live_configurations.rb +39 -0
  103. data/lib/vas/web_server/logs.rb +37 -0
  104. data/lib/vas/web_server/node_instances.rb +39 -0
  105. data/lib/vas/web_server/node_live_configurations.rb +39 -0
  106. data/lib/vas/web_server/nodes.rb +53 -0
  107. data/lib/vas/web_server/pending_configurations.rb +39 -0
  108. data/lib/vas/web_server/web_server.rb +43 -0
  109. metadata +137 -76
@@ -26,25 +26,32 @@ module Shared
26
26
  attr_reader :size
27
27
 
28
28
  private
29
-
29
+
30
30
  attr_reader :content_location
31
-
31
+
32
32
  public
33
33
 
34
34
  # @private
35
35
  def initialize(location, client, instance_type, instance_class)
36
36
  super(location, client)
37
37
 
38
- @path = details["path"]
39
- @size = details["size"]
38
+ @instance_class = instance_class
40
39
 
41
40
  @instance_location = Util::LinkUtils.get_link_href(details, instance_type)
42
- @content_location = Util::LinkUtils.get_link_href(details, "content")
41
+ @content_location = Util::LinkUtils.get_link_href(details, 'content')
43
42
 
44
- @instance_class = instance_class
43
+ @path = details['path']
44
+ end
45
+
46
+ # Reloads the configuration's details from the server
47
+ #
48
+ # @return [void]
49
+ def reload
50
+ super
51
+ @size = details['size']
45
52
  end
46
53
 
47
- # Retrieves the configuration's content and passes it to the block
54
+ # Retrieves the configuration's content from the server and passes it to the block
48
55
  #
49
56
  # @yield [chunk] a chunk of the configuration's content
50
57
  #
@@ -55,12 +62,12 @@ module Shared
55
62
 
56
63
  # @return [Instance] the instance that owns the configuration
57
64
  def instance
58
- @instance_class.new(@instance_location, client)
65
+ @instance ||= @instance_class.new(@instance_location, client)
59
66
  end
60
67
 
61
68
  # @return [String] a string representation of the configuration
62
69
  def to_s
63
- "#<#{self.class} name='#@path' size=#@size>"
70
+ "#<#{self.class} name='#@path' size='#@size'>"
64
71
  end
65
72
 
66
73
  end
@@ -0,0 +1,34 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Shared
18
+
19
+ # The +Deletable+ mixin provides classes with support for deletion. The
20
+ # class must provide two instance variables: client and location
21
+ module Deletable
22
+
23
+ # @private
24
+ attr_accessor :collection
25
+
26
+ # Performs a delete. If a collection is available it is reloaded
27
+ def delete
28
+ @client.delete(@location)
29
+ @collection.reload unless @collection.nil?
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -21,11 +21,9 @@ module Shared
21
21
 
22
22
  # @private
23
23
  def initialize(location, client, group_class)
24
- super(location, client, "groups", group_class)
24
+ super(location, client, 'groups', group_class)
25
25
  end
26
26
 
27
- public
28
-
29
27
  # Creates a new group
30
28
  #
31
29
  # @param name [String] the group's name
@@ -33,18 +31,17 @@ module Shared
33
31
  #
34
32
  # @return [Group] the new group
35
33
  def create(name, nodes)
36
- node_locations = []
37
- nodes.each { |node| node_locations << node.location }
38
- entry_class.new(client.post(location, {:name => name, :nodes => node_locations}, "group"), client)
34
+ payload = {:name => name,
35
+ :nodes => nodes.collect { |node| node.location }}
36
+ super(payload, 'group')
39
37
  end
40
38
 
41
39
  end
42
40
 
43
41
  # @abstract A collection of one or more nodes
44
42
  class Group < Shared::Resource
45
-
46
- # @return [Installations] the group's installations
47
- attr_reader :installations
43
+
44
+ include Deletable
48
45
 
49
46
  # @return [String] the group's name
50
47
  attr_reader :name
@@ -52,18 +49,31 @@ module Shared
52
49
  # @private
53
50
  def initialize(location, client, nodes_class, installations_class)
54
51
  super(location, client)
55
- @name = details["name"]
56
- @installations = installations_class.new(Util::LinkUtils.get_link_href(details, "installations"), client)
52
+
53
+ @installations_class = installations_class
57
54
  @nodes_class = nodes_class
55
+
56
+ @installations_location = Util::LinkUtils.get_link_href(details, 'installations')
57
+
58
+ @name = details['name']
58
59
  end
59
-
60
+
61
+ # Reloads the group's details from the server
62
+ def reload
63
+ super
64
+ @nodes = nil
65
+ end
66
+
67
+ # @return [Installations] the group's installations
68
+ def installations
69
+ @installations ||= @installations_class.new(@installations_location, client)
70
+ end
71
+
60
72
  public
61
73
 
62
74
  # @return [GroupableNode[]] the group's nodes
63
75
  def nodes
64
- nodes = []
65
- Util::LinkUtils.get_link_hrefs(client.get(location), "node").each { |node_location| nodes << @nodes_class.new(node_location, client)}
66
- nodes
76
+ @nodes ||= create_resources_from_links('node', @nodes_class)
67
77
  end
68
78
 
69
79
  # @return [String] a string representation of the group
@@ -85,6 +95,7 @@ module Shared
85
95
  node_locations = []
86
96
  nodes.each { |node| node_locations << node.location }
87
97
  client.post(location, {:nodes => node_locations})
98
+ reload
88
99
  end
89
100
 
90
101
  end
@@ -21,7 +21,7 @@ module Shared
21
21
 
22
22
  # @private
23
23
  def initialize(location, client, installation_image_class)
24
- super(location, client, "installation-images", installation_image_class)
24
+ super(location, client, 'installation-images', installation_image_class)
25
25
  end
26
26
 
27
27
  # Creates an installation image by uploading a file to the server and assigning it a version
@@ -31,7 +31,7 @@ module Shared
31
31
  #
32
32
  # @return [InstallationImage] the new installation image
33
33
  def create(path, version)
34
- entry_class.new(client.post_image(location, path, { :version => version }), client)
34
+ create_image(path, { :version => version })
35
35
  end
36
36
 
37
37
  end
@@ -41,6 +41,8 @@ module Shared
41
41
  # group.
42
42
  class InstallationImage < Resource
43
43
 
44
+ include Deletable
45
+
44
46
  # @return [String] the installation image's version
45
47
  attr_reader :version
46
48
 
@@ -50,23 +52,29 @@ module Shared
50
52
  # @private
51
53
  def initialize(location, client, installation_class) #:nodoc:
52
54
  super(location, client)
53
- @version = details["version"]
54
- @size = details["size"]
55
+
55
56
  @installation_class = installation_class
57
+
58
+ @version = details['version']
59
+ @size = details['size']
60
+ end
61
+
62
+ # Reloads the installation image's details from the server
63
+ #
64
+ # @return [void]
65
+ def reload
66
+ super
67
+ @installations = nil
56
68
  end
57
69
 
58
70
  # @return [Installation[]] the installations that have been created from the installation image
59
71
  def installations
60
- installations = []
61
- Util::LinkUtils.get_link_hrefs(client.get(location), "installation").each { |installation_location|
62
- installations << @installation_class.new(installation_location, client)
63
- }
64
- installations
72
+ @installations ||= create_resources_from_links('installation', @installation_class)
65
73
  end
66
74
 
67
75
  # @return [String] a string representation of the installation image
68
76
  def to_s
69
- "#<#{self.class} version='#@version'>"
77
+ "#<#{self.class} version='#@version' size='#@size'>"
70
78
  end
71
79
 
72
80
  end
@@ -21,7 +21,7 @@ module Shared
21
21
 
22
22
  # @private
23
23
  def initialize(location, client, installation_class)
24
- super(location, client, "installations", installation_class)
24
+ super(location, client, 'installations', installation_class)
25
25
  end
26
26
 
27
27
  # Creates a new installation
@@ -30,7 +30,7 @@ module Shared
30
30
  #
31
31
  # @return [Installation] the new installation
32
32
  def create(installation_image)
33
- entry_class.new(client.post(location, { :image => installation_image.location }, "installation"), client)
33
+ super({ :image => installation_image.location }, 'installation')
34
34
  end
35
35
 
36
36
  end
@@ -39,39 +39,39 @@ module Shared
39
39
  # installation is used when creating a new instance and provides the binaries that the instance uses at
40
40
  # runtime
41
41
  class Installation < Shared::Resource
42
+
43
+ include Deletable
42
44
 
43
45
  # @return [String] the installation's version
44
46
  attr_reader :version
45
-
46
- # @return [InstallationImage] the installation image that was used to create the installation
47
- attr_reader :installation_image
48
-
49
- # @return [Group] the group that contains the installation
50
- attr_reader :group
51
47
 
52
48
  # @private
53
- def initialize(location, client, installation_image_class, group_class) #:nodoc:
49
+ def initialize(location, client, installation_image_class, group_class)
54
50
  super(location, client)
55
51
 
56
- @version = details["version"]
57
- @installation_image = installation_image_class.new(Util::LinkUtils.get_link_href(details, "installation-image"), client)
58
- @group = group_class.new(Util::LinkUtils.get_link_href(details, "group"), client)
52
+ @installation_image_location = Util::LinkUtils.get_link_href(details, 'installation-image')
53
+ @group_location = Util::LinkUtils.get_link_href(details, 'group')
54
+
55
+ @installation_image_class = installation_image_class
56
+ @group_class = group_class
57
+
58
+ @version = details['version']
59
+ end
60
+
61
+ # @return [Group] the group that contains the installation
62
+ def group
63
+ @group ||= @group_class.new(@group_location, client)
64
+ end
65
+
66
+ # @return [InstallationImage] the installation image that was used to create the installation
67
+ def installation_image
68
+ @installation_image ||= @installation_image_class.new(@installation_image_location, client)
59
69
  end
60
70
 
61
71
  # @return [String] a string representation of the installation
62
72
  def to_s #:nodoc:
63
73
  "#<#{self.class} version='#@version'>"
64
74
  end
65
-
66
- private
67
-
68
- def retrieve_instances(instance_rel, instance_class)
69
- instances = []
70
- Util::LinkUtils.get_link_hrefs(client.get(location), instance_rel).each { |instance_location|
71
- instances << instance_class.new(instance_location, client)
72
- }
73
- instances
74
- end
75
75
 
76
76
  end
77
77
 
@@ -18,19 +18,12 @@ module Shared
18
18
 
19
19
  # @abstract A collection of instances
20
20
  class Instance < Shared::StateResource
21
+
22
+ include Deletable
21
23
 
22
24
  # @return [String] the instance's name
23
25
  attr_reader :name
24
26
 
25
- # @return the instance's live configurations
26
- attr_reader :live_configurations
27
-
28
- # @return the instance's pending configurations
29
- attr_reader :pending_configurations
30
-
31
- # @return [Group] the group that contains this instance
32
- attr_reader :group
33
-
34
27
  # @private
35
28
  def initialize(location, client,
36
29
  group_class,
@@ -38,29 +31,57 @@ module Shared
38
31
  live_configurations_class,
39
32
  pending_configurations_class,
40
33
  node_instance_class,
41
- node_instance_type) #:nodoc:
34
+ node_instance_type)
35
+
42
36
  super(location, client)
43
37
 
44
- @name = details["name"]
45
- @live_configurations = live_configurations_class.new(Util::LinkUtils.get_link_href(details, "live-configurations"), client)
46
- @pending_configurations = pending_configurations_class.new(Util::LinkUtils.get_link_href(details, "pending-configurations"), client)
47
- @group = group_class.new(Util::LinkUtils.get_link_href(details, "group"), client)
38
+ @live_configurations_location = Util::LinkUtils.get_link_href(details, 'live-configurations')
39
+ @pending_configurations_location = Util::LinkUtils.get_link_href(details, 'pending-configurations')
40
+ @group_location = Util::LinkUtils.get_link_href(details, 'group')
41
+
42
+ @group_class = group_class
48
43
  @installation_class = installation_class
49
44
  @node_instance_class = node_instance_class
45
+ @live_configurations_class = live_configurations_class
46
+ @pending_configurations_class = pending_configurations_class
50
47
  @node_instance_type = node_instance_type
48
+
49
+ @name = details['name']
50
+ end
51
+
52
+ # Reloads the instance's details from the server
53
+ #
54
+ # @return [void]
55
+ def reload
56
+ super
57
+ @installation_location = Util::LinkUtils.get_link_href(details, 'installation')
58
+ @installation = nil
59
+ @node_instances = nil
51
60
  end
52
61
 
53
62
  # @return [Installation] the installation that this instance is using
54
63
  def installation
55
- @installation_class.new(Util::LinkUtils.get_link_href(client.get(location), 'installation'), client)
64
+ @installation ||= @installation_class.new(@installation_location, client)
56
65
  end
57
66
 
58
67
  # @return [NodeInstance[]] the instance's individual node instances
59
68
  def node_instances
60
- node_instances = []
61
- Util::LinkUtils.get_link_hrefs(client.get(location), @node_instance_type).each {
62
- |node_instance_location| node_instances << @node_instance_class.new(node_instance_location, client)}
63
- node_instances
69
+ @node_instances ||= create_resources_from_links(@node_instance_type, @node_instance_class)
70
+ end
71
+
72
+ # @return [Group] the group that contains this instance
73
+ def group
74
+ @group ||= @group_class.new(@group_location, client)
75
+ end
76
+
77
+ # @return the instance's live configurations
78
+ def live_configurations
79
+ @live_configurations ||= @live_configurations_class.new(@live_configurations_location, client)
80
+ end
81
+
82
+ # @return the instance's pending configurations
83
+ def pending_configurations
84
+ @pending_configurations ||= @pending_configurations_class.new(@pending_configurations_location, client)
64
85
  end
65
86
 
66
87
  # @return [String] a string representation of the instance
@@ -0,0 +1,42 @@
1
+ # vFabric Administration Server Ruby API
2
+ # Copyright (c) 2012 VMware, Inc. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ module Shared
18
+
19
+ # @abstract A live configuration file in an instance
20
+ class LiveConfiguration < Shared::Configuration
21
+
22
+ # @private
23
+ def initialize(location, client, instance_type, instance_class, node_live_configuration_class)
24
+ super(location, client, instance_type, instance_class)
25
+ @node_live_configuration_class = node_live_configuration_class
26
+ end
27
+
28
+ # Reloads the live configuration's details from the server
29
+ def reload
30
+ super
31
+ @node_live_configurations = nil
32
+ end
33
+
34
+ # @return [NodeLiveConfiguration[]] the configuration's node configurations
35
+ def node_configurations
36
+ @node_live_configurations ||= create_resources_from_links('node-live-configuration',
37
+ @node_live_configuration_class)
38
+ end
39
+
40
+ end
41
+
42
+ end