def set_firewall_profile(vm, profile, nic): log.info("Setting VM %s, NIC %s, firewall %s", vm, nic, profile) if profile not in [x[0] for x in NetworkInterface.FIREWALL_PROFILES]: raise faults.BadRequest("Unsupported firewall profile") backend.set_firewall_profile(vm, profile=profile, nic=nic) return None
def set_firewall_profile(server_id, profile, nic_id, credentials=None, atomic_context=None): with commands.ServerCommand("SET_FIREWALL_PROFILE", server_id, credentials, atomic_context) as vm: nic = util.get_vm_nic(vm, nic_id) log.info("Setting VM %s, NIC %s, firewall %s", vm, nic, profile) if profile not in [x[0] for x in NetworkInterface.FIREWALL_PROFILES]: raise faults.BadRequest("Unsupported firewall profile") backend.set_firewall_profile(vm, profile=profile, nic=nic) return vm
def set_firewall_profile(request, vm, args): # Normal Response Code: 200 # Error Response Codes: computeFault (400, 500), # serviceUnavailable (503), # unauthorized (401), # badRequest (400), # badMediaType(415), # itemNotFound (404), # buildInProgress (409), # overLimit (413) profile = args.get('profile', '') log.info("Set VM %s firewall %s", vm, profile) if profile not in [x[0] for x in NetworkInterface.FIREWALL_PROFILES]: raise faults.BadRequest("Unsupported firewall profile") backend.set_firewall_profile(vm, profile) return HttpResponse(status=202)