import json
models=[{'name':'free','root_control':False,'ops_required':False},{'name':'shared','root_control':False,'ops_required':False},{'name':'cloud-vm','root_control':True,'ops_required':True},{'name':'dedicated','root_control':True,'ops_required':True},{'name':'colocation','root_control':True,'ops_required':True,'own_hardware':True}]
def assess(model,needs_root,has_ops):
reasons=[]
if needs_root and not model['root_control']:reasons.append('root control absent')
if model['ops_required'] and not has_ops:reasons.append('operations capability missing')
return {'type':model['name'],'ready_for_fixture':not reasons,'reasons':reasons}
without=[assess(m,True,False) for m in models];assert not any(r['ready_for_fixture'] for r in without)
with_ops=[assess(m,True,True) for m in models];assert [r['type'] for r in with_ops if r['ready_for_fixture']]==['cloud-vm','dedicated','colocation']
print(json.dumps({'without_ops':without,'with_ops':with_ops,'model_only_not_real_provider_claim':True},ensure_ascii=False))
本例需在 本地Python3.12/SQLite;PHP8.4.27 -n;回环HTTP 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:本地Python3.12/SQLite;PHP8.4.27 -n;回环HTTP
入口文件:projects/hosting-lab/hosting_types.py
预期结果与验证条件观察提示
- 需root但无运维时无就绪候选,有运维时模型筛选正确
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联11章) · 含当前章节或实例 · mbskycom202611a516.zip