Exemplo n.º 1
0
Arquivo: ovn.py Projeto: satva/ovn4nfv
def sign_and_send(mconfig):
    data = mconfig.get_worker_data()
    central_ip = get_my_ip()
    master_hostname = run_command('hostname')

    signed_certs = {}
    for unit in data:
        worker_hostname = unit['worker_hostname']

        if not was_invoked(worker_hostname):
            mark_invoked(worker_hostname)
            cert = unit['cert_to_sign']
            worker_subnet = get_worker_subnet()

            os.chdir('/tmp/')
            cert_file = open('/tmp/ovncontroller-req.pem', 'w+')
            cert_file.truncate(0)
            cert_file.seek(0, 0)
            cert_file.write(cert)
            cert_file.close()
            run_command(
                'sudo ovs-pki -d /certs/pki -b sign ovncontroller switch --force'
            )

            cert_file = open('ovncontroller-cert.pem', 'r')
            signed_cert = cert_file.read()

            signed_certs[worker_hostname] = {
                "central_ip": central_ip,
                "signed_cert": signed_cert,
                "master_hostname": master_hostname,
                "worker_hostname": worker_hostname,
                "worker_subnet": worker_subnet,
            }

    mconfig.send_signed_certs(signed_certs)
Exemplo n.º 2
0
def mark_invoked(*handler_ids):
    """
    Record that the handler has been invoked, for use with only_once.
    """
    for handler_id in handler_ids:
        helpers.mark_invoked(handler_id)
Exemplo n.º 3
0
 def wrapper(*args, **kwargs):
     action_id = _action_id(action)
     if not was_invoked(action_id):
         action(*args, **kwargs)
         mark_invoked(action_id)