Commits

Mikhail Korobov committed 5695dee

Better run_as implementation

  • Participants
  • Parent commits 4677e55

Comments (0)

Files changed (1)

fab_deploy/utils.py

 from fabric.contrib.files import upload_template
 from fabric.api import *
 from fabric.state import _AttributeDict
+from fabric.network import normalize, join_host_strings
 
 SUPPORTED_SYSTEMS = ['lenny', 'squeeze']
 
     def decorator(func):
         @wraps(func)
         def inner(*args, **kwargs):
-            old_user = env.user
-            env.user = user
+            old_user, host, port = normalize(env.host_string)
+            env.host_string = join_host_strings(user, host, port)
             result = func(*args, **kwargs)
-            env.user = old_user
+            env.host_string = join_host_strings(old_user, host, port)
             return result
         return inner
     return decorator
         return inner
     return decorator
 
+
 def upload_config_template(name, to=None):
     if to is None:
         base_dir = env.conf['ENV_DIR'] + "/etc/"
     )
     defaults.update(env.conf)
     env.conf = defaults
+
     if env.conf.OS not in SUPPORTED_SYSTEMS:
         abort('%s is not supported. Supported operating systems: %s' % (
             env.conf.OS, ', '.join(SUPPORTED_SYSTEMS)