p4_pd_status_t p4_pd_mc_node_create(p4_pd_sess_hdl_t session, int device, mgrp_rid_t rid, const uint8_t *port_map, const uint8_t *lag_map, p4_pd_entry_hdl_t *node_hdl) { (void) session; std::string port_map_ = convert_map(port_map, PRE_PORTS_MAX); std::string lag_map_ = convert_map(lag_map, PRE_LAG_MAX); *node_hdl = pd_conn_mgr_mc_client(conn_mgr_state, device)->bm_mc_node_create( 0, rid, port_map_, lag_map_); return 0; // TODO }
// Convert a QVariant to a Python object with an optional specific type. PyObject *qpycore_qvariant_value(QVariant &value, PyObject *type) { PyObject *value_obj; if (type) { const Chimera *ct = Chimera::parse(type); if (!ct) return 0; // Get QVariant to do a conversion if there is one to do. if (ct->metatype() < static_cast<int>(QVariant::UserType)) { QVariant::Type wanted = static_cast<QVariant::Type>(ct->metatype()); // If we have a QStringList but are not wanting one then convert it // to a QVariantList. if (wanted != QVariant::StringList && value.type() == QVariant::StringList) value.convert(QVariant::List); // If we have a container but are not wanting one then assume we // want a container with elements of the wanted type. if (wanted != QVariant::List && value.type() == QVariant::List) value_obj = convert_list(ct, value.toList()); else if (wanted != QVariant::Map && value.type() == QVariant::Map) value_obj = convert_map(ct, value.toMap()); #if QT_VERSION >= 0x040500 else if (wanted != QVariant::Hash && value.type() == QVariant::Hash) value_obj = convert_hash(ct, value.toHash()); #endif else value_obj = convert(ct, value); } else if (!value.isValid() && ct->py_type()) { // Convert an invalid value to the default value of the requested // type. This is most useful when the requested type is a list or // dict. value_obj = PyObject_CallObject(ct->py_type(), NULL); } else { // This is likely to fail and the exception will say why. value_obj = ct->toPyObject(value); } delete ct; } else { QVariant *heap = new QVariant(value); value_obj = sipConvertFromNewType(heap, sipType_QVariant, 0); if (!value_obj) delete heap; } return value_obj; }
p4_pd_status_t p4_pd_mc_set_lag_membership(p4_pd_sess_hdl_t session, int device, mgrp_lag_id_t lag_id, const uint8_t *port_map) { (void) session; std::string port_map_ = convert_map(port_map, PRE_PORTS_MAX); pd_conn_mgr_mc_client(conn_mgr_state, device)->bm_mc_set_lag_membership( 0, lag_id, port_map_); return 0; // TODO }