Merge pull request #9 from Mirantis/fabric
Replace subprocess.call with fabric.api.local
This commit is contained in:
commit
9e862356d6
@ -12,3 +12,4 @@ enum34==1.0.4
|
||||
redis==2.10.3
|
||||
pytest
|
||||
fakeredis
|
||||
Fabric==1.10.2
|
||||
|
@ -18,11 +18,11 @@ On create "golden" resource should be moved to special place
|
||||
"""
|
||||
|
||||
import click
|
||||
from fabric import api as fabric_api
|
||||
import json
|
||||
import networkx as nx
|
||||
import os
|
||||
import pprint
|
||||
import subprocess
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
@ -245,7 +245,7 @@ def init_cli_connections():
|
||||
end_with=end_with)
|
||||
|
||||
nx.write_dot(g, 'graph.dot')
|
||||
subprocess.call(['dot', '-Tpng', 'graph.dot', '-o', 'graph.png'])
|
||||
fabric_api.local('dot', '-Tpng', 'graph.dot', '-o', 'graph.png')
|
||||
|
||||
# Matplotlib
|
||||
#pos = nx.spring_layout(g)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from fabric import api as fabric_api
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from solar.core.log import log
|
||||
from solar.core.handlers.base import BaseHandler
|
||||
@ -16,8 +16,8 @@ class Ansible(BaseHandler):
|
||||
log.debug('EXECUTING: %s', ' '.join(call_args))
|
||||
|
||||
try:
|
||||
subprocess.check_output(call_args)
|
||||
except subprocess.CalledProcessError as e:
|
||||
fabric_api.local(' '.join(call_args))
|
||||
except Exception as e:
|
||||
log.error(e.output)
|
||||
log.exception(e)
|
||||
raise
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import subprocess
|
||||
from fabric import api as fabric_api
|
||||
|
||||
from solar.core.handlers.base import BaseHandler
|
||||
|
||||
@ -7,4 +7,4 @@ from solar.core.handlers.base import BaseHandler
|
||||
class Shell(BaseHandler):
|
||||
def action(self, resource, action_name):
|
||||
action_file = self._compile_action_file(resource, action_name)
|
||||
subprocess.call(['bash', action_file])
|
||||
fabric_api.local('bash {}'.format(action_file))
|
||||
|
@ -1,7 +1,7 @@
|
||||
from fabric import api as fabric_api
|
||||
import os
|
||||
import requests
|
||||
import StringIO
|
||||
import subprocess
|
||||
import zipfile
|
||||
|
||||
from solar import utils
|
||||
@ -46,7 +46,6 @@ class GitProvider(BaseProvider):
|
||||
with open('/tmp/git-provider.yaml', 'w') as f:
|
||||
f.write("""
|
||||
---
|
||||
|
||||
- hosts: all
|
||||
tasks:
|
||||
- git: repo={repository} dest={destination} clone={clone} update=yes
|
||||
@ -56,12 +55,9 @@ class GitProvider(BaseProvider):
|
||||
clone='yes'
|
||||
))
|
||||
|
||||
subprocess.check_call([
|
||||
'ansible-playbook',
|
||||
'-i', '"localhost,"',
|
||||
'-c', 'local',
|
||||
'/tmp/git-provider.yaml'
|
||||
])
|
||||
fabric_api.local(
|
||||
'ansible-playbook -i "localhost," -c local /tmp/git-provider.yaml'
|
||||
)
|
||||
|
||||
|
||||
class RemoteZipProvider(BaseProvider):
|
||||
|
@ -11,8 +11,8 @@ from solar.core import actions
|
||||
db = get_db()
|
||||
|
||||
from dictdiffer import diff, patch, revert
|
||||
from fabric import api as fabric_api
|
||||
import networkx as nx
|
||||
import subprocess
|
||||
|
||||
|
||||
def guess_action(from_, to):
|
||||
@ -101,7 +101,7 @@ def execute(res, action):
|
||||
try:
|
||||
actions.resource_action(res, action)
|
||||
return state.STATES.success
|
||||
except subprocess.CalledProcessError:
|
||||
except Exception as e:
|
||||
return state.STATES.error
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user