Example #1
0
 def extract(self, pc, data):
     if pc == None:
         return webservice.WSPathExtractResult(error="End of requested URI")
     if pc == self._schema.dbname:
         return webservice.WSPathExtractResult(value=self._schema)
     return webservice.WSPathExtractResult(error="'%s' != '%s'" %
                                           (pc, self._schema.dbname))
Example #2
0
 def extract(self, pc, data):
     if pc == None:
         return webservice.WSPathExtractResult(error="End of requested URI")
     pc = unicode(pc, 'utf-8')
     if self._dm.is_valid_directory_name(pc):
         return webservice.WSPathExtractResult(pc)
     err = "invalid directory name %s" % pc
     return webservice.WSPathExtractResult(error=err)
Example #3
0
 def extract(self, pc, data):
     if pc == None:
         return webservice.WSPathExtractResult(error="End of requested URI")
     schema = data[self._schema.dbname]
     if schema.tables.has_key(pc):
         return webservice.WSPathExtractResult(value=pc)
     e = "Database table '%s' does not exist." % pc
     return webservice.WSPathExtractResult(error=e)
Example #4
0
    def extract(self, pc, data):
        if pc == None:
            return webservice.WSPathExtractResult(
                error="End of requested URI.")

        if compile.__protos__.has_key(pc):
            return webservice.WSPathExtractResult(value=pc)
        return webservice.WSPathExtractResult(
            error='Protocol %s does not exist.' % pc)
Example #5
0
 def extract(self, pc, data):
     if pc == None:
         return webservice.WSPathExtractResult(error="End of requested URI")
     try:
         if self._switchstats.get_dp(pc) == None:
             e = "switch '%s' is unknown" % pc
             return webservice.WSPathExtractResult(error=e)
     except ValueError, e:
         err = "invalid switch name %s" % str(pc)
         return webservice.WSPathExtractResult(error=err)
Example #6
0
 def extract(self, pc, data):
     if pc == None:
         return webservice.WSPathExtractResult(error="End of requested URI")
     try:
         interfaces = self.ws.cfg.get_interfaces()
         for item in interfaces:
             if item.name == pc:
                 return webservice.WSPathExtractResult(value=pc)
     except Exception, e:
         pass
Example #7
0
    def extract(self, pc, data):
        if pc == None:
            return webservice.WSPathExtractResult(error="End of requested URI")

        components = self._component.ctxt.get_kernel().get_all()
        for component in components:
            if component.get_name() == pc:
                return webservice.WSPathExtractResult(pc)
        e = "Unknown component '%s'" % pc
        return webservice.WSPathExtractResult(error=e)
Example #8
0
 def extract(self, pc, data):
     if pc == None:
         return webservice.WSPathExtractResult(error="End of requested URI")
     e = "Invalid db row GUID value."
     if len(pc) != 40:
         return webservice.WSPathExtractResult(error=e)
     try:
         guid = pc.decode("hex")
     except TypeError:
         return webservice.WSPathExtractResult(error=e)
     return webservice.WSPathExtractResult(value=("GUID", guid))
Example #9
0
    def extract(self, pc, data):
        global __params__

        if pc == None:
            return webservice.WSPathExtractResult(
                error="End of requested URI.")

        if __params__.has_key(pc):
            return webservice.WSPathExtractResult(value=pc)
        return webservice.WSPathExtractResult(
            error="Invalid rule parameter \'%s\'." % pc)
Example #10
0
 def extract(self, pc, data):
     if pc == None:
         return webservice.WSPathExtractResult(error="End of requested URI")
     schema = data[self._schema.dbname]
     if schema.tables.has_key(pc):
         e = "Database table '%s' already exists." % pc
         return webservice.WSPathExtractResult(error=e)
     if pc == "":
         e = "The database table name '%s' is not valid." % pc
         return webservice.WSPathExtractResult(error=e)
     # TBD: further verify db name is valid according to Storage
     return webservice.WSPathExtractResult(value=pc)
Example #11
0
    def extract(self, pc, data):
        if pc == None:
            return webservice.WSPathExtractResult(
                error="End of requested URI.")

        try:
            id = int(pc, 10)
        except ValueError:
            return webservice.WSPathExtractResult(
                error="Invalid non-integer rule id %s." % pc)

        if not self.policy.rules.has_key(id):
            return webservice.WSPathExtractResult(
                error="Rule id %s does not exist." % pc)
        return webservice.WSPathExtractResult(value=id)
Example #12
0
    def extract(self, pc, data):
        if pc == None:
            return webservice.WSPathExtractResult(
                error="End of requested URI.")

        try:
            id = int(pc, 10)
        except ValueError:
            return webservice.WSPathExtractResult(
                error="Invalid non-integer policy id %s." % pc)

        if self.policy.is_locked():
            return webservice.WSPathExtractResult(
                error="Policy is currently being updated.")
        if id != self.policy.policy_id:
            return webservice.WSPathExtractResult(
                error="Policy id %s does not exist." % pc)
        return webservice.WSPathExtractResult(value=id)
Example #13
0
class WSPathExistingSwitchName(webservice.WSPathComponent):
    def __init__(self, switchstats):
        webservice.WSPathComponent.__init__(self)
        self._switchstats = switchstats

    def __str__(self):
        return "<switch name>"

    def extract(self, pc, data):
        if pc == None:
            return webservice.WSPathExtractResult(error="End of requested URI")
        try:
            if self._switchstats.get_dp(pc) == None:
                e = "switch '%s' is unknown" % pc
                return webservice.WSPathExtractResult(error=e)
        except ValueError, e:
            err = "invalid switch name %s" % str(pc)
            return webservice.WSPathExtractResult(error=err)
        return webservice.WSPathExtractResult(pc)
Example #14
0
class WSPathValidInterfaceName(webservice.WSPathComponent):
    def __init__(self, ws):
        webservice.WSPathComponent.__init__(self)
        self.ws = ws

    def __str__(self):
        return "<interface>"

    def extract(self, pc, data):
        if pc == None:
            return webservice.WSPathExtractResult(error="End of requested URI")
        try:
            interfaces = self.ws.cfg.get_interfaces()
            for item in interfaces:
                if item.name == pc:
                    return webservice.WSPathExtractResult(value=pc)
        except Exception, e:
            pass
        e = "Invalid interface name '" + pc + "'."
        return webservice.WSPathExtractResult(error=e)
Example #15
0
    def extract(self, pc, data):
        if pc == None:
            return webservice.WSPathExtractResult(
                error="End of requested URI.")

        return webservice.WSPathExtractResult(value=pc)