Skip to content

CLOUDSTACK-10047: DVSwitch fixes and improvements - #2293

Merged
yadvr merged 3 commits into
apache:masterfrom
shapeblue:CLOUDSTACK-10047
Oct 25, 2017
Merged

CLOUDSTACK-10047: DVSwitch fixes and improvements#2293
yadvr merged 3 commits into
apache:masterfrom
shapeblue:CLOUDSTACK-10047

Conversation

@yadvr

Copy link
Copy Markdown
Member

This adds a minor feature to accepts security policies while creating network offering. Changes:

  • Deployed network will have security policies from the network offering
    applied on the port group (in vmware environment)
  • Global settings as fallback when security policies are not defined for a network
    offering
  • Default promiscuous mode security policy set to REJECT as it's the default
    for standard/default vswitch

This also allows admins to define a network with vlan range such as vlan://200-400
and use the range to configure vlan-trunking with the range for a portgroup
in dvswitch.

VLAN overlap checks are performed for:

  • isolated network against existing shared and isolated networks
  • dedicated vlan ranges for the physical/public network for the zone
  • shared network against existing isolated network

Notes:

  • No vlan-range overlap checks are performed when creating shared networks
  • Multiple vlan id/ranges should include the vlan:// scheme prefix

@yadvr

Copy link
Copy Markdown
MemberAuthor

Notes:

  • Portgroup creation and update is triggered primarily by StartCommand for a network (when a VM is started, here VM could be either a guest VM or a VR, therefore VM start and VR start triggered by network deployment or network restart with cleanup=true).
  • While processing StartCommand, the subsystem reconfigures the nics/portgroups/disks etc which is not possible when simply doing a VM reboot/restart from CloudStack, which is why portgroups changes are not applied/propagated when doing VM reboot via CloudStack which send a Vm reboot to vmware.
  • The global settings will apply for (cloud.public, cloud.guest and cloud.private) portgroups, while if network offering has the security policies defined the defined policies will be applied to cloud.guest (i.e. the guest/vm network specific portgroup) otherwise that will too use the global settings
  • The feature is primarily intended for new networks and/or network-offerings, and if old/existing network offerings are used then global settings will be used.
  • The security policies/behaviour is same as vswitches, i.e. promiscuous mode set to false, and others set to true. By default, dvswitch would previously set promiscuous mode to true which would be both an overhead and security issue.

@yadvr

Copy link
Copy Markdown
MemberAuthor

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1150

@resmoresmo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job. extensive work. code lgtm.

Comment threadui/l10n/en.js Outdated
"label.firewall":"Firewall",
"label.first.name":"First Name",
"label.firstname.lower":"firstname",
"label.forged.trasmits":"Forged Transmits",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo s/trasmits/transmits

Comment threadui/scripts/configuration.js Outdated
},

forgedTransmits: {
label: 'label.forged.trasmits',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same typo

@yadvr

Copy link
Copy Markdown
MemberAuthor

Thanks @resmo fixed :)

@yadvr

Copy link
Copy Markdown
MemberAuthor

@blueorangutan test centos7 vmware-55u3

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Trillian-Jenkins test job (centos7 mgmt + vmware-55u3) has been kicked to run smoke tests

@rafaelweingartnerrafaelweingartner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rhtyd I have seen some points that might benefit from improvements.

final NetworkVO network = _networkDao.findByUuid(nicTo.getNetworkUuid());
if (network != null) {
final Map<NetworkOffering.Detail, String> details = networkOfferingDetailsDao.getNtwkOffDetails(network.getNetworkOfferingId());
if (details != null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about reducing the cyclomatic complexicity here?
it is a matter of inverting the conditional. Instead of if (true){doSomething}, we can do if(!false){continue} doSomething
This would enable to remove one if inception

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're protecting against NPEs and setting details to a NicTO object when those details are available. We cannot simply continue as the value is being set at lines 161, 163.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right about the details, but I think I clicked on the wrong line (sorry for the mistake). I was talking about the if (network != null) check. if if (network == null) you do not do anything, then it is the same as using a continue. I mean, you do a nics[i++] = nicTo;, but that can go inside the condition as well. Duplicated lines are not that great, so let's see what else could be done...

We can do something else, we could extract lines 149-160 to a method; this would improve the readability of the code and enable unit tests and Java docs.

@yadvryadvrOct 12, 2017

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The block converts NicProfile to NicTO, the idea of the changes is to override certain security settings on dvswitch's portgroups if they already don't have the settings, using global settings. I'll explore further refactorings if I get time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for both the explanations and for the effort!

BTW: your explanation is great to enrich our code base. This explanation would be awesome in a Javadoc, so people in the future can understand why we are doing this without needing to deeply inspect the code.

*/
public static List<Integer> expandVlanUri(final String vlanAuthority) {
final List<Integer> expandedVlans = new ArrayList<>();
if (vlanAuthority == null || vlanAuthority.isEmpty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about StringUtils.isBlank here?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with Strings.isNullOrEmpty, thanks

return expandedVlans;
}
for (final String vlanPart: vlanAuthority.split(",")) {
if (vlanPart == null || vlanPart.isEmpty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about StringUtils.isBlank here?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with Strings.isNullOrEmpty, thanks

}
} else {
final Integer value = NumbersUtil.parseInt(range[0], -1);
if (value > -1) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about a debug message here to say why we are rejecting this value, and displaying the value of range[0], in case range[0] is not a number and the method returns -1

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used for vlan range checks etc, vlans are always > -1.

public static boolean checkVlanUriOverlap(final String vlanRange1, final String vlanRange2) {
final List<Integer> vlans1 = expandVlanUri(vlanRange1);
final List<Integer> vlans2 = expandVlanUri(vlanRange2);
if (vlans1 == null || vlans2 == null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if one of them is null, the result is true? This means that they overlap?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're checking if two vlan ranges (comma separated ranges or values, such as 100-200,300 or 20-30 etc) overlap, if any of them when expanded (i.e. 1-3 expands to 1,2,3) is null, i.e. there is no overlap.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not understand the explanations :(

Anyways, looking at the code of expandVlanUri, I did not see a way for it to return null. Worst case scenario it returns an empty list. Do we need this check?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we need this check.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind explaining why if the method expandVlanUri returns an empty list in the worst case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that, but I think we should not over code or engineer. If we worry about the method expandVlanUri returning null, we can do something else to catch this.

What about a test case for expandVlanUri that fails if it returns null? Then, we can remove this check. On thing is to be defensive when a null case can happen, the other is to code expecting someone to make a mistake in the future (for that it is better to write unit test cases).

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're over-discussing, not over-engineering :) I'll ping you on respective unit tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that as well ;)

I am sorry to bother, but if I do not understand something I keep asking until I can move along.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use !Collections.disjoint(vlans1, vlans2)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmaximus fixed.


private List<DataCenterVnetVO> findOverlappingVnets(final long dcId, final Long physicalNetworkId, final String vnet) {
final List<Integer> searchVnets = UriUtils.expandVlanUri(vnet);
final List<DataCenterVnetVO> overlappingVnets = new ArrayList<>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about inverting this conditional?
if( searchVnets == null || searchVnets.size() == 0){return overlappingVnets;}
This helps to reduce the number of IFs inside of IFs

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-1579)
Environment: vmware-55u3 (x2), Advanced Networking with Mgmt server 7
Total time taken: 47610 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr2293-t1579-vmware-55u3.zip
Intermitten failure detected: /marvin/tests/smoke/test_deploy_vgpu_enabled_vm.py
Intermitten failure detected: /marvin/tests/smoke/test_privategw_acl.py
Intermitten failure detected: /marvin/tests/smoke/test_routers_network_ops.py
Intermitten failure detected: /marvin/tests/smoke/test_volumes.py
Intermitten failure detected: /marvin/tests/smoke/test_vpc_vpn.py
Test completed. 58 look OK, 4 have error(s)

TestResultTime (s)Test File
test_01_vpc_remote_access_vpnFailure151.50test_vpc_vpn.py
test_01_create_volumeFailure194.87test_volumes.py
test_02_RVR_Network_FW_PF_SSH_default_routes_egress_falseFailure486.73test_routers_network_ops.py
test_01_RVR_Network_FW_PF_SSH_default_routes_egress_trueFailure489.86test_routers_network_ops.py
test_04_rvpc_privategw_static_routesFailure635.95test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanupFailure424.84test_privategw_acl.py
test_02_vpc_privategw_static_routesFailure450.06test_privategw_acl.py
test_01_vpc_privategw_aclFailure127.16test_privategw_acl.py
test_08_resize_volumeSkipped5.12test_volumes.py
test_07_resize_failSkipped10.26test_volumes.py
test_09_copy_delete_templateSkipped0.02test_templates.py
test_06_copy_templateSkipped0.00test_templates.py
test_static_role_account_aclsSkipped0.02test_staticroles.py
test_11_ss_nfs_version_on_ssvmSkipped0.02test_ssvm.py
test_01_scale_vmSkipped64.44test_scale_vm.py
test_01_primary_storage_iscsiSkipped0.08test_primary_storage.py
test_vm_nic_adapter_vmxnet3Skipped0.00test_nic_adapter_type.py
test_06_copy_isoSkipped0.00test_iso.py
test_list_ha_for_host_validSkipped0.02test_hostha_simulator.py
test_list_ha_for_host_invalidSkipped0.03test_hostha_simulator.py
test_list_ha_for_hostSkipped0.05test_hostha_simulator.py
test_hostha_enable_feature_without_setting_providerSkipped0.03test_hostha_simulator.py
test_hostha_enable_feature_validSkipped0.03test_hostha_simulator.py
test_hostha_disable_feature_validSkipped0.02test_hostha_simulator.py
test_hostha_configure_invalid_providerSkipped0.04test_hostha_simulator.py
test_hostha_configure_default_driverSkipped0.05test_hostha_simulator.py
test_ha_verify_fsm_recoveringSkipped0.04test_hostha_simulator.py
test_ha_verify_fsm_fencedSkipped0.05test_hostha_simulator.py
test_ha_verify_fsm_degradedSkipped0.05test_hostha_simulator.py
test_ha_verify_fsm_availableSkipped0.05test_hostha_simulator.py
test_ha_multiple_mgmt_server_ownershipSkipped0.04test_hostha_simulator.py
test_ha_list_providersSkipped0.05test_hostha_simulator.py
test_ha_enable_feature_invalidSkipped0.02test_hostha_simulator.py
test_ha_disable_feature_invalidSkipped0.03test_hostha_simulator.py
test_ha_configure_enabledisable_across_clusterzonesSkipped0.03test_hostha_simulator.py
test_configure_ha_provider_validSkipped0.04test_hostha_simulator.py
test_configure_ha_provider_invalidSkipped0.03test_hostha_simulator.py
test_remove_ha_provider_not_possibleSkipped0.05test_hostha_kvm.py
test_hostha_kvm_host_recoveringSkipped0.06test_hostha_kvm.py
test_hostha_kvm_host_fencingSkipped0.03test_hostha_kvm.py
test_hostha_kvm_host_degradedSkipped0.04test_hostha_kvm.py
test_hostha_enable_ha_when_host_in_maintenanceSkipped0.06test_hostha_kvm.py
test_hostha_enable_ha_when_host_disconectedSkipped0.04test_hostha_kvm.py
test_hostha_enable_ha_when_host_disabledSkipped0.04test_hostha_kvm.py
test_hostha_configure_default_driverSkipped0.03test_hostha_kvm.py
test_disable_oobm_ha_state_ineligibleSkipped0.04test_hostha_kvm.py
test_06_verify_guest_lspci_againSkipped0.00test_deploy_virtio_scsi_vm.py
test_05_change_vm_ostype_restartSkipped0.00test_deploy_virtio_scsi_vm.py
test_04_verify_guest_lspciSkipped0.00test_deploy_virtio_scsi_vm.py
test_03_verify_libvirt_attach_diskSkipped0.00test_deploy_virtio_scsi_vm.py
test_02_verify_libvirt_after_restartSkipped0.00test_deploy_virtio_scsi_vm.py
test_01_verify_libvirtSkipped0.00test_deploy_virtio_scsi_vm.py
test_deploy_vgpu_enabled_vmSkipped1.17test_deploy_vgpu_enabled_vm.py

@borisstoyanov

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@borisstoyanov a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos6 ✔centos7 ✔debian. JID-1152

@borisstoyanov

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@borisstoyanov a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

Assert.assertFalse(UriUtils.checkVlanUriOverlap("10-30,45,50,12,31", ""));
Assert.assertFalse(UriUtils.checkVlanUriOverlap("10-30,45,50,12,31", "32"));
Assert.assertFalse(UriUtils.checkVlanUriOverlap("10,22,111", "12"));
Assert.assertFalse(UriUtils.checkVlanUriOverlap("100-200", "30-40,50,201-250"));

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelweingartner unit tests for respective methods in questions are in this file, please see all the above lines.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had already seen these tests, I did not say anything because in my option they are properly written ;)

So, about that null case, in my option it is already covered, if for some reason someone alters the method to return null, your test cases will catch it (this is great!). That is why I was saying you do not need those null checks.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, sometimes we do want to over-engineer™ :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahaha, sometimes we do, but we should not.

I totally understand when we do, I also exaggerate sometimes, that is why I find it is great a review process to get another set of eyes to look at the problem and the code.

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-1582)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 26649 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr2293-t1582-kvm-centos7.zip
Intermitten failure detected: /marvin/tests/smoke/test_privategw_acl.py
Intermitten failure detected: /marvin/tests/smoke/test_vpc_vpn.py
Test completed. 60 look OK, 2 have error(s)

TestResultTime (s)Test File
test_01_vpc_remote_access_vpnFailure60.78test_vpc_vpn.py
test_04_rvpc_privategw_static_routesFailure237.96test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanupFailure117.19test_privategw_acl.py
test_02_vpc_privategw_static_routesFailure182.87test_privategw_acl.py
test_01_vpc_privategw_aclFailure56.63test_privategw_acl.py
test_change_service_offering_for_vm_with_snapshotsSkipped0.00test_vm_snapshots.py
test_09_copy_delete_templateSkipped0.01test_templates.py
test_06_copy_templateSkipped0.00test_templates.py
test_static_role_account_aclsSkipped0.01test_staticroles.py
test_11_ss_nfs_version_on_ssvmSkipped0.02test_ssvm.py
test_01_scale_vmSkipped0.00test_scale_vm.py
test_01_primary_storage_iscsiSkipped0.06test_primary_storage.py
test_vm_nic_adapter_vmxnet3Skipped0.00test_nic_adapter_type.py
test_nested_virtualization_vmwareSkipped0.00test_nested_virtualization.py
test_06_copy_isoSkipped0.00test_iso.py
test_list_ha_for_host_validSkipped0.02test_hostha_simulator.py
test_list_ha_for_host_invalidSkipped0.02test_hostha_simulator.py
test_list_ha_for_hostSkipped0.02test_hostha_simulator.py
test_hostha_enable_feature_without_setting_providerSkipped0.02test_hostha_simulator.py
test_hostha_enable_feature_validSkipped0.02test_hostha_simulator.py
test_hostha_disable_feature_validSkipped0.02test_hostha_simulator.py
test_hostha_configure_invalid_providerSkipped0.02test_hostha_simulator.py
test_hostha_configure_default_driverSkipped0.02test_hostha_simulator.py
test_ha_verify_fsm_recoveringSkipped0.02test_hostha_simulator.py
test_ha_verify_fsm_fencedSkipped0.02test_hostha_simulator.py
test_ha_verify_fsm_degradedSkipped0.02test_hostha_simulator.py
test_ha_verify_fsm_availableSkipped0.02test_hostha_simulator.py
test_ha_multiple_mgmt_server_ownershipSkipped0.02test_hostha_simulator.py
test_ha_list_providersSkipped0.02test_hostha_simulator.py
test_ha_enable_feature_invalidSkipped0.02test_hostha_simulator.py
test_ha_disable_feature_invalidSkipped0.02test_hostha_simulator.py
test_ha_configure_enabledisable_across_clusterzonesSkipped0.02test_hostha_simulator.py
test_configure_ha_provider_validSkipped0.02test_hostha_simulator.py
test_configure_ha_provider_invalidSkipped0.02test_hostha_simulator.py
test_deploy_vgpu_enabled_vmSkipped0.02test_deploy_vgpu_enabled_vm.py
test_3d_gpu_supportSkipped0.03test_deploy_vgpu_enabled_vm.py

if (network != null) {
final Map<NetworkOffering.Detail, String> details = networkOfferingDetailsDao.getNtwkOffDetails(network.getNetworkOfferingId());
if (details != null) {
if (!details.containsKey(NetworkOffering.Detail.PromiscuousMode)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might also use putIfAbsent here instead, which was added in Java 8

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks, good tip.

public static boolean checkVlanUriOverlap(final String vlanRange1, final String vlanRange2) {
final List<Integer> vlans1 = expandVlanUri(vlanRange1);
final List<Integer> vlans2 = expandVlanUri(vlanRange2);
if (vlans1 == null || vlans2 == null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use !Collections.disjoint(vlans1, vlans2)

@sgoeminnsgoeminn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code LGTM!

return vlan;
}

public Boolean getBypassVlanOverlapCheck() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we do return a Boolean instead of boolean? (this function can never return null)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because cmd classes set API args to fields using reflections etc. It's easier to not use native type boolean. When arg is not sent part of the API request, it would be set to null; setting null to boolean will throw an exception.

public List<DataCenterVnetVO> findVnet(long dcId, long physicalNetworkId, String vnet) {
private List<DataCenterVnetVO> findOverlappingVnets(final long dcId, final Long physicalNetworkId, final String vnet) {
final List<Integer> searchVnets = UriUtils.expandVlanUri(vnet);
final List<DataCenterVnetVO> overlappingVnets = new ArrayList<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use searchVnets.isEmpty() instead of size()==0?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed.

networkName = composeCloudNetworkName(namePrefix, vlanId, secondaryvlanId, networkRateMbps, physicalNetwork);

if (vlanId != null && !UNTAGGED_VLAN_NAME.equalsIgnoreCase(vlanId)) {
if (vlanId != null && !UNTAGGED_VLAN_NAME.equalsIgnoreCase(vlanId) && !vlanId.contains(",") && !vlanId.contains("-")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&& !vlanId.contains(",") && !vlanId.contains("-") could be replaced by !StringUtils.containsAny(vlanId, ",-")?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

createGCTag = true;
vid = Integer.parseInt(vlanId);
}
if (vlanId != null && (vlanId.contains(",") || vlanId.contains("-"))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be replaced by StringUtils.containsAny(vlanId, ",-")? Maybe also extract it to a separate boolean because it's checked multiple times?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

@borisstoyanovborisstoyanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this on both vSwitch and dvSwitch vmware environments and it works as expected, marvin smoketests does not show any explicit new failures. LGTM

- Accepts security policies while creating network offering
- Deployed network will have security policies from the network offering
applied on the port group (in vmware environment)
- Global settings as fallback when security policies are not defined for a network
offering
- Default promiscuous mode security policy set to REJECT as it's the default
for standard/default vswitch
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This allows admins to define a network with comma separated vlan id and vlan
range such as vlan://200-400,21,30-50 and use the provided vlan range to
configure vlan-trunking for a portgroup in dvswitch based environment.
VLAN overlap checks are performed for:
- isolated network against existing shared and isolated networks
- dedicated vlan ranges for the physical/public network for the zone
- shared network against existing isolated network
Allow shared networks to bypass vlan overlap checks: This allows admins
to create shared networks with a `bypassvlanoverlapcheck` API flag
which when set to 'true' will create a shared network without
performing vlan overlap checks against isolated network and against
the vlans allocated to the datacenter's physical network (vlan ranges).
Notes:
- No vlan-range overlap checks are performed when creating shared networks
- Multiple vlan id/ranges should include the vlan:// scheme prefix
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
@yadvr

Copy link
Copy Markdown
MemberAuthor

I've incorporated feedback from code review, given this has enough LGTMs and test results, I'll merge this as soon as Travis goes green. Thanks everyone for your feedback, review and testings.

@yadvr
yadvr merged commit 41fdb88 into apache:masterOct 25, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@yadvr@blueorangutan@borisstoyanov@resmo@fmaximus@rafaelweingartner@sgoeminn