cobbler api接口开发测试实例
条件1:必须搭建好cobbler服务,并且可以通过web访问:http://cobbler_ip/cobbler_web 测试可以打开。然后再用以下命令测试。
#!/opt/python3/bin/python3
#Author: zhaoyong import xmlrpc.client,time if __name__ == '__main__':
time_str = time.time()
server = 'http://cobbler_ip/cobbler_api'
user = 'cobbler'
passwd = '账号密码' try:
remote_server = xmlrpc.client.Server(server)
tokin = remote_server.login(user, passwd)
except Exception as e:
exit('URL:%s no access' % server) # print(remote_server.ping()) # cobbler服务器状态监测
# print(remote_server.get_user_from_token(tokin)) # 返回cobbler系统登录账号
# print(remote_server.get_item('distro','Centos6.9-x86_64')) # 获取指定发布版本的信息
# print('-------------------------')
# print(remote_server.get_distro('Centos6.9-x86_64')) #返回distro指定名称的详细信息
# print('-------------------------')
# print(remote_server.get_profile('CT6.8_PHY_db_high')) # 返回profile 指定名称的详细信息
# print('-------------------------')
# print(remote_server.get_distros()) # 返回所有distro 的已有内容
# print('-------------------------')
# print(remote_server.get_profiles()) # 返回所有profiles的已有内容
# print('-------------------------')
# print(remote_server.find_system()) # 以列表返回所有的 system 名称
# print('-------------------------')
# print(remote_server.find_distro()) # 以列表返回所有的distro名称
# print('-------------------------')
# print(remote_server.find_profile()) # 以列表返回所有profile的名称
# print('-------------------------')
# print(remote_server.has_item('distro','Centos6.9-x86_64')) # 检测指定distro中指定的名称是否存在
# print('-------------------------')
# print(remote_server.get_distro_handle('Centos6.9-x86_64',tokin)) # 没啥用
# print(remote_server.remove_profile('test111',tokin)) # 删除指定的profile
# print('-------------------------')
# print(remote_server.remove_system('hostname121',tokin)) # 删除指定的system
# print('-------------------------')
# prof_id = remote_server.new_profile(tokin) # 创建一个新的profile 并保存
# print('profile new id:%s' % prof_id)
# print('-------------------------')
# remote_server.modify_profile(prof_id,'name','vm_test1',tokin) # 修改prof_id指定的profile 名称
# remote_server.modify_profile(prof_id,'distro','centos6.8-x86_64',tokin) # 也是修改prof_id的信息
# remote_server.modify_profile(prof_id,'kickstart','/var/lib/cobbler/kickstarts/txt111',tokin)
# remote_server.save_profile(prof_id,tokin) # 保存
# remote_server.sync(tokin) # 同步cobbler修改后的信息,这个做任何操作后,都要必须有
# print('-------------------------')
# print(remote_server.get_kickstart_templates()) # 获取所有KS模板文件路径
print('-------------------------')
print(remote_server.get_snippets()) # 获取所有snippets文件路径
# print('-------------------------')
# print(remote_server.is_kickstart_in_use('/var/lib/cobbler/kickstarts/CT6.8_PHY_db_middle.ks')) # 判断ks文件是否在使用
# print('-------------------------')
# print(remote_server.generate_kickstart('CT6.8_PHY_web_high')) # 打印profile对应的ks文件内存
# print('-------------------------')
# print(remote_server.generate_kickstart('vm_test1','t1'))# 打印profile对应的ks文件内存
# print('-------------------------')
# print(remote_server.generate_gpxe('vm_test1')) # 启动方面的,没用
# print('-------------------------')
# print(remote_server.generate_bootcfg('vm_test1'))
# print('-------------------------')
# print(remote_server.get_blended_data('vm_test1')) # 获取profile 的详细信息
# print('-------------------------')
# print(remote_server.get_settings()) # 没啥用
# print('-------------------------')
# print(remote_server.get_signatures()) # 不知道输出的是啥
# print('-------------------------')
# print(remote_server.get_valid_breeds()) # 获取的是各个操作系统的类型,
#输出: ['debian', 'freebsd', 'generic', 'nexenta', 'redhat', 'suse', 'ubuntu', 'unix', 'vmware', 'windows', 'xen']
# print('-------------------------')
# print(remote_server.get_valid_os_versions()) # 没啥用
# print('-------------------------')
# print(remote_server.get_repo_config_for_profile('vm_test1'))
# print('-------------------------')
# print(remote_server.get_repo_config_for_system('t1'))
# print('-------------------------')
# print(remote_server.version()) # 返回cobbler版本,没啥用
# print('-------------------------')
# print(remote_server.extended_version()) # 返回cobbler详细版本信息,没啥用
# print('-------------------------')
# print(remote_server.logout(tokin)) # 退出当前cobbler连接
# print('-------------------------')
# print(remote_server.token_check(tokin)) # 检测当前tokin状态,是否失效
# print('-------------------------')
# print(remote_server.sync_dhcp(tokin) # 同步DHCP
# print('-------------------------')
# print(remote_server.sync(tokin)) # 进行同步更新
# print('-------------------------')
# print(remote_server.read_or_write_kickstart_template('cobbler上ks文件路径','false为可写','将要替换ks文件的内容',tokin)) # 注意 替换KS字符串如果为-1,将删除此Ks文件,条件是此ks文件已不在引用
# print(remote_server.read_or_write_kickstart_template('/var/lib/cobbler/kickstarts/hostname106.ks',False,-1,tokin))
# print('-------------------------')
# print(remote_server.get_config_data('zhaoyong')) # 没啥用
# print('-------------------------')
# x = remote_server.test_xmlrpc_ro()
# print(x.distro)
# print(remote_server.read_or_write_snippet('/var/lib/cobbler/snippets/test1',False,'zhaoyong_test',tokin)) # 在snippgets下建立脚本文件
# distro_obj = cbl_distro.cobbler_distro(remote_server,tokin)
# # distro 查询
# out = distro_obj.find_distro_name()
# print(out)
# out = distro_obj.find_distro_info('Centos6.9-x86_64')
# print(out)
#
# profile_obj = cbl_profile.cobbler_profiles(remote_server,tokin)
# profile 查找
# pro_name_list = profile_obj.find_profile_name()
# print(out)
# out = profile_obj.find_profile_info('CT6.8_VM_web_custom')
# print(out)
#
# system_obj = cbl_system.cobbler_system(remote_server,tokin)
# # system 查询
# out_all = system_obj.find_system_name()
# print(out_all)
# out = system_obj.system_name_info('tttttt')
# print(out)
# del system
cobbler api接口开发测试实例的更多相关文章
- .NET微信扫码支付模式二API接口开发测试
主要实现微信扫码支付,官网的SDKdemo 就不要使用 一直不能调试通过的,还是自己按照API接口文档一步一步来实现,吐槽下微信一点责任感都木有,能不能demo搞个正常的吗,不要坑惨了一大群码农们有点 ...
- .NET MVC结构框架下的微信扫码支付模式二 API接口开发测试
直接上干货 ,我们的宗旨就是为人民服务.授人以鱼不如授人以渔.不吹毛求疵.不浮夸.不虚伪.不忽悠.一切都是为了社会共同进步,繁荣昌盛,小程序猿.大程序猿.老程序猿还是嫩程序猿,希望这个社会不要太急功近 ...
- API接口开发 配置、实现、测试
Yii2 基于RESTful架构的 advanced版API接口开发 配置.实现.测试 环境配置: 开启服务器伪静态 本处以apache为例,查看apache的conf目录下httpd.conf,找到 ...
- 示例浅谈PHP与手机APP开发,即API接口开发
示例浅谈PHP与手机APP开发,即API接口开发 API(Application Programming Interface,应用程序接口)架构,已经成为目前互联网产品开发中常见的软件架构模式,并且诞 ...
- 浅谈使用 PHP 进行手机 APP 开发(API 接口开发)
做过 API 的人应该了解,其实开发 API 比开发 WEB 更简洁,但可能逻辑更复杂,因为 API 其实就是数据输出,不用呈现页面,所以也就不存在 MVC(API 只有 M 和 C),那么我们来探讨 ...
- 利用postman进行api接口开发
场景: api接口开发时,经常使用一些工具来帮助设计开发.Yapi主要是在设计阶段进行api接口设计,统一前后端参数请求和返回体:swagger主要在开发阶段,用来显示实际上后端开发进度和接口情况:p ...
- json-lib-2.4-jdk15.jar所需全部JAR包.rar java jsoup解析开彩网api接口json数据实例
json-lib-2.4-jdk15.jar所需全部JAR包.rar java jsoup解析开彩网api接口json数据实例 json-lib-2.4-jdk15.jar所需全部JAR包.rar ...
- F5 api接口开发实战手册(二)
F5 rest api 各对象使用方式详解 本篇文章介绍rest api接口下Collection.Resource.Subcollections.SubResource的各种使用方法.如果您不了解这 ...
- Yii2 基于RESTful架构的 advanced版API接口开发 配置、实现、测试 (转)
环境配置: 开启服务器伪静态 本处以apache为例,查看apache的conf目录下httpd.conf,找到下面的代码 LoadModule rewrite_module modules/mod_ ...
随机推荐
- What is the difference between try/except and assert?
assert only check if a condition is true or not and throw an exception. A try/except block can run a ...
- Respond.js-----20150415
Respond.js让IE6-8支持CSS3 Media Query. Bootstrap里面就引入了这个js文件,从名字看出来是自适应的兼容.打开IE看了一下,效果挺好的,自适应的效果挺好的.Res ...
- LeetCode 数组中的第K个最大元素
在未排序的数组中找到第 k 个最大的元素.请注意,你需要找的是数组排序后的第 k 个最大的元素,而不是第 k 个不同的元素. 示例 1: 输入: [3,2,1,5,6,4] 和 k = 2 输出: 5 ...
- 删除mysql主从
在创建数据库主从配置后,若想删除数据库的主从服务可根据以下步骤来删除数据库主从 1.停止slave服务器的主从同步 为了防止主从数据不同步,需要先停止slave上的同步服务, STOP SLAVE ...
- PAT Basic 1023
1023 组个最小数 给定数字0-9各若干个.你可以以任意顺序排列这些数字,但必须全部使用.目标是使得最后得到的数尽可能小(注意0不能做首位).例如:给定两个0,两个1,三个5,一个8,我们得到的最小 ...
- Experiments done
喷重金属 换重金属溶液 荧光光合 备注 ASD 备注 高光谱 备注 泡EDTA 备注 电镜 备注 2018.12.19(day1) 2018.12.19(day1) 2018.12.18晚(day0) ...
- pycharm的一些操作指令和技巧
Alt+Enter 自动添加包Ctrl+t SVN更新Ctrl+k SVN提交Ctrl + / 注释(取消注释)选择的行Ctrl+Shift+F 高级查找Ctrl+Enter 补全Shift + En ...
- 详解Java类的生命周期
引言 最近有位细心的朋友在阅读笔者的文章时,对Java类的生命周期问题有一些疑惑,笔者打开百度搜了一下相关的问题,看到网上的资料很少有把这个问题讲明白的,主要是因为目前国内Java方面的教材大多只是告 ...
- SQL Server数据库和MySQL数据库有什么区别?
SQL Server数据库和MySQL数据库有什么区别呢?详细很多初入IT行业的朋友对于SQL Server数据库和MySQL数据库经常搞混,认为这两种数据库是同一种,其实不然,今天我们来分析一下这两 ...
- Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of
class Solution { public: ListNode *reverseKGroup(ListNode *head, int k) { if (!head || !(head->ne ...