Esempio n. 1
0
    def setup(self):
        # Setup specific configurations
        oslo_parser = cfg.MultiConfigParser()
        parsed_buf = oslo_parser.read(cfg.CONF.config_file)

        if not len(parsed_buf) == len(cfg.CONF.config_file):
            raise utils.DMConfigError("Parsing problem")

        config = oslo_parser.parsed[0]

        # get each switch from config file
        switches = [i for i in config if str(i) != 'ml2_datacom']

        # create the actual dictionary
        for switch in switches:
            sw_dic = config[switch]
            # each field is a list, when it should be a value
            for i in sw_dic:
                if i.startswith('dm'):
                    sw_dic[i] = sw_dic[i][0]

            # get each global configuration, when not mentioned in the specific
            for field in cfg.CONF.ml2_datacom:
                if field not in sw_dic:
                    sw_dic[field] = cfg.CONF.ml2_datacom[field]

            sw_dic['rpc'] = rpc.RPC(str(sw_dic['dm_username']),
                                    str(sw_dic['dm_password']), str(switch),
                                    str(sw_dic['dm_method']))

            sw_dic['xml'] = ManagedXml()
            self.switches_dic[switch] = sw_dic
Esempio n. 2
0
def refresh_peers(sender_peer_id_str, peers_box):
    if sender_peer_id_str == "":
        return
    try:
        sender_peer_id = int(sender_peer_id_str)
    except Exception:
        messagebox.showinfo("Invalid peer ID", "Please enter numeric peer ID")
        return

    rpc_client = rpc.RPC(sender_peer_id, True)
    success = rpc_client.init()
    if not success:
        messagebox.showinfo(
            "Connection failed",
            "Unable to connect to the peer with instance ID %d." %
            sender_peer_id)
        return

    rpc_client.peers()
    current_peers = ast.literal_eval(rpc_client.recv_out())
    peers = []
    for _, peer in current_peers.items():
        peers.append(peer["username"])

    peers_box['values'] = peers
    peers_box.current(0)
Esempio n. 3
0
def set_class(queue):
    global class_data
    for node in queue:
        if not node.get('name'):
            class_data.append(
                base.Base(trace_id=node['trace_id'], level=node['level']))
        elif node.get('name') == 'db':
            class_data.append(
                db.DB(node['project'], node['service'], node['level'],
                      node['trace_id'], node['parent_id'], node['starttime'],
                      node['time']))
        elif node.get('name') == 'wsgi':
            class_data.append(
                wsgi.WSGI(node['project'], node['service'], node['level'],
                          node['trace_id'], node['parent_id'],
                          node['starttime'], node['time']))
        elif node.get('name') == 'compute_api':
            class_data.append(
                compute.compute(node['project'], node['service'],
                                node['level'], node['trace_id'],
                                node['parent_id'], node['starttime'],
                                node['time']))
        elif node.get('name') == 'rpc':
            class_data.append(
                rpc.RPC(node['project'], node['service'], node['level'],
                        node['trace_id'], node['parent_id'], node['starttime'],
                        node['time']))
        elif node.get('name') == 'driver':
            class_data.append(
                driver.driver(node['project'], node['service'], node['level'],
                              node['trace_id'], node['parent_id'],
                              node['starttime'], node['time']))
        elif node.get('name') == 'vif_driver':
            class_data.append(
                vif_driver.vif(node['project'], node['service'], node['level'],
                               node['trace_id'], node['parent_id'],
                               node['starttime'], node['time']))
        elif node.get('name') == 'neutron_api':
            class_data.append(
                neutron.neutron(node['project'], node['service'],
                                node['level'], node['trace_id'],
                                node['parent_id'], node['starttime'],
                                node['time']))
        elif node.get('name') == 'volume_api':
            class_data.append(
                volume.volume(node['project'], node['service'], node['level'],
                              node['trace_id'], node['parent_id'],
                              node['starttime'], node['time']))
        elif node.get('name') == 'nova_image':
            class_data.append(
                nova.nova(node['project'], node['service'], node['level'],
                          node['trace_id'], node['parent_id'],
                          node['starttime'], node['time']))
        else:
            class_data.append(
                stack.stack(node['project'], node['service'], node['level'],
                            node['trace_id'], node['parent_id'],
                            node['starttime'], node['time']))
Esempio n. 4
0
def send_msg(sender_peer_id_str, sender_username, message, receiver_username,
             text_area):
    if sender_peer_id_str == "":
        return
    try:
        sender_peer_id = int(sender_peer_id_str)
    except Exception:
        messagebox.showinfo("Invalid peer ID", "Please enter numeric peer ID")
        return

    rpc_client = rpc.RPC(sender_peer_id, True)
    success = rpc_client.init()
    if not success:
        messagebox.showinfo(
            "Connection failed",
            "Unable to connect to the peer with instance ID %d." %
            sender_peer_id)
        return
    rpc_client.message(sender_username, receiver_username, message)

    text_area.delete(1.0, END)
Esempio n. 5
0
'''
This script runs a Rock Properties Catalog lookup, prestack modeling,
and stacking operation.
'''

import mod_func
import rpc as rock

rpc = rock.RPC()
mod = mod_func.modeler()

# load rock properties
filters = ["[[lithology::Shale||Sandstone||Limestone]][[Delta::%2B]]"]
properties = [
    'Citation', 'Description', 'Lithology', 'Vp', 'Vs', 'Rho', 'Delta',
    'Epsilon'
]
options = ["limit=100"]

df = rpc.query(filters, properties, options)

#df.head()
#print(df.Vs[2])

# model seismic from roscks
nang = 30  # # of offset angles
dang = 1  # offset angle increment
pf = 10  # peak freq (Hz)
dt = 0.004  # sample rate (s)
vp1 = df.Vp[2]  # top material Vp
vs1 = df.Vs[2]  # top material Vs
Esempio n. 6
0
def main():
    parser = argparse.ArgumentParser(description='RPC client')
    parser.add_argument('--id', required=True, type=int, help='instance id')
    parser.add_argument('--peer', action='store_true', help='peer mode')
    parser.add_argument('--node', action='store_true', help='node mode')
    parser.add_argument('--command', required=True, type=str, help='command')
    base_args = sys.argv[1:6]
    parsed_args = parser.parse_args(base_args)

    cmd_args = sys.argv[6:]
    cmd_args_dict = {}
    for i, arg in enumerate(cmd_args):
        if i % 2 == 0:
            opt = arg[2:]
            if not arg.startswith("--"):
                error.fatal_error("Invalid option '%s'." % arg)
        else:
            cmd_args_dict[opt] = arg

    if len(cmd_args) % 2 != 0:
        error.fatal_error("Invalid command arguments.")

    is_peer = False
    if parsed_args.peer and not parsed_args.node:
        is_peer = True

    rpc_client = rpc.RPC(parsed_args.id, is_peer)
    success = rpc_client.init()
    if not success:
        error.fatal_error("Cannot connect to RPC server (%s %d)." % (
            ("peer" if is_peer else "node"), parsed_args.id))

    if parsed_args.command == "message":
        if "from" in cmd_args_dict and "to" in cmd_args_dict and "message" in cmd_args_dict:
            rpc_client.message(
                cmd_args_dict["from"], cmd_args_dict["to"], cmd_args_dict["message"])
        else:
            error.fatal_error("Missing arguments for command message.")
    elif parsed_args.command == "getlist":
        rpc_client.getlist()
    elif parsed_args.command == "peers":
        rpc_client.peers()
        print(rpc_client.recv_out())
    elif parsed_args.command == "reconnect":
        if "reg-ipv4" in cmd_args_dict and "reg-port" in cmd_args_dict:
            rpc_client.reconnect(
                cmd_args_dict["reg-ipv4"], cmd_args_dict["reg-port"])
        else:
            error.fatal_error("Missing arguments for command reconnect.")
    elif parsed_args.command == "database":
        rpc_client.database()
        print(rpc_client.recv_out())
    elif parsed_args.command == "neighbors":
        rpc_client.neighbors()
        print(rpc_client.recv_out())
    elif parsed_args.command == "connect":
        if "reg-ipv4" in cmd_args_dict and "reg-port" in cmd_args_dict:
            rpc_client.connect(
                cmd_args_dict["reg-ipv4"], cmd_args_dict["reg-port"])
        else:
            error.fatal_error("Missing arguments for command connect.")
    elif parsed_args.command == "disconnect":
        rpc_client.disconnect()
    elif parsed_args.command == "sync":
        rpc_client.sync()
    else:
        error.fatal_error("Unknown command '%s'." % parsed_args.command)
Esempio n. 7
0
fn_map = {
    'update': update,
    'progress': progress,
    'play': play,
    'connect': connect
}


async def server_fn(websocket, path):
    async for message in websocket:
        obj = json.loads(message)
        try:
            fn_map[obj['type']](obj)
        except:
            print("Error in function : " + obj['type'])
            print(sys.exc_info())
            print()


rpc = rpc.RPC()

loop = asyncio.get_event_loop()

server = websockets.serve(server_fn, 'localhost', 8765)
loop.run_until_complete(server)

# Patch nested run_until_complete
nest_asyncio.apply(loop)

loop.run_forever()
Esempio n. 8
0
#!/usr/bin/env python3

import rpc

lib = rpc.RPC()
username = None

prompt = f'¿Qué deseas hacer, {username}?' if username is not None else '¿Qué deseas hacer?'

print(prompt)
print(lib)
option = input('Escriba su opción: ')

if option == '1':
    ans = lib.add(2, b=3)
    print(ans)

elif option == '0':
    print('Saliendo del programa...')