Skip to content

Commit

Permalink
add dry_run_desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandredevely committed Oct 11, 2023
1 parent d4778c0 commit 7326528
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions oc/od/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@ def build_volumes_home( self, authinfo:AuthInfo, userinfo:AuthUser, volume_type:
'mountPath':user_homedirectory
}


self.logger.debug( f"volumes_mount['home']: {volumes_mount.get('home')}" )
self.logger.debug( f"volumes['home']: {volumes.get('home')}")
self.logger.debug( f"volumes_mount['cache']: {volumes_mount.get('cache')}" )
Expand Down Expand Up @@ -1275,6 +1276,7 @@ def get_volumes_localaccount_name( self, authinfo:AuthInfo, userinfo:AuthUser )-
self.logger.debug('')
assert isinstance(authinfo, AuthInfo), f"authinfo has invalid type {type(authinfo)}"
assert isinstance(userinfo, AuthUser), f"userinfo has invalid type {type(userinfo)}"

localaccount_name = None
mysecretdict = self.list_dict_secret_data( authinfo, userinfo, access_type='localaccount' )
if isinstance(mysecretdict, dict ) and len(mysecretdict)>0:
Expand Down Expand Up @@ -1380,11 +1382,6 @@ def build_volumes( self, authinfo:AuthInfo, userinfo:AuthUser, volume_type, secr
volumes.update( localaccount_volumes )
volumes_mount.update( localaccount_volumes_mount )


if kwargs.get('dry_run') == 'All':
# do not add volume secrets or external resources
return (volumes, volumes_mount)

#
# mount vnc secret in /var/secrets/abcdesktop
# always add vnc secret for 'pod_desktop'
Expand Down Expand Up @@ -2889,11 +2886,10 @@ def create_vnc_secret( self, authinfo:AuthInfo, userinfo:AuthUser, kwargs:dict )
"""
self.logger.debug('vnc kubernetes secret checking')
plaintext_vnc_password = ODVncPassword().getplain()
if kwargs.get('dry_run') != 'All':
vnc_secret = oc.od.secret.ODSecretVNC( self.namespace, self.kubeapi )
vnc_secret_password = vnc_secret.create( authinfo=authinfo, userinfo=userinfo, data={ 'password' : plaintext_vnc_password } )
if not isinstance( vnc_secret_password, V1Secret ):
raise ODAPIError( f"create vnc kubernetes secret {plaintext_vnc_password} failed" )
vnc_secret = oc.od.secret.ODSecretVNC( self.namespace, self.kubeapi )
vnc_secret_password = vnc_secret.create( authinfo=authinfo, userinfo=userinfo, data={ 'password' : plaintext_vnc_password } )
if not isinstance( vnc_secret_password, V1Secret ):
raise ODAPIError( f"create vnc kubernetes secret {plaintext_vnc_password} failed" )
self.logger.debug(f"vnc kubernetes secret set to {plaintext_vnc_password}")

def createdesktop(self, authinfo:AuthInfo, userinfo:AuthUser, **kwargs)-> ODDesktop :
Expand All @@ -2915,7 +2911,8 @@ def createdesktop(self, authinfo:AuthInfo, userinfo:AuthUser, **kwargs)-> ODDesk
assert isinstance(userinfo, AuthUser), f"userinfo has invalid type {type(userinfo)}"

myDesktop = None # default return object
env = kwargs.get('env', {} )
env = kwargs.get('env', {} )
dry_run = kwargs.get('dry_run')

# get the execute class if user has a executeclassname tag
executeclasse = self.get_executeclasse( authinfo, userinfo )
Expand Down Expand Up @@ -3164,23 +3161,29 @@ def createdesktop(self, authinfo:AuthInfo, userinfo:AuthUser, **kwargs)-> ODDesk
pod_manifest['spec']['containers'].append( graphical_container )
self.logger.debug(f"pod container created {currentcontainertype}" )


localaccount_volume_name = self.get_volumes_localaccount_name( authinfo=authinfo, userinfo=userinfo)
containers = {

localaccount_volume_name = self.get_volumes_localaccount_name( authinfo=authinfo, userinfo=userinfo )
assert isinstance(localaccount_volume_name, str), f"localaccount_volume_name has invalid type {type(localaccount_volume_name)}"
containers = {
# printer uses tmp volume
'printer': { 'list_volumeMounts': [ pod_allvolumeMounts['tmp'] ] },
'printer': { 'list_volumeMounts': [ pod_allvolumeMounts.get('tmp') ] },
# sound uses tmp, home, log volumes
'sound': { 'list_volumeMounts': [ pod_allvolumeMounts[localaccount_volume_name], pod_allvolumeMounts['tmp'], pod_allvolumeMounts['home'], pod_allvolumeMounts['log'] ] },
'sound': { 'list_volumeMounts': [ pod_allvolumeMounts.get(localaccount_volume_name),
pod_allvolumeMounts.get('tmp'),
pod_allvolumeMounts.get('home'),
pod_allvolumeMounts.get('log') ] },
# ssh uses default user volumes
'ssh': { 'list_volumeMounts': list_volumeMounts },
# filter uses default user volumes
'filer': { 'list_volumeMounts': list_volumeMounts },
# storage uses default user volumes
'storage': { 'list_volumeMounts': list_pod_allvolumeMounts },
# rdp uses default user volumes
'rdp': { 'list_volumeMounts': [ pod_allvolumeMounts['x11socket']] } ,
'rdp': { 'list_volumeMounts': [ pod_allvolumeMounts.get('x11socket') ] } ,
# x11overlay uses default user volumes
'x11overlay' : { 'list_volumeMounts': [ pod_allvolumeMounts[localaccount_volume_name], pod_allvolumeMounts['x11socket']] }
'x11overlay' : { 'list_volumeMounts': [
pod_allvolumeMounts.get(localaccount_volume_name),
pod_allvolumeMounts.get('x11socket') ] }
}

for currentcontainertype in containers.keys():
Expand All @@ -3201,7 +3204,6 @@ def createdesktop(self, authinfo:AuthInfo, userinfo:AuthUser, **kwargs)-> ODDesk
self.on_desktoplaunchprogress('b.Creating your desktop')
jsonpod_manifest = json.dumps( pod_manifest, indent=2 )
self.logger.info( 'dump yaml %s', jsonpod_manifest )
dry_run = kwargs.get('dry_run')

pod = None
try:
Expand Down

0 comments on commit 7326528

Please sign in to comment.