|
@@ -11,11 +11,41 @@ require 'fog-aws'
|
|
module NeoInfra
|
|
module NeoInfra
|
|
# Provide informations about the accounts available
|
|
# Provide informations about the accounts available
|
|
class Nodes
|
|
class Nodes
|
|
- def load_nodes
|
|
|
|
- aws = NeoInfra::Aws.new
|
|
|
|
|
|
+
|
|
|
|
+ def initialize
|
|
@cfg = NeoInfra::Config.new
|
|
@cfg = NeoInfra::Config.new
|
|
neo4j_url = "http://#{@cfg.neo4j[:host]}:#{@cfg.neo4j[:port]}"
|
|
neo4j_url = "http://#{@cfg.neo4j[:host]}:#{@cfg.neo4j[:port]}"
|
|
Neo4j::Session.open(:server_db, neo4j_url)
|
|
Neo4j::Session.open(:server_db, neo4j_url)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ def display_node(node_id)
|
|
|
|
+ n = Node.where(node_id: node_id).first
|
|
|
|
+ return {
|
|
|
|
+ "Name" => n.name,
|
|
|
|
+ "IP" => n.ip,
|
|
|
|
+ "State" => n.state,
|
|
|
|
+ "AMI" => n.ami,
|
|
|
|
+ "Public_IP" => n.public_ip,
|
|
|
|
+ "AZ" => n.az.az,
|
|
|
|
+ "Account" => n.account.name,
|
|
|
|
+ "Size" => n.size,
|
|
|
|
+ "Subnet" => n.subnet.name,
|
|
|
|
+ "VPC" => n.subnet.subnet.name,
|
|
|
|
+ "SSH-Key" => n.sshkey.name,
|
|
|
|
+ "SecurityGroup" => n.node_sg.name,
|
|
|
|
+ }
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ def search_nodes_by_ip(ip)
|
|
|
|
+ display_node(Node.where(ip: ip).first.node_id)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ def search_nodes_by_node_id(node_id)
|
|
|
|
+ display_node(Node.where(node_id: node_id).first.node_id)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ def load_nodes
|
|
|
|
+ aws = NeoInfra::Aws.new
|
|
|
|
|
|
@cfg.accounts.each do |account|
|
|
@cfg.accounts.each do |account|
|
|
base_conf = {
|
|
base_conf = {
|