def quantum_agent_find(agentName): tbl = keystone_utils.table (osutils.run('quantum agent-list') ) print(tbl) r = keystone_utils.row(tbl, 'agent_type', agentName) if r != None: return keystone_utils.get(tbl, 'id', r) return None
def quantum_net_create(tenantId, netName, external=False): tbl = keystone_utils.table( osutils.run('quantum net-list') ) r = keystone_utils.row(tbl, 'name', netName) if r != None: return keystone_utils.get(tbl, 'id', r) cmd = 'quantum net-create --tenant-id %s %s' if external: cmd = cmd + ' --router:external=True' return quantum_id( osutils.run(cmd % (tenantId, netName)) )
def quantum_router_create(tenantId, routerName): tbl = keystone_utils.table (osutils.run('quantum router-list') ) r = keystone_utils.row(tbl, 'name', routerName) if r != None: return keystone_utils.get(tbl, 'id', r) return quantum_id( osutils.run('quantum router-create --tenant-id %s %s' % (tenantId, routerName) ))
def quantum_subnet_create(tenantId, netName, cidr, opts=''): tbl = keystone_utils.table (osutils.run('quantum subnet-list') ) r = keystone_utils.row(tbl, 'cidr', cidr) if r != None: return keystone_utils.get(tbl, 'id', r) return quantum_id( osutils.run('quantum subnet-create --tenant-id %s %s %s %s' % (tenantId, opts, netName, cidr)) )
def quantum_id(out): tbl = keystone_utils.table(out) return keystone_utils.get(tbl, 'Value', keystone_utils.row(tbl, 'Field', 'id'))