本文整理汇总了Python中networkapi.interface.models.Interface.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Interface.remove方法的具体用法?Python Interface.remove怎么用?Python Interface.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkapi.interface.models.Interface
的用法示例。
在下文中一共展示了Interface.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_delete
# 需要导入模块: from networkapi.interface.models import Interface [as 别名]
# 或者: from networkapi.interface.models.Interface import remove [as 别名]
def handle_delete(self, request, user, *args, **kwargs):
"""Trata uma requisição DELETE para excluir uma interface
URL: /interface/<id_interface>/
"""
# Get request data and check permission
try:
# Valid Interface ID
id_interface = kwargs.get("id_interface")
if not is_valid_int_greater_zero_param(id_interface):
self.log.error(u"The id_interface parameter is not a valid value: %s.", id_interface)
raise InvalidValueError(None, "id_interface", id_interface)
# Get interface and equipment to check permission
interface = Interface.get_by_pk(id_interface)
id_equipamento = interface.equipamento_id
# Check permission
if not has_perm(
user,
AdminPermission.EQUIPMENT_MANAGEMENT,
AdminPermission.WRITE_OPERATION,
None,
id_equipamento,
AdminPermission.EQUIP_WRITE_OPERATION,
):
return self.not_authorized()
with distributedlock(LOCK_INTERFACE % id_interface):
# Remove interface
Interface.remove(user, id_interface)
return self.response(dumps_networkapi({}))
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)