Class: Bim::Action::Node
- Inherits:
-
Object
- Object
- Bim::Action::Node
- Extended by:
- Util
- Defined in:
- lib/bim/action/node.rb
Overview
Node class uses by Bim::Subcommands::Node
Constant Summary collapse
- NODE_PATH =
'/mgmt/tm/ltm/node'.freeze
- NODE_URI =
URI.join(Bim::BASE_URL, Bim::Action::Node::NODE_PATH)
Constants included from Util
Class Method Summary collapse
Class Method Details
.create(name, address) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/bim/action/node.rb', line 21 def create(name, address) post( NODE_URI, { 'name' => name, 'address' => address }.to_json ) end |
.delete(name) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bim/action/node.rb', line 28 def delete(name) self_link = JSON.parse(detail(name))&.fetch('selfLink') return "not found #{name} node" if self_link.nil? return "cancel delete #{name} node" unless yes_or_no?("you want to delete #{name} node? [y|n]") uri = URI(self_link.sub('localhost', Bim::BIGIP_HOST)) req = request(uri, Bim::AUTH, 'application/json', 'DELETE') msg = http(uri).request(req).body msg.empty? ? "success delete #{name} node" : msg end |
.detail(name) ⇒ Object
17 18 19 |
# File 'lib/bim/action/node.rb', line 17 def detail(name) specify(NODE_URI) { |d| d['name'] == name } end |
.ls ⇒ Object
11 12 13 14 15 |
# File 'lib/bim/action/node.rb', line 11 def ls map(NODE_URI) do |item| { name: item['name'], address: item['address'] } end end |