def set_static_ip_address(self, payload):
<EOL>macaddr = payload.get('<STR_LIT>')<EOL>ipaddr = payload.get('<STR_LIT>')<EOL>req = dict(mac=macaddr)<EOL>instances = self.get_vms_for_this_req(**req)<EOL>for vm in instances:<EOL><INDENT>LOG.info('<STR_LIT>',<EOL>{'<STR_LIT>': ipaddr, '<STR_LIT>': macaddr})<EOL>try:<EOL><INDENT>rule_info = dict(ip=ipaddr, mac=macaddr,<EOL>port=vm.port_id,<EOL>status='<STR_LIT>')<EOL>self.neutron_event.update_ip_rule(str(vm.host),<EOL>str(rule_info))<EOL><DEDENT>except (rpc.MessagingTimeout, rpc.RPCException,<EOL>rpc.RemoteError):<EOL><INDENT>LOG.error("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>params = dict(columns=dict(ip=ipaddr))<EOL>self.update_vm_db(vm.port_id, **params)<EOL>vm_info = dict(status=vm.status, vm_mac=vm.mac,<EOL>segmentation_id=vm.segmentation_id,<EOL>host=vm.host, port_uuid=vm.port_id,<EOL>net_uuid=vm.network_id,<EOL>oui=dict(ip_addr=ipaddr,<EOL>vm_name=vm.name,<EOL>vm_uuid=vm.instance_id,<EOL>gw_mac=vm.gw_mac,<EOL>fwd_mod=vm.fwd_mod,<EOL>oui_id='<STR_LIT>'))<EOL>try:<EOL><INDENT>self.neutron_event.send_vm_info(vm.host,<EOL>str(vm_info))<EOL><DEDENT>except (rpc.MessagingTimeout, rpc.RPCException,<EOL>rpc.RemoteError):<EOL><INDENT>LOG.error('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>
Set static ip address for a VM.