Skip to content

Commit

Permalink
Merge branch 'release-1.112.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sergii-iakovenko committed Jan 18, 2022
2 parents 09f7688 + e056a8f commit 02e6d83
Show file tree
Hide file tree
Showing 110 changed files with 3,676 additions and 728 deletions.
83 changes: 44 additions & 39 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Note that the build process will install additional packages. It is recommended
### Prerequisites

The followings are required for building Kilda controller:
- Gradle 6.7+
- Gradle 7.0+
- Maven 3.3.9+
- JDK8
- Python 3.6+
Expand Down Expand Up @@ -44,7 +44,7 @@ sudo pip3 install docker-compose
You can either install Gradle, or use Gradle wrapper:
- Option 1 - Use Gradle wrapper. The Kilda repository contains an instance of Gradle Wrapper
which can be used straight from here without further installation.
- Option 2 - Install Gradle (ensure that you have gradle 6.7 or later) - https://gradle.org/install/
- Option 2 - Install Gradle (ensure that you have gradle 7.0 or later) - https://gradle.org/install/


#### Docker
Expand Down
51 changes: 51 additions & 0 deletions docs/design/y-flow/y-flow-nb-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,57 @@ Response body:
}
```

## Ping operation

REST endpoint: `POST /v2/y-flows/{y_flow_id}/ping`

request payload:

```json
{
"timeout": 0
}
```

response payload:

```json
{
"y_flow_id": "yf-AAAAAAAAAAAAAAA",
"ping_success": true,
"error": "error",
"sub_flows": [
{
"flow_id": "fAAAAAAAAAAAAAAA",
"forward": {
"ping_success": true,
"error": "error",
"latency": 0
},
"reverse": {
"ping_success": true,
"error": "error",
"latency": 0
}
},
{
"flow_id": "fAAAAAAAAAAAAAAB",
"forward": {
"ping_success": true,
"error": "error",
"latency": 0
},
"reverse": {
"ping_success": true,
"error": "error",
"latency": 0
}
}
]
}
```


# Existing API changes

All flows CRUD operation responses will be extended with following fields:
Expand Down
29 changes: 11 additions & 18 deletions src-gui/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* This file was generated by the Gradle 'init' task.
*/

plugins {
id 'java'
id 'jacoco'
Expand All @@ -11,13 +7,9 @@ plugins {
}

repositories {
jcenter()
mavenCentral()
maven {
url = uri('https://repo.spring.io/libs-milestone')
}

maven {
url = uri('http://repo.maven.apache.org/maven2')
url 'https://repo.spring.io/libs-milestone'
}
}

Expand Down Expand Up @@ -60,13 +52,13 @@ dependencies {
testImplementation 'org.mockito:mockito-all:2.0.2-beta'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.0.0-M4'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.0.0-M4'

compileOnly 'org.projectlombok:lombok:1.18.10'
testCompileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.10'
compile group: 'org.eclipse.jdt.core.compiler', name: 'ecj', version: '4.5.1'

implementation group: 'org.eclipse.jdt.core.compiler', name: 'ecj', version: '4.5.1'
}

group = 'org.openkilda'
Expand All @@ -78,14 +70,14 @@ tasks.withType(JavaCompile) {
}

jacoco {
toolVersion = '0.8.5'
toolVersion = '0.8.7'
}

jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled true
xml.required = true
csv.required = false
html.required = true
}
}

Expand Down Expand Up @@ -114,9 +106,10 @@ checkstyle {
}
}

/*TODO: not compatible with Gradle 7+, need another way
[checkstyleMain, checkstyleTest].each { task ->
task.logging.setLevel(LogLevel.LIFECYCLE)
}
}*/

jar {
manifest {
Expand Down
2 changes: 1 addition & 1 deletion src-gui/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 33 additions & 2 deletions src-gui/src/main/java/org/openkilda/constants/IConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,33 @@ private SessionTimeout() {
public static Integer DEFAULT_TIME_IN_MINUTE = 45;
}

public static final class InvalidLoginAttempt {
private InvalidLoginAttempt() {

}

public static Integer INVALID_LOGIN_ATTEMPTS_COUNT;

public static Integer DEFAULT_INVALID_LOGIN_ATTEMPTS_COUNT = 5;
}

public static final class UserAccUnlockTime {
private UserAccUnlockTime() {

}

public static Integer USER_ACCOUNT_UNLOCK_TIME;

public static Integer DEFAULT_USER_ACCOUNT_UNLOCK_TIME = 60;
}


public enum ApplicationSetting {

SESSION_TIMEOUT(String.valueOf(SessionTimeout.DEFAULT_TIME_IN_MINUTE)), SWITCH_NAME_STORAGE_TYPE(
StorageType.FILE_STORAGE.name());
StorageType.FILE_STORAGE.name()), INVALID_LOGIN_ATTEMPT(String.valueOf(InvalidLoginAttempt
.DEFAULT_INVALID_LOGIN_ATTEMPTS_COUNT)), USER_ACCOUNT_UNLOCK_TIME(
String.valueOf(UserAccUnlockTime.DEFAULT_USER_ACCOUNT_UNLOCK_TIME));

final String value;

Expand Down Expand Up @@ -174,6 +197,8 @@ private NorthBoundUrl() {
public static final String GET_SWITCH_PORT_PROPERTY = VERSION_TWO + "/switches/{switch_id}"
+ "/ports/{port}/properties";
public static final String UPDATE_SWITCH_LOCATION = VERSION_TWO + "/switches/{switch_id}";
public static final String GET_LINK_BFD_PROPERTIES = VERSION_TWO
+ "/links/{src-switch}_{src-port}/{dst-switch}_{dst-port}/bfd";
}

public final class OpenTsDbUrl {
Expand Down Expand Up @@ -299,11 +324,17 @@ private Permission() {

public static final String SW_SWITCH_METERS = "sw_switch_meters";

public static final String SW_SWITCH_LOCATION_UPDATE = "sw_switch_location_update";
public static final String UM_USER_ACCOUNT_UNLOCK = "um_user_account_unlock";

public static final String SAML_SETTING = "saml_setting";

public static final String SW_SWITCH_LOCATION_UPDATE = "sw_switch_location_update";

public static final String TOPOLOGY_WORLD_MAP_VIEW = "topology_world_map_view";

public static final String ISL_UPDATE_BFD_PROPERTIES = "isl_update_bfd_properties";

public static final String ISL_DELETE_BFD = "isl_delete_bfd";
}

public final class Settings {
Expand Down
7 changes: 4 additions & 3 deletions src-gui/src/main/java/org/openkilda/constants/Status.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2018 Telstra Open Source
/* Copyright 2019 Telstra Open Source
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,8 +22,9 @@ public enum Status {
/** The active. */
ACTIVE("ACT"),
/** The inactive. */
INACTIVE("INA");
/** The expired. */
INACTIVE("INA"),
/** The locked. */
LOCK("LCK");

private String code;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2018 Telstra Open Source
/* Copyright 2019 Telstra Open Source
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,6 +28,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.LockedException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
Expand Down Expand Up @@ -120,7 +121,7 @@ public ModelAndView authenticate(@RequestParam("username") String username,
SecurityContextHolder.getContext().setAuthentication(authenticate);
userService.updateLoginDetail(username);
} else {
error = "Invalid email or password";
error = "Login failed; Invalid email or password.";
LOGGER.warn("Authentication failure for user: '" + username + "'");
modelAndView.setViewName(IConstants.View.REDIRECT_LOGIN);
}
Expand Down Expand Up @@ -155,7 +156,10 @@ public ModelAndView authenticate(@RequestParam("username") String username,
}
} catch (BadCredentialsException e) {
LOGGER.warn("Authentication failure", e);
error = "Invalid email or password";
error = e.getMessage();
modelAndView.setViewName(IConstants.View.REDIRECT_LOGIN);
} catch (LockedException e) {
error = e.getMessage();
modelAndView.setViewName(IConstants.View.REDIRECT_LOGIN);
} catch (Exception e) {
LOGGER.warn("Authentication failure", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.openkilda.integration.model.response.ConfiguredPort;
import org.openkilda.log.ActivityLogger;
import org.openkilda.log.constants.ActivityType;
import org.openkilda.model.BfdProperties;
import org.openkilda.model.FlowInfo;
import org.openkilda.model.IslLinkInfo;
import org.openkilda.model.LinkBfdProperties;
import org.openkilda.model.LinkMaxBandwidth;
import org.openkilda.model.LinkParametersDto;
import org.openkilda.model.LinkProps;
Expand Down Expand Up @@ -410,4 +412,67 @@ public class SwitchController {
activityLogger.log(ActivityType.UPDATE_SWITCH_LOCATION, switchId);
return serviceSwitch.updateSwitchLocation(switchId, switchLocation);
}

/**
* Gets the link BFD properties.
*
* @param srcSwitch the src switch
* @param srcPort the src port
* @param dstSwitch the dst switch
* @param dstPort the dst port
* @return the link Bfd properties
*/
@RequestMapping(value = "/links/bfd", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody LinkBfdProperties readBfdProperties(@RequestParam(value = "src_switch",
required = false) final String srcSwitch, @RequestParam(value = "src_port",
required = false) final String srcPort, @RequestParam(value = "dst_switch",
required = false) final String dstSwitch, @RequestParam(value = "dst_port",
required = false) final String dstPort) {
return serviceSwitch.getLinkBfdProperties(srcSwitch, srcPort, dstSwitch, dstPort);
}

/**
* Updates the link BFD properties.
*
* @param srcSwitch the src switch
* @param srcPort the src port
* @param dstSwitch the dst switch
* @param dstPort the dst port
* @return the link Bfd properties
*/
@RequestMapping(value = "/links/bfd", method = RequestMethod.PUT)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = IConstants.Permission.ISL_UPDATE_BFD_PROPERTIES)
public @ResponseBody LinkBfdProperties updateBfdProperties(@RequestParam(value = "src_switch",
required = true) final String srcSwitch, @RequestParam(value = "src_port",
required = true) final String srcPort, @RequestParam(value = "dst_switch",
required = true) final String dstSwitch, @RequestParam(value = "dst_port",
required = true) final String dstPort, @RequestBody(required = true) BfdProperties properties) {
activityLogger.log(ActivityType.UPDATE_ISL_BFD_PROPERTIES, "Src_SW_" + srcSwitch + "\nSrc_PORT_"
+ srcPort + "\nDst_SW_" + dstSwitch + "\nDst_PORT_"
+ dstPort + "\nProperties_" + properties);
return serviceSwitch.updateLinkBfdProperties(srcSwitch, srcPort, dstSwitch, dstPort, properties);
}

/**
* Delete link BFD.
*
* @param srcSwitch the src switch
* @param srcPort the src port
* @param dstSwitch the dst switch
* @param dstPort the dst port
*/
@RequestMapping(value = "/links/bfd", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = IConstants.Permission.ISL_DELETE_BFD)
public @ResponseBody String deleteLinkBfd(@RequestParam(value = "src_switch",
required = true) final String srcSwitch, @RequestParam(value = "src_port",
required = true) final String srcPort, @RequestParam(value = "dst_switch",
required = true) final String dstSwitch, @RequestParam(value = "dst_port",
required = true) final String dstPort) {
activityLogger.log(ActivityType.DELETE_ISL_BFD, "Src_SW_" + srcSwitch + "\nSrc_PORT_"
+ srcPort + "\nDst_SW_" + dstSwitch + "\nDst_PORT_" + dstPort);
return serviceSwitch.deleteLinkBfd(srcSwitch, srcPort, dstSwitch, dstPort);
}
}
26 changes: 26 additions & 0 deletions src-gui/src/main/java/org/openkilda/helper/RestClientManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,30 @@ public static boolean isValidResponse(final HttpResponse response) {
}
}
}

/**
* Checks if is delete link bfd valid response.
*
* @param response the response
* @return true, if is valid response
*/
public static boolean isDeleteBfdValidResponse(final HttpResponse response) {
LOGGER.debug("[isValidResponse] Response Code " + response.getStatusLine().getStatusCode());
boolean isValid = response.getStatusLine().getStatusCode() >= HttpStatus.OK.value()
&& response.getStatusLine().getStatusCode() < HttpStatus.MULTIPLE_CHOICES.value();
if (isValid) {
return true;
} else {
try {
String content = IoUtil.toString(response.getEntity().getContent());
LOGGER.warn("Found invalid Response. Status Code: " + response.getStatusLine().getStatusCode()
+ ", content: " + content);
throw new InvalidResponseException(response.getStatusLine().getStatusCode(), content);
} catch (IOException exception) {
LOGGER.warn("Error occurred while vaildating response", exception);
throw new InvalidResponseException(HttpError.INTERNAL_ERROR.getCode(),
HttpError.INTERNAL_ERROR.getMessage());
}
}
}
}
Loading

0 comments on commit 02e6d83

Please sign in to comment.