Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
[Compatibility] Make Subnet Entity OpenStack Compatible (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-zhonghao authored Oct 21, 2020
1 parent 0b92c61 commit 5e94af8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@
import com.futurewei.alcor.subnet.config.ConstantsConfig;
import com.futurewei.alcor.subnet.service.SubnetService;
import com.futurewei.alcor.subnet.service.implement.SubnetServiceImp;
import com.futurewei.alcor.web.entity.subnet.HostRoute;
import com.futurewei.alcor.web.entity.subnet.SubnetWebRequestJson;
import com.futurewei.alcor.web.entity.subnet.SubnetWebRequest;
import org.apache.commons.net.util.SubnetUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

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

public class SubnetManagementUtil {

private static SubnetService subnetService = new SubnetServiceImp();
Expand Down Expand Up @@ -73,6 +77,34 @@ public static boolean checkSubnetRequestResourceIsValid(SubnetWebRequestJson res
return false;
}

// tags
List<String> tags = subnet.getTags();
if (tags == null) {
tags = new ArrayList<String>(){};
subnet.setTags(tags);
}

// dns_nameservers
List<String> dnsNameservers = subnet.getDnsNameservers();
if (dnsNameservers == null) {
dnsNameservers = new ArrayList<String>(){};
subnet.setDnsNameservers(dnsNameservers);
}

// host_routes
List<HostRoute> hostRoutes = subnet.getHostRoutes();
if (hostRoutes == null) {
hostRoutes = new ArrayList<HostRoute>(){};
subnet.setHostRoutes(hostRoutes);
}

// service_types
List<String> serviceType = subnet.getServiceTypes();
if (serviceType == null) {
serviceType = new ArrayList<String>(){};
subnet.setServiceTypes(serviceType);
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
@Data
public class AllocationPool {

@JsonProperty("start_ip")
@JsonProperty("start")
private String start;

@JsonProperty("end_ip")
@JsonProperty("end")
private String end;

public AllocationPool () {}
Expand Down

0 comments on commit 5e94af8

Please sign in to comment.