From 1f4ec41ae3b83d0144873bf2abcee6ba27f2698d Mon Sep 17 00:00:00 2001 From: Sunil Kumar <sk0064@surrey.ac.uk> Date: Thu, 3 Aug 2023 11:19:02 +0100 Subject: [PATCH] Initial commit --- near-rt-ric-simulator/Dockerfile | 38 -- near-rt-ric-simulator/LICENSES.txt | 30 -- .../{api/STD_1.1.3 => }/STD_A1.yaml | 10 +- .../__pycache__/a1.cpython-38.pyc | Bin 0 -> 5042 bytes .../__pycache__/main.cpython-38.pyc | Bin 0 -> 4660 bytes .../__pycache__/maincommon.cpython-38.pyc | Bin 0 -> 1537 bytes .../__pycache__/utils.cpython-38.pyc | Bin 0 -> 360 bytes .../var_declaration.cpython-38.pyc | Bin 0 -> 319 bytes .../{src/STD_1.1.3 => }/a1.py | 2 +- .../api/OSC_2.1.0/openapi.yaml | 349 ------------ .../api/STD_2.0.0/ORAN_A1-p_V2.0.0_api.yaml | 341 ------------ .../{src/STD_2.0.0 => }/callBack.py | 12 +- near-rt-ric-simulator/certificate/cert.crt | 16 - near-rt-ric-simulator/certificate/key.crt | 30 -- near-rt-ric-simulator/certificate/pass | 1 - near-rt-ric-simulator/container-tag.yaml | 2 - .../{src/STD_1.1.3 => }/main.py | 8 +- .../{src/common => }/maincommon.py | 11 +- near-rt-ric-simulator/nginx.conf | 122 ----- .../src/OSC_2.1.0/.gitignore | 1 - near-rt-ric-simulator/src/OSC_2.1.0/a1.py | 275 ---------- near-rt-ric-simulator/src/OSC_2.1.0/main.py | 222 -------- .../src/OSC_2.1.0/var_declaration.py | 25 - .../src/STD_1.1.3/.gitignore | 1 - .../src/STD_1.1.3/callBack.py | 43 -- .../src/STD_2.0.0/.gitignore | 1 - near-rt-ric-simulator/src/STD_2.0.0/a1.py | 271 ---------- near-rt-ric-simulator/src/STD_2.0.0/main.py | 255 --------- .../src/STD_2.0.0/var_declaration.py | 27 - near-rt-ric-simulator/src/common/.gitignore | 1 - near-rt-ric-simulator/src/start.sh | 51 -- .../generate_cert_and_key.sh => start.sh} | 22 +- .../test/OSC_2.1.0/basic_test.sh | 275 ---------- .../test/OSC_2.1.0/build_and_start.sh | 34 -- .../test/OSC_2.1.0/jsonfiles/pi1.json | 10 - .../test/OSC_2.1.0/jsonfiles/pi2.json | 9 - .../jsonfiles/pi2_missing_param.json | 8 - .../test/OSC_2.1.0/jsonfiles/pt1.json | 41 -- .../test/OSC_2.1.0/jsonfiles/pt2.json | 41 -- .../test/STD_1.1.3/basic_test.sh | 77 ++- near-rt-ric-simulator/test/STD_2.0.0/.p.json | 1 - .../test/STD_2.0.0/basic_test.sh | 288 ---------- .../test/STD_2.0.0/build_and_start.sh | 33 -- .../test/STD_2.0.0/jsonfiles/pi1.json | 10 - .../test/STD_2.0.0/jsonfiles/pi1_updated.json | 10 - .../test/STD_2.0.0/jsonfiles/pi2.json | 10 - .../test/STD_2.0.0/jsonfiles/std_1.json | 56 -- near-rt-ric-simulator/tests/.gitignore | 1 - near-rt-ric-simulator/tests/test_osc_2_1_0.py | 510 ------------------ near-rt-ric-simulator/tests/test_std_1_1_3.py | 459 ---------------- near-rt-ric-simulator/tests/test_std_2_0_0.py | 436 --------------- near-rt-ric-simulator/tests/unittest_setup.py | 58 -- .../{src/common => }/utils.py | 9 +- .../{src/STD_1.1.3 => }/var_declaration.py | 9 +- tox.ini | 24 +- 55 files changed, 81 insertions(+), 4495 deletions(-) delete mode 100644 near-rt-ric-simulator/Dockerfile delete mode 100644 near-rt-ric-simulator/LICENSES.txt rename near-rt-ric-simulator/{api/STD_1.1.3 => }/STD_A1.yaml (96%) create mode 100644 near-rt-ric-simulator/__pycache__/a1.cpython-38.pyc create mode 100644 near-rt-ric-simulator/__pycache__/main.cpython-38.pyc create mode 100644 near-rt-ric-simulator/__pycache__/maincommon.cpython-38.pyc create mode 100644 near-rt-ric-simulator/__pycache__/utils.cpython-38.pyc create mode 100644 near-rt-ric-simulator/__pycache__/var_declaration.cpython-38.pyc rename near-rt-ric-simulator/{src/STD_1.1.3 => }/a1.py (99%) delete mode 100644 near-rt-ric-simulator/api/OSC_2.1.0/openapi.yaml delete mode 100644 near-rt-ric-simulator/api/STD_2.0.0/ORAN_A1-p_V2.0.0_api.yaml rename near-rt-ric-simulator/{src/STD_2.0.0 => }/callBack.py (79%) delete mode 100644 near-rt-ric-simulator/certificate/cert.crt delete mode 100644 near-rt-ric-simulator/certificate/key.crt delete mode 100644 near-rt-ric-simulator/certificate/pass delete mode 100644 near-rt-ric-simulator/container-tag.yaml rename near-rt-ric-simulator/{src/STD_1.1.3 => }/main.py (96%) rename near-rt-ric-simulator/{src/common => }/maincommon.py (86%) delete mode 100644 near-rt-ric-simulator/nginx.conf delete mode 100644 near-rt-ric-simulator/src/OSC_2.1.0/.gitignore delete mode 100644 near-rt-ric-simulator/src/OSC_2.1.0/a1.py delete mode 100644 near-rt-ric-simulator/src/OSC_2.1.0/main.py delete mode 100644 near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py delete mode 100644 near-rt-ric-simulator/src/STD_1.1.3/.gitignore delete mode 100644 near-rt-ric-simulator/src/STD_1.1.3/callBack.py delete mode 100644 near-rt-ric-simulator/src/STD_2.0.0/.gitignore delete mode 100644 near-rt-ric-simulator/src/STD_2.0.0/a1.py delete mode 100644 near-rt-ric-simulator/src/STD_2.0.0/main.py delete mode 100644 near-rt-ric-simulator/src/STD_2.0.0/var_declaration.py delete mode 100644 near-rt-ric-simulator/src/common/.gitignore delete mode 100755 near-rt-ric-simulator/src/start.sh rename near-rt-ric-simulator/{certificate/generate_cert_and_key.sh => start.sh} (55%) delete mode 100755 near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh delete mode 100755 near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh delete mode 100644 near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi1.json delete mode 100644 near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2.json delete mode 100644 near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2_missing_param.json delete mode 100644 near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt1.json delete mode 100644 near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt2.json delete mode 100644 near-rt-ric-simulator/test/STD_2.0.0/.p.json delete mode 100755 near-rt-ric-simulator/test/STD_2.0.0/basic_test.sh delete mode 100755 near-rt-ric-simulator/test/STD_2.0.0/build_and_start.sh delete mode 100644 near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1.json delete mode 100644 near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1_updated.json delete mode 100644 near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi2.json delete mode 100644 near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/std_1.json delete mode 100644 near-rt-ric-simulator/tests/.gitignore delete mode 100644 near-rt-ric-simulator/tests/test_osc_2_1_0.py delete mode 100644 near-rt-ric-simulator/tests/test_std_1_1_3.py delete mode 100644 near-rt-ric-simulator/tests/test_std_2_0_0.py delete mode 100644 near-rt-ric-simulator/tests/unittest_setup.py rename near-rt-ric-simulator/{src/common => }/utils.py (72%) rename near-rt-ric-simulator/{src/STD_1.1.3 => }/var_declaration.py (71%) diff --git a/near-rt-ric-simulator/Dockerfile b/near-rt-ric-simulator/Dockerfile deleted file mode 100644 index b079d73..0000000 --- a/near-rt-ric-simulator/Dockerfile +++ /dev/null @@ -1,38 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -FROM python:3.8-slim-buster - -WORKDIR /usr/src/app - -RUN pip install connexion[swagger-ui] - -#install nginx -RUN apt-get update -RUN apt-get install -y nginx=1.14.* -RUN apt-get install -y nginx-extras - -#install curl -RUN apt-get install -y curl - -COPY src src -COPY api api -COPY nginx.conf nginx.conf -COPY certificate /usr/src/app/cert - -RUN chmod +x src/start.sh -CMD src/start.sh ${A1_VERSION} diff --git a/near-rt-ric-simulator/LICENSES.txt b/near-rt-ric-simulator/LICENSES.txt deleted file mode 100644 index 9e98e14..0000000 --- a/near-rt-ric-simulator/LICENSES.txt +++ /dev/null @@ -1,30 +0,0 @@ -LICENSES.txt - - -Unless otherwise specified, all software contained herein is licensed -under the Apache License, Version 2.0 (the "Software License"); -you may not use this software except in compliance with the Software -License. You may obtain a copy of the Software License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the Software License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the Software License for the specific language governing permissions -and limitations under the Software License. - - -Unless otherwise specified, all documentation contained herein is licensed -under the Creative Commons License, Attribution 4.0 Intl. (the -"Documentation License"); you may not use this documentation except in -compliance with the Documentation License. You may obtain a copy of the -Documentation License at - -https://creativecommons.org/licenses/by/4.0/ - -Unless required by applicable law or agreed to in writing, documentation -distributed under the Documentation License is distributed on an "AS IS" -BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -implied. See the Documentation License for the specific language governing -permissions and limitations under the Documentation License. diff --git a/near-rt-ric-simulator/api/STD_1.1.3/STD_A1.yaml b/near-rt-ric-simulator/STD_A1.yaml similarity index 96% rename from near-rt-ric-simulator/api/STD_1.1.3/STD_A1.yaml rename to near-rt-ric-simulator/STD_A1.yaml index 71638f4..c68d175 100644 --- a/near-rt-ric-simulator/api/STD_1.1.3/STD_A1.yaml +++ b/near-rt-ric-simulator/STD_A1.yaml @@ -3,14 +3,14 @@ info: title: 'A1-P Policy Management Service' version: 1.1.3 description: | - API for Policy Management Service. - © 2019, O-RAN Alliance. + API for Policy Management Service Near. + © 2023, S. Kumar Chaudhary. All rights reserved. externalDocs: - description: 'ORAN-WG2.A1.AP-v01.01 A1 interface: Application protocol' - url: 'https://www.o-ran.org/specifications' + description: 'As per ORAN Specification version-1, A1 interface Application protocol' + url: 'https://orandownloadsweb.azurewebsites.net/specifications' servers: - - url: '{apiRoot}/A1-P/v1' + - url: '{apiRoot}/A1AP/v1' variables: apiRoot: default: 'https://example.com' diff --git a/near-rt-ric-simulator/__pycache__/a1.cpython-38.pyc b/near-rt-ric-simulator/__pycache__/a1.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..06b7b5a3b47f807322d2f9e9bcb3e3066bff453a GIT binary patch literal 5042 zcma)A$&=hx8JE;jw|blDS!~aYmnexz(govjhyzJ*LKeprr$Wc&iHk%B8d>kPTOMsZ zy`FfwG{s@KCY1wJ!G#(Z7jl3LR}LJZigOM+aDj{e0;q6+-}ltr?wN5V=`OwH(_6lM z(d~A-q2c$(|NVvi<E*CrlP2>&1C!VBWdA|KG^U4|TlTuEtGVGCs;{^e)tj!Vdds!Y z8(}r7xiy{kR6;wdyY;ByHln86j9P9hYP)Uq&I}i#MRzgkxSeRpU5b|7<!HrSiB{cJ z_1+3kMW@}<YFrJ^L~HI^wC=7)8}3GQ);$Y&%{|9#_dKh!#xFGY0&B7s`X^YMEueSU zBI}@kk}a`i^iQ!Bwu=5~c8Z-wf03PGYv{kl*4YO7XV_VG4*j!C-`2Y4AA)+V*VT)9 zFL^78C68s-Dy-|Fm+cf)p7~zNi<;m+8}UpQ_AQ>JNu2Sb9eF#vFDBD&wdkZt82Eer zAkL&0`#dY!6A0#VlofT~3&T5}zmpY<gGBh8^)oJI5Z}#;<;l_kW?ZBqh-Fb9CYj7= z4X|6pX8-!5w_USn`$O*U^u07lJvl6D)4`K>x$I}7G);uW9XN`Mfd_<U*cMCtz7(D> z`*cM=_98y+cxej!JsBkN*1ar=$7}PDR3vvo9(|kM_{6g5PsgBw=Pf+hchE>p>e4tc zbWK(cG*jD$g6!1Axm?@Uq$#b#>I3aSXZpYZ`;FeizhY0fCYI5OHZ>NS;!H_gl(1kB zfQl)j3o{HdDQsF}?(n?~ywSzynpgwm%PU*MB;s4cJ6qoKn=`^Ucc0&ixhFP-+!TSo znFY}(^kgEi>QcH_tP{f^oBmXS3`!8lfM*wRXhwHwM#EUpO+##8>=Vt?UlW5m9z{RH zn-lcIm=yg`xACep?wR`raUnMz==;WxwfH4dleL|O80s4RrA<c0V0yWBVC`3A9jhC8 z<pE%_$ts^zs@g~3<%i(wzRApeE7xS}u>C;WsftgTwQtD<*~+zbaCzU93%P;5npfrG zWX%_HF|V#``?b85YdaP3g}Sl&RX1*HIZPi^{0n={SAiLwaa98~ox>$o10{BD%jI0V zs^tdVepL&!{W`PrI;#U#mn-U>#jG9UGhMtgp$a@;mRu#OwrNL$HFE8YmN!@vr<at| z8Z&QTRqGRT8&pGY+P(3U9}KxuO3Vo|$4`V9rP4`+69riYOS$y$Gl=7Jy|AMo;&LzL z5B~;1i4`>CC+2pOPCH&GxX1P!ejoakU2@OFiG=Ev25}9xAH>Qwiu&!|wYRU|=)HZd zX!BSZ^0qSY@$%Li&u`w`g0?BNpg&uM{a#WY(KU+N5I1m<iSxjqd+M0Vi&a1ilX=oB zOhT!!!o*|n8*ktDc}jL!toT4u^8Umc`?O3{X`jVLQJNJCZ`{23UjOE;_uuTlyZwGo z*@-xf1!94kmb$_d@HiDHy`TsoNPCOA+DLo4&B89(dV`5GwBTu4V5JJD<{-uGd^bqo z(cl)PpD<n+gVZ(Ce!yIl*j5;6CZ3|LWR+#JPKPwok(^lBCCsyHXr`uR=v93I|Bk+4 zn7XOA=rL^cHvS!b72~R58<=Bc64Yn_N-M<+IOm92l1n1SlxB&+SD7W$**vtA0lhA( zvUX@olMD!or^`AsNI7ML;v9n+D6=%mb!5cMgjuRJU8|?GOPs@n<BOzXlfc2*R8?8R zGY3p6746c)UqVN_t;gxYobZSeLC#1#M-91I@hml6G@n<*CXJP>h^;5MPX4VF=}+)F zBUPAky``@i9bJ46kR$vv0hsacQ%t@g|L%b=ig$22262)&1gB<V1b$*vpN$%`QIi~= zY?W?6w!vwWS*$v7fK9n@xTqYUB|GJsZmm~n5C0Cl6tBO0dd{4K(tYna$5<_{VEOoB zFPVyB8mXP3mpOMhj~&KCj+l9=yYw{zAr_X_R7sOmnNVp=N>Y#H^GIeSsjfLEsVzF< zapG#1SWF}qVp&FJ^hjbYy)pSOknDbdcSmG*ME8ey`we9`)&2TR_Zt)4Z%%X{p$5*G z!qQRwZ?P)b2&AI)AHJ?yCOyj4iI;&x$^DlgC&9^I$4O}caMUN{@o^xBj)e70Mfr-O z#N2IvjaZJ^33;|-#v)!M*fF=X^vFQ^CEh>BsuOmys*6_v_wmerlnPM7qWsKN3?zd0 zdYSUPghWWqU<-iIm_nwk9Ku2#=s9xebxm5OMys%9_6n06s-TlflB<F;jN;V9^K&5* zG0TRO@1JuFO3C!cYSjwSI7vIF$<!w}Ia5^vd?@+ZHC?<8*a-?L1yU5giNPF&uZ=h6 zX_UrcrL=OSHK&o*m`H1`mTApLDsWTMqS8JDEFOA$U8^LoLJ6-a5vL0)3pr24Gq?%4 zU1b-6`IxwDmh{!`UtvwwLZbnD0}sUyaUJs`6sQGg6a}<gY6p~P=?8?1-s>7_k0O2U zE_Ew~Eftx6i$O+SQA3<k5TE2e{gLKX@TfaJ!~n?*tVJbFtGSk2B>TKf1uy10<_4uo z>iw16z`TMv>MSH#*YXPHCgx?*^+9f8ZeeZ#-zs#3l9|FnjvAJ#QdAk2UJw@c)Tb#r zx>dJEOZ&+{yaSv{wYov0chMA<(xy3*6}1#teurn`byTEPF__};^smCt5wAm*KwMB9 z_%jBeUf(gq8uSI4UdGM?PyjfRKyg{YtE|S5@J`@$z~51DB!H|ngSP?yse&(1wKsz= z0e)Y>m#ONT!A}AHnS!6D>Td>L2mJR6zCl%B30L#;!0JLdR~q_6&#hd!e0kh_(__;h zE>K2m<LmF=xyOC!1hJEPdz7N7aE_EL<s#g3U}LJhK*&cfN|9bb(-Bo1nJA}*Ty&VQ z0>@t&qv({_F^XB~AI~8=!8(%>%EJ=wcv9`Ued`8c^x}B=M{2)18AVI-F=xTA!2I!r zlP?IF`Q0xUHfr1f>O2|zhW5O5t1N7hK99nZkUPk#MS^lM1Ii$h{IEX~0yU9C&XGIG zKmn(C0<G`9JYM=BNu0=w_om#+f<Mp=ubhA*-0t!+-ez<t?(m$u!7k#j7l9SX;c)?6 zfm?a;^7qH9H{xtGKqelP7$m~G%Y*;Y*}tZ!U$XNU0jPK(1`<I@z!X<p>wBY&D*`~~ zE+UMea5RcN)VCy}425C&Uce1;LQy6DPRuzgrI?L;;?H0dLf(E7rIa;Hc%r@&5aut8 zSGKv>4IoGyz6<N58-jlm;<pI#`RgYP#&M4j8G11zl(2M?MLKMxQ1l$hBb4`^*mIIy zXdRTWsNIft;^gCae4cbFAfzJT4vayB`ep%C8Sm=KbkV&AZ9Z=MKLqSgc(My<H00SG zSo~ujL(tmpa}=;pL))lZI0;QfqoNijckd#!7fnA2LzoMymrRgrz-N#oj!|Wya-mO9 zg*Bj0Euw<4ApffB|1z-E=>6iZC*bb=&=X1yWm>F4yDDEOJgQVoeLX0wkqp92l{-Zv z@`4!hiE!5<E$dLTM2-5~pz<_|nX0T;MTE+PRZ68|eHjxdq9~VNCf!8%9OGtjqOh;x rd&MZ^uhHr1W60E9qDSF!PInNb)+#7(Dt5!ZY%ka=cx=0FTXyIFe5uA9 literal 0 HcmV?d00001 diff --git a/near-rt-ric-simulator/__pycache__/main.cpython-38.pyc b/near-rt-ric-simulator/__pycache__/main.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4d2afa16cb4ad4624d825f6e3e6970f9239c8b76 GIT binary patch literal 4660 zcmcgw%WoV>8Sm=ud3(l>IDRB{(s7=X*q%6n1%ef=$pcobyk?UX*_P0#GgXe;)7>*v z*JR_-_+(CqNPFPG(MEg8WiLn^IUzv&2`z4%eBppN`NZ$59?v*y?+xKm*W;_NzWVBW zmp?0)iw6FJKm3s|&KSl&X>#%}gUN^Z;(s&4;09-b;if%vnVy@jse8+{bZ@&hdNas` zSvSiF*9vlB-pz*vw-6THVpwuZ8g2(8Vc9L~aVDsQqwZ)p=8lEq?sz!iPK4*&bK#^r zsn@f?`Ebge3a8!aaK@bpXWd!AbM6H(wP!Fx7~2=coS5eMx28KU=C?2L0x!N|y!6)O zBfR`8V~@F)HM}x_kMc1McQkyQPxSH6@ktH8qT%NU@F_m6;R_l*Gl0+X3mSe^!!Hit zb9`RIuW9%tez{NI;a4>Lx`r<d@UQY~8h%5=uk#7)F!c>?@SA$&re3)<xIvZQ*6>^W zj$0MCg}HrakMYH3=1V63E*5Fdmu3yIv}bBae-7OF{bjy<z#zFfUTf0ozd*Yts{Afr z;rHHJkS=>>RPP^>HLO=zVsChAt7<2ir-2tYldOmvURxwNDSp`zu}bovin!g1VgcOz zYcKG*r$jZIjI~>V-`J`9QLMbEA>yRmhhVNcaZ+e_LGaRRG~;A+vn3mX*JGiSAH9l` zi9YHkW<s{5AE~6U)rwV2IN+w-*b<Fq-D~@8u$SbH2UlJRRgXLEc1tP{#6BT6J)B;b zeKwPE@kU9nq3T4h9(keY78PK%cHsF@mAT__TQvMlzu_sr71g;fk66vMe*EM)u9ypj z+G_E*LGn5IM;`MCUtB?>AVqE}#;vy&q-n1w<|jWr{2Nx@K}w+yB0FtSHDwl{r1<>F zi|6%?kJmn0e`m;9fOK>8q_))xMQ!V4E%w7DZ)It4omwP3xg^z+^czc9>;#@_$yzKM zwP(*C*H@NTmhaa>TxYqxlh_J+x(TYWiN>(xMYP@XwMHvaKoRnUm`+^_?w?+ZI90}; z@eEghUC1%ahrFhv3xFk)XVG24%JK2@7<b2NTm(XifqA(0#wX97pE`da)`!@ojD2<h zw^wGrx6+;)%I0hpK?l9LYN$+qJ<Ba_s~pd0HDuQlyV2qz$>3~nr#rV61Wsyc&VUam z<%`SnI8aWZspe%KU6N@8kh&}ooT8^JQ8Pjf2}dH1o-L8Fl;qGA?gLZXiDBj0@F%YT z-Yxbe1MfH`jWe_%=dcO-puK16qu4(k^gaYmss&RnVBD?LwC5fB#;Nn@-j8V024PPs zW1H=poE<P_k-UFyL~}M|-Ym+y40@rEovwUtMCJ?V0Zx!5$SeZ!G*SY-llqXCi0=8P z<o?bv7Y^y@fz!S0z}Fox=(Hl?#0Uj}aMo4^ctZ`n%S*D8#P%eDhlLoRb(0jHylIFw zd2#A!R;=W=tEv2+ES}P}b&|A9HpwdZ$y>y2DV3Qvq5r?YE)xsoRA8C~2x=aJY7B%0 zJ)e|PJQS0>ip^)+h`zd}_p>wZU8O^FwKQ<M*2ZV=`zgtO;HQ7aWN0V5Mh`a8%*zE> zfypiSr%k@tBOlEk7|on~jFn8!fMsOy<&H7>H1Y>*m-SF`fW{^;3qu-xj3O{h-`KT! ztY`5OqQFQGwzg~cP@psm^7lOx@baqBvw3CO=$U%WQn{X?VWWWI^j%w7z!<~%<2qVQ ztS9+2IQabN=7uMcDUeN^)nnj8C-h@7O9T%XrA~*3U&2M-nMpR4m7In&j*1&P75e;v zb5wGo78!LX;>(A>1+rWw;a)#MKizs3^&~5W7q_CMEF!J3XF8R3D`~GyK((B~@~0ZR zn{m8|JKeJOrIh;z&d@9n-$;A%8a3Cc8HO_*`0S?GiFMqoX52zbpzd?cxx9xBiP?tR zh4HHs#-(#X0Un%Q=NCYW=>)?XLCCAH5jKS{9od5*NRSaGzYjb(S}Y=-Zhz0wh}%JA z`UfWe6MKUV&KkRn>;k>ny`b{jg`TO3`=uTt9?$c_TWi-s%v(rf9jvjaMtY`>Y^Bt0 zv&QGhkS~m$wOxiCqW#dY4a;a6@@rmh+VU@v&5URgdn>dGi|_A*PgwiKgJU~HkvgzL zc^h|>cc@vUhLWkQQFE7?6*Nz)W@2x{G~DcKA^pvr?#&I9H%=-&XVdco!50x(I|0`g zNTPLA>w)9{2S#}KSJ3e9VAQ>IdY|)!ueSP8S)0w#nAdKjy3++xjgCzdW#!uqNoURP z61x;rlYHM_;>2!)Px%7^W_TxT$C65wq?B@Ar(96Yq!Rdm7R<&=*QQjF*r+tUZ(3Y& zXfqw4$CO|UQyUuEDU-6T$u6)gn_~`}#9aOe7-VePm#9{H&)6W7p|O2Ts5%YqQW0YH z3<MuagA4sM_(9(^GP?dl`SI2|HVKu%4j30q$>y1UWtd&>-gv%+?4}QQ=thnoL)KDu z+R8!h>&KYoRP|Jkq@MdjjE+5bji9LrgO<l*d4m8$FQ(cFC4xp9l$TO_XmNP$-vBG7 za>g)C$cHlCq$wX`-knFW*r8gwwhCn-<UQ!mseFFeAQ>J1*%%Cx!JjZe0$@#3UQ&i) z%2d`K!&}9KyXe{&t2S1@gNm7og&{NxXaJdI_j3m*9w-TH=XXt_0;e>|?RahmuKEpX zdF=Z&FYFf-B?b%FIFXy1CM6wS#OhZ>gO^V3!|5YB1(8Emj=A7)<?86VTaG&6uy`8= zPPae{RLRE)yXzJP<@q5A#2t|$Y$>7N8SxQYbVo?NNU}a$bVm|SxAG{Jt3!fBP#!pR zwUp{lJA)O7NY|ig@j_*MVz%NWi%O^Q1y3?<Pb#?5cFT`s8LL&>EuGL%!rBPY?Ife0 zP^VmmsHANC4trxND5)@=($SgXah6@exTxdxgej>Q^uI;~J|s>gRZ86wy*t)cmUp}` zNb>bMJwEF7Zeiu#_m=PCxAL@Vk*`aY*u;gKS6fJCT<|I+hbKcM-cX&Ut=Ni@Z$2X0 zt7wuOz3~G7rKIEB%qBfVrA5nRY-!9PV|R-biefwsLr>-iF#6h)buJnKvbQb+DQ%ot z!IRYRKMHW&XoVpdp=X>NrDlwpacZc-cda!@5;r7`)$56cQ0Qi4s{`+#hn1w~O<IjF z(C8L5R6yyZrh|?4DJ?~}L=vgPj9v;Ue*!FB!@f?6J_-xCCLYd-1-o){9_RGjO)S}o zPH0fOv-aftYS`kPKs=lPnRp$|;AMf7I|Jo8Y{s(9tXZ)tteEM4BmKUJzJzZY-_%$- Op0L>%n_xu~KlWcorAw&* literal 0 HcmV?d00001 diff --git a/near-rt-ric-simulator/__pycache__/maincommon.cpython-38.pyc b/near-rt-ric-simulator/__pycache__/maincommon.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..28076139988fa26400390ec78075ec0f76afc894 GIT binary patch literal 1537 zcmZ8h&2J+$6t~Com1z^YP*`@6mf^NpDGA*JNYR3bwxL}K+NurOWrQ@EjNNA1`C8lk ziYBLpBN7MBDCNdq!Ii(kS5EyGxWMxyv;|x9{A@ql@4ese%{R@ahoISi|4z?cg#Of% zyN$r)3;4ts1Vt35C|Ha*z%VybBO?L9dX1!JW(8KQ<J1o9+TIBqY6dPt^9Hr9aNtp! zI^UyUg}Sr><0|#&3XDyP4^Vsc8s0%WZLG|_NKRmM_n9b*T(D_t<LRf}kD+h$pF#`P z_lIBaj)vj(?!o9F{Azb=>&4Ditk2(VI)dl$iANwL_<7>;hZ0l#24f_RIibcCXcWQg zWM}FR^D}?2_hN4_+V=B8`hv->KfFj}k{@-UU1PYXZ7L@!lM-B1R>_lGDk3h0G8q{D zhIj*PYVp^z-lWJ_Z!+#h8y&D?{4k1H=WL^wvxs-N?C>P+h$K5rBU$iX7A1LHWLc4S z%S+XaCoDb*mrp&^Vb~xLcA@hX(Ebyzj#cm1@g9RBk;HT33cbNIRH0)s!!S1~zQQx3 zf<Cu&^q--nP8RyyzCw^2z)iXpmW>K>MXmSI1GwitqV|0R>qf0R8pR(8<j&ifl5V%B z?1lGJSICIVu9!^Ud49?{%cXx4e&6RNcsKpT_Xla}i_@|!xMb8HY}^|8mr<4qnEP^) z2tO`z3Atgs?_d9+4||eb$X=PkqNYifWK3R`tnG0Fwv|x`WgjsapHqMcToKAi6Cr8B zm6ha_T_{t)t6V1y(34z|l;v%raH)*43`oTJEs$K-iTVgG3~$^GZvqk_U$WE(GtmNp z@G7>k2Xa+o^#E34?byG~0R<{<fz_{|)ZA?FpDTO}m}!h^u0EDTuTVp0e`e&Z<s2{O zl*|a=Xi~tAk19i26#=x+4`4qtrjMjOcPha6J2Eq8*37QZ+^tN__?PJQFD8<W6OaFd z0dEWpfxWsKzJ<M4DEIUVt*z_&uy%s=?a^p2d=-AVyZ>^qzd790np#<w;$U-gf9mx6 zhtT@L<Fq(Bg0cyVL9NES{CA;Ub%m<XY`LY7D4l+m`Q*6$dIaCuNUEI&(lkt+g; z=kG$6lvndgoF{U^-_r}WDB=?)RTE6~_2bKkQUDXAY78%8R?4Kv+m34JT@gY-D~Ge! zr%ZrSJCu~lE;&0)fD_s|WkqQc3ALhcVnS%%{GST<fPFlQ<!wk$z#E}!RF~%(UNc(Q z1OlvK1HKmYw+*gs+AaPT3|uonIr<-xCgTNZt-~}DCp9JchkBd9<J{7k<}zf1f1r=* q%C9L^UwFs0`o~jK)qR!~^fYCkH^Ek{gV6ts1sh#r8Xj?N*ZT)fql@kU literal 0 HcmV?d00001 diff --git a/near-rt-ric-simulator/__pycache__/utils.cpython-38.pyc b/near-rt-ric-simulator/__pycache__/utils.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..aa958261a4cb89274089866b4a90c1a3b9ab3185 GIT binary patch literal 360 zcmYjMJ5B>J6nxLSiB>>>E+FLsTP&+oP(%och%!w?gG8~c4Y9I6Y%fwIZxs##B@Jib z9Bw%R9SuAOA>~Ok_ITdNn(M(}2WZ}ZKKLX6`1E3X7>Nsl-Xr3`@fmJ_vpK{;j`Z|D zl!YGQlAxzV96PjNU>T`1L$??93TvFg?WkiGO<>s?hhRbrmK~Ebgbp8%s)!s?bFhS% z%^bu%7jl^!*VnZ&g1c}jR@w#HD0h%&MSdl#2ca4zD-#C}8;7Ms`3A~2`#wz<bt%%t zU7C#(S`q3#%SG}uPAieAM43d%Jkhdji_Fw2ZH+ASNwZRYO7HtNzByos5gy`*MYwTh Z@!z@mWQ%rb*F}@E=4~O)eg4bGe*yW*Pm%xt literal 0 HcmV?d00001 diff --git a/near-rt-ric-simulator/__pycache__/var_declaration.cpython-38.pyc b/near-rt-ric-simulator/__pycache__/var_declaration.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a63e44cebc38c86e54bf0e73b8717de5c532d61b GIT binary patch literal 319 zcmYjNu};G<5OtaqQbYhT^dCB;Q8$JN!4I$?mM+oNzBCq&9obH$%zOc#!B_AfUik|q z&TR+o^xoaOd&}KhQCu;KhtF@ZOd0!$;(ySLJrUfRNV082LYNU!!7vp`&5m_e$6bc= z54OD!?3Jz3mymHIFw6xim{ynJZZJynsgc@w&>UST&J)spbYa0ksU7fl7j9c)If}-i z_fqd&xIbH4QfLP&wGSz6!=f|JyJ-AkHlA~&-{-0`JyzYWf=x+gv@LKf51UFO*wXsa rN?tnIj|#l8)d6fHkSnm@rP1qQ3VGcdF)Dn#jxV?&%92y&Nlx7#bo*P< literal 0 HcmV?d00001 diff --git a/near-rt-ric-simulator/src/STD_1.1.3/a1.py b/near-rt-ric-simulator/a1.py similarity index 99% rename from near-rt-ric-simulator/src/STD_1.1.3/a1.py rename to near-rt-ric-simulator/a1.py index d7169b1..5310334 100644 --- a/near-rt-ric-simulator/src/STD_1.1.3/a1.py +++ b/near-rt-ric-simulator/a1.py @@ -1,5 +1,5 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2023, S. K. Chaudhary, All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/near-rt-ric-simulator/api/OSC_2.1.0/openapi.yaml b/near-rt-ric-simulator/api/OSC_2.1.0/openapi.yaml deleted file mode 100644 index 828a6bf..0000000 --- a/near-rt-ric-simulator/api/OSC_2.1.0/openapi.yaml +++ /dev/null @@ -1,349 +0,0 @@ -# ================================================================================== -# Copyright (c) 2019-2020 Nokia -# Copyright (c) 2018-2020 AT&T Intellectual Property. -# Copyright (c) 2020 Nordix Foundation, Modifications -# -# 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 -# -# 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. -# ================================================================================== -openapi: 3.0.0 -info: - version: 2.1.0 - title: RIC A1 -paths: - '/a1-p/healthcheck': - get: - description: > - Perform a healthcheck on a1 - tags: - - A1 Mediator - operationId: a1.get_healthcheck - responses: - 200: - description: > - A1 is healthy. - Anything other than a 200 should be considered a1 as failing - - '/a1-p/policytypes': - get: - description: "Get a list of all registered policy type ids" - tags: - - A1 Mediator - operationId: a1.get_all_policy_types - responses: - 200: - description: "list of all registered policy type ids" - content: - application/json: - schema: - type: array - items: - "$ref": "#/components/schemas/policy_type_id" - example: [20000, 20020] - 503: - description: "Potentially transient backend database error. Client should attempt to retry later." - - '/a1-p/policytypes/{policy_type_id}': - parameters: - - name: policy_type_id - in: path - required: true - schema: - "$ref": "#/components/schemas/policy_type_id" - get: - description: > - Get this policy type - tags: - - A1 Mediator - operationId: a1.get_policy_type - responses: - '200': - description: "policy type successfully found" - content: - application/json: - schema: - "$ref": "#/components/schemas/policy_type_schema" - '404': - description: > - policy type not found - '503': - description: "Potentially transient backend database error. Client should attempt to retry later." - delete: - description: > - Delete this policy type. Can only be performed if there are no instances of this type - tags: - - A1 Mediator - operationId: a1.delete_policy_type - responses: - '204': - description: > - policy type successfully deleted - '400': - description: > - Policy type cannot be deleted because there are instances - All instances must be removed before a policy type can be deleted - '404': - description: > - policy type not found - '503': - description: "Potentially transient backend database error. Client should attempt to retry later." - put: - description: > - Create a new policy type . - Replace is not currently allowed; to replace, for now do a DELETE and then a PUT again. - - tags: - - A1 Mediator - operationId: a1.create_policy_type - requestBody: - content: - application/json: - schema: - "$ref": "#/components/schemas/policy_type_schema" - example: - name: admission_control_policy - description: various parameters to control admission of dual connection - policy_type_id: 20000 - create_schema: - $schema: 'http://json-schema.org/draft-07/schema#' - type: object - properties: - enforce: - type: boolean - default: true - window_length: - type: integer - default: 1 - minimum: 1 - maximum: 60 - description: Sliding window length (in minutes) - blocking_rate: - type: number - default: 10 - minimum: 1 - maximum: 100 - description: '% Connections to block' - trigger_threshold: - type: integer - default: 10 - minimum: 1 - description: Minimum number of events in window to trigger blocking - additionalProperties: false - - responses: - '201': - description: "policy type successfully created" - '400': - description: "illegal ID, or object already existed" - '503': - description: "Potentially transient backend database error. Client should attempt to retry later." - - '/a1-p/policytypes/{policy_type_id}/policies': - parameters: - - name: policy_type_id - in: path - required: true - schema: - "$ref": "#/components/schemas/policy_type_id" - get: - description: "get a list of all policy instance ids for this policy type id" - tags: - - A1 Mediator - operationId: a1.get_all_policy_identities - responses: - 200: - description: "list of all policy instance ids for this policy type id" - content: - application/json: - schema: - type: array - items: - "$ref": "#/components/schemas/policy_instance_id" - example: ["3d2157af-6a8f-4a7c-810f-38c2f824bf12", "06911bfc-c127-444a-8eb1-1bffad27cc3d"] - '503': - description: "Potentially transient backend database error. Client should attempt to retry later." - - - '/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}': - parameters: - - name: policy_type_id - in: path - required: true - schema: - "$ref": "#/components/schemas/policy_type_id" - - - name: policy_instance_id - in: path - required: true - schema: - "$ref": "#/components/schemas/policy_instance_id" - - get: - description: > - Retrieve the policy instance - - tags: - - A1 Mediator - operationId: a1.get_policy_instance - responses: - '200': - description: > - The policy instance. - the schema of this object is defined by the create_schema field of the policy type - content: - application/json: - schema: - type: object - '404': - description: > - there is no policy instance with this policy_instance_id or there is no policy type with this policy_type_id - '503': - description: "Potentially transient backend database error. Client should attempt to retry later." - - delete: - description: > - Delete this policy instance - - tags: - - A1 Mediator - operationId: a1.delete_policy_instance - responses: - '202': - description: > - policy instance deletion initiated - '404': - description: > - there is no policy instance with this policy_instance_id or there is no policy type with this policy_type_id - '503': - description: "Potentially transient backend database error. Client should attempt to retry later." - - put: - description: > - Create or replace a policy instance of type policy_type_id. - The schema of the PUT body is defined by the create_schema field of the policy type. - - tags: - - A1 Mediator - operationId: a1.create_or_replace_policy_instance - requestBody: - content: - application/json: - schema: - type: object - description: > - the schema of this object is defined by the create_schema field of the policy type - example: - enforce: true - window_length: 10 - blocking_rate: 20 - trigger_threshold: 10 - - responses: - '202': - description: > - Policy instance creation initiated - '400': - description: > - Bad PUT body for this policy instance - '404': - description: > - There is no policy type with this policy_type_id - '503': - description: "Potentially transient backend database error. Client should attempt to retry later." - - '/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}/status': - parameters: - - name: policy_type_id - in: path - required: true - schema: - "$ref": "#/components/schemas/policy_type_id" - - - name: policy_instance_id - in: path - required: true - schema: - "$ref": "#/components/schemas/policy_instance_id" - - get: - description: > - Retrieve the policy instance status across all handlers of the policy - If this endpoint returns successfully (200), it is either IN EFFECT or NOT IN EFFECT. - IN EFFECT is returned if at least one policy handler in the RIC is implementing the policy - NOT IN EFFECT is returned otherwise - If a policy instance is successfully deleted, this endpoint will return a 404 (not a 200) - tags: - - A1 Mediator - operationId: a1.get_policy_instance_status - responses: - '200': - description: > - successfully retrieved the status - content: - application/json: - schema: - type: object - properties: - instance_status: - type: string - enum: - - IN EFFECT - - NOT IN EFFECT - has_been_deleted: - type: boolean - created_at: - type: string - format: date-time - - '404': - description: > - there is no policy instance with this policy_instance_id or there is no policy type with this policy_type_id - '503': - description: "Potentially transient backend database error. Client should attempt to retry later." - -components: - schemas: - policy_type_schema: - type: object - required: - - name - - description - - policy_type_id - - create_schema - additionalProperties: false - properties: - name: - type: string - description: name of the policy type - description: - type: string - description: description of the policy type - policy_type_id: - description: the integer of the policy type - type: integer - create_schema: - type: object - description: > - jsonschema (following http://json-schema.org/draft-07/schema) of the CREATE payload to be sent to handlers of this policy - - policy_type_id: - description: > - represents a policy type identifier. Currently this is restricted to an integer range. - type: integer - minimum: 1 - maximum: 2147483647 - - policy_instance_id: - description: > - represents a policy instance identifier. UUIDs are advisable but can be any string - type: string - example: "3d2157af-6a8f-4a7c-810f-38c2f824bf12" diff --git a/near-rt-ric-simulator/api/STD_2.0.0/ORAN_A1-p_V2.0.0_api.yaml b/near-rt-ric-simulator/api/STD_2.0.0/ORAN_A1-p_V2.0.0_api.yaml deleted file mode 100644 index 3cb62c5..0000000 --- a/near-rt-ric-simulator/api/STD_2.0.0/ORAN_A1-p_V2.0.0_api.yaml +++ /dev/null @@ -1,341 +0,0 @@ -openapi: 3.0.0 -info: - title: 'A1-P Policy Management Service' - version: 2.0.0 - description: | - API for Policy Management Service. - © 2020, O-RAN Alliance. - All rights reserved. -externalDocs: - description: 'O-RAN.WG2.A1AP-v02.00 A1 interface: Application Protocol' - url: 'https://www.o-ran.org/specifications' -servers: - - url: '{apiRoot}/A1-P/v2' - variables: - apiRoot: - default: 'https://example.com' - description: 'apiRoot as defined in clause 4.2.1 in ORAN-WG2.A1.AP' -paths: - '/policytypes': - get: - operationId: a1.get_all_policy_types - description: 'Get all policy type identifiers' - tags: - - All Policy Type Identifiers - responses: - 200: - description: 'Array of all policy type identifiers' - content: - application/json: - schema: - type: array - items: - "$ref": "#/components/schemas/PolicyTypeId" - minItems: 0 - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policytypes/{policyTypeId}': - parameters: - - name: policyTypeId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyTypeId" - get: - operationId: a1.get_policy_type - description: 'Get the schemas for a policy type' - tags: - - Individual Policy Type - responses: - 200: - description: 'The policy type schemas' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyTypeObject" - 404: - "$ref": "#/components/responses/404-NotFound" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policytypes/{policyTypeId}/policies': - get: - operationId: a1.get_all_policy_identities - description: 'Get all policy identifiers' - tags: - - All Policy Identifiers - parameters: - - name: policyTypeId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyTypeId" - responses: - 200: - description: 'Array of all policy identifiers' - content: - application/json: - schema: - type: array - items: - "$ref": "#/components/schemas/PolicyId" - minItems: 0 - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policytypes/{policyTypeId}/policies/{policyId}': - parameters: - - name: policyTypeId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyTypeId" - - name: policyId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyId" - put: - operationId: a1.put_policy - description: 'Create, or update, a policy' - tags: - - Individual Policy Object - parameters: - - name: notificationDestination - in: query - required: false - schema: - "$ref": "#/components/schemas/NotificationDestination" - requestBody: - required: true - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - responses: - 200: - description: 'The policy was updated' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - 201: - description: 'The policy was created' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - headers: - Location: - description: 'Contains the URI of the created policy' - required: true - schema: - type: string - 400: - "$ref": "#/components/responses/400-BadRequest" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - 507: - "$ref": "#/components/responses/507-InsufficientStorage" - callbacks: - policyStatusNotification: - '{$request.query.notificationDestination}': - post: - description: 'Notify about status changes for this policy' - requestBody: - required: true - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyStatusObject" - responses: - 204: - description: 'Notification received' - get: - operationId: a1.get_policy - description: 'Query a policy' - tags: - - Individual Policy Object - responses: - 200: - description: 'The requested policy' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyObject" - 404: - "$ref": "#/components/responses/404-NotFound" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - delete: - operationId: a1.delete_policy - description: 'Delete a policy' - tags: - - Individual Policy Object - responses: - 204: - description: 'The policy was deleted' - 404: - "$ref": "#/components/responses/404-NotFound" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - - '/policytypes/{policyTypeId}/policies/{policyId}/status': - parameters: - - name: policyTypeId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyTypeId" - - name: policyId - in: path - required: true - schema: - "$ref": "#/components/schemas/PolicyId" - get: - operationId: a1.get_policy_status - description: 'Query a policy status' - tags: - - Individual Policy Status Object - responses: - 200: - description: 'The requested policy status' - content: - application/json: - schema: - "$ref": "#/components/schemas/PolicyStatusObject" - 404: - "$ref": "#/components/responses/404-NotFound" - 409: - "$ref": "#/components/responses/409-Conflict" - 429: - "$ref": "#/components/responses/429-TooManyRequests" - 503: - "$ref": "#/components/responses/503-ServiceUnavailable" - -components: - schemas: - # - # Representation objects - # - PolicyObject: - description: 'A generic policy object that can be used to transport any policy. Additionally, a policy shall be valid according to the schema of its specific policy type.' - type: object - - PolicyStatusObject: - description: 'A generic policy status object that can be used to transport any policy status. Additionally, a policy status shall be valid according to the schema of its specific policy type.' - type: object - - PolicyTypeObject: - description: 'A definition of a policy type, i.e. the schemas for a policy respectively its status' - type: object - properties: - policySchema: - "$ref": "#/components/schemas/JsonSchema" - statusSchema: - "$ref": "#/components/schemas/JsonSchema" - required: - - policySchema - - ProblemDetails: - description: 'A problem detail to carry details in a HTTP response according to RFC 7807' - type: object - properties: - type: - type: string - title: - type: string - status: - type: number - detail: - type: string - instance: - type: string - - # - # Simple data types - # - JsonSchema: - description: 'A JSON schema following http://json-schema.org/draft-07/schema' - type: object - - NotificationDestination: - description: 'A complete callback URI defined according to IETF RFC 3986 where to send notifications' - type: string - - PolicyId: - description: 'Policy identifier assigned by the A1-P Consumer when a policy is created' - type: string - - PolicyTypeId: - description: 'Policy type identifier assigned by the A1-P Provider' - type: string - - responses: - 400-BadRequest: - description: 'Object in payload not properly formulated or not related to the method' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 404-NotFound: - description: 'No resource found at the URI' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 405-MethodNotAllowed: - description: 'Method not allowed for the URI' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 409-Conflict: - description: 'Request could not be processed in the current state of the resource' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 429-TooManyRequests: - description: 'Too many requests have been sent in a given amount of time' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 503-ServiceUnavailable: - description: 'The provider is currently unable to handle the request due to a temporary overload' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - 507-InsufficientStorage: - description: 'The method could not be performed on the resource because the provider is unable to store the representation needed to successfully complete the request' - content: - application/problem+json: - schema: - "$ref": "#/components/schemas/ProblemDetails" - - diff --git a/near-rt-ric-simulator/src/STD_2.0.0/callBack.py b/near-rt-ric-simulator/callBack.py similarity index 79% rename from near-rt-ric-simulator/src/STD_2.0.0/callBack.py rename to near-rt-ric-simulator/callBack.py index 0e8e416..1ae8964 100644 --- a/near-rt-ric-simulator/src/STD_2.0.0/callBack.py +++ b/near-rt-ric-simulator/callBack.py @@ -1,18 +1,14 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2023, S. K. Chaudhary. All rights reserved. # ======================================================================== -# 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 -# +# # 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. # ============LICENSE_END================================================= + # import json @@ -38,6 +34,6 @@ def statustest(): return Response(json.dumps(data), 200, mimetype='application/json') -port_number = 2223 +port_number = 2222 app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/certificate/cert.crt b/near-rt-ric-simulator/certificate/cert.crt deleted file mode 100644 index 51e37a7..0000000 --- a/near-rt-ric-simulator/certificate/cert.crt +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN CERTIFICATE----- -MIICljCCAX4CCQDVlvlNzxH9FzANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT -RTAeFw0yMDA0MjgxOTE2MTNaFw00NzA5MTMxOTE2MTNaMA0xCzAJBgNVBAYTAlNF -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqpnXP5VmOvMPOTWaxWvm -zfSBRvnioEFHoriGld+pW+vvvrma9UiWfxX3GaGFItxuwbwLwqwvR2LDo6wQQpbl -SaNhg89DYD/NZvlRlLNcYOL218LjfFf4xaKVQGBHfT0Ts9JGTbTD/zcR2VS+3DUR -lvLzbNpQ+Rdvwls7wsL1ZblR+1lry9HMGKCrtsYDSOMSyGqE40u1bOYAw1+VMrfp -cK14u9toNPIbvk+HDP5yYnjC4FEp0ai07s3T6YDWHvp0WNIFJHCVFYzYQgS79/2b -8zg4H7ZMQ5XjxcenU6f8Q97nN0VMk46LIutGe/7rYO0uYKrHcJz1qUu1ui96zOVC -DQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBGvmFRHuUESpwijkekR0WFBuW6UNE5 -J7cZ9CXm7Mz06jeTAZWoCWVAZjYnpQ/MjvyzFglD9wL+A6LblIU+yNctYwtfspAq -xDYmBKlhsKzlgZ3fyBUlfrM5BFxZR2uu1/4bUU4geEQrI2rYzif3Flj0a55EIeSa -37fa7Acc+nNfy47mAa8Dsog6LHMs+FXGmuMS31c9lc70c9v4jCArctdDn/zKg9A7 -HCwd0+icgyDD+9U9eBhcFreBWyA1tPREWyx0qbhlw43OsVMpB6VM4exLGs/v1e0x -/Nmmsis1o54eu2cLGjr5EYlDmdFD3Dn458r0zFkxg4CE23lRUtFz8d6F ------END CERTIFICATE----- diff --git a/near-rt-ric-simulator/certificate/key.crt b/near-rt-ric-simulator/certificate/key.crt deleted file mode 100644 index 380e145..0000000 --- a/near-rt-ric-simulator/certificate/key.crt +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIoefVgflG3OYCAggA -MB0GCWCGSAFlAwQBKgQQEaJvnbiOIkAwGcyqi6eYCQSCBNDnK9PT/NdGvZAriJAg -VYbqJiCxrqfrfRDAKU4Z4GWFnodzLt2+Xe6iEeOmCkCfs/oVaWx+yIMFzZKY2sq/ -jMmiihJggV+R+hIEXBsVnvqL/nqbchQ7ckhJK8ofXMcpdUdCd8CHylRPNmNNfMsu -o3BbDjKEdCtWMmBWuMWI3DtF0U5Tu5d+nH2ZHpl7YtA7U+N5w3nWBlxoPVXmqsEH -YE8cL0C/b+nFNs81FXKlbIPGNSv51c5YPjS0WQneci2Vj9JMPHWT6VMCaxVlv3js -droG6AxzHH+UpB1Lx4BfVunHR79nmhzmH9mo74rWCiYZ+Kh7DnC26WHrJW/tqJX8 -AvDPIEyVsQ8JQH7omBviVs6NCwoDCwS7jX0NUTy2aWgd4feI+BLwt9SDpEIzyQHt -YXZnwREd2ymDhS0ewvC4fjV82PJHc/yGBlNnXTh4er8hpUPjxTIuNZGaaWP7fcYP -qqPuyfTZvTkKtzHKYsrOk6Fq7M5kMGjFBrGWK3dCNptCXM/R8gaxRqcOvEOb9G5g -ISlC+TZy5T/EUZXJUJEK3gGMrQY4LYCxGm71Wnwe89zmC6bK/z/2XvNts867YKU+ -pODWHcxntJhwlzBRLL56dn2T0OhJEiynUMtpm45O3bHBtRkMjlQ5BhNic0Tog6fb -757gJnbnSNFB5mCSkB09iPt8LEEamQGYUGbXE+0mPTdqwaAaKbz4Gh1yV3T9alh+ -AxJu/YaB52mmf2KdFVUuPBVzSMawYvp6hXHIgzJ6tb/GmYFI7P21RBQfVR/fKuJx -pQMgRclNdYCAC0VCqHxSZdO0Lu7Sd/SWybCCNbfw+0tEO1fDlZwWbVQiF79AL62J -VvaWX3pX8IF227astnyMxkCH6MB4fvu7CSZKTYgdkXekP81Ck5ZxStRcSj4jOvYj -xuMqIvGzy16JRG1aGE1jpzunYBdDKiKKOIphH+jBK3NPk3b7wkTLxi7IkdS4MUf1 -e5E50W/Xx3wUlfyBvuc1TQy/1Moh+HvXIIG3JHU9MjfPkYwHvDITWIdXJb1vSEAE -opi+zNt7C5A+mC1/CC2MCjHk+g+cqpLcSFmv9MXnhg8bHmuhSjaXWChD8sj/S7H4 -Kazc87gikvQguxFv+bFiVQ6+GdPcGvsrnh+UFn/kfHUM8wt2AWnrKc8OLWXbs8Ge -0bCqXo1uy2sZEv558BGRKI35c/F4sovf0FLe8+M+UHPqOeYVaxSt9accXTHK2ajN -IEEKuL5v0BDNTQqo0uDw0HJyKW+L55UpJQ9nNSdVjtQUnPJtbWlVg0V2Q7mnVOSF -GRMqBtu+U9sejR03odkURjDFULntSw80M+U0LC+ceOrESLkO0AK2Yub1+IhR3OBh -jICv3eTZbqZ27ltZrsyDTAYoRVnTvPQwSZoUJ6cQS6XgLa3QitDcj+Zqch9z7sV2 -ydkEHEbLXPIt/sQyASluKm5j1tHJVtzwezb5GO54WYwdpy3MmZ3VhXsagJc9oLHX -MtsDGZR0hXMgzPp49leBhcieWW6fWXAZKt2oa64eI/12i2wSTjNsxPfsu45tJYXO -GAPL0OYBKeVLi1Pfa3kCLqlMDAyC4GzTScWXad5/FEeo189JU1aGcJn7Gn7Ao805 -wuOOs1TQk+KHvAFDEGkkJEM0lg== ------END ENCRYPTED PRIVATE KEY----- diff --git a/near-rt-ric-simulator/certificate/pass b/near-rt-ric-simulator/certificate/pass deleted file mode 100644 index 30d74d2..0000000 --- a/near-rt-ric-simulator/certificate/pass +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/near-rt-ric-simulator/container-tag.yaml b/near-rt-ric-simulator/container-tag.yaml deleted file mode 100644 index 51b0588..0000000 --- a/near-rt-ric-simulator/container-tag.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -tag: 2.1.0 diff --git a/near-rt-ric-simulator/src/STD_1.1.3/main.py b/near-rt-ric-simulator/main.py similarity index 96% rename from near-rt-ric-simulator/src/STD_1.1.3/main.py rename to near-rt-ric-simulator/main.py index 5742791..0d9f00a 100644 --- a/near-rt-ric-simulator/src/STD_1.1.3/main.py +++ b/near-rt-ric-simulator/main.py @@ -1,5 +1,5 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2023, S. K. Chaudhary. All rights reserved. # ======================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -33,13 +33,13 @@ check_apipath() -app = connexion.App(__name__, specification_dir=apipath) +app = connexion.App(__name__) #Check alive function @app.route('/', methods=['GET']) def test(): - return Response("OK", 200, mimetype=TEXT_PLAIN) + return Response("This is connection Test and the status is OK", 200, mimetype=TEXT_PLAIN) #Return the current and all supported yamls for the this container @app.route('/container_interfaces', methods=['GET']) @@ -176,4 +176,4 @@ def getcounter(countername): app.add_api('STD_A1.yaml') if __name__ == '__main__': - app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file + app.run(port=port_number, host="127.0.0.1", threaded=False) diff --git a/near-rt-ric-simulator/src/common/maincommon.py b/near-rt-ric-simulator/maincommon.py similarity index 86% rename from near-rt-ric-simulator/src/common/maincommon.py rename to near-rt-ric-simulator/maincommon.py index 7dc8024..b04ef41 100644 --- a/near-rt-ric-simulator/src/common/maincommon.py +++ b/near-rt-ric-simulator/maincommon.py @@ -1,12 +1,7 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2023, S. K. Chaudhary. All rights reserved. # ======================================================================== -# 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 -# +# # 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. @@ -23,7 +18,7 @@ import ssl #Must exist -apipath=os.environ['APIPATH'] +apipath='127.0.0.1:2222' #May exist remote_hosts_logging=os.getenv('REMOTE_HOSTS_LOGGING') diff --git a/near-rt-ric-simulator/nginx.conf b/near-rt-ric-simulator/nginx.conf deleted file mode 100644 index 3087a3f..0000000 --- a/near-rt-ric-simulator/nginx.conf +++ /dev/null @@ -1,122 +0,0 @@ -user www-data; -worker_processes auto; -pid /run/nginx.pid; -include /etc/nginx/modules-enabled/*.conf; - -env ALLOW_HTTP; - -events { - worker_connections 768; - # multi_accept on; -} - -http { - - ## - # Basic Settings - ## - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - # server_tokens off; - - # server_names_hash_bucket_size 64; - # server_name_in_redirect off; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - perl_set $allow_http 'sub { return $ENV{"ALLOW_HTTP"}; }'; - - server { # simple reverse-proxy - listen 8085; - listen [::]:8085; - server_name localhost; - if ($allow_http != true) { - return 444; - } - - # serve dynamic requests - location / { - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://localhost:2222; - } - } - - server { # simple reverse-proxy - listen 8185 ssl; - listen [::]:8185 ssl; - server_name localhost; - ssl_certificate /usr/src/app/cert/cert.crt; - ssl_certificate_key /usr/src/app/cert/key.crt; - ssl_password_file /usr/src/app/cert/pass; - - # serve dynamic requests - location / { - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://localhost:2222; - } - } - ## - # SSL Settings - ## - - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE - ssl_prefer_server_ciphers on; - - ## - # Logging Settings - ## - - access_log /var/log/nginx/access.log; - error_log /var/log/nginx/error.log; - - ## - # Gzip Settings - ## - - gzip on; - - # gzip_vary on; - # gzip_proxied any; - # gzip_comp_level 6; - # gzip_buffers 16 8k; - # gzip_http_version 1.1; - # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; - - ## - # Virtual Host Configs - ## - - include /etc/nginx/conf.d/*.conf; - include /etc/nginx/sites-enabled/*; -} - - -#mail { -# # See sample authentication script at: -# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript -# -# # auth_http localhost/auth.php; -# # pop3_capabilities "TOP" "USER"; -# # imap_capabilities "IMAP4rev1" "UIDPLUS"; -# -# server { -# listen localhost:110; -# protocol pop3; -# proxy on; -# } -# -# server { -# listen localhost:143; -# protocol imap; -# proxy on; -# } -#} \ No newline at end of file diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/.gitignore b/near-rt-ric-simulator/src/OSC_2.1.0/.gitignore deleted file mode 100644 index bee8a64..0000000 --- a/near-rt-ric-simulator/src/OSC_2.1.0/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/a1.py b/near-rt-ric-simulator/src/OSC_2.1.0/a1.py deleted file mode 100644 index 6ec59ff..0000000 --- a/near-rt-ric-simulator/src/OSC_2.1.0/a1.py +++ /dev/null @@ -1,275 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -import json -import datetime -import time - -from datetime import datetime -from connexion import NoContent -from flask import Flask, request, Response -from jsonschema import validate -from var_declaration import policy_instances, policy_types, policy_status, policy_fingerprint, forced_settings, hosts_set -from utils import calcFingerprint -from maincommon import extract_host_name - -#Constsants -APPL_JSON='application/json' - -# API Function: Health check -def get_healthcheck(): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - return (None, 200) - -# API Function: Get all policy type ids -def get_all_policy_types(): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - res = list(policy_instances.keys()) - res = list(map(int, res)) - return (res, 200) - -# API Function: Get a policy type -def get_policy_type(policy_type_id): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policy_type_id) - - if (policy_type_id not in policy_types.keys()): - return (None, 404) - - return Response(json.dumps(policy_types[policy_type_id]), 200, mimetype=APPL_JSON) - -# API Function: Delete a policy type -def delete_policy_type(policy_type_id): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policy_type_id) - - if (policy_type_id not in policy_instances.keys()): - return (None, 404) - - if (len(policy_instances[policy_type_id]) > 0): - return (None, 400) - - del policy_instances[policy_type_id] - del policy_types[policy_type_id] - - return (None, 204) - - -# API Function: Create a policy type -def create_policy_type(policy_type_id): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - try: - int(policy_type_id) - except Exception: - return Response("The policy type id is not an int", 400, mimetype='text/plain') - - policy_type_id=str(policy_type_id) - - if (policy_type_id in policy_instances.keys()): - if (len(policy_instances[policy_type_id]) > 0): - return (None, 400) - - try: - data = request.data - data = json.loads(data) - except Exception: - return (None, 400) - - if (('name' not in data.keys()) or ('description' not in data.keys()) or ('policy_type_id' not in data.keys()) or ('create_schema' not in data.keys())): - return (None, 400) - - if (policy_type_id not in policy_instances.keys()): - policy_instances[policy_type_id]={} - - policy_types[policy_type_id]=data - - return (None, 201) - - -# API Function: Get all policy ids for a type -def get_all_policy_identities(policy_type_id): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policy_type_id) - - if (policy_type_id not in policy_instances.keys()): - return (None, 404) - return (list(policy_instances[policy_type_id].keys()), 200) - -# API Function: Get a policy instance -def get_policy_instance(policy_type_id, policy_instance_id): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policy_type_id) - - if (policy_type_id not in policy_instances.keys()): - return (None, 404) - - if (policy_instance_id not in policy_instances[policy_type_id].keys()): - return (None, 404) - - return Response(json.dumps(policy_instances[policy_type_id][policy_instance_id]), 200, mimetype=APPL_JSON) - -# API function: Delete a policy -def delete_policy_instance(policy_type_id, policy_instance_id): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policy_type_id) - - if (policy_type_id not in policy_instances.keys()): - return (None, 404) - - if (policy_instance_id not in policy_instances[policy_type_id].keys()): - return (None, 404) - - fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_instance_id]) - del policy_fingerprint[fp_previous] - del policy_instances[policy_type_id][policy_instance_id] - del policy_status[policy_instance_id] - - return (None, 202) - -# API function: Create/update a policy -def create_or_replace_policy_instance(policy_type_id, policy_instance_id): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policy_type_id) - - if (policy_type_id not in policy_instances.keys()): - return (None, 404) - - try: - data = request.data - data = json.loads(data) - except Exception: - return (None, 400) - - try: - validate(instance=data, schema=policy_types[policy_type_id]['create_schema']) - except Exception: - return (None, 400) - - fp_previous=None - if policy_instance_id in policy_instances[policy_type_id].keys(): - retcode=200 - fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_instance_id]) - else: - if (policy_instance_id in policy_fingerprint.values()): - return (None, 400) - - fp=calcFingerprint(data) - if (fp in policy_fingerprint.keys()): - p_id=policy_fingerprint[fp] - if (p_id != policy_instance_id): - return (None, 400) - - if (fp_previous is not None): - del policy_fingerprint[fp_previous] - - policy_fingerprint[fp]=policy_instance_id - - policy_instances[policy_type_id][policy_instance_id]=data - ps={} - ps["instance_status"] = "NOT IN EFFECT" - ps["has_been_deleted"] = "false" - ps["created_at"] = str(datetime.now().strftime("%m/%d/%Y, %H:%M:%S")) - policy_status[policy_instance_id]=ps - - return (None, 202) - -# API function: Get policy status -def get_policy_instance_status(policy_type_id, policy_instance_id): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policy_type_id) - if (policy_type_id not in policy_instances.keys()): - return (None, 404) - - if (policy_instance_id not in policy_instances[policy_type_id].keys()): - return (None, 404) - - return Response(json.dumps(policy_status[policy_instance_id]), 200, mimetype=APPL_JSON) - -# Helper: Create a response object if forced http response code is set -def get_forced_response(): - - response_code=forced_settings['code'] - if (response_code is not None): - forced_settings['code'] = None - return (None, response_code) - return None - -# Helper: Delay if delayed response code is set -def do_delay(): - - if (forced_settings['delay'] is not None): - try: - val=int(forced_settings['delay']) - time.sleep(val) - except Exception: - return - return - -# Helper: Check if response shall be delayed or a forced response shall be sent -def check_modified_response(): - do_delay() - return get_forced_response() \ No newline at end of file diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/main.py b/near-rt-ric-simulator/src/OSC_2.1.0/main.py deleted file mode 100644 index e0766d8..0000000 --- a/near-rt-ric-simulator/src/OSC_2.1.0/main.py +++ /dev/null @@ -1,222 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -import connexion -import json -import sys -import os -import requests - -from pathlib import Path -from flask import Flask, escape, request, Response, jsonify -from jsonschema import validate -from var_declaration import policy_instances, policy_types, policy_status, policy_fingerprint, forced_settings, hosts_set -from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name -from time import sleep - -#Constants -TEXT_PLAIN='text/plain' - -check_apipath() - -app = connexion.FlaskApp(__name__, specification_dir=apipath) - -#Check alive function -@app.route('/', methods=['GET']) -def test(): - - return Response("OK", 200, mimetype=TEXT_PLAIN) - -@app.route('/ip', methods=['GET']) -def get_ip(): - if request.environ.get('HTTP_X_FORWARDED_FOR') is None: - return jsonify({'ip': request.environ['REMOTE_ADDR']}), 200 - else: - return jsonify({'ip': request.environ['HTTP_X_FORWARDED_FOR']}), 200 - -#Return the current and all supported yamls for the this container -@app.route('/container_interfaces', methods=['GET']) -def container_interfaces(): - - return get_supported_interfaces_response() - -#Delete all created instances and status -@app.route('/deleteinstances', methods=['POST']) -def deleteinstances(): - - for i in policy_instances.keys(): - policy_instances[i]={} - - policy_status.clear() - forced_settings.clear() - forced_settings['code']=None - forced_settings['delay']=None - policy_fingerprint.clear() - return Response("All policy instances deleted", 200, mimetype=TEXT_PLAIN) - -#Delete all - all reset -@app.route('/deleteall', methods=['POST']) -def deleteall(): - - policy_instances.clear() - policy_types.clear() - policy_status.clear() - forced_settings['code']=None - forced_settings['delay']=None - policy_fingerprint.clear() - return Response("All policy instances and types deleted", 200, mimetype=TEXT_PLAIN) - -#Load a policy type -@app.route('/policytype', methods=['PUT']) -def policytype(): - - policy_type_id=request.args.get('id') - if (policy_type_id is None): - return Response('Parameter <id> missing in request', status=400, mimetype=TEXT_PLAIN) - try: - int(policy_type_id) - except Exception: - return Response("The policy type id is not an int", 400, mimetype=TEXT_PLAIN) - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The policy type is corrupt or missing", 400, mimetype=TEXT_PLAIN) - - if ('name' not in data.keys() or 'description' not in data.keys() or 'policy_type_id' not in data.keys() or'create_schema' not in data.keys()): - return Response("The policy type missing atributes", 400, mimetype=TEXT_PLAIN) - - retcode=201 - if (policy_type_id in policy_types.keys()): - retcode=200 - if (len(policy_instances[policy_type_id]) > 0): - return Response("The policy type already exists and instances exists", 400, mimetype=TEXT_PLAIN) - - policy_types[policy_type_id]=data - policy_instances[policy_type_id]={} - return Response("Policy type " + policy_type_id + " is OK.", retcode, mimetype=TEXT_PLAIN) - -#Delete a policy type -@app.route('/policytype', methods=['DELETE']) -def del_policytype(): - - policy_type_id=request.args.get('id') - if (policy_type_id is None): - return Response('Parameter <id> missing in request', status=400, mimetype=TEXT_PLAIN) - try: - int(policy_type_id) - except Exception: - return Response("The policy type id is not an int", 400, mimetype=TEXT_PLAIN) - - if (policy_type_id in policy_types.keys()): - if (len(policy_instances[policy_type_id]) > 0): - return Response("The policy type already exists and instances exists", 400, mimetype=TEXT_PLAIN) - - del policy_types[policy_type_id] - del policy_instances[policy_type_id] - return Response("Policy type " + policy_type_id + " is OK.", 204, mimetype=TEXT_PLAIN) - - return Response("Policy type " + policy_type_id + " not found.", 204, mimetype=TEXT_PLAIN) - - -# Get all policy type ids -@app.route('/policytypes', methods=['GET']) -def get_policytype_ids(): - - return (json.dumps(list(policy_instances.keys())), 200) - -#Set force response for one A1 response -#/forceresponse?code=<responsecode> -@app.route('/forceresponse', methods=['POST']) -def forceresponse(): - - try: - forced_settings['code']=int(request.args.get('code')) - except Exception: - forced_settings['code']=None - return Response("Force response code: " + str(forced_settings['code']) + " set for one single A1 response", 200, mimetype=TEXT_PLAIN) - -#Set force delay response, in seconds, for all A1 responses -#/froceesponse?delay=<seconds> -@app.route('/forcedelay', methods=['POST']) -def forcedelay(): - - try: - forced_settings['delay']=int(request.args.get('delay')) - except Exception: - forced_settings['delay']=None - return Response("Force delay: " + str(forced_settings['delay']) + " sec set for all A1 responses", 200, mimetype=TEXT_PLAIN) - - -#Set status and reason -#/status?policyid=<policyid>&status=<status>[&deleted=<boolean>][&created_at=<timestamp>] -@app.route('/status', methods=['PUT']) -def setstatus(): - - policy_id=request.args.get('policyid') - if (policy_id is None): - return Response('Parameter <policyid> missing in request', status=400, mimetype=TEXT_PLAIN) - - if policy_id not in policy_status.keys(): - return Response('Policyid: '+policy_id+' not found.', status=404, mimetype=TEXT_PLAIN) - status=request.args.get('status') - if (status is None): - return Response('Parameter <status> missing in request', status=400, mimetype=TEXT_PLAIN) - policy_status[policy_id]["instance_status"]=status - msg = "Status set to "+status - deleted_policy=request.args.get('deleted') - if (deleted_policy is not None): - policy_status[policy_id]["has_been_deleted"]=deleted_policy - msg = msg + " and has_been_deleted set to "+deleted_policy - created_at = request.args.get('created_at') - if (created_at is not None): - policy_status[policy_id]["created_at"]=created_at - msg = msg + " and created_at set to "+created_at - msg=msg + " for policy: " + policy_id - return Response(msg, 200, mimetype=TEXT_PLAIN) - - -#Metrics function -#Get a named counter -@app.route('/counter/<string:countername>', methods=['GET']) -def getcounter(countername): - - if (countername == "num_instances"): - return Response(str(len(policy_fingerprint)), 200, mimetype=TEXT_PLAIN) - elif (countername == "num_types"): - return Response(str(len(policy_instances)),200, mimetype=TEXT_PLAIN) - elif (countername == "interface"): - p=Path(os.getcwd()) - pp=p.parts - return Response(str(pp[len(pp)-1]),200, mimetype=TEXT_PLAIN) - elif (countername == "remote_hosts"): - hosts=",".join(hosts_set) - return str(hosts),200 - elif (countername == "datadelivery"): - return Response(str(0),200, mimetype=TEXT_PLAIN) - else: - return Response("Counter name: "+countername+" not found.",404, mimetype=TEXT_PLAIN) - -port_number = 2222 -if len(sys.argv) >= 2 : - if isinstance(sys.argv[1], int): - port_number = sys.argv[1] - -app.add_api('openapi.yaml') - -if __name__ == '__main__': - app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py b/near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py deleted file mode 100644 index 5fe0469..0000000 --- a/near-rt-ric-simulator/src/OSC_2.1.0/var_declaration.py +++ /dev/null @@ -1,25 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -policy_types={} -policy_instances={} -policy_status={} -forced_settings={} -forced_settings['code']=None -forced_settings['delay']=None -policy_fingerprint={} -hosts_set=set() diff --git a/near-rt-ric-simulator/src/STD_1.1.3/.gitignore b/near-rt-ric-simulator/src/STD_1.1.3/.gitignore deleted file mode 100644 index bee8a64..0000000 --- a/near-rt-ric-simulator/src/STD_1.1.3/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/near-rt-ric-simulator/src/STD_1.1.3/callBack.py b/near-rt-ric-simulator/src/STD_1.1.3/callBack.py deleted file mode 100644 index 0e8e416..0000000 --- a/near-rt-ric-simulator/src/STD_1.1.3/callBack.py +++ /dev/null @@ -1,43 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -import json -from flask import Flask, request, Response - -app = Flask(__name__) #NOSONAR - -#Check alive function -@app.route('/', methods=['GET']) -def test(): - - return Response("OK", 200, mimetype='text/plain') - -#Receive status (only for testing callbacks) -#/statustest -@app.route('/statustest', methods=['POST', 'PUT']) -def statustest(): - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The status data is corrupt or missing.", 400, mimetype='text/plain') - - return Response(json.dumps(data), 200, mimetype='application/json') - -port_number = 2223 - -app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/STD_2.0.0/.gitignore b/near-rt-ric-simulator/src/STD_2.0.0/.gitignore deleted file mode 100644 index bee8a64..0000000 --- a/near-rt-ric-simulator/src/STD_2.0.0/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/near-rt-ric-simulator/src/STD_2.0.0/a1.py b/near-rt-ric-simulator/src/STD_2.0.0/a1.py deleted file mode 100644 index c4aa4ca..0000000 --- a/near-rt-ric-simulator/src/STD_2.0.0/a1.py +++ /dev/null @@ -1,271 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -import copy -import datetime -import json -import logging -import collections -import time - -from connexion import NoContent -from flask import Flask, escape, request, Response, make_response -from jsonschema import validate -from var_declaration import policy_instances, policy_types, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set -from utils import calcFingerprint -from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name - -#Constsants -APPL_JSON='application/json' -APPL_PROB_JSON='application/problem+json' - -# API Function: Get all policy type ids -def get_all_policy_types(): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - res = list(policy_types.keys()) - return (res, 200) - -# API Function: Get a policy type -def get_policy_type(policyTypeId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_type_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - return Response(json.dumps(policy_types[policy_type_id]), 200, mimetype=APPL_JSON) - -# API Function: Get all policy ids -def get_all_policy_identities(policyTypeId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_type_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - return (list(policy_instances[policy_type_id].keys()), 200) - -# API Function: Create or update a policy -def put_policy(policyTypeId, policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - policy_id=str(policyId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - try: - data = request.data - data = json.loads(data) - except Exception: - pjson=create_problem_json(None, "The policy is corrupt or missing.", 400, None, policy_id) - return Response(json.dumps(pjson), 400, mimetype=APPL_PROB_JSON) - - try: - validate(instance=data, schema=policy_types[policy_type_id]['policySchema']) - except Exception: - return (None, 400) - - fp_previous=None - retcode=201 - if policy_id in policy_instances[policy_type_id].keys(): - retcode=200 - fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_id]) - else: - if (policy_id in policy_fingerprint.values()): - return (None, 400) - - fp=calcFingerprint(data) - if (fp in policy_fingerprint.keys()): - p_id=policy_fingerprint[fp] - if (p_id != policy_id): - pjson=create_problem_json(None, "Duplicate, the policy json already exists.", 400, None, policy_id) - return Response(json.dumps(pjson), 400, mimetype=APPL_PROB_JSON) - - if (fp_previous is not None): - del policy_fingerprint[fp_previous] - - policy_fingerprint[fp]=policy_id - - noti=request.args.get('notificationDestination') - callbacks[policy_id]=noti - - policy_instances[policy_type_id][policy_id]=data - - if (policy_types[policy_type_id]['statusSchema'] is not None): - ps = {} - ps["enforceStatus"] = "" - ps["enforceReason"] = "" - policy_status[policy_id] = ps - - if (retcode == 200): - return Response(json.dumps(data), 200, mimetype=APPL_JSON) - else: - headers={} - headers['Location']='/A1-P/v2/policytypes/' + policy_type_id + '/policies/' + policy_id - return Response(json.dumps(data), 201, headers=headers, mimetype=APPL_JSON) - -# API Function: Get a policy -def get_policy(policyTypeId, policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - policy_id=str(policyId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - if (policy_id not in policy_instances[policy_type_id].keys()): - pjson=create_problem_json(None, "The requested policy does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - return Response(json.dumps(policy_instances[policy_type_id][policy_id]), 200, mimetype=APPL_JSON) - - -# API Function: Delete a policy -def delete_policy(policyTypeId, policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - policy_id=str(policyId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - if (policy_id not in policy_instances[policy_type_id].keys()): - pjson=create_problem_json(None, "The requested policy does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - fp_previous=calcFingerprint(policy_instances[policy_type_id][policy_id]) - policy_fingerprint.pop(fp_previous) - policy_instances[policy_type_id].pop(policy_id) - policy_status.pop(policy_id) - callbacks.pop(policy_id) - return Response('', 204, mimetype=APPL_JSON) - - -# API Function: Get status for a policy -def get_policy_status(policyTypeId, policyId): - - extract_host_name(hosts_set, request) - - if ((r := check_modified_response()) is not None): - return r - - policy_type_id=str(policyTypeId) - policy_id=str(policyId) - - if (policy_type_id not in policy_types.keys()): - pjson=create_problem_json(None, "The policy type does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - if (policy_id not in policy_instances[policy_type_id].keys()): - pjson=create_problem_json(None, "The requested policy does not exist.", 404, None, policy_id) - return Response(json.dumps(pjson), 404, mimetype=APPL_PROB_JSON) - - return Response(json.dumps(policy_status[policy_id]), status=200, mimetype=APPL_JSON) - -# Helper: Create a response object if forced http response code is set -def get_forced_response(): - if (forced_settings['code'] is not None): - pjson=create_error_response(forced_settings['code']) - forced_settings['code']=None - return Response(json.dumps(pjson), pjson['status'], mimetype=APPL_PROB_JSON) - return None - -# Helper: Delay if delayed response code is set -def do_delay(): - if (forced_settings['delay'] is not None): - try: - val=int(forced_settings['delay']) - time.sleep(val) - except Exception: - return - -# Helper: Check if response shall be delayed or a forced response shall be sent -def check_modified_response(): - do_delay() - return get_forced_response() - -# Helper: Create a problem json object -def create_problem_json(type_of, title, status, detail, instance): - - error = {} - if type_of is not None: - error["type"] = type_of - if title is not None: - error["title"] = title - if status is not None: - error["status"] = status - if detail is not None: - error["detail"] = detail - if instance is not None: - error["instance"] = instance - return error - -# Helper: Create a problem json based on a generic http response code -def create_error_response(code): - - if code == '400': - return(create_problem_json(None, "Bad request", 400, "Object in payload not properly formulated or not related to the method", None)) - elif code == '404': - return(create_problem_json(None, "Not found", 404, "No resource found at the URI", None)) - elif code == '405': - return(create_problem_json(None, "Method not allowed", 405, "Method not allowed for the URI", None)) - elif code == '409': - return(create_problem_json(None, "Conflict", 409, "Request could not be processed in the current state of the resource", None)) - elif code == '429': - return(create_problem_json(None, "Too many requests", 429, "Too many requests have been sent in a given amount of time", None)) - elif code == '507': - return(create_problem_json(None, "Insufficient storage", 507, "The method could not be performed on the resource because the provider is unable to store the representation needed to successfully complete the request", None)) - elif code == '503': - return(create_problem_json(None, "Service unavailable", 503, "The provider is currently unable to handle the request due to a temporary overload", None)) - else: - return(create_problem_json(None, "Unknown", code, "Not implemented response code", None)) diff --git a/near-rt-ric-simulator/src/STD_2.0.0/main.py b/near-rt-ric-simulator/src/STD_2.0.0/main.py deleted file mode 100644 index dcf835e..0000000 --- a/near-rt-ric-simulator/src/STD_2.0.0/main.py +++ /dev/null @@ -1,255 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -import connexion -import json -import sys -import os -import requests - - -from pathlib import Path -from flask import Flask, escape, request, Response -from jsonschema import validate -from var_declaration import policy_instances, policy_types, policy_status, callbacks, forced_settings, policy_fingerprint, hosts_set, data_delivery_counter -from maincommon import check_apipath, apipath, get_supported_interfaces_response, extract_host_name - -#Constants -TEXT_PLAIN='text/plain' - -check_apipath() - -app = connexion.App(__name__, specification_dir=apipath) - -#Check alive function -@app.route('/', methods=['GET']) -def test(): - - return Response("OK", 200, mimetype=TEXT_PLAIN) - -#Return the current and all supported yamls for the this container -@app.route('/container_interfaces', methods=['GET']) -def container_interfaces(): - - return get_supported_interfaces_response() - -#Delete all created instances and status -@app.route('/deleteinstances', methods=['POST']) -def delete_instances(): - - for i in policy_instances.keys(): - policy_instances[i]={} - policy_status.clear() - callbacks.clear() - forced_settings['code']=None - forced_settings['delay']=None - policy_fingerprint.clear() - return Response("All policy instances deleted", 200, mimetype=TEXT_PLAIN) - -#Delete all - all reset -#(same as delete_instances but kept to in order to use the same interface as other version of the simulator) -@app.route('/deleteall', methods=['POST']) -def delete_all(): - - policy_instances.clear() - policy_types.clear() - policy_status.clear() - callbacks.clear() - forced_settings['code']=None - forced_settings['delay']=None - policy_fingerprint.clear() - return Response("All policy instances and types deleted", 200, mimetype=TEXT_PLAIN) - -#Load a policy type -@app.route('/policytype', methods=['PUT']) -def policytype(): - - policy_type_id=request.args.get('id') - if (policy_type_id is None): - return Response('Parameter <id> missing in request', status=400, mimetype=TEXT_PLAIN) - - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The policy type is corrupt or missing", 400, mimetype=TEXT_PLAIN) - - if ('policySchema' not in data.keys()): - return Response("The policy type atribute policySchema is missing", 400, mimetype=TEXT_PLAIN) - - retcode=201 - if (policy_type_id in policy_types.keys()): - retcode=200 - if (len(policy_instances[policy_type_id]) > 0): - return Response("The policy type already exists and instances exists", 400, mimetype=TEXT_PLAIN) - - policy_types[policy_type_id]=data - policy_instances[policy_type_id]={} - return Response("Policy type " + policy_type_id + " is OK.", retcode, mimetype=TEXT_PLAIN) - -#Delete a policy type -@app.route('/policytype', methods=['DELETE']) -def del_policytype(): - - policy_type_id=request.args.get('id') - if (policy_type_id is None): - return Response('Parameter <id> missing in request', status=400, mimetype=TEXT_PLAIN) - - if (policy_type_id in policy_types.keys()): - if (len(policy_instances[policy_type_id]) > 0): - return Response("The policy type already exists and instances exists", 400, mimetype=TEXT_PLAIN) - - del policy_types[policy_type_id] - del policy_instances[policy_type_id] - return Response("Policy type " + policy_type_id + " is OK.", 204, mimetype=TEXT_PLAIN) - - return Response("Policy type " + policy_type_id + " not found.", 204, mimetype=TEXT_PLAIN) - - -# Get all policy type ids -@app.route('/policytypes', methods=['GET']) -def get_policytype_ids(): - - return (json.dumps(list(policy_instances.keys())), 200) - - -#Set force response for one A1 response -#/forceresponse?code=<responsecode> -@app.route('/forceresponse', methods=['POST']) -def forceresponse(): - - try: - forced_settings['code']=request.args.get('code') - except Exception: - forced_settings['code']=None - return Response("Force response code: " + str(forced_settings['code']) + " set for one single A1 response", 200, mimetype=TEXT_PLAIN) - -#Set force delay response, in seconds, for all A1 responses -#/froceesponse?delay=<seconds> -@app.route('/forcedelay', methods=['POST']) -def forcedelay(): - - try: - forced_settings['delay']=request.args.get('delay') - except Exception: - forced_settings['delay']=None - return Response("Force delay: " + str(forced_settings['delay']) + " sec set for all A1 responses", 200, mimetype=TEXT_PLAIN) - - -#Set status and reason -#/status?policyid=<policyid>&status=<status>[&reason=<reason>] -@app.route('/status', methods=['PUT']) -def setstatus(): - - policy_id=request.args.get('policyid') - if (policy_id is None): - return Response('Parameter <policyid> missing in request', status=400, mimetype=TEXT_PLAIN) - if policy_id not in policy_status.keys(): - return Response('Policyid: '+policy_id+' not found.', status=404, mimetype=TEXT_PLAIN) - status=request.args.get('status') - if (status is None): - return Response('Parameter <status> missing in request', status=400, mimetype=TEXT_PLAIN) - reason=request.args.get('reason') - ps = {} - ps["enforceStatus"] = status - msg="Status set to "+status - if (reason is not None): - ps["enforceReason"] = reason - msg=msg+" and "+reason - policy_status[policy_id] = ps - msg=msg+" for policy: " + policy_id - return Response(msg, 200, mimetype=TEXT_PLAIN) - -#Send status -#/status?policyid=<policyid> -@app.route('/sendstatus', methods=['POST']) -def sendstatus(): - policyid=request.args.get('policyid') - if (policyid is None): - return Response('Parameter <policyid> missing in request', status=400, mimetype=TEXT_PLAIN) - - if (policyid not in policy_status.keys()): - return Response('Policyid: '+policyid+' not found.', status=404, mimetype=TEXT_PLAIN) - - ps=policy_status[policyid] - cb=callbacks[policyid] - try: - print("Callback url: " + str(cb)) - resp=requests.post(cb,json=json.dumps(ps), verify=False) # NOSONAR - except: - return Response('Post status failed, could not send to: '+str(cb), status=500, mimetype=TEXT_PLAIN) - if (resp.status_code<199 & resp.status_code > 299): - return Response('Post status failed with code: '+resp.status_code, status=500, mimetype=TEXT_PLAIN) - - data = resp.json() - return Response(data, 200, mimetype='application/json') - -#Receive status (only for testing callbacks) -#/statustest -@app.route('/statustest', methods=['POST', 'PUT']) -def statustest(): - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The status data is corrupt or missing.", 400, mimetype=TEXT_PLAIN) - - return Response(json.dumps(data), 200, mimetype='application/json') - -#Receive a data delivery package -#/datadelivery -@app.route('/datadelivery', methods=['POST']) -def datadelivery(): - global data_delivery_counter - try: - data = request.data - data = json.loads(data) - except Exception: - return Response("The data is corrupt or missing.", 400, mimetype=TEXT_PLAIN) - data_delivery_counter += 1 - return Response("", 200, mimetype=TEXT_PLAIN) - -#Metrics function -#Get a named counter -@app.route('/counter/<string:countername>', methods=['GET']) -def getcounter(countername): - - if (countername == "num_instances"): - return Response(str(len(policy_fingerprint)), 200, mimetype=TEXT_PLAIN) - elif (countername == "num_types"): - return Response(str(len(policy_instances)),200, mimetype=TEXT_PLAIN) - elif (countername == "interface"): - p=Path(os.getcwd()) - pp=p.parts - return Response(str(pp[len(pp)-1]),200, mimetype=TEXT_PLAIN) - elif (countername == "remote_hosts"): - hosts=",".join(hosts_set) - return str(hosts),200 - elif (countername == "datadelivery"): - return Response(str(data_delivery_counter),200, mimetype=TEXT_PLAIN) - else: - return Response("Counter name: "+countername+" not found.",404, mimetype=TEXT_PLAIN) - -port_number = 2222 -if len(sys.argv) >= 2: - if isinstance(sys.argv[1], int): - port_number = sys.argv[1] - -app.add_api('ORAN_A1-p_V2.0.0_api.yaml') - -if __name__ == '__main__': - app.run(port=port_number, host="127.0.0.1", threaded=False) \ No newline at end of file diff --git a/near-rt-ric-simulator/src/STD_2.0.0/var_declaration.py b/near-rt-ric-simulator/src/STD_2.0.0/var_declaration.py deleted file mode 100644 index 5136404..0000000 --- a/near-rt-ric-simulator/src/STD_2.0.0/var_declaration.py +++ /dev/null @@ -1,27 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -policy_types={} -policy_instances = {} -policy_status = {} -callbacks = {} -forced_settings = {} -forced_settings['code']=None -forced_settings['delay']=None -policy_fingerprint={} -hosts_set=set() -data_delivery_counter=0 diff --git a/near-rt-ric-simulator/src/common/.gitignore b/near-rt-ric-simulator/src/common/.gitignore deleted file mode 100644 index bee8a64..0000000 --- a/near-rt-ric-simulator/src/common/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/near-rt-ric-simulator/src/start.sh b/near-rt-ric-simulator/src/start.sh deleted file mode 100755 index feb5a1d..0000000 --- a/near-rt-ric-simulator/src/start.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -if [ $# -ne 1 ]; then - echo "Expected folder name of simulator." - echo "The container shall be started with env variable 'A1_VERSION' set to the folder name of the A1 version to use." - echo "Exiting...." - exit 1 -fi -echo "Version folder for simulator: "$1 - -#Set path to open api -export APIPATH=$PWD/api/$1 -echo "APIPATH set to: "$APIPATH - -cd src - -#Include common module(s) -export PYTHONPATH=$PWD/common -echo "PYTHONPATH set to: "$PYTHONPATH - -cd $1 - -#start nginx -nginx -c /usr/src/app/nginx.conf - -#start callBack server -if [[ ${A1_VERSION} == "STD"* ]]; then - echo "Path to callBack.py: "$PWD - python -u callBack.py & -fi - -#start near-rt-ric-simulator -echo "Path to main.py: "$PWD -python -u main.py diff --git a/near-rt-ric-simulator/certificate/generate_cert_and_key.sh b/near-rt-ric-simulator/start.sh similarity index 55% rename from near-rt-ric-simulator/certificate/generate_cert_and_key.sh rename to near-rt-ric-simulator/start.sh index 0f79bbf..bade4f2 100755 --- a/near-rt-ric-simulator/certificate/generate_cert_and_key.sh +++ b/near-rt-ric-simulator/start.sh @@ -1,14 +1,9 @@ #!/bin/bash # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2023. S.K. Chaudhary. All rights reserved. # ======================================================================== -# 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 -# +# # 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. @@ -17,5 +12,14 @@ # ============LICENSE_END================================================= # -# This will generate a self-signed certificate with password 'test' -openssl req -x509 -passout pass:"test" -newkey rsa:2048 -keyout key.crt -out cert.crt -days 9999 + + +#start callBack server +if [[ ${A1_VERSION} == "STD"* ]]; then + echo "Path to callBack.py: "$PWD + python -u callBack.py & +fi + +#start near-rt-ric-simulator +echo "Path to main.py: "$PWD +python -u main.py diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh b/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh deleted file mode 100755 index bc2413d..0000000 --- a/near-rt-ric-simulator/test/OSC_2.1.0/basic_test.sh +++ /dev/null @@ -1,275 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -# Script for basic test of the simulator. -# Run the build_and_start with the same arg as this script -if [ $# -ne 1 ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 -fi -if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 -fi - -if [ $1 == "nonsecure" ]; then - #Default http port for the simulator - PORT=8085 - # Set http protocol - HTTPX="http" -else - #Default https port for the simulator - PORT=8185 - # Set https protocol - HTTPX="https" -fi - -. ../common/test_common.sh - -echo "=== Simulator hello world ===" -RESULT="OK" -do_curl GET / 200 - -echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" -do_curl GET /container_interfaces 200 - -echo "=== Reset simulator instances ===" -RESULT="All policy instances deleted" -do_curl POST /deleteinstances 200 - -echo "=== Reset simulator, all ===" -RESULT="All policy instances and types deleted" -do_curl POST /deleteall 200 - -echo "=== API: Healthcheck ===" -RESULT="" -do_curl GET /a1-p/healthcheck 200 - -echo "=== API: Get policy types, shall be empty array ==" -RESULT="json:[]" -do_curl GET /a1-p/policytypes 200 - -echo "=== API: Delete a policy type, shall fail ==" -RESULT="" -do_curl DELETE /a1-p/policytypes/1 404 - -echo "=== API: Get policy instances for type 1, shall fail ==" -RESULT="" -do_curl GET /a1-p/policytypes/1/policies 404 - -echo "=== API: Put a policy type: 1 ===" -RESULT="" -do_curl PUT /a1-p/policytypes/1 201 jsonfiles/pt1.json - -echo "=== API: Put a policy type: 1, again ===" -RESULT="" -do_curl PUT /a1-p/policytypes/1 201 jsonfiles/pt1.json - -echo "=== API: Delete a policy type: 1 ===" -RESULT="" -do_curl DELETE /a1-p/policytypes/1 204 - -echo "=== API: Get policy type ids, shall be empty ==" -RESULT="json:[]" -do_curl GET /a1-p/policytypes 200 - -echo "=== API: Load a policy type: 1 ===" -RESULT="" -do_curl PUT /a1-p/policytypes/1 201 jsonfiles/pt1.json - -echo "=== API: Get policy type ids, shall contain type 1 ==" -RESULT="json:[ 1 ]" -do_curl GET /a1-p/policytypes 200 - -echo "=== API: Get instances for type 1, shall be empty ===" -RESULT="json:[]" -do_curl GET '/a1-p/policytypes/1/policies' 200 - -echo "=== API: Create policy instance pi1 of type: 1 ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi1' 202 jsonfiles/pi1.json - -echo "=== API: Update policy instance pi1 of type: 1 ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi1' 202 jsonfiles/pi1.json - -echo "=== API: Load a policy type: 1, shall fail ===" -RESULT="" -do_curl PUT /a1-p/policytypes/1 400 jsonfiles/pt1.json - -echo "=== API: Get instances for type 1, shall contain pi1 ===" -RESULT="json:[ \"pi1\" ]" -do_curl GET '/a1-p/policytypes/1/policies' 200 - -echo "=== API: Create policy instance pi2 (copy of pi1) of type: 1. Shall fail ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi2' 400 jsonfiles/pi1.json - -echo "=== Set force response code 401. ===" -RESULT="*" -do_curl POST '/forceresponse?code=401' 200 - -echo "=== API: Get policy type 1. Shall fail with forced code ===" -RESULT="" -do_curl GET '/a1-p/policytypes/1' 401 - -echo "=== API: Get policy status ===" -RESULT="json:{\"instance_status\": \"NOT IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 - -echo "=== Load a policy type: 2 ===" -RESULT="Policy type 2 is OK." -do_curl PUT '/policytype?id=2' 201 jsonfiles/pt2.json - -echo "=== Load a policy type: 2 again. ===" -RESULT="Policy type 2 is OK." -do_curl PUT '/policytype?id=2' 200 jsonfiles/pt2.json - -echo "=== API: Get policy type ids, shall contain type 1 and 2 ==" -RESULT="json:[ 1, 2 ]" -do_curl GET /a1-p/policytypes 200 - -echo "=== Get policy type ids, shall contain type 1 and 2 ==" -RESULT="json:[\"1\", \"2\"]" -do_curl GET /policytypes 200 - -echo "=== API: Get policy type 2 ==" -RESULT="json:{\"name\": \"pt2\", \"description\": \"pt2 policy type\", \"policy_type_id\": 2, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}" -do_curl GET /a1-p/policytypes/2 200 - -echo "=== Delete policy type: 2 ===" -RESULT="" -do_curl DELETE '/policytype?id=2' 204 jsonfiles/pt2.json - -echo "=== API: Get policy type ids, shall contain type 1 ==" -RESULT="json:[ 1 ]" -do_curl GET /a1-p/policytypes 200 - -echo "=== Load a policy type: 2 ===" -RESULT="Policy type 2 is OK." -do_curl PUT '/policytype?id=2' 201 jsonfiles/pt2.json - -echo "=== API: Get policy type 2 ==" -RESULT="json:{\"name\": \"pt2\", \"description\": \"pt2 policy type\", \"policy_type_id\": 2, \"create_schema\": {\"\$schema\": \"http://json-schema.org/draft-07/schema#\", \"title\": \"STD_QoSNudging_0.2.0\", \"description\": \"QoS policy type\", \"type\": \"object\", \"properties\": {\"scope\": {\"type\": \"object\", \"properties\": {\"ueId\": {\"type\": \"string\"}, \"qosId\": {\"type\": \"string\"}}, \"additionalProperties\": false, \"required\": [\"ueId\", \"qosId\"]}, \"statement\": {\"type\": \"object\", \"properties\": {\"priorityLevel\": {\"type\": \"number\"}}, \"additionalProperties\": false, \"required\": [\"priorityLevel\"]}}}}" -do_curl GET /a1-p/policytypes/2 200 - -echo "=== API: Get instances for type 2, shall be empty ===" -RESULT="json:[]" -do_curl GET '/a1-p/policytypes/2/policies' 200 - -echo "=== API: Create policy instance pi1 of type: 2, shall fail===" -RESULT="" -do_curl PUT '/a1-p/policytypes/2/policies/pi1' 400 jsonfiles/pi1.json - -echo "=== API: Create policy instance pi2 of type: 2. Missing param, shall fail. ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/2/policies/pi2' 400 jsonfiles/pi2_missing_param.json - -echo "=== API: Create policy instance pi2 of type: 2 ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/2/policies/pi2' 202 jsonfiles/pi2.json - -echo "=== API: Update policy instance pi2 of type: 2 ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/2/policies/pi2' 202 jsonfiles/pi2.json - -echo "=== API: Get instances for type 1, shall contain pi1 ===" -RESULT="json:[ \"pi1\" ]" -do_curl GET '/a1-p/policytypes/1/policies' jsonfiles/200 - -echo "=== API: Get instances for type 2, shall contain pi2 ===" -RESULT="json:[ \"pi2\" ]" -do_curl GET '/a1-p/policytypes/2/policies' 200 - -echo "=== API: Create policy instance pi11 (copy of pi1) of type: 1. Shall fail ===" -RESULT="" -do_curl PUT '/a1-p/policytypes/1/policies/pi11' 400 jsonfiles/pi1.json - -echo "=== Set force response code 401. ===" -RESULT="*" -do_curl POST '/forceresponse?code=401' 200 - -echo "=== API: Get policy status for pi1, shall fail ===" -RESULT="" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 401 - -echo "=== Set force delay 10. ===" -RESULT="Force delay: 10 sec set for all A1 responses" -do_curl POST '/forcedelay?delay=10' 200 - -echo "=== API: Get policy status for pi1. Shall delay 10 sec ===" -RESULT="json:{\"instance_status\": \"NOT IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 - -echo "=== Reset force delay. ===" -RESULT="Force delay: None sec set for all A1 responses" -do_curl POST '/forcedelay' 200 - -echo "=== Set status for pi1 ===" -RESULT="Status set to IN EFFECT for policy: pi1" -do_curl PUT '/status?policyid=pi1&status=IN%20EFFECT' 200 - -echo "=== API: Get policy status for pi1 ===" -RESULT="json:{\"instance_status\": \"IN EFFECT\", \"has_been_deleted\": \"false\", \"created_at\": \"????\"}" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 - -echo "=== Set status for pi1 ===" -RESULT="Status set to IN EFFECT and has_been_deleted set to true and created_at set to 2020-03-30 12:00:00 for policy: pi1" -do_curl PUT '/status?policyid=pi1&status=IN%20EFFECT&deleted=true&created_at=2020-03-30%2012:00:00' 200 - -echo "=== API: Get policy status for pi1 ===" -RESULT="json:{\"instance_status\": \"IN EFFECT\", \"has_been_deleted\": \"true\", \"created_at\": \"2020-03-30 12:00:00\"}" -do_curl GET '/a1-p/policytypes/1/policies/pi1/status' 200 - -echo "=== Get counter: instances ===" -RESULT="2" -do_curl GET '/counter/num_instances' 200 - -echo "=== Get counter: types ===" -RESULT="2" -do_curl GET '/counter/num_types' 200 - -echo "=== Get counter: interface ===" -RESULT="OSC_2.1.0" -do_curl GET '/counter/interface' 200 - -echo "=== Get counter: remote hosts ===" -RESULT="*" -do_curl GET '/counter/remote_hosts' 200 - -echo "=== DELETE policy pi1 ===" -RESULT="" -do_curl DELETE /a1-p/policytypes/1/policies/pi1 202 - -echo "=== API: Get instances for type 1, shall be empty ===" -RESULT="[]" -do_curl GET /a1-p/policytypes/1/policies 200 - -echo "=== API: Get instances for type 2, shall contain pi2 ===" -RESULT="[ \"pi2\" ]" -do_curl GET /a1-p/policytypes/2/policies 200 - -echo "=== Get counter: instances ===" -RESULT="1" -do_curl GET /counter/num_instances 200 - -echo "********************" -echo "*** All tests ok ***" -echo "********************" diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh b/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh deleted file mode 100755 index f376971..0000000 --- a/near-rt-ric-simulator/test/OSC_2.1.0/build_and_start.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -# Script to build and start the container - -echo "Building image" -cd ../../ - -#Build the image -docker build -t a1test . - -docker stop a1OscSimulator > /dev/null 2>&1 -docker rm -f a1OscSimulator > /dev/null 2>&1 - -echo "Starting $1 mode" -#Run the container in interactive mode, unsecure port 8085, secure port 8185. -docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=OSC_2.1.0 -e ALLOW_HTTP=true -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" --name a1OscSimulator a1test - diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi1.json b/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi1.json deleted file mode 100644 index 25247a1..0000000 --- a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi1.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "scope": { - "ueId": "ue1", - "qosId": "qos1" - }, - "statement": { - "priorityLevel": 5 - } -} - diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2.json b/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2.json deleted file mode 100644 index ef076e4..0000000 --- a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "scope": { - "ueId": "ue2", - "qosId": "qos2" - }, - "statement": { - "priorityLevel": 10 - } - } \ No newline at end of file diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2_missing_param.json b/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2_missing_param.json deleted file mode 100644 index 11e325d..0000000 --- a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pi2_missing_param.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "scope": { - "qosId": "qos2" - }, - "statement": { - "priorityLevel": 10 - } - } \ No newline at end of file diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt1.json b/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt1.json deleted file mode 100644 index ba0c6d1..0000000 --- a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt1.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "pt1", - "description": "pt1 policy type", - "policy_type_id": 1, - "create_schema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "STD_QoSNudging_0.2.0", - "description": "QoS policy type", - "type": "object", - "properties": { - "scope": { - "type": "object", - "properties": { - "ueId": { - "type": "string" - }, - "qosId": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "ueId", - "qosId" - ] - }, - "statement": { - "type": "object", - "properties": { - "priorityLevel": { - "type": "number" - } - }, - "additionalProperties": false, - "required": [ - "priorityLevel" - ] - } - } - } -} diff --git a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt2.json b/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt2.json deleted file mode 100644 index 68c5e73..0000000 --- a/near-rt-ric-simulator/test/OSC_2.1.0/jsonfiles/pt2.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "pt2", - "description": "pt2 policy type", - "policy_type_id": 2, - "create_schema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "STD_QoSNudging_0.2.0", - "description": "QoS policy type", - "type": "object", - "properties": { - "scope": { - "type": "object", - "properties": { - "ueId": { - "type": "string" - }, - "qosId": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "ueId", - "qosId" - ] - }, - "statement": { - "type": "object", - "properties": { - "priorityLevel": { - "type": "number" - } - }, - "additionalProperties": false, - "required": [ - "priorityLevel" - ] - } - } - } - } \ No newline at end of file diff --git a/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh b/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh index 3a828d2..a021982 100755 --- a/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh +++ b/near-rt-ric-simulator/test/STD_1.1.3/basic_test.sh @@ -1,14 +1,9 @@ #!/bin/bash # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2023, S.K Chaudhary. All rights reserved. # ======================================================================== -# 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 -# +# # 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. @@ -30,12 +25,12 @@ fi if [ $1 == "nonsecure" ]; then #Default http port for the simulator - PORT=8085 + PORT=2222 # Set http protocol HTTPX="http" else #Default https port for the simulator - PORT=8185 + PORT=2223 # Set https protocol HTTPX="https" fi @@ -44,40 +39,42 @@ fi echo "=== Simulator hello world ===" -RESULT="OK" +RESULT="This is connection Test and the status is OK" do_curl GET / 200 -echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" -do_curl GET /container_interfaces 200 +#echo "=== Check used and implemented interfaces ===" +#RESULT="Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" +#do_curl GET /container_interfaces 200 -echo "=== Reset simulator instances ===" -RESULT="All policy instances deleted" -do_curl POST /deleteinstances 200 +#echo "=== Reset simulator instances ===" +#RESULT="All policy instances deleted" +#do_curl POST /deleteinstances 200 -echo "=== Reset simulator, all ===" -RESULT="All policy instances deleted" -do_curl POST /deleteall 200 +#echo "=== Reset simulator, all ===" +#RESULT="All policy instances deleted" +#do_curl POST /deleteall 200 + +#if you are running the script second time then first delete the instance pi2 through swagger ui. Then it will run properly or restart the esrver. echo "=== API: Get policy instances, shall be empty==" RESULT="json:[]" -do_curl GET /A1-P/v1/policies 200 +do_curl GET /A1AP/v1/policies 200 echo "=== API: Create policy instance pi1 ===" RESULT="json:{\"scope\": {\"ueId\": \"ue1\", \"groupId\": \"group1\", \"sliceId\": \"slice1\", \"qosId\": \"qos1\", \"cellId\": \"cell1\"}, \"statement\": {\"priorityLevel\": 5}}" -do_curl PUT /A1-P/v1/policies/pi1 201 jsonfiles/pi1.json +do_curl PUT /A1AP/v1/policies/pi1 201 jsonfiles/pi1.json echo "=== API: Update policy instance pi1 ===" RESULT="json:{\"scope\": {\"ueId\": \"ue1\", \"groupId\": \"group1\", \"sliceId\": \"slice1\", \"qosId\": \"qos1\", \"cellId\": \"cell1\"}, \"statement\": {\"priorityLevel\": 6}}" -do_curl PUT /A1-P/v1/policies/pi1 200 jsonfiles/pi1_updated.json +do_curl PUT /A1AP/v1/policies/pi1 200 jsonfiles/pi1_updated.json echo "=== API: Get policy instances, shall contain pi1==" RESULT="json:[ \"pi1\" ]" -do_curl GET /A1-P/v1/policies 200 +do_curl GET /A1AP/v1/policies 200 echo "=== API: Create policy instance pi2 (copy of pi1). Shall fail ===" RESULT="json:{\"title\": \"The policy json already exists.\", \"status\": 400, \"instance\": \"pi2\"}" -do_curl PUT /A1-P/v1/policies/pi2 400 jsonfiles/pi1_updated.json +do_curl PUT /A1AP/v1/policies/pi2 400 jsonfiles/pi1_updated.json echo "=== Set force response code 409. ===" RESULT="*" @@ -85,23 +82,23 @@ do_curl POST '/forceresponse?code=409' 200 echo "=== API: Get policy instances, shall fail ==" RESULT="json:{\"title\": \"Conflict\", \"status\": 409, \"detail\": \"Request could not be processed in the current state of the resource\"}" -do_curl GET /A1-P/v1/policies 409 +do_curl GET /A1AP/v1/policies 409 echo "=== API: Get policy status ===" RESULT="json:{\"enforceStatus\": \"UNDEFINED\"}" -do_curl GET /A1-P/v1/policies/pi1/status 200 +do_curl GET /A1AP/v1/policies/pi1/status 200 echo "=== API: Create policy instance pi2 ===" RESULT="json:{\"scope\": {\"ueId\": \"ue2\", \"groupId\": \"group2\", \"sliceId\": \"slice2\", \"qosId\": \"qos2\", \"cellId\": \"cell2\"}, \"statement\": {\"priorityLevel\": 10}}" -do_curl PUT /A1-P/v1/policies/pi2 201 jsonfiles/pi2.json +do_curl PUT /A1AP/v1/policies/pi2 201 jsonfiles/pi2.json echo "=== API: Update policy instance pi2 ===" RESULT="json:{\"scope\": {\"ueId\": \"ue2\", \"groupId\": \"group2\", \"sliceId\": \"slice2\", \"qosId\": \"qos2\", \"cellId\": \"cell2\"}, \"statement\": {\"priorityLevel\": 10}}" -do_curl PUT '/A1-P/v1/policies/pi2?notificationDestination=http://localhost:2223/statustest' 200 jsonfiles/pi2.json +do_curl PUT '/A1AP/v1/policies/pi2?notificationDestination=http://localhost:2223/statustest' 200 jsonfiles/pi2.json echo "=== API: Get policy instances, shall contain pi1 and pi2==" RESULT="json:[ \"pi1\", \"pi2\" ]" -do_curl GET /A1-P/v1/policies 200 +do_curl GET /A1AP/v1/policies 200 echo "=== Set force delay 10. ===" RESULT="Force delay: 10 sec set for all A1 responses" @@ -109,7 +106,7 @@ do_curl POST '/forcedelay?delay=10' 200 echo "=== API: Get policy instances, shall contain pi1 and pi2 and delayed 10 sec==" RESULT="json:[ \"pi1\", \"pi2\" ]" -do_curl GET /A1-P/v1/policies 200 +do_curl GET /A1AP/v1/policies 200 echo "=== Reset force delay. ===" RESULT="Force delay: None sec set for all A1 responses" @@ -117,19 +114,19 @@ do_curl POST /forcedelay 200 echo "=== API: GET policy instance pi1 ===" RESULT="json:{\"scope\": {\"ueId\": \"ue1\", \"groupId\": \"group1\", \"sliceId\": \"slice1\", \"qosId\": \"qos1\", \"cellId\": \"cell1\"}, \"statement\": {\"priorityLevel\": 6}}" -do_curl GET /A1-P/v1/policies/pi1 200 +do_curl GET /A1AP/v1/policies/pi1 200 echo "=== API: GET policy instance pi2 ===" RESULT="json:{\"scope\": {\"ueId\": \"ue2\", \"groupId\": \"group2\", \"sliceId\": \"slice2\", \"qosId\": \"qos2\", \"cellId\": \"cell2\"}, \"statement\": {\"priorityLevel\": 10}}" -do_curl GET /A1-P/v1/policies/pi2 200 +do_curl GET /A1AP/v1/policies/pi2 200 echo "=== API: DELETE policy instance pi1 ===" RESULT="" -do_curl DELETE /A1-P/v1/policies/pi1 204 +do_curl DELETE /A1AP/v1/policies/pi1 204 echo "=== API: Get policy status for pi1, shall fail===" RESULT="json:{\"title\": \"The policy identity does not exist.\", \"status\": 404, \"detail\": \"There is no existing policy instance with the identity: pi1\", \"instance\": \"pi1\"}" -do_curl GET /A1-P/v1/policies/pi1/status 404 +do_curl GET /A1AP/v1/policies/pi1/status 404 echo "=== Set status for policy instance pi2 ===" RESULT="Status set to OK for policy: pi2" @@ -137,7 +134,7 @@ do_curl PUT '/status?policyid=pi2&status=OK' 200 echo "=== API: Get policy status for pi2===" RESULT="json:{\"enforceStatus\": \"OK\"}" -do_curl GET /A1-P/v1/policies/pi2/status 200 +do_curl GET /A1AP/v1/policies/pi2/status 200 echo "=== Set status for policy instance pi2 ===" RESULT="Status set to NOTOK and notok_reason for policy: pi2" @@ -145,11 +142,11 @@ do_curl PUT '/status?policyid=pi2&status=NOTOK&reason=notok_reason' 200 echo "=== API: Get policy status for pi2 ===" RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\": \"notok_reason\"}" -do_curl GET /A1-P/v1/policies/pi2/status 200 +do_curl GET /A1AP/v1/policies/pi2/status 200 -echo "=== Send status for pi2===" -RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\": \"notok_reason\"}" -do_curl POST '/sendstatus?policyid=pi2' 200 +#echo "=== Send status for pi2===" +#RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\": \"notok_reason\"}" +#do_curl POST '/sendstatus?policyid=pi2' 200 echo "=== Get counter: intstance ===" RESULT="1" @@ -160,7 +157,7 @@ RESULT="0" do_curl GET /counter/num_types 200 echo "=== Get counter: interface ===" -RESULT="STD_1.1.3" +RESULT="near-rt-ric-simulator" do_curl GET /counter/interface 200 echo "=== Get counter: remote hosts ===" diff --git a/near-rt-ric-simulator/test/STD_2.0.0/.p.json b/near-rt-ric-simulator/test/STD_2.0.0/.p.json deleted file mode 100644 index 0967ef4..0000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/.p.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/near-rt-ric-simulator/test/STD_2.0.0/basic_test.sh b/near-rt-ric-simulator/test/STD_2.0.0/basic_test.sh deleted file mode 100755 index 576bd5e..0000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/basic_test.sh +++ /dev/null @@ -1,288 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -# Script for basic test of the simulator. -# Run the build_and_start with the same arg as this script -if [ $# -ne 1 ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 -fi -if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then - echo "Usage: ./basic_test.sh nonsecure|secure" - exit 1 -fi - -if [ $1 == "nonsecure" ]; then - #Default http port for the simulator - PORT=8085 - # Set http protocol - HTTPX="http" -else - #Default https port for the simulator - PORT=8185 - # Set https protocol - HTTPX="https" -fi - -. ../common/test_common.sh - - -echo "=== Simulator hello world ===" -RESULT="OK" -do_curl GET / 200 - -echo "=== Check used and implemented interfaces ===" -RESULT="Current interface: STD_2.0.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" -do_curl GET /container_interfaces 200 - -echo "=== Reset simulator instances ===" -RESULT="All policy instances deleted" -do_curl POST /deleteinstances 200 - -echo "=== Reset simulator, all ===" -RESULT="All policy instances and types deleted" -do_curl POST /deleteall 200 - -echo "=== Get counter: interface ===" -RESULT="STD_2.0.0" -do_curl GET /counter/interface 200 - -echo "=== Get counter: remote hosts ===" -RESULT="*" -do_curl GET /counter/remote_hosts 200 - -echo "=== Get counter: intstance ===" -RESULT="0" -do_curl GET /counter/num_instances 200 - -echo "=== Get counter: types (shall be 0)===" -RESULT="0" -do_curl GET /counter/num_types 200 - -echo "=== API: Get policy types, shall be empty array ==" -RESULT="json:[]" -do_curl GET /A1-P/v2/policytypes 200 - -echo "=== API: Get policy instances for type 1, type not found==" -RESULT="json:{\"title\": \"The policy type does not exist.\", \"status\": 404, \"instance\": \"1\"}" -do_curl GET /A1-P/v2/policytypes/1/policies 404 - -echo "=== API: Get policy instances, type not found==" -RESULT="json:{\"title\": \"The policy type does not exist.\", \"status\": 404, \"instance\": \"test\"}" -do_curl GET /A1-P/v2/policytypes/test/policies 404 - -echo "=== Put a policy type: STD_1 ===" -RESULT="Policy type STD_1 is OK." -do_curl PUT '/policytype?id=STD_1' 201 jsonfiles/std_1.json - -echo "=== Put a policy type: STD_1, again ===" -RESULT="Policy type STD_1 is OK." -do_curl PUT '/policytype?id=STD_1' 200 jsonfiles/std_1.json - -echo "=== API: Get policy type ids, shall contain type STD_1 ==" -RESULT="json:[ \"STD_1\" ]" -do_curl GET /A1-P/v2/policytypes 200 - -echo "=== Delete a policy type: STD_1 ===" -RESULT="" -do_curl DELETE '/policytype?id=STD_1' 204 - -echo "=== API: Get policy type ids, shall be empty ==" -RESULT="json:[]" -do_curl GET /A1-P/v2/policytypes 200 - -echo "=== Put a policy type: STD_1 ===" -RESULT="Policy type STD_1 is OK." -do_curl PUT '/policytype?id=STD_1' 201 jsonfiles/std_1.json - -echo "=== API: Get policy type ids, shall contain type STD_1 ==" -RESULT="json:[ \"STD_1\" ]" -do_curl GET /A1-P/v2/policytypes 200 - -echo "=== Get counter: types (shall be 1)===" -RESULT="1" -do_curl GET /counter/num_types 200 - -echo "=== API: Get policy type: STD_1 ===" -res=$(cat jsonfiles/std_1.json) -RESULT="json:$res" -do_curl GET /A1-P/v2/policytypes/STD_1 200 - -echo "=== API: Get policy instances, shall be empty==" -RESULT="json:[ ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== API: Create policy instance pi1 of type: STD_1 ===" -res=$(cat jsonfiles/pi1.json) -RESULT="json:$res" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi1 201 jsonfiles/pi1.json - -echo "=== API: Get policy instance pi1 of type: STD_1 ===" -res=$(cat jsonfiles/pi1.json) -RESULT="json:$res" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi1 200 - -echo "=== API: Update policy instance pi1 of type: STD_1===" -res=$(cat jsonfiles/pi1.json) -RESULT="json:$res" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi1 200 jsonfiles/pi1.json - -echo "=== API: Update policy instance pi1 of type: STD_1===" -res=$(cat jsonfiles/pi1_updated.json) -RESULT="json:$res" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi1 200 jsonfiles/pi1_updated.json - -echo "=== API: Duplicate policy instance pi2 of type: STD_1===" -res=$(cat jsonfiles/pi1_updated.json) -RESULT="json:{\"title\": \"Duplicate, the policy json already exists.\", \"status\": 400, \"instance\": \"pi2\"}" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi2 400 jsonfiles/pi1_updated.json - -echo "=== API: Get policy instances, shall contain pi1==" -RESULT="json:[ \"pi1\" ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== Get counter: types (shall be 1)===" -RESULT="1" -do_curl GET /counter/num_types 200 - -echo "=== Get counter: intstance ===" -RESULT="1" -do_curl GET /counter/num_instances 200 - - -echo "=== Set force response code 409. ===" -RESULT="*" -do_curl POST '/forceresponse?code=409' 200 - -echo "=== API: Get policy instances, shall fail with 409 ==" -RESULT="json:{\"title\": \"Conflict\", \"status\": 409, \"detail\": \"Request could not be processed in the current state of the resource\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 409 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"\", \"enforceReason\": \"\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi1/status 200 - -echo "=== API: Create policy instance pi2 of type: STD_1 ===" -res=$(cat jsonfiles/pi2.json) -RESULT="json:$res" -do_curl PUT /A1-P/v2/policytypes/STD_1/policies/pi2 201 jsonfiles/pi2.json - -echo "=== API: Update policy instance pi2 of type: STD_1 ===" -res=$(cat jsonfiles/pi2.json) -RESULT="json:$res" -do_curl PUT '/A1-P/v2/policytypes/STD_1/policies/pi2?notificationDestination=http://localhost:2223/statustest' 200 jsonfiles/pi2.json - -echo "=== API: Get policy instances, shall contain pi1 and pi2==" -RESULT="json:[ \"pi1\", \"pi2\" ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== Get counter: types (shall be 1)===" -RESULT="1" -do_curl GET /counter/num_types 200 - -echo "=== Get counter: intstance ===" -RESULT="2" -do_curl GET /counter/num_instances 200 - -echo "=== Set force delay 10. ===" -RESULT="Force delay: 10 sec set for all A1 responses" -do_curl POST '/forcedelay?delay=10' 200 - -echo "=== API: Get policy instances, shall contain pi1 and pi2==" -RESULT="json:[ \"pi1\", \"pi2\" ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== Reset force delay. ===" -RESULT="Force delay: None sec set for all A1 responses" -do_curl POST /forcedelay 200 - -echo "=== API: Get policy instance pi1 of type: STD_1 ===" -res=$(cat jsonfiles/pi1_updated.json) -RESULT="json:$res" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi1 200 - -echo "=== API: Get policy instance pi2 of type: STD_1 ===" -res=$(cat jsonfiles/pi2.json) -RESULT="json:$res" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi2 200 - -echo "=== API: DELETE policy instance pi1 ===" -RESULT="" -do_curl DELETE /A1-P/v2/policytypes/STD_1/policies/pi1 204 - -echo "=== API: Get policy instances, shall contain pi1 and pi2==" -RESULT="json:[ \"pi2\" ]" -do_curl GET /A1-P/v2/policytypes/STD_1/policies 200 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"\", \"enforceReason\": \"\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi2/status 200 - -echo "=== Set status for policy instance pi2 ===" -RESULT="Status set to OK for policy: pi2" -do_curl PUT '/status?policyid=pi2&status=OK' 200 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"OK\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi2/status 200 - -echo "=== Set status for policy instance pi2 ===" -RESULT="Status set to NOTOK and notok_reason for policy: pi2" -do_curl PUT '/status?policyid=pi2&status=NOTOK&reason=notok_reason' 200 - -echo "=== API: Get policy status ===" -RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\":\"notok_reason\"}" -do_curl GET /A1-P/v2/policytypes/STD_1/policies/pi2/status 200 - -echo "=== Send status for pi2===" -RESULT="json:{\"enforceStatus\": \"NOTOK\", \"enforceReason\": \"notok_reason\"}" -do_curl POST '/sendstatus?policyid=pi2' 200 - -echo "=== Get counter: datadelivery ===" -RESULT="0" -do_curl GET /counter/datadelivery 200 - -echo "=== Send data ===" -echo "{}" > .p.json -RESULT="" -do_curl POST /datadelivery 200 .p.json - -echo "=== Get counter: datadelivery ===" -RESULT="1" -do_curl GET /counter/datadelivery 200 - -echo "=== Get counter: intstance ===" -RESULT="1" -do_curl GET /counter/num_instances 200 - -echo "=== Get counter: types (shall be 0)===" -RESULT="1" -do_curl GET /counter/num_types 200 - -echo "=== Get counter: interface ===" -RESULT="STD_2.0.0" -do_curl GET /counter/interface 200 - -echo "=== Get counter: remote hosts ===" -RESULT="*" -do_curl GET /counter/remote_hosts 200 - -echo "********************" -echo "*** All tests ok ***" -echo "********************" diff --git a/near-rt-ric-simulator/test/STD_2.0.0/build_and_start.sh b/near-rt-ric-simulator/test/STD_2.0.0/build_and_start.sh deleted file mode 100755 index 2cba8c1..0000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/build_and_start.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -# Script to build and start the container - -echo "Building image" -cd ../../ - -#Build the image -docker build -t a1test . - -docker stop a1StdSimulator > /dev/null 2>&1 -docker rm -f a1StdSimulator > /dev/null 2>&1 - -echo "Starting ric-sim" -#Run the container in interactive mode, unsecure port 8085, secure port 8185 -docker run -it -p 8085:8085 -p 8185:8185 -e A1_VERSION=STD_2.0.0 -e ALLOW_HTTP=true -e REMOTE_HOSTS_LOGGING=1 --volume "$PWD/certificate:/usr/src/app/cert" --name a1StdSimulator a1test diff --git a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1.json b/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1.json deleted file mode 100644 index 25247a1..0000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "scope": { - "ueId": "ue1", - "qosId": "qos1" - }, - "statement": { - "priorityLevel": 5 - } -} - diff --git a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1_updated.json b/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1_updated.json deleted file mode 100644 index 7b4ada7..0000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi1_updated.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "scope": { - "ueId": "ue1", - "qosId": "qos1" - }, - "statement": { - "priorityLevel": 6 - } -} - diff --git a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi2.json b/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi2.json deleted file mode 100644 index 441a9cf..0000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/pi2.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "scope": { - "ueId": "ue2", - "qosId": "qos2" - }, - "statement": { - "priorityLevel": 5 - } -} - diff --git a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/std_1.json b/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/std_1.json deleted file mode 100644 index 9b0c302..0000000 --- a/near-rt-ric-simulator/test/STD_2.0.0/jsonfiles/std_1.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "policySchema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "STD_1_0.2.0", - "description": "STD 1 policy type", - "type": "object", - "properties": { - "scope": { - "type": "object", - "properties": { - "ueId": { - "type": "string" - }, - "qosId": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "ueId", - "qosId" - ] - }, - "statement": { - "type": "object", - "properties": { - "priorityLevel": { - "type": "number" - } - }, - "additionalProperties": false, - "required": [ - "priorityLevel" - ] - } - } - }, - "statusSchema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "STD_1_0.2.0", - "description": "STD 1 policy type status", - "type": "object", - "properties": { - "enforceStatus": { - "type": "string" - }, - "enforceReason": { - "type": "string" - }, - "additionalProperties": false, - "required": [ - "enforceStatus" - ] - } - } -} \ No newline at end of file diff --git a/near-rt-ric-simulator/tests/.gitignore b/near-rt-ric-simulator/tests/.gitignore deleted file mode 100644 index bee8a64..0000000 --- a/near-rt-ric-simulator/tests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/near-rt-ric-simulator/tests/test_osc_2_1_0.py b/near-rt-ric-simulator/tests/test_osc_2_1_0.py deleted file mode 100644 index 9d70ed0..0000000 --- a/near-rt-ric-simulator/tests/test_osc_2_1_0.py +++ /dev/null @@ -1,510 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -# This test case test the OSC_2.1.0 version of the simulator - -import json - -#Version of simulator -INTERFACE_VERSION="OSC_2.1.0" - -from unittest_setup import SERVER_URL, setup_env, get_testdata_dir, client - -#Setup env and import paths -setup_env(INTERFACE_VERSION) - -from compare_json import compare - -def test_apis(client): - - testdata=get_testdata_dir() - - # Simulator hello world - response=client.get(SERVER_URL) - assert response.status_code == 200 - - # Check used and implemented interfaces - response=client.get(SERVER_URL+'container_interfaces') - assert response.status_code == 200 - assert response.data == b"Current interface: OSC_2.1.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" - - # Reset simulator instances - response=client.post(SERVER_URL+'deleteinstances') - assert response.status_code == 200 - - # Reset simulator, all - response=client.post(SERVER_URL+'deleteall') - assert response.status_code == 200 - - # API: Healthcheck - response=client.get(SERVER_URL+'a1-p/healthcheck') - assert response.status_code == 200 - - # API: Get policy types, shall be empty - data_policytypes_get = [ ] - response=client.get(SERVER_URL+'a1-p/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policytypes_get, result) - assert res == True - - # API: Delete a policy type, shall fail - response=client.delete(SERVER_URL+'a1-p/policytypes/1') - assert response.status_code == 404 - - # API: Get policy instances for type 1, shall fail - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies') - assert response.status_code == 404 - - # Header for json payload - header = { - "Content-Type" : "application/json" - } - - # API: Put a policy type: 1 - with open(testdata+'pt1.json') as json_file: - policytype_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1', headers=header, data=json.dumps(policytype_1)) - assert response.status_code == 201 - - # API: Put a policy type: 1 again - with open(testdata+'pt1.json') as json_file: - policytype_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1', headers=header, data=json.dumps(policytype_1)) - assert response.status_code == 201 - - # API: Delete a policy type - response=client.delete(SERVER_URL+'a1-p/policytypes/1') - assert response.status_code == 204 - - # API: Get policy type ids, shall be empty - data_policytypes_get = [ ] - response=client.get(SERVER_URL+'a1-p/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policytypes_get, result) - assert res == True - - # API: Put a policy type: 1 - with open(testdata+'pt1.json') as json_file: - policytype_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1', headers=header, data=json.dumps(policytype_1)) - assert response.status_code == 201 - - # API: Get policy type ids, shall contain '1' - data_policytypes_get = [ 1 ] - response=client.get(SERVER_URL+'a1-p/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policytypes_get, result) - assert res == True - - # API: Get instances for type 1, shall be empty - data_policies_get = [ ] - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policies_get, result) - assert res == True - - # API: Create policy instance pi1 of type: 1 - with open(testdata+'pi1.json') as json_file: - policy_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1/policies/pi1', headers=header, data=json.dumps(policy_1)) - assert response.status_code == 202 - - # API: Get policy instance pi1 of type: 1 - with open(testdata+'pi1.json') as json_file: - policy_1 = json.load(json_file) - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies/pi1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(policy_1, result) - assert res == True - - # API: Update policy instance pi1 of type: 1 - with open(testdata+'pi1.json') as json_file: - policy_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1/policies/pi1', headers=header, data=json.dumps(policy_1)) - assert response.status_code == 202 - - # API: Update policy type: 1, shall fail - with open(testdata+'pt1.json') as json_file: - policytype_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1', headers=header, data=json.dumps(policytype_1)) - assert response.status_code == 400 - - # API: Get instances for type 1, shall contain 'pi1' - data_policies_get = [ "pi1" ] - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policies_get, result) - assert res == True - - # API: Create policy instance pi2 (copy of pi1) of type: 1. Shall fail - with open(testdata+'pi1.json') as json_file: - policy_2 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1/policies/pi2', headers=header, data=json.dumps(policy_2)) - assert response.status_code == 400 - - # Set force response code 401 - response=client.post(SERVER_URL+'forceresponse?code=401') - assert response.status_code == 200 - - # API: Get policy type 1. Shall fail with forced code - response=client.get(SERVER_URL+'a1-p/policytypes/1') - assert response.status_code == 401 - - # API: Get policy status - policy_status = { - "instance_status" : "NOT IN EFFECT", - "has_been_deleted" : "false", - "created_at" : "????" - } - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies/pi1/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(policy_status, result) - assert res == True - - # Load a policy type: 2 - with open(testdata+'pt2.json') as json_file: - policytype_2 = json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=2', headers=header, data=json.dumps(policytype_2)) - assert response.status_code == 201 - assert response.data == b"Policy type 2 is OK." - - # Load a policy type: 2, again - with open(testdata+'pt2.json') as json_file: - policytype_2 = json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=2', headers=header, data=json.dumps(policytype_2)) - assert response.status_code == 200 - assert response.data == b"Policy type 2 is OK." - - # API: Get policy type ids, shall contain '1' and '2' - data_policytypes_get = [ 1,2 ] - response=client.get(SERVER_URL+'a1-p/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policytypes_get, result) - assert res == True - - # Get policy type ids, shall contain type 1 and 2 ==" - data_policytypes_get = [ "1","2" ] - response=client.get(SERVER_URL+'policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policytypes_get, result) - assert res == True - - # API: Get policy type 2 - with open(testdata+'pt2.json') as json_file: - policytype_2 = json.load(json_file) - response=client.get(SERVER_URL+'a1-p/policytypes/2') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(policytype_2, result) - assert res == True - - # Delete a policy type - response=client.delete(SERVER_URL+'policytype?id=2') - assert response.status_code == 204 - - # API: Get policy type ids, shall contain '1' - data_policytypes_get = [ 1] - response=client.get(SERVER_URL+'a1-p/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policytypes_get, result) - assert res == True - - # Load a policy type: 2 - with open(testdata+'pt2.json') as json_file: - policytype_2 = json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=2', headers=header, data=json.dumps(policytype_2)) - assert response.status_code == 201 - assert response.data == b"Policy type 2 is OK." - - # API: Get policy type 2 - with open(testdata+'pt2.json') as json_file: - policytype_2 = json.load(json_file) - response=client.get(SERVER_URL+'a1-p/policytypes/2') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(policytype_2, result) - assert res == True - - # API: Get instances for type 2, shall be empty - data_policies_get = [ ] - response=client.get(SERVER_URL+'a1-p/policytypes/2/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policies_get, result) - assert res == True - - # API: Create policy instance pi1 of type: 2, shall fail - with open(testdata+'pi1.json') as json_file: - policy_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/2/policies/pi1', headers=header, data=json.dumps(policy_1)) - assert response.status_code == 400 - - # API: Create policy instance pi2 of type: 2. Missing param, shall fail - with open(testdata+'pi2_missing_param.json') as json_file: - policy_2 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/2/policies/pi1', headers=header, data=json.dumps(policy_2)) - assert response.status_code == 400 - - # API: Create policy instance pi2 of type: 2 - with open(testdata+'pi2.json') as json_file: - policy_2 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/2/policies/pi2', headers=header, data=json.dumps(policy_2)) - assert response.status_code == 202 - - with open(testdata+'pi2.json') as json_file: - policy_2 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/2/policies/pi2', headers=header, data=json.dumps(policy_2)) - assert response.status_code == 202 - - # API: Get instances for type 1, shall contain pi1 - data_policies_get = [ "pi1" ] - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policies_get, result) - assert res == True - - # API: Get instances for type 2, shall contain pi2 - data_policies_get = ["pi2" ] - response=client.get(SERVER_URL+'a1-p/policytypes/2/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policies_get, result) - assert res == True - - # API: Create policy instance pi11 (copy of pi1) of type: 1. Shall fail - with open(testdata+'pi1.json') as json_file: - policy_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1/policies/pi11', headers=header, data=json.dumps(policy_1)) - assert response.status_code == 400 - - # Set force response code 409. ===" - response=client.post(SERVER_URL+'forceresponse?code=401') - assert response.status_code == 200 - - # API: Get policy status for pi1, shall fail - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies/pi1/status') - assert response.status_code == 401 - - # Set force delay 10 - response=client.post(SERVER_URL+'forcedelay?delay=10') - assert response.status_code == 200 - assert response.data == b"Force delay: 10 sec set for all A1 responses" - - # API: Get policy status for pi1. Shall delay 10 sec - policy_status = { - "instance_status" : "NOT IN EFFECT", - "has_been_deleted" : "false", - "created_at" : "????" - } - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies/pi1/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(policy_status, result) - assert res == True - - # Reset force delay - response=client.post(SERVER_URL+'forcedelay') - assert response.status_code == 200 - assert response.data == b"Force delay: None sec set for all A1 responses" - - # Set status for pi1 - response=client.put(SERVER_URL+'status?policyid=pi1&status=IN%20EFFECT') - assert response.status_code == 200 - - # API: Get policy status for pi1 - policy_status = { - "instance_status" : "IN EFFECT", - "has_been_deleted" : "false", - "created_at" : "????" - } - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies/pi1/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(policy_status, result) - assert res == True - - # Set status for pi1 - response=client.put(SERVER_URL+'status?policyid=pi1&status=IN%20EFFECT&deleted=true&created_at=2020-03-30%2012:00:00') - assert response.status_code == 200 - - # API: Get policy status for pi1 - policy_status = { - "instance_status" : "IN EFFECT", - "has_been_deleted" : "true", - "created_at" : "????" - } - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies/pi1/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(policy_status, result) - assert res == True - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"2" - - # Get counter: types (shall be 2) - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"2" - - # Get counter: interface - response=client.get(SERVER_URL+'counter/interface') - assert response.status_code == 200 - assert response.data == b"OSC_2.1.0" - - # Get counter: remote hosts - response=client.get(SERVER_URL+'counter/remote_hosts') - assert response.status_code == 200 - - # Get counter: test, shall fail - response=client.get(SERVER_URL+'counter/test') - assert response.status_code == 404 - - # API: DELETE policy instance pi1 - response=client.delete(SERVER_URL+'a1-p/policytypes/1/policies/pi1') - assert response.status_code == 202 - - # API: Get instances for type 1, shall be empty - data_policies_get = [ ] - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policies_get, result) - assert res == True - - # API: Get instances for type 2, shall contain pi2 - data_policies_get = ["pi2" ] - response=client.get(SERVER_URL+'a1-p/policytypes/2/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policies_get, result) - assert res == True - - # Get counter: instances - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"1" - - - ### Tests to increase code coverage - - # Set force response code 500 - response=client.post(SERVER_URL+'forceresponse?code=500') - assert response.status_code == 200 - - # API: Healthcheck - response=client.get(SERVER_URL+'a1-p/healthcheck') - assert response.status_code == 500 - - # Set force response code 501 - response=client.post(SERVER_URL+'forceresponse?code=501') - assert response.status_code == 200 - - # API: Get policy types - data_policytypes_get = [ ] - response=client.get(SERVER_URL+'a1-p/policytypes') - assert response.status_code == 501 - - # Set force response code 502 - response=client.post(SERVER_URL+'forceresponse?code=502') - assert response.status_code == 200 - - # API: Delete a policy type, shall fail - response=client.delete(SERVER_URL+'a1-p/policytypes/55') - assert response.status_code == 502 - - # Set force response code 503. ===" - response=client.post(SERVER_URL+'forceresponse?code=503') - assert response.status_code == 200 - - with open(testdata+'pi1.json') as json_file: - policy_1 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/1/policies/pi11', headers=header, data=json.dumps(policy_1)) - assert response.status_code == 503 - - # Set force response code 504 - response=client.post(SERVER_URL+'forceresponse?code=504') - assert response.status_code == 200 - - # API: Get instances for type 1, shall fail - data_policies_get = [ ] - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies') - assert response.status_code == 504 - - # Set force response code 505. ===" - response=client.post(SERVER_URL+'forceresponse?code=505') - assert response.status_code == 200 - - # API: delete instance pi1, shall fail - response=client.delete(SERVER_URL+'a1-p/policytypes/1/policies/pi1') - assert response.status_code == 505 - - # API: Delete a policy type having instances, shall fail - response=client.delete(SERVER_URL+'a1-p/policytypes/2') - assert response.status_code == 400 - - # API: delete instance pi1 in type 5, shall fail - response=client.delete(SERVER_URL+'a1-p/policytypes/5/policies/pi1') - assert response.status_code == 404 - - # API: delete instance pi99 in type 1, shall fail - response=client.delete(SERVER_URL+'a1-p/policytypes/1/policies/pi99') - assert response.status_code == 404 - - # API: Create policy instance pi80 of type: 5 - with open(testdata+'pi1.json') as json_file: - policy_80 = json.load(json_file) - response=client.put(SERVER_URL+'a1-p/policytypes/5/policies/pi80', headers=header, data=json.dumps(policy_80)) - assert response.status_code == 404 - - # API: Get policy type - data_policytypes_get = [ ] - response=client.get(SERVER_URL+'a1-p/policytypes/55') - assert response.status_code == 404 - - # API: Get status, bad type - shall fail - response=client.get(SERVER_URL+'a1-p/policytypes/99/policies/pi1/status') - assert response.status_code == 404 - - # API: Get status, bad instance - shall fail - response=client.get(SERVER_URL+'a1-p/policytypes/1/policies/pi111/status') - assert response.status_code == 404 - - # Load policy type, no type in url - shall faill - with open(testdata+'pt2.json') as json_file: - policytype_2 = json.load(json_file) - response=client.put(SERVER_URL+'policytype', headers=header, data=json.dumps(policytype_2)) - assert response.status_code == 400 - - # Load policy type - duplicatee - shall faill - with open(testdata+'pt1.json') as json_file: - policytype_1 = json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=2', headers=header, data=json.dumps(policytype_1)) - assert response.status_code == 400 diff --git a/near-rt-ric-simulator/tests/test_std_1_1_3.py b/near-rt-ric-simulator/tests/test_std_1_1_3.py deleted file mode 100644 index 721d7a6..0000000 --- a/near-rt-ric-simulator/tests/test_std_1_1_3.py +++ /dev/null @@ -1,459 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -# This test case test the STD_1.1.3 version of the simulator - -import json - -#Version of simulator -INTERFACE_VERSION="STD_1.1.3" - -from unittest_setup import SERVER_URL, HOST_IP, PORT_NUMBER, setup_env, client - -#Setup env and import paths -setup_env(INTERFACE_VERSION) - -from compare_json import compare - -def test_apis(client): - - # Simulator hello world - response=client.get(SERVER_URL) - assert response.status_code == 200 - - # Check used and implemented interfaces - response=client.get(SERVER_URL+'container_interfaces') - assert response.status_code == 200 - assert response.data == b"Current interface: STD_1.1.3 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" - - # Reset simulator instances - response=client.post(SERVER_URL+'deleteinstances') - assert response.status_code == 200 - - # Reset simulator, all - response=client.post(SERVER_URL+'deleteall') - assert response.status_code == 200 - - # API: Get policy instances, shall be empty - data_policy_get = [ ] - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_get, result) - assert res == True - - #API: Create policy instance pi1 - data_pi1 = { - "scope": { - "ueId": "ue1", - "groupId": "group1", - "sliceId": "slice1", - "qosId": "qos1", - "cellId": "cell1" - }, - "statement": { - "priorityLevel": 5 - } - } - # header for json payload - header = { - "Content-Type" : "application/json" - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi1', headers=header, data=json.dumps(data_pi1)) - assert response.status_code == 201 - result=json.loads(response.data) - res=compare(data_pi1, result) - assert res == True - - #API: Update policy instance pi1 - data_pi1_updated = { - "scope": { - "ueId": "ue1", - "groupId": "group1", - "sliceId": "slice1", - "qosId": "qos1", - "cellId": "cell1" - }, - "statement": { - "priorityLevel": 6 - } - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi1', headers=header, data=json.dumps(data_pi1_updated)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_pi1_updated, result) - assert res == True - - #API: Create policy instance pi9, bad json - response=client.put(SERVER_URL+'A1-P/v1/policies/pi9', headers=header, data="test") - assert response.status_code == 400 - - # API: Get policy instances, shall contain pi1 - data_policy_get = [ "pi1" ] - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_get, result) - assert res == True - - # API: Create policy instance pi2 (copy of pi1). Shall fail - data_create_errror_pi1 = { - "title" : "The policy json already exists.", - "status" : 400, - "instance" : "pi2" - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi2', headers=header, data=json.dumps(data_pi1_updated)) - assert response.status_code == 400 - result=json.loads(response.data) - res=compare(data_create_errror_pi1, result) - assert res == True - - # Set force response code 409. ===" - response=client.post(SERVER_URL+'forceresponse?code=409') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_get_errror = { - "title" : "Conflict", - "status" : 409, - "detail" : "Request could not be processed in the current state of the resource" - } - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 409 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Reset force response - response=client.post(SERVER_URL+'forceresponse') - assert response.status_code == 200 - assert response.data == b"Force response code: None set for one single A1 response" - - ### - ### Repeating the above two test for code coverage - ### - # Set force response code 400 - response=client.post(SERVER_URL+'forceresponse?code=400') - assert response.status_code == 200 - - #API: Create policy instance pi3, shall fail - data_pi3 = { - "scope": { - "ueId": "ue3" - }, - "statement": { - "priorityLevel": 5 - } - } - data_get_errror = { - "title" : "Bad request", - "status" : 400, - "detail" : "Object in payload not properly formulated or not related to the method" - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi3', headers=header, data=json.dumps(data_pi3)) - assert response.status_code == 400 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 404 - response=client.post(SERVER_URL+'forceresponse?code=404') - assert response.status_code == 200 - - # API: Get policy instance pi1, shall fail ==" - data_get_errror = { - "title" : "Not found", - "status" : 404, - "detail" : "No resource found at the URI" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi1') - assert response.status_code == 404 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 405 - response=client.post(SERVER_URL+'forceresponse?code=405') - assert response.status_code == 200 - - # API: Delete policy instances pi1, shall fail ==" - data_get_errror = { - "title" : "Method not allowed", - "status" : 405, - "detail" : "Method not allowed for the URI" - } - response=client.delete(SERVER_URL+'A1-P/v1/policies/pi1') - assert response.status_code == 405 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 429 - response=client.post(SERVER_URL+'forceresponse?code=429') - assert response.status_code == 200 - - # API: Get policy status pi3, shall fail ==" - data_get_errror = { - "title" : "Too many requests", - "status" : 429, - "detail" : "Too many requests have been sent in a given amount of time" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi3/status') - assert response.status_code == 429 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 507 - response=client.post(SERVER_URL+'forceresponse?code=507') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_get_errror = { - "title" : "Insufficient storage", - "status" : 507, - "detail" : "The method could not be performed on the resource because the provider is unable to store the representation needed to successfully complete the request" - } - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 507 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 503. ===" - response=client.post(SERVER_URL+'forceresponse?code=503') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_get_errror = { - "title" : "Service unavailable", - "status" : 503, - "detail" : "The provider is currently unable to handle the request due to a temporary overload" - } - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 503 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set force response code 555. ===" - response=client.post(SERVER_URL+'forceresponse?code=555') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_get_errror = { - "title" : "Unknown", - "status" : "555", - "detail" : "Not implemented response code" - } - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 555 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - ### - ### End of repeated test - ### - - - # API: Get policy status - data_policy_status = { - "enforceStatus" : "UNDEFINED" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi1/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_status, result) - assert res == True - - # API: Create policy instance pi2 - data_pi2 = { - "scope": { - "ueId": "ue2", - "groupId": "group2", - "sliceId": "slice2", - "qosId": "qos2", - "cellId": "cell2" - }, - "statement": { - "priorityLevel": 10 - } - } - response=client.put(SERVER_URL+'A1-P/v1/policies/pi2', headers=header, data=json.dumps(data_pi2)) - assert response.status_code == 201 - result=json.loads(response.data) - res=compare(data_pi2, result) - assert res == True - - - # API: Update policy instance pi2 - # Reuse same policy data - response=client.put(SERVER_URL+'A1-P/v1/policies/pi2?notificationDestination=http://'+HOST_IP+':'+PORT_NUMBER+'/statustest', headers=header, data=json.dumps(data_pi2)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_pi2, result) - assert res == True - - # API: Get policy instances, shall contain pi1 and pi2 - data_policy_get = [ "pi1", "pi2" ] - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_get, result) - assert res == True - - # Set force delay 10 - response=client.post(SERVER_URL+'forcedelay?delay=10') - assert response.status_code == 200 - assert response.data == b"Force delay: 10 sec set for all A1 responses" - - # API: Get policy instances, shall contain pi1 and pi2 and delayed 10 sec - data_policy_get = [ "pi1", "pi2" ] - response=client.get(SERVER_URL+'A1-P/v1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_policy_get, result) - assert res == True - - # Reset force delay - response=client.post(SERVER_URL+'forcedelay') - assert response.status_code == 200 - assert response.data == b"Force delay: None sec set for all A1 responses" - - # API: GET policy instance pi1 - response=client.get(SERVER_URL+'A1-P/v1/policies/pi1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_pi1_updated, result) - assert res == True - - # API: GET policy instance pi2 - response=client.get(SERVER_URL+'A1-P/v1/policies/pi2') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_pi2, result) - assert res == True - - # API: GET policy instance pi9, shall fail - response=client.get(SERVER_URL+'A1-P/v1/policies/pi9') - assert response.status_code == 404 - - # API: DELETE policy instance pi1 - response=client.delete(SERVER_URL+'A1-P/v1/policies/pi1') - assert response.status_code == 204 - - # API: DELETE policy instance pi9, shall fail - response=client.delete(SERVER_URL+'A1-P/v1/policies/pi9') - assert response.status_code == 404 - - # API: Get policy status for pi1, shall fail - data_get_errror = { - "title" : "The policy identity does not exist.", - "status" : 404, - "detail" : "There is no existing policy instance with the identity: pi1", - "instance" : "pi1" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi1/status') - assert response.status_code == 404 - result=json.loads(response.data) - res=compare(data_get_errror, result) - assert res == True - - # Set status for policy instance pi2 - response=client.put(SERVER_URL+'status?policyid=pi2&status=OK') - assert response.status_code == 200 - - # API: Get policy status for pi2 - data_get_status = { - "enforceStatus" : "OK" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_get_status, result) - assert res == True - - # Set status for policy instance pi2 - response=client.put(SERVER_URL+'status?policyid=pi2&status=NOTOK&reason=notok_reason') - assert response.status_code == 200 - - # API: Get policy status for pi2 - data_get_status = { - "enforceStatus" : "NOTOK", - "enforceReason" : "notok_reason" - } - response=client.get(SERVER_URL+'A1-P/v1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_get_status, result) - assert res == True - - #Found no way to test these functions - #'sendstatus' will send a http request that will fail - #since no server will receive the call - #These function is instead tested when running the bash script in the 'test' dir - # # Send status for pi2 - # response=client.post(SERVER_URL+'sendstatus?policyid=pi2') - # assert response.status_code == 200 - # result=json.loads(response.data) - # res=compare(data_get_status, result) - # assert res == True - - # # Send status, shall fail - # response=client.post(SERVER_URL+'sendstatus') - # assert response.status_code == 400 - - # # Send status pi9, shall fail - # response=client.post(SERVER_URL+'sendstatus?policyid=pi9') - # assert response.status_code == 404 - - # Set status for policy instance , shall fail - response=client.put(SERVER_URL+'status') - assert response.status_code == 400 - - # Set status for policy instance pi9, shall fail - response=client.put(SERVER_URL+'status?policyid=pi9') - assert response.status_code == 404 - - # Set status for policy instance pi2, shall fail - response=client.put(SERVER_URL+'status?policyid=pi2') - assert response.status_code == 400 - - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"1" - - # Get counter: types (shall be 0) - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"0" - - # Get counter: interface - response=client.get(SERVER_URL+'counter/interface') - assert response.status_code == 200 - assert response.data == b"STD_1.1.3" - - # Get counter: remote hosts - response=client.get(SERVER_URL+'counter/remote_hosts') - assert response.status_code == 200 - - # Get counter: test, shall fail - response=client.get(SERVER_URL+'counter/test') - assert response.status_code == 404 diff --git a/near-rt-ric-simulator/tests/test_std_2_0_0.py b/near-rt-ric-simulator/tests/test_std_2_0_0.py deleted file mode 100644 index d63d4c3..0000000 --- a/near-rt-ric-simulator/tests/test_std_2_0_0.py +++ /dev/null @@ -1,436 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -# This test case test the STD_2.0.0 version of the simulator - -import json -import time - -#Version of simulator -INTERFACE_VERSION="STD_2.0.0" - -from unittest_setup import SERVER_URL, HOST_IP, PORT_NUMBER, setup_env, get_testdata_dir, client - -#Setup env and import paths -setup_env(INTERFACE_VERSION) - -from compare_json import compare - -def test_apis(client): - - testdata=get_testdata_dir() - - # Header for json payload - header = { - "Content-Type" : "application/json" - } - - # Simulator hello world - response=client.get(SERVER_URL) - assert response.status_code == 200 - - # Check used and implemented interfaces - response=client.get(SERVER_URL+'container_interfaces') - assert response.status_code == 200 - assert response.data == b"Current interface: STD_2.0.0 All supported A1 interface yamls in this container: ['OSC_2.1.0', 'STD_1.1.3', 'STD_2.0.0']" - - # Reset simulator instances - response=client.post(SERVER_URL+'deleteinstances') - assert response.status_code == 200 - - # Reset simulator, all - response=client.post(SERVER_URL+'deleteall') - assert response.status_code == 200 - - # Get counter: interface - response=client.get(SERVER_URL+'counter/interface') - assert response.status_code == 200 - assert response.data == b"STD_2.0.0" - - # Get counter: remote hosts - response=client.get(SERVER_URL+'counter/remote_hosts') - assert response.status_code == 200 - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"0" - - # Get counter: types - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"0" - - # API: Get policy type, shall be empty - data_response = [ ] - response=client.get(SERVER_URL+'A1-P/v2/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Get policy instances for type 1, type not found - data_response = {"title": "The policy type does not exist.", "status": 404, "instance": "1"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/1/policies') - assert response.status_code == 404 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Get policy instances, type not found - data_response = {"title": "The policy type does not exist.", "status": 404, "instance": "test"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/test/policies') - assert response.status_code == 404 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Put a policy type: STD_1 - with open(testdata+'std_1.json') as json_file: - data_response = b"Policy type STD_1 is OK." - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=STD_1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 201 - assert data_response == response.data - - # Put a policy type: STD_1, again - with open(testdata+'std_1.json') as json_file: - data_response = b"Policy type STD_1 is OK." - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=STD_1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - assert data_response == response.data - - # API: Get policy type ids, shall contain type STD_1 - data_response = [ "STD_1" ] - response=client.get(SERVER_URL+'A1-P/v2/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Delete a policy type: STD_1 - data_response = b"" - response=client.delete(SERVER_URL+'policytype?id=STD_1') - assert response.status_code == 204 - assert data_response == response.data - - # API: Get policy type ids, shall be empty - data_response = [ ] - response=client.get(SERVER_URL+'A1-P/v2/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Put a policy type: STD_1 - with open(testdata+'std_1.json') as json_file: - data_response = b"Policy type STD_1 is OK." - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'policytype?id=STD_1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 201 - assert data_response == response.data - - # API: Get policy type ids, shall contain type STD_1 - data_response = [ "STD_1" ] - response=client.get(SERVER_URL+'A1-P/v2/policytypes') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Get counter: types (shall be 1) - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"1" - - # API: Get policy type: STD_1 - with open(testdata+'std_1.json') as json_file: - data_response = json.load(json_file) - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: API: Get policy instances, shall be empty - data_response = [] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Create policy instance pi1 of type: STD_1 - with open(testdata+'pi1.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 201 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: API: Get policy instance pi1 of type: STD_1 - with open(testdata+'pi1.json') as json_file: - data_response = json.load(json_file) - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Update policy instance pi1 of type: STD_1 - with open(testdata+'pi1.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: Update policy instance pi1 of type: STD_1 - with open(testdata+'pi1_updated.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: Duplicate policy instance pi2 of type: STD_1 - with open(testdata+'pi1_updated.json') as json_file: - data_response = {"title": "Duplicate, the policy json already exists.", "status": 400, "instance": "pi2"} - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 400 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Get policy instances, shall contain pi1 - data_response = ["pi1"] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"1" - - # Get counter: types - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"1" - - # Set force response code 409. ===" - response=client.post(SERVER_URL+'forceresponse?code=409') - assert response.status_code == 200 - - # API: Get policy instances, shall fail - data_response = {"title" : "Conflict", "status" : 409, "detail" : "Request could not be processed in the current state of the resource"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 409 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: API: Get policy status - data_response = {"enforceStatus" : "", "enforceReason" : ""} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: Create policy instance pi2 of type: STD_1 - with open(testdata+'pi2.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 201 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: Update policy instance pi2 of type: STD_1 - with open(testdata+'pi2.json') as json_file: - json_payload=json.load(json_file) - response=client.put(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(json_payload, result) - assert res == True - - # API: Get policy instances, shall contain pi1 and pi2 - data_response = ["pi1","pi2"] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"2" - - # Get counter: types - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"1" - - # Set force delay 10 - response=client.post(SERVER_URL+'forcedelay?delay=10') - assert response.status_code == 200 - assert response.data == b"Force delay: 10 sec set for all A1 responses" - - #start time stamp - start=time.time() - - # API: Get policy instances, shall contain pi1 and pi2 and delayed 10 sec - data_response = ["pi1","pi2"] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - end=time.time() - - assert (end-start) > 9 - - # Reset force delay - response=client.post(SERVER_URL+'forcedelay') - assert response.status_code == 200 - assert response.data == b"Force delay: None sec set for all A1 responses" - - # API: API: Get policy instance pi1 of type: STD_1 - with open(testdata+'pi1_updated.json') as json_file: - data_response = json.load(json_file) - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: API: Get policy instance pi2 of type: STD_1 - with open(testdata+'pi2.json') as json_file: - data_response = json.load(json_file) - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: DELETE policy instance pi1 - data_response = b"" - response=client.delete(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi1') - assert response.status_code == 204 - assert data_response == response.data - - # API: Get policy instances, shall contain pi2 - data_response = ["pi2"] - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # API: API: Get policy status - data_response = {"enforceStatus" : "", "enforceReason" : ""} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - # Set status for policy instance pi2 - response=client.put(SERVER_URL+'status?policyid=pi2&status=OK') - assert response.status_code == 200 - - # API: API: Get policy status - data_response = {"enforceStatus" : "OK"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - print(response.data) - assert res == True - - # Set status for policy instance pi2 - response=client.put(SERVER_URL+'status?policyid=pi2&status=NOTOK&reason=notok_reason') - assert response.status_code == 200 - - # API: API: Get policy status - data_response = {"enforceStatus" : "NOTOK", "enforceReason" : "notok_reason"} - response=client.get(SERVER_URL+'A1-P/v2/policytypes/STD_1/policies/pi2/status') - assert response.status_code == 200 - result=json.loads(response.data) - res=compare(data_response, result) - assert res == True - - - # #Found no way to test these functions - # #'sendstatus' will send a http request that will fail - # #since no server will receive the call - # #These function is instead tested when running the bash script in the 'test' dir - # # # Send status for pi2 - # # response=client.post(SERVER_URL+'sendstatus?policyid=pi2') - # # assert response.status_code == 200 - # # result=json.loads(response.data) - # # res=compare(data_get_status, result) - # # assert res == True - - # # # Send status, shall fail - # # response=client.post(SERVER_URL+'sendstatus') - # # assert response.status_code == 400 - - # Get counter: data_delivery - response=client.get(SERVER_URL+'counter/datadelivery') - assert response.status_code == 200 - assert response.data == b"0" - - # Send data - json_payload={} - response=client.post(SERVER_URL+'datadelivery', headers=header, data=json.dumps(json_payload)) - assert response.status_code == 200 - - # Get counter: data_delivery - response=client.get(SERVER_URL+'counter/datadelivery') - assert response.status_code == 200 - assert response.data == b"1" - - # Get counter: interface - response=client.get(SERVER_URL+'counter/interface') - assert response.status_code == 200 - assert response.data == b"STD_2.0.0" - - # Get counter: remote hosts - response=client.get(SERVER_URL+'counter/remote_hosts') - assert response.status_code == 200 - - # Get counter: intstance - response=client.get(SERVER_URL+'counter/num_instances') - assert response.status_code == 200 - assert response.data == b"1" - - # Get counter: types - response=client.get(SERVER_URL+'counter/num_types') - assert response.status_code == 200 - assert response.data == b"1" \ No newline at end of file diff --git a/near-rt-ric-simulator/tests/unittest_setup.py b/near-rt-ric-simulator/tests/unittest_setup.py deleted file mode 100644 index 0dbbd22..0000000 --- a/near-rt-ric-simulator/tests/unittest_setup.py +++ /dev/null @@ -1,58 +0,0 @@ -# ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. -# ======================================================================== -# 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 -# -# 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. -# ============LICENSE_END================================================= -# - -# Setting up dir and env for unit test of simualators -import sys -import os -import pytest - -#Server port and base path -PORT_NUMBER="2222" -HOST_IP="localhost" -SERVER_URL="http://"+HOST_IP+":"+PORT_NUMBER+"/" - -#Dir for json test data files -testdata="" - -def setup_env(interface_version): - global testdata - cwd=os.getcwd()+"/" - # Env TESTS_BASE_PATH is set when executed via tox.ini - # If basic test is executed from cmd line, that env var is not needed - if 'TESTS_BASE_PATH' in os.environ: - cwd=os.environ['TESTS_BASE_PATH']+"/" - testdata=cwd+"../test/"+interface_version+"/jsonfiles/" - - #Env var to setup version and host logging - os.environ['APIPATH'] = cwd+"../api/"+interface_version - os.environ['REMOTE_HOSTS_LOGGING'] = "ON" - - # Paths need to run the sim, including needed source file dirs - sys.path.append(os.path.abspath(cwd+'../src/common')) - sys.path.append(os.path.abspath(cwd+'../test/common')) - sys.path.append(os.path.abspath(cwd+'../src/'+interface_version)) - os.chdir(cwd+"../src/"+interface_version) - -def get_testdata_dir(): - return testdata - -#Test client for rest calls -@pytest.fixture -def client(): - from main import app - with app.app.test_client() as c: - yield c \ No newline at end of file diff --git a/near-rt-ric-simulator/src/common/utils.py b/near-rt-ric-simulator/utils.py similarity index 72% rename from near-rt-ric-simulator/src/common/utils.py rename to near-rt-ric-simulator/utils.py index 1ed2a7e..8f7e284 100644 --- a/near-rt-ric-simulator/src/common/utils.py +++ b/near-rt-ric-simulator/utils.py @@ -1,12 +1,7 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2023, S. K. Chaudhary. All rights reserved. # ======================================================================== -# 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 -# +# # 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. diff --git a/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py b/near-rt-ric-simulator/var_declaration.py similarity index 71% rename from near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py rename to near-rt-ric-simulator/var_declaration.py index 06b0031..f4a1d8b 100644 --- a/near-rt-ric-simulator/src/STD_1.1.3/var_declaration.py +++ b/near-rt-ric-simulator/var_declaration.py @@ -1,12 +1,7 @@ # ============LICENSE_START=============================================== -# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# Copyright (C) 2023, S. K. Chaudhary. All rights reserved. # ======================================================================== -# 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 -# +# # 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. diff --git a/tox.ini b/tox.ini index 8250799..8c68c26 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,14 @@ -# ================================================================================== -# Copyright (c) 2020 Nordix +# ============LICENSE_START=============================================== +# Copyright (C) 2023, S. K. Chaudhary. All rights reserved. +# ======================================================================== +# +# 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. +# ============LICENSE_END================================================= # -# 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 -# -# 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. -# ================================================================================== [tox] envlist = code,docs,docs-linkcheck -- GitLab