Class: Chef::Provisioning::ChefLoadBalancerSpec
- Inherits:
-
LoadBalancerSpec
- Object
- LoadBalancerSpec
- Chef::Provisioning::ChefLoadBalancerSpec
- Defined in:
- lib/chef/provisioning/chef_load_balancer_spec.rb
Overview
Specification for a image. Sufficient information to find and contact it after it has been set up.
Instance Attribute Summary
Attributes inherited from LoadBalancerSpec
#load_balancer_data, #machines
Class Method Summary collapse
-
.empty(id, chef_server = Cheffish.default_chef_server) ⇒ Object
Creates a new empty ImageSpec with the given name.
-
.get(name, chef_server = Cheffish.default_chef_server) ⇒ Object
Get a ImageSpec from the chef server.
- .id_from(chef_server, name) ⇒ Object
Instance Method Summary collapse
- #delete(action_handler) ⇒ Object
-
#id ⇒ Object
Globally unique identifier for this image.
-
#initialize(node, chef_server) ⇒ ChefLoadBalancerSpec
constructor
A new instance of ChefLoadBalancerSpec.
-
#save(action_handler) ⇒ Object
Save this node to the server.
Methods inherited from LoadBalancerSpec
#driver_url, #load_balancer_options, #load_balancer_options=, #location, #location=, #name
Constructor Details
#initialize(node, chef_server) ⇒ ChefLoadBalancerSpec
Returns a new instance of ChefLoadBalancerSpec.
12 13 14 15 |
# File 'lib/chef/provisioning/chef_load_balancer_spec.rb', line 12 def initialize(node, chef_server) super(node) @chef_server = chef_server end |
Class Method Details
.empty(id, chef_server = Cheffish.default_chef_server) ⇒ Object
Creates a new empty ImageSpec with the given name.
37 38 39 |
# File 'lib/chef/provisioning/chef_load_balancer_spec.rb', line 37 def self.empty(id, chef_server = Cheffish.default_chef_server) ChefLoadBalancerSpec.new({ 'id' => id }, chef_server) end |
.get(name, chef_server = Cheffish.default_chef_server) ⇒ Object
Get a ImageSpec from the chef server. If the node does not exist on the server, it returns nil.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/chef/provisioning/chef_load_balancer_spec.rb', line 21 def self.get(name, chef_server = Cheffish.default_chef_server) chef_api = Cheffish.chef_server_api(chef_server) begin data = chef_api.get("/data/loadbalancers/#{name}") data['load_balancer_options'] = strings_to_symbols(data['load_balancer_options']) ChefLoadBalancerSpec.new(data, chef_server) rescue Net::HTTPServerException => e if e.response.code == '404' nil else raise end end end |
.id_from(chef_server, name) ⇒ Object
49 50 51 |
# File 'lib/chef/provisioning/chef_load_balancer_spec.rb', line 49 def self.id_from(chef_server, name) "#{chef_server[:chef_server_url]}/data/loadbalancers/#{name}" end |
Instance Method Details
#delete(action_handler) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/chef/provisioning/chef_load_balancer_spec.rb', line 71 def delete(action_handler) # Save the node to the server. _self = self _chef_server = _self.chef_server Chef::Provisioning.inline_resource(action_handler) do chef_data_bag_item _self.name do data_bag 'loadbalancers' chef_server _chef_server action :destroy end end end |
#id ⇒ Object
Globally unique identifier for this image. Does not depend on the image’s location or existence.
45 46 47 |
# File 'lib/chef/provisioning/chef_load_balancer_spec.rb', line 45 def id ChefLoadBalancerSpec.id_from(chef_server, name) end |
#save(action_handler) ⇒ Object
Save this node to the server. If you have significant information that could be lost, you should do this as quickly as possible. Data will be saved automatically for you after allocate_image and ready_image.
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chef/provisioning/chef_load_balancer_spec.rb', line 58 def save(action_handler) # Save the node to the server. _self = self _chef_server = _self.chef_server Chef::Provisioning.inline_resource(action_handler) do chef_data_bag_item _self.name do data_bag 'loadbalancers' chef_server _chef_server raw_data _self.load_balancer_data end end end |