Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 49DF318B5F for ; Mon, 11 Apr 2016 03:25:19 +0000 (UTC) Received: (qmail 10695 invoked by uid 500); 11 Apr 2016 03:25:18 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 10624 invoked by uid 500); 11 Apr 2016 03:25:18 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 10611 invoked by uid 99); 11 Apr 2016 03:25:18 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Apr 2016 03:25:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 705D9DFC6E; Mon, 11 Apr 2016 03:25:18 +0000 (UTC) From: jburwell To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: OSPF: adding dynamically routing capabili... Content-Type: text/plain Message-Id: <20160411032518.705D9DFC6E@git1-us-west.apache.org> Date: Mon, 11 Apr 2016 03:25:18 +0000 (UTC) Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1371#discussion_r59150902 --- Diff: api/src/com/cloud/network/vpc/OSPFZoneConfig.java --- @@ -0,0 +1,332 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package com.cloud.network.vpc; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; + +import com.cloud.exception.InvalidParameterValueException; +import com.cloud.utils.net.NetUtils; + +public class OSPFZoneConfig { + + private long zoneId; + private Protocol protocol; + private String ospfArea; + private Short helloInterval; + private Short deadInterval; + private Short retransmitInterval; + private Short transitDelay; + private Authentication authentication; + private String password; + private String[] superCIDRList; + private Boolean enabled; + + public static final String s_protocol = "protocol"; + public static final String s_area = "area"; + public static final String s_helloInterval = "hellointerval"; + public static final String s_deadInterval = "deadinterval"; + public static final String s_retransmitInterval = "retransmitinterval"; + public static final String s_transitDelay = "transitdelay"; + public static final String s_authentication = "authentication"; + public static final String s_superCIDR = "supercidr"; + public static final String s_password = "password"; + public static final String s_enabled = "enabled"; + + public Protocol getProtocol() { + return protocol; + } + + public void setProtocol(Protocol protocol) { + this.protocol = protocol; + } + + public String getOspfArea() { + return ospfArea; + } + + public void setOspfArea(String ospfArea) { + this.ospfArea = ospfArea; + } + + public Short getHelloInterval() { + return helloInterval; + } + + public void setHelloInterval(Short helloInterval) { + this.helloInterval = helloInterval; + } + + public Short getDeadInterval() { + return deadInterval; + } + + public void setDeadInterval(Short deadInterval) { + this.deadInterval = deadInterval; + } + + public Short getRetransmitInterval() { + return retransmitInterval; + } + + public void setRetransmitInterval(Short retransmitInterval) { + this.retransmitInterval = retransmitInterval; + } + + public Short getTransitDelay() { + return transitDelay; + } + + public void setTransitDelay(Short transitDelay) { + this.transitDelay = transitDelay; + } + + public Authentication getAuthentication() { + return authentication; + } + + public void setAuthentication(Authentication authentication) { + this.authentication = authentication; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String[] getSuperCIDR() { + return superCIDRList; + } + + public void setSuperCIDR(String[] superCIDR) { + this.superCIDRList = superCIDR; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public enum Params { + PROTOCOL, AREA, HELLO_INTERVAL, DEAD_INTERVAL, RETRANSMIT_INTERVAL, TRANSIT_DELAY, AUTHENTICATION, SUPER_CIDR, PASSWORD, ENABLED + } + + public enum Protocol { + OSPF, BGP + } + + public enum Authentication { + MD5, PLAIN_TEXT + } + + public OSPFZoneConfig() { + } + + public void setDefaultValues(final Map details) { + this.protocol = details.get(Params.PROTOCOL.name()) == null ? Protocol.OSPF : Protocol.valueOf(details.get(Params.PROTOCOL.name())); + this.ospfArea = details.get(Params.AREA.name()) == null ? "0" : details.get(Params.AREA.name()); + this.helloInterval = Short.valueOf(details.get(Params.HELLO_INTERVAL.name()) == null ? "10" : details.get(Params.HELLO_INTERVAL.name())); + this.deadInterval = Short.valueOf(details.get(Params.DEAD_INTERVAL.name()) == null ? "40" : details.get(Params.DEAD_INTERVAL.name())); + this.retransmitInterval = Short.valueOf(details.get(Params.RETRANSMIT_INTERVAL.name()) == null ? "5" : details.get(Params.RETRANSMIT_INTERVAL.name())); + this.transitDelay = Short.valueOf(details.get(Params.TRANSIT_DELAY.name()) == null ? "1" : details.get(Params.TRANSIT_DELAY.name())); + this.authentication = details.get(Params.AUTHENTICATION.name()) == null ? Authentication.MD5 + : Authentication.valueOf(details.get(Params.AUTHENTICATION.name())); + this.password = details.get(Params.PASSWORD.name()) == null ? "" : details.get(Params.PASSWORD.name()); + String cidr_list = details.get(Params.SUPER_CIDR.name()) == null ? "200.100.0.0/20" : details.get(Params.SUPER_CIDR.name()); + this.superCIDRList = cidr_list.split(","); + this.enabled = details.get(Params.ENABLED.name()) == null ? Boolean.FALSE : Boolean.valueOf(details.get(Params.ENABLED.name())); --- End diff -- 1. This ternary operation is repeated throughout this method. Please extract to a common utility method such as ``getMapValueWithDefault`` and include unit tests. 1. Since the value being retrieved is a ``String``, test the value with ``Strings.isNullOrEmpty``to protect against both null and blank values. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---