示例#1
0
def urlmapping_group_delete(db, urlmapping_groupname):
    #return showalldevices(db)
    dm2 = urlmapping_mgmt(db=db)
    ret = dm2.delete_urlmapping(urlmapping_groupname)
    if ret == False:
        response.status = HTTP_SERVER_ERROR
        return dict(error='failed to delete urlmapping .')
    
    return dict(ok='ok')
示例#2
0
 def getFileName(self, schemapath):
     import re
     processUrlfileName = None
     urlmappingClass = urlmapping_mgmt(None,self.dbfile)
     templateMap = urlmappingClass.find_urlmappingbygroup("sshengine");
     if (templateMap == None) :
         return None
     for elem in templateMap:  
         urlpath = elem.get("uriregular")   
         fileName = elem.get("modulename")   
         #fileName = self.templateMap[elem]
         result = re.match(urlpath, schemapath)
         if (result != None):
             processUrlfileName = fileName 
             break
     return processUrlfileName
示例#3
0
def urlmapping_post(db):
    
    body= request.body
    ddict = body.read()
    try:
        urlmapping = json.loads(ddict)
        
        groupname = urlmapping['groupname']
        uriregular = urlmapping['uriregular']
        modulename = urlmapping['modulename']
        
        dm2 = urlmapping_mgmt(db=db)
        ret = dm2.add_urlmapping(groupname, uriregular, modulename)
  
        if ret == False:
            response.status = HTTP_SERVER_ERROR
            return dict(error='failed to create urlmapping .')
        else:
            return dict(ok='ok')
    except Exception, e:
        response.status = HTTP_SERVER_ERROR
        return dict(error=e.message)
示例#4
0
def initUrlmapping():
    urlmappingclass = urlmapping_mgmt(None,dbfile)
    #groupname,uriregular,modulename
    urlmappingclass.add_urlmapping('sshengine', '^inventory/interfaces/interface\\?portID=.*$', 'ovs.portflow') 
    urlmappingclass.add_urlmapping('sshengine', '^netmonitorPortMirror/portMirrors/portMirror$', 'ovs.portmirror') 
    urlmappingclass.add_urlmapping('sshengine', '^qos/cars', 'ovs.qoscar') 
示例#5
0
def urlmapping_get(db):
    #return showalldevices(db)
    dm2 = urlmapping_mgmt(db=db)
    namelist = dm2.getAllUrlmappingInfo()
    return {'urlmappings':namelist}
示例#6
0
def urlmapping_get_bygroupname(db, urlmapping_groupname):
    #return showalldevices(db)
    dm2 = urlmapping_mgmt(db=db)
    namelist = dm2.find_urlmappingbygroup(urlmapping_groupname)
    return {'urlmappings':namelist}
示例#7
0
def urlmapping_get_byid(db, urlmapping_id):
    #return showalldevices(db)
    dm2 = urlmapping_mgmt(db=db)
    namelist = dm2.find_urlmappingbyid(urlmapping_id)
    return {'urlmappings':namelist}        
示例#8
0
from network_mgmt import NetworkM

from plugin.auth_backend import AuthBackend

main_app=bottle.Bottle()

#get dbfile's handle
dbfile=config.dbFile
sqlite_plugin=SQLitePlugin(dbfile)
network_devices=NetworkM()
g_enableAuth=False
g_enableWhiteList=False
g_channelnum=2
g_checkesn=False
g_aaa=AuthBackend(dbfile, True)
g_urlmappingclass=urlmapping_mgmt(None,dbfile)

HTTP_UNAUTHORIZED_ACCESS = 401
HTTP_SERVER_ERROR = 500
HTTP_RESPONSE_OK = 200
HTTP_RESOURCE_EMPTY = 204
HTTP_RESOURCE_NOTFIND = 404
HTTP_CONTENT_TYPE_JSON = "application/json"
HTTP_CONTENT_TYPE_XML = "application/xml"
logger = logging.getLogger("ops.web") 

def myauth_basic(needrole, realm="login", text="Access denied"):
    ''' Callback decorator to require HTTP auth (basic).
        TODO: Add route(check_auth=...) parameter. '''
    def decorator(func):
        def wrapper(*a, **ka):