Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.openstack4j.api.network;

import static org.junit.Assert.assertNotNull;
import static org.testng.Assert.assertEquals;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.openstack4j.api.AbstractTest;
import org.openstack4j.api.Builders;
import org.openstack4j.model.network.AllowedAddressPair;
import org.openstack4j.model.network.Port;
import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;

/**
* @author Rizwan Qamar
*/
Expand Down Expand Up @@ -42,6 +44,10 @@ private void validatePort(Port port) {
assertEquals(port.getNetworkId(), NETWORK_ID);
assertEquals(port.getCreatedTime(), DATE);
assertEquals(port.getUpdatedTime(), DATE);

AllowedAddressPair allowedAddressPair = port.getAllowedAddressPairs().iterator().next();
assertNotNull(allowedAddressPair.getIpAddress());
assertNotNull(allowedAddressPair.getMacAddress());
}

private Port getPort() {
Expand Down
6 changes: 6 additions & 0 deletions core-test/src/main/resources/network/port_external.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
"binding:vnic_type": "baremetal",
"device_id": "d90a13da-be41-461f-9f99-1dbcf438fdf2",
"device_owner": "baremetal:none",
"allowed_address_pairs": [
{
"ip_address": "192.168.0.100",
"mac_address": "00:60:2f:38:62:8d"
}
],
"created_at": "2020-10-30T22:16:01Z",
"updated_at": "2020-10-30T22:16:01Z"
}
Expand Down
14 changes: 12 additions & 2 deletions core-test/src/main/resources/network/ports_external.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"ports": [
{
"admin_state_up": false,
"allowed_address_pairs": [],
"data_plane_status": null,
"description": "",
"device_id": "",
Expand All @@ -13,6 +12,12 @@
"subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2"
}
],
"allowed_address_pairs": [
{
"ip_address": "192.168.0.100",
"mac_address": "00:60:2f:38:62:8d"
}
],
"id": "94225baa-9d3f-4b93-bf12-b41e7ce49cdb",
"mac_address": "fa:16:3e:48:b8:9f",
"name": "sample_port_1",
Expand All @@ -28,7 +33,6 @@
},
{
"admin_state_up": false,
"allowed_address_pairs": [],
"data_plane_status": null,
"description": "",
"device_id": "",
Expand All @@ -39,6 +43,12 @@
"subnet_id": "a0304c3a-4f08-4c43-88af-d796509c97d2"
}
],
"allowed_address_pairs": [
{
"ip_address": "192.168.0.101",
"mac_address": "fa:16:3e:f4:73:df"
}
],
"id": "235b09e0-63c4-47f1-b221-66ba54c21760",
"mac_address": "fa:16:3e:f4:73:df",
"name": "sample_port_2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public class NeutronPortCreate implements ModelEntity {

@JsonProperty("mac_address")
private String macAddress;


@JsonProperty("allowed_address_pairs")
private Set<NeutronAllowedAddressPair> allowedAddressPairs;

@JsonProperty("network_id")
private String networkId;

Expand Down Expand Up @@ -89,6 +92,7 @@ public static NeutronPortCreate fromPort(Port port) {
c.deviceOwner = port.getDeviceOwner();
c.securityGroups = port.getSecurityGroups();
c.fixedIps = (Set<NeutronIP>) port.getFixedIps();
c.allowedAddressPairs = (Set<NeutronAllowedAddressPair>) port.getAllowedAddressPairs();
c.portSecurityEnabled = port.isPortSecurityEnabled();
c.hostId = port.getHostId();
c.vifType = port.getVifType();
Expand Down