Nebulapythonsdk是一个pythonic sdk,用于管理Nebula容器编排器
NebulaPythonSDK的Python项目详细描述
Nebula Python软件开发包
一个通过python管理nebula的sdk。
把星云的所有呼叫转换成更像Python的东西。
源代码位于github
如何使用
首先让Nebulapythondk进入您的机器
# Install from PyPi
pip install NebulaPythonSDK
现在在代码中使用它
# Load API wrapper from libraryfromNebulaPythonSDKimportNebula# Create API object.# port defaults to 80, protocol defaults to "http" & request_timeout defaults to 60 if any of them is not set.connection=Nebula(username="your_nebula_user",password="your_nebula_pass",host="nebula.example.com",port=80,protocol="http",request_timeout=60)# List appsapp_list=connection.list_apps()# List app infoapp_config=connection.list_app_info("app_name")# Create appapp_conf={"containers_per_cpu":8,"env_vars":{"test":"blabla","test3t2t32":"tesg4ehgee"},"docker_ulimits":[],"networks":["nebula"],"running":True,"rolling_restart":False,"volumes":["/tmp:/tmp/1","/var/tmp/:/var/tmp/1:ro"],"containers_per":{"cpu":6},"starting_ports":[{"81":80}],"docker_image":"httpd","privileged":False,"devices":[]}connection.create_app("app_name",app_conf)# create device groupdevice_group_config={"apps":["app_name"]}connection.create_device_group("device_group_name",device_group_config)# list device groupconnection.list_device_group("device_group_name")# list device group infoconnection.list_device_group_info("device_group_name")# ping apiconnection.check_api()# delete appconnection.delete_app("app_name")# stop appconnection.stop_app("app_name")# start appconnection.start_app("app_name")# restart appconnection.restart_app("app_name")# update appconnection.update_app("app_name",app_conf)# update app force all params - will reset all params to default values if not declared and raise an error for params # that are required but not given, similar to the POST update of the APIconnection.update_app("app_name",app_conf,force_all=True)# prune images on all device groupsconnection.prune_images()# delete device_groupconnection.delete_device_group("device_group_name")# prune images on a selected device groupsconnection.prune__device_group_images("device_group_name")# update device groupconnection.update_device_group("device_group_name",device_group_config)# list paginated reportsconnection.list_reports()# create a useruser_config={"password":"user_password","token":"user_token"}connection.create_user("user_name",user_config)# list user infoconnection.list_user("user_name")# list all usersconnection.list_users()# update a useruser_config={"password":"new_password","token":"new_token"}connection.update_user("user_name",user_config)# refresh a user tokenconnection.refresh_user_token("user_name")# delete a userconnection.delete_user("user_name")# create a user groupuser_group_config={"group_members":["user_name"],"pruning_allowed":True,"apps":{"app_name":"rw"},"device_groups":{"device_group_name":"ro"},"admin":False}connection.create_user_group("user_group_name",user_group_config)# list user group infoconnection.list_user_group("user_group_name")# list all users groupconnection.list_user_groups()# update a user groupuser_group_config={"admin":False}connection.update_user_group("user_group_name",user_group_config)# delete a user groupconnection.delete_user_group("user_group_name")# list all cron jobsconnection.list_cron_jobs()# delete a cron jobconnection.delete_cron_job("cron_job_name")# list a cron jobconnection.list_cron_job_info("cron_job_name")# create a cron jobcron_job_config={"env_vars":{"test":"test123"},"docker_image":"nginx","running":True,"volumes":[],"networks":["nebula","bridge"],"devices":[],"privileged":False,"schedule":"0 * * * *"}connection.create_cron_job("cron_job_name",cron_job_config)# update a cron jobcron_job_config={"schedule":"5 * * * *"}connection.update_cron_job("cron_job_name",cron_job_config)# update a cron job force all params - will reset all params to default values if not declared and raise an error for # params that are required but not given, similar to the POST update of the APIcron_job_config={"schedule":"5 * * * *","docker_image":"nginx"}connection.update_cron_job("cron_job_name",cron_job_config,force_all=True)