Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def shutdownSupervisor(self):
xmlrpclib.ServerProxy('http://127.0.0.1', SupervisorTransport('', '',
'unix://%s' % self.supervisor_socket)).supervisor.shutdown()
def getAllProcessInfo(self):
server = None
protocol = self.config['xmlrpc_server_protocol']
path = self.config['xmlrpc_server_path']
uri = '{}://{}'.format(protocol, path)
self.log.debug(
'Attempting to connect to XML-RPC server "%s"', uri)
if protocol == 'unix':
server = xmlrpclib.ServerProxy(
'http://127.0.0.1',
supervisor.xmlrpc.SupervisorTransport(None, None, uri)
).supervisor
elif protocol == 'http':
server = xmlrpclib.Server(uri).supervisor
else:
self.log.debug(
'Invalid xmlrpc_server_protocol config setting "%s"',
protocol)
return None
return server.getAllProcessInfo()
def __init__(self):
super(Command, self).__init__()
self.app = celery.Celery(broker=settings.BROKER_URL)
self.server = xmlrpclib.ServerProxy(
defaults.MON_URI,
transport=supervisor.xmlrpc.SupervisorTransport(
defaults.MON_SERVER_USER, defaults.MON_SERVER_PASS,
defaults.MON_SERVER_URL)
)
self.queue = None
def handle_minemeld_engine(supervisor_url):
sserver = xmlrpclib.ServerProxy(
'http://127.0.0.1',
transport=supervisor.xmlrpc.SupervisorTransport(
None,
None,
supervisor_url
)
)
# check supervisor state
sstate = sserver.supervisor.getState()
if sstate['statecode'] == 2: # FATAL
raise RuntimeError('Supervisor state: 2')
if sstate['statecode'] != 1:
raise RuntimeError(
"Supervisor transitioning to a new state, restore not performed"
)
def get_supervisor_proxy():
proxy = xmlrpclib.ServerProxy(
'http://' + settings.INTERNAL_IPS[0],
transport=xmlrpc.SupervisorTransport(
None, None, 'unix://'+settings.SUPERVISOR_UNIX_SOCKET_FILE))
return proxy
def _connect(instance):
sock = instance.get('socket')
user = instance.get('user')
password = instance.get('pass')
if sock is not None:
host = instance.get('host', DEFAULT_SOCKET_IP)
transport = supervisor.xmlrpc.SupervisorTransport(user, password, sock)
server = xmlrpclib.ServerProxy(host, transport=transport)
else:
host = instance.get('host', DEFAULT_HOST)
port = instance.get('port', DEFAULT_PORT)
auth = '{}:{}@'.format(user, password) if user and password else ''
server = xmlrpclib.Server('http://{}{}:{}/RPC2'.format(auth, host, port))
return server.supervisor
def _reload_candidate_config(supervisor_url):
SR = redis.StrictRedis()
ckeys = SR.keys('{}*'.format(REDIS_KEY_PREFIX))
if ckeys:
for ck in ckeys:
LOG.info('Deleting {}'.format(ck))
SR.delete(ck)
LOG.info('Candidate config keys deleted')
sserver = xmlrpclib.ServerProxy(
'http://127.0.0.1',
transport=supervisor.xmlrpc.SupervisorTransport(
None,
None,
supervisor_url
)
)
# check supervisor state
sstate = sserver.supervisor.getState()
if sstate['statecode'] == 2: # FATAL
raise RuntimeError('Supervisor state: 2')
if sstate['statecode'] != 1:
raise RuntimeError(
"Supervisor transitioning to a new state, restore not performed"
)
def start_minemeld_traced(supervisor_url):
sserver = xmlrpclib.ServerProxy(
'http://127.0.0.1',
transport=supervisor.xmlrpc.SupervisorTransport(
None,
None,
supervisor_url
)
)
sserver.supervisor.startProcess('minemeld-traced', False)
LOG.info('Started minemeld-traced')
@staticmethod
def _connect(instance):
sock = instance.get('socket')
if sock is not None:
host = instance.get('host', DEFAULT_SOCKET_IP)
transport = supervisor.xmlrpc.SupervisorTransport(None, None, sock)
server = xmlrpclib.ServerProxy(host, transport=transport)
else:
host = instance.get('host', DEFAULT_HOST)
port = instance.get('port', DEFAULT_PORT)
user = instance.get('user')
password = instance.get('pass')
auth = '%s:%s@' % (user, password) if user and password else ''
server = xmlrpclib.Server('http://%s%s:%s/RPC2' % (auth, host, port))
return server.supervisor