lib/yun/commands/yun_command.rb in yun-0.0.3 vs lib/yun/commands/yun_command.rb in yun-0.0.4
- old
+ new
@@ -1,26 +1,30 @@
-require 'thor'
-require 'thor/group'
-require 'yun/commands/command_base'
-require 'yun/commands/node_command'
-
module Yun
class YunCommand < Thor
include CommandBase
desc "ssh NODE_NAME", "ssh to a node"
def ssh node_name
- key = "~/.ssh/#{Config.key_name}.pem"
- user_name = "ec2-user"
+ ssh_config = SshConfig.new Config.key_name
+ node = connection.find node_name
+ ssh = Ssh.new node.ip, ssh_config
+ ssh.connect
+ end
+
+ desc "test NODE_NAME, ROLE", "provision node with chef"
+ def chef node_name, role
+ ssh_config = SshConfig.new Config.key_name
node = connection.find node_name
- server_ip = node.ip
+ ssh = Ssh.new node.ip, ssh_config
- exec "ssh -i #{key} #{user_name}@#{server_ip}"
+ ssh.chef role
end
register NodeCommand, :node, "node SUBCOMMAND", "commands for node"
+
+ private
end
end
Yun::YunCommand.start