1. Odd Otter Co
  2. Untitled project
  3. django-djaboto

Commits

Docta Jay  committed 5a76a81

Back to MH, but with some TBD comments

  • Participants
  • Parent commits e136d5f
  • Branches master

Comments (0)

Files changed (1)

File djaboto/management/commands/aws.py

View file
 
 
     def get_sshKey(self, keyfile=None):
-        if keyfile is not None:
+        # if keyfile is not None:
             # *********************
-            fab_api.env.host_string = 'localhost'
-            fab_api.env['user'] = getuser()
-            if not fab_exists('/%s/etc/ssh/id_rsa.pub' % settings.PROJECT_DIR):
-                if not fab_exists('%s/etc/ssh' % settings.PROJECT_DIR):
-                    fab_api.run('mkdir %s/etc/ssh' % settings.PROJECT_DIR)
-                fab_api.run('ssh-keygen -f %s/etc/ssh/id_rsa -N ""' % settings.PROJECT_DIR)
-
-            keyfile = os.path.abspath(os.path.join(settings.PROJECT_DIR, "etc", "ssh", "id_rsa.pub"))
-        print keyfile
+            # fab_api.env.host_string = 'localhost'
+            # fab_api.env['user'] = getuser()
+            # if not fab_exists('/%s/etc/ssh/id_rsa.pub' % settings.PROJECT_DIR):
+                # if not fab_exists('%s/etc/ssh' % settings.PROJECT_DIR):
+                    # fab_api.run('mkdir %s/etc/ssh' % settings.PROJECT_DIR)
+                # fab_api.run('ssh-keygen -f %s/etc/ssh/id_rsa -N ""' % settings.PROJECT_DIR)
+
+            # keyfile = os.path.abspath(os.path.join(settings.PROJECT_DIR, "etc", "ssh", "id_rsa.pub"))
+        # print keyfile
+        if not keyfile:
+            home = os.getenv('USERPROFILE') or os.getenv('HOME')
+            keyfile = os.path.abspath(os.path.join(home, ".ssh", "id_rsa.pub"))
+        keyfile = os.path.expanduser(keyfile)
         try:
            kf = open(keyfile)
         except IOError as e:
             print fab_colors.red('Keyfile: %s does not exist!  Please specify a valid pubkey file with --sshpubkey=PATH_TO_SECURITY_KEY' % keyfile)
             sys.exit(0)
         keyvalue = kf.readline()
-        print keyvalue
+        # print keyvalue
         keyid = keyvalue.split()[-1].strip() # delimeter not always "== ", but always id is last text following final space
-        print keyid
+        # print keyid
         kf.close()
-        fab_api.env.host_string = self.instance.ip_address
-        fab_api.env['user'] = fab_api.env.AWS_USER
+        # fab_api.env.host_string = self.instance.ip_address
+        # fab_api.env['user'] = fab_api.env.AWS_USER
 
         return (keyid, keyvalue)