Beispiel #1
0
 def remove(self, req, *args, **kwargs):
     """delete the dns zone_record"""
     url = req.url
     try:
         if len(args) != 2:
             raise BadRequest(resource="record remove", msg=url)
         list_ = ['current_user']
         # get the body
         dic = json.loads(req.body)
         # validate the in values of the zone_record
         dic_body = tool.validat_parms(dic, list_)
         c = req.context
         LOG.info(_("server is %(json)s, args is %(args)s, "
                    "kwargs is %(kwargs)s"),
                  {"json": req.body, "args": args, "kwargs": kwargs})
         """from rpc server delete the zone_record"""
         record = self.manager.delete_record(c, dic_body, args[0], args[1])
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         return tool.ret_info(e.code, e.message)
     except MessagingException as exception:
         self.response.status = 500
         message = exception.value
         return tool.ret_info(self.response.status, message)
     except Exception as exception:
         LOG.exception(exception)
         self.response.status = 500
         message = "the values of the body format error"
         return tool.ret_info(self.response.status, message)
     LOG.info(_("Return of remove_record JSON  is %(record)s !"),
              {"record": record})
     return record
Beispiel #2
0
 def remove(self, req, *args, **kwargs):
     """delete the dns zones"""
     # get the context
     context = req.context
     # check the in values
     valid_attributes = ['current_user']
     try:
         # get the url
         url = req.url
         if len(args) != 1:
             raise BadRequest(resource="zone delete", msg=url)
         # get the body
         values = json.loads(req.body)
         LOG.info(_("the in value body is %(body)s"), {"body": values})
         LOG.info(_("the id is %(id)s"), {"id": args[0]})
         # check the in values
         recom_msg = tools.validat_parms(values, valid_attributes)
         # from rpc server delete the zones in db and device
         zones = self.manager.delete_zone(context, recom_msg, args[0])
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         return tools.ret_info(e.code, e.message)
     except MessagingException as exception:
         self.response.status = 500
         message = exception.value
         return tools.ret_info(self.response.status, message)
     except Exception as exception:
         LOG.exception(exception)
         self.response.status = 500
         message = "the values of the body format error"
         return tools.ret_info(self.response.status, message)
     return zones
Beispiel #3
0
 def update(self, req, *args, **kwargs):
     """update the dns zones by currentUser/owners"""
     # get the context
     context = req.context
     try:
         # get the url
         url = req.url
         if len(args) > 2:
             raise BadRequest(resource="zone update", msg=url)
         # get the body
         values = json.loads(req.body)
         LOG.info(_("the in value body is %(body)s"), {"body": values})
         LOG.info(_("the id is %(id)s"), {"id": args[0]})
         if len(args) is 2:
             if args[1] == 'owners':
                 # check the in values
                 valid_attributes = ['owners', 'current_user']
                 recom_msg = tools.validat_parms(values, valid_attributes)
                 # from rpc server update the zones in db and device
                 zones = self.manager.update_zone_owners(context, recom_msg,
                                                         args[0])
             else:
                 # return the wrong message
                 raise BadRequest(resource="zone update", msg=url)
         else:
             # check the in values
             valid_attributes = ['default_ttl', 'current_user']
             recom_msg = tools.validat_parms(values, valid_attributes)
             # from rpc server update the zones in db and device
             zones = self.manager.update_zone(context, recom_msg, args[0])
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         return tools.ret_info(e.code, e.message)
     except MessagingException as exception:
         self.response.status = 500
         message = exception.value
         return tools.ret_info(self.response.status, message)
     except Exception as exception:
         LOG.exception(exception)
         self.response.status = 500
         message = "the values of the body format error"
         return tools.ret_info(self.response.status, message)
     return zones
Beispiel #4
0
    def clean_cache(self, *args, **kwargs):
        list_ = ['owners', 'domain_name', 'view_name', 'current_user']
        req = pecan.request
        context = req.context
        try:
            # get the body
            values = json.loads(req.body)
        except Nca47Exception as e:
            self.response.status = e.code
            LOG.error(_LE('Error exception! error info: %' + e.message))
            LOG.exception(e)
            return tool.ret_info(e.code, e.message)

        LOG.info(_("req is %(json)s, args is %(args)s,"
                   " kwargs is %(kwargs)s"),
                 {"json": req.body, "args": args, "kwargs": kwargs})
        tool.validat_parms(values, list_)
        zones = self.manager.del_cache(context, values)
        LOG.info(_("Return of delete cache JSON is %(zones)s !"),
                 {"zones": zones})
        return zones
Beispiel #5
0
 def create(self, req, *args, **kwargs):
     """create the dns zones"""
     # get the context
     context = req.context
     try:
         # get the body
         values = json.loads(req.body)
         # get the url
         url = req.url
         if len(args) != 0:
             raise BadRequest(resource="zone create", msg=url)
         if 'renewal' not in values.keys():
             raise NonExistParam(param_name='renewal')
         if values['renewal'] == 'no':
             # check the in values
             valid_attributes = ['name', 'owners', 'default_ttl', 'renewal',
                                 'current_user', 'tenant_id']
         elif values['renewal'] == 'yes':
             # check the in values
             valid_attributes = ['name', 'owners', 'default_ttl', 'renewal',
                                 'zone_content', 'slaves', 'current_user',
                                 'tenant_id']
         else:
             raise ParamValueError(param_name='renewal')
         # check the in values
         recom_msg = tools.validat_parms(values, valid_attributes)
         LOG.info(_("the in value body is %(body)s"), {"body": values})
         # from rpc server create the zones in db and device
         zones = self.manager.create_zone(context, recom_msg)
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         return tools.ret_info(e.code, e.message)
     except MessagingException as exception:
         self.response.status = 500
         message = exception.value
         return tools.ret_info(self.response.status, message)
     except Exception as exception:
         LOG.exception(exception)
         self.response.status = 500
         message = "the values of the body format error"
         return tools.ret_info(self.response.status, message)
     return zones