client.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python
  2. # Copyright 2015 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import argparse
  16. import requests
  17. import socket
  18. from urlparse import urlparse
  19. def CheckServiceAddress(address):
  20. hostname = urlparse(address).hostname
  21. service_address = socket.gethostbyname(hostname)
  22. print service_address
  23. def GetServerResponse(address):
  24. print 'Send request to:', address
  25. response = requests.get(address)
  26. print response
  27. print response.content
  28. def Main():
  29. parser = argparse.ArgumentParser()
  30. parser.add_argument('address')
  31. args = parser.parse_args()
  32. CheckServiceAddress(args.address)
  33. GetServerResponse(args.address)
  34. if __name__ == "__main__":
  35. Main()