Skip to content

Commit

Permalink
In VM UVE we have interface list and for each of these interfaces we …
Browse files Browse the repository at this point in the history
…send the VM Name. This name is populated by Nova msg. For Non-nova VMIs this field has empty string in agent. While sending UVE for such VMIs we need to pick VM name from VM object instead of VMI.

Closes-Bug: #1416345

Change-Id: I28adcf98f97ba4c736fa388571969fd218f30b65
  • Loading branch information
ashoksr committed Jan 30, 2015
1 parent 704b14f commit 5318438
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
64 changes: 64 additions & 0 deletions src/vnsw/agent/uve/test/test_vm_uve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,70 @@ TEST_F(UveVmUveTest, VmChangeOnVMI) {
vmut->ClearCount();
}

/* Verify that VM name is not NULL-string in the interface list sent as part of
* VM UVE */
TEST_F(UveVmUveTest, VmNameInInterfaceList) {
VmUveTableTest *vmut = static_cast<VmUveTableTest *>
(Agent::GetInstance()->uve()->vm_uve_table());
struct PortInfo input[] = {
{"vmi1", 1, "1.1.1.1", "00:00:00:01:01:01", 1, 1}
};

//Add physical-device and physical-interface and add their association
util_.VmAdd(input[0].vm_id);
AddPhysicalDevice("prouter1", 1);
AddPhysicalInterface("pi1", 1, "pid1");
AddLogicalInterface("li1", 1, "lid1");
AddPort("vmi1", 1);
AddLink("physical-router", "prouter1", "physical-interface", "pi1");
AddLink("physical-interface", "pi1", "logical-interface", "li1");
AddLink("virtual-machine-interface", "vmi1", "logical-interface", "li1");
AddLink("virtual-machine-interface", "vmi1", "virtual-machine", "vm1");
client->WaitForIdle();
WAIT_FOR(1000, 500, (PhysicalDeviceGet(1) != NULL));
WAIT_FOR(1000, 500, (PhysicalInterfaceGet("pi1") != NULL));
WAIT_FOR(1000, 500, (LogicalInterfaceGet(1, "li1") != NULL));
WAIT_FOR(1000, 500, (VmInterfaceGet(1) != NULL));

//Verify UVE
VmEntry *vm = VmGet(input[0].vm_id);
EXPECT_TRUE(vm != NULL);
UveVirtualMachineAgent *uve1 = vmut->VmUveObject(vm);
EXPECT_TRUE(uve1 != NULL);
EXPECT_EQ(1U, uve1->get_interface_list().size());

//Verify that VMI does not have VM Name set
VmInterface *vmi = VmInterfaceGet(input[0].intf_id);
EXPECT_TRUE((vmi->vm_name() == agent_->NullString()));

//Verify that UVE has sent VM name for VMI
VmInterfaceAgent intf_entry = uve1->get_interface_list().front();
EXPECT_TRUE((intf_entry.get_vm_name() == vm->GetCfgName()));

//cleanup
DelLink("virtual-machine-interface", "vmi1", "virtual-machine", "vm1");
DelNode("virtual-machine", "vm1");
//Disassociate VMI from logical-interface
DelLink("virtual-machine-interface", "vmi1", "logical-interface", "li1");
//Disassociate logical-interface from physical_interface
DelLink("physical-interface", "pi1", "logical-interface", "li1");
//Disassociate physical-device from physical-interface
DelLink("physical-router", "prouter1", "physical-interface", "pi1");
//Delete physical-device and physical-interface
DelPort("vmi1");
DeleteLogicalInterface("li1");
DeletePhysicalInterface("pi1");
DeletePhysicalDevice("prouter1");
client->WaitForIdle();
WAIT_FOR(1000, 500, (PhysicalInterfaceGet("pi1") == NULL));
WAIT_FOR(1000, 500, (PhysicalDeviceGet(1) == NULL));
WAIT_FOR(1000, 500, (LogicalInterfaceGet(1, "li1") == NULL));

//clear counters at the end of test case
client->Reset();
vmut->ClearCount();
}

int main(int argc, char **argv) {
GETUSERARGS();
client = TestInit(init_file, ksync_init, true, false, true,
Expand Down
11 changes: 10 additions & 1 deletion src/vnsw/agent/uve/vm_uve_entry_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ bool VmUveEntryBase::FrameInterfaceMsg(const VmInterface *vm_intf,
return false;
}
s_intf->set_name(vm_intf->cfg_name());
s_intf->set_vm_name(vm_intf->vm_name());
/* VM interfaces which are not created by Nova will not have VM name set.
* In that case pick VM name from VM object instead of VMI object */
if (vm_intf->vm_name() != agent_->NullString()) {
s_intf->set_vm_name(vm_intf->vm_name());
} else {
const VmEntry *vm = vm_intf->vm();
if (vm) {
s_intf->set_vm_name(vm->GetCfgName());
}
}
if (vm_intf->vn() != NULL) {
s_intf->set_virtual_network(vm_intf->vn()->GetName());
} else {
Expand Down

0 comments on commit 5318438

Please sign in to comment.