条件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接口开发测试实例的更多相关文章

  1. .NET微信扫码支付模式二API接口开发测试

    主要实现微信扫码支付,官网的SDKdemo 就不要使用 一直不能调试通过的,还是自己按照API接口文档一步一步来实现,吐槽下微信一点责任感都木有,能不能demo搞个正常的吗,不要坑惨了一大群码农们有点 ...

  2. .NET MVC结构框架下的微信扫码支付模式二 API接口开发测试

    直接上干货 ,我们的宗旨就是为人民服务.授人以鱼不如授人以渔.不吹毛求疵.不浮夸.不虚伪.不忽悠.一切都是为了社会共同进步,繁荣昌盛,小程序猿.大程序猿.老程序猿还是嫩程序猿,希望这个社会不要太急功近 ...

  3. API接口开发 配置、实现、测试

    Yii2 基于RESTful架构的 advanced版API接口开发 配置.实现.测试 环境配置: 开启服务器伪静态 本处以apache为例,查看apache的conf目录下httpd.conf,找到 ...

  4. 示例浅谈PHP与手机APP开发,即API接口开发

    示例浅谈PHP与手机APP开发,即API接口开发 API(Application Programming Interface,应用程序接口)架构,已经成为目前互联网产品开发中常见的软件架构模式,并且诞 ...

  5. 浅谈使用 PHP 进行手机 APP 开发(API 接口开发)

    做过 API 的人应该了解,其实开发 API 比开发 WEB 更简洁,但可能逻辑更复杂,因为 API 其实就是数据输出,不用呈现页面,所以也就不存在 MVC(API 只有 M 和 C),那么我们来探讨 ...

  6. 利用postman进行api接口开发

    场景: api接口开发时,经常使用一些工具来帮助设计开发.Yapi主要是在设计阶段进行api接口设计,统一前后端参数请求和返回体:swagger主要在开发阶段,用来显示实际上后端开发进度和接口情况:p ...

  7. 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  ...

  8. F5 api接口开发实战手册(二)

    F5 rest api 各对象使用方式详解 本篇文章介绍rest api接口下Collection.Resource.Subcollections.SubResource的各种使用方法.如果您不了解这 ...

  9. Yii2 基于RESTful架构的 advanced版API接口开发 配置、实现、测试 (转)

    环境配置: 开启服务器伪静态 本处以apache为例,查看apache的conf目录下httpd.conf,找到下面的代码 LoadModule rewrite_module modules/mod_ ...

随机推荐

  1. BestCoder Round#15 1002-Instruction

    http://acm.hdu.edu.cn/showproblem.php?pid=5083 官方题解——> 1002 Instruction 先考虑编码,首先找到operation对应的编码, ...

  2. CAS (Compare and Swap)

    synchronized是悲观锁 注意:实现了CAS的有原子类(AtomicInteger,AtomicLong,等等原子类) CAS 是乐观锁,一种高效实现线程安全性的方法 1.支持原子更新操作,适 ...

  3. Lazy Instantiator

    lazy instantiator (懒加载.延迟实例化.延迟初始化) 最开始看斯坦福的视频,对 延迟初始化 这个概念,不太理解 只见到,有些属性的初始化是在init做的,有些是在viewDidLoa ...

  4. nodejs 设置安装包路径的取消和安装cnpm

    安装cnpm: $ npm install -g cnpm --registry=https://registry.npm.taobao.org 配置nodejs的npm安装包路径: npm conf ...

  5. vue 使用element-ui实现城市三级联动

    <template> <div> <el-select v-model="prov" style="width:167px;margin-r ...

  6. Android目录结构

    |ABI-- 应用程序二进制接口(application binary interface,ABI) |-- Makefile |-- bionic               (bionic C库) ...

  7. awk中next以及getline用法示例

    在awk中,如果调用next,那么next之后的命令就都不执行了.此行文本的处理到此结束,开始读取下一条记录并操作. 实例如下: [plain] view plain copy zoer@ubuntu ...

  8. Java-确定被加载类的路径

    如何输出当前类在硬盘的物理路径 package com.tj; import java.net.URL; import java.security.CodeSource; import java.se ...

  9. MySQL MGR集群搭建

    本文来自网易云社区,转载务必请注明出处. 本文将从零开始搭建一个MySQL Group Replication集群,包含3个节点.简单介绍如何查询MGR集群状态信息.并介绍如何进行MGR节点上下线操作 ...

  10. C#Windows服务安装

    1,做好windows服务后,生成 一下,然后在项目目录中找到bin文件夹下的Debug文件夹,文件夹下有文件xxxx.exe 2,然后在C:\Windows\Microsoft.NET\Framew ...