@@ -117,17 +117,18 @@ def get_user_password_from_args(args):
117
117
return args .user , args .password
118
118
return get_user_password_from_file (args .file_for_user_password )
119
119
120
- def launch_node_commands ( node , api_server , args ):
120
+ def launch_chroot_commands ( child ):
121
121
"""
122
- This function launches commands in the node
122
+ This function launch chroot command
123
123
"""
124
- user , password = get_user_password_from_args (args )
125
- child = pexpect .spawnu ('oc debug nodes/' + node , timeout = NODE_CONNECTION_TIMEOUT )
126
- child .logfile_read = sys .stdout
127
- child .expect ('# ' )
128
124
send_pexpect_command (child , '\n ' , '#' )
129
125
send_pexpect_command (child , 'chroot /host' , '#' )
130
126
send_pexpect_command (child , '\n ' , '#' )
127
+
128
+ def launch_cluster_auth_commands (child , args , api_server ):
129
+ """
130
+ This function launch cluster authentication commands
131
+ """
131
132
if args .cluster_password :
132
133
send_pexpect_command (child , 'oc login -u kubeadmin -p ' + args .cluster_password +
133
134
' ' + api_server , ': ' )
@@ -139,6 +140,12 @@ def launch_node_commands(node, api_server, args):
139
140
send_pexpect_command (child , 'yes' , '#' )
140
141
else :
141
142
send_pexpect_command (child , '\n ' , '#' )
143
+
144
+ def launch_podman_commands (child , args ):
145
+ """
146
+ This function launch podman authentication commands
147
+ """
148
+ user , password = get_user_password_from_args (args )
142
149
send_pexpect_command (child , 'podman login -u kubeadmin -p $(oc whoami -t) ' +
143
150
LOCAL_REGISTRY , '#' )
144
151
send_pexpect_command (child , 'echo' , '#' )
@@ -151,11 +158,21 @@ def launch_node_commands(node, api_server, args):
151
158
send_pexpect_command (child , 'podman images | grep ' + LOCAL_REGISTRY , '#' )
152
159
send_pexpect_command (child , 'podman push ' + LOCAL_REGISTRY + '/' +
153
160
get_image_path (args .original_image ), '#' )
161
+
162
+ def launch_node_commands (node , api_server , args ):
163
+ """
164
+ This function launches commands in the node
165
+ """
166
+ child = pexpect .spawnu ('oc debug nodes/' + node , timeout = NODE_CONNECTION_TIMEOUT )
167
+ child .logfile_read = sys .stdout
168
+ child .expect ('# ' )
169
+ launch_chroot_commands (child )
170
+ launch_cluster_auth_commands (child , args , api_server )
171
+ launch_podman_commands (child , args )
154
172
send_pexpect_command (child , 'exit' , '#' )
155
173
sys .stdout .flush ()
156
174
child .close ()
157
175
158
-
159
176
def execute_command (cmd ):
160
177
"""
161
178
This function executes command and returs its result
0 commit comments