def after_vm_start(self, environ, domxml): # check if the vm was launched in the paused state launch_flags = hooking.load_vm_launch_flags_from_file(environ['vmId']) if launch_flags == libvirt.VIR_DOMAIN_START_PAUSED: # sleep for a minute for each provisioned vm time.sleep(60) self.resume_paused_vm(environ) return domxml
def main(): # TODO (HACK): # This code waits for the nic to be attached to neutron for a # certain amount of time. This is one way of going around the # race between the code and the vm nic becoming active. It is # a very fragile hack, as there is no guarantee the nic will # actually be ready after this. vm_id = os.environ[VM_ID_KEY] launch_flags = hooking.load_vm_launch_flags_from_file(vm_id) if launch_flags == libvirt.VIR_DOMAIN_START_PAUSED: time.sleep(OPENSTACK_NIC_WAIT_TIME) resume_paused_vm(vm_id)
def main(): if PROVIDER_TYPE_KEY not in os.environ: return providerType = os.environ[PROVIDER_TYPE_KEY] if providerType == OPENSTACK_NET_PROVIDER_TYPE: domxml = hooking.read_domxml() vNicId = os.environ[VNIC_ID_KEY] pluginType = os.environ[PLUGIN_TYPE_KEY] sys.stderr.write('Adding vNIC %s for provider type %s and plugin %s' % (vNicId, providerType, pluginType)) addOpenstackVnic(domxml, pluginType, vNicId) hooking.write_domxml(domxml) vm_id = os.environ[VM_ID_KEY] PAUSE_FLAG = libvirt.VIR_DOMAIN_START_PAUSED flags = hooking.load_vm_launch_flags_from_file(vm_id) if (flags & PAUSE_FLAG) != PAUSE_FLAG: flags |= PAUSE_FLAG hooking.dump_vm_launch_flags_to_file(vm_id, flags) mark_for_unpause(vm_id)
def main(): if PROVIDER_TYPE_KEY not in os.environ: return providerType = os.environ[PROVIDER_TYPE_KEY] if providerType == OPENSTACK_NET_PROVIDER_TYPE: domxml = hooking.read_domxml() vNicId = os.environ[VNIC_ID_KEY] pluginType = os.environ[PLUGIN_TYPE_KEY] hasSecurityGroups = SECURITY_GROUPS_KEY in os.environ sys.stderr.write('Adding vNIC %s for provider type %s and plugin %s' % (vNicId, providerType, pluginType)) addOpenstackVnic(domxml, pluginType, vNicId, hasSecurityGroups) hooking.write_domxml(domxml) vm_id = os.environ[VM_ID_KEY] PAUSE_FLAG = libvirt.VIR_DOMAIN_START_PAUSED flags = hooking.load_vm_launch_flags_from_file(vm_id) if (flags & PAUSE_FLAG) != PAUSE_FLAG: flags |= PAUSE_FLAG hooking.dump_vm_launch_flags_to_file(vm_id, flags) mark_for_unpause(vm_id)
def add_launch_paused_flag(self, environ): vm_id = environ['vmId'] flags = hooking.load_vm_launch_flags_from_file(vm_id) flags |= libvirt.VIR_DOMAIN_START_PAUSED hooking.dump_vm_launch_flags_to_file(vm_id, flags)
def after_vm_start(self, environ, domxml): vm_id = environ['vmId'] launch_flags = hooking.load_vm_launch_flags_from_file(vm_id) if launch_flags == libvirt.VIR_DOMAIN_START_PAUSED: self.resume_paused_vm(environ) return domxml