mirror of
				https://github.com/vdsm/virtual-dsm.git
				synced 2025-11-04 08:54:51 +08:00 
			
		
		
		
	Retrieve IP from VM
This commit is contained in:
		
							parent
							
								
									d6d0e7f029
								
							
						
					
					
						commit
						bba243ce9d
					
				
							
								
								
									
										39
									
								
								run/check.sh
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								run/check.sh
									
									
									
									
									
								
							@ -1,18 +1,39 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
set -u
 | 
					set -u
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Docker Healthcheck
 | 
					# Retrieve guest info for Docker healthcheck
 | 
				
			||||||
 | 
					RESPONSE=$(curl -s -m 5 -S http://127.0.0.1:2210/read?command=10 2>&1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: ${DHCP:='N'}
 | 
					if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then
 | 
				
			||||||
 | 
					  echo "Failed to connect to guest: $RESPONSE"
 | 
				
			||||||
if [[ "${DHCP}" == [Yy1]* ]]; then
 | 
					  exit 1
 | 
				
			||||||
  PORT=5555
 | 
					 | 
				
			||||||
  IP="127.0.0.1"
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
  PORT=5000
 | 
					 | 
				
			||||||
  IP="20.20.20.21"
 | 
					 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Retrieve the HTTP port number
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ ! "${RESPONSE}" =~ "\"http_port\"" ]] ; then
 | 
				
			||||||
 | 
					  echo "Failed to parse response from guest: $RESPONSE"
 | 
				
			||||||
 | 
					  exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rest=${RESPONSE#*http_port}
 | 
				
			||||||
 | 
					rest=${rest#*:}
 | 
				
			||||||
 | 
					rest=${rest%%,*}
 | 
				
			||||||
 | 
					PORT=${rest%%\"*}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Retrieve the IP address
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ ! "${RESPONSE}" =~ "eth0" ]] ; then
 | 
				
			||||||
 | 
					  echo "Failed to parse response from guest: $RESPONSE"
 | 
				
			||||||
 | 
					  exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					rest=${RESPONSE#*eth0}
 | 
				
			||||||
 | 
					rest=${rest#*ip}
 | 
				
			||||||
 | 
					rest=${rest#*:}
 | 
				
			||||||
 | 
					rest=${rest#*\"}
 | 
				
			||||||
 | 
					IP=${rest%%\"*}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then
 | 
					if ! curl -m 3 -ILfSs "http://${IP}:${PORT}/" > /dev/null; then
 | 
				
			||||||
  echo "Failed to reach ${IP}:${PORT}"
 | 
					  echo "Failed to reach ${IP}:${PORT}"
 | 
				
			||||||
  exit 1
 | 
					  exit 1
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user