From afef94cb3215f67eab88a04cd91b04228b57e170 Mon Sep 17 00:00:00 2001 From: fuwei Date: Fri, 31 Mar 2023 14:16:56 +0800 Subject: [PATCH] [sugon_sdn]Add vrouter agent api call when stop and destory vm 1.Add vrouter agent api call when stop and destory vm 2.Change lighttpd kill timeout after tf userdata apply --- .../kvmagent/plugins/tf_net_userdata_plugin.py | 4 ++-- kvmagent/kvmagent/plugins/vm_plugin.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/kvmagent/kvmagent/plugins/tf_net_userdata_plugin.py b/kvmagent/kvmagent/plugins/tf_net_userdata_plugin.py index efe7433e3..c8eab3a90 100644 --- a/kvmagent/kvmagent/plugins/tf_net_userdata_plugin.py +++ b/kvmagent/kvmagent/plugins/tf_net_userdata_plugin.py @@ -243,9 +243,9 @@ class TfNetProviderUserdata(kvmagent.KvmAgent): linux.mkdir('/var/log/lighttpd', 0o750) # restart lighttpd to load new configuration shell.call('lighttpd -f %s' % conf_path) - if not linux.wait_callback_success(check, None, 5): + if not linux.wait_callback_success(check, None, 10): raise Exception('lighttpd[conf-file:%s] is not running ' - 'after being started %s seconds' % (conf_path, 5)) + 'after being started %s seconds' % (conf_path, 10)) @kvmagent.replyerror def release_userdata_for_tf(self, req): diff --git a/kvmagent/kvmagent/plugins/vm_plugin.py b/kvmagent/kvmagent/plugins/vm_plugin.py index 4b2f7cd77..ea7a3b640 100644 --- a/kvmagent/kvmagent/plugins/vm_plugin.py +++ b/kvmagent/kvmagent/plugins/vm_plugin.py @@ -5533,6 +5533,15 @@ class VmPlugin(kvmagent.KvmAgent): try: self._record_operation(cmd.uuid, self.VM_OP_STOP) self._stop_vm(cmd) + # notify vrouter agent nic removed from source host + for nic in cmd.nics: + if nic.type == 'TFVNIC': + vrouter_cmd = [ + 'vrouter-port-control', + '--oper=delete', + '--uuid=%s' % transform_to_tf_uuid(nic.uuid) + ] + notify_vrouter(vrouter_cmd) logger.debug("successfully stopped vm[uuid:%s]" % cmd.uuid) except kvmagent.KvmError as e: logger.warn(linux.get_exception_stacktrace()) @@ -5599,6 +5608,15 @@ class VmPlugin(kvmagent.KvmAgent): if vm: vm.destroy() ovs.OvsCtl().freeVdpa(cmd.uuid) + # notify vrouter agent nic removed from source host + for nic in cmd.vmNics: + if nic.type == 'TFVNIC': + vrouter_cmd = [ + 'vrouter-port-control', + '--oper=delete', + '--uuid=%s' % transform_to_tf_uuid(nic.uuid) + ] + notify_vrouter(vrouter_cmd) logger.debug('successfully destroyed vm[uuid:%s]' % cmd.uuid) except kvmagent.KvmError as e: logger.warn(linux.get_exception_stacktrace()) -- Gitee