コード例 #1
0
ファイル: lxc_container.c プロジェクト: amery/libvirt-vserver
/**
 * lxcContainerRenameAndEnableInterfaces:
 * @nveths: number of interfaces
 * @veths: interface names
 *
 * This function will rename the interfaces to ethN
 * with id ascending order from zero and enable the
 * renamed interfaces for this container.
 *
 * Returns 0 on success or nonzero in case of error
 */
static int lxcContainerRenameAndEnableInterfaces(unsigned int nveths,
                                                 char **veths)
{
    int rc = 0;
    unsigned int i;
    char *newname = NULL;

    for (i = 0 ; i < nveths ; i++) {
        if (virAsprintf(&newname, "eth%d", i) < 0) {
            virReportOOMError();
            rc = -1;
            goto error_out;
        }

        DEBUG("Renaming %s to %s", veths[i], newname);
        rc = setInterfaceName(veths[i], newname);
        if (rc < 0)
            goto error_out;

        DEBUG("Enabling %s", newname);
        rc = vethInterfaceUpOrDown(newname, 1);
        if (rc < 0)
            goto error_out;

        VIR_FREE(newname);
    }

    /* enable lo device only if there were other net devices */
    if (veths)
        rc = vethInterfaceUpOrDown("lo", 1);

error_out:
    VIR_FREE(newname);
    return rc;
}
コード例 #2
0
ファイル: vlansetting.cpp プロジェクト: Bridges/libnm-qt5
void NetworkManager::VlanSetting::fromMap(const QVariantMap &setting)
{
    if (setting.contains(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME))) {
        setInterfaceName(setting.value(QLatin1String(NM_SETTING_VLAN_INTERFACE_NAME)).toString());
    }

    if (setting.contains(QLatin1String(NM_SETTING_VLAN_PARENT))) {
        setParent(setting.value(QLatin1String(NM_SETTING_VLAN_PARENT)).toString());
    }

    if (setting.contains(QLatin1String(NM_SETTING_VLAN_ID))) {
        setId(setting.value(QLatin1String(NM_SETTING_VLAN_ID)).toUInt());
    }

    if (setting.contains(QLatin1String(NM_SETTING_VLAN_FLAGS))) {
        setFlags((Flag)setting.value(QLatin1String(NM_SETTING_VLAN_FLAGS)).toUInt());
    }

    if (setting.contains(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP))) {
        setIngressPriorityMap(setting.value(QLatin1String(NM_SETTING_VLAN_INGRESS_PRIORITY_MAP)).toStringList());
    }

    if (setting.contains(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP))) {
        setEgressPriorityMap(setting.value(QLatin1String(NM_SETTING_VLAN_EGRESS_PRIORITY_MAP)).toStringList());
    }
}
コード例 #3
0
ファイル: vlansetting.cpp プロジェクト: Bridges/libnm-qt5
NetworkManager::VlanSetting::VlanSetting(const Ptr &other):
    Setting(other),
    d_ptr(new VlanSettingPrivate())
{
    setInterfaceName(other->interfaceName());
    setParent(other->parent());
    setId(other->id());
    setFlags(other->flags());
    setIngressPriorityMap(other->ingressPriorityMap());
    setEgressPriorityMap(other->egressPriorityMap());
}
コード例 #4
0
void NetworkManager::ConnectionSettings::fromMap(const NMVariantMapMap &map)
{
    QVariantMap connectionSettings = map.value(QLatin1String(NM_SETTING_CONNECTION_SETTING_NAME));

    setId(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_ID)).toString());
    setUuid(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_UUID)).toString());
    setConnectionType(typeFromString(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_TYPE)).toString()));

    if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_INTERFACE_NAME))) {
        setInterfaceName(connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_INTERFACE_NAME)).toString());
    }
    if (connectionSettings.contains(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS))) {
        QStringList permissions = connectionSettings.value(QLatin1String(NM_SETTING_CONNECTION_PERMISSIONS)).toStringList();
        Q_FOREACH (const QString & permission, permissions) {
            const QStringList split = permission.split(QLatin1String(":"), QString::KeepEmptyParts);
            addToPermissions(split.at(1), split.at(2));
        }
    }
コード例 #5
0
NetworkManager::ConnectionSettings::ConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &other)
    : d_ptr(new ConnectionSettingsPrivate(this))
{
    Q_D(ConnectionSettings);

    setId(other->id());
    setUuid(other->uuid());
    setInterfaceName(other->interfaceName());
    setConnectionType(other->connectionType());
    setPermissions(other->permissions());
    setAutoconnect(other->autoconnect());
    setAutoconnectPriority(other->autoconnectPriority());
    setTimestamp(other->timestamp());
    setReadOnly(other->readOnly());
    setZone(other->zone());
    setMaster(other->master());
    setSlaveType(other->slaveType());
    setGatewayPingTimeout(other->gatewayPingTimeout());
    d->initSettings(other);
}
コード例 #6
0
ファイル: xTEDSCommand.cpp プロジェクト: NKSG/vn-sdm
bool xTEDSCommand::SetCommand(const command* Command, const xTEDSVariableList& VariableList)
{
	if (Command == NULL || Command->command_message == NULL)
		return false;
	
	// Set the command attributes
	if (Command->interface_name != NULL) setInterfaceName (Command->interface_name);
	if (Command->interface_id != NULL) setInterfaceID (atoi(Command->interface_id));
	
	// Set the command message, required
	m_CommandMessage = new xTEDSCommandMsg();
	bool ReturnResult = m_CommandMessage->SetCommandMsg(Command->command_message, VariableList);
	if (ReturnResult == false)
 		return false;
	
	// Set the fault message, optional
	if (Command->fault_message != NULL)
	{
		m_FaultMessage = new xTEDSFaultMsg();
		ReturnResult = m_FaultMessage->SetFaultMsg(Command->fault_message, VariableList);
	}
	return ReturnResult;
}