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
11 changes: 10 additions & 1 deletion core/src/main/java/org/openstack4j/model/network/Port.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openstack4j.model.network;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.openstack4j.common.Buildable;
Expand Down Expand Up @@ -60,6 +61,14 @@ public interface Port extends Resource, Buildable<PortBuilder> {
* @return The port security status. A valid value is enabled (true) or disabled (false).
*/
Boolean isPortSecurityEnabled();

String getHostId();

String getVifType();

Map<String, Object> getVifDetails();

String getvNicType();

Map<String, Object> getProfile();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.openstack4j.model.network.builder;

import java.util.Map;

import org.openstack4j.common.Buildable.Builder;
import org.openstack4j.model.identity.v3.Tenant;
import org.openstack4j.model.network.ExtraDhcpOptCreate;
Expand Down Expand Up @@ -104,5 +106,15 @@ public interface PortBuilder extends Builder<PortBuilder, Port> {

PortBuilder portSecurityEnabled(Boolean portSecurityEnabled);

PortBuilder hostId(String hostId);

PortBuilder vifType(String vifType);

PortBuilder vifDetails(Map<String, Object> vifDetails);

PortBuilder vNicType(String vNicType);

PortBuilder profile(Map<String, Object> profile);


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.openstack4j.model.common.builder.ResourceBuilder;
Expand Down Expand Up @@ -70,7 +71,22 @@ public class NeutronPort implements Port {

@JsonProperty("port_security_enabled")
private Boolean portSecurityEnabled;


@JsonProperty("binding:host_id")
private String hostId;

@JsonProperty("binding:vif_type")
private String vifType;

@JsonProperty("binding:vif_details")
private Map<String, Object> vifDetails;

@JsonProperty("binding:vnic_type")
private String vNicType;

@JsonProperty("binding:profile")
private Map<String, Object> profile;

public static PortBuilder builder() {
return new PortConcreteBuilder();
}
Expand Down Expand Up @@ -153,12 +169,12 @@ public Set<? extends IP> getFixedIps() {
}

/**
* {@inheritDoc}
*/
@Override
public Set<? extends AllowedAddressPair> getAllowedAddressPairs() {
return allowedAddressPairs;
}
* {@inheritDoc}
*/
@Override
public Set<? extends AllowedAddressPair> getAllowedAddressPairs() {
return allowedAddressPairs;
}

/**
* {@inheritDoc}
Expand All @@ -176,6 +192,46 @@ public List<String> getSecurityGroups() {
return securityGroups;
}

/**
* {@inheritDoc}
*/
@Override
public String getHostId() {
return hostId;
}

/**
* {@inheritDoc}
*/
@Override
public String getVifType() {
return vifType;
}

/**
* {@inheritDoc}
*/
@Override
public Map<String, Object> getVifDetails() {
return vifDetails;
}

/**
* {@inheritDoc}
*/
@Override
public String getvNicType() {
return vNicType;
}

/**
* {@inheritDoc}
*/
@Override
public Map<String, Object> getProfile() {
return profile;
}

/**
* {@inheritDoc}
*/
Expand All @@ -200,7 +256,27 @@ public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

/**
public void setHostId(String hostId) {
this.hostId = hostId;
}

public void setVifType(String vifType) {
this.vifType = vifType;
}

public void setVifDetails(Map<String, Object> vifDetails) {
this.vifDetails = vifDetails;
}

public void setvNicType(String vNicType) {
this.vNicType = vNicType;
}

public void setProfile(Map<String, Object> profile) {
this.profile = profile;
}

/**
* {@inheritDoc}
*/
@Override
Expand All @@ -219,6 +295,8 @@ public String toString() {
.add("deviceOwner", deviceOwner).add("fixedIps", fixedIps).add("macAddress", macAddress)
.add("networkId", networkId).add("tenantId", tenantId).add("securityGroups", securityGroups)
.add("allowed_address_pairs", allowedAddressPairs).add("port_security_enabled ", portSecurityEnabled)
.add("binding:host_id", hostId).add("binding:vif_type", vifType).add("binding:vif_details", vifDetails)
.add("binding:vnic_type", vNicType).add("binding:profile", profile)
.toString();
}

Expand Down Expand Up @@ -279,23 +357,23 @@ public PortBuilder fixedIp(String address, String subnetId) {
return this;
}

@Override
@Override
public PortBuilder removeFixedIp(String address, String subnetId) {
if (m.fixedIps == null)
m.fixedIps = Sets.newHashSet();
Iterator<NeutronIP> iter = m.fixedIps.iterator();
while (iter.hasNext()) {
NeutronIP fixedIP = iter.next();
if (fixedIP.getSubnetId() != null && fixedIP.getSubnetId().equals(subnetId) &&
fixedIP.getIpAddress() != null && fixedIP.getIpAddress().equals(address)) {
iter.remove();
}
}
return this;
}
if (m.fixedIps == null)
m.fixedIps = Sets.newHashSet();
Iterator<NeutronIP> iter = m.fixedIps.iterator();
while (iter.hasNext()) {
NeutronIP fixedIP = iter.next();
if (fixedIP.getSubnetId() != null && fixedIP.getSubnetId().equals(subnetId) &&
fixedIP.getIpAddress() != null && fixedIP.getIpAddress().equals(address)) {
iter.remove();
}
}
return this;
}

@Override
public PortBuilder allowedAddressPair(String ipAddress, String macAddress) {
Expand Down Expand Up @@ -375,6 +453,37 @@ public PortBuilder portSecurityEnabled(Boolean portSecurityEnabled) {
m.portSecurityEnabled=portSecurityEnabled;
return this;
}

@Override
public PortBuilder hostId(String hostId) {
m.hostId = hostId;
return this;
}

@Override
public PortBuilder vifType(String vifType) {
m.vifType = vifType;
return this;
}

@Override
public PortBuilder vifDetails(Map<String, Object> vifDetails) {
m.vifDetails = vifDetails;
return this;
}

@Override
public PortBuilder vNicType(String vNicType) {
m.vNicType = vNicType;
return this;
}

@Override
public PortBuilder profile(Map<String, Object> profile) {
m.profile = profile;
return this;
}

}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openstack4j.openstack.networking.domain;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.openstack4j.model.ModelEntity;
Expand Down Expand Up @@ -45,6 +46,22 @@ public class NeutronPortCreate implements ModelEntity {

@JsonProperty("port_security_enabled")
private Boolean portSecurityEnabled;

@JsonProperty("binding:host_id")
private String hostId;

@JsonProperty("binding:vif_type")
private String vifType;

@JsonProperty("binding:vif_details")
private Map<String, Object> vifDetails;

@JsonProperty("binding:vnic_type")
private String vNicType;

@JsonProperty("binding:profile")
private Map<String, Object> profile;


public NeutronPortCreate() {
}
Expand All @@ -66,6 +83,12 @@ public static NeutronPortCreate fromPort(Port port) {
c.securityGroups = port.getSecurityGroups();
c.fixedIps = (Set<NeutronIP>) port.getFixedIps();
c.portSecurityEnabled=port.isPortSecurityEnabled();
c.hostId = port.getHostId();
c.vifType = port.getVifType();
c.vifDetails = port.getVifDetails();
c.vNicType = port.getvNicType();
c.profile = port.getProfile();


return c;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public Port create(Port port) {
public Port update(Port port) {
checkNotNull(port);
checkNotNull(port.getId());
Port p = port.toBuilder().networkId(null).state(null).tenantId(null).macAddress(null).build();
Port p = port.toBuilder().networkId(null).state(null).tenantId(null).macAddress(null)
.vifType(null).vifDetails(null)
.build();
return put(NeutronPort.class, uri("/ports/%s", getAndClearIdentifier(p))).entity(p).execute();
}

Expand Down