openstack-api-manage/glance/glance_main.py

60 lines
2.4 KiB
Python
Raw Permalink Normal View History

2024-06-17 20:20:39 +08:00
from glance import image
2024-06-20 20:03:52 +08:00
from keystone import get_token
def glance_main():
2024-06-17 20:20:39 +08:00
print("====================")
print("选择一个操作:")
print("====================")
print("Glance操作")
print("1. 镜像管理")
print("====================")
choice = input("输入选项 (1-3): ")
ip = "172.30.26.171"
2024-06-20 20:03:52 +08:00
token = get_token.get_token(ip,'demo','admin','admin','000000')
if choice == '1':
print("====================")
print("镜像管理")
print("====================")
print("1. 创建镜像")
print("2. 列出镜像")
print("3. 获取镜像")
print("4. 删除镜像")
print("5. 上传镜像文件")
print("6. 更新镜像")
print("====================")
choice = input("输入选项 (1-6): ")
if choice == '1':
image_name = input("输入镜像名称: ")
image_description = input("输入镜像描述: ")
disk_format = input("输入镜像格式: ")
container_format = input("输入镜像容器格式: ")
result=image.create_image(ip, token, image_name, image_description,disk_format, container_format)
print(result)
glance_main()
if choice == '2':
image.get_image(ip, token)
result=image.get_image(ip, token)
print(result)
glance_main()
if choice == '3':
image_name = input("输入镜像名称: ")
result=image.show_image(ip, token, image_name)
print(result)
glance_main()
if choice == '4':
image_name = input("输入镜像名称: ")
result=image.delete_image(ip, token, image_name)
print(result)
glance_main()
if choice == '5':
image_name = input("输入镜像名称: ")
image_path = input("输入镜像路径: ")
result=image.upload_iamge_file(ip,token,image_name,image_path)
print(result)
glance_main()
if choice == '6':
image_name = input("输入镜像名称: ")
new_image_name = input("输入新镜像名称: ")
new_image_description = input("输入新镜像描述: ")
result=image.update_image(ip, token, image_name, new_image_name, new_image_description)
print(result)
glance_main()