import paramiko

host = '8.140.221.49'
username = 'root'
private_key_path = r'C:\Users\FZX\.ssh\FzxBdsh-ECS.pem'

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(host, username=username, key_filename=private_key_path, timeout=30)

print('='*80)
print('查找Dockerfile')
print('='*80)

# 1. 查找所有Dockerfile
print('\n1. 查找所有Dockerfile...')
cmd = 'find /opt/Fzxpodman -name "Dockerfile" -type f'
stdin, stdout, stderr = ssh.exec_command(cmd)
result = stdout.read().decode()
print(f'找到的Dockerfile:\n{result}')

# 2. 检查是否有api-gateway相关的Dockerfile
print('\n2. 查找api-gateway相关的Dockerfile...')
cmd = 'find /opt/Fzxpodman -name "*api-gateway*" -type f'
stdin, stdout, stderr = ssh.exec_command(cmd)
result = stdout.read().decode()
print(f'api-gateway相关文件:\n{result}')

# 3. 检查docker目录结构
print('\n3. 检查docker目录...')
cmd = 'ls -la /opt/Fzxpodman/infrastructure/docker/'
stdin, stdout, stderr = ssh.exec_command(cmd)
result = stdout.read().decode()
print(f'docker目录内容:\n{result}')

# 4. 检查现有的Dockerfile内容
print('\n4. 检查现有Dockerfile内容...')
cmd = 'find /opt/Fzxpodman -name "Dockerfile" -exec echo "=== {} ===" \\; -exec cat {} \\;'
stdin, stdout, stderr = ssh.exec_command(cmd)
result = stdout.read().decode()
print(f'Dockerfile内容:\n{result}')

ssh.close()

print('\n' + '='*80)
print('检查完成!')
print('='*80)