Exemple #1
0
def load_e3vswitch_interfaces_from_db():
    session = db_sessions[DB_NAME]()
    try:
        session.begin()
        ifaces = session.query(E3VswitchInterface).all()
        for iface in ifaces:
            root_keeper.set('vswitch_interface', iface.id, iface.clone())
    finally:
        session.close()
Exemple #2
0
def load_vswitch_topology_edges_from_db():
    session = db_sessions[DB_NAME]()
    try:
        session.begin()
        edges = session.query(E3TopologyEdge).all()
        for edge in edges:
            root_keeper.set('topology_edge', edge.id, edge.clone())
    finally:
        session.close()
Exemple #3
0
def load_e3vswitch_hosts_from_db():
    session = db_sessions[DB_NAME]()
    try:
        session.begin()
        hosts = session.query(E3VswitchHost).all()
        for host in hosts:
            root_keeper.set('vswitch_host', host.id, host.clone())
    finally:
        session.close()
Exemple #4
0
def load_e3switch_lanzone_from_db():
    session = db_sessions[DB_NAME]()
    try:
        session.begin()
        lanzones = session.query(E3VswitchLANZone).all()
        for lanzone in lanzones:
            root_keeper.set('vswitch_lan_zone', lanzone.id, lanzone.clone())
    finally:
        session.close()
Exemple #5
0
def load_tokens_from_db():
    session = db_sessions[DB_NAME]()
    try:
        session.begin()
        tokens = session.query(Token).all()
        for token in tokens:
            root_keeper.set('token', token.id, token.clone())
    finally:
        session.close()
 def register_or_update_object_post(self, root_key, sub_key, success):
     e3loger.debug('post registery call:<%s,%s> %s' %
                   (root_key, sub_key, success))
     if success:
         obj, valid = root_keeper.get(root_key, sub_key)
         if valid:
             root_keeper.invalidate(root_key, sub_key)
         else:
             root_keeper.set(root_key, sub_key, None, False)
def load_tenants_from_db():
    session = db_sessions[DB_NAME]()
    try:
        session.begin()
        tenants = session.query(Tenant).all()
        for tenant in tenants:
            root_keeper.set('tenant', tenant.id, tenant.clone())
    finally:
        session.close()
def laod_ether_services_from_db():
    session = db_sessions[DB_NAME]()
    try:
        session.begin()
        services = session.query(E3EtherService).all()
        for svc in services:
            root_keeper.set('ether_service', svc.id, svc.clone())
    finally:
        session.close()
def load_ether_service_vlans_from_db():
    session = db_sessions[DB_NAME]()
    try:
        session.begin()
        vlans = session.query(E3EtherServiceVlan).all()
        for vlan in vlans:
            root_keeper.set('ether_service_vlan', vlan.id, vlan.clone())
    finally:
        session.close()
 def set_raw_object(self, root_key, sub_key, raw_obj):
     if self._isReady() is False:
         e3loger.warning('synchronization state not ready')
         return False, 'sync base not ready'
     try:
         root_keeper.set(root_key, sub_key, raw_obj, True)
         e3loger.info('set raw object for <%s,%s> as %s' %
                      (root_key, sub_key, raw_obj))
         return True, None
     except Exception as e:
         e3loger.error('failed to set raw object for <%s,%s>' %
                       (root_key, sub_key))
         return False, e
 def get_object(self, root_key, sub_key):
     try:
         obj, valid = root_keeper.get(root_key, sub_key)
         if not valid:
             obj = dispatching_for_retrieval[root_key](
                 **sub_key_to_args[root_key](sub_key))
             #if the object can not be retrieved, an exception must be thrown
             #anyway add an assertion here for sanity check purpose
             assert (obj)
             root_keeper.set(root_key, sub_key, obj, True)
         return obj
     except Exception as e:
         e3loger.error('with given root_key:%s,sub_key:%s' %
                       (str(root_key), str(sub_key)))
         e3loger.error(str(traceback.format_exc()))
         raise e
Exemple #12
0
 def sync_state(self):
     root_keeper.set(root_key, self.id, self)