forked from RamenDR/ramen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CDI is used to populate PVCs with VM images. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: The RamenDR authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import os | ||
import sys | ||
|
||
import drenv | ||
from drenv import kubectl | ||
|
||
VERSION = "v1.57.0" | ||
BASE_URL = "https://github.com/kubevirt/containerized-data-importer/releases/download" | ||
NAMESPACE = "cdi" | ||
|
||
|
||
def deploy(cluster): | ||
print("Deploying cdi operator") | ||
kubectl.apply( | ||
f"--filename={BASE_URL}/{VERSION}/cdi-operator.yaml", | ||
context=cluster, | ||
) | ||
|
||
print("Waiting until cdi-operator is rolled out") | ||
kubectl.rollout( | ||
"status", | ||
"deploy/cdi-operator", | ||
f"--namespace={NAMESPACE}", | ||
context=cluster, | ||
) | ||
|
||
print("Deploying cdi cr") | ||
kubectl.apply( | ||
f"--filename={BASE_URL}/{VERSION}/cdi-cr.yaml", | ||
context=cluster, | ||
) | ||
|
||
|
||
def wait(cluster): | ||
print("Waiting until cdi cr reports phase") | ||
drenv.wait_for( | ||
"cdi.cdi.kubevirt.io/cdi", | ||
namespace=NAMESPACE, | ||
output="jsonpath={.status.phase}", | ||
timeout=60, | ||
profile=cluster, | ||
) | ||
|
||
print("Waiting until cdi cr phase is deployed") | ||
kubectl.wait( | ||
"cdi.cdi.kubevirt.io/cdi", | ||
"--for=jsonpath={.status.phase}=Deployed", | ||
f"--namespace={NAMESPACE}", | ||
"--timeout=300s", | ||
context=cluster, | ||
) | ||
|
||
|
||
if len(sys.argv) != 2: | ||
print(f"Usage: {sys.argv[0]} cluster") | ||
sys.exit(1) | ||
|
||
os.chdir(os.path.dirname(__file__)) | ||
cluster = sys.argv[1] | ||
|
||
deploy(cluster) | ||
wait(cluster) |