Example #1
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
Example #2
0
 def show(self, req, *args, **kwargs):
     try:
         url = req.url
         if len(args) != 1:
             raise BadRequest(resource="netservice operation", msg=url)
         json_body = req.body
         context = req.context
         dic = json.loads(json_body)
         list_ = ['id']
         dic_body = tools.firewall_params(dic, list_)
         LOG.info(_LI("get_vlan body is %(json)s, args is %(args)s,"
                      "kwargs is %(kwargs)s"),
                  {"json": dic, "args": args, "kwargs": kwargs})
         response = self.manager.get_netservice(context, dic_body)
         return response
     except Nca47Exception as e:
         LOG.error(_LE('Nca47Exception! error info: ' + e.message))
         self.response.status = e.code
         return tools.ret_info(e.code, e.message)
     except MessagingException as e:
         self.response.status = 500
         return tools.ret_info(self.response.status, e.value)
     except Exception as e:
         LOG.error(_LE('Exception! error info: ' + e.message))
         self.response.status = 500
         message = "the values of the body format is error"
         return tools.ret_info(self.response.status, message)
Example #3
0
 def show(self, req, id, *args, **kwargs):
     """get one dns zone info"""
     # get the context
     context = req.context
     try:
         if kwargs.get('device'):
             LOG.info(_(" args is %(args)s"), {"args": args})
             # from rpc server get the zone in device
             zones = self.manager.get_zones(context)
         else:
             LOG.info(_(" args is %(args)s"), {"args": args})
             # from rpc server get the zone in db
             zones = self.manager.get_zone_db_details(context, id)
     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 RemoteError 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
         return tools.ret_info(self.response.status, exception.message)
     return zones
Example #4
0
 def show(self, req, *args, **kwargs):
     context = req.context
     try:
         if len(args) != 1:
             raise BadRequest(resource="show packetfilter operation",
                              msg=req.url)
         body_values = json.loads(req.body)
         valid_attributes = ['id']
         values = tools.validat_values(body_values, valid_attributes)
         packetfilter_info = self.manager.get_packetfilter(context, values)
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         self.response.status = e.code
         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 packetfilter_info
Example #5
0
 def create(self, req, *args, **kwargs):
     """create the dns proximitys"""
     # get the context
     context = req.context
     try:
         # get the body
         values = json.loads(req.body)
         # get the url
         url = req.url
         # if len(args) != 1:
         #     raise BadRequest(resource="proximity create", msg=url)
         # check the in values
         valid_attributes = ['tenant_id', 'priority', 'src_type',
                             'src_logic', 'src_data1', 'dst_type',
                             'dst_logic', 'dst_data1']
         # check the in values
         recom_msg = self.validat_parms(values, valid_attributes)
         LOG.info(_("the in value body is %(body)s"), {"body": values})
         # from rpc server create the proximitys in db and device
         proximitys = self.manager.create_sp_policy(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 RemoteError as e:
         self.response.status = 500
         message = e.value
         return tools.ret_info(self.response.status, message)
     except Exception as exception:
         LOG.exception(exception)
         self.response.status = 500
         return tools.ret_info(self.response.status, exception.message)
     return proximitys
Example #6
0
 def list(self, req, *args, **kwargs):
     context = req.context
     try:
         if len(args) != 1:
             raise BadRequest(resource="list packetfilters operation",
                              msg=req.url)
         body_values = json.loads(req.body)
         valid_attributes = ['tenant_id', 'dc_name', 'network_zone',
                             'vfwname']
         values = tools.validat_values(body_values, valid_attributes)
         packetfilter_infos = self.manager.get_all_packetfilters(context,
                                                                 values)
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         self.response.status = e.code
         return tools.ret_info(e.code, e.message)
     except RemoteError as exception:
         self.response.status = 500
         message = exception.value
         return tools.ret_info(self.response.status, message)
     except Exception as e:
         LOG.exception(e)
         self.response.status = 500
         return tools.ret_info(self.response.status, e.message)
     return packetfilter_infos
Example #7
0
 def create(self, req, *args, **kwargs):
     try:
         url = req.url
         if len(args) != 1:
             raise BadRequest(resource="vlan operation", msg=url)
         json_body = req.body
         context = req.context
         dic = json.loads(json_body)
         list_ = ['tenant_id', 'dc_name', 'vlan_id',
                  'network_zone', 'ipaddr', "ifnames"]
         dic_body = tools.firewall_params(dic, list_)
         LOG.info(_LI("add_vlan body is %(json)s,args is %(args)s,"
                      "kwargs is %(kwargs)s"),
                  {"json": dic, "args": args, "kwargs": kwargs})
         response = self.manager.create_vlan(context, dic_body)
         return response
     except Nca47Exception as e:
         LOG.error(_LE('Nca47Exception! error info: ' + e.message))
         self.response.status = e.code
         return tools.ret_info(e.code, e.message)
     except MessagingException as e:
         self.response.status = 500
         return tools.ret_info(self.response.status, e.value)
     except Exception as e:
         LOG.error(_LE('Exception! error info: ' + e.message))
         self.response.status = 500
         message = "the values of the body format is error"
         return tools.ret_info(self.response.status, message)
Example #8
0
    def clean_cache(self, *args, **kwargs):
        list_ = ['owners', 'domain_name', 'view_name']
        req = pecan.request
        context = req.context
        try:
            # get the body
            values = json.loads(req.body)

            LOG.info(_("req is %(json)s, args is %(args)s,"
                       " kwargs is %(kwargs)s"),
                     {"json": req.body, "args": args, "kwargs": kwargs})
            self.validat_parms(values, list_)
            caches = self.manager.del_cache(context, values)
            LOG.info(_("Return of delete cache JSON is %(zones)s !"),
                     {"zones": caches})
        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 RemoteError 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
            return tools.ret_info(self.response.status, exception.message)
        return caches
Example #9
0
 def update(self, req, id, *args, **kwargs):
     """
     update GPool method
     :param req:
     :param args:
     :param kwargs:
     :return:
     """
     context = req.context
     try:
         values = json.loads(req.body)
         values['id'] = id
         url = req.url
         self.check_update(values)
         # recom_msg = self.validat_update(values, valid_attrbutes)
         LOG.info(_('the in value body is %(body)s'), {'body': values})
         gpools = self.manager.update_gpool(context, values)
     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(self.response.status, e.message)
     except RemoteError as e:
         self.response.status = 500
         message = e.value
         return tools.ret_info(self.response.status, e.message)
     except Exception as e:
         LOG.exception(e)
         self.response.status = 500
         return tools.ret_info(self.response.status, e.message)
     return gpools
Example #10
0
 def create(self, req, *args, **kwargs):
     """create the dns zone_record"""
     url = req.url
     try:
         if len(args) != 1:
             raise BadRequest(resource="record create", msg=url)
         list1 = ['name', 'type', 'rdata', "tenant_id"]
         list2 = ['ttl', 'current_user', "klass"]
         # get the body
         dic = json.loads(req.body)
         # validate the in values of the zone_record
         dic_body = tool.message_regrouping(dic, list1, list2)
         context = req.context
         LOG.info(_("req is %(json)s, args is %(args)s,"
                    "kwargs is %(kwargs)s"),
                  {"json": req.body, "args": args, "kwargs": kwargs})
         # from rpc server create the zone_record
         record = self.manager.create_record(context, dic_body, args[0])
     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 create_zone_record JSON is %(record)s !"),
              {"record": record})
     return record
Example #11
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
Example #12
0
 def remove(self, req, *args, **kwargs):
     try:
         url = req.url
         if len(args) > 1:
             raise BadRequest(resource="SNAT del", msg=url)
         context = req.context
         body_values = json.loads(req.body)
         valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'id']
         values = tools.validat_values(body_values, valid_attributes)
     # input the snat values with dic format
         LOG.info(_LI("delete Staticnat body is %(json)s"),
                  {"json": body_values})
         response = self.manager.del_snat(context, values)
         return response
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         self.response.status = e.code
         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)
Example #13
0
 def remove(self, req, *args, **kwargs):
     try:
         url = req.url
         if len(args) > 1:
             raise BadRequest(resource="VRF del", msg=url)
         context = req.context
         body_values = json.loads(req.body)
         valid_attributes = ['tenant_id', 'dc_name', 'network_zone', 'id']
         values = tools.validat_values(body_values, valid_attributes)
         # input the vrf values with dic format
         LOG.info(_LI("delete the vrf values with dic format\
                      is %(json)s"),
                  {"json": body_values})
         response = self.manager.del_vrf(context, values)
         return response
     except Nca47Exception as e:
         LOG.error(_LE('Nca47Exception! error info: ' + e.message))
         self.response.status = e.code
         return tools.ret_info(e.code, e.message)
     except RemoteError as e:
         self.response.status = 500
         return tools.ret_info(self.response.status, e.value)
     except Exception as e:
         LOG.error(_LE('Exception! error info: ' + e.message))
         self.response.status = 500
         return tools.ret_info(self.response.status, e.message)
Example #14
0
 def list(self, req, *args, **kwargs):
     """get the list of the dns zones"""
     # get the context
     context = req.context
     try:
         if 'device' in args:
             LOG.info(_(" args is %(args)s, kwargs is %(kwargs)s"),
                      {"args": args, "kwargs": kwargs})
             # from rpc server get the zones in device
             zones = self.manager.get_zones(context)
         else:
             LOG.info(_(" args is %(args)s, kwargs is %(kwargs)s"),
                      {"args": args, "kwargs": kwargs})
             # from rpc server get the zones in db
             zones = self.manager.get_all_db_zone(context)
             LOG.info(_("Return of get_all_db_zone JSON is %(zones)s !"),
                      {"zones": zones})
     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)
     LOG.info(_("Return of get_zones json is %(zones)s"), {"zones": zones})
     return zones
Example #15
0
 def remove(self, req, id, *args, **kwargs):
     """delete the dns zone_record"""
     url = req.url
     try:
         # if len(args) != 1:
         #     raise BadRequest(resource="record remove", msg=url)
         dic = {}
         dic.update(kwargs)
         list_ = ["tenant_id", "id"]
         dic['id'] = id
         dic_body = self.validat_parms(dic, list_)
         # get the body
         # validate the in values of the zone_record
         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)
     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 RemoteError 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
         return tool.ret_info(self.response.status, exception.message)
     LOG.info(_("Return of remove_record JSON  is %(record)s !"),
              {"record": record})
     return record
Example #16
0
 def remove(self, req, id, *args, **kwargs):
     """
     delete GPool method
     :param req:
     :param id:
     :param args:
     :param kwargs:
     :return: return http response
     """
     context = req.context
     try:
         url = req.url
         values = {}
         values.update(kwargs)
         values['id'] = id
         self.check_update(values)
         LOG.info(_('the in value body is %(body)s'), {'body': values})
         recom_msg = {}
         gmap = self.manager.delete_gpool(context, values)
     except Nca47Exception as e:
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         self.response.status = e.code
         return tools.ret_info(e.code, e.message)
     except RemoteError 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
         return tools.ret_info(self.response.status, exception.message)
     return gmap
Example #17
0
 def list(self, req, *args, **kwargs):
     try:
         url = req.url
         if len(args) != 1:
             raise BadRequest(resource="vlan operation", msg=url)
         context = req.context
         json_body = req.body
         dic = json.loads(json_body)
         LOG.info(_LI("get_all_vlan body is %(json)s, args is %(args)s,"
                      "kwargs is %(kwargs)s"),
                  {"json": dic, "args": args, "kwargs": kwargs})
         list_ = ['tenant_id', 'dc_name', 'network_zone']
         dic_body = self.firewall_params(dic, list_)
         response = self.manager.get_vlans(context, dic_body)
         return response
     except Nca47Exception as e:
         LOG.error(_LE('Nca47Exception! error info: ' + e.message))
         self.response.status = e.code
         return tools.ret_info(e.code, e.message)
     except RemoteError as e:
         self.response.status = 500
         return tools.ret_info(self.response.status, e.value)
     except Exception as e:
         LOG.error(_LE('Exception! error info: ' + e.message))
         self.response.status = 500
         return tools.ret_info(self.response.status, e.message)
Example #18
0
 def remove(self, req, id, *args, **kwargs):
     """
     delete the syngroup method
     :param req:
     :param id:
     :param args:
     :param kwargs:
     :return:
     """
     context = req.context
     try:
         values = json.loads(req.body)
         values['id'] = id
         self.check_remove(values)
         LOG.info(_('the in value body is %(body)s'), {'body': values})
         syngroup = self.manager.delete_syngroup(context, values)
     except Nca47Exception as e:
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         self.response.status = e.code
         return tools.ret_info(e.code, e.message)
     except RemoteError 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
         return tools.ret_info(self.response.status, exception.message)
     return syngroup
Example #19
0
 def remove(self, req, *args, **kwargs):
     """del the snataddrpool"""
     url = req.url
     try:
         # get the right url
         if len(args) != 1:
             raise BadRequest(resource="AddrPool operation", msg=url)
         # get the body
         json_body = req.body
         # get the context
         context = req.context
         values = json.loads(json_body)
         # check the in values
         valid_attributes = ['tenant_id', 'dc_name', 'id', 'network_zone',
                             'vfwname']
         # check the in values
         recom_msg = self.validat_values(values, valid_attributes)
         LOG.info(_("the in value body is %(body)s"), {"body": values})
         # from rpc server delete the snataddrpool in db and device
         snataddrpool = self.manager.del_snataddrpool(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 snataddrpool
Example #20
0
 def get(self, req, *args, **kwargs):
     """
     # get info for one or more
     :param req:
     :param args:
     :param kwargs:
     :return:
     """
     context = req.context
     try:
         LOG.info(
             _("args is %(args)s,kwargs is %(kwargs)s"), {
                 'args': args, "kwargs": kwargs})
         syngroup = self.manager.get_syngroups(context)
         LOG.info(_("Retrun of get_all_db_zone JSON is %(syngroup)s !"),
                  {"syngroup": syngroup})
     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 RemoteError as e:
         self.response.status = 500
         message = e.value
         return tools.ret_info(self.response.status, message)
     except Exception as exception:
         LOG.exception(exception)
         self.response.status = 500
         return tools.ret_info(self.response.status, exception.message)
     return syngroup
Example #21
0
    def list(self, req, *args, **kwargs):
        try:
            url = req.url
            if len(args) > 1:
                raise BadRequest(resource="staticnat getAll", msg=url)
            context = req.context
            body_values = json.loads(req.body)
            valid_attributes = ['tenant_id', 'dc_name',
                                'network_zone', 'vfwname']
            values = tools.validat_values(body_values, valid_attributes)

            # input the staticnat values with dic format
            LOG.info(_LI("get_all the staticnat values with dic format\
                         is %(json)s"),
                     {"json": body_values})

            response = self.manager.get_staticnats(context, values)
            return response
        except Nca47Exception as e:
            self.response.status = e.code
            LOG.error(_LE('Error exception! error info: %' + e.message))
            LOG.exception(e)
            self.response.status = e.code
            return tools.ret_info(e.code, e.message)
        except RemoteError as exception:
            self.response.status = 500
            message = exception.value
            return tools.ret_info(self.response.status, message)
        except Exception as e:
            LOG.exception(e)
            self.response.status = 500
            return tools.ret_info(self.response.status, e.message)
Example #22
0
 def show(self, req, id, *args, **kwargs):
     """
     get syngroup by id
     :param req:
     :param id:
     :param args:
     :param kwargs:
     :return: return http response
     """
     context = req.context
     try:
         LOG.info(_("args is %(args)s"), {"args": args})
         syngroup = self.manager.get_syngroup(context, id)
     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 RemoteError 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
         return tools.ret_info(self.response.status, exception.message)
     return syngroup
Example #23
0
 def list(self, req, *args, **kwargs):
     """get the list of the dns proximitys"""
     # get the context
     context = req.context
     try:
         # get the body
         values = {}
         values.update(req.GET)
         LOG.info(_(" args is %(args)s, kwargs is %(kwargs)s"),
                  {"args": args, "kwargs": kwargs})
         # check the in values
         valid_attributes = ['tenant_id']
         recom_msg = self.validat_parms(values, valid_attributes)
         # from rpc server get the proximitys in device
         proximitys = self.manager.get_db_proximitys(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 RemoteError 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
         return tools.ret_info(self.response.status, exception.message)
     return proximitys
Example #24
0
 def create(self, req, *args, **kwargs):
     """
     Create syngorup method
     :param req:
     :param args:
     :param kwargs:
     :return:
     """
     context = req.context
     try:
         values = json.loads(req.body)
         url = req.url
         valid_attributes = [
             "tenant_id",
             "name",
         ]
         self.check_create(valid_attributes, values)
         LOG.info(_('the in value body is %(body)s'), {'body': values})
         syngroups = self.manager.create_syngroup(context, values)
     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(self.response.status, e.message)
     except RemoteError as e:
         self.response.status = 500
         message = e.value
         return tools.ret_info(self.response.status, message)
     except Exception as e:
         LOG.exception(e)
         self.response.status = 500
         return tools.ret_info(self.response.status, e.message)
     return syngroups
Example #25
0
 def update(self, req, id, *args, **kwargs):
     """update the dns proximitys by currentUser/owners"""
     # get the context
     context = req.context
     try:
         # get the url
         url = req.url
         # if len(args) != 1:
         #     raise BadRequest(resource="proximity update", msg=url)
         # get the body
         values = json.loads(req.body)
         values['id'] = id
         LOG.info(_("the in value body is %(body)s"), {"body": values})
         # check the in values
         valid_attributes = ['new_priority', 'tenant_id', 'id']
         recom_msg = self.validat_parms(values, valid_attributes)
         # from rpc server update the proximitys in db and device
         proximitys = self.manager.update_sp_policy(context, recom_msg,
                                                    recom_msg['id'])
     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 RemoteError 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
         return tools.ret_info(self.response.status, exception.message)
     return proximitys
Example #26
0
 def update(self, req, id, *args, **kwargs):
     """
     update Syngroup method
     :param req:
     :param args:
     :param kwargs:
     :return:
     """
     context = req.context
     try:
         url = req.url
         values = json.loads(req.body)
         values['id'] = id
         LOG.info(_("the in value body if %(body)s"), {'body': values})
         self.check_update(values)
         syngroups = self.manager.update_syngroup(
             context, values)
         # args[0] is id
     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 RemoteError as exception:
         self.reponse.status = 500
         message = exception.value
         return tools.ret_info(self.reponse.status, message)
     except Exception as exception:
         LOG.exception(exception)
         self.response.status = 500
         return tools.ret_info(self.response.status, exception.message)
     return syngroups
Example #27
0
 def remove(self, req, id, *args, **kwargs):
     """delete the dns zones"""
     # get the context
     context = req.context
     try:
         # get the url
         url = req.url
         # if len(args) != 1:
         #     raise BadRequest(resource="zone delete", msg=url)
         # get the body
         values = {}
         values.update(kwargs)
         values['id'] = id
         LOG.info(_("the in value body is %(body)s"), {"body": values})
         # check the in values
         valid_attributes = ['tenant_id', 'id']
         recom_msg = self.validat_parms(values, valid_attributes)
         # from rpc server delete the zones in db and device
         zones = self.manager.delete_zone(context, recom_msg['id'])
     except Nca47Exception as e:
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         self.response.status = e.code
         return tools.ret_info(e.code, e.message)
     except RemoteError 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
         return tools.ret_info(self.response.status, exception.message)
     return zones
Example #28
0
 def show(self, req, *args, **kwargs):
     """get the one addrobj"""
     url = req.url
     try:
         # get the right url
         if len(args) != 1:
             raise BadRequest(resource="addrobj operation", msg=url)
         # get the body
         json_body = req.body
         # get the context
         context = req.context
         values = json.loads(json_body)
         # check the in values
         valid_attributes = ['id']
         # check the in values
         recom_msg = self.validat_values(values, valid_attributes)
         LOG.info(_("the in value body is %(body)s"), {"body": values})
         # from rpc server get the addrobj in db and device
         addrobj = self.manager.get_addrobj(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 addrobj
Example #29
0
 def remove(self, req, *args, **kwargs):
     context = req.context
     try:
         if len(args) != 1:
             raise BadRequest(resource="delete dnat operation",
                              msg=req.url)
         body_values = json.loads(req.body)
         valid_attributes = ['id', 'tenant_id', 'dc_name', 'network_zone']
         values = tools.validat_values(body_values, valid_attributes)
         response = self.manager.delete_dnat(context, values)
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE('Error exception! error info: %' + e.message))
         LOG.exception(e)
         self.response.status = e.code
         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 response
Example #30
0
 def list(self, req, *args, **kwargs):
     try:
         url = req.url
         if len(args) > 1:
             raise BadRequest(resource="SecurityZone getAll", msg=url)
         context = req.context
         body_values = json.loads(req.body)
         valid_attributes = ["tenant_id", "dc_name", "network_zone"]
         values = tools.validat_values(body_values, valid_attributes)
         # get_all the SecurityZone values with dic format
         LOG.info(_LI("get_all SecurityZone body is %(json)s"), {"json": body_values})
         response = self.manager.get_securityZones(context, values)
         return response
     except Nca47Exception as e:
         self.response.status = e.code
         LOG.error(_LE("Error exception! error info: %" + e.message))
         LOG.exception(e)
         self.response.status = e.code
         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)