├── version ├── .travis.yml ├── .gitignore ├── license-template ├── src ├── main │ ├── resources │ │ ├── buildInfo.properties │ │ ├── AvailableBundle.properties │ │ ├── LocalMsgResources │ │ │ └── infrastructure │ │ │ │ ├── IdentityExceptionDtls_de.properties │ │ │ │ ├── IdentityExceptionDtls_en.properties │ │ │ │ ├── IdentityExceptionDtls_fr.properties │ │ │ │ ├── IdentityExceptionDtls_ja.properties │ │ │ │ ├── IdentityExceptionDtls_ko.properties │ │ │ │ └── IdentityExceptionDtls_zh_CN.properties │ │ ├── bootstrap.yml │ │ ├── config-readme.md │ │ ├── request_builder.md │ │ └── application.yml │ └── java │ │ └── com │ │ └── dell │ │ └── isg │ │ └── smi │ │ └── service │ │ ├── device │ │ ├── discovery │ │ │ ├── BuildInfo.java │ │ │ ├── Application.java │ │ │ ├── SimpleCORSFilter.java │ │ │ ├── config │ │ │ │ ├── InnerConfig.java │ │ │ │ ├── DiscoveryDeviceConfig.java │ │ │ │ └── DiscoveryDeviceConfigProvider.java │ │ │ ├── validation │ │ │ │ ├── Validator.java │ │ │ │ ├── IPRangeValidatorUtil.java │ │ │ │ ├── Inet4RangeComparator.java │ │ │ │ ├── ValidatedInet4Range.java │ │ │ │ ├── Inet4ConverterValidator.java │ │ │ │ ├── ValidatedInet4Address.java │ │ │ │ └── ValidatedInet4SubnetMask.java │ │ │ ├── utilities │ │ │ │ ├── PatternUtils.java │ │ │ │ ├── ExceptionUtilities.java │ │ │ │ ├── DiscoverDeviceTypeUtil.java │ │ │ │ └── ExtractDeviceSummaryUtil.java │ │ │ ├── controller │ │ │ │ ├── RootController.java │ │ │ │ └── DeviceDiscoveryController.java │ │ │ ├── manager │ │ │ │ ├── IDiscoveryManager.java │ │ │ │ ├── DiscoveryManagerImpl.java │ │ │ │ └── threads │ │ │ │ │ ├── DiscoveryThreadScope.java │ │ │ │ │ ├── SummaryCollectionThread.java │ │ │ │ │ ├── DeviceIdentificationThread.java │ │ │ │ │ └── RequestScopeDiscoveryCredential.java │ │ │ ├── DiscoveryRequestContextFilter.java │ │ │ ├── DiscoveryRequestContextListener.java │ │ │ ├── DiscoveryCustomScopeRegisteringBeanFactoryPostProcessor.java │ │ │ └── ui │ │ │ │ ├── builder │ │ │ │ ├── DeviceRangeRequestModifiedEvent.java │ │ │ │ ├── DeviceRangeRequestHandler.java │ │ │ │ ├── DeviceRangeRequest.java │ │ │ │ ├── DeviceRangeRequestForm.java │ │ │ │ └── RequestBuilderUI.java │ │ │ │ └── config │ │ │ │ ├── ConfigDeviceType.java │ │ │ │ ├── ConfigDeviceTypeForm.java │ │ │ │ ├── ConfigDeviceTypeHandler.java │ │ │ │ └── ConfigurationUI.java │ │ └── exception │ │ │ ├── EnumErrorCode.java │ │ │ ├── BadRequestException.java │ │ │ └── NotFoundException.java │ │ └── server │ │ └── inventory │ │ └── Transformer │ │ ├── TranformerUtil.java │ │ └── TransformerAssemblerConstants.java ├── docs │ └── asciidoc │ │ ├── api-device-discovery-v1.adoc │ │ ├── examples.adoc │ │ └── readme.adoc └── test │ └── java │ └── com │ └── dell │ └── isg │ └── smi │ └── service │ └── device │ └── discovery │ ├── Swagger2MarkupTest.java │ └── DeviceDiscoveryControllerTest.java ├── settings.gradle.setting ├── pkg └── dell-device-discovery.service ├── Dockerfile ├── .classpath ├── .project ├── gradle.properties ├── README.md ├── LICENSE └── application.yml /version: -------------------------------------------------------------------------------- 1 | 1.1.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /bin/ 3 | src/main/lib/ 4 | .gradle/ 5 | .settings/ 6 | -------------------------------------------------------------------------------- /license-template: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/license-template -------------------------------------------------------------------------------- /src/main/resources/buildInfo.properties: -------------------------------------------------------------------------------- 1 | buildInfo.version=1.0 2 | buildInfo.tag=devel 3 | buildInfo.date=09-27-2017_10-03 -------------------------------------------------------------------------------- /settings.gradle.setting: -------------------------------------------------------------------------------- 1 | include ':smi-lib-commons-model' 2 | project(':smi-lib-commons-model').projectDir = new File(settingsDir, '../smi-lib-commons-model') -------------------------------------------------------------------------------- /src/main/resources/AvailableBundle.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/resources/AvailableBundle.properties -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/BuildInfo.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/BuildInfo.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/Application.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/Application.java -------------------------------------------------------------------------------- /src/docs/asciidoc/api-device-discovery-v1.adoc: -------------------------------------------------------------------------------- 1 | include::{generated}/overview.adoc[] 2 | include::readme.adoc[] 3 | include::{generated}/paths.adoc[] 4 | include::{generated}/definitions.adoc[] 5 | include::examples.adoc[] -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/exception/EnumErrorCode.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/exception/EnumErrorCode.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/SimpleCORSFilter.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/SimpleCORSFilter.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/config/InnerConfig.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/config/InnerConfig.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/exception/BadRequestException.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/exception/BadRequestException.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/exception/NotFoundException.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/exception/NotFoundException.java -------------------------------------------------------------------------------- /src/test/java/com/dell/isg/smi/service/device/discovery/Swagger2MarkupTest.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/test/java/com/dell/isg/smi/service/device/discovery/Swagger2MarkupTest.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/validation/Validator.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/validation/Validator.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/utilities/PatternUtils.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/utilities/PatternUtils.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/controller/RootController.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/controller/RootController.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/manager/IDiscoveryManager.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/manager/IDiscoveryManager.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/server/inventory/Transformer/TranformerUtil.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/server/inventory/Transformer/TranformerUtil.java -------------------------------------------------------------------------------- /src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_de.properties -------------------------------------------------------------------------------- /src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_en.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_en.properties -------------------------------------------------------------------------------- /src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_fr.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_fr.properties -------------------------------------------------------------------------------- /src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_ja.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_ja.properties -------------------------------------------------------------------------------- /src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_ko.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_ko.properties -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/DiscoveryRequestContextFilter.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/DiscoveryRequestContextFilter.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/config/DiscoveryDeviceConfig.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/config/DiscoveryDeviceConfig.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/manager/DiscoveryManagerImpl.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/manager/DiscoveryManagerImpl.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/utilities/ExceptionUtilities.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/utilities/ExceptionUtilities.java -------------------------------------------------------------------------------- /src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_zh_CN.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/resources/LocalMsgResources/infrastructure/IdentityExceptionDtls_zh_CN.properties -------------------------------------------------------------------------------- /src/test/java/com/dell/isg/smi/service/device/discovery/DeviceDiscoveryControllerTest.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/test/java/com/dell/isg/smi/service/device/discovery/DeviceDiscoveryControllerTest.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/DiscoveryRequestContextListener.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/DiscoveryRequestContextListener.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/validation/IPRangeValidatorUtil.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/validation/IPRangeValidatorUtil.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/validation/Inet4RangeComparator.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/validation/Inet4RangeComparator.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/validation/ValidatedInet4Range.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/validation/ValidatedInet4Range.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/utilities/DiscoverDeviceTypeUtil.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/utilities/DiscoverDeviceTypeUtil.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/utilities/ExtractDeviceSummaryUtil.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/utilities/ExtractDeviceSummaryUtil.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/validation/Inet4ConverterValidator.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/validation/Inet4ConverterValidator.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/validation/ValidatedInet4Address.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/validation/ValidatedInet4Address.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/config/DiscoveryDeviceConfigProvider.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/config/DiscoveryDeviceConfigProvider.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/controller/DeviceDiscoveryController.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/controller/DeviceDiscoveryController.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/manager/threads/DiscoveryThreadScope.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/manager/threads/DiscoveryThreadScope.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/validation/ValidatedInet4SubnetMask.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/validation/ValidatedInet4SubnetMask.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/manager/threads/SummaryCollectionThread.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/manager/threads/SummaryCollectionThread.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/server/inventory/Transformer/TransformerAssemblerConstants.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/server/inventory/Transformer/TransformerAssemblerConstants.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/manager/threads/DeviceIdentificationThread.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/manager/threads/DeviceIdentificationThread.java -------------------------------------------------------------------------------- /pkg/dell-device-discovery.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=dell-device-discovery 3 | After=syslog.target 4 | 5 | [Service] 6 | User=devuser 7 | ExecStart=/opt/dell/smi/service-device-discovery/application.jar 8 | SuccessExitStatus=143 9 | 10 | [Install] 11 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/manager/threads/RequestScopeDiscoveryCredential.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/manager/threads/RequestScopeDiscoveryCredential.java -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/DiscoveryCustomScopeRegisteringBeanFactoryPostProcessor.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RackHD/smi-service-device-discovery/master/src/main/java/com/dell/isg/smi/service/device/discovery/DiscoveryCustomScopeRegisteringBeanFactoryPostProcessor.java -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre 2 | ADD build/libs/service-device-discovery*.jar app.jar 3 | COPY application.yml /application.yml 4 | EXPOSE 46002 5 | RUN apt-get update -qq && apt-get -y install arping 6 | RUN sh -c 'touch /app.jar' 7 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 8 | 9 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | smi-service-device-discovery 4 | 5 | 6 | 7 | org.eclipse.buildship.core.gradleprojectnature 8 | org.eclipse.jdt.core.javanature 9 | 10 | 11 | 12 | org.eclipse.jdt.core.javabuilder 13 | 14 | 15 | 16 | org.eclipse.buildship.core.gradleprojectbuilder 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/builder/DeviceRangeRequestModifiedEvent.java: -------------------------------------------------------------------------------- 1 | package com.dell.isg.smi.service.device.discovery.ui.builder; 2 | 3 | import java.io.Serializable; 4 | 5 | public class DeviceRangeRequestModifiedEvent implements Serializable { 6 | 7 | /** 8 | * 9 | */ 10 | private static final long serialVersionUID = -3802187894585926758L; 11 | private final DeviceRangeRequest deviceRangeRequest; 12 | 13 | public DeviceRangeRequestModifiedEvent(DeviceRangeRequest deviceRangeRequest) { 14 | this.deviceRangeRequest = deviceRangeRequest; 15 | } 16 | 17 | public DeviceRangeRequest getDeviceRangeRequest() { 18 | return deviceRangeRequest; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | version=1.0 2 | dockerTag=devel 3 | dependency_repo=libs-snapshot 4 | buildInfo.licenseControl.runChecks=true 5 | buildInfo.licenseControl.autoDiscover=true 6 | buildInfo.build.name=com.dell.isg.smi:service-device-discovery 7 | systemProp.sonar.host.url=https://sonarqube.com 8 | systemProp.sonar.organization=rackhd-smi 9 | systemProp.sonar.login=##sonarqubeLogin-placeholder## 10 | bintrayRepo=docs 11 | bintrayUserOrg=rackhd 12 | bintrayVcsUrl=https://bintray.com/rackhd/docs/apidoc 13 | bintrayUser=##bintray-user-placeholder## 14 | bintrayApiKey=##bintray-api-key-placeholder## 15 | adapterServerVersion=1.0.81 16 | adapterChassisVersion=1.0.32 17 | commonsElmVersion=1.0.82 18 | commonsUtilitiesVersion=1.0.32 19 | commonsModelVersion=1.0.97 20 | -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/builder/DeviceRangeRequestHandler.java: -------------------------------------------------------------------------------- 1 | 2 | package com.dell.isg.smi.service.device.discovery.ui.builder; 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import org.springframework.stereotype.Component; 8 | 9 | @Component 10 | public class DeviceRangeRequestHandler { 11 | private List rangeSet = new ArrayList(); 12 | 13 | public List getRangeSet() { 14 | return rangeSet; 15 | } 16 | 17 | public void setRangeSet(List rangeSet) { 18 | this.rangeSet = rangeSet; 19 | } 20 | 21 | public void addRange(DeviceRangeRequest deviceRangeRequest) { 22 | rangeSet.add(deviceRangeRequest); 23 | } 24 | 25 | public void delete(DeviceRangeRequest deviceRangeRequest) { 26 | rangeSet.remove(deviceRangeRequest); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 46002 3 | 4 | logging: 5 | level.root: ERROR 6 | level.com.dell.isg.smi: DEBUG 7 | file: /var/log/dell/service-device-discovery.log 8 | 9 | spring: 10 | jackson: 11 | serialization-inclusion : non_null 12 | 13 | command: 14 | arp: 15 | mac: "arping -I eth0 -c 1 %s" 16 | 17 | --- 18 | 19 | spring: 20 | profiles: default 21 | application: 22 | name: DEVICE-DISCOVERY 23 | cloud: 24 | bus: 25 | enabled: false 26 | consul: 27 | enabled: false 28 | config: 29 | enabled: false 30 | --- 31 | 32 | spring: 33 | profiles: consul 34 | application: 35 | name: DEVICE-DISCOVERY 36 | cloud: 37 | consul: 38 | discovery: 39 | preferIpAddress: true 40 | enabled: true 41 | host: service-registry 42 | port: 8500 43 | config: 44 | prefix: config 45 | profileSeparator: '::' 46 | format: YAML 47 | data-key: data 48 | fail-fast: true -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/builder/DeviceRangeRequest.java: -------------------------------------------------------------------------------- 1 | package com.dell.isg.smi.service.device.discovery.ui.builder; 2 | 3 | import java.util.Set; 4 | 5 | import javax.validation.constraints.NotNull; 6 | import javax.validation.constraints.Size; 7 | 8 | public class DeviceRangeRequest { 9 | 10 | String id; 11 | Set deviceGroups; 12 | @NotNull(message = "startIp is required") 13 | @Size(min = 3, max = 50, message = "name must be longer than 3 and less than 40 characters") 14 | String startIp; 15 | @NotNull(message = "endIp is required") 16 | @Size(min = 0, max = 500, message = "name must be longer than 3 and less than 500 characters") 17 | String endIp; 18 | String username; 19 | String password; 20 | 21 | public DeviceRangeRequest() { 22 | super(); 23 | } 24 | 25 | public Set getDeviceGroups() { 26 | return deviceGroups; 27 | } 28 | 29 | public void setDeviceGroups(Set deviceGroups) { 30 | this.deviceGroups = deviceGroups; 31 | } 32 | 33 | public String getStartIp() { 34 | return startIp; 35 | } 36 | 37 | public void setStartIp(String startIp) { 38 | this.startIp = startIp; 39 | } 40 | 41 | public String getEndIp() { 42 | return endIp; 43 | } 44 | 45 | public void setEndIp(String endIp) { 46 | this.endIp = endIp; 47 | } 48 | 49 | public String getUsername() { 50 | return username; 51 | } 52 | 53 | public void setUsername(String username) { 54 | this.username = username; 55 | } 56 | 57 | public String getPassword() { 58 | return password; 59 | } 60 | 61 | public void setPassword(String password) { 62 | this.password = password; 63 | } 64 | 65 | public String getId() { 66 | return id; 67 | } 68 | 69 | public void setId(String id) { 70 | this.id = id; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/config/ConfigDeviceType.java: -------------------------------------------------------------------------------- 1 | package com.dell.isg.smi.service.device.discovery.ui.config; 2 | 3 | import javax.validation.constraints.NotNull; 4 | import javax.validation.constraints.Size; 5 | 6 | public class ConfigDeviceType { 7 | 8 | @NotNull(message = "Group is required") 9 | @Size(min = 3, max = 50, message = "name must be longer than 3 and less than 40 characters") 10 | String group; 11 | @NotNull(message = "Name is required") 12 | @Size(min = 3, max = 50, message = "name must be longer than 3 and less than 40 characters") 13 | String name; 14 | @NotNull(message = "IndentifyBy is required") 15 | @Size(min = 3, max = 50, message = "name must be longer than 3 and less than 40 characters") 16 | String identifyBy; 17 | @NotNull(message = "Identifiers is required") 18 | @Size(min = 0, max = 500, message = "name must be longer than 3 and less than 500 characters") 19 | String identifiers; 20 | @NotNull(message = "Username is required") 21 | @Size(min = 3, max = 50, message = "name must be longer than 3 and less than 40 characters") 22 | String username; 23 | @NotNull(message = "Password is required") 24 | @Size(min = 3, max = 50, message = "name must be longer than 3 and less than 40 characters") 25 | String password; 26 | @NotNull(message = "Enabled is required") 27 | boolean enabled; 28 | 29 | public ConfigDeviceType() { 30 | super(); 31 | } 32 | 33 | 34 | 35 | public ConfigDeviceType(String group) { 36 | super(); 37 | this.group = group; 38 | } 39 | 40 | 41 | 42 | public ConfigDeviceType(String group, String name, Boolean enabled) { 43 | super(); 44 | this.group = group; 45 | this.name = name; 46 | this.enabled = enabled; 47 | } 48 | 49 | public String getGroup() { 50 | return group; 51 | } 52 | 53 | public void setGroup(String group) { 54 | this.group = group; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public void setName(String name) { 62 | this.name = name; 63 | } 64 | 65 | public String getIdentifyBy() { 66 | return identifyBy; 67 | } 68 | 69 | public void setIdentifyBy(String identifyBy) { 70 | this.identifyBy = identifyBy; 71 | } 72 | 73 | public String getIdentifiers() { 74 | return identifiers; 75 | } 76 | 77 | public void setIdentifiers(String identifiers) { 78 | this.identifiers = identifiers; 79 | } 80 | 81 | public String getUsername() { 82 | return username; 83 | } 84 | 85 | public void setUsername(String username) { 86 | this.username = username; 87 | } 88 | 89 | public String getPassword() { 90 | return password; 91 | } 92 | 93 | public void setPassword(String password) { 94 | this.password = password; 95 | } 96 | 97 | public Boolean getEnabled() { 98 | return enabled; 99 | } 100 | 101 | public void setEnabled(Boolean enabled) { 102 | this.enabled = enabled; 103 | } 104 | 105 | public boolean isPersisted() { 106 | return name != null; 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/builder/DeviceRangeRequestForm.java: -------------------------------------------------------------------------------- 1 | package com.dell.isg.smi.service.device.discovery.ui.builder; 2 | 3 | import java.util.stream.Stream; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.vaadin.viritin.form.AbstractForm; 7 | import org.vaadin.viritin.layouts.MFormLayout; 8 | import org.vaadin.viritin.layouts.MVerticalLayout; 9 | 10 | import com.dell.isg.smi.commons.model.device.discovery.DiscoveryDeviceGroupEnum; 11 | import com.vaadin.spring.annotation.SpringComponent; 12 | import com.vaadin.spring.annotation.UIScope; 13 | import com.vaadin.ui.CheckBox; 14 | import com.vaadin.ui.Component; 15 | import com.vaadin.ui.Notification; 16 | import com.vaadin.ui.Panel; 17 | import com.vaadin.ui.PasswordField; 18 | import com.vaadin.ui.TextField; 19 | import com.vaadin.ui.TwinColSelect; 20 | import com.vaadin.ui.VerticalLayout; 21 | 22 | @UIScope 23 | @SpringComponent 24 | public class DeviceRangeRequestForm extends AbstractForm { 25 | 26 | private static final long serialVersionUID = -5957848856809398440L; 27 | @Autowired 28 | DeviceRangeRequestHandler deviceRangeRequestHandler; 29 | private RequestBuilderUI requestBuilderUI; 30 | private TwinColSelect deviceGroups = new TwinColSelect("Select the group(s) for Discovery :"); 31 | private TextField startIp = new TextField("Start IP :"); 32 | private TextField endIp = new TextField("End IP :"); 33 | private CheckBox credential = new CheckBox("Local Credential "); 34 | private TextField username = new TextField("Username :"); 35 | private PasswordField password = new PasswordField("Password :"); 36 | private Panel credPanel = new Panel(); 37 | 38 | public DeviceRangeRequestForm(RequestBuilderUI requestBuilderUI) { 39 | super(DeviceRangeRequest.class); 40 | this.requestBuilderUI = requestBuilderUI; 41 | String[] discoverGroupNames = Stream.of(DiscoveryDeviceGroupEnum.values()).map(DiscoveryDeviceGroupEnum::name) 42 | .toArray(String[]::new); 43 | deviceGroups.setItems(discoverGroupNames); 44 | 45 | VerticalLayout credLayout = new VerticalLayout(); 46 | credLayout.addComponents(username, password); 47 | credPanel.setContent(credLayout); 48 | credPanel.setVisible(false); 49 | 50 | credential.addValueChangeListener(event -> { 51 | if (event.getValue() == false) { 52 | credPanel.setVisible(false); 53 | } else { 54 | credPanel.setVisible(true); 55 | } 56 | }); 57 | // setSavedHandler(rangeRequest -> { 58 | // try { 59 | // deviceRangeRequestHandler.addRange(rangeRequest); 60 | // requestBuilderUI.onPersonModified(); 61 | // } catch (Exception e) { 62 | // e.printStackTrace(); 63 | // } 64 | // }); 65 | 66 | setSizeUndefined(); 67 | } 68 | 69 | 70 | @Override 71 | protected Component createContent() { 72 | return new MVerticalLayout( 73 | new MFormLayout( 74 | deviceGroups, 75 | startIp, 76 | endIp, 77 | credential, 78 | credPanel 79 | ).withWidth(""), 80 | getToolbar() 81 | ).withWidth(""); 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/config/ConfigDeviceTypeForm.java: -------------------------------------------------------------------------------- 1 | package com.dell.isg.smi.service.device.discovery.ui.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.vaadin.viritin.button.MButton; 5 | import org.vaadin.viritin.fields.MTextField; 6 | 7 | import com.vaadin.data.Binder; 8 | import com.vaadin.event.ShortcutAction.KeyCode; 9 | import com.vaadin.icons.VaadinIcons; 10 | import com.vaadin.server.FontAwesome; 11 | import com.vaadin.spring.annotation.SpringComponent; 12 | import com.vaadin.spring.annotation.UIScope; 13 | import com.vaadin.ui.Button; 14 | import com.vaadin.ui.CheckBox; 15 | import com.vaadin.ui.FormLayout; 16 | import com.vaadin.ui.HorizontalLayout; 17 | import com.vaadin.ui.Notification; 18 | import com.vaadin.ui.Panel; 19 | import com.vaadin.ui.PasswordField; 20 | import com.vaadin.ui.TextArea; 21 | import com.vaadin.ui.TextField; 22 | import com.vaadin.ui.themes.ValoTheme; 23 | 24 | @UIScope 25 | @SpringComponent 26 | public class ConfigDeviceTypeForm extends FormLayout { 27 | 28 | /** 29 | * 30 | */ 31 | private static final long serialVersionUID = 1L; 32 | @Autowired 33 | public ConfigDeviceTypeHandler configHandler; 34 | private ConfigDeviceType configDeviceType; 35 | private ConfigurationUI configuratorUI; 36 | private Binder binder = new Binder<>(ConfigDeviceType.class); 37 | 38 | private TextField group = new TextField("Group :"); 39 | private TextField name = new TextField("Device Type :"); 40 | private TextField identifyBy = new TextField("Identified By :"); 41 | private TextArea identifiers = new TextArea("Identifiers :"); 42 | private TextField username = new TextField("User :"); 43 | private PasswordField password = new PasswordField("Password :"); 44 | private CheckBox enabled = new CheckBox("Discovery Enabled "); 45 | private Button save = new MButton(); 46 | private Button cancel = new MButton(); 47 | 48 | public ConfigDeviceTypeForm(ConfigurationUI configuratorUI) { 49 | this.configuratorUI = configuratorUI; 50 | group.setEnabled(false); 51 | name.setEnabled(false); 52 | identifyBy.setEnabled(false); 53 | identifiers.setEnabled(false); 54 | identifiers.setWordWrap(true); 55 | save.setIcon(VaadinIcons.CHECK_CIRCLE,"Save"); 56 | cancel.setIcon(VaadinIcons.CLOSE_CIRCLE,"Cancel"); 57 | setSizeUndefined(); 58 | HorizontalLayout buttons = new HorizontalLayout(save, cancel); 59 | 60 | Panel formPanel = new Panel("Global Credential "); 61 | formPanel.addStyleName("mypanelexample"); 62 | formPanel.setSizeUndefined(); // Shrink to fit content 63 | // Create the content 64 | FormLayout content = new FormLayout(); 65 | content.addStyleName("mypanelcontent"); 66 | content.addComponents(group, name, username, password, enabled, buttons); 67 | //content.addComponents(group, name, identifyBy, identifiers, username, password, enabled, buttons); 68 | content.setSizeUndefined(); // Shrink to fit 69 | content.setMargin(true); 70 | formPanel.setContent(content); 71 | setSizeUndefined(); 72 | addComponents(formPanel); 73 | save.setStyleName(ValoTheme.BUTTON_PRIMARY); 74 | save.setClickShortcut(KeyCode.ENTER); 75 | binder.bindInstanceFields(this); 76 | save.addClickListener(e -> this.save()); 77 | cancel.addClickListener(e -> this.cancel()); 78 | } 79 | 80 | public void setConfigDeviceType(ConfigDeviceType configDeviceType) { 81 | this.configDeviceType = configDeviceType; 82 | binder.setBean(configDeviceType); 83 | setVisible(true); 84 | group.selectAll(); 85 | } 86 | 87 | private void cancel() { 88 | configuratorUI.updateList(); 89 | setVisible(false); 90 | } 91 | 92 | private void save() { 93 | try { 94 | configHandler.save(configDeviceType); 95 | } catch (Exception e) { 96 | 97 | } 98 | configuratorUI.updateList(); 99 | setVisible(false); 100 | Notification.show("Saved :", 101 | "Configuration modification to " +configDeviceType.name + " was successfull !!!. ", 102 | Notification.Type.HUMANIZED_MESSAGE); 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/docs/asciidoc/examples.adoc: -------------------------------------------------------------------------------- 1 | Device Summary Response 2 | ------------------------ 3 | 4 | Based on the device type identified , the summary response schema could be any one of the following.. 5 | 6 | SERVER 7 | ~~~~~~ 8 | 9 | Types - IDRAC7, IDRAC8 and IDRAC9 10 | 11 | Example: 12 | 13 | ----------------- 14 | { 15 | "id":"100.68.123.39", 16 | "activePowerPolicy":null, 17 | "assetTag":"", 18 | "biosReleaseDate":"", 19 | "biosVersionString":"2.4.2", 20 | "baseBoardChassisSlot":"Slot 01", 21 | "boardPartNumber":"0JXJPTA00", 22 | "boardSerialNumber":"CN7016352P00A6", 23 | "cmcip":"100.68.123.36", 24 | "bladeGeometry":"5", 25 | "cpldVersion":"1.0.5", 26 | "cpuRollupStatus":"1", 27 | "caption":null, 28 | "chassisName":"CMC-5VN2D42", 29 | "chassisModel":"PowerEdge FX2s", 30 | "deviceDescription":"System", 31 | "chassisServiceTag":"5VN2D42", 32 | "chassisSystemHeight":"2", 33 | "currentRollupStatus":"1", 34 | "estimatedSystemAirflow":"255", 35 | "estimatedExhaustTemperature":"255", 36 | "expressServiceCode":"12797151266", 37 | "elementName":null, 38 | "fqdd":"System.Embedded.1", 39 | "fanRollupStatus":"1", 40 | "batteryRollupStatus":"1", 41 | "generation":null, 42 | "hostName":"", 43 | "instanceID":"System.Embedded.1", 44 | "idsdmRollupStatus":null, 45 | "intrusionRollupStatus":null, 46 | "lastSystemInventoryTime":"20170915175417.000000+000", 47 | "lastUpdateTime":"20170912224518.000000+000", 48 | "licensingRollupStatus":"1", 49 | "lifecycleControllerVersion":"2.41.40.40", 50 | "manufacturer":"Dell Inc.", 51 | "maxCpuSockets":"2", 52 | "maxDimmSlots":"24", 53 | "maxPcieSlots":"3", 54 | "memoryOperationMode":"OptimizerMode", 55 | "memoryRollupStatus":"1", 56 | "model":"PowerEdge FC630", 57 | "nodeId":"5VN3D42", 58 | "psRollupStatus":"1", 59 | "platformGuid":"3234444f-c0b5-3380-4e10-00564c4c4544", 60 | "populatedCpuSockets":"2", 61 | "populatedDimmSlots":"6", 62 | "populatedPcieSlots":"2", 63 | "powerCap":"423", 64 | "powerCapEnabledState":"3", 65 | "powerState":"2", 66 | "primaryStatus":"1", 67 | "sdCardRollupStatus":null, 68 | "rollupStatus":"1", 69 | "serverAllocation":"446", 70 | "serviceTag":"5VN3D42", 71 | "storageRollupStatus":"1", 72 | "sysMemErrorInfo":null, 73 | "sysMemErrorMethodology":"6", 74 | "sysMemFailOverState":"NotInUse", 75 | "sysMemLocation":"3", 76 | "sysMemPrimaryStatus":"1", 77 | "sysMemTotalSize":96, 78 | "sysMemMaxCapacitySize":"3145728", 79 | "systemGeneration":"13G Modular", 80 | "systemID":"1563", 81 | "systemRevision":"0", 82 | "tempRollupStatus":"1", 83 | "tempStatisticsRollupStatus":"1", 84 | "uuid":"4c4c4544-0056-4e10-8033-b5c04f443432", 85 | "voltRollupStatus":"1", 86 | "smbiosGUID":"44454c4c-5600-104e-8033-b5c04f443432" 87 | } 88 | ----------------- 89 | 90 | CHASSIS 91 | ~~~~~~~ 92 | 93 | Type : CMC, CMC_FX2, CSERVER and VRTX 94 | 95 | Example : 96 | 97 | ----------------- 98 | { 99 | "id":"100.68.123.96", 100 | "name":"CMC-2LLTW52", 101 | "serviceTag":"2LLTW52", 102 | "model":"PowerEdge FX2s", 103 | "dnsName":"cmc-2LLTW52", 104 | "location":"[UNDEFINED]", 105 | "totalSlots":2, 106 | "freeSlots":1 107 | } 108 | ----------------- 109 | 110 | Supported Devices 111 | ~~~~~~~~~~~~~~~~~ 112 | *SERVER,CHASSIS and STORAGE - Discovery and brief summary. 113 | *VM and SWITCH - Only discovery but NO Summary 114 | 115 | Supported device types: 116 | .... 117 | SERVER: 118 | IDRAC7 119 | IDRAC8 120 | IDRAC9 121 | 122 | CHASSIS: 123 | CMC 124 | CMC_FX2 125 | CSERVER 126 | VRTX 127 | 128 | SWITCH: 129 | FORCE10_S4810 130 | FORCE10_S5000 131 | FORCE10_S6000 132 | FORCE10_S4048 133 | FORCE10_S55 134 | BROCADE 135 | POWERCONNECT 136 | POWERCONNECT_N3000 137 | POWERCONNECT_N4000 138 | CISCONEXUS 139 | 140 | STORAGE: 141 | COMPELLENT 142 | 143 | VM: 144 | VCENTER 145 | .... 146 | 147 | Licensing 148 | --------- 149 | 150 | This docker microservice is available under the 151 | http://www.apache.org/licenses/LICENSE-2.0.txt[Apache 2.0 License]. 152 | 153 | Source code for this microservice is available in repositories at 154 | https://github.com/RackHD. 155 | 156 | 157 | Support 158 | ------- 159 | 160 | Slack Channel: codecommunity.slack.com 161 | -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/config/ConfigDeviceTypeHandler.java: -------------------------------------------------------------------------------- 1 | 2 | package com.dell.isg.smi.service.device.discovery.ui.config; 3 | 4 | import java.util.ArrayList; 5 | import java.util.Arrays; 6 | import java.util.List; 7 | import java.util.OptionalInt; 8 | import java.util.concurrent.CopyOnWriteArrayList; 9 | import java.util.stream.IntStream; 10 | 11 | import org.apache.commons.collections4.CollectionUtils; 12 | import org.apache.commons.collections4.Predicate; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.springframework.beans.BeanUtils; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.stereotype.Component; 17 | 18 | import com.dell.isg.smi.commons.model.device.discovery.DiscoveryDeviceGroupEnum; 19 | import com.dell.isg.smi.commons.model.device.discovery.config.DeviceDefaultCredential; 20 | import com.dell.isg.smi.commons.model.device.discovery.config.DeviceType; 21 | import com.dell.isg.smi.commons.model.device.discovery.config.Identifier; 22 | import com.dell.isg.smi.service.device.discovery.config.DiscoveryDeviceConfig; 23 | import com.dell.isg.smi.service.device.discovery.config.DiscoveryDeviceConfigProvider; 24 | 25 | @Component 26 | public class ConfigDeviceTypeHandler { 27 | 28 | @Autowired 29 | DiscoveryDeviceConfig discoveryDeviceConfig; 30 | 31 | @Autowired 32 | DiscoveryDeviceConfigProvider discoveryDeviceConfigProvider; 33 | 34 | CopyOnWriteArrayList configDeviceTypeMasterList = new CopyOnWriteArrayList(); 35 | 36 | void loadDeviceTypes(){ 37 | for (DiscoveryDeviceGroupEnum deviceGroupEnum : DiscoveryDeviceGroupEnum.values()) { 38 | List deviceTypeList = discoveryDeviceConfigProvider.getDeviceTypeByGroup(deviceGroupEnum); 39 | configDeviceTypeMasterList.addAll(transform(deviceGroupEnum.name(), deviceTypeList)); 40 | } 41 | } 42 | 43 | List findAll() { 44 | if (CollectionUtils.isEmpty(configDeviceTypeMasterList)) { 45 | loadDeviceTypes(); 46 | } 47 | return configDeviceTypeMasterList; 48 | } 49 | 50 | private List transform(String name, List deviceTypeList) { 51 | List configDeviceTypeList = new ArrayList(); 52 | if (CollectionUtils.isEmpty(deviceTypeList)) { 53 | return configDeviceTypeList; 54 | } 55 | for (DeviceType deviceType : deviceTypeList) { 56 | ConfigDeviceType configDeviceType = new ConfigDeviceType(name); 57 | BeanUtils.copyProperties(deviceType, configDeviceType); 58 | configDeviceType.setUsername(deviceType.getDeviceDefaultCredential().getUsername()); 59 | configDeviceType.setPassword(deviceType.getDeviceDefaultCredential().getPassword()); 60 | List identifierStrList = new ArrayList(); 61 | for (Identifier identifier : deviceType.getIdentifier()) { 62 | identifierStrList.add(identifier.getText()); 63 | } 64 | String[] identifiers = identifierStrList.stream().toArray(String[]::new); 65 | StringBuilder sb = new StringBuilder(); 66 | int count = 1; 67 | for (String s : identifiers) 68 | { 69 | sb.append(count +" : "+s + "\n"); 70 | count++; 71 | } 72 | configDeviceType.setIdentifiers(sb.toString()); 73 | configDeviceTypeList.add(configDeviceType); 74 | } 75 | return configDeviceTypeList; 76 | } 77 | 78 | List findByNameLikeIgnoreCase(String nameFilter) { 79 | if (CollectionUtils.isEmpty(configDeviceTypeMasterList)) { 80 | loadDeviceTypes(); 81 | } 82 | List convertedList = Arrays.asList(configDeviceTypeMasterList.stream().toArray(ConfigDeviceType[]::new)); 83 | List configDeviceTypeList = convertedList; 84 | if (!StringUtils.isEmpty(nameFilter)){ 85 | configDeviceTypeList = (List) CollectionUtils.select(convertedList , predicateConfigDeviceType(nameFilter.toUpperCase())); 86 | } 87 | return configDeviceTypeList; 88 | } 89 | 90 | private Predicate predicateConfigDeviceType(String filterString) { 91 | return new Predicate() { 92 | @Override 93 | public boolean evaluate(ConfigDeviceType configDeviceType) { 94 | if (configDeviceType == null) { 95 | return false; 96 | } 97 | return configDeviceType.getGroup().contains(filterString); 98 | } 99 | }; 100 | } 101 | 102 | synchronized void save(ConfigDeviceType configDeviceType) { 103 | OptionalInt indexOpt = IntStream.range(0, configDeviceTypeMasterList.size()) 104 | .filter(i -> configDeviceType.getName().equals(configDeviceTypeMasterList.get(i).getName())) 105 | .findFirst(); 106 | configDeviceTypeMasterList.set(indexOpt.getAsInt(), configDeviceType); 107 | DeviceType deviceType = new DeviceType(); 108 | deviceType.setName(configDeviceType.getName()); 109 | deviceType.setDeviceDefaultCredential(new DeviceDefaultCredential(configDeviceType.getUsername(),configDeviceType.getPassword())); 110 | deviceType.setEnabled(configDeviceType.getEnabled()); 111 | discoveryDeviceConfigProvider.modifyDeviceTypeConfig(deviceType,configDeviceType.getGroup()); 112 | } 113 | 114 | void reset() { 115 | discoveryDeviceConfigProvider.restore(); 116 | configDeviceTypeMasterList.clear(); 117 | loadDeviceTypes(); 118 | } 119 | 120 | void loadFrom(DiscoveryDeviceConfig deviceConfig) { 121 | discoveryDeviceConfigProvider.loadFrom(deviceConfig); 122 | configDeviceTypeMasterList.clear(); 123 | loadDeviceTypes(); 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /src/docs/asciidoc/readme.adoc: -------------------------------------------------------------------------------- 1 | Purpose 2 | ~~~~~~~ 3 | 4 | Given an IP Range and credentials, the service attemps to connect to each IP address to try and identify and retrieve basic summary information for all devices within the range. It is written primarily for finding Dell devices, but may identify a few others in the datacenter as well. It is a stateless (12 factor app) that returns a JSON summary response. 5 | 6 | This microservice can be used by itself, or as one piece of a larger discovery and inventory effort. This service is used by RackHD as part of a Dell WSMAN discovery and inventory workflow (taskgraph). It is one of several Docker containerized micro-services used as part of the workflow. 7 | 8 | How to Use 9 | ~~~~~~~~~~ 10 | 11 | A docker container for this service is available at: 12 | https://hub.docker.com/r/rackhd/device-discovery/ 13 | 14 | .... 15 | docker run --name device-discovery -p 0.0.0.0:46002:46002 -d rackhd/device-discovery:latest 16 | .... 17 | 18 | The service can also start up to bootstrap its configuration from consul. More information about registration with and using advanced configuration settings provided by a Consul K/V store can be found in the online help. 19 | 20 | CURL example with one network range payload 21 | +++++++++++++++++++++++++++++++++++++++++++ 22 | 23 | The micro-service REST endpoints can be invoked via CURL or via another application. 24 | 25 | Example: 26 | 27 | .... 28 | curl -X POST -H 'Content-Type: application/json' -d '{"credential":{"user": "root","password": "calvin"},"discoverIpRangeDeviceRequests":[{"deviceType": null,"deviceStartIp": "100.68.123.1","deviceEndIp": "100.68.123.254","credential": null}]}' http://:46002/api/1.0/discover/range 29 | .... 30 | 31 | Example payloads 32 | ++++++++++++++++ 33 | 34 | The payload allows for global and local (per range) credentials and device types. Global values are always overwritten by local values. 35 | 36 | Example Payload 1. 37 | 38 | Use global credentials (override all credentials in application yml for all devices) 39 | .... 40 | /api/1.0/discover/range 41 | 42 | { 43 | "credential":{ 44 | "userName":"root", 45 | "password":"calvin" 46 | }, 47 | "discoverIpRangeDeviceRequests":[ 48 | { 49 | "deviceStartIp":"100.68.124.6", 50 | "deviceEndIp":"100.68.124.57", 51 | } 52 | ] 53 | } 54 | 55 | /api/1.0/discover/ips: 56 | 57 | { 58 | "credential": { 59 | "password": "calvin1", 60 | "userName": "root1" 61 | }, 62 | "ips": [ 63 | "100.68.124.37","100.68.124.43" 64 | ] 65 | } 66 | .... 67 | 68 | Example Payload 2. 69 | 70 | Use Credential specific to device type (Override credential from application YML specific to devices). If global credentials are supplied (as in example 1 above), the specific device credentials will be used instead for that device type. 71 | 72 | .... 73 | /api/1.0/discover/range 74 | 75 | { 76 | "discoverIpRangeDeviceRequests":[ 77 | { 78 | "deviceType":["SERVER"], 79 | "deviceStartIp":"100.68.124.0", 80 | "deviceEndIp":"100.68.124.255", 81 | "credential":{ 82 | "userName":"abc0", 83 | "password":"xyz0" 84 | } 85 | }, 86 | { 87 | "deviceType":["CHASSIS"], 88 | "deviceStartIp":"100.68.12.0", 89 | "deviceEndIp":"100.68.12.255", 90 | "credential":{ 91 | "userName":"abc1", 92 | "password":"xyz1" 93 | } 94 | }, 95 | { 96 | "deviceType":["IOM"], 97 | "deviceStartIp":"100.68.123.0", 98 | "deviceEndIp":"100.68.123.255", 99 | "credential":{ 100 | "userName":"abc2", 101 | "password":"xyz2" 102 | } 103 | }, 104 | { 105 | "deviceType":["SWITCH"], 106 | "deviceStartIp":"100.68.13.0", 107 | "deviceEndIp":"100.68.13.255", 108 | "credential":{ 109 | "userName":"abc3", 110 | "password":"xyz3" 111 | } 112 | }, 113 | { 114 | "deviceType":["VM"], 115 | "deviceStartIp":"100.68.126.0", 116 | "deviceEndIp":"100.68.126.255", 117 | "credential":{ 118 | "userName":"abc4", 119 | "password":"xyz4" 120 | } 121 | }, 122 | { 123 | "deviceType":["STORAGE"], 124 | "deviceStartIp":"100.68.14.0", 125 | "deviceEndIp":"100.68.14.255", 126 | "credential":{ 127 | "userName":"abc5", 128 | "password":"xyz5" 129 | } 130 | } 131 | ] 132 | } 133 | 134 | /api/1.0/discover/ips: No support 135 | .... 136 | 137 | Example Payload 3. 138 | 139 | Use default device credentials (configured in application.yml). This option is for when you want to pull credentials from a supplied configuration at service startup, to prevent the consuming application from needing to be aware of them. 140 | 141 | .... 142 | 143 | /api/1.0/discover/range 144 | 145 | { 146 | "discoverIpRangeDeviceRequests": 147 | [ 148 | { 149 | "deviceType":["SERVER"], 150 | "deviceStartIp":"100.68.124.6", 151 | "deviceEndIp":"100.68.124.57", 152 | }, 153 | { 154 | "deviceType":["CHASSIS"], 155 | "deviceStartIp":"100.68.123.6", 156 | "deviceEndIp":"100.68.123.57", 157 | } 158 | ] 159 | } 160 | 161 | /api/1.0/discover/ips: 162 | 163 | { 164 | "ips": [ 165 | "100.68.124.37","100.68.124.43" 166 | ] 167 | } 168 | 169 | OR 170 | 171 | { 172 | "deviceType":["SERVER","CHASSIS"], 173 | "ips": [ 174 | "100.68.124.37","100.68.124.43" 175 | ] 176 | } 177 | .... 178 | 179 | Example Payload 4. 180 | 181 | The example payload below will attempt to discover servers and chassis in the ip range 100.68.124.11 - 57, using the global credentials "root" and "calvin". It will also attempt to discover switches in the ip range of 100.68.124.6 - 10, using the range specific credentials "abc0" and "xyz0" 182 | 183 | .... 184 | 185 | /api/1.0/discover/range 186 | { 187 | "credential":{ 188 | "userName": "root", 189 | "password": "calvin" 190 | }, 191 | "deviceType": ["SERVER", "CHASSIS"], 192 | "discoverIpRangeDeviceRequests":[ 193 | { 194 | "deviceStartIp": "100.68.124.6", 195 | "deviceEndIp": "100.68.124.10", 196 | "credential":{ 197 | "userName": "abc0", 198 | "password": "xyz0" 199 | }, 200 | "deviceType": ["SWITCH"], 201 | }, 202 | { 203 | "deviceStartIp": "100.68.124.11", 204 | "deviceEndIp": "100.68.124.57" 205 | } 206 | ] 207 | } 208 | 209 | /api/1.0/discover/ips: No support 210 | .... 211 | -------------------------------------------------------------------------------- /src/main/resources/config-readme.md: -------------------------------------------------------------------------------- 1 | ## Device discovery - Configuration 2 | 3 | ### Purpose 4 | Given an IP Range and credentials, the discovery service attempts to connect to each IP address to try and identify and retrieve basic summary information for all devices within the range. 5 | The discovery process uses pre-defined configuration rules for discovery. By default not all NOT all dell devices are enabled for discovery. The configurations can be changed dynamically or manually based on user preference. 6 | 7 | This configuration UI would enable user to change the configuration dynamically. 8 | 9 | ### Device Group. 10 | Current version of discovery service would support below group of Dell devices. 11 | SERVER: Supports both device discovery and device summary. 12 | CHASSIS: Supports both device discovery and device summary. 13 | SWITCH: Supports both device discovery and device summary NOT supported in the current version. 14 | STORAGE: Supports both device discovery and device summary for Compellent storage. Summary is NOT supported for EQUALLOGIC in our current version 15 | VM: Supports both device discovery and device summary. 16 | IOM: Supports both device discovery and device summary NOT supported in the current version. 17 | 18 | Adding new group and deleting groups are not allowed in the current version. But devices types can be enabled and disabled for discovery. 19 | 20 | ### Discovery Rules. 21 | 22 | Discovery Rules are the core configuration used for device discovery. Core rules configuration such has command, protocol and rule pattern identifiers for each device type. These key configurations are allowed to be edited 23 | or deleted. Addition of new rules needs some code changes as well. Configuration UI allows user to view these rules. 24 | 25 | Customization to the rule pattern identifiers should be done manually. 26 | 27 | ### Device Type. 28 | Current version of discovery service would support below group of Dell device types. 29 | 30 | SERVER: 31 | IDRAC6 : Supports both device discovery and device summary. 32 | IDRAC7 : Supports both device discovery and device summary. 33 | IDRAC8 : Supports both device discovery and device summary. 34 | IDRAC9 : Supports both device discovery and device summary. 35 | CHASSIS: 36 | CMC : Supports both device discovery and device summary. 37 | CMC_FX2 : Supports both device discovery and device summary. 38 | CSERVER : Supports both device discovery and device summary. 39 | VRTX : Supports both device discovery and device summary. 40 | SWITCH: 41 | FORCE10_S4810 : Supports both device discovery and device summary NOT supported in the current version. 42 | FORCE10_S5000 : Supports both device discovery and device summary NOT supported in the current version. 43 | FORCE10_S6000 : Supports both device discovery and device summary NOT supported in the current version. 44 | FORCE10_S4048 : Supports both device discovery and device summary NOT supported in the current version. 45 | FORCE10_S55 : Supports both device discovery and device summary NOT supported in the current version. 46 | BROCADE : Supports both device discovery and device summary NOT supported in the current version. 47 | POWERCONNECT : Supports both device discovery and device summary NOT supported in the current version. 48 | POWERCONNECT_N3000 : Supports both device discovery and device summary NOT supported in the current version. 49 | POWERCONNECT_N4000 : Supports both device discovery and device summary NOT supported in the current version. 50 | CISCONEXUS : Supports both device discovery and device summary NOT supported in the current version. 51 | STORAGE: 52 | COMPELLENT : Supports both device discovery and device summary. 53 | EM_COMPELLENT : Supports both device discovery and device summary. 54 | EQUALLOGIC : Supports both device discovery and device summary NOT supported in the current version. 55 | IOM: 56 | FX2_IOM : Supports both device discovery and device summary NOT supported in the current version. 57 | FORCE10IOM : Supports both device discovery and device summary NOT supported in the current version. 58 | DELL_IOM_84 : Supports both device discovery and device summary NOT supported in the current version. 59 | VM: 60 | VCENTER : Supports both device discovery and device summary. 61 | 62 | By default NOT all the device types are enabled for the discovery. ONLY all device types under SERVER and CHASSIS are enabled by default. User can use the configuration UI to enable and disable the device type of their preferences. 63 | The changes would be applied dynamically. 64 | 65 | ### Default Credential. 66 | Each device type would have a pre-configurtion of the credential. These are factory default for the respective device type. Based on the user preference these credentials can be dynamically changed 67 | using the Configuration UI. Service also provides the flexiability of overriding the credential during discovery request as well. 68 | 69 | Please refer the README.md for more information the supported request types for credential overriding. 70 | 71 | ### Sample Discovery Configuration. 72 | Discovery configuration can be found in application.yml. Sample configuration is shown below for the reference. 73 | ~~~ 74 | discoveryConfig: 75 | deviceGroup: 76 | - 77 | discoveryRule: 78 | - 79 | protocol: "HTTPS" 80 | command: "https://%s/discover" 81 | deviceType: 82 | - 83 | name: "IDRAC6" 84 | identifyBy: "REGULAR" 85 | identifier: 86 | - 87 | text: iDRAC6 88 | deviceDefaultCredential: 89 | username: "root" 90 | password: "*****" 91 | enabled: true 92 | - 93 | name: "IDRAC7" 94 | identifyBy: "REGULAR" 95 | identifier: 96 | - 97 | text: "iDRAC7" 98 | deviceDefaultCredential: 99 | username: "root" 100 | password: "*****" 101 | enabled: true 102 | groupName: "SERVER" 103 | - 104 | discoveryRule: 105 | - 106 | protocol: "SSH" 107 | command: "show\n" 108 | deviceType: 109 | - 110 | name: "FORCE10_S4810" 111 | identifyBy: "REGEX" 112 | identifier: 113 | - 114 | text: "(Dell Force10|Dell Real Time Operating System Software)" 115 | - 116 | text: "S4810|S4820" 117 | deviceDefaultCredential: 118 | username: "admin" 119 | password: "*****" 120 | enabled: true 121 | groupName: "SWITCH" 122 | -------------------------------------------------------------------------------- /src/main/resources/request_builder.md: -------------------------------------------------------------------------------- 1 | ### smi-service-device-discovery 2 | 3 | ### Purpose 4 | 5 | Given an IP Range and credentials, the service attemps to connect to each IP address to try and identify and retrieve basic summary information for all devices within the range. It is written primarily for finding Dell devices, but may identify a few others in the datacenter as well. It is a stateless (12 factor app) that returns a JSON summary response. 6 | 7 | This microservice can be used by itself, or as one piece of a larger discovery and inventory effort. This service is used by RackHD as part of a Dell WSMAN discovery and inventory workflow (taskgraph). It is one of several Docker containerized micro-services used as part of the workflow. 8 | 9 | 10 | ### How to Use 11 | 12 | Under Construction. Docker container not yet published on DockerHub..... 13 | 14 | #### Startup 15 | Standalone, with no configuration settings provided: 16 | ``` 17 | docker run --name device-discovery -p 0.0.0.0:46002:46002 -d rackhd/device-discovery:latest 18 | ``` 19 | 20 | The service can also start up to bootstrap its configuration from consul. More information about registration with and using advanced configuration settings provided by a Consul K/V store can be found in the online help. 21 | 22 | 23 | #### API Definitions 24 | 25 | A swagger UI is provided by the microservice at http://:46002/swagger-ui.html 26 | 27 | #### Synchronous CURL example with one network range payload ### 28 | The micro-service REST endpoints can be invoked via CURL or via another application. 29 | 30 | Example: 31 | ``` 32 | curl -X POST -H 'Content-Type: application/json' -d '{"credential":{"user": "root","password": "calvin"},"discoverIpRangeDeviceRequests":[{"deviceType": null,"deviceStartIp": "100.68.123.1","deviceEndIp": "100.68.123.254","credential": null}]}' http://:46002/api/1.0/discover/range 33 | ``` 34 | 35 | #### Example payloads 36 | The payload allows for global and local (per range) credentials and device types. Global values are always overwritten by local values. 37 | 38 | 39 | ###### Example Payload 1. 40 | Use global credentials (override all credentials in application yml for all devices) 41 | ~~~ 42 | /api/1.0/discover/range 43 | 44 | { 45 | "credential":{ 46 | "user":"root", 47 | "password":"calvin" 48 | }, 49 | "discoverIpRangeDeviceRequests":[ 50 | { 51 | "deviceStartIp":"100.68.124.6", 52 | "deviceEndIp":"100.68.124.57", 53 | } 54 | ] 55 | } 56 | 57 | /api/1.0/discover/ips: 58 | 59 | { 60 | "credential": { 61 | "password": "calvin1", 62 | "userName": "root1" 63 | }, 64 | "ips": [ 65 | "100.68.124.37","100.68.124.43" 66 | ] 67 | } 68 | ~~~ 69 | 70 | ###### Example Payload 2. 71 | Use Credential specific to device type (Override credential from application YML specific to devices). If global credentials are supplied (as in example 1 above), the specific device credentials will be used instead for that device type. 72 | ~~~ 73 | /api/1.0/discover/range 74 | 75 | { 76 | "discoverIpRangeDeviceRequests":[ 77 | { 78 | "deviceType":["SERVER"], 79 | "deviceStartIp":"100.68.124.0", 80 | "deviceEndIp":"100.68.124.255", 81 | "credential":{ 82 | "userName":"abc0", 83 | "password":"xyz0" 84 | } 85 | }, 86 | { 87 | "deviceType":["CHASSIS"], 88 | "deviceStartIp":"100.68.12.0", 89 | "deviceEndIp":"100.68.12.255", 90 | "credential":{ 91 | "userName":"abc1", 92 | "password":"xyz1" 93 | } 94 | }, 95 | { 96 | "deviceType":["IOM"], 97 | "deviceStartIp":"100.68.123.0", 98 | "deviceEndIp":"100.68.123.255", 99 | "credential":{ 100 | "userName":"abc2", 101 | "password":"xyz2" 102 | } 103 | }, 104 | { 105 | "deviceType":["SWITCH"], 106 | "deviceStartIp":"100.68.13.0", 107 | "deviceEndIp":"100.68.13.255", 108 | "credential":{ 109 | "userName":"abc3", 110 | "password":"xyz3" 111 | } 112 | }, 113 | { 114 | "deviceType":["VM"], 115 | "deviceStartIp":"100.68.126.0", 116 | "deviceEndIp":"100.68.126.255", 117 | "credential":{ 118 | "userName":"abc4", 119 | "password":"xyz4" 120 | } 121 | }, 122 | { 123 | "deviceType":["STORAGE"], 124 | "deviceStartIp":"100.68.14.0", 125 | "deviceEndIp":"100.68.14.255", 126 | "credential":{ 127 | "userName":"abc5", 128 | "password":"xyz5" 129 | } 130 | } 131 | ] 132 | } 133 | 134 | /api/1.0/discover/ips: No support 135 | ~~~ 136 | 137 | ###### Example Payload 3. 138 | Use default device credentials (configured in application.yml). This option is for when you want to pull credentials from a supplied configuration at service startup, to prevent the consuming application from needing to be aware of them. 139 | 140 | ``` 141 | 142 | /api/1.0/discover/range 143 | 144 | { 145 | "discoverIpRangeDeviceRequests": 146 | [ 147 | { 148 | "deviceType":["SERVER"], 149 | "deviceStartIp":"100.68.124.6", 150 | "deviceEndIp":"100.68.124.57", 151 | }, 152 | { 153 | "deviceType":["CHASSIS"], 154 | "deviceStartIp":"100.68.123.6", 155 | "deviceEndIp":"100.68.123.57", 156 | } 157 | ] 158 | } 159 | 160 | /api/1.0/discover/ips: 161 | 162 | { 163 | "ips": [ 164 | "100.68.124.37","100.68.124.43" 165 | ] 166 | } 167 | 168 | OR 169 | 170 | { 171 | "deviceType":["SERVER","CHASSIS"], 172 | "ips": [ 173 | "100.68.124.37","100.68.124.43" 174 | ] 175 | } 176 | 177 | ``` 178 | 179 | ##### Example Payload 4. 180 | The example payload below will attempt to discover servers and chassis in the ip range 100.68.124.11 - 57, using the global credentials "root" and "calvin". It will also attempt to discover switches in the ip range of 100.68.124.6 - 10, using the range specific credentials "abc0" and "xyz0" 181 | 182 | ~~~ 183 | 184 | /api/1.0/discover/range 185 | { 186 | "credential":{ 187 | "user": "root", 188 | "password": "calvin" 189 | }, 190 | "deviceType": ["SERVER", "CHASSIS"], 191 | "discoverIpRangeDeviceRequests":[ 192 | { 193 | "deviceStartIp": "100.68.124.6", 194 | "deviceEndIp": "100.68.124.10", 195 | "credential":{ 196 | "userName": "abc0", 197 | "password": "xyz0" 198 | }, 199 | "deviceType": ["SWITCH"], 200 | }, 201 | { 202 | "deviceStartIp": "100.68.124.11", 203 | "deviceEndIp": "100.68.124.57" 204 | } 205 | ] 206 | } 207 | 208 | /api/1.0/discover/ips: No support 209 | ~~~ 210 | - ##### _supported devices group are {SERVER,CHASSIS and STORAGE (Complellent) - Discovery and brief summary;} 211 | - VM and SWITCH (Only discovery but NO Summary) 212 | Supported device types: 213 | 214 | ~~~ 215 | SERVER: 216 | IDRAC7, 217 | IDRAC8, 218 | 219 | CHASSIS: 220 | CMC, 221 | CMC_FX2, 222 | CSERVER, 223 | VRTX 224 | 225 | SWITCH: 226 | FORCE10_S4810, 227 | FORCE10_S5000, 228 | FORCE10_S6000, 229 | FORCE10_S4048, 230 | FORCE10_S55 231 | BROCADE, 232 | POWERCONNECT, 233 | POWERCONNECT_N3000, 234 | POWERCONNECT_N4000, 235 | CISCONEXUS 236 | 237 | STORAGE: 238 | COMPELLENT, 239 | 240 | VM: 241 | VCENTER 242 | ~~~ 243 | --- 244 | 245 | ### Support 246 | Slack Channel: codecommunity.slack.com 247 | -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/config/ConfigurationUI.java: -------------------------------------------------------------------------------- 1 | package com.dell.isg.smi.service.device.discovery.ui.config; 2 | 3 | import java.io.File; 4 | import java.io.FileOutputStream; 5 | import java.io.IOException; 6 | import java.io.OutputStream; 7 | import java.util.List; 8 | 9 | import org.apache.commons.io.FilenameUtils; 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.vaadin.viritin.button.ConfirmButton; 14 | import org.vaadin.viritin.components.DisclosurePanel; 15 | import org.vaadin.viritin.label.RichText; 16 | 17 | import com.dell.isg.smi.service.device.discovery.config.DiscoveryDeviceConfig; 18 | import com.fasterxml.jackson.databind.DeserializationFeature; 19 | import com.fasterxml.jackson.databind.ObjectMapper; 20 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; 21 | import com.google.common.io.Files; 22 | import com.vaadin.annotations.Theme; 23 | import com.vaadin.annotations.Title; 24 | import com.vaadin.icons.VaadinIcons; 25 | import com.vaadin.server.VaadinRequest; 26 | import com.vaadin.shared.ui.ValueChangeMode; 27 | import com.vaadin.spring.annotation.SpringUI; 28 | import com.vaadin.ui.Button; 29 | import com.vaadin.ui.CssLayout; 30 | import com.vaadin.ui.Grid; 31 | import com.vaadin.ui.HorizontalLayout; 32 | import com.vaadin.ui.Label; 33 | import com.vaadin.ui.Notification; 34 | import com.vaadin.ui.TextField; 35 | import com.vaadin.ui.UI; 36 | import com.vaadin.ui.Upload; 37 | import com.vaadin.ui.Upload.Receiver; 38 | import com.vaadin.ui.Upload.SucceededEvent; 39 | import com.vaadin.ui.Upload.SucceededListener; 40 | import com.vaadin.ui.VerticalLayout; 41 | import com.vaadin.ui.themes.ValoTheme; 42 | 43 | /** 44 | * This UI is the application entry point. A UI may either represent a browser 45 | * window (or tab) or some part of a html page where a Vaadin application is 46 | * embedded. 47 | *

48 | * The UI is initialized using {@link #init(VaadinRequest)}. This method is 49 | * intended to be overridden to add component to the user interface and 50 | * initialize non-component functionality. 51 | */ 52 | @SuppressWarnings("deprecation") 53 | @Title("Discovery Configuration UI") 54 | @Theme("valo") 55 | @SpringUI(path = "/config-ui") 56 | public class ConfigurationUI extends UI { 57 | 58 | /** 59 | * 60 | */ 61 | private static final long serialVersionUID = 1L; 62 | @Autowired 63 | public ConfigDeviceTypeHandler configHandler; 64 | private Grid grid = new Grid<>(ConfigDeviceType.class); 65 | private TextField filterGroup = new TextField(); 66 | private ConfigDeviceTypeForm configDeviceTypeForm = new ConfigDeviceTypeForm(this); 67 | private Button resetBtn = new ConfirmButton(VaadinIcons.FLIP_V, 68 | "Are you sure you want to reset to default configuration?", this::reset); 69 | 70 | private static final Logger logger = LoggerFactory.getLogger(ConfigurationUI.class.getName()); 71 | 72 | @Override 73 | protected void init(VaadinRequest vaadinRequest) { 74 | final VerticalLayout layout = new VerticalLayout(); 75 | 76 | HorizontalLayout titleBar = new HorizontalLayout(); 77 | titleBar.setWidth("100%"); 78 | 79 | Label title = new Label("CONFIGURATION UI: "); 80 | title.addStyleName(ValoTheme.LABEL_HUGE); 81 | titleBar.addComponent(title); 82 | Label titleComment = new Label("for Discovery"); 83 | titleComment.addStyleName(ValoTheme.LABEL_LIGHT); 84 | titleComment.setSizeUndefined(); 85 | titleBar.addComponent(titleComment); 86 | titleBar.setExpandRatio(title, 1.0f); 87 | 88 | filterGroup.setPlaceholder("Filter by Group..."); 89 | filterGroup.addValueChangeListener(e -> updateList()); 90 | filterGroup.setValueChangeMode(ValueChangeMode.LAZY); 91 | 92 | Button clearFilterTextBtn = new Button(VaadinIcons.CLOSE_SMALL); 93 | clearFilterTextBtn.setDescription("Clear the current filter"); 94 | clearFilterTextBtn.addClickListener(e -> filterGroup.clear()); 95 | 96 | CssLayout filtering = new CssLayout(); 97 | filtering.addComponents(filterGroup, clearFilterTextBtn); 98 | filtering.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP); 99 | 100 | resetBtn.setCaption("Reset back to orginal configuration."); 101 | 102 | DisclosurePanel aboutConfig = new DisclosurePanel("About Discovery Configuration", 103 | new RichText().withMarkDownResource("/config-readme.md")); 104 | HorizontalLayout toolbar = new HorizontalLayout(aboutConfig, filtering, resetBtn); 105 | grid.setColumns("group", "name", "enabled"); 106 | 107 | HorizontalLayout main = new HorizontalLayout(grid, configDeviceTypeForm); 108 | main.setSizeFull(); 109 | grid.setSizeFull(); 110 | grid.setHeight("450"); 111 | main.setExpandRatio(grid, 1); 112 | 113 | final ConfigUploader receiver = new ConfigUploader(); 114 | Upload upload = new Upload("Upload Configuration", receiver); 115 | upload.setImmediateMode(false); 116 | upload.addSucceededListener(receiver); 117 | upload.setButtonCaption("Upload Now"); 118 | 119 | HorizontalLayout uploader = new HorizontalLayout(upload); 120 | uploader.setSizeFull(); 121 | layout.addComponents(titleBar , toolbar, main, uploader); 122 | updateList(); 123 | setContent(layout); 124 | configDeviceTypeForm.setVisible(false); 125 | grid.asSingleSelect().addValueChangeListener(event -> { 126 | if (event.getValue() == null) { 127 | configDeviceTypeForm.setVisible(false); 128 | } else { 129 | configDeviceTypeForm.setConfigDeviceType(event.getValue()); 130 | } 131 | }); 132 | } 133 | 134 | public void updateList() { 135 | List configDeviceTypeList = configHandler.findByNameLikeIgnoreCase(filterGroup.getValue()); 136 | grid.setItems(configDeviceTypeList); 137 | } 138 | 139 | public void reset(){ 140 | grid.asSingleSelect().clear(); 141 | configHandler.reset(); 142 | updateList(); 143 | Notification.show("Reset to deafult :", 144 | "Default YML Configuration applied successfully !!!. ", 145 | Notification.Type.HUMANIZED_MESSAGE); 146 | } 147 | 148 | class ConfigUploader implements Receiver, SucceededListener { 149 | private static final long serialVersionUID = -1276759102490466761L; 150 | public File file; 151 | public OutputStream receiveUpload(String filename, String mimeType) { 152 | FileOutputStream fileOutputStream = null; 153 | try { 154 | if (!FilenameUtils.isExtension(filename,"yml")) { 155 | throw new IOException("Invalid file extention."); 156 | } 157 | File tempDir = Files.createTempDir(); 158 | file = new File(tempDir+File.separator+filename); 159 | fileOutputStream = new FileOutputStream(file); 160 | } catch (Exception e) { 161 | logger.error("Unable to upload the YML file."); 162 | Notification.show("Error :", 163 | "Invalid file !!!. Please upload valid YML configuration file !!!. ", 164 | Notification.Type.ERROR_MESSAGE); 165 | } 166 | return fileOutputStream; 167 | } 168 | 169 | public void uploadSucceeded(SucceededEvent event) { 170 | try { 171 | updateConfig(); 172 | Notification.show("Configuration Upload :", 173 | "YML Configuration applied successfully !!!. ", 174 | Notification.Type.HUMANIZED_MESSAGE); 175 | } catch (Exception e) { 176 | logger.error("Unable to parse the YML file."); 177 | Notification.show("Error :", 178 | "Parsing error !!!. Unable to parse the YML configuration file !!!. ", 179 | Notification.Type.ERROR_MESSAGE); 180 | } 181 | 182 | 183 | } 184 | 185 | public synchronized void updateConfig() throws Exception{ 186 | try { 187 | ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); 188 | mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 189 | DiscoveryDeviceConfig discoveryConfig = mapper.readValue(file, DiscoveryDeviceConfig.class); 190 | configHandler.loadFrom(discoveryConfig); 191 | updateList(); 192 | } catch (Exception e) { 193 | throw e; 194 | } 195 | } 196 | }; 197 | 198 | } 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### smi-service-device-discovery 2 | 3 | Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved. 4 | 5 | ### Purpose 6 | 7 | Given an IP Range and credentials, the service attemps to connect to each IP address to try and identify and retrieve basic summary information for all devices within the range. It is written primarily for finding Dell devices, but may identify a few others in the datacenter as well. It is a stateless (12 factor app) that returns a JSON summary response. 8 | 9 | This microservice can be used by itself, or as one piece of a larger discovery and inventory effort. This service is used by RackHD as part of a Dell WSMAN discovery and inventory workflow (taskgraph). It is one of several Docker containerized micro-services used as part of the workflow. 10 | 11 | 12 | ### How to Use 13 | 14 | A docker container for this service is available at: https://hub.docker.com/r/rackhd/device-discovery/ 15 | 16 | #### Startup 17 | Standalone, with no configuration settings provided: 18 | ``` 19 | docker run --name device-discovery -p 0.0.0.0:46002:46002 -d rackhd/device-discovery:latest 20 | ``` 21 | 22 | The service can also start up to bootstrap its configuration from consul. More information about registration with and using advanced configuration settings provided by a Consul K/V store can be found in the online help. 23 | 24 | 25 | #### API Definitions 26 | 27 | A swagger UI is provided by the microservice at http://:46002/swagger-ui.html 28 | 29 | #### Synchronous CURL example with one network range payload ### 30 | The micro-service REST endpoints can be invoked via CURL or via another application. 31 | 32 | Example: 33 | ``` 34 | curl -X POST -H 'Content-Type: application/json' -d '{"credential":{"user": "root","password": "calvin"},"discoverIpRangeDeviceRequests":[{"deviceType": null,"deviceStartIp": "100.68.123.1","deviceEndIp": "100.68.123.254","credential": null}]}' http://:46002/api/1.0/discover/range 35 | ``` 36 | 37 | #### Example payloads 38 | The payload allows for global and local (per range) credentials and device types. Global values are always overwritten by local values. 39 | 40 | 41 | ###### Example Payload 1. 42 | Use global credentials (override all credentials in application yml for all devices) 43 | ~~~ 44 | /api/1.0/discover/range 45 | 46 | { 47 | "credential":{ 48 | "user":"root", 49 | "password":"calvin" 50 | }, 51 | "discoverIpRangeDeviceRequests":[ 52 | { 53 | "deviceStartIp":"100.68.124.6", 54 | "deviceEndIp":"100.68.124.57", 55 | } 56 | ] 57 | } 58 | 59 | /api/1.0/discover/ips: 60 | 61 | { 62 | "credential": { 63 | "password": "calvin1", 64 | "userName": "root1" 65 | }, 66 | "ips": [ 67 | "100.68.124.37","100.68.124.43" 68 | ] 69 | } 70 | ~~~ 71 | 72 | ###### Example Payload 2. 73 | Use Credential specific to device type (Override credential from application YML specific to devices). If global credentials are supplied (as in example 1 above), the specific device credentials will be used instead for that device type. 74 | ~~~ 75 | /api/1.0/discover/range 76 | 77 | { 78 | "discoverIpRangeDeviceRequests":[ 79 | { 80 | "deviceType":["SERVER"], 81 | "deviceStartIp":"100.68.124.0", 82 | "deviceEndIp":"100.68.124.255", 83 | "credential":{ 84 | "userName":"abc0", 85 | "password":"xyz0" 86 | } 87 | }, 88 | { 89 | "deviceType":["CHASSIS"], 90 | "deviceStartIp":"100.68.12.0", 91 | "deviceEndIp":"100.68.12.255", 92 | "credential":{ 93 | "userName":"abc1", 94 | "password":"xyz1" 95 | } 96 | }, 97 | { 98 | "deviceType":["IOM"], 99 | "deviceStartIp":"100.68.123.0", 100 | "deviceEndIp":"100.68.123.255", 101 | "credential":{ 102 | "userName":"abc2", 103 | "password":"xyz2" 104 | } 105 | }, 106 | { 107 | "deviceType":["SWITCH"], 108 | "deviceStartIp":"100.68.13.0", 109 | "deviceEndIp":"100.68.13.255", 110 | "credential":{ 111 | "userName":"abc3", 112 | "password":"xyz3" 113 | } 114 | }, 115 | { 116 | "deviceType":["VM"], 117 | "deviceStartIp":"100.68.126.0", 118 | "deviceEndIp":"100.68.126.255", 119 | "credential":{ 120 | "userName":"abc4", 121 | "password":"xyz4" 122 | } 123 | }, 124 | { 125 | "deviceType":["STORAGE"], 126 | "deviceStartIp":"100.68.14.0", 127 | "deviceEndIp":"100.68.14.255", 128 | "credential":{ 129 | "userName":"abc5", 130 | "password":"xyz5" 131 | } 132 | } 133 | ] 134 | } 135 | 136 | /api/1.0/discover/ips: No support 137 | ~~~ 138 | 139 | ###### Example Payload 3. 140 | Use default device credentials (configured in application.yml). This option is for when you want to pull credentials from a supplied configuration at service startup, to prevent the consuming application from needing to be aware of them. 141 | 142 | ``` 143 | 144 | /api/1.0/discover/range 145 | 146 | { 147 | "discoverIpRangeDeviceRequests": 148 | [ 149 | { 150 | "deviceType":["SERVER"], 151 | "deviceStartIp":"100.68.124.6", 152 | "deviceEndIp":"100.68.124.57", 153 | }, 154 | { 155 | "deviceType":["CHASSIS"], 156 | "deviceStartIp":"100.68.123.6", 157 | "deviceEndIp":"100.68.123.57", 158 | } 159 | ] 160 | } 161 | 162 | /api/1.0/discover/ips: 163 | 164 | { 165 | "ips": [ 166 | "100.68.124.37","100.68.124.43" 167 | ] 168 | } 169 | 170 | OR 171 | 172 | { 173 | "deviceType":["SERVER","CHASSIS"], 174 | "ips": [ 175 | "100.68.124.37","100.68.124.43" 176 | ] 177 | } 178 | 179 | ``` 180 | 181 | ##### Example Payload 4. 182 | The example payload below will attempt to discover servers and chassis in the ip range 100.68.124.11 - 57, using the global credentials "root" and "calvin". It will also attempt to discover switches in the ip range of 100.68.124.6 - 10, using the range specific credentials "abc0" and "xyz0" 183 | 184 | ~~~ 185 | 186 | /api/1.0/discover/range 187 | { 188 | "credential":{ 189 | "user": "root", 190 | "password": "calvin" 191 | }, 192 | "deviceType": ["SERVER", "CHASSIS"], 193 | "discoverIpRangeDeviceRequests":[ 194 | { 195 | "deviceStartIp": "100.68.124.6", 196 | "deviceEndIp": "100.68.124.10", 197 | "credential":{ 198 | "userName": "abc0", 199 | "password": "xyz0" 200 | }, 201 | "deviceType": ["SWITCH"], 202 | }, 203 | { 204 | "deviceStartIp": "100.68.124.11", 205 | "deviceEndIp": "100.68.124.57" 206 | } 207 | ] 208 | } 209 | 210 | /api/1.0/discover/ips: No support 211 | ~~~ 212 | - ##### _supported devices group are {SERVER,CHASSIS and STORAGE (Complellent) - Discovery and brief summary;} 213 | - VM and SWITCH (Only discovery but NO Summary) 214 | Supported device types: 215 | 216 | ~~~ 217 | SERVER: 218 | IDRAC7, 219 | IDRAC8, 220 | 221 | CHASSIS: 222 | CMC, 223 | CMC_FX2, 224 | CSERVER, 225 | VRTX 226 | 227 | SWITCH: 228 | FORCE10_S4810, 229 | FORCE10_S5000, 230 | FORCE10_S6000, 231 | FORCE10_S4048, 232 | FORCE10_S55 233 | BROCADE, 234 | POWERCONNECT, 235 | POWERCONNECT_N3000, 236 | POWERCONNECT_N4000, 237 | CISCONEXUS 238 | 239 | STORAGE: 240 | COMPELLENT, 241 | 242 | VM: 243 | VCENTER 244 | ~~~ 245 | --- 246 | 247 | #### Licensing 248 | Licensed 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 249 | 250 | 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. 251 | 252 | Source code for this microservice is available in repositories at https://github.com/RackHD. 253 | 254 | The microservice makes use of dependent Jar libraries that may be covered by other licenses. In order to comply with the requirements of applicable licenses, the source for dependent libraries used by this microservice is available for download at: https://bintray.com/rackhd/binary/download_file?file_path=smi-service-device-discovery-dependency-sources-devel.zip 255 | 256 | Additionally the binary and source jars for all dependent libraries are available for download on Maven Central. 257 | 258 | RackHD is a Trademark of Dell EMC 259 | 260 | 261 | ### Support 262 | Slack Channel: codecommunity.slack.com 263 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /application.yml: -------------------------------------------------------------------------------- 1 | discoveryConfig: 2 | deviceGroup: 3 | - 4 | discoveryRule: 5 | - 6 | protocol: "HTTPS" 7 | command: "https://%s/cgi-bin/discover" 8 | deviceType: 9 | - 10 | name: "IDRAC6" 11 | identifyBy: "REGULAR" 12 | identifier: 13 | - 14 | text: "iDRAC6" 15 | deviceDefaultCredential: 16 | username: "root" 17 | password: "calvin" 18 | enabled: true 19 | - 20 | name: "IDRAC7" 21 | identifyBy: "REGULAR" 22 | identifier: 23 | - 24 | text: "iDRAC7" 25 | deviceDefaultCredential: 26 | username: "root" 27 | password: "calvin" 28 | enabled: true 29 | - 30 | name: "IDRAC8" 31 | identifyBy: "REGULAR" 32 | identifier: 33 | - 34 | text: "iDRAC8" 35 | deviceDefaultCredential: 36 | username: "root" 37 | password: "calvin" 38 | enabled: true 39 | - 40 | name: "IDRAC9" 41 | identifyBy: "REGULAR" 42 | identifier: 43 | - 44 | text: "iDRAC9" 45 | deviceDefaultCredential: 46 | username: "root" 47 | password: "calvin" 48 | enabled: true 49 | groupName: "SERVER" 50 | - 51 | discoveryRule: 52 | - 53 | protocol: "HTTPS" 54 | command: "https://%s/cgi-bin/discover" 55 | deviceType: 56 | - 57 | name: "CMC_FX2" 58 | identifyBy: "REGULAR" 59 | identifier: 60 | - 61 | text: "CMC" 62 | - 63 | text: "3.0" 64 | deviceDefaultCredential: 65 | username: "root" 66 | password: "calvin" 67 | enabled: true 68 | - 69 | name: "VRTX" 70 | identifyBy: "REGULAR" 71 | identifier: 72 | - 73 | text: "CMC" 74 | - 75 | text: "2.0" 76 | deviceDefaultCredential: 77 | username: "root" 78 | password: "calvin" 79 | enabled: true 80 | - 81 | name: "CMC" 82 | identifyBy: "REGULAR" 83 | identifier: 84 | - 85 | text: "CMC" 86 | deviceDefaultCredential: 87 | username: "root" 88 | password: "calvin" 89 | enabled: true 90 | - 91 | protocol: "HTTPS" 92 | command: "https://%s/login.html" 93 | deviceType: 94 | - 95 | name: "CSERVER" 96 | identifyBy: "REGULAR" 97 | identifier: 98 | - 99 | text: "Dell Remote Management Controller" 100 | deviceDefaultCredential: 101 | username: "root" 102 | password: "calvin" 103 | enabled: true 104 | groupName: "CHASSIS" 105 | - 106 | discoveryRule: 107 | - 108 | protocol: "HTTPS" 109 | command: "https://%s/en/welcomeRes.js" 110 | deviceType: 111 | - 112 | name: "VCENTER" 113 | identifyBy: "REGULAR" 114 | identifier: 115 | - 116 | text: "var ID_VMWVC2 = \"VMware vSphere\";" 117 | deviceDefaultCredential: 118 | username: "root" 119 | password: "vmware" 120 | enabled: false 121 | groupName: "VM" 122 | - 123 | discoveryRule: 124 | - 125 | protocol: "SSH" 126 | command: "show version\n" 127 | deviceType: 128 | - 129 | name: "FX2_IOM" 130 | identifyBy: "REGEX" 131 | identifier: 132 | - 133 | text: "(Dell Force10|Dell Real Time Operating System Software)" 134 | - 135 | text: "IOA" 136 | deviceDefaultCredential: 137 | username: "admin" 138 | password: "password" 139 | enabled: false 140 | - 141 | name: "FORCE10IOM" 142 | identifyBy: "REGEX" 143 | identifier: 144 | - 145 | text: "(Dell Force10|Dell Real Time Operating System Software)" 146 | - 147 | text: "(I/O-Aggregator|MXL)" 148 | deviceDefaultCredential: 149 | username: "admin" 150 | password: "password" 151 | enabled: false 152 | - 153 | protocol: "HTTPS" 154 | command: "http://%s/switchExplorer_installed.html" 155 | deviceType: 156 | - 157 | name: "DELL_IOM_84" 158 | identifyBy: "REGEX" 159 | identifier: 160 | - 161 | text: "M5424|_FC_IOM" 162 | deviceDefaultCredential: 163 | username: "admin" 164 | password: "password" 165 | enabled: false 166 | groupName: "IOM" 167 | - 168 | discoveryRule: 169 | - 170 | protocol: "SSH" 171 | command: "show version\n" 172 | deviceType: 173 | - 174 | name: "FORCE10_S4810" 175 | identifyBy: "REGEX" 176 | identifier: 177 | - 178 | text: "(Dell Force10|Dell Real Time Operating System Software)" 179 | - 180 | text: "S4810|S4820" 181 | deviceDefaultCredential: 182 | username: "admin" 183 | password: "password" 184 | enabled: false 185 | - 186 | name: "FORCE10_S5000" 187 | identifyBy: "REGEX" 188 | identifier: 189 | - 190 | text: "(Dell Force10|Dell Real Time Operating System Software)" 191 | - 192 | text: "S5000" 193 | deviceDefaultCredential: 194 | username: "admin" 195 | password: "password" 196 | enabled: false 197 | - 198 | name: "FORCE10_S6000" 199 | identifyBy: "REGEX" 200 | identifier: 201 | - 202 | text: "(Dell Force10|Dell Real Time Operating System Software)" 203 | - 204 | text: "S6000" 205 | deviceDefaultCredential: 206 | username: "admin" 207 | password: "password" 208 | enabled: false 209 | - 210 | name: "FORCE10_S4048" 211 | identifyBy: "REGEX" 212 | identifier: 213 | - 214 | text: "(Dell Force10|Dell Real Time Operating System Software)" 215 | - 216 | text: "S4048" 217 | deviceDefaultCredential: 218 | username: "admin" 219 | password: "password" 220 | enabled: false 221 | - 222 | name: "FORCE10_S55" 223 | identifyBy: "REGEX" 224 | identifier: 225 | - 226 | text: "(Dell Force10|Dell Real Time Operating System Software)" 227 | - 228 | text: "S55" 229 | deviceDefaultCredential: 230 | username: "admin" 231 | password: "password" 232 | enabled: false 233 | - 234 | name: "CISCONEXUS" 235 | identifyBy: "REGULAR" 236 | identifier: 237 | - 238 | text: "Cisco Nexus" 239 | deviceDefaultCredential: 240 | username: "admin" 241 | password: "password" 242 | enabled: false 243 | - 244 | protocol: "SSH" 245 | command: "show system\n" 246 | deviceType: 247 | - 248 | name: "POWERCONNECT_N4000" 249 | identifyBy: "REGEX" 250 | identifier: 251 | - 252 | text: "Dell Networking" 253 | - 254 | text: "N4032|N4064" 255 | deviceDefaultCredential: 256 | username: "admin" 257 | password: "password" 258 | enabled: false 259 | - 260 | name: "POWERCONNECT_N3000" 261 | identifyBy: "REGEX" 262 | identifier: 263 | - 264 | text: "Dell Networking" 265 | - 266 | text: "N3024|N3048" 267 | deviceDefaultCredential: 268 | username: "admin" 269 | password: "password" 270 | enabled: false 271 | - 272 | name: "POWERCONNECT" 273 | identifyBy: "REGEX" 274 | identifier: 275 | - 276 | text: "Dell Networking" 277 | - 278 | text: "PowerConnect" 279 | deviceDefaultCredential: 280 | username: "admin" 281 | password: "password" 282 | enabled: false 283 | - 284 | protocol: "HTTPS" 285 | command: "http://%s/switchExplorer_installed.html" 286 | deviceType: 287 | - 288 | name: "BROCADE" 289 | identifyBy: "REGULAR" 290 | identifier: 291 | - 292 | text: "com.brocade.web.switchview.SwitchExplorerApplet" 293 | deviceDefaultCredential: 294 | username: "admin" 295 | password: "password" 296 | enabled: false 297 | groupName: "SWITCH" 298 | - 299 | discoveryRule: 300 | - 301 | protocol: "HTTPS" 302 | command: "https://%s/SystemExplorer.asp" 303 | deviceType: 304 | - 305 | name: "COMPELLENT" 306 | identifyBy: "REGULAR" 307 | identifier: 308 | - 309 | text: "COMPELLENT" 310 | deviceDefaultCredential: 311 | username: "Admin" 312 | password: "password" 313 | enabled: false 314 | - 315 | protocol: "HTTPS" 316 | command: "https://%s:3033/em/EnterpriseManager" 317 | deviceType: 318 | - 319 | name: "EM_COMPELLENT" 320 | identifyBy: "REGULAR" 321 | identifier: 322 | - 323 | text: "Enterprise Manager" 324 | deviceDefaultCredential: 325 | username: "Administrator" 326 | password: "password" 327 | enabled: false 328 | - 329 | protocol: "HTTPS" 330 | command: "http://%s/groupmgr.html" 331 | deviceType: 332 | - 333 | name: "EQUALLOGIC" 334 | identifyBy: "REGULAR" 335 | identifier: 336 | - 337 | text: "" 338 | deviceDefaultCredential: 339 | username: "grpadmin" 340 | password: "password" 341 | enabled: false 342 | groupName: "STORAGE" -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | discoveryConfig: 2 | deviceGroup: 3 | - 4 | discoveryRule: 5 | - 6 | protocol: "HTTPS" 7 | command: "https://%s/cgi-bin/discover" 8 | deviceType: 9 | - 10 | name: "IDRAC6" 11 | identifyBy: "REGULAR" 12 | identifier: 13 | - 14 | text: "iDRAC6" 15 | deviceDefaultCredential: 16 | username: "root" 17 | password: "calvin" 18 | enabled: true 19 | - 20 | name: "IDRAC7" 21 | identifyBy: "REGULAR" 22 | identifier: 23 | - 24 | text: "iDRAC7" 25 | deviceDefaultCredential: 26 | username: "root" 27 | password: "calvin" 28 | enabled: true 29 | - 30 | name: "IDRAC8" 31 | identifyBy: "REGULAR" 32 | identifier: 33 | - 34 | text: "iDRAC8" 35 | deviceDefaultCredential: 36 | username: "root" 37 | password: "calvin" 38 | enabled: true 39 | - 40 | name: "IDRAC9" 41 | identifyBy: "REGULAR" 42 | identifier: 43 | - 44 | text: "iDRAC9" 45 | deviceDefaultCredential: 46 | username: "root" 47 | password: "calvin" 48 | enabled: true 49 | groupName: "SERVER" 50 | - 51 | discoveryRule: 52 | - 53 | protocol: "HTTPS" 54 | command: "https://%s/cgi-bin/discover" 55 | deviceType: 56 | - 57 | name: "CMC_FX2" 58 | identifyBy: "REGULAR" 59 | identifier: 60 | - 61 | text: "CMC" 62 | - 63 | text: "3.0" 64 | deviceDefaultCredential: 65 | username: "root" 66 | password: "calvin" 67 | enabled: true 68 | - 69 | name: "VRTX" 70 | identifyBy: "REGULAR" 71 | identifier: 72 | - 73 | text: "CMC" 74 | - 75 | text: "2.0" 76 | deviceDefaultCredential: 77 | username: "root" 78 | password: "calvin" 79 | enabled: true 80 | - 81 | name: "CMC" 82 | identifyBy: "REGULAR" 83 | identifier: 84 | - 85 | text: "CMC" 86 | deviceDefaultCredential: 87 | username: "root" 88 | password: "calvin" 89 | enabled: true 90 | - 91 | protocol: "HTTPS" 92 | command: "https://%s/login.html" 93 | deviceType: 94 | - 95 | name: "CSERVER" 96 | identifyBy: "REGULAR" 97 | identifier: 98 | - 99 | text: "Dell Remote Management Controller" 100 | deviceDefaultCredential: 101 | username: "root" 102 | password: "calvin" 103 | enabled: true 104 | groupName: "CHASSIS" 105 | - 106 | discoveryRule: 107 | - 108 | protocol: "HTTPS" 109 | command: "https://%s/en/welcomeRes.js" 110 | deviceType: 111 | - 112 | name: "VCENTER" 113 | identifyBy: "REGULAR" 114 | identifier: 115 | - 116 | text: "var ID_VMWVC2 = \"VMware vSphere\";" 117 | deviceDefaultCredential: 118 | username: "root" 119 | password: "vmware" 120 | enabled: false 121 | groupName: "VM" 122 | - 123 | discoveryRule: 124 | - 125 | protocol: "SSH" 126 | command: "show version\n" 127 | deviceType: 128 | - 129 | name: "FX2_IOM" 130 | identifyBy: "REGEX" 131 | identifier: 132 | - 133 | text: "(Dell Force10|Dell Real Time Operating System Software)" 134 | - 135 | text: "IOA" 136 | deviceDefaultCredential: 137 | username: "admin" 138 | password: "password" 139 | enabled: false 140 | - 141 | name: "FORCE10IOM" 142 | identifyBy: "REGEX" 143 | identifier: 144 | - 145 | text: "(Dell Force10|Dell Real Time Operating System Software)" 146 | - 147 | text: "(I/O-Aggregator|MXL)" 148 | deviceDefaultCredential: 149 | username: "admin" 150 | password: "password" 151 | enabled: false 152 | - 153 | protocol: "HTTPS" 154 | command: "http://%s/switchExplorer_installed.html" 155 | deviceType: 156 | - 157 | name: "DELL_IOM_84" 158 | identifyBy: "REGEX" 159 | identifier: 160 | - 161 | text: "M5424|_FC_IOM" 162 | deviceDefaultCredential: 163 | username: "admin" 164 | password: "password" 165 | enabled: false 166 | groupName: "IOM" 167 | - 168 | discoveryRule: 169 | - 170 | protocol: "SSH" 171 | command: "show version\n" 172 | deviceType: 173 | - 174 | name: "FORCE10_S4810" 175 | identifyBy: "REGEX" 176 | identifier: 177 | - 178 | text: "(Dell Force10|Dell Real Time Operating System Software)" 179 | - 180 | text: "S4810|S4820" 181 | deviceDefaultCredential: 182 | username: "admin" 183 | password: "password" 184 | enabled: false 185 | - 186 | name: "FORCE10_S5000" 187 | identifyBy: "REGEX" 188 | identifier: 189 | - 190 | text: "(Dell Force10|Dell Real Time Operating System Software)" 191 | - 192 | text: "S5000" 193 | deviceDefaultCredential: 194 | username: "admin" 195 | password: "password" 196 | enabled: false 197 | - 198 | name: "FORCE10_S6000" 199 | identifyBy: "REGEX" 200 | identifier: 201 | - 202 | text: "(Dell Force10|Dell Real Time Operating System Software)" 203 | - 204 | text: "S6000" 205 | deviceDefaultCredential: 206 | username: "admin" 207 | password: "password" 208 | enabled: false 209 | - 210 | name: "FORCE10_S4048" 211 | identifyBy: "REGEX" 212 | identifier: 213 | - 214 | text: "(Dell Force10|Dell Real Time Operating System Software)" 215 | - 216 | text: "S4048" 217 | deviceDefaultCredential: 218 | username: "admin" 219 | password: "password" 220 | enabled: false 221 | - 222 | name: "FORCE10_S55" 223 | identifyBy: "REGEX" 224 | identifier: 225 | - 226 | text: "(Dell Force10|Dell Real Time Operating System Software)" 227 | - 228 | text: "S55" 229 | deviceDefaultCredential: 230 | username: "admin" 231 | password: "password" 232 | enabled: false 233 | - 234 | name: "CISCONEXUS" 235 | identifyBy: "REGULAR" 236 | identifier: 237 | - 238 | text: "Cisco Nexus" 239 | deviceDefaultCredential: 240 | username: "admin" 241 | password: "password" 242 | enabled: false 243 | - 244 | protocol: "SSH" 245 | command: "show system\n" 246 | deviceType: 247 | - 248 | name: "POWERCONNECT_N4000" 249 | identifyBy: "REGEX" 250 | identifier: 251 | - 252 | text: "Dell Networking" 253 | - 254 | text: "N4032|N4064" 255 | deviceDefaultCredential: 256 | username: "admin" 257 | password: "password" 258 | enabled: false 259 | - 260 | name: "POWERCONNECT_N3000" 261 | identifyBy: "REGEX" 262 | identifier: 263 | - 264 | text: "Dell Networking" 265 | - 266 | text: "N3024|N3048" 267 | deviceDefaultCredential: 268 | username: "admin" 269 | password: "password" 270 | enabled: false 271 | - 272 | name: "POWERCONNECT" 273 | identifyBy: "REGEX" 274 | identifier: 275 | - 276 | text: "Dell Networking" 277 | - 278 | text: "PowerConnect" 279 | deviceDefaultCredential: 280 | username: "admin" 281 | password: "password" 282 | enabled: false 283 | - 284 | protocol: "HTTPS" 285 | command: "http://%s/switchExplorer_installed.html" 286 | deviceType: 287 | - 288 | name: "BROCADE" 289 | identifyBy: "REGULAR" 290 | identifier: 291 | - 292 | text: "com.brocade.web.switchview.SwitchExplorerApplet" 293 | deviceDefaultCredential: 294 | username: "admin" 295 | password: "password" 296 | enabled: false 297 | groupName: "SWITCH" 298 | - 299 | discoveryRule: 300 | - 301 | protocol: "HTTPS" 302 | command: "https://%s/SystemExplorer.asp" 303 | deviceType: 304 | - 305 | name: "COMPELLENT" 306 | identifyBy: "REGULAR" 307 | identifier: 308 | - 309 | text: "COMPELLENT" 310 | deviceDefaultCredential: 311 | username: "Admin" 312 | password: "password" 313 | enabled: false 314 | - 315 | protocol: "HTTPS" 316 | command: "https://%s:3033/em/EnterpriseManager" 317 | deviceType: 318 | - 319 | name: "EM_COMPELLENT" 320 | identifyBy: "REGULAR" 321 | identifier: 322 | - 323 | text: "Enterprise Manager" 324 | deviceDefaultCredential: 325 | username: "Administrator" 326 | password: "password" 327 | enabled: false 328 | - 329 | protocol: "HTTPS" 330 | command: "http://%s/groupmgr.html" 331 | deviceType: 332 | - 333 | name: "EQUALLOGIC" 334 | identifyBy: "REGULAR" 335 | identifier: 336 | - 337 | text: "" 338 | deviceDefaultCredential: 339 | username: "grpadmin" 340 | password: "password" 341 | enabled: false 342 | groupName: "STORAGE" -------------------------------------------------------------------------------- /src/main/java/com/dell/isg/smi/service/device/discovery/ui/builder/RequestBuilderUI.java: -------------------------------------------------------------------------------- 1 | package com.dell.isg.smi.service.device.discovery.ui.builder; 2 | 3 | import java.util.HashSet; 4 | import java.util.List; 5 | import java.util.OptionalInt; 6 | import java.util.Random; 7 | import java.util.Set; 8 | import java.util.stream.IntStream; 9 | import java.util.stream.Stream; 10 | 11 | import org.apache.commons.collections4.CollectionUtils; 12 | import org.apache.commons.lang.ArrayUtils; 13 | import org.apache.commons.lang3.StringUtils; 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.vaadin.viritin.button.ConfirmButton; 18 | import org.vaadin.viritin.button.MButton; 19 | import org.vaadin.viritin.components.DisclosurePanel; 20 | import org.vaadin.viritin.fields.MTextField; 21 | import org.vaadin.viritin.form.AbstractForm; 22 | import org.vaadin.viritin.grid.MGrid; 23 | import org.vaadin.viritin.label.RichText; 24 | import org.vaadin.viritin.layouts.MHorizontalLayout; 25 | 26 | import com.dell.isg.smi.commons.model.common.Credential; 27 | import com.dell.isg.smi.commons.model.common.DevicesIpsRequest; 28 | import com.dell.isg.smi.commons.model.device.discovery.DiscoverDeviceRequest; 29 | import com.dell.isg.smi.commons.model.device.discovery.DiscoverIPRangeDeviceRequests; 30 | import com.dell.isg.smi.commons.model.device.discovery.DiscoverdDeviceResponse; 31 | import com.dell.isg.smi.commons.model.device.discovery.DiscoveryDeviceGroupEnum; 32 | import com.dell.isg.smi.service.device.discovery.manager.IDiscoveryManager; 33 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 34 | import com.fasterxml.jackson.databind.ObjectMapper; 35 | import com.vaadin.annotations.Theme; 36 | import com.vaadin.annotations.Title; 37 | import com.vaadin.icons.VaadinIcons; 38 | import com.vaadin.server.VaadinRequest; 39 | import com.vaadin.spring.annotation.SpringUI; 40 | import com.vaadin.ui.Alignment; 41 | import com.vaadin.ui.Button; 42 | import com.vaadin.ui.Button.ClickEvent; 43 | import com.vaadin.ui.CheckBox; 44 | import com.vaadin.ui.CssLayout; 45 | import com.vaadin.ui.HorizontalLayout; 46 | import com.vaadin.ui.Label; 47 | import com.vaadin.ui.Notification; 48 | import com.vaadin.ui.Panel; 49 | import com.vaadin.ui.PasswordField; 50 | import com.vaadin.ui.RadioButtonGroup; 51 | import com.vaadin.ui.TextArea; 52 | import com.vaadin.ui.TextField; 53 | import com.vaadin.ui.TwinColSelect; 54 | import com.vaadin.ui.UI; 55 | import com.vaadin.ui.VerticalLayout; 56 | import com.vaadin.ui.Window; 57 | import com.vaadin.ui.themes.Runo; 58 | import com.vaadin.ui.themes.ValoTheme; 59 | 60 | import de.codecentric.vaadin.copy2clipboard.Copy2ClipboardButton; 61 | 62 | @Title("Discovery Request Builder UI") 63 | @SpringUI(path = "/builder-ui") 64 | @Theme("valo") 65 | public class RequestBuilderUI extends UI { 66 | 67 | /** 68 | * 69 | */ 70 | private static final long serialVersionUID = 8881224699705009785L; 71 | @Autowired 72 | DeviceRangeRequestHandler deviceRangeRequestHandler; 73 | 74 | DeviceRangeRequestForm deviceRangeRequestForm = new DeviceRangeRequestForm(this); 75 | 76 | private static final Logger logger = LoggerFactory.getLogger(RequestBuilderUI.class.getName()); 77 | 78 | @Autowired 79 | IDiscoveryManager discoveryManager; 80 | 81 | private MGrid grid = new MGrid<>(DeviceRangeRequest.class) 82 | .withProperties("startIp", "endIp", "deviceGroups").withColumnHeaders("Strat IP:", "End IP:", "Groups:") 83 | .withFullWidth(); 84 | 85 | private RadioButtonGroup endpoint = new RadioButtonGroup<>("Please select service endpoint.."); 86 | private Panel rangePanel = new Panel(); 87 | private Panel ipsPanel = new Panel(); 88 | private TextArea requestAreaIps = new TextArea("Request JSON : "); 89 | private TextArea requestAreaRange = new TextArea("Request JSON : "); 90 | private TextArea responseArea = new TextArea("Response JSON : "); 91 | 92 | private Button addNew = new MButton(VaadinIcons.PLUS, this::add); 93 | private Button edit = new MButton(VaadinIcons.PENCIL, this::edit); 94 | private Button delete = new ConfirmButton(VaadinIcons.TRASH, "Are you sure you want to delete the entry?", 95 | this::remove); 96 | 97 | private DiscoverIPRangeDeviceRequests discoverIPRangeDeviceRequests = new DiscoverIPRangeDeviceRequests(); 98 | private DevicesIpsRequest devicesIpsRequest = new DevicesIpsRequest(); 99 | private ObjectMapper mapper = new ObjectMapper(); 100 | //private ObjectWriter objectWritter = new ObjectMapper().writer().withDefaultPrettyPrinter(); 101 | 102 | @Override 103 | protected void init(VaadinRequest vaadinRequest) { 104 | 105 | deviceRangeRequestForm.setSavedHandler(new AbstractForm.SavedHandler() { 106 | @Override 107 | public void onSave(DeviceRangeRequest rangeRequest) { 108 | try { 109 | if (StringUtils.isEmpty(rangeRequest.getId())) { 110 | Random randomGenerator = new Random(); 111 | rangeRequest.setId(""+randomGenerator.nextInt(4)); 112 | deviceRangeRequestHandler.addRange(rangeRequest); 113 | } else { 114 | OptionalInt indexOpt = IntStream.range(0, deviceRangeRequestHandler.getRangeSet().size()) 115 | .filter(i -> rangeRequest.getId().equals( deviceRangeRequestHandler.getRangeSet().get(i).getId())) 116 | .findFirst(); 117 | if (indexOpt != null) { 118 | deviceRangeRequestHandler.getRangeSet().set(indexOpt.getAsInt(), rangeRequest); 119 | } 120 | 121 | } 122 | onDeviceRangeRequestModified(); 123 | } catch (Exception e) { 124 | e.printStackTrace(); 125 | } 126 | } 127 | }); 128 | VerticalLayout main = new VerticalLayout(); 129 | HorizontalLayout center = new HorizontalLayout(); 130 | HorizontalLayout titleBar = new HorizontalLayout(); 131 | titleBar.setWidth("100%"); 132 | 133 | // Title 134 | Label title = new Label("REQUEST BUILDER UI: "); 135 | title.addStyleName(ValoTheme.LABEL_HUGE); 136 | titleBar.addComponent(title); 137 | Label titleComment = new Label("for Discovery"); 138 | titleComment.addStyleName(ValoTheme.LABEL_LIGHT); 139 | titleComment.setSizeUndefined(); 140 | titleBar.addComponent(titleComment); 141 | titleBar.setExpandRatio(title, 1.0f); 142 | 143 | CssLayout endpointLayout = new CssLayout(); 144 | 145 | endpoint.setItems("ips", "range"); 146 | endpointLayout.addComponent(endpoint); 147 | 148 | HorizontalLayout aboutLayout = new HorizontalLayout(); 149 | // About 150 | DisclosurePanel aboutConfig = new DisclosurePanel("About Discovery Request Builder", 151 | new RichText().withMarkDownResource("/request_builder.md")); 152 | 153 | aboutLayout.setWidth("100%"); 154 | aboutLayout.addComponents(aboutConfig); 155 | 156 | HorizontalLayout rangeLayout = new HorizontalLayout(); 157 | rangeLayout.setWidth("100%"); 158 | rangeLayout.addComponents(buildLeftPanel(), buildCenterRangePanel(), buildRightRangeRequestPanel()); 159 | rangePanel.setContent(rangeLayout); 160 | rangePanel.setVisible(false); 161 | 162 | HorizontalLayout ipsLayout = new HorizontalLayout(); 163 | ipsLayout.setWidth("100%"); 164 | ipsLayout.addComponents(buildLeftPanel(), buildCenterIpsPanel(), buildRightIpsRequestPanel()); 165 | ipsPanel.setContent(ipsLayout); 166 | ipsPanel.setVisible(false); 167 | 168 | center.addComponents(rangePanel, ipsPanel); 169 | center.setSizeFull(); 170 | 171 | main.addComponents(titleBar, aboutLayout, endpointLayout, center); 172 | endpoint.addValueChangeListener(event -> { 173 | if (event.getValue() == "range") { 174 | rangePanel.setVisible(true); 175 | ipsPanel.setVisible(false); 176 | } else { 177 | rangePanel.setVisible(false); 178 | ipsPanel.setVisible(true); 179 | } 180 | buildRequest(event.getValue()); 181 | }); 182 | setContent(main); 183 | 184 | } 185 | 186 | private Panel buildLeftPanel() { 187 | Panel leftPanel = new Panel(); 188 | leftPanel.addStyleName(Runo.PANEL_LIGHT); 189 | leftPanel.setSizeFull(); 190 | VerticalLayout leftPanelLayout = new VerticalLayout(); 191 | leftPanelLayout.setSizeFull(); 192 | CheckBox globalCredential = new CheckBox("Global Credential "); 193 | globalCredential.setValue(false); 194 | Panel credPanel = new Panel(); 195 | TextField globalUsername = new MTextField("Username :"); 196 | PasswordField globalPassword = new PasswordField("Password :"); 197 | VerticalLayout credLayout = new VerticalLayout(); 198 | credLayout.addComponents(globalUsername, globalPassword); 199 | credPanel.setContent(credLayout); 200 | credPanel.setVisible(false); 201 | 202 | Button next = new MButton(); 203 | next.setIcon(VaadinIcons.ARROW_CIRCLE_RIGHT, "Next"); 204 | next.setEnabled(false); 205 | globalCredential.addValueChangeListener(event -> { 206 | if (event.getValue() == false) { 207 | credPanel.setVisible(false); 208 | next.setEnabled(false); 209 | } else { 210 | credPanel.setVisible(true); 211 | next.setEnabled(true); 212 | } 213 | }); 214 | next.addClickListener(event -> { 215 | if (globalCredential.getValue() == true && StringUtils.isEmpty(globalUsername.getValue())) { 216 | Notification.show("Username :", "Cannot be null or empty !!!. ", Notification.Type.ERROR_MESSAGE); 217 | } else { 218 | Credential credential = new Credential(); 219 | credential.setUserName(globalUsername.getValue()); 220 | credential.setPassword(globalPassword.getValue()); 221 | if (StringUtils.equals(endpoint.getValue(), "range")) { 222 | discoverIPRangeDeviceRequests.setCredential(credential); 223 | } else if (StringUtils.equals(endpoint.getValue(), "ips")) { 224 | devicesIpsRequest.setCredential(credential); 225 | } 226 | } 227 | buildRequest(endpoint.getValue()); 228 | }); 229 | leftPanelLayout.addComponents(globalCredential, credPanel, next); 230 | leftPanelLayout.setSizeFull(); 231 | leftPanel.setSizeFull(); 232 | leftPanel.setContent(leftPanelLayout); 233 | return leftPanel; 234 | 235 | } 236 | 237 | private Panel buildCenterIpsPanel() { 238 | Panel ipsPanel = new Panel(); 239 | 240 | ipsPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); 241 | ipsPanel.setSizeFull(); 242 | VerticalLayout ipsLayout = new VerticalLayout(); 243 | TwinColSelect deviceGroups = new TwinColSelect("Select the group(s) for Discovery :"); 244 | String[] discoverGroupNames = Stream.of(DiscoveryDeviceGroupEnum.values()).map(DiscoveryDeviceGroupEnum::name) 245 | .toArray(String[]::new); 246 | deviceGroups.setItems(discoverGroupNames); 247 | TextField ipList = new MTextField("IP List [',' has delimiter]:"); 248 | Label ipListLabel = new Label("Sample IP List :"); 249 | ipListLabel.setValue("Example: - 100.68.123.31,100.68.124.95,100.68.123.35"); 250 | ipList.setSizeFull(); 251 | ipList.setWidth("400"); 252 | ipsLayout.setSizeFull(); 253 | ipsLayout.setMargin(true); 254 | ipsPanel.setContent(ipsLayout); 255 | ipsPanel.setSizeFull(); 256 | ipsPanel.setStyleName(ValoTheme.PANEL_BORDERLESS); 257 | 258 | Button next = new MButton(); 259 | next.setIcon(VaadinIcons.ARROW_CIRCLE_RIGHT, "Next"); 260 | next.setEnabled(false); 261 | 262 | ipList.addValueChangeListener(event -> { 263 | if (!StringUtils.isEmpty(ipList.getValue())) { 264 | next.setEnabled(true); 265 | } 266 | }); 267 | next.addClickListener(event -> { 268 | if (StringUtils.isEmpty(ipList.getValue())) { 269 | Notification.show("IP List :", "Cannot be null or empty !!!. ", Notification.Type.ERROR_MESSAGE); 270 | } else { 271 | String[] ips = ipList.getValue().split(","); 272 | devicesIpsRequest.setIps(ips); 273 | } 274 | buildRequest(endpoint.getValue()); 275 | }); 276 | 277 | deviceGroups.addValueChangeListener(event -> { 278 | String[] deviceType = null; 279 | if (deviceGroups.getSelectedItems().size() == 0) { 280 | devicesIpsRequest.setDeviceType(deviceType); 281 | } else { 282 | deviceType = deviceGroups.getSelectedItems().stream().toArray(String[]::new); 283 | devicesIpsRequest.setDeviceType(deviceType); 284 | } 285 | buildRequest(endpoint.getValue()); 286 | }); 287 | 288 | ipsLayout.addComponents(deviceGroups, ipList, ipListLabel, next); 289 | 290 | return ipsPanel; 291 | } 292 | 293 | private Panel buildRightIpsRequestPanel() { 294 | Panel requestPanel = new Panel(); 295 | requestPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); 296 | requestPanel.setSizeUndefined(); 297 | VerticalLayout requestViewerLayout = new VerticalLayout(); 298 | requestAreaIps.setSizeFull(); 299 | requestAreaIps.setCaption("Request Viewer:"); 300 | requestAreaIps.setHeight("350"); 301 | requestAreaIps.setWidth("430"); 302 | requestAreaIps.setEnabled(false); 303 | Copy2ClipboardButton copy = new Copy2ClipboardButton(); 304 | copy.setCaption("Copy2Clipboard"); 305 | copy.setIcon(VaadinIcons.COPY_O, "Copy"); 306 | copy.addClickListener(event -> { 307 | { 308 | copy.setClipboardText(requestAreaIps.getValue()); 309 | Notification.show("Request copy :", "Copied request to the clipboard !!!. " + requestAreaIps.getValue(), 310 | Notification.Type.HUMANIZED_MESSAGE); 311 | } 312 | }); 313 | 314 | Button process = new MButton(); 315 | process.setCaption("Run"); 316 | process.setIcon(VaadinIcons.FILE_PROCESS, "Process"); 317 | process.addClickListener(event -> { 318 | List response = null; 319 | try { 320 | if (StringUtils.equals(endpoint.getValue(), "range")) { 321 | response = discoveryManager.discover(discoverIPRangeDeviceRequests); 322 | } else if (StringUtils.equals(endpoint.getValue(), "ips")) { 323 | if (ArrayUtils.isEmpty(devicesIpsRequest.getIps())) { 324 | Notification.show("IP List :", "Cannot be null or empty !!!. ", 325 | Notification.Type.ERROR_MESSAGE); 326 | } else { 327 | response = discoveryManager.discover(devicesIpsRequest); 328 | } 329 | } 330 | } catch (Exception e) { 331 | Notification.show("Request Builder :", "Unable to create json string. !!!. ", Notification.Type.ERROR_MESSAGE); 332 | logger.error("Unable to create json string."); 333 | } 334 | if (response != null) { 335 | buildResponse(response); 336 | } 337 | 338 | }); 339 | 340 | Button swagger = new MButton("Open Swagger"); 341 | swagger.addClickListener(event -> { 342 | getUI().getPage().open("http://localhost:46002/swagger-ui.html", "Swagger-UI"); 343 | }); 344 | requestViewerLayout.addComponents(requestAreaIps, new MHorizontalLayout(copy, process, swagger)); 345 | requestViewerLayout.setSizeFull(); 346 | requestPanel.setContent(requestViewerLayout); 347 | requestPanel.setStyleName(ValoTheme.PANEL_BORDERLESS); 348 | requestPanel.setSizeFull(); 349 | return requestPanel; 350 | 351 | } 352 | 353 | private Panel buildRightRangeRequestPanel() { 354 | Panel requestPanel = new Panel(); 355 | requestPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); 356 | requestPanel.setSizeUndefined(); 357 | VerticalLayout requestViewerLayout = new VerticalLayout(); 358 | requestAreaRange.setSizeFull(); 359 | requestAreaRange.setCaption("Request Viewer:"); 360 | requestAreaRange.setHeight("350"); 361 | requestAreaRange.setWidth("430"); 362 | requestAreaRange.setEnabled(false); 363 | Copy2ClipboardButton copy = new Copy2ClipboardButton(); 364 | copy.setCaption("Copy2Clipboard"); 365 | copy.setIcon(VaadinIcons.COPY_O, "Copy"); 366 | copy.addClickListener(event -> { 367 | { 368 | copy.setClipboardText(requestAreaIps.getValue()); 369 | Notification.show("Request copy :", "Copied request to the clipboard !!!. " + requestAreaIps.getValue(), 370 | Notification.Type.HUMANIZED_MESSAGE); 371 | } 372 | }); 373 | 374 | Button process = new MButton(); 375 | process.setCaption("Run"); 376 | process.setIcon(VaadinIcons.FILE_PROCESS, "Process"); 377 | process.addClickListener(event -> { 378 | List response = null; 379 | try { 380 | if (StringUtils.equals(endpoint.getValue(), "range")) { 381 | response = discoveryManager.discover(discoverIPRangeDeviceRequests); 382 | } else if (StringUtils.equals(endpoint.getValue(), "ips")) { 383 | if (ArrayUtils.isEmpty(devicesIpsRequest.getIps())) { 384 | Notification.show("IP List :", "Cannot be null or empty !!!. ", 385 | Notification.Type.ERROR_MESSAGE); 386 | } else { 387 | response = discoveryManager.discover(devicesIpsRequest); 388 | } 389 | } 390 | } catch (Exception e) { 391 | Notification.show("Get Response :", "Unable to get the response from the service. !!!. ", Notification.Type.ERROR_MESSAGE); 392 | logger.error("Unable to get the response from the service."); 393 | } 394 | if (response != null) { 395 | buildResponse(response); 396 | } 397 | 398 | }); 399 | 400 | Button swagger = new MButton("Open Swagger"); 401 | swagger.addClickListener(event -> { 402 | getUI().getPage().open("http://localhost:46002/swagger-ui.html", "Swagger-UI"); 403 | }); 404 | requestViewerLayout.addComponents(requestAreaRange, new MHorizontalLayout(copy, process, swagger)); 405 | requestViewerLayout.setSizeFull(); 406 | requestPanel.setContent(requestViewerLayout); 407 | requestPanel.setStyleName(ValoTheme.PANEL_BORDERLESS); 408 | requestPanel.setSizeFull(); 409 | return requestPanel; 410 | 411 | } 412 | 413 | private Panel buildCenterRangePanel() { 414 | Panel rangePanel = new Panel(); 415 | VerticalLayout rangeForm = new VerticalLayout(); 416 | edit.setEnabled(false); 417 | delete.setEnabled(false); 418 | grid.asSingleSelect().addValueChangeListener(e -> { 419 | boolean hasSelection = !grid.getSelectedItems().isEmpty(); 420 | edit.setEnabled(hasSelection); 421 | delete.setEnabled(hasSelection); 422 | buildRange(); 423 | }); 424 | 425 | Button next = new MButton(); 426 | next.setIcon(VaadinIcons.ARROW_CIRCLE_RIGHT, "Next"); 427 | next.addClickListener(event -> { 428 | if (deviceRangeRequestHandler.getRangeSet().size() <= 0) { 429 | Notification.show("Range :", "You should define atleast one range !!!. ", 430 | Notification.Type.ERROR_MESSAGE); 431 | } else{ 432 | buildRange(); 433 | } 434 | 435 | }); 436 | 437 | updateList(); 438 | rangeForm.addComponents(new MHorizontalLayout(addNew, edit, delete), grid, next); 439 | rangeForm.setExpandRatio(grid, 1); 440 | rangeForm.setSizeFull(); 441 | rangeForm.setMargin(true); 442 | rangePanel.addStyleName(ValoTheme.PANEL_BORDERLESS); 443 | rangePanel.setStyleName(ValoTheme.PANEL_BORDERLESS); 444 | rangePanel.setSizeFull(); 445 | rangePanel.setContent(rangeForm); 446 | return rangePanel; 447 | 448 | } 449 | 450 | private void buildRange(){ 451 | if (deviceRangeRequestHandler.getRangeSet().size() > 0) { 452 | Set discoverDeviceRequestSet = transformDeviceRangeRequest( 453 | deviceRangeRequestHandler.getRangeSet()); 454 | discoverIPRangeDeviceRequests.setDiscoverIpRangeDeviceRequests(discoverDeviceRequestSet); 455 | } else { 456 | discoverIPRangeDeviceRequests.setDiscoverIpRangeDeviceRequests(new HashSet()); 457 | } 458 | buildRequest(endpoint.getValue()); 459 | } 460 | 461 | private Set transformDeviceRangeRequest(List rangeSet) { 462 | Set discoveryRangeRequestList = new HashSet(); 463 | for (DeviceRangeRequest rangeRequest : rangeSet) { 464 | DiscoverDeviceRequest discoverDeviceRequest = new DiscoverDeviceRequest(); 465 | if (!CollectionUtils.isEmpty(rangeRequest.getDeviceGroups())) { 466 | discoverDeviceRequest.setDeviceType(rangeRequest.getDeviceGroups().stream().toArray(String[]::new)); 467 | } 468 | discoverDeviceRequest.setDeviceStartIp(rangeRequest.getStartIp()); 469 | discoverDeviceRequest.setDeviceEndIp(rangeRequest.getEndIp()); 470 | if (!StringUtils.isEmpty(rangeRequest.getUsername())) { 471 | Credential credential = new Credential(); 472 | credential.setUserName(rangeRequest.getUsername()); 473 | credential.setPassword(rangeRequest.getPassword()); 474 | discoverDeviceRequest.setCredential(credential); 475 | } 476 | discoveryRangeRequestList.add(discoverDeviceRequest); 477 | } 478 | return discoveryRangeRequestList; 479 | } 480 | 481 | public void add(ClickEvent clickEvent) { 482 | edit(new DeviceRangeRequest()); 483 | 484 | } 485 | 486 | public void edit(ClickEvent e) { 487 | edit(grid.asSingleSelect().getValue()); 488 | } 489 | 490 | public void remove() { 491 | deviceRangeRequestHandler.delete(grid.asSingleSelect().getValue()); 492 | grid.deselectAll(); 493 | buildRange(); 494 | updateList(); 495 | 496 | } 497 | 498 | protected void edit(final DeviceRangeRequest deviceRangeRequestEntry) { 499 | deviceRangeRequestForm.setEntity(deviceRangeRequestEntry); 500 | deviceRangeRequestForm.openInModalPopup(); 501 | } 502 | 503 | public void onDeviceRangeRequestModified() { 504 | deviceRangeRequestForm.closePopup(); 505 | buildRange(); 506 | updateList(); 507 | } 508 | 509 | private void buildRequest(String endpoint) { 510 | mapper.setSerializationInclusion(Include.NON_NULL); 511 | String value = ""; 512 | try { 513 | if (StringUtils.equals(endpoint, "range")) { 514 | 515 | value = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(discoverIPRangeDeviceRequests); 516 | requestAreaRange.setValue(value); 517 | } else if (StringUtils.equals(endpoint, "ips")) { 518 | value = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(devicesIpsRequest); 519 | requestAreaIps.setValue(value); 520 | } 521 | } catch (Exception e) { 522 | Notification.show("Request Builder :", "Unable to build the request. !!!. ", Notification.Type.ERROR_MESSAGE); 523 | logger.error("Unable to build the request."); 524 | } 525 | 526 | } 527 | 528 | private void buildResponse(List responseList) { 529 | String value = ""; 530 | try { 531 | value = mapper.writer().withDefaultPrettyPrinter().writeValueAsString(responseList); 532 | } catch (Exception e) { 533 | logger.error("Unable to get the response from the service."); 534 | } 535 | // responseArea.setValue(value); 536 | Window subWindow = new Window("Response Window:"); 537 | VerticalLayout subContent = new VerticalLayout(); 538 | subWindow.setContent(subContent); 539 | responseArea.setCaption("Response:"); 540 | responseArea.setWidth("450"); 541 | responseArea.setHeight("500"); 542 | responseArea.setEnabled(false); 543 | responseArea.setValue(value); 544 | subContent.addComponent(responseArea); 545 | subContent.setComponentAlignment(responseArea, Alignment.MIDDLE_CENTER); 546 | subWindow.center(); 547 | subWindow.setWidth("600"); 548 | subWindow.setHeight("650"); 549 | addWindow(subWindow); 550 | } 551 | 552 | public void updateList() { 553 | grid.setRows(deviceRangeRequestHandler.getRangeSet()); 554 | } 555 | 556 | } --------------------------------------------------------------------------------