@@ -638,9 +638,6 @@ def is_instance_app( self, appinstance ):
638
638
def execwaitincontainer ( self , desktop , command , timeout = 1000 ):
639
639
raise NotImplementedError (f"{ type (self )} .removedesktop" )
640
640
641
- def getappinstance ( self , authinfo , userinfo , app ):
642
- raise NotImplementedError (f"{ type (self )} .getappinstance" )
643
-
644
641
def get_auth_env_dict ( self , authinfo , userinfo ):
645
642
return {}
646
643
@@ -2423,6 +2420,21 @@ def countRunningAppforUser( self, authinfo:AuthInfo, userinfo:AuthUser, myDeskto
2423
2420
count += len ( myappinstance .list (authinfo , userinfo , myDesktop ) )
2424
2421
return count
2425
2422
2423
+
2424
+ def list_application_by_type_of_application ( self , authinfo :AuthInfo , userinfo :AuthUser , myDesktop :ODDesktop , application_type :str , apps :ODApps = None ):
2425
+ assert isinstance (authinfo , AuthInfo ), f"authinfo has invalid type { type (authinfo )} "
2426
+ assert isinstance (userinfo , AuthUser ), f"userinfo has invalid type { type (userinfo )} "
2427
+ assert isinstance (myDesktop , ODDesktop ), f"myDesktop has invalid type { type (myDesktop )} "
2428
+ self .logger .debug ('' )
2429
+ list_apps = []
2430
+ if application_type == self .pod_application :
2431
+ myappinstance = ODAppInstanceKubernetesPod ( self )
2432
+ list_apps += myappinstance .list (authinfo , userinfo , myDesktop , phase_filter = self .all_phases_status , apps = apps )
2433
+ if application_type == self .ephemeral_container :
2434
+ myappinstance = ODAppInstanceKubernetesEphemeralContainer ( self )
2435
+ list_apps += myappinstance .list (authinfo , userinfo , myDesktop , phase_filter = self .all_phases_status , apps = apps )
2436
+ return list_apps
2437
+
2426
2438
def listContainerApps ( self , authinfo :AuthInfo , userinfo :AuthUser , myDesktop :ODDesktop , apps :ODApps = None ):
2427
2439
"""listContainerApps
2428
2440
@@ -2491,40 +2503,41 @@ def getAppInstanceKubernetes( self, authinfo:AuthInfo, userinfo:AuthUser, pod_na
2491
2503
2492
2504
return myappinstance
2493
2505
2494
- def logContainerApp ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , containerid :str ):
2506
+ def logContainerApp ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , app_name :str ):
2495
2507
assert isinstance (pod_name , str ), f"podname has invalid type { type (pod_name )} "
2496
2508
log_app = None
2497
- myappinstance = self .getAppInstanceKubernetes (authinfo , userinfo , pod_name , containerid )
2509
+ myappinstance = self .getAppInstanceKubernetes (authinfo , userinfo , pod_name , app_name )
2498
2510
if isinstance ( myappinstance , ODAppInstanceBase ):
2499
- log_app = myappinstance .logContainerApp (pod_name , containerid )
2511
+ log_app = myappinstance .logContainerApp (pod_name , app_name )
2500
2512
return log_app
2501
2513
2502
- def envContainerApp ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , containerid :str ):
2514
+ def envContainerApp ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , app_name :str ):
2503
2515
assert isinstance (pod_name , str ), f"podname has invalid type { type (pod_name )} "
2504
2516
env_result = None
2505
- myappinstance = self .getAppInstanceKubernetes (authinfo , userinfo , pod_name , containerid )
2517
+ myappinstance = self .getAppInstanceKubernetes (authinfo , userinfo , pod_name , app_name )
2506
2518
if isinstance ( myappinstance , ODAppInstanceBase ):
2507
- env_result = myappinstance .envContainerApp (authinfo , userinfo , pod_name , containerid )
2519
+ env_result = myappinstance .envContainerApp (authinfo , userinfo , pod_name , app_name )
2508
2520
return env_result
2509
2521
2510
- def stopContainerApp ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , containerid :str )-> bool :
2522
+ def stopContainerApp ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , app_name :str )-> bool :
2511
2523
assert isinstance (pod_name , str ), f"podname has invalid type { type (pod_name )} "
2512
2524
stop_result = None
2513
- myappinstance = self .getAppInstanceKubernetes (authinfo , userinfo , pod_name , containerid )
2525
+ myappinstance = self .getAppInstanceKubernetes (authinfo , userinfo , pod_name , app_name )
2514
2526
if isinstance ( myappinstance , ODAppInstanceBase ):
2515
- stop_result = myappinstance .stop (pod_name , containerid )
2527
+ stop_result = myappinstance .stop (pod_name , app_name )
2516
2528
return stop_result
2517
2529
2518
- def removeContainerApp ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , containerid :str ):
2519
- return self .stopContainerApp ( authinfo , userinfo , pod_name , containerid )
2530
+ def describe_application ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , app_name :str )-> dict :
2531
+ assert isinstance (pod_name , str ), f"podname has invalid type { type (pod_name )} "
2532
+ assert isinstance (app_name , str ), f"app_name has invalid type { type (app_name )} "
2533
+ app_description = None
2534
+ myappinstance = self .getAppInstanceKubernetes (authinfo , userinfo , pod_name , app_name )
2535
+ if isinstance ( myappinstance , ODAppInstanceBase ):
2536
+ app_description = myappinstance .describe (pod_name , app_name )
2537
+ return app_description
2520
2538
2521
- def getappinstance ( self , authinfo , userinfo , app ):
2522
- self .logger .debug ('' )
2523
- for app_class in self .appinstance_classes .values ():
2524
- app_object = app_class ( orchestrator = self )
2525
- appinstance = app_object .findRunningAppInstanceforUserandImage ( authinfo , userinfo , app )
2526
- if app_object .isinstance ( appinstance ):
2527
- return appinstance
2539
+ def removeContainerApp ( self , authinfo :AuthInfo , userinfo :AuthUser , pod_name :str , app_name :str )-> bool :
2540
+ return self .stopContainerApp ( authinfo , userinfo , pod_name , app_name )
2528
2541
2529
2542
"""
2530
2543
def read_configmap( self, name, entry ):
@@ -4452,8 +4465,11 @@ def find_userinfo_authinfo_desktop_by_desktop_name( self, name:str )->tuple:
4452
4465
# not found
4453
4466
pass
4454
4467
return (authinfo ,userinfo ,myDesktop )
4455
-
4468
+
4456
4469
def describe_desktop_byname ( self , name :str )-> dict :
4470
+ return self .describe_pod_byname ( name )
4471
+
4472
+ def describe_pod_byname ( self , name :str )-> dict :
4457
4473
"""describe_desktop_byname
4458
4474
4459
4475
Args:
@@ -5491,6 +5507,18 @@ def create(self, myDesktop:ODDesktop, app, authinfo:AuthInfo, userinfo:AuthUser=
5491
5507
return appinstancestatus
5492
5508
"""
5493
5509
5510
+ def describe ( self , pod_name :str , app_name :str ):
5511
+ description = None
5512
+ pod = self .orchestrator .kubeapi .read_namespaced_pod (namespace = self .orchestrator .namespace ,name = pod_name )
5513
+ if isinstance ( pod , V1Pod ) and \
5514
+ isinstance ( pod .spec , V1PodSpec ) and \
5515
+ isinstance ( pod .spec .ephemeral_containers , list ):
5516
+ for c in pod .spec .ephemeral_containers :
5517
+ if isinstance ( c , V1EphemeralContainer ) :
5518
+ if c .name == app_name :
5519
+ description = c .to_dict ()
5520
+ break
5521
+ return description
5494
5522
5495
5523
def findRunningAppInstanceforUserandImage ( self , authinfo :AuthInfo , userinfo :AuthUser , app ):
5496
5524
self .logger .debug ('' )
@@ -5561,6 +5589,9 @@ def get_nodeSelector( self ):
5561
5589
nodeSelector = oc .od .settings .desktop_pod .get (self .type , {}).get ('nodeSelector' ,{})
5562
5590
return nodeSelector
5563
5591
5592
+ def describe ( self , pod_name :str , app_name :str ):
5593
+ return self .orchestrator .describe_pod_byname ( app_name )
5594
+
5564
5595
def get_appnodeSelector ( self , authinfo :AuthInfo , userinfo :AuthUser , app :dict ):
5565
5596
"""get_appnodeSelector
5566
5597
get the node selector merged data from
0 commit comments