Skip to content

Commit 5214e2e

Browse files
authored
🐛If the uuid of a VM is null, do not interrupt the process of getting VM list. (#41)
* 🐛If the uuid of a VM is null, do not interrupt the process of getting VM list. * ✨Add github action to deploy the vcenter module.
1 parent a77a590 commit 5214e2e

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

.github/workflows/build-vcenter.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: '编译并推送vcenter模块镜像'
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
12+
- name: Setup java
13+
uses: actions/setup-java@v3
14+
with:
15+
distribution: 'temurin'
16+
java-version: 8
17+
18+
- name: Build
19+
run: ./gradlew clean :vcenter:build -x test --no-daemon
20+
21+
- name: Build and Push Docker Image
22+
env:
23+
image: ${{ secrets.ALIYUN_DOCKER_NAMESPACE }}/vcenter
24+
tags: ${{ github.sha }}
25+
registry: ${{ secrets.ALIYUN_DOCKER_REGISTRY }}
26+
username: ${{ secrets.ALIYUN_DOCKER_USERNAME }}
27+
password: ${{ secrets.ALIYUN_DOCKER_PASSWORD }}
28+
run: |
29+
cd vcenter
30+
docker login ${registry} -u ${username} -p ${password}
31+
docker build -t ${image}:${tags} .
32+
docker push ${image}:${tags}

vcenter/src/main/kotlin/cn/edu/buaa/scs/vcenter/VCenterWrapper.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@ object VCenterWrapper {
184184
RetrieveOptions()
185185
)
186186
vmList?.forEach { (_, vmProps) ->
187-
val vm = convertVMModel(hostName, vmProps)
188-
finalVirtualMachineList.add(vm)
187+
try {
188+
val vm = convertVMModel(hostName, vmProps)
189+
finalVirtualMachineList.add(vm)
190+
} catch (e: NullPointerException) {
191+
logger.error { e }
192+
}
189193
}
190194
} catch (e: Throwable) {
191195
logger.error { e.stackTraceToString() }

0 commit comments

Comments
 (0)