Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 1 | ======================== |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 2 | DFC (DataFile Collector) |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 3 | ======================== |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 4 | |
| 5 | :Date: 2018-09-21 |
| 6 | |
| 7 | .. contents:: |
| 8 | :depth: 3 |
| 9 | .. |
| 10 | |
| 11 | Overview |
| 12 | ======== |
| 13 | |
| 14 | DFC will orchestrate the collection of bulk PM data flow: |
| 15 | 1. Subscribes to fileReady DMaaP topic |
| 16 | 2. Collects the file from the xNF |
| 17 | 3. Sends new event to DataRouter with file. |
| 18 | |
| 19 | Introduction |
| 20 | ============ |
| 21 | |
| 22 | DFC is delivered as one **Docker container** which hosts application server and can be started by `docker-compose`. |
| 23 | |
| 24 | Functionality |
| 25 | ============= |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 26 | .. image:: ../images/DFC.png |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 27 | |
| 28 | |
| 29 | Paths |
| 30 | ===== |
| 31 | |
| 32 | GET /events/unauthenticated.VES_NOTIFICATION_OUTPUT |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 33 | --------------------------------------------------- |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 34 | |
| 35 | Description |
| 36 | ~~~~~~~~~~~ |
| 37 | |
| 38 | Reads fileReady events from DMaaP (Data Movement as a Platform) |
| 39 | |
| 40 | |
| 41 | Responses |
| 42 | ~~~~~~~~~ |
| 43 | |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 44 | +-----------+---------------------+ |
| 45 | | HTTP Code | Description | |
| 46 | +===========+=====================+ |
| 47 | | **200** | successful response | |
| 48 | +-----------+---------------------+ |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 49 | |
| 50 | |
| 51 | |
| 52 | POST /publish |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 53 | ------------- |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 54 | |
| 55 | Description |
| 56 | ~~~~~~~~~~~ |
| 57 | |
| 58 | Publish the collected file/s as a stream to DataRouter |
| 59 | - file as stream |
| 60 | - compression |
| 61 | - fileFormatType |
| 62 | - fileFormatVersion |
| 63 | |
| 64 | |
| 65 | Responses |
| 66 | ~~~~~~~~~ |
| 67 | |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 68 | +-----------+---------------------+ |
| 69 | | HTTP Code | Description | |
| 70 | +===========+=====================+ |
| 71 | | **200** | successful response | |
| 72 | +-----------+---------------------+ |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 73 | |
| 74 | Compiling DFC |
| 75 | ============= |
| 76 | |
| 77 | Whole project (top level of DFC directory) and each module (sub module directory) can be compiled using |
| 78 | `mvn clean install` command. |
| 79 | |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 80 | Configuration file: Config/datafile_endpoints.json |
| 81 | |
| 82 | Main API Endpoints |
| 83 | ================== |
| 84 | |
| 85 | Running with dev-mode of DFC |
| 86 | - Heartbeat: **http://<container_address>:8100/heartbeat** or **https://<container_address>:8433/heartbeat** |
| 87 | - Start DFC: **http://<container_address>:8100/start** or **https://<container_address>:8433/start** |
| 88 | - Stop DFC: **http://<container_address>:8100/stopDatafile** or **https://<container_address>:8433/stopDatafile** |
| 89 | |
| 90 | The external port allocated for 8100 (http) is 30245. |
| 91 | |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 92 | Maven GroupId: |
| 93 | ============== |
| 94 | |
| 95 | org.onap.dcaegen2.collectors |
| 96 | |
| 97 | Maven Parent ArtifactId: |
| 98 | ======================== |
| 99 | |
| 100 | dcae-collectors |
| 101 | |
| 102 | Maven Children Artifacts: |
| 103 | ========================= |
| 104 | |
| 105 | 1. datafile-app-server: DFC server |
| 106 | 2. datafile-dmaap-client: Contains implementation of DmaaP client |
| 107 | 3. datafile-commons: Common code for whole DFC modules |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 108 | 4. docker-compose: Contains the docker-compose |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 109 | |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 110 | Configuration of Certificates in test environment(For FTP over TLS): |
| 111 | ==================================================================== |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 112 | |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 113 | DFC supports two protocols: FTPES and SFTP. |
| 114 | For FTPES, it is mutual authentication with certificates. |
| 115 | In our test environment, we use vsftpd to simulate xNF, and we generate self-signed |
| 116 | keys & certificates on both vsftpd server and DFC. |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 117 | |
| 118 | 1. Generate key/certificate with openssl for DFC: |
| 119 | ------------------------------------------------- |
| 120 | .. code:: bash |
| 121 | |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 122 | openssl genrsa -out dfc.key 2048 |
| 123 | openssl req -new -out dfc.csr -key dfc.key |
| 124 | openssl x509 -req -days 365 -in dfc.csr -signkey dfc.key -out dfc.crt |
elinuxhenrik | b511dbc | 2018-09-20 13:05:18 +0200 | [diff] [blame] | 125 | |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 126 | 2. Generate key & certificate with openssl for vsftpd: |
| 127 | ------------------------------------------------------ |
| 128 | .. code:: bash |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 129 | |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 130 | openssl genrsa -out ftp.key 2048 |
| 131 | openssl req -new -out ftp.csr -key ftp.key |
| 132 | openssl x509 -req -days 365 -in ftp.csr -signkey ftp.key -out ftp.crt |
| 133 | |
| 134 | 3. Configure java keystore in DFC: |
| 135 | ---------------------------------- |
| 136 | We have two keystore files, one for TrustManager, one for KeyManager. |
| 137 | |
| 138 | **For TrustManager:** |
| 139 | |
| 140 | 1. First, create a jks keystore for TrustManager: |
| 141 | |
| 142 | .. code:: bash |
| 143 | |
| 144 | keytool -keystore ftp.jks -genkey -alias ftp |
| 145 | |
| 146 | 2. Second, convert your certificate in a DER format : |
| 147 | |
| 148 | .. code:: bash |
| 149 | |
| 150 | openssl x509 -outform der -in ftp.crt -out ftp.der |
| 151 | |
| 152 | 3. And after, import it in the keystore : |
| 153 | |
| 154 | .. code:: bash |
| 155 | |
| 156 | keytool -import -alias ftp -keystore ftp.jks -file ftp.der |
| 157 | |
| 158 | **For KeyManager:** |
| 159 | |
| 160 | 1. First, create a jks keystore: |
| 161 | |
| 162 | .. code:: bash |
| 163 | |
| 164 | keytool -keystore dfc.jks -genkey -alias dfc |
| 165 | |
| 166 | 2. Second, import dfc.crt and dfc.key to dfc.jks. This is a bit troublesome. |
| 167 | |
| 168 | 1). Step one: Convert x509 Cert and Key to a pkcs12 file |
| 169 | |
| 170 | .. code:: bash |
| 171 | |
| 172 | openssl pkcs12 -export -in dfc.crt -inkey dfc.key -out dfc.p12 -name [some-alias] |
| 173 | |
| 174 | Note: Make sure you put a password on the p12 file - otherwise you'll get a null reference exception when yy to import it. (In case anyone else had this headache). |
| 175 | |
| 176 | Note 2: You might want to add the -chainoption to preserve the full certificate chain. |
| 177 | |
| 178 | 2). Step two: Convert the pkcs12 file to a java keystore: |
| 179 | |
| 180 | .. code:: bash |
| 181 | |
| 182 | keytool -importkeystore -deststorepass [changeit] -destkeypass [changeit] -destkeystore dfc.jks -srckeystore dfc.p12 -srcstoretype PKCS12 -srcstorepass [some-password] -alias [some-alias] |
| 183 | |
| 184 | 3. Finished |
| 185 | |
| 186 | 4. Configure vsftpd: |
| 187 | -------------------- |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 188 | update /etc/vsftpd/vsftpd.conf: |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 189 | |
| 190 | .. code-block:: javascript |
| 191 | |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 192 | rsa_cert_file=/etc/ssl/private/ftp.crt |
| 193 | rsa_private_key_file=/etc/ssl/private/ftp.key |
| 194 | ssl_enable=YES |
| 195 | allow_anon_ssl=NO |
| 196 | force_local_data_ssl=YES |
| 197 | force_local_logins_ssl=YES |
| 198 | |
| 199 | ssl_tlsv1=YES |
| 200 | ssl_sslv2=YES |
| 201 | ssl_sslv3=YES |
| 202 | |
| 203 | require_ssl_reuse=NO |
| 204 | ssl_ciphers=HIGH |
| 205 | |
| 206 | require_cert=YES |
| 207 | ssl_request_cert=YES |
| 208 | ca_certs_file=/home/vsftpd/myuser/dfc.crt |
| 209 | |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 210 | 5. Configure config/datafile_endpoints.json: |
| 211 | -------------------------------------------- |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 212 | Update the file accordingly: |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 213 | |
| 214 | .. code-block:: javascript |
| 215 | |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 216 | "ftpesConfiguration": { |
| 217 | "keyCert": "/config/dfc.jks", |
| 218 | "keyPassword": "[yourpassword]", |
| 219 | "trustedCA": "/config/ftp.jks", |
| 220 | "trustedCAPassword": "[yourpassword]" |
| 221 | } |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 222 | |
Chengkai Yan | 285e47c | 2018-10-18 10:40:14 +0200 | [diff] [blame] | 223 | 6. This has been tested with vsftpd and dfc, with self-signed certificates. |
Chengkai Yan | 54d8a3b | 2018-11-01 12:06:26 +0100 | [diff] [blame] | 224 | --------------------------------------------------------------------------- |
| 225 | In real deployment, we should use ONAP-CA signed certificate for DFC, and vendor-CA signed certificate for xNF |