├── .github ├── docker-resolv.sh └── workflows │ ├── basic.yml │ └── wait-for-docker.sh ├── .gitignore ├── COPYING ├── README.md ├── backup.sh ├── boards-ci-2022.01.yaml ├── boards-ci-2023.01.yaml ├── boards-ci-2023.06.yaml ├── boards-ci-2023.10.yaml ├── boards-ci.yaml ├── boards.yaml.example ├── boards.yaml.minimal ├── deploy.sh ├── dhcpd └── dhcpd.conf ├── healthcheck ├── Dockerfile └── port.conf ├── lava-master ├── Dockerfile ├── apache2 │ └── .empty ├── backup │ └── .empty ├── default │ └── .empty ├── device-types-patch │ ├── .empty │ └── patch-device-type.sh ├── device-types │ └── .empty ├── entrypoint.d │ └── 01_setup.sh ├── env │ └── .empty ├── health-checks │ └── .empty └── lava-patch │ └── .empty ├── lava-slave-install.md ├── lava-slave ├── Dockerfile ├── aliases │ └── .empty ├── configs │ ├── lava-slave │ └── tftpd-hpa ├── default │ └── .empty ├── deviceinfo │ └── .empty ├── entrypoint.d │ └── empty ├── grub.cfg ├── lava-coordinator │ └── .empty ├── lava-patch │ └── .empty ├── lavapdu.conf ├── scripts │ ├── cu-loop │ ├── extra_actions │ ├── getworkertoken.py │ ├── retire.sh │ ├── setdispatcherip.py │ ├── setup.sh │ └── start.sh ├── ser2net.yaml └── tags │ └── .empty ├── lavalab-gen.py ├── lavalab-gen.sh ├── requirements.txt ├── squid ├── Dockerfile ├── entrypoint.sh └── squid.conf └── standalone-slave.yaml.example /.github/docker-resolv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | docker run busybox nslookup github.com 4 | if [ $? -eq 0 ]; then 5 | echo "DEBUG: DNS query works in docker" 6 | # exit 0 7 | fi 8 | 9 | sudo echo ' 10 | { 11 | "dns": ["8.8.8.8"] 12 | }' > /etc/docker/daemon.json 13 | 14 | sudo service docker restart || exit $? 15 | -------------------------------------------------------------------------------- /.github/workflows/basic.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: basic 3 | on: # yamllint disable-line rule:truthy rule:line-length 4 | push: 5 | pull_request: 6 | 7 | jobs: 8 | check-lava-lab-gen: 9 | runs-on: ubuntu-22.04 10 | steps: 11 | - uses: actions/checkout@v3 12 | - name: install lavacli 13 | run: sudo apt-get -y install lavacli 14 | - run: ./lavalab-gen.py boards-ci.yaml 15 | - run: cat output/local/docker-compose.yml 16 | - name: Verify DNS query in docker 17 | run: sh .github/docker-resolv.sh 18 | - name: Build lava-docker 19 | run: cd output/local && docker-compose build 20 | check-formats: 21 | runs-on: ubuntu-22.04 22 | steps: 23 | - uses: actions/checkout@v3 24 | - name: install yamllint 25 | run: sudo apt-get -y install yamllint 26 | - name: verify yaml files 27 | run: find -iname '*.yaml' | xargs yamllint 28 | - name: verify yml files 29 | run: find -iname '*.yml' | xargs yamllint 30 | check-lava-upgrade: 31 | runs-on: ubuntu-22.04 32 | steps: 33 | - uses: actions/checkout@v3 34 | - name: install lavacli 35 | run: sudo apt-get -y install lavacli 36 | - run: ./lavalab-gen.py boards-ci-2022.01.yaml 37 | - run: cat output/local/docker-compose.yml 38 | - name: Verify DNS query in docker 39 | run: sh .github/docker-resolv.sh 40 | - name: Build lava-docker 41 | run: cd output/local && docker-compose build 42 | - name: Launch lava-docker 43 | run: cd output/local && docker-compose up -d 44 | - name: Wait for LAVA to be started 45 | run: sh .github/workflows/wait-for-docker.sh 46 | - name: Wait for first job to be completed 47 | # yamllint disable-line rule:line-length 48 | run: lavacli --uri http://admin:tokenforci@127.0.0.1:10080/RPC2 jobs wait 1 49 | 50 | - name: Run backup 51 | run: ./backup.sh 52 | - name: stop docker 53 | run: cd output/local && docker-compose down 54 | 55 | - name: Clean old install 56 | run: rm -r output 57 | - name: Copy backup 58 | run: cp -v backup-latest/* lava-master/backup/ 59 | - name: Run lavalab-gen 60 | run: ./lavalab-gen.py boards-ci-2023.01.yaml 61 | - name: Build lava-docker 62 | run: cd output/local && docker-compose build 63 | - name: Launch lava-docker 64 | run: cd output/local && docker-compose up -d 65 | - name: Wait for LAVA to be started 66 | run: sh .github/workflows/wait-for-docker.sh 67 | - name: Wait for first job to be completed 68 | # yamllint disable-line rule:line-length 69 | run: lavacli --uri http://admin:tokenforci@127.0.0.1:10080/RPC2 jobs wait 2 70 | - name: Verify we still have logs 71 | # yamllint disable-line rule:line-length 72 | run: lavacli --uri http://admin:tokenforci@127.0.0.1:10080/RPC2 jobs logs 1 73 | - name: Verify we still have logs really 74 | # yamllint disable-line rule:line-length 75 | run: lavacli --uri http://admin:tokenforci@127.0.0.1:10080/RPC2 jobs logs 1 > log1 && [[ -s log1 ]] || exit 1 76 | - name: stop docker 77 | run: cd output/local && docker-compose down 78 | 79 | - name: restart lava-docker 80 | run: cd output/local && docker-compose up -d 81 | - name: Wait for LAVA to be started 82 | run: sh .github/workflows/wait-for-docker.sh 83 | 84 | - name: Run backup of 2023.01 85 | run: ./backup.sh 86 | - name: stop docker 87 | run: cd output/local && docker-compose down 88 | 89 | # - name: Clean old install 90 | # run: rm -r output 91 | # - name: Copy backup 92 | # run: cp -v backup-latest/* lava-master/backup/ 93 | # - name: Run lavalab-gen 94 | # run: ./lavalab-gen.py boards-ci-2023.06.yaml 95 | # - name: Build lava-docker 2023.06 96 | # run: cd output/local && docker-compose build 97 | # - name: Launch lava-docker 2023.06 98 | # run: cd output/local && docker-compose up -d 99 | # - name: Wait for LAVA 2023.06 to be started 100 | # run: sh .github/workflows/wait-for-docker.sh 101 | # 102 | # - name: Run backup of 2023.06 103 | # run: ./backup.sh 104 | # - name: stop docker 105 | # run: cd output/local && docker-compose down 106 | 107 | - name: Clean old install 108 | run: rm -r output 109 | - name: Copy backup 110 | run: cp -v backup-latest/* lava-master/backup/ 111 | - name: Run lavalab-gen 112 | run: ./lavalab-gen.py boards-ci-2023.10.yaml 113 | - name: Build lava-docker 2023.10 114 | run: cd output/local && docker-compose build 115 | - name: Launch lava-docker 2023.10 116 | run: cd output/local && docker-compose up -d 117 | - name: Wait for LAVA 2023.10 to be started 118 | run: sh .github/workflows/wait-for-docker.sh 119 | -------------------------------------------------------------------------------- /.github/workflows/wait-for-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd output/local 4 | 5 | TIMEOUT=0 6 | 7 | while [ $TIMEOUT -le 1200 ] 8 | do 9 | lavacli --uri http://admin:tokenforci@127.0.0.1:10080/RPC2 devices list > devices.list 10 | if [ $? -eq 0 ];then 11 | grep -q qemu devices.list 12 | if [ $? -eq 0 ];then 13 | lavacli --uri http://admin:tokenforci@127.0.0.1:10080/RPC2 devices list 14 | # now wait for a job 15 | lavacli --uri http://admin:tokenforci@127.0.0.1:10080/RPC2 jobs list > joblist 16 | grep -q Running joblist 17 | if [ $? -eq 0 ];then 18 | exit 0 19 | lavacli --uri http://admin:tokenforci@127.0.0.1:10080/RPC2 jobs logs --no-follow 1 20 | else 21 | cat joblist 22 | fi 23 | fi 24 | fi 25 | docker-compose logs --tail=60 26 | docker ps > /tmp/alldocker 27 | grep -q master /tmp/alldocker 28 | if [ $? -ne 0 ];then 29 | echo "==========================================" 30 | echo "==========================================" 31 | echo "==========================================" 32 | echo "ERROR: master died" 33 | docker-compose logs 34 | exit 1 35 | fi 36 | sleep 10 37 | TIMEOUT=$((TIMEOUT+10)) 38 | done 39 | exit 1 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | boards.yaml 2 | output/ 3 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | This repo has migrated to https://github.com/BayLibre/lava-docker 3 | -------------------------------------------------------------------------------- /backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BACKUP_DIR="backup-$(date +%Y%m%d_%H%M)" 4 | # use /tmp by default on host (this is used by tar) 5 | TMPDIR=${TMPDIR:-/tmp} 6 | export TMPDIR 7 | 8 | mkdir -p $TMPDIR 9 | 10 | mkdir $BACKUP_DIR 11 | cp boards.yaml $BACKUP_DIR 12 | 13 | DOCKERID=$(docker ps |grep master | cut -d' ' -f1) 14 | if [ -z "$DOCKERID" ];then 15 | exit 1 16 | fi 17 | 18 | docker exec $DOCKERID tar czf /root/devices.tar.gz /etc/lava-server/dispatcher-config/devices/ || exit $? 19 | docker cp $DOCKERID:/root/devices.tar.gz $BACKUP_DIR/ || exit $? 20 | 21 | # for an unknown reason pg_dump > file doesnt work 22 | docker exec $DOCKERID sudo -u postgres pg_dump --create --clean lavaserver --file /tmp/db_lavaserver || exit $? 23 | docker exec $DOCKERID gzip /tmp/db_lavaserver || exit $? 24 | docker cp $DOCKERID:/tmp/db_lavaserver.gz $BACKUP_DIR/ || exit $? 25 | docker exec $DOCKERID rm /tmp/db_lavaserver.gz || exit $? 26 | 27 | # tar outputs warnings when file changes on disk while creating tar file. So do not "exit on error" 28 | docker exec $DOCKERID tar czf /root/joboutput.tar.gz /var/lib/lava-server/default/media/job-output/ || echo "WARNING: tar operation returned $?" 29 | docker cp $DOCKERID:/root/joboutput.tar.gz $BACKUP_DIR/ || exit $? 30 | docker exec $DOCKERID rm /root/joboutput.tar.gz || exit $? 31 | 32 | echo "Backup done in $BACKUP_DIR" 33 | rm -f backup-latest 34 | ln -sf $BACKUP_DIR backup-latest 35 | -------------------------------------------------------------------------------- /boards-ci-2022.01.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | masters: 3 | - name: masterci1 4 | version: "2022.01" 5 | host: local 6 | healthcheck_url: http://healthcheck 7 | users: 8 | - name: admin 9 | token: tokenforci 10 | password: passwordforci 11 | superuser: true 12 | staff: true 13 | tokens: 14 | - username: admin 15 | token: dfjdfkfkdjfkdsjfslforci 16 | description: no description 17 | slaves: 18 | - name: lab-ci-0 19 | version: "2022.01" 20 | host: local 21 | remote_master: masterci1 22 | remote_user: admin 23 | use_overlay_server: false 24 | use_tftp: false 25 | host_healthcheck: true 26 | 27 | boards: 28 | - name: qemu-01 29 | type: qemu 30 | -------------------------------------------------------------------------------- /boards-ci-2023.01.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | masters: 3 | - name: masterci1 4 | version: "2023.01" 5 | host: local 6 | healthcheck_url: http://healthcheck 7 | users: 8 | - name: admin 9 | token: tokenforci 10 | password: passwordforci 11 | superuser: true 12 | staff: true 13 | tokens: 14 | - username: admin 15 | token: dfjdfkfkdjfkdsjfslforci 16 | description: no description 17 | slaves: 18 | - name: lab-ci-0 19 | version: "2023.01" 20 | host: local 21 | remote_master: masterci1 22 | remote_user: admin 23 | use_overlay_server: false 24 | use_tftp: false 25 | host_healthcheck: true 26 | 27 | boards: 28 | - name: qemu-01 29 | type: qemu 30 | -------------------------------------------------------------------------------- /boards-ci-2023.06.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | masters: 3 | - name: masterci1 4 | version: "2023.06" 5 | host: local 6 | healthcheck_url: http://healthcheck 7 | users: 8 | - name: admin 9 | token: tokenforci 10 | password: passwordforci 11 | superuser: true 12 | staff: true 13 | tokens: 14 | - username: admin 15 | token: dfjdfkfkdjfkdsjfslforci 16 | description: no description 17 | slaves: 18 | - name: lab-ci-0 19 | version: "2023.06" 20 | host: local 21 | remote_master: masterci1 22 | remote_user: admin 23 | use_overlay_server: false 24 | use_tftp: false 25 | host_healthcheck: true 26 | 27 | boards: 28 | - name: qemu-01 29 | type: qemu 30 | -------------------------------------------------------------------------------- /boards-ci-2023.10.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | masters: 3 | - name: masterci1 4 | version: "2023.10" 5 | host: local 6 | healthcheck_url: http://healthcheck 7 | users: 8 | - name: admin 9 | token: tokenforci 10 | password: passwordforci 11 | superuser: true 12 | staff: true 13 | tokens: 14 | - username: admin 15 | token: dfjdfkfkdjfkdsjfslforci 16 | description: no description 17 | slaves: 18 | - name: lab-ci-0 19 | version: "2023.10" 20 | host: local 21 | remote_master: masterci1 22 | remote_user: admin 23 | use_overlay_server: false 24 | use_tftp: false 25 | host_healthcheck: true 26 | 27 | boards: 28 | - name: qemu-01 29 | type: qemu 30 | -------------------------------------------------------------------------------- /boards-ci.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | masters: 3 | - name: masterci1 4 | host: local 5 | users: 6 | - name: admin 7 | token: tokenforci 8 | password: passwordforci 9 | superuser: true 10 | staff: true 11 | tokens: 12 | - username: admin 13 | token: dfjdfkfkdjfkdsjfslforci 14 | description: no description 15 | slaves: 16 | - name: lab-ci-0 17 | host: local 18 | remote_master: masterci1 19 | remote_user: admin 20 | use_overlay_server: false 21 | use_tftp: false 22 | 23 | boards: 24 | - name: qemu-01 25 | type: qemu 26 | -------------------------------------------------------------------------------- /boards.yaml.example: -------------------------------------------------------------------------------- 1 | --- 2 | masters: 3 | - name: master1 4 | host: local 5 | users: 6 | - name: admin 7 | token: longrandomtokenadmin 8 | password: admin 9 | superuser: true 10 | staff: true 11 | slaves: 12 | - name: lab-slave-0 13 | host: local 14 | remote_master: master1 15 | remote_user: admin 16 | dispatcher_ip: 192.168.66.1 17 | 18 | boards: 19 | - name: qemu-02 20 | type: qemu 21 | slave: lab-slave-0 22 | kvm: true 23 | - name: meson-gxl-s905x-libretech-cc-01 24 | type: meson-gxl-s905x-libretech-cc 25 | slave: lab-slave-0 26 | pdu_generic: 27 | hard_reset_command: /usr/local/bin/acme-cli -s 192.168.66.2 reset 2 28 | power_off_command: /usr/local/bin/acme-cli -s 192.168.66.2 switch_off 2 29 | power_on_command: /usr/local/bin/acme-cli -s 192.168.66.2 switch_on 2 30 | uart: 31 | idvendor: 0x0403 32 | idproduct: 0x6001 33 | serial: FT9QR2TZ 34 | - name: meson-gxbb-nanopi-k2-01 35 | type: meson-gxbb-nanopi-k2 36 | slave: lab-slave-0 37 | custom_option: 38 | - 'set bootloader_prompt = "nanopi-k2#"' 39 | - "set interrupt_prompt = 'nanopi'" 40 | uboot_ipaddr: 192.168.66.201 41 | pdu_generic: 42 | hard_reset_command: /usr/local/bin/acme-cli -s 192.168.66.2 reset 3 43 | power_off_command: /usr/local/bin/acme-cli -s 192.168.66.2 switch_off 3 44 | power_on_command: /usr/local/bin/acme-cli -s 192.168.66.2 switch_on 3 45 | uart: 46 | idvendor: 0x0403 47 | idproduct: 0x6001 48 | serial: FT9ZOR0I 49 | -------------------------------------------------------------------------------- /boards.yaml.minimal: -------------------------------------------------------------------------------- 1 | --- 2 | masters: 3 | - name: master1 4 | host: local 5 | users: 6 | - name: admin 7 | token: longrandomtokenadmin 8 | password: admin 9 | superuser: true 10 | staff: true 11 | tokens: 12 | - username: admin 13 | token: dfjdfkfkdjfkdsjfsl 14 | description: no description 15 | slaves: 16 | - name: lab-slave-0 17 | host: local 18 | remote_master: master1 19 | remote_user: admin 20 | 21 | boards: 22 | - name: qemu-01 23 | type: qemu 24 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #check for root 4 | BEROOT="" 5 | if [ $(id -u) -ne 0 ];then 6 | BEROOT="sudo " 7 | fi 8 | $BEROOT rm /etc/udev/rules.d/*lavaworker-udev*rules 9 | $BEROOT cp udev/*lavaworker-udev*rules /etc/udev/rules.d/ 10 | $BEROOT udevadm control --reload-rules || exit $? 11 | $BEROOT udevadm trigger || exit $? 12 | 13 | docker-compose build || exit 1 14 | docker-compose up -d || exit 1 15 | -------------------------------------------------------------------------------- /dhcpd/dhcpd.conf: -------------------------------------------------------------------------------- 1 | # dhcpd.conf 2 | # 3 | # Sample configuration file for ISC dhcpd 4 | # 5 | 6 | # option definitions common to all supported networks... 7 | option domain-name "lavalab.local"; 8 | #option domain-name-servers 192.168.1.1; 9 | 10 | default-lease-time 600; 11 | max-lease-time 7200; 12 | 13 | # The ddns-updates-style parameter controls whether or not the server will 14 | # attempt to do a DNS update when a lease is confirmed. We default to the 15 | # behavior of the version 2 packages ('none', since DHCP v2 didn't 16 | # have support for DDNS.) 17 | ddns-update-style none; 18 | 19 | # If this DHCP server is the official DHCP server for the local 20 | # network, the authoritative directive should be uncommented. 21 | authoritative; 22 | 23 | # Use this to send dhcp log messages to a different log file (you also 24 | # have to hack syslog.conf to complete the redirection). 25 | #log-facility local7; 26 | 27 | # No service will be given on this subnet, but declaring it helps the 28 | # DHCP server to understand the network topology. 29 | 30 | #subnet 10.152.187.0 netmask 255.255.255.0 { 31 | #} 32 | 33 | # This is a very basic subnet declaration. 34 | 35 | #subnet 10.254.239.0 netmask 255.255.255.224 { 36 | # range 10.254.239.10 10.254.239.20; 37 | # option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; 38 | #} 39 | 40 | # This declaration allows BOOTP clients to get dynamic addresses, 41 | # which we don't really recommend. 42 | 43 | #subnet 10.254.239.32 netmask 255.255.255.224 { 44 | # range dynamic-bootp 10.254.239.40 10.254.239.60; 45 | # option broadcast-address 10.254.239.31; 46 | # option routers rtr-239-32-1.example.org; 47 | #} 48 | 49 | # A slightly different configuration for an internal subnet. 50 | #subnet 10.5.5.0 netmask 255.255.255.224 { 51 | # range 10.5.5.26 10.5.5.30; 52 | # option domain-name-servers ns1.internal.example.org; 53 | # option domain-name "internal.example.org"; 54 | # option routers 10.5.5.1; 55 | # option broadcast-address 10.5.5.31; 56 | # default-lease-time 600; 57 | # max-lease-time 7200; 58 | #} 59 | 60 | # Hosts which require special configuration options can be listed in 61 | # host statements. If no address is specified, the address will be 62 | # allocated dynamically (if possible), but the host-specific information 63 | # will still come from the host declaration. 64 | 65 | #host passacaglia { 66 | # hardware ethernet 0:0:c0:5d:bd:95; 67 | # filename "vmunix.passacaglia"; 68 | # server-name "toccata.example.com"; 69 | #} 70 | 71 | # Fixed IP addresses can also be specified for hosts. These addresses 72 | # should not also be listed as being available for dynamic assignment. 73 | # Hosts for which fixed IP addresses have been specified can boot using 74 | # BOOTP or DHCP. Hosts for which no fixed address is specified can only 75 | # be booted with DHCP, unless there is an address range on the subnet 76 | # to which a BOOTP client is connected which has the dynamic-bootp flag 77 | # set. 78 | #host fantasia { 79 | # hardware ethernet 08:00:07:26:c0:a5; 80 | # fixed-address fantasia.example.com; 81 | #} 82 | 83 | # You can declare a class of clients and then do address allocation 84 | # based on that. The example below shows a case where all clients 85 | # in a certain class get addresses on the 10.17.224/24 subnet, and all 86 | # other clients get addresses on the 10.0.29/24 subnet. 87 | 88 | #class "foo" { 89 | # match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; 90 | #} 91 | 92 | #shared-network 224-29 { 93 | # subnet 10.17.224.0 netmask 255.255.255.0 { 94 | # option routers rtr-224.example.org; 95 | # } 96 | # subnet 10.0.29.0 netmask 255.255.255.0 { 97 | # option routers rtr-29.example.org; 98 | # } 99 | # pool { 100 | # allow members of "foo"; 101 | # range 10.17.224.10 10.17.224.250; 102 | # } 103 | # pool { 104 | # deny members of "foo"; 105 | # range 10.0.29.10 10.0.29.230; 106 | # } 107 | #} 108 | 109 | subnet 192.168.66.0 netmask 255.255.255.0 { 110 | range 192.168.66.3 192.168.66.254; 111 | group { 112 | host baylibre-acme { 113 | hardware ethernet 6c:ec:eb:67:89:ad; 114 | fixed-address 192.168.66.2; 115 | } 116 | host baylibre-acme2 { 117 | hardware ethernet 84:eb:18:94:2e:ca; 118 | fixed-address 192.168.66.2; 119 | } 120 | } 121 | } 122 | 123 | -------------------------------------------------------------------------------- /healthcheck/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM bitnami/minideb:bullseye 2 | 3 | RUN apt-get update && apt-get -y install git 4 | RUN git clone https://github.com/BayLibre/lava-healthchecks-binary.git 5 | 6 | FROM nginx:mainline-alpine 7 | 8 | COPY port.conf /etc/nginx/conf.d/ 9 | 10 | COPY --from=0 /lava-healthchecks-binary/mainline /usr/share/nginx/html/mainline/ 11 | COPY --from=0 lava-healthchecks-binary/images /usr/share/nginx/html/images/ 12 | COPY --from=0 lava-healthchecks-binary/next /usr/share/nginx/html/next/ 13 | COPY --from=0 lava-healthchecks-binary/stable /usr/share/nginx/html/stable/ 14 | -------------------------------------------------------------------------------- /healthcheck/port.conf: -------------------------------------------------------------------------------- 1 | # On docker, port 80 cannot be exported since lava-slave already export it 2 | # So port 8080 is exported instead. 3 | server { 4 | listen 8080; 5 | root /usr/share/nginx/html/; 6 | } 7 | -------------------------------------------------------------------------------- /lava-master/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM lavasoftware/lava-server:2024.05 2 | 3 | RUN apt-get update && apt-get -y install sudo git 4 | 5 | COPY backup /root/backup/ 6 | 7 | COPY default/* /etc/default/ 8 | 9 | RUN git clone https://github.com/BayLibre/lava-healthchecks.git 10 | RUN cp lava-healthchecks/health-checks/* /etc/lava-server/dispatcher-config/health-checks/ 11 | COPY health-checks/* /etc/lava-server/dispatcher-config/health-checks/ 12 | RUN if [ -e /etc/lava-server/dispatcher-config/health-checks/healthcheck_url ];then sed -i "s,http.*blob/master,$(cat /etc/lava-server/dispatcher-config/health-checks/healthcheck_url)," /etc/lava-server/dispatcher-config/health-checks/* && sed -i 's,?.*$,,' /etc/lava-server/dispatcher-config/health-checks/* ;fi 13 | RUN chown -R lavaserver:lavaserver /etc/lava-server/dispatcher-config/health-checks/ 14 | 15 | COPY devices/ /root/devices/ 16 | COPY device-types/ /root/device-types/ 17 | COPY users/ /root/lava-users/ 18 | COPY groups/ /root/lava-groups/ 19 | COPY tokens/ /root/lava-callback-tokens/ 20 | COPY entrypoint.d/*sh /root/entrypoint.d/ 21 | 22 | COPY settings.conf /etc/lava-server/ 23 | 24 | COPY lava-patch/ /root/lava-patch 25 | RUN cd /usr/lib/python3/dist-packages && for patch in $(ls /root/lava-patch/*patch| sort) ; do echo $patch && patch -p1 < $patch || exit $?;done 26 | 27 | COPY device-types-patch/ /root/device-types-patch/ 28 | RUN sh root/device-types-patch/patch-device-type.sh 29 | 30 | COPY lava_http_fqdn /root/ 31 | 32 | COPY env/ /etc/lava-server/dispatcher.d/ 33 | RUN chown -R lavaserver:lavaserver /etc/lava-server/dispatcher.d/ 34 | 35 | COPY apache2/ /etc/apache2/ 36 | 37 | # Fixes 'postgresql ERROR: invalid locale name: "en_US.UTF-8"' when restoring a backup 38 | RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && locale-gen en_US.UTF-8 39 | 40 | COPY pg_lava_password /root 41 | 42 | # TODO: send this fix to upstream 43 | RUN sed -i 's,find /root/entrypoint.d/ -type f,find /root/entrypoint.d/ -type f | sort,' /root/entrypoint.sh 44 | # TODO: send this fix to upstream 45 | RUN sed -i 's,pidfile =.*,pidfile = "/run/lava-coordinator/lava-coordinator.pid",' /usr/bin/lava-coordinator 46 | 47 | EXPOSE 3079 5555 5556 48 | 49 | CMD /root/entrypoint.sh && while [ true ];do sleep 365d; done 50 | -------------------------------------------------------------------------------- /lava-master/apache2/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-master/apache2/.empty -------------------------------------------------------------------------------- /lava-master/backup/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-master/backup/.empty -------------------------------------------------------------------------------- /lava-master/default/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-master/default/.empty -------------------------------------------------------------------------------- /lava-master/device-types-patch/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-master/device-types-patch/.empty -------------------------------------------------------------------------------- /lava-master/device-types-patch/patch-device-type.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DEVTYPE_PATH=/etc/lava-server/dispatcher-config/device-types/ 4 | if [ -e /usr/share/lava-server/device-types/ ];then 5 | DEVTYPE_PATH=/usr/share/lava-server/device-types/ 6 | fi 7 | 8 | cd $DEVTYPE_PATH 9 | for patch in $(ls /root/device-types-patch/*patch) 10 | do 11 | echo "DEBUG: patch with $patch" 12 | sed -i 's,lava_scheduler_app/tests/device-types/,,' $patch 13 | sed -i 's,etc/dispatcher-config/device-types/,,' $patch 14 | patch -p1 < $patch || exit $? 15 | done 16 | chown -R lavaserver:lavaserver $DEVTYPE_PATH 17 | -------------------------------------------------------------------------------- /lava-master/device-types/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-master/device-types/.empty -------------------------------------------------------------------------------- /lava-master/entrypoint.d/01_setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # always reset the lavaserver user, since its password could have been reseted in a "docker build --nocache" 4 | if [ ! -s /root/pg_lava_password ];then 5 | echo "DEBUG: Generating a random LAVA password" 6 | < /dev/urandom tr -dc A-Za-z0-9 | head -c16 > /root/pg_lava_password 7 | else 8 | echo "DEBUG: use the given LAVA password" 9 | fi 10 | sudo -u postgres psql -c "ALTER USER lavaserver WITH PASSWORD '$(cat /root/pg_lava_password)';" || exit $? 11 | if [ -e /etc/lava-server/instance.conf ];then 12 | # pre 2020.05 13 | sed -i "s,^LAVA_DB_PASSWORD=.*,LAVA_DB_PASSWORD='$(cat /root/pg_lava_password)'," /etc/lava-server/instance.conf || exit $? 14 | else 15 | # 2020.05+ 16 | sed -i "s,PASSWORD:.*,PASSWORD: '$(cat /root/pg_lava_password)'," /etc/lava-server/settings.d/00-database.yaml || exit $? 17 | fi 18 | 19 | cd /root/ 20 | #lava-server manage makemigrations || exit $? 21 | 22 | # verify that the backup was not already applied in case of persistent_db 23 | if [ ! -e "/var/lib/postgresql/lava-docker.backup_done" ];then 24 | if [ -e /root/backup/db_lavaserver.gz ];then 25 | gunzip /root/backup/db_lavaserver.gz || exit $? 26 | fi 27 | 28 | if [ -e /root/backup/db_lavaserver ];then 29 | echo "Restore database from backup" 30 | sudo -u postgres psql < /root/backup/db_lavaserver || exit $? 31 | #yes yes | lava-server manage migrate || exit $? 32 | echo "Restore jobs output from backup" 33 | rm -r /var/lib/lava-server/default/media/job-output/* 34 | 35 | # allow using different folder for tar operations (/tmp by default) 36 | TMPDIR=${TMPDIR:-/tmp} 37 | 38 | echo "DEBUG: restoring jobs output" 39 | tar xzf /root/backup/joboutput.tar.gz || exit $? 40 | mv /root/var/lib/lava-server/default/media/job-output/* cd /var/lib/lava-server/default/media/job-output/ 41 | chown -R lavaserver:lavaserver /var/lib/lava-server/default/media/job-output/ 42 | touch /var/lib/postgresql/lava-docker.backup_done 43 | fi 44 | if [ -e /root/backup/devices.tar.gz ];then 45 | echo "INFO: Restoring devices files" 46 | tar xzf /root/backup/devices.tar.gz 47 | mv /root/etc/lava-server/dispatcher-config/devices/* /etc/lava-server/dispatcher-config/devices/ 48 | chown -R lavaserver:lavaserver /etc/lava-server/dispatcher-config/devices 49 | fi 50 | else 51 | echo "DEBUG: backup already applied" 52 | fi 53 | 54 | # check current LAVA version 55 | # not very good way, but no real choice 56 | echo "DEBUG: check LAVA version from DB" 57 | su - postgres -c 'psql --tuples-only lavaserver -c "SELECT DISTINCT version from lava_scheduler_app_worker" | sort -V' > /tmp/workerversions 58 | sed -i 's,^[[:space:]]*,,' /tmp/workerversions 59 | echo "======" 60 | cat /tmp/workerversions 61 | echo "======" 62 | 63 | echo "DEBUG: check LAVA version from file" 64 | cat /usr/lib/python3/dist-packages/lava_common/VERSION 65 | # hack 66 | grep -q '2023.01' /usr/lib/python3/dist-packages/lava_common/VERSION 67 | if [ $? -eq 0 ];then 68 | echo "DEBUG: 2023.01 need to do an old migration" 69 | lava-server manage makemigrations 70 | yes yes | lava-server manage migrate || exit $? 71 | fi 72 | # if we came from 2023.01 to 2023.05, we need to handle the migration bug 73 | grep -q '2023.0[1-5]' /tmp/workerversions 74 | if [ $? -eq 0 ];then 75 | grep -qE '2023.0[68]|2023.10' /usr/lib/python3/dist-packages/lava_common/VERSION 76 | if [ $? -eq 0 ];then 77 | echo "=============================" 78 | echo "DEBUG: handle DB migration BUG" 79 | sudo -u postgres psql lavaserver -c "SELECT * from django_migrations where app = 'lava_scheduler_app';" 80 | echo "=============================" 81 | sudo -u postgres psql lavaserver -c "SELECT * from django_migrations where app = 'lava_results_app';" 82 | echo "=============================" 83 | lava-server manage migrate --fake lava_results_app 0019_update_query_contenttype || exit $? 84 | echo "=============================" 85 | lava-server manage migrate --fake lava_scheduler_app 0057_dt_permissions_worker_master_version || exit $? 86 | echo "=============================" 87 | lava-server manage migrate lava_results_app 0018_drop_buglink || exit $? 88 | echo "=============================" 89 | lava-server manage migrate lava_scheduler_app 0056_testjob_queue_timeout || exit $? 90 | echo "=============================" 91 | sudo -u postgres psql lavaserver -c "SELECT * from django_migrations where app = 'lava_scheduler_app';" 92 | echo "=============================" 93 | sudo -u postgres psql lavaserver -c "SELECT * from django_migrations where app = 'lava_results_app';" 94 | echo "=============================" 95 | else 96 | echo "DEBUG: no spetial handling for DB" 97 | fi 98 | else 99 | echo "DEBUG: no spetial handling for DB" 100 | fi 101 | 102 | echo "DEBUG: call postinst for managing migrations" 103 | /usr/share/lava-server/postinst.py || exit $? 104 | #lava-server manage makemigrations 105 | #yes yes | lava-server manage migrate || exit $? 106 | 107 | # default site is set as example.com 108 | if [ -e /root/lava_http_fqdn ];then 109 | sudo -u postgres psql lavaserver -c "UPDATE django_site SET name = '$(cat /root/lava_http_fqdn)'" || exit $? 110 | sudo -u postgres psql lavaserver -c "UPDATE django_site SET domain = '$(cat /root/lava_http_fqdn)'" || exit $? 111 | fi 112 | 113 | if [ -e /root/lava-users ];then 114 | for ut in $(ls /root/lava-users) 115 | do 116 | # User is the filename 117 | USER=$ut 118 | USER_OPTION="" 119 | STAFF=0 120 | SUPERUSER=0 121 | TOKEN="" 122 | . /root/lava-users/$ut 123 | if [ -z "$PASSWORD" -o "$PASSWORD" = "$TOKEN" ];then 124 | echo "Generating password..." 125 | #Could be very long, should be avoided 126 | PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) 127 | fi 128 | if [ $STAFF -eq 1 ];then 129 | USER_OPTION="$USER_OPTION --staff" 130 | fi 131 | if [ $SUPERUSER -eq 1 ];then 132 | USER_OPTION="$USER_OPTION --superuser" 133 | fi 134 | lava-server manage users list --all > /tmp/allusers 135 | if [ $? -ne 0 ];then 136 | echo "ERROR: cannot generate user list" 137 | exit 1 138 | fi 139 | #filter first name/last name (enclose by "()") 140 | sed -i 's,[[:space:]](.*$,,' /tmp/allusers 141 | grep -q "[[:space:]]${USER}$" /tmp/allusers 142 | if [ $? -eq 0 ];then 143 | echo "Skip already existing $USER DEBUG(with $TOKEN / $PASSWORD / $USER_OPTION)" 144 | else 145 | echo "Adding username $USER DEBUG(with $TOKEN / $PASSWORD / $USER_OPTION)" 146 | lava-server manage users add --passwd $PASSWORD $USER_OPTION $USER 147 | if [ $? -ne 0 ];then 148 | echo "ERROR: Adding user $USER" 149 | cat /tmp/allusers 150 | exit 1 151 | fi 152 | if [ ! -z "$TOKEN" ];then 153 | echo "Adding token to user $USER" 154 | lava-server manage tokens add --user $USER --secret $TOKEN || exit 1 155 | fi 156 | if [ ! -z "$EMAIL" ];then 157 | echo "Adding email to user $USER" 158 | lava-server manage users update --email $EMAIL $USER || exit 1 159 | fi 160 | fi 161 | done 162 | fi 163 | 164 | if [ -e /root/lava-groups ];then 165 | echo "======================================================" 166 | echo "Handle groups" 167 | echo "======================================================" 168 | GROUP_CURRENT_LIST=/tmp/group.list 169 | lava-server manage groups list > ${GROUP_CURRENT_LIST}.raw || exit 1 170 | grep '^\*' ${GROUP_CURRENT_LIST}.raw > ${GROUP_CURRENT_LIST} 171 | for group in $(ls /root/lava-groups/*group) 172 | do 173 | GROUPNAME="" 174 | SUBMIT=0 175 | OPTION_SUBMIT="" 176 | . $group 177 | grep -q $GROUPNAME $GROUP_CURRENT_LIST 178 | if [ $? -eq 0 ];then 179 | echo "DEBUG: SKIP creation of $GROUPNAME which already exists" 180 | else 181 | if [ $SUBMIT -eq 1 ];then 182 | echo "DEBUG: $GROUPNAME can submit jobs" 183 | OPTION_SUBMIT="--submitting" 184 | fi 185 | echo "DEBUG: Add group $GROUPNAME" 186 | lava-server manage groups add $OPTION_SUBMIT $GROUPNAME || exit 1 187 | fi 188 | if [ -e ${group}.list ];then 189 | echo "DEBUG: Found ${group}.list" 190 | while read username 191 | do 192 | echo "DEBUG: Add user $username to group $GROUPNAME" 193 | lava-server manage groups update --username $username $GROUPNAME || exit 1 194 | done < ${group}.list 195 | fi 196 | done 197 | fi 198 | 199 | if [ -e /root/lava-callback-tokens ];then 200 | for ct in $(ls /root/lava-callback-tokens) 201 | do 202 | . /root/lava-callback-tokens/$ct 203 | if [ -z "$USER" ];then 204 | echo "Missing USER" 205 | exit 1 206 | fi 207 | if [ -z "$TOKEN" ];then 208 | echo "Missing TOKEN for $USER" 209 | exit 1 210 | fi 211 | if [ -z "$DESCRIPTION" ];then 212 | echo "Missing DESCRIPTION for $USER" 213 | exit 1 214 | fi 215 | lava-server manage tokens list --user $USER |grep -q $TOKEN 216 | if [ $? -eq 0 ];then 217 | echo "SKIP already present token for $USER" 218 | else 219 | echo "Adding $USER ($DESCRIPTION) DEBUG($TOKEN)" 220 | lava-server manage tokens add --user $USER --secret $TOKEN --description "$DESCRIPTION" || exit 1 221 | fi 222 | done 223 | fi 224 | 225 | lava-server manage device-types --no-color list > /tmp/device-types.list 226 | if [ $? -ne 0 ];then 227 | echo "ERROR: fail to get device-types" 228 | exit 1 229 | fi 230 | 231 | # This directory is used for storing device-types already added 232 | mkdir -p /root/.lavadocker/ 233 | if [ -e /root/device-types ];then 234 | for i in $(ls /root/device-types/*jinja2) 235 | do 236 | if [ -e /etc/lava-server/dispatcher-config/device-types/$(basename $i) ];then 237 | echo "WARNING: overwriting device-type $i" 238 | diff -u "/etc/lava-server/dispatcher-config/device-types/$(basename $i)" $i 239 | fi 240 | cp $i /etc/lava-server/dispatcher-config/device-types/ 241 | chown lavaserver:lavaserver /etc/lava-server/dispatcher-config/device-types/$(basename $i) 242 | devicetype=$(basename $i |sed 's,.jinja2,,') 243 | grep -q "[[:space:]]$devicetype[[:space:]]" /tmp/device-types.list 244 | if [ $? -eq 0 ];then 245 | echo "Skip already known $devicetype" 246 | else 247 | echo "Adding custom $devicetype" 248 | lava-server manage device-types add $devicetype || exit $? 249 | touch /root/.lavadocker/devicetype-$devicetype 250 | fi 251 | done 252 | fi 253 | 254 | for worker in $(ls /root/devices/) 255 | do 256 | echo "Adding worker $worker" 257 | lava-server manage workers add $worker || exit $? 258 | for device in $(ls /root/devices/$worker/) 259 | do 260 | devicename=$(echo $device | sed 's,.jinja2,,') 261 | devicetype=$(grep -h extends /root/devices/$worker/$device| grep -o '[a-zA-Z0-9_-]*.jinja2' | sed 's,.jinja2,,') 262 | if [ -e /root/.lavadocker/devicetype-$devicetype ];then 263 | echo "Skip devicetype $devicetype" 264 | else 265 | echo "Add devicetype $devicetype" 266 | lava-server manage device-types add $devicetype || exit $? 267 | touch /root/.lavadocker/devicetype-$devicetype 268 | fi 269 | echo "Add device $devicename on $worker" 270 | cp /root/devices/$worker/$device /etc/lava-server/dispatcher-config/devices/ || exit $? 271 | lava-server manage devices add --device-type $devicetype --worker $worker $devicename || exit $? 272 | done 273 | done 274 | 275 | if [ ! -z "$GUNICORN_WORKERS" ];then 276 | echo "DEBUG: set gunicorn workers to $GUNICORN_WORKERS" 277 | grep -ri workers /etc 278 | sed -i "s,.*WORKERS=.*,WORKERS=$GUNICORN_WORKERS," /etc/lava-server/lava-server-gunicorn || exit $? 279 | fi 280 | 281 | echo "DEBUG: fix owning rights on /etc/lava-server/dispatcher-config" 282 | chown -Rc lavaserver:lavaserver /etc/lava-server/dispatcher-config 283 | exit 0 284 | -------------------------------------------------------------------------------- /lava-master/env/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-master/env/.empty -------------------------------------------------------------------------------- /lava-master/health-checks/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-master/health-checks/.empty -------------------------------------------------------------------------------- /lava-master/lava-patch/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-master/lava-patch/.empty -------------------------------------------------------------------------------- /lava-slave-install.md: -------------------------------------------------------------------------------- 1 | This is an howto install a lava-docker slave 2 | This howto is based on a Debian host. 3 | Along with this file, you could see standalone-slave.yaml.example file. 4 | The rest of the document is based on that example. 5 | 6 | # Create a dedicated user 7 | The user will be lavadocker in our example. It must be in the docker group for doing docker operations. 8 | ``` 9 | useradd -G docker lavadocker 10 | ``` 11 | 12 | # Install all pre-requisites packages 13 | docker-compose need to be installed from PIP 14 | ``` 15 | apt-get install git python-pip 16 | ``` 17 | 18 | # Install docker-ce 19 | See https://docs.docker.com/install/linux/docker-ce/debian/ for more detailled informations. 20 | 21 | # install docker-compose for our user 22 | 23 | As lavadocker run: 24 | ``` 25 | pip install --user docker-compose 26 | ``` 27 | 28 | # Install a second network interface 29 | Having a dedicated network for boards is recommanded. 30 | Anyway, we will call enx0 the network card wired on the network connected to DUTs. (Whatever it is dedicated or not) 31 | 32 | # Install a DHCPD listenning on enx0 33 | You need to have a DHCPD on the network where your boards are. 34 | You have many choices, for our examples we will use isc-dhcp-server: 35 | ``` 36 | apt-get install isc-dhcp-server 37 | ``` 38 | 39 | ## Configure the DHCPD server 40 | ``` 41 | sed -i 's,INTERFACESv4="",INTERFACESv4="enx0",' /etc/default/isc-dhcp-server 42 | ``` 43 | 44 | Add the following to /etc/dhcp/dhcpd.conf 45 | ``` 46 | subnet 192.168.66.0 netmask 255.255.255.0 { 47 | range 192.168.66.11 192.168.66.250; 48 | option routers 192.168.66.1; 49 | } 50 | ``` 51 | The IP range is an example. You can use whatever you want BUT your need that enx0 to be in the same IP network. (network accessible from the IP given by DHCPD) 52 | In this example enx0 can be 192.168.66.1. 53 | 54 | # Checkout lava-docker sources 55 | As lavadocker run: 56 | ``` 57 | git clone https://github.com/kernelci/lava-docker.git 58 | ``` 59 | 60 | # Create your slave configuration file 61 | ## Create your own file 62 | Copy standalone-slave.yaml.example to standalone-slave.yaml 63 | 64 | ## Get the following required values from the LAVA master administrator 65 | * A remote username (remote_user) 66 | * A remote token for this username (remote_user_token) 67 | * The FQDN for connecting to the master (remote_master) 68 | 69 | In our standalone-slave.yaml it will be: 70 | ``` 71 | remote_master: lava.example.com 72 | remote_user: lab-extern 73 | remote_user_token: lab-extern-randomtoken 74 | ``` 75 | 76 | # Generate files 77 | As lavadocker run: 78 | ``` 79 | ./lavalab-gen.py standalone-slave.yaml 80 | ``` 81 | 82 | # Run deploy.sh in the generated directory 83 | ``` 84 | cd output/externpc/ 85 | ./deploy.sh 86 | ``` 87 | 88 | deploy.sh will 89 | - Deploy udev rules 90 | - Build images 91 | - Run the final images 92 | -------------------------------------------------------------------------------- /lava-slave/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM lavasoftware/lava-dispatcher:2024.05 2 | 3 | RUN apt-get update 4 | 5 | # telnet is for using ser2net 6 | # git is necessary for checkout tests 7 | RUN DEBIAN_FRONTEND=noninteractive apt-get -y install telnet git ser2net patch lavacli 8 | 9 | COPY configs/lava-slave /etc/lava-dispatcher/lava-slave 10 | 11 | COPY configs/tftpd-hpa /etc/default/tftpd-hpa 12 | 13 | COPY scripts/ /usr/local/bin/ 14 | RUN chmod a+x /usr/local/bin/* 15 | 16 | # Caution to not use any port between the Linux dynamic port range: 32768-60999 17 | RUN find /usr/lib/python3/dist-packages/ -iname constants.py | xargs sed -i 's,XNBD_PORT_RANGE_MIN.*,XNBD_PORT_RANGE_MIN=61950,' 18 | RUN find /usr/lib/python3/dist-packages/ -iname constants.py | xargs sed -i 's,XNBD_PORT_RANGE_MAX.*,XNBD_PORT_RANGE_MAX=62000,' 19 | 20 | COPY ser2net.yaml /etc 21 | 22 | # PXE stuff 23 | RUN if [ $(uname -m) != amd64 -a $(uname -m) != x86_64 ]; then dpkg --add-architecture amd64 && apt-get update; fi 24 | RUN apt-get -y install grub-efi-amd64-bin:amd64 25 | RUN if [ $(uname -m) != amd64 -a $(uname -m) != x86_64 ]; then dpkg --remove architecture amd64 && apt-get update; fi 26 | COPY grub.cfg /root/ 27 | 28 | COPY default/* /etc/default/ 29 | 30 | COPY phyhostname /root/ 31 | COPY setupenv /root/ 32 | COPY scripts/setup.sh . 33 | 34 | COPY lava-patch/ /root/lava-patch 35 | RUN cd /usr/lib/python3/dist-packages && for patch in $(ls /root/lava-patch/*patch) ; do echo "APPLY $patch"; patch -p1 < $patch || exit $?;done 36 | 37 | # needed for lavacli identities 38 | RUN mkdir -p /root/.config 39 | 40 | COPY devices/ /root/devices/ 41 | COPY tags/ /root/tags/ 42 | COPY aliases/ /root/aliases/ 43 | COPY deviceinfo/ /root/deviceinfo/ 44 | COPY entrypoint.d/* /root/entrypoint.d/ 45 | RUN chmod +x /root/entrypoint.d/* 46 | 47 | RUN if [ -x /usr/local/bin/extra_actions ] ; then /usr/local/bin/extra_actions ; fi 48 | 49 | EXPOSE 69/udp 80 50 | 51 | CMD /usr/local/bin/start.sh 52 | -------------------------------------------------------------------------------- /lava-slave/aliases/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/aliases/.empty -------------------------------------------------------------------------------- /lava-slave/configs/lava-slave: -------------------------------------------------------------------------------- 1 | # Configuration for lava-slave daemon 2 | 3 | # URL to the master and the logger 4 | MASTER_URL="tcp://{LAVA_MASTER}:5556" 5 | LOGGER_URL="tcp://{LAVA_MASTER}:5555" 6 | 7 | # Logging level should be uppercase (DEBUG, INFO, WARNING, ERROR) 8 | # LOGLEVEL="DEBUG" 9 | 10 | # Encryption 11 | # If set, will activate encryption using the master public and the slave 12 | # private keys 13 | # ENCRYPT="--encrypt" 14 | # MASTER_CERT="--master-cert /etc/lava-dispatcher/certificates.d/" 15 | # SLAVE_CERT="--slave-cert /etc/lava-dispatcher/certificates.d/" 16 | -------------------------------------------------------------------------------- /lava-slave/configs/tftpd-hpa: -------------------------------------------------------------------------------- 1 | # /etc/default/tftpd-hpa 2 | 3 | TFTP_USERNAME="tftp" 4 | TFTP_DIRECTORY="/var/lib/lava/dispatcher/tmp/" 5 | TFTP_ADDRESS="0.0.0.0:69" 6 | TFTP_OPTIONS="--secure -4" 7 | -------------------------------------------------------------------------------- /lava-slave/default/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/default/.empty -------------------------------------------------------------------------------- /lava-slave/deviceinfo/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/deviceinfo/.empty -------------------------------------------------------------------------------- /lava-slave/entrypoint.d/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/entrypoint.d/empty -------------------------------------------------------------------------------- /lava-slave/grub.cfg: -------------------------------------------------------------------------------- 1 | insmod part_msdos 2 | insmod part_gpt 3 | insmod lvm 4 | insmod loopback 5 | insmod iso9660 6 | insmod all_video 7 | insmod regexp 8 | set pager=1 9 | 10 | # This fake menu is necessary for letting LAVA see that grub is started 11 | menuentry "fake menu" { 12 | linux /boot/kernel 13 | } 14 | -------------------------------------------------------------------------------- /lava-slave/lava-coordinator/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/lava-coordinator/.empty -------------------------------------------------------------------------------- /lava-slave/lava-patch/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/lava-patch/.empty -------------------------------------------------------------------------------- /lava-slave/lavapdu.conf: -------------------------------------------------------------------------------- 1 | { 2 | "daemon": { 3 | "hostname": "0.0.0.0", 4 | "port": 16421, 5 | "dbhost": "127.0.0.1", 6 | "dbuser": "pdudaemon", 7 | "dbpass": "pdudaemon", 8 | "dbname": "lavapdu", 9 | "retries": 5, 10 | "logging_level": "INFO" 11 | }, 12 | "pdus": { 13 | "acme-0": { 14 | "driver": "localcmdline", 15 | "cmd_on": "/usr/local/bin/acme-cli -s 192.168.66.2 switch_on %d", 16 | "cmd_off": "/usr/local/bin/acme-cli -s 192.168.66.2 switch_off %d" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lava-slave/scripts/cu-loop: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | DEV=$1 3 | BAUD=${2:-115200} 4 | 5 | while true; do 6 | # NOTE: needs cu >= 1.07-24 7 | # c.f. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=336996 8 | test -e $DEV && cu -l $DEV -s $BAUD --parity=none --nostop --nortscts dir 9 | sleep 0.2 10 | done 11 | 12 | -------------------------------------------------------------------------------- /lava-slave/scripts/extra_actions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/scripts/extra_actions -------------------------------------------------------------------------------- /lava-slave/scripts/getworkertoken.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import xmlrpc.client 4 | import sys 5 | 6 | if len(sys.argv) < 3: 7 | print("ERROR: Usage: %s URI workername" % sys.argv[0]) 8 | sys.exit(1) 9 | 10 | server = xmlrpc.client.ServerProxy("%s" % sys.argv[1]) 11 | wdet = server.scheduler.workers.show("%s" % sys.argv[2]) 12 | if "token" in wdet: 13 | print(wdet["token"]) 14 | sys.exit(0) 15 | sys.exit(1) 16 | -------------------------------------------------------------------------------- /lava-slave/scripts/retire.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LAVA_MASTER_URI=$1 4 | 5 | if [ -z "$LAVA_MASTER_URI" ];then 6 | echo "retire.sh: remove an offline worker" 7 | echo "Usage: $0 LAVA_MASTER_URI" 8 | echo "ERROR: Missing LAVA_MASTER_URI" 9 | exit 11 10 | fi 11 | 12 | LAVACLIOPTS="--uri $LAVA_MASTER_URI" 13 | 14 | retire_worker() { 15 | worker=$1 16 | lavacli $LAVACLIOPTS workers list |grep -q $worker 17 | if [ $? -eq 0 ];then 18 | echo "Removing $worker" 19 | lavacli $LAVACLIOPTS workers update $worker || exit $? 20 | else 21 | echo "SKIP: worker $worker does not exists" 22 | return 0 23 | fi 24 | lavacli $LAVACLIOPTS devices list -a | grep '^\*' | cut -d' ' -f2 | 25 | while read devicename 26 | do 27 | lavacli $LAVACLIOPTS devices show $devicename |grep -q "^worker.*$worker$" 28 | if [ $? -eq 0 ];then 29 | echo "Retire $devicename" 30 | lavacli $LAVACLIOPTS devices update --health RETIRED --worker $worker $devicename || exit $? 31 | fi 32 | done 33 | return 0 34 | } 35 | 36 | if [ -z "$2" ];then 37 | for ww in $(ls devices/) 38 | do 39 | retire_worker $ww 40 | done 41 | else 42 | retire_worker $2 43 | fi 44 | -------------------------------------------------------------------------------- /lava-slave/scripts/setdispatcherip.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import xmlrpc.client 4 | import sys 5 | 6 | if len(sys.argv) < 4: 7 | print("ERROR: Usage: %s URI workername dispatcherIP" % sys.argv[0]) 8 | sys.exit(1) 9 | 10 | server = xmlrpc.client.ServerProxy("%s" % sys.argv[1]) 11 | server.scheduler.workers.set_config("%s" % sys.argv[2], "dispatcher_ip: %s" % sys.argv[3]) 12 | -------------------------------------------------------------------------------- /lava-slave/scripts/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -e "/root/devices/$(hostname)" ];then 4 | echo "Static slave for $LAVA_MASTER" 5 | exit 0 6 | fi 7 | 8 | . /root/setupenv 9 | 10 | if [ -z "$LAVA_MASTER_URI" ];then 11 | echo "ERROR: Missing LAVA_MASTER_URI" 12 | exit 11 13 | fi 14 | 15 | # Install PXE 16 | OPWD=$(pwd) 17 | cd /var/lib/lava/dispatcher/tmp && grub-mknetdir --net-directory=. 18 | cp /root/grub.cfg /var/lib/lava/dispatcher/tmp/boot/grub/ 19 | cd $OPWD 20 | 21 | lavacli identities add --uri $LAVA_MASTER_BASEURI --token $LAVA_MASTER_TOKEN --username $LAVA_MASTER_USER default 22 | 23 | echo "Dynamic slave for $LAVA_MASTER ($LAVA_MASTER_URI)" 24 | LAVACLIOPTS="--uri $LAVA_MASTER_URI" 25 | 26 | # do a sort of ping for letting master to be up 27 | TIMEOUT=1200 28 | while [ $TIMEOUT -ge 1 ]; 29 | do 30 | STEP=2 31 | lavacli $LAVACLIOPTS device-types list >/dev/null 32 | if [ $? -eq 0 ];then 33 | TIMEOUT=0 34 | else 35 | echo "Wait for master.... (${TIMEOUT}s remains)" 36 | sleep $STEP 37 | fi 38 | TIMEOUT=$(($TIMEOUT-$STEP)) 39 | done 40 | 41 | # This directory is used for storing device-types already added 42 | mkdir -p /root/.lavadocker/ 43 | if [ -e /root/device-types ];then 44 | for i in $(ls /root/device-types/*jinja2) 45 | do 46 | devicetype=$(basename $i |sed 's,.jinja2,,') 47 | echo "Adding custom $devicetype" 48 | lavacli $LAVACLIOPTS device-types list || exit $? 49 | touch /root/.lavadocker/devicetype-$devicetype 50 | done 51 | fi 52 | 53 | lavacli $LAVACLIOPTS device-types list > /tmp/device-types.list 54 | if [ $? -ne 0 ];then 55 | echo "ERROR: fail to list device-types" 56 | exit 1 57 | fi 58 | lavacli $LAVACLIOPTS devices list -a > /tmp/devices.list 59 | if [ $? -ne 0 ];then 60 | echo "ERROR: fail to list devices" 61 | exit 1 62 | fi 63 | for worker in $(ls /root/devices/) 64 | do 65 | lavacli $LAVACLIOPTS workers list |grep -q $worker 66 | if [ $? -eq 0 ];then 67 | echo "Remains of $worker, cleaning it" 68 | /usr/local/bin/retire.sh $LAVA_MASTER_URI $worker 69 | #lavacli $LAVACLIOPTS workers update $worker || exit $? 70 | else 71 | echo "Adding worker $worker" 72 | lavacli $LAVACLIOPTS workers add --description "LAVA dispatcher on $(cat /root/phyhostname)" $worker || exit $? 73 | # does we ran 2020.09+ and worker need a token 74 | fi 75 | grep -q "TOKEN" /root/entrypoint.sh 76 | if [ $? -eq 0 ];then 77 | # This is 2020.09+ 78 | echo "DEBUG: Worker need a TOKEN" 79 | if [ -z "$LAVA_WORKER_TOKEN" ];then 80 | echo "DEBUG: get token dynamicly" 81 | # Does not work on 2020.09, since token was not added yet in RPC2 82 | WTOKEN=$(getworkertoken.py $LAVA_MASTER_URI $worker) 83 | if [ $? -ne 0 ];then 84 | echo "ERROR: cannot get WORKER TOKEN" 85 | exit 1 86 | fi 87 | if [ -z "$WTOKEN" ];then 88 | echo "ERROR: got an empty token" 89 | exit 1 90 | fi 91 | else 92 | echo "DEBUG: got token from env" 93 | WTOKEN=$LAVA_WORKER_TOKEN 94 | fi 95 | echo "DEBUG: write token in /var/lib/lava/dispatcher/worker/" 96 | mkdir -p /var/lib/lava/dispatcher/worker/ 97 | echo "$WTOKEN" > /var/lib/lava/dispatcher/worker/token 98 | # lava worker ran under root 99 | chown root:root /var/lib/lava/dispatcher/worker/token 100 | chmod 640 /var/lib/lava/dispatcher/worker/token 101 | sed -i "s,.*TOKEN.*,TOKEN=\"--token-file /var/lib/lava/dispatcher/worker/token\"," /etc/lava-dispatcher/lava-worker || exit $? 102 | 103 | echo "DEBUG: set master URL to $LAVA_MASTER_URL" 104 | sed -i "s,^# URL.*,URL=\"$LAVA_MASTER_URL\"," /etc/lava-dispatcher/lava-worker || exit $? 105 | cat /etc/lava-dispatcher/lava-worker 106 | else 107 | echo "DEBUG: Worker does not need a TOKEN" 108 | fi 109 | if [ ! -z "$LAVA_DISPATCHER_IP" ];then 110 | echo "Add dispatcher_ip $LAVA_DISPATCHER_IP to $worker" 111 | /usr/local/bin/setdispatcherip.py $LAVA_MASTER_URI $worker $LAVA_DISPATCHER_IP || exit $? 112 | fi 113 | for device in $(ls /root/devices/$worker/) 114 | do 115 | devicename=$(echo $device | sed 's,.jinja2,,') 116 | devicetype=$(grep -h extends /root/devices/$worker/$device| grep -o '[a-zA-Z0-9_-]*.jinja2' | sed 's,.jinja2,,') 117 | if [ -e /root/.lavadocker/devicetype-$devicetype ];then 118 | echo "Skip devicetype $devicetype" 119 | else 120 | echo "Add devicetype $devicetype" 121 | grep -q "$devicetype[[:space:]]" /tmp/device-types.list 122 | if [ $? -eq 0 ];then 123 | echo "Skip devicetype $devicetype" 124 | else 125 | lavacli $LAVACLIOPTS device-types add $devicetype || exit $? 126 | fi 127 | touch /root/.lavadocker/devicetype-$devicetype 128 | fi 129 | DEVICE_OPTS="" 130 | if [ -e /root/deviceinfo/$devicename ];then 131 | echo "Found customization for $devicename" 132 | . /root/deviceinfo/$devicename 133 | if [ ! -z "$DEVICE_USER" ];then 134 | echo "DEBUG: give $devicename to $DEVICE_USER" 135 | DEVICE_OPTS="$DEVICE_OPTS --user $DEVICE_USER" 136 | fi 137 | if [ ! -z "$DEVICE_GROUP" ];then 138 | echo "DEBUG: give $devicename to group $DEVICE_GROUP" 139 | DEVICE_OPTS="$DEVICE_OPTS --group $DEVICE_GROUP" 140 | fi 141 | fi 142 | echo "Add device $devicename on $worker" 143 | grep -q "$devicename[[:space:]]" /tmp/devices.list 144 | if [ $? -eq 0 ];then 145 | echo "$devicename already present" 146 | #verify if present on another worker 147 | lavacli $LAVACLIOPTS devices show $devicename |grep ^worker > /tmp/current-worker 148 | if [ $? -ne 0 ]; then 149 | CURR_WORKER="" 150 | else 151 | CURR_WORKER=$(cat /tmp/current-worker | sed 's,^.* ,,') 152 | fi 153 | if [ ! -z "$CURR_WORKER" -a "$CURR_WORKER" != "$worker" ];then 154 | echo "ERROR: $devicename already present on another worker $CURR_WORKER" 155 | exit 1 156 | fi 157 | DEVICE_HEALTH=$(grep "$devicename[[:space:]]" /tmp/devices.list | sed 's/.*,//') 158 | case "$DEVICE_HEALTH" in 159 | Retired) 160 | echo "DEBUG: Keep $devicename state: $DEVICE_HEALTH" 161 | DEVICE_HEALTH='RETIRED' 162 | ;; 163 | Maintenance) 164 | echo "DEBUG: Keep $devicename state: $DEVICE_HEALTH" 165 | DEVICE_HEALTH='MAINTENANCE' 166 | ;; 167 | *) 168 | echo "DEBUG: Set $devicename state to UNKNOWN (from $DEVICE_HEALTH)" 169 | DEVICE_HEALTH='UNKNOWN' 170 | ;; 171 | esac 172 | lavacli $LAVACLIOPTS devices update --worker $worker --health $DEVICE_HEALTH $DEVICE_OPTS $devicename || exit $? 173 | # always reset the device dict in case of update of it 174 | lavacli $LAVACLIOPTS devices dict set $devicename /root/devices/$worker/$device || exit $? 175 | else 176 | lavacli $LAVACLIOPTS devices add --type $devicetype --worker $worker $DEVICE_OPTS $devicename || exit $? 177 | lavacli $LAVACLIOPTS devices dict set $devicename /root/devices/$worker/$device || exit $? 178 | fi 179 | if [ -e /root/tags/$devicename ];then 180 | while read tag 181 | do 182 | echo "DEBUG: Add tag $tag to $devicename" 183 | lavacli $LAVACLIOPTS devices tags add $devicename $tag || exit $? 184 | done < /root/tags/$devicename 185 | fi 186 | done 187 | done 188 | 189 | for devicetype in $(ls /root/aliases/) 190 | do 191 | lavacli $LAVACLIOPTS device-types aliases list $devicetype > /tmp/device-types-aliases-$devicetype.list 192 | while read alias 193 | do 194 | grep -q " $alias$" /tmp/device-types-aliases-$devicetype.list 195 | if [ $? -eq 0 ];then 196 | echo "DEBUG: $alias for $devicetype already present" 197 | continue 198 | fi 199 | echo "DEBUG: Add alias $alias to $devicetype" 200 | lavacli $LAVACLIOPTS device-types aliases add $devicetype $alias || exit $? 201 | echo " $alias" >> /tmp/device-types-aliases-$devicetype.list 202 | done < /root/aliases/$devicetype 203 | done 204 | 205 | exit 0 206 | -------------------------------------------------------------------------------- /lava-slave/scripts/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /setup.sh || exit $? 4 | 5 | # Set LAVA Master IP 6 | if [[ -n "$LAVA_MASTER" ]]; then 7 | sed -i -e "s/{LAVA_MASTER}/$LAVA_MASTER/g" /etc/lava-dispatcher/lava-slave 8 | fi 9 | 10 | echo "LOGFILE=/var/log/lava-dispatcher/lava-slave.log" >> /etc/lava-dispatcher/lava-slave 11 | 12 | service tftpd-hpa start || exit 4 13 | if [ -s /etc/ser2net.yaml ];then 14 | service ser2net start || exit 7 15 | fi 16 | 17 | # start an http file server for boot/transfer_overlay support 18 | (cd /var/lib/lava/dispatcher; python3 -m http.server 80) & 19 | 20 | # FIXME lava-slave does not run if old pid is present 21 | rm -f /var/run/lava-slave.pid 22 | #service lava-slave start || exit 5 23 | #/etc/init.d/lava-slave start 24 | 25 | /root/entrypoint.sh 26 | 27 | sleep 3650d 28 | -------------------------------------------------------------------------------- /lava-slave/ser2net.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/ser2net.yaml -------------------------------------------------------------------------------- /lava-slave/tags/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelci/lava-docker/b445b5b9fbe64ed8d20ee8d505e256b3005c8c7a/lava-slave/tags/.empty -------------------------------------------------------------------------------- /lavalab-gen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | from __future__ import print_function 4 | import os, sys, time 5 | import subprocess 6 | import yaml 7 | import re 8 | import string 9 | import socket 10 | import shutil 11 | 12 | # Defaults 13 | boards_yaml = "boards.yaml" 14 | tokens_yaml = "tokens.yaml" 15 | baud_default = 115200 16 | ser2net_port_start = 63001 17 | ser2net_ports = {} 18 | allowed_hosts_list = [ '"127.0.0.1","localhost"' ] 19 | 20 | #no comment it is volontary 21 | template_device = string.Template("""{% extends '${devicetype}.jinja2' %} 22 | """) 23 | 24 | template_device_connection_command = string.Template("""# 25 | {% set connection_command = '${connection_command}' %} 26 | """) 27 | template_device_pdu_generic = string.Template(""" 28 | {% set hard_reset_command = '${hard_reset_command}' %} 29 | {% set power_off_command = '${power_off_command}' %} 30 | {% set power_on_command = '${power_on_command}' %} 31 | """) 32 | 33 | template_device_ser2net = string.Template(""" 34 | {% set connection_command = 'telnet ${telnet_host} ${port}' %} 35 | """) 36 | 37 | ser2net_dict = {} 38 | 39 | template_settings_conf = string.Template(""" 40 | { 41 | "DEBUG": false, 42 | "STATICFILES_DIRS": [ 43 | ["lava-server", "/usr/share/pyshared/lava_server/htdocs/"] 44 | ], 45 | "MEDIA_ROOT": "/var/lib/lava-server/default/media", 46 | "ARCHIVE_ROOT": "/var/lib/lava-server/default/archive", 47 | "STATIC_ROOT": "/usr/share/lava-server/static", 48 | "STATIC_URL": "/static/", 49 | "MOUNT_POINT": "/", 50 | "HTTPS_XML_RPC": false, 51 | "LOGIN_URL": "/accounts/login/", 52 | "LOGIN_REDIRECT_URL": "/", 53 | "ALLOWED_HOSTS": [ $allowed_hosts ], 54 | "CSRF_TRUSTED_ORIGINS": ["$lava_http_fqdn"], 55 | "CSRF_COOKIE_SECURE": $cookie_secure, 56 | "SESSION_COOKIE_SECURE": $session_cookie_secure, 57 | "SERVER_EMAIL": "$server_email", 58 | "EMAIL_HOST": "$email_host", 59 | "EMAIL_HOST_USER": "$email_host_user", 60 | "EMAIL_HOST_PASSWORD": "$email_host_password", 61 | "EMAIL_PORT": $email_port, 62 | "EMAIL_USE_TLS": $email_use_tls, 63 | "EMAIL_USE_SSL": $email_use_ssl, 64 | "EMAIL_BACKEND": "$email_backend", 65 | "EVENT_TOPIC": "$event_notification_topic", 66 | "INTERNAL_EVENT_SOCKET": "ipc:///tmp/lava.events", 67 | "EVENT_SOCKET": "tcp://*:$event_notification_port", 68 | "EVENT_NOTIFICATION": $event_notification_enabled, 69 | "EVENT_ADDITIONAL_SOCKETS": [] 70 | } 71 | """) 72 | 73 | template_lava_coordinator_conf = string.Template(""" 74 | { 75 | "port": 3079, 76 | "blocksize": 4096, 77 | "poll_delay": 3, 78 | "coordinator_hostname": "$masterurl" 79 | } 80 | """) 81 | 82 | def dockcomp_add_device(dockcomp, worker_name, devicemap): 83 | if "devices" in dockcomp["services"][worker_name]: 84 | dc_devices = dockcomp["services"][worker_name]["devices"] 85 | else: 86 | dockcomp["services"][worker_name]["devices"] = [] 87 | dc_devices = dockcomp["services"][worker_name]["devices"] 88 | for dmap in dc_devices: 89 | if dmap == devicemap: 90 | return 91 | dc_devices.append(devicemap) 92 | 93 | def dockcomp_add_cap(dockcomp, worker_name, cap): 94 | if "cap_add" not in dockcomp["services"][worker_name]: 95 | dockcomp["services"][worker_name]["cap_add"] = [] 96 | dockcomp["services"][worker_name]["cap_add"].append(cap) 97 | 98 | def usage(): 99 | print("%s [boardsfile.yaml]" % sys.argv[0]) 100 | 101 | def main(): 102 | fp = open(boards_yaml, "r") 103 | workers = yaml.safe_load(fp) 104 | fp.close() 105 | 106 | os.mkdir("output") 107 | 108 | if "masters" not in workers: 109 | masters = {} 110 | else: 111 | masters = workers["masters"] 112 | for master in masters: 113 | keywords_master = [ 114 | "allowed_hosts", 115 | "build_args", 116 | "event_notifications", 117 | "groups", "gunicorn_workers", 118 | "healthcheck_url", "host", "http_fqdn", 119 | "listen_address", 120 | "loglevel", "lava-coordinator", 121 | "name", 122 | "persistent_db", "pg_lava_password", 123 | "slaveenv", "smtp", 124 | "tokens", "type", 125 | "users", 126 | "version", 127 | "webadmin_https", "webinterface_port", 128 | ] 129 | for keyword in master: 130 | if not keyword in keywords_master: 131 | print("WARNING: unknown keyword %s" % keyword) 132 | name = master["name"].lower() 133 | print("Handle %s\n" % name) 134 | if not "host" in master: 135 | host = "local" 136 | else: 137 | host = master["host"] 138 | workerdir = "output/%s/%s" % (host, name) 139 | os.mkdir("output/%s" % host) 140 | shutil.copy("deploy.sh", "output/%s/" % host) 141 | if not "webinterface_port" in master: 142 | webinterface_port = "10080" 143 | else: 144 | webinterface_port = master["webinterface_port"] 145 | if "listen_address" in master: 146 | listen_address = master["listen_address"] 147 | else: 148 | listen_address = '0.0.0.0' 149 | dockcomp = {} 150 | dockcomp["version"] = "2.4" 151 | dockcomp["services"] = {} 152 | dockcomposeymlpath = "output/%s/docker-compose.yml" % host 153 | dockcomp["services"][name] = {} 154 | dockcomp["services"][name]["hostname"] = name 155 | dockcomp["services"][name]["ports"] = [ listen_address + ":" + str(webinterface_port) + ":80"] 156 | dockcomp["services"][name]["volumes"] = [ "/boot:/boot", "/lib/modules:/lib/modules" ] 157 | dockcomp["services"][name]["build"] = {} 158 | dockcomp["services"][name]["build"]["context"] = name 159 | if "build_args" in master: 160 | dockcomp["services"][name]["build"]["args"] = master['build_args'] 161 | persistent_db = False 162 | if "persistent_db" in master: 163 | persistent_db = master["persistent_db"] 164 | if persistent_db: 165 | pg_volume_name = "pgdata_" + name 166 | dockcomp["services"][name]["volumes"].append(pg_volume_name + ":/var/lib/postgresql") 167 | etc_volume_name = "lava_etc_" + name 168 | dockcomp["services"][name]["volumes"].append(etc_volume_name + ":/etc/lava-server/") 169 | dockcomp["services"][name]["volumes"].append("lava_job_output:/var/lib/lava-server/default/media/job-output/") 170 | dockcomp["volumes"] = {} 171 | dockcomp["volumes"][etc_volume_name] = {} 172 | dockcomp["volumes"][pg_volume_name] = {} 173 | dockcomp["volumes"]["lava_job_output"] = {} 174 | 175 | shutil.copytree("lava-master", workerdir) 176 | os.mkdir("%s/devices" % workerdir) 177 | # handle users / tokens 178 | userdir = "%s/users" % workerdir 179 | os.mkdir(userdir) 180 | groupdir = "%s/groups" % workerdir 181 | os.mkdir(groupdir) 182 | worker = master 183 | if "pg_lava_password" in master: 184 | f_pg = open("%s/pg_lava_password" % workerdir, 'w') 185 | f_pg.write(master["pg_lava_password"]) 186 | f_pg.close() 187 | else: 188 | f_pg = open("%s/pg_lava_password" % workerdir, 'w') 189 | f_pg.close() 190 | if "version" in worker: 191 | dockerfile = open("%s/Dockerfile" % workerdir, "r+") 192 | dockerfilec = re.sub('(^FROM.*:).*', '\g<1>%s' % worker["version"], dockerfile.read()) 193 | dockerfile.seek(0) 194 | dockerfile.write(dockerfilec) 195 | dockerfile.close() 196 | dockcomp["services"][name]["image"] = "%s:%s" % (name, worker["version"]) 197 | if "lava-coordinator" in master and master["lava-coordinator"]: 198 | dockcomp["services"][name]["ports"].append('3079:3079') 199 | f_entrypoint = open("%s/entrypoint.d/02_lava-coordinator.sh" % workerdir, 'w') 200 | f_entrypoint.write("#!/bin/sh\n") 201 | f_entrypoint.write("echo 'Start lava-coordinator'\n") 202 | f_entrypoint.write("mkdir /run/lava-coordinator && chown lavaserver /run/lava-coordinator\n") 203 | f_entrypoint.write("start-stop-daemon --start --chuid lavaserver --background --exec /usr/bin/lava-coordinator -- --logfile=/var/log/lava-server/lava-coordinator.log\n") 204 | f_entrypoint.write("exit $?\n") 205 | f_entrypoint.close() 206 | os.chmod("%s/entrypoint.d/02_lava-coordinator.sh" % workerdir, 0o755) 207 | if "gunicorn_workers" in worker: 208 | dockcomp["services"][name]["environment"] = {} 209 | dockcomp["services"][name]["environment"]["GUNICORN_WORKERS"] = worker["gunicorn_workers"] 210 | 211 | with open(dockcomposeymlpath, 'w') as f: 212 | yaml.dump(dockcomp, f) 213 | if "healthcheck_url" in master: 214 | f_hc = open("%s/health-checks/healthcheck_url" % workerdir, 'w') 215 | f_hc.write(master["healthcheck_url"]) 216 | f_hc.close() 217 | webadmin_https = False 218 | if "webadmin_https" in worker: 219 | webadmin_https = worker["webadmin_https"] 220 | if webadmin_https: 221 | cookie_secure = "true" 222 | session_cookie_secure = "true" 223 | else: 224 | cookie_secure = "false" 225 | session_cookie_secure = "false" 226 | if "http_fqdn" in worker: 227 | lava_http_fqdn = worker["http_fqdn"] 228 | allowed_hosts_list.append('"%s"' % lava_http_fqdn) 229 | else: 230 | lava_http_fqdn = "127.0.0.1" 231 | allowed_hosts_list.append('"%s"' % name) 232 | if "allowed_hosts" in worker: 233 | for allow_host in worker["allowed_hosts"]: 234 | allowed_hosts_list.append('"%s"' % allow_host) 235 | allowed_hosts = ','.join(allowed_hosts_list) 236 | f_fqdn = open("%s/lava_http_fqdn" % workerdir, 'w') 237 | f_fqdn.write(lava_http_fqdn) 238 | f_fqdn.close() 239 | # DJANGO defaults 240 | email_host = "localhost" 241 | email_host_user = "" 242 | email_host_password = "" 243 | email_port = 25 244 | email_use_tls = 'false' 245 | email_use_ssl = 'false' 246 | email_backend = 'django.core.mail.backends.smtp.EmailBackend' 247 | server_email = "root@localhost" 248 | if "smtp" in worker: 249 | if "server_email" in worker["smtp"]: 250 | server_email = worker["smtp"]["server_email"] 251 | if "email_host" in worker["smtp"]: 252 | email_host = worker["smtp"]["email_host"] 253 | if "email_host_user" in worker["smtp"]: 254 | email_host_user = worker["smtp"]["email_host_user"] 255 | if "email_host_password" in worker["smtp"]: 256 | email_host_password = worker["smtp"]["email_host_password"] 257 | if "email_port" in worker["smtp"]: 258 | email_port = worker["smtp"]["email_port"] 259 | # django does not like True or False but want true/false (no upper case) 260 | if "email_use_tls" in worker["smtp"]: 261 | email_use_tls = worker["smtp"]["email_use_tls"] 262 | if isinstance(email_use_tls, bool): 263 | if email_use_tls: 264 | email_use_tls = 'true' 265 | else: 266 | email_use_tls = 'false' 267 | if "email_use_ssl" in worker["smtp"]: 268 | email_use_ssl = worker["smtp"]["email_use_ssl"] 269 | if isinstance(email_use_ssl, bool): 270 | if email_use_ssl: 271 | email_use_ssl = 'true' 272 | else: 273 | email_use_ssl = 'false' 274 | if "email_backend" in worker["smtp"]: 275 | email_backend = worker["smtp"]["email_backend"] 276 | # Event notifications 277 | event_notification_topic=name 278 | event_notification_port='5500' 279 | event_notification_enabled='false' 280 | if "event_notifications" in worker: 281 | if "event_notification_topic" in worker["event_notifications"]: 282 | event_notification_topic = worker["event_notifications"]["event_notification_topic"] 283 | if "event_notification_port" in worker["event_notifications"]: 284 | event_notification_port = worker["event_notifications"]["event_notification_port"] 285 | if "event_notification_enabled" in worker["event_notifications"]: 286 | event_notification_enabled = worker["event_notifications"]["event_notification_enabled"] 287 | # django does not like True or False but want true/false (no upper case) 288 | if isinstance(event_notification_enabled, bool): 289 | if event_notification_enabled: 290 | event_notification_enabled = 'true' 291 | else: 292 | event_notification_enabled = 'false' 293 | # Substitute variables in settings.conf 294 | fsettings = open("%s/settings.conf" % workerdir, 'w') 295 | fsettings.write( 296 | template_settings_conf.substitute( 297 | cookie_secure=cookie_secure, 298 | session_cookie_secure=session_cookie_secure, 299 | lava_http_fqdn=lava_http_fqdn, 300 | allowed_hosts=allowed_hosts, 301 | email_host = email_host, 302 | email_host_user = email_host_user, 303 | email_host_password = email_host_password, 304 | email_port = email_port, 305 | email_use_tls = email_use_tls, 306 | email_use_ssl = email_use_ssl, 307 | email_backend = email_backend, 308 | server_email = server_email, 309 | event_notification_topic = event_notification_topic, 310 | event_notification_port = event_notification_port, 311 | event_notification_enabled = event_notification_enabled 312 | ) 313 | ) 314 | fsettings.close() 315 | if "users" in worker: 316 | for user in worker["users"]: 317 | keywords_users = [ "name", "staff", "superuser", "password", "token", "email", "groups" ] 318 | for keyword in user: 319 | if not keyword in keywords_users: 320 | print("WARNING: unknown keyword %s" % keyword) 321 | username = user["name"] 322 | ftok = open("%s/%s" % (userdir, username), "w") 323 | if "token" in user: 324 | token = user["token"] 325 | ftok.write("TOKEN=" + token + "\n") 326 | if "password" in user: 327 | password = user["password"] 328 | ftok.write("PASSWORD=" + password + "\n") 329 | # libyaml convert yes/no to true/false... 330 | if "email" in user: 331 | email = user["email"] 332 | ftok.write("EMAIL=" + email + "\n") 333 | if "staff" in user: 334 | value = user["staff"] 335 | if value is True: 336 | ftok.write("STAFF=1\n") 337 | if "superuser" in user: 338 | value = user["superuser"] 339 | if value is True: 340 | ftok.write("SUPERUSER=1\n") 341 | ftok.close() 342 | if "groups" in user: 343 | for group in user["groups"]: 344 | groupname = group["name"] 345 | print("\tAdd user %s to %s" % (username, groupname)) 346 | fgrp_userlist = open("%s/%s.group.list" % (groupdir, groupname), "a") 347 | fgrp_userlist.write("%s\n" % username) 348 | fgrp_userlist.close() 349 | if "groups" in worker: 350 | for group in worker["groups"]: 351 | groupname = group["name"] 352 | print("\tAdding group %s" % groupname) 353 | fgrp = open("%s/%s.group" % (groupdir, groupname), "w") 354 | fgrp.write("GROUPNAME=%s\n" % groupname) 355 | submitter = False 356 | if "submitter" in group: 357 | submitter = group["submitter"] 358 | if submitter: 359 | fgrp.write("SUBMIT=1\n") 360 | fgrp.close() 361 | tokendir = "%s/tokens" % workerdir 362 | os.mkdir(tokendir) 363 | if "tokens" in worker: 364 | filename_num = {} 365 | print("Found tokens") 366 | for token in worker["tokens"]: 367 | keywords_tokens = [ "username", "token", "description" ] 368 | for keyword in token: 369 | if not keyword in keywords_tokens: 370 | print("WARNING: unknown keyword %s" % keyword) 371 | username = token["username"] 372 | description = token["description"] 373 | if username in filename_num: 374 | number = filename_num[username] 375 | filename_num[username] = filename_num[username] + 1 376 | else: 377 | filename_num[username] = 1 378 | number = 0 379 | filename = "%s-%d" % (username, number) 380 | print("\tAdd token for %s in %s" % (username, filename)) 381 | ftok = open("%s/%s" % (tokendir, filename), "w") 382 | ftok.write("USER=" + username + "\n") 383 | vtoken = token["token"] 384 | ftok.write("TOKEN=" + vtoken + "\n") 385 | ftok.write("DESCRIPTION=\"%s\"" % description) 386 | ftok.close() 387 | if "slaveenv" in worker: 388 | for slaveenv in worker["slaveenv"]: 389 | slavename = slaveenv["name"] 390 | envdir = "%s/env/%s" % (workerdir, slavename) 391 | if not os.path.isdir(envdir): 392 | os.mkdir(envdir) 393 | fenv = open("%s/env.yaml" % envdir, 'w') 394 | fenv.write("overrides:\n") 395 | for line in slaveenv["env"]: 396 | fenv.write(" %s\n" % line) 397 | fenv.close() 398 | if "loglevel" in worker: 399 | for component in worker["loglevel"]: 400 | if component != "lava-master" and component != "lava-logs" and component != 'lava-server-gunicorn' and component != "lava-scheduler": 401 | print("ERROR: invalid loglevel component %s" % component) 402 | sys.exit(1) 403 | loglevel = worker["loglevel"][component] 404 | if loglevel != 'DEBUG' and loglevel != 'INFO' and loglevel != 'WARN' and loglevel != 'ERROR': 405 | print("ERROR: invalid loglevel %s for %s" % (loglevel, component)) 406 | sys.exit(1) 407 | fcomponent = open("%s/default/%s" % (workerdir, component), 'w') 408 | fcomponent.write("LOGLEVEL=%s\n" % loglevel) 409 | fcomponent.close() 410 | 411 | default_slave = "lab-slave-0" 412 | if "slaves" not in workers: 413 | slaves = {} 414 | else: 415 | slaves = workers["slaves"] 416 | for slave in slaves: 417 | keywords_slaves = [ 418 | "arch", 419 | "bind_dev", "build_args", 420 | "custom_volumes", 421 | "devices", "dispatcher_ip", "default_slave", 422 | "extra_actions", "export_ser2net", "expose_ser2net", "expose_ports", "env", 423 | "host", "host_healthcheck", 424 | "loglevel", "lava-coordinator", "lava_worker_token", 425 | "name", 426 | "remote_user", "remote_master", "remote_address", "remote_rpc_port", "remote_proto", "remote_user_token", 427 | "tags", 428 | "use_docker", "use_nfs", "use_nbd", "use_overlay_server", "use_tftp", "use_tap", 429 | "version", 430 | ] 431 | for keyword in slave: 432 | if not keyword in keywords_slaves: 433 | print("WARNING: unknown keyword %s" % keyword) 434 | name = slave["name"].lower() 435 | if len(slaves) == 1: 436 | default_slave = name 437 | print("Handle %s" % name) 438 | if not "host" in slave: 439 | host = "local" 440 | else: 441 | host = slave["host"] 442 | if slave.get("default_slave") and slave["default_slave"]: 443 | default_slave = name 444 | workerdir = "output/%s/%s" % (host, name) 445 | dockcomposeymlpath = "output/%s/docker-compose.yml" % host 446 | if not os.path.isdir("output/%s" % host): 447 | os.mkdir("output/%s" % host) 448 | shutil.copy("deploy.sh", "output/%s/" % host) 449 | dockcomp = {} 450 | dockcomp["version"] = "2.0" 451 | dockcomp["services"] = {} 452 | else: 453 | #master exists 454 | fp = open(dockcomposeymlpath, "r") 455 | dockcomp = yaml.safe_load(fp) 456 | fp.close() 457 | dockcomp["services"][name] = {} 458 | dockcomp["services"][name]["hostname"] = name 459 | dockcomp["services"][name]["dns_search"] = "" 460 | dockcomp["services"][name]["ports"] = [] 461 | dockcomp["services"][name]["volumes"] = [ "/boot:/boot", "/lib/modules:/lib/modules" ] 462 | dockcomp["services"][name]["environment"] = {} 463 | dockcomp["services"][name]["build"] = {} 464 | dockcomp["services"][name]["build"]["context"] = name 465 | if "build_args" in slave: 466 | dockcomp["services"][name]["build"]["args"] = slave['build_args'] 467 | # insert here remote 468 | 469 | shutil.copytree("lava-slave", workerdir) 470 | fp = open("%s/phyhostname" % workerdir, "w") 471 | fp.write(host) 472 | fp.close() 473 | 474 | worker = slave 475 | worker_name = name 476 | slave_master = None 477 | if "version" in worker: 478 | dockerfile = open("%s/Dockerfile" % workerdir, "r+") 479 | dockerfilec = re.sub('(^FROM.*:).*', '\g<1>%s' % worker["version"], dockerfile.read()) 480 | dockerfile.seek(0) 481 | dockerfile.write(dockerfilec) 482 | dockerfile.close() 483 | dockcomp["services"][name]["image"] = "%s:%s" % (name, worker["version"]) 484 | if "arch" in worker: 485 | if worker["arch"] == 'arm64': 486 | dockerfile = open("%s/Dockerfile" % workerdir, "r+") 487 | dockerfilec = dockerfile.read().replace("lava-slave-base", "lava-slave-base-arm64") 488 | dockerfile.seek(0) 489 | dockerfile.write(dockerfilec) 490 | dockerfile.close() 491 | #NOTE remote_master is on slave 492 | if not "remote_master" in worker: 493 | remote_master = "lava-master" 494 | else: 495 | remote_master = worker["remote_master"] 496 | if not "remote_address" in worker: 497 | remote_address = remote_master 498 | else: 499 | remote_address = worker["remote_address"] 500 | if not "remote_rpc_port" in worker: 501 | remote_rpc_port = "80" 502 | else: 503 | remote_rpc_port = worker["remote_rpc_port"] 504 | dockcomp["services"][worker_name]["environment"]["LAVA_MASTER"] = remote_address 505 | if "lava_worker_token" in worker: 506 | fsetupenv = open("%s/setupenv" % workerdir, "a") 507 | fsetupenv.write("LAVA_WORKER_TOKEN=%s\n" % worker["lava_worker_token"]) 508 | fsetupenv.close() 509 | remote_user = worker["remote_user"] 510 | # find master 511 | remote_token = "BAD" 512 | if "masters" in workers: 513 | masters = workers["masters"] 514 | else: 515 | masters = {} 516 | if "remote_user_token" in worker: 517 | remote_token = worker["remote_user_token"] 518 | for fm in masters: 519 | if fm["name"].lower() == remote_master.lower(): 520 | slave_master = fm 521 | for fuser in fm["users"]: 522 | if fuser["name"] == remote_user: 523 | remote_token = fuser["token"] 524 | if remote_token == "BAD": 525 | print("Cannot find %s on %s" % (remote_user, remote_master)) 526 | sys.exit(1) 527 | if "env" in slave: 528 | if not slave_master: 529 | print("Cannot set env without master") 530 | sys.exit(1) 531 | envdir = "output/%s/%s/env/%s" % (slave_master["host"], slave_master["name"], name) 532 | os.mkdir(envdir) 533 | fenv = open("%s/env.yaml" % envdir, 'w') 534 | fenv.write("overrides:\n") 535 | for line in slave["env"]: 536 | fenv.write(" %s\n" % line) 537 | fenv.close() 538 | if "custom_volumes" in slave: 539 | for cvolume in slave["custom_volumes"]: 540 | dockcomp["services"][worker_name]["volumes"].append(cvolume) 541 | volume_name = cvolume.split(':')[0] 542 | if "volumes" not in dockcomp: 543 | dockcomp["volumes"] = {} 544 | if cvolume[0] != '/': 545 | dockcomp["volumes"][volume_name] = {} 546 | if not "remote_proto" in worker: 547 | remote_proto = "http" 548 | else: 549 | remote_proto = worker["remote_proto"] 550 | remote_uri = "%s://%s:%s@%s:%s/RPC2" % (remote_proto, remote_user, remote_token, remote_address, remote_rpc_port) 551 | remote_master_url = "%s://%s:%s" % (remote_proto, remote_address, remote_rpc_port) 552 | 553 | fsetupenv = open("%s/setupenv" % workerdir, "a") 554 | fsetupenv.write("LAVA_MASTER_URI=%s\n" % remote_uri) 555 | fsetupenv.write("LAVA_MASTER_URL=%s\n" % remote_master_url) 556 | fsetupenv.write("LAVA_MASTER_USER=%s\n" % remote_user) 557 | fsetupenv.write("LAVA_MASTER_BASEURI=%s://%s:%s/RPC2\n" % (remote_proto, remote_address, remote_rpc_port)) 558 | fsetupenv.write("LAVA_MASTER_TOKEN=%s\n" % remote_token) 559 | fsetupenv.close() 560 | 561 | if "lava-coordinator" in worker and worker["lava-coordinator"]: 562 | fcoordinator = open("%s/lava-coordinator/lava-coordinator.cnf" % workerdir, 'w') 563 | fcoordinator.write(template_lava_coordinator_conf.substitute(masterurl=remote_address)) 564 | fcoordinator.close() 565 | if "dispatcher_ip" in worker: 566 | dockcomp["services"][worker_name]["environment"]["LAVA_DISPATCHER_IP"] = worker["dispatcher_ip"] 567 | if "expose_ports" in worker: 568 | for eports in worker["expose_ports"]: 569 | dockcomp["services"][name]["ports"].append("%s" % eports) 570 | if "bind_dev" in worker and worker["bind_dev"]: 571 | dockcomp["services"][worker_name]["volumes"].append("/dev:/dev") 572 | dockcomp["services"][worker_name]["privileged"] = True 573 | if "use_tap" in worker and worker["use_tap"]: 574 | dockcomp_add_device(dockcomp, worker_name, "/dev/net/tun:/dev/net/tun") 575 | dockcomp_add_cap(dockcomp, worker_name, "NET_ADMIN") 576 | if "host_healthcheck" in worker and worker["host_healthcheck"]: 577 | dockcomp["services"]["healthcheck"] = {} 578 | dockcomp["services"]["healthcheck"]["ports"] = ["8080:8080"] 579 | dockcomp["services"]["healthcheck"]["build"] = {} 580 | dockcomp["services"]["healthcheck"]["build"]["context"] = "healthcheck" 581 | if remote_master in worker and "build_args" in worker[remote_master]: 582 | dockcomp["services"]["healthcheck"]["build"]["args"] = worker[remote_master]['build_args'] 583 | shutil.copytree("healthcheck", "output/%s/healthcheck" % host) 584 | if "extra_actions" in worker: 585 | fp = open("%s/scripts/extra_actions" % workerdir, "w") 586 | for eaction in worker["extra_actions"]: 587 | fp.write(eaction) 588 | fp.write("\n") 589 | fp.close() 590 | os.chmod("%s/scripts/extra_actions" % workerdir, 0o755) 591 | 592 | if "devices" in worker: 593 | if not os.path.isdir("output/%s/udev" % host): 594 | os.mkdir("output/%s/udev" % host) 595 | for udev_dev in worker["devices"]: 596 | udev_line = 'SUBSYSTEM=="tty", ATTRS{idVendor}=="%04x", ATTRS{idProduct}=="%04x",' % (udev_dev["idvendor"], udev_dev["idproduct"]) 597 | if "serial" in udev_dev: 598 | udev_line += 'ATTRS{serial}=="%s", ' % udev_dev["serial"] 599 | if "devpath" in udev_dev: 600 | udev_line += 'ATTRS{devpath}=="%s", ' % udev_dev["devpath"] 601 | udev_line += 'MODE="0664", OWNER="uucp", SYMLINK+="%s"\n' % udev_dev["name"] 602 | fudev = open("output/%s/udev/99-lavaworker-udev.rules" % host, "a") 603 | fudev.write(udev_line) 604 | fudev.close() 605 | if not "bind_dev" in slave or not slave["bind_dev"]: 606 | dockcomp_add_device(dockcomp, worker_name, "/dev/%s:/dev/%s" % (udev_dev["name"], udev_dev["name"])) 607 | use_tftp = True 608 | if "use_tftp" in worker: 609 | use_tftp = worker["use_tftp"] 610 | if use_tftp: 611 | if "dispatcher_ip" in worker: 612 | dockcomp["services"][name]["ports"].append(worker["dispatcher_ip"] + ":69:69/udp") 613 | else: 614 | dockcomp["services"][name]["ports"].append("69:69/udp") 615 | use_docker = False 616 | if "use_docker" in worker: 617 | use_docker = worker["use_docker"] 618 | if use_docker: 619 | dockcomp["services"][worker_name]["volumes"].append("/var/run/docker.sock:/var/run/docker.sock") 620 | dockcomp["services"][worker_name]["volumes"].append("/run/udev/data:/run/udev/data") 621 | # TODO permit to change the range of NBD ports 622 | use_nbd = True 623 | if "use_nbd" in worker: 624 | use_nbd = worker["use_nbd"] 625 | if use_nbd: 626 | dockcomp["services"][name]["ports"].append("61950-62000:61950-62000") 627 | fp = open("%s/scripts/extra_actions" % workerdir, "a") 628 | # LAVA issue 585 need to remove /etc/nbd-server/config 629 | fp.write("apt-get -y install nbd-server && rm -f /etc/nbd-server/config\n") 630 | fp.close() 631 | os.chmod("%s/scripts/extra_actions" % workerdir, 0o755) 632 | use_overlay_server = True 633 | if "use_overlay_server" in worker: 634 | use_overlay_server = worker["use_overlay_server"] 635 | if use_overlay_server: 636 | dockcomp["services"][name]["ports"].append("80:80") 637 | use_nfs = False 638 | if "use_nfs" in worker: 639 | use_nfs = worker["use_nfs"] 640 | if use_nfs or use_docker: 641 | dockcomp["services"][worker_name]["volumes"].append("/var/lib/lava/dispatcher/tmp:/var/lib/lava/dispatcher/tmp") 642 | if use_nfs: 643 | fp = open("%s/scripts/extra_actions" % workerdir, "a") 644 | # LAVA check if this package is installed when doing NFS jobs 645 | # So we need to install it, even if it is not used 646 | fp.write("apt-get -y install nfs-kernel-server\n") 647 | fp.close() 648 | os.chmod("%s/scripts/extra_actions" % workerdir, 0o755) 649 | with open(dockcomposeymlpath, 'w') as f: 650 | yaml.dump(dockcomp, f) 651 | if "loglevel" in worker: 652 | for component in worker["loglevel"]: 653 | if component != "lava-slave": 654 | print("ERROR: invalid loglevel component %s" % component) 655 | sys.exit(1) 656 | loglevel = worker["loglevel"][component] 657 | if loglevel != 'DEBUG' and loglevel != 'INFO' and loglevel != 'WARN' and loglevel != 'ERROR': 658 | print("ERROR: invalid loglevel %s for %s" % (loglevel, component)) 659 | sys.exit(1) 660 | fcomponent = open("%s/default/%s" % (workerdir, component), 'w') 661 | fcomponent.write("LOGLEVEL=%s\n" % loglevel) 662 | fcomponent.close() 663 | 664 | if "boards" not in workers: 665 | boards = {} 666 | else: 667 | boards = workers["boards"] 668 | for board in boards: 669 | board_name = board["name"] 670 | if "slave" in board: 671 | worker_name = board["slave"] 672 | else: 673 | worker_name = default_slave 674 | print("\tFound %s on %s" % (board_name, worker_name)) 675 | found_slave = False 676 | for fs in workers["slaves"]: 677 | if fs["name"].lower() == worker_name.lower(): 678 | slave = fs 679 | found_slave = True 680 | if not found_slave: 681 | print("Cannot find slave %s" % worker_name) 682 | sys.exit(1) 683 | if not "host" in slave: 684 | host = "local" 685 | else: 686 | host = slave["host"] 687 | workerdir = "output/%s/%s" % (host, worker_name) 688 | dockcomposeymlpath = "output/%s/docker-compose.yml" % host 689 | fp = open(dockcomposeymlpath, "r") 690 | dockcomp = yaml.safe_load(fp) 691 | fp.close() 692 | device_path = "%s/devices/" % workerdir 693 | devices_path = "%s/devices/%s" % (workerdir, worker_name) 694 | devicetype = board["type"] 695 | device_line = template_device.substitute(devicetype=devicetype) 696 | if "pdu_generic" in board: 697 | hard_reset_command = board["pdu_generic"]["hard_reset_command"] 698 | power_off_command = board["pdu_generic"]["power_off_command"] 699 | power_on_command = board["pdu_generic"]["power_on_command"] 700 | device_line += template_device_pdu_generic.substitute(hard_reset_command=hard_reset_command, power_off_command=power_off_command, power_on_command=power_on_command) 701 | use_kvm = False 702 | if "kvm" in board: 703 | use_kvm = board["kvm"] 704 | if use_kvm: 705 | dockcomp_add_device(dockcomp, worker_name, "/dev/kvm:/dev/kvm") 706 | # board specific hacks 707 | if devicetype == "qemu" and not use_kvm: 708 | device_line += "{% set no_kvm = True %}\n" 709 | if "uart" in board: 710 | keywords_uart = [ "baud", "devpath", "idproduct", "idvendor", "interfacenum", "serial", "use_ser2net", "worker" ] 711 | for keyword in board["uart"]: 712 | if not keyword in keywords_uart: 713 | print("WARNING: unknown keyword %s" % keyword) 714 | uart = board["uart"] 715 | baud = board["uart"].get("baud", baud_default) 716 | idvendor = board["uart"]["idvendor"] 717 | idproduct = board["uart"]["idproduct"] 718 | if type(idproduct) == str: 719 | print("Please put hexadecimal IDs for product %s (like 0x%s)" % (board_name, idproduct)) 720 | sys.exit(1) 721 | if type(idvendor) == str: 722 | print("Please put hexadecimal IDs for vendor %s (like 0x%s)" % (board_name, idvendor)) 723 | sys.exit(1) 724 | udev_line = 'SUBSYSTEM=="tty", ATTRS{idVendor}=="%04x", ATTRS{idProduct}=="%04x",' % (idvendor, idproduct) 725 | if "serial" in uart: 726 | udev_line += 'ATTRS{serial}=="%s", ' % board["uart"]["serial"] 727 | if "devpath" in uart: 728 | udev_line += 'ATTRS{devpath}=="%s", ' % board["uart"]["devpath"] 729 | if "interfacenum" in uart: 730 | udev_line += 'ENV{ID_USB_INTERFACE_NUM}=="%s", ' % board["uart"]["interfacenum"] 731 | udev_line += 'MODE="0664", OWNER="uucp", SYMLINK+="%s"\n' % board_name 732 | if not os.path.isdir("output/%s/udev" % host): 733 | os.mkdir("output/%s/udev" % host) 734 | fp = open("output/%s/udev/99-lavaworker-udev.rules" % host, "a") 735 | fp.write(udev_line) 736 | fp.close() 737 | if not "bind_dev" in slave or not slave["bind_dev"]: 738 | dockcomp_add_device(dockcomp, worker_name, "/dev/%s:/dev/%s" % (board_name, board_name)) 739 | use_ser2net = False 740 | ser2net_keepopen = False 741 | if "use_ser2net" in uart: 742 | use_ser2net = uart["use_ser2net"] 743 | if "ser2net_keepopen" in uart: 744 | ser2net_keepopen = uart["ser2net_keepopen"] 745 | if not use_ser2net and not "connection_command" in board: 746 | use_ser2net = True 747 | if use_ser2net: 748 | if "worker" in uart: 749 | worker_ser2net = uart["worker"] 750 | telnet_host = worker_ser2net 751 | else: 752 | worker_ser2net = worker_name 753 | telnet_host = "127.0.0.1" 754 | ser2netdir = "output/%s/%s" % (host, worker_ser2net) 755 | if not os.path.isdir(ser2netdir): 756 | os.mkdir(ser2netdir) 757 | if (not "bind_dev" in slave or not slave["bind_dev"]) and worker_ser2net == worker_name: 758 | dockcomp_add_device(dockcomp, worker_name, "/dev/%s:/dev/%s" % (board_name, board_name)) 759 | udev_line = 'SUBSYSTEM=="tty", ATTRS{idVendor}=="%04x", ATTRS{idProduct}=="%04x",' % (idvendor, idproduct) 760 | if "serial" in uart: 761 | udev_line += 'ATTRS{serial}=="%s", ' % board["uart"]["serial"] 762 | if "devpath" in uart: 763 | udev_line += 'ATTRS{devpath}=="%s", ' % board["uart"]["devpath"] 764 | if "interfacenum" in uart: 765 | udev_line += 'ENV{ID_USB_INTERFACE_NUM}=="%s", ' % board["uart"]["interfacenum"] 766 | udev_line += 'MODE="0664", OWNER="uucp", SYMLINK+="%s"\n' % board_name 767 | udevdir = "output/%s/%s/udev" % (host, worker_ser2net) 768 | if not os.path.isdir(udevdir): 769 | os.mkdir(udevdir) 770 | fp = open("%s/99-lavaworker-udev.rules" % udevdir, "a") 771 | fp.write(udev_line) 772 | fp.close() 773 | if not worker_ser2net in ser2net_ports: 774 | ser2net_ports[worker_ser2net] = ser2net_port_start 775 | fp = open("%s/ser2net.yaml" % ser2netdir, "a") 776 | fp.write("%YAML 1.1\n---\n") 777 | fp.close() 778 | device_line += template_device_ser2net.substitute(port=ser2net_ports[worker_ser2net], telnet_host=telnet_host) 779 | # YAML version 780 | fp = open("%s/ser2net.yaml" % ser2netdir, "a") 781 | fp.write("connection: &con%d\n" % ser2net_ports[worker_ser2net]) 782 | fp.write(" accepter: telnet(rfc2217),tcp,%d\n" % ser2net_ports[worker_ser2net]) 783 | fp.write(" enable: on\n") 784 | if ser2net_keepopen: 785 | ser2net_yaml_line= " connector: keepopen(retry-time=2000,discard-badwrites),serialdev,/dev/%s,%dn81,local" % (board_name, baud) 786 | else: 787 | ser2net_yaml_line = " connector: serialdev,/dev/%s,%dn81,local" % (board_name, baud) 788 | if "ser2net_options" in uart: 789 | for ser2net_yaml_option in uart["ser2net_options"]: 790 | ser2net_yaml_line += ",%s" % ser2net_yaml_option 791 | ser2net_yaml_line += "\n" 792 | fp.write(ser2net_yaml_line) 793 | fp.write(" options:\n") 794 | fp.write(" max-connections: 10\n") 795 | ser2net_ports[worker_ser2net] += 1 796 | fp.close() 797 | if "connection_command" in board: 798 | connection_command = board["connection_command"] 799 | device_line += template_device_connection_command.substitute(connection_command=connection_command) 800 | if "uboot_ipaddr" in board: 801 | device_line += "{%% set uboot_ipaddr_cmd = 'setenv ipaddr %s' %%}\n" % board["uboot_ipaddr"] 802 | if "uboot_macaddr" in board: 803 | device_line += '{% set uboot_set_mac = true %}' 804 | device_line += "{%% set uboot_mac_addr = '%s' %%}\n" % board["uboot_macaddr"] 805 | if "fastboot_serial_number" in board: 806 | fserial = board["fastboot_serial_number"] 807 | device_line += "{%% set fastboot_serial_number = '%s' %%}" % fserial 808 | if "tags" in board: 809 | tagdir = "%s/tags/" % workerdir 810 | ftag = open("%s/%s" % (tagdir, board_name), 'w') 811 | for tag in board["tags"]: 812 | ftag.write("%s\n" % tag) 813 | ftag.close() 814 | if "tags" in slave: 815 | tagdir = "%s/tags/" % workerdir 816 | ftag = open("%s/%s" % (tagdir, board_name), 'a') 817 | for tag in slave["tags"]: 818 | ftag.write("%s\n" % tag) 819 | ftag.close() 820 | if "aliases" in board: 821 | aliases_dir = "%s/aliases/" % workerdir 822 | falias = open("%s/%s" % (aliases_dir, board["type"]), 'a') 823 | for alias in board["aliases"]: 824 | falias.write("%s\n" % alias) 825 | falias.close() 826 | if "user" in board: 827 | deviceinfo = open("%s/deviceinfo/%s" % (workerdir, board_name), 'w') 828 | deviceinfo.write("DEVICE_USER=%s\n" % board["user"]) 829 | deviceinfo.close() 830 | if "group" in board: 831 | if "user" in board: 832 | print("user and group are exclusive") 833 | sys.exit(1) 834 | deviceinfo = open("%s/deviceinfo/%s" % (workerdir, board_name), 'w') 835 | deviceinfo.write("DEVICE_GROUP=%s\n" % board["group"]) 836 | deviceinfo.close() 837 | if "custom_option" in board: 838 | if type(board["custom_option"]) == list: 839 | for coption in board["custom_option"]: 840 | device_line += "{%% %s %%}\n" % coption 841 | else: 842 | for line in board["custom_option"].splitlines(): 843 | device_line += "{%% %s %%}\n" % line 844 | if "raw_custom_option" in board: 845 | for coption in board["raw_custom_option"]: 846 | device_line += "%s\n" % coption 847 | if not os.path.isdir(device_path): 848 | os.mkdir(device_path) 849 | if not os.path.isdir(devices_path): 850 | os.mkdir(devices_path) 851 | board_device_file = "%s/%s.jinja2" % (devices_path, board_name) 852 | fp = open(board_device_file, "w") 853 | fp.write(device_line) 854 | fp.close() 855 | with open(dockcomposeymlpath, 'w') as f: 856 | yaml.dump(dockcomp, f) 857 | #end for board 858 | 859 | for slave_name in ser2net_ports: 860 | expose_ser2net = False 861 | for fs in workers["slaves"]: 862 | if fs["name"] == slave_name: 863 | if not "host" in fs: 864 | host = "local" 865 | else: 866 | host = fs["host"] 867 | if "expose_ser2net" in fs: 868 | expose_ser2net = fs["expose_ser2net"] 869 | if "export_ser2net" in fs: 870 | print("export_ser2net is deprecated, please use expose_ser2net") 871 | expose_ser2net = fs["export_ser2net"] 872 | if not expose_ser2net: 873 | continue 874 | print("Add ser2net ports for %s (%s) %s-%s" % (slave_name, host, ser2net_port_start, ser2net_ports[slave_name])) 875 | dockcomposeymlpath = "output/%s/docker-compose.yml" % host 876 | fp = open(dockcomposeymlpath, "r") 877 | dockcomp = yaml.safe_load(fp) 878 | fp.close() 879 | ser2net_port_max = ser2net_ports[slave_name] - 1 880 | dockcomp["services"][slave_name]["ports"].append("%s-%s:%s-%s" % (ser2net_port_start, ser2net_port_max, ser2net_port_start, ser2net_port_max)) 881 | with open(dockcomposeymlpath, 'w') as f: 882 | yaml.dump(dockcomp, f) 883 | 884 | if len(sys.argv) > 1: 885 | if sys.argv[1] == '-h' or sys.argv[1] == '--help': 886 | usage() 887 | sys.exit(0) 888 | boards_yaml = sys.argv[1] 889 | 890 | if __name__ == "__main__": 891 | main() 892 | 893 | -------------------------------------------------------------------------------- /lavalab-gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf output 4 | 5 | if [ "$1" = "mrproper" ];then 6 | exit 0 7 | fi 8 | 9 | ./lavalab-gen.py $* || exit 1 10 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | docker 2 | docker-compose 3 | pyyaml 4 | -------------------------------------------------------------------------------- /squid/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:9 2 | 3 | RUN apt-get update 4 | RUN DEBIAN_FRONTEND=noninteractive apt-get install -y squid3 5 | 6 | COPY entrypoint.sh /sbin/entrypoint.sh 7 | COPY squid.conf /etc/squid/squid.conf 8 | RUN chmod 755 /sbin/entrypoint.sh 9 | 10 | EXPOSE 3128/tcp 11 | CMD "/sbin/entrypoint.sh" 12 | -------------------------------------------------------------------------------- /squid/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -e /var/run/squid.pid ];then 4 | #echo "DEBUG: Removed old squid PID" 5 | rm /var/run/squid.pid 6 | fi 7 | 8 | # Create cache FS 9 | if [ ! -e /var/spool/squid/00 ];then 10 | squid -z || exit $? 11 | fi 12 | /usr/sbin/squid -NYC -f /etc/squid/squid.conf || exit $? 13 | -------------------------------------------------------------------------------- /standalone-slave.yaml.example: -------------------------------------------------------------------------------- 1 | slaves: 2 | - name: lab-extern-1 3 | host: externpc 4 | dispatcher_ip: 192.168.66.1 5 | remote_master: lava.example.com 6 | remote_user: lab-extern 7 | remote_user_token: lab-extern-randomtoken 8 | 9 | boards: 10 | - name: qemu-01 11 | type: qemu 12 | slave: lab-extern-1 13 | kvm: True 14 | --------------------------------------------------------------------------------