Skip to content

Commit 0d61420

Browse files
author
Dougal Ballantyne
committed
Removed sshmaster CLI option; added CLI version checking
1 parent 9eaf774 commit 0d61420

File tree

7 files changed

+21
-186
lines changed

7 files changed

+21
-186
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ everything is done using CloudFormation or resources within AWS.
88

99
### Installation
1010

11-
The current working version is cfncluster-0.0.5. The CLI is written in python and uses BOTO for AWS actions. You can install the CLI with the following command:
11+
The current working version is cfncluster-0.0.8. The CLI is written in python and uses BOTO for AWS actions. You can install the CLI with the following command:
1212

1313
#### Linux/OSX
1414

@@ -77,7 +77,4 @@ Once all of those settings contain valid values, you can launch the cluster by r
7777
```
7878
$ cfncluster create mycluster
7979
```
80-
Once the cluster reaches the "CREATE_COMPLETE" status, you can connect using your normal SSH client/settings or via the cfncluster CLI.
81-
```
82-
$ cfncluster sshmaster mycluster
83-
```
80+
Once the cluster reaches the "CREATE_COMPLETE" status, you can connect using your normal SSH client/settings. For more details on connecting to EC2 instances, check the EC2 User Guide - http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-connect-to-instance-linux.html#using-ssh-client

cli/cfncluster/cfncluster.py

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
import boto.exception
1616
import time
1717
import os
18-
import paramiko
1918
import socket
20-
import interactive
2119
import logging
2220

2321
import cfnconfig
@@ -277,74 +275,3 @@ def delete(args):
277275
print('\nExiting...')
278276
sys.exit(0)
279277

280-
def sshmaster(args):
281-
stack = ('cfncluster-' + args.cluster_name)
282-
config = cfnconfig.CfnClusterConfig(args)
283-
cfnconn = boto.cloudformation.connect_to_region(config.region,aws_access_key_id=config.aws_access_key_id,
284-
aws_secret_access_key=config.aws_secret_access_key)
285-
outputs = cfnconn.describe_stacks(stack)[0].outputs
286-
if args.useprivateip:
287-
hostname = [ o for o in outputs if o.key == 'MasterPrivateIP' ][0].value
288-
else:
289-
hostname = [ o for o in outputs if o.key == 'MasterPublicIP' ][0].value
290-
port = 22
291-
292-
try:
293-
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
294-
sock.connect((hostname, port))
295-
except Exception, e:
296-
print '*** Connect failed: ' + str(e)
297-
traceback.print_exc()
298-
sys.exit(1)
299-
300-
try:
301-
t = paramiko.Transport(sock)
302-
try:
303-
t.start_client()
304-
except paramiko.SSHException:
305-
print '*** SSH negotiation failed.'
306-
sys.exit(1)
307-
308-
try:
309-
keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
310-
except IOError:
311-
try:
312-
keys = paramiko.util.load_host_keys(os.path.expanduser('~/ssh/known_hosts'))
313-
except IOError:
314-
print '*** Unable to open host keys file'
315-
keys = {}
316-
317-
# check server's host key -- this is important.
318-
key = t.get_remote_server_key()
319-
if not keys.has_key(hostname):
320-
print '*** WARNING: Unknown host key!'
321-
elif not keys[hostname].has_key(key.get_name()):
322-
print '*** WARNING: Unknown host key!'
323-
elif keys[hostname][key.get_name()] != key:
324-
print '*** WARNING: Host key has changed!!!'
325-
sys.exit(1)
326-
else:
327-
print '*** Host key OK.'
328-
329-
key = paramiko.RSAKey.from_private_key_file(config.key_location)
330-
username = 'ec2-user'
331-
t.auth_publickey(username, key)
332-
333-
chan = t.open_session()
334-
chan.get_pty()
335-
chan.invoke_shell()
336-
print '*** Here we go!'
337-
print
338-
interactive.interactive_shell(chan)
339-
chan.close()
340-
t.close()
341-
342-
except Exception, e:
343-
print '*** Caught exception: ' + str(e.__class__) + ': ' + str(e)
344-
##traceback.print_exc()
345-
try:
346-
t.close()
347-
except:
348-
pass
349-
sys.exit(1)
350-

cli/cfncluster/cfnconfig.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import inspect
1616
import pkg_resources
1717
import logging
18+
import json
19+
import urllib2
1820

1921
class CfnClusterConfig:
2022

@@ -57,6 +59,20 @@ def __init__(self, args):
5759
self.__cluster_template = __config.get('global', 'cluster_template')
5860
self.__cluster_section = ('cluster %s' % self.__cluster_template)
5961

62+
# Check if package updates should be checked
63+
try:
64+
self.__update_check = __config.get('global', 'update_check')
65+
except ConfigParser.NoOptionError:
66+
self.__update_check = True
67+
68+
if self.__update_check == True:
69+
try:
70+
__latest = json.loads(urllib2.urlopen("http://pypi.python.org/pypi/cfncluster/json").read())['info']['version']
71+
if self.version < __latest:
72+
print('warning: There is a newer version %s of cfncluster available.' % __latest)
73+
except Exception:
74+
pass
75+
6076
# Get the EC2 keypair name to be used, exit if not set
6177
try:
6278
self.key_name = __config.get(self.__cluster_section, 'key_name')

cli/cfncluster/cli.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ def list(args):
3131
def delete(args):
3232
cfncluster.delete(args)
3333

34-
def sshmaster(args):
35-
cfncluster.sshmaster(args)
36-
3734
def instances(args):
3835
cfncluster.instances(args)
3936

@@ -123,13 +120,6 @@ def main():
123120
help='show the status of cfncluster with the provided name.')
124121
pinstances.set_defaults(func=instances)
125122

126-
psshmaster = subparsers.add_parser('sshmaster', help='ssh to Master instance')
127-
psshmaster.add_argument("cluster_name", type=str, default=None,
128-
help='ssh to the Master of the cfncluster with the provided name.')
129-
psshmaster.add_argument("--privateip", action='store_true', dest="useprivateip",
130-
help='connect to the private IP of the MasterServer')
131-
psshmaster.set_defaults(func=sshmaster)
132-
133123
args = parser.parse_args()
134124
logging.debug(args)
135125
args.func(args)

cli/cfncluster/examples/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
[global]
33
# Default cluster config section.
44
cluster_template = default
5+
# Check for updates
6+
update_check = false
57

68
[aws]
79
# This is the AWS credentials section (required).

cli/cfncluster/interactive.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

cli/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def read(fname):
3131
url = ("https://github.com/awslabs/cfncluster"),
3232
license = "Amazon Software License",
3333
packages = find_packages(),
34-
install_requires=['boto >= 2.28.0', 'paramiko >= 1.14.0', 'argparse'],
34+
install_requires=['boto', 'argparse'],
3535
entry_points=dict(console_scripts=console_scripts),
3636
include_package_data = True,
3737
zip_safe = False,

0 commit comments

Comments
 (0)