+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-
-/**
- * @file
- * @author Mateusz Malicki (m.malicki2@samsung.com)
- * @brief HostIPCConnection class
- */
-
-#include <config.hpp>
-#include "host-ipc-connection.hpp"
-#include <api/messages.hpp>
-#include <host-ipc-definitions.hpp>
-
-namespace vasum {
-namespace client {
-
-namespace {
- const int TIMEOUT_INFINITE = -1;
-} //namespace
-
-void HostIPCConnection::connect(const std::string& address, ipc::epoll::EventPoll& eventPoll)
-{
- mClient.reset(new ipc::Client(eventPoll, address));
- mClient->start();
-}
-
-void HostIPCConnection::disconnect()
-{
- mClient.reset();
-}
-
-bool HostIPCConnection::isConnected()
-{
- return mClient && mClient->isStarted();
-}
-
-
-void HostIPCConnection::callGetZoneIds(api::ZoneIds& argOut)
-{
- argOut = *mClient->callSync<api::Void, api::ZoneIds>(
- api::ipc::METHOD_GET_ZONE_ID_LIST,
- std::make_shared<api::Void>());
-}
-
-void HostIPCConnection::callGetActiveZoneId(api::ZoneId& argOut)
-{
- argOut = *mClient->callSync<api::Void, api::ZoneId>(
- api::ipc::METHOD_GET_ACTIVE_ZONE_ID,
- std::make_shared<api::Void>());
-}
-
-void HostIPCConnection::callSetActiveZone(const api::ZoneId& argIn)
-{
- mClient->callSync<api::ZoneId, api::Void>(
- api::ipc::METHOD_SET_ACTIVE_ZONE,
- std::make_shared<api::ZoneId>(argIn));
-}
-
-void HostIPCConnection::callGetZoneInfo(const api::ZoneId& argIn, api::ZoneInfoOut& argOut)
-{
- argOut = *mClient->callSync<api::ZoneId, api::ZoneInfoOut>(
- api::ipc::METHOD_GET_ZONE_INFO,
- std::make_shared<api::ZoneId>(argIn));
-}
-
-void HostIPCConnection::callSetNetdevAttrs(const api::SetNetDevAttrsIn& argIn)
-{
- mClient->callSync<api::SetNetDevAttrsIn, api::Void>(
- api::ipc::METHOD_SET_NETDEV_ATTRS,
- std::make_shared<api::SetNetDevAttrsIn>(argIn));
-}
-
-void HostIPCConnection::callGetNetdevAttrs(const api::GetNetDevAttrsIn& argIn, api::GetNetDevAttrs& argOut)
-{
- argOut = *mClient->callSync<api::GetNetDevAttrsIn, api::GetNetDevAttrs>(
- api::ipc::METHOD_GET_NETDEV_ATTRS,
- std::make_shared<api::GetNetDevAttrsIn>(argIn));
-}
-
-void HostIPCConnection::callGetNetdevList(const api::ZoneId& argIn, api::NetDevList& argOut)
-{
- argOut = *mClient->callSync<api::ZoneId, api::NetDevList>(
- api::ipc::METHOD_GET_NETDEV_LIST,
- std::make_shared<api::ZoneId>(argIn));
-}
-
-void HostIPCConnection::callCreateNetdevVeth(const api::CreateNetDevVethIn& argIn)
-{
- mClient->callSync<api::CreateNetDevVethIn, api::Void>(
- api::ipc::METHOD_CREATE_NETDEV_VETH,
- std::make_shared<api::CreateNetDevVethIn>(argIn));
-}
-
-void HostIPCConnection::callCreateNetdevMacvlan(const api::CreateNetDevMacvlanIn& argIn)
-{
- mClient->callSync<api::CreateNetDevMacvlanIn, api::Void>(
- api::ipc::METHOD_CREATE_NETDEV_MACVLAN,
- std::make_shared<api::CreateNetDevMacvlanIn>(argIn));
-}
-
-void HostIPCConnection::callCreateNetdevPhys(const api::CreateNetDevPhysIn& argIn)
-{
- mClient->callSync<api::CreateNetDevPhysIn, api::Void>(
- api::ipc::METHOD_CREATE_NETDEV_PHYS,
- std::make_shared<api::CreateNetDevPhysIn>(argIn));
-}
-
-void HostIPCConnection::callDestroyNetdev(const api::DestroyNetDevIn& argIn)
-{
- mClient->callSync<api::DestroyNetDevIn, api::Void>(
- api::ipc::METHOD_DESTROY_NETDEV,
- std::make_shared<api::DestroyNetDevIn>(argIn));
-}
-
-void HostIPCConnection::callDeleteNetdevIpAddress(const api::DeleteNetdevIpAddressIn& argIn)
-{
- mClient->callSync<api::DeleteNetdevIpAddressIn, api::Void>(
- api::ipc::METHOD_DELETE_NETDEV_IP_ADDRESS,
- std::make_shared<api::DeleteNetdevIpAddressIn>(argIn));
-}
-
-void HostIPCConnection::callDeclareFile(const api::DeclareFileIn& argIn, api::Declaration& argOut)
-{
- argOut = *mClient->callSync<api::DeclareFileIn, api::Declaration>(
- api::ipc::METHOD_DECLARE_FILE,
- std::make_shared<api::DeclareFileIn>(argIn));
-}
-
-void HostIPCConnection::callDeclareMount(const api::DeclareMountIn& argIn, api::Declaration& argOut)
-{
- argOut = *mClient->callSync<api::DeclareMountIn, api::Declaration>(
- api::ipc::METHOD_DECLARE_MOUNT,
- std::make_shared<api::DeclareMountIn>(argIn));
-}
-
-void HostIPCConnection::callDeclareLink(const api::DeclareLinkIn& argIn, api::Declaration& argOut)
-{
- argOut = *mClient->callSync<api::DeclareLinkIn, api::Declaration>(
- api::ipc::METHOD_DECLARE_LINK,
- std::make_shared<api::DeclareLinkIn>(argIn));
-}
-
-void HostIPCConnection::callGetDeclarations(const api::ZoneId& argIn, api::Declarations& argOut)
-{
- argOut = *mClient->callSync<api::ZoneId, api::Declarations>(
- api::ipc::METHOD_GET_DECLARATIONS,
- std::make_shared<api::ZoneId>(argIn));
-}
-
-void HostIPCConnection::callRemoveDeclaration(const api::RemoveDeclarationIn& argIn)
-{
- mClient->callSync<api::RemoveDeclarationIn, api::Void>(
- api::ipc::METHOD_REMOVE_DECLARATION,
- std::make_shared<api::RemoveDeclarationIn>(argIn));
-}
-
-void HostIPCConnection::callCreateZone(const api::CreateZoneIn& argIn)
-{
- mClient->callSync<api::CreateZoneIn, api::Void>(
- api::ipc::METHOD_CREATE_ZONE,
- std::make_shared<api::CreateZoneIn>(argIn),
- TIMEOUT_INFINITE);
-}
-
-void HostIPCConnection::callDestroyZone(const api::ZoneId& argIn)
-{
- mClient->callSync<api::ZoneId, api::Void>(
- api::ipc::METHOD_DESTROY_ZONE,
- std::make_shared<api::ZoneId>(argIn),
- TIMEOUT_INFINITE);
-}
-
-void HostIPCConnection::callShutdownZone(const api::ZoneId& argIn)
-{
- mClient->callSync<api::ZoneId, api::Void>(
- api::ipc::METHOD_SHUTDOWN_ZONE,
- std::make_shared<api::ZoneId>(argIn),
- TIMEOUT_INFINITE);
-}
-
-void HostIPCConnection::callStartZone(const api::ZoneId& argIn)
-{
- mClient->callSync<api::ZoneId, api::Void>(
- api::ipc::METHOD_START_ZONE,
- std::make_shared<api::ZoneId>(argIn),
- TIMEOUT_INFINITE);
-}
-
-void HostIPCConnection::callLockZone(const api::ZoneId& argIn)
-{
- mClient->callSync<api::ZoneId, api::Void>(
- api::ipc::METHOD_LOCK_ZONE,
- std::make_shared<api::ZoneId>(argIn),
- TIMEOUT_INFINITE);
-}
-
-void HostIPCConnection::callUnlockZone(const api::ZoneId& argIn)
-{
- mClient->callSync<api::ZoneId, api::Void>(
- api::ipc::METHOD_UNLOCK_ZONE,
- std::make_shared<api::ZoneId>(argIn));
-}
-
-void HostIPCConnection::callGrantDevice(const api::GrantDeviceIn& argIn)
-{
- mClient->callSync<api::GrantDeviceIn, api::Void>(
- api::ipc::METHOD_GRANT_DEVICE,
- std::make_shared<api::GrantDeviceIn>(argIn));
-}
-
-void HostIPCConnection::callRevokeDevice(const api::RevokeDeviceIn& argIn)
-{
- mClient->callSync<api::RevokeDeviceIn, api::Void>(
- api::ipc::METHOD_REVOKE_DEVICE,
- std::make_shared<api::RevokeDeviceIn>(argIn));
-}
-
-void HostIPCConnection::callNotifyActiveZone(const api::NotifActiveZoneIn& argIn)
-{
- mClient->callSync<api::NotifActiveZoneIn, api::Void>(
- api::ipc::METHOD_NOTIFY_ACTIVE_ZONE,
- std::make_shared<api::NotifActiveZoneIn>(argIn));
-}
-
-void HostIPCConnection::callFileMoveRequest(const api::FileMoveRequestIn& argIn,
- api::FileMoveRequestStatus& argOut)
-{
- argOut = *mClient->callSync<api::FileMoveRequestIn, api::FileMoveRequestStatus>(
- api::ipc::METHOD_FILE_MOVE_REQUEST,
- std::make_shared<api::FileMoveRequestIn>(argIn));
-}
-
-void HostIPCConnection::signalSwitchToDefault()
-{
-
- mClient->signal(api::ipc::SIGNAL_SWITCH_TO_DEFAULT,
- std::make_shared<api::Void>());
-}
-
-HostIPCConnection::SubscriptionId
-HostIPCConnection::subscribeNotification(const NotificationCallback& callback)
-{
- auto callbackWrapper = [callback] (const ipc::PeerID,
- std::shared_ptr<api::Notification>& data) {
- callback(*data);
- };
- mClient->setSignalHandler<api::Notification>(api::ipc::SIGNAL_NOTIFICATION, callbackWrapper);
- return api::ipc::SIGNAL_NOTIFICATION;
-}
-
-void HostIPCConnection::unsubscribe(const SubscriptionId& id)
-{
- mClient->removeMethod(id);
-}
-
-} // namespace client
-} // namespace vasum
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Mateusz Malicki <m.malicki2@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-
-/**
- * @file
- * @author Mateusz Malicki (m.malicki2@samsung.com)
- * @brief HostIPCConnection class
- */
-
-#ifndef VASUM_CLIENT_HOST_IPC_CONNECTION_HPP
-#define VASUM_CLIENT_HOST_IPC_CONNECTION_HPP
-
-#include <api/messages.hpp>
-#include <ipc/client.hpp>
-#include <ipc/epoll/event-poll.hpp>
-
-#include <functional>
-
-namespace vasum {
-namespace client {
-
-/**
- * HostIPCConnection is used for communication with the vasum's server from host through ipc
- */
-class HostIPCConnection {
-public:
- typedef unsigned int SubscriptionId;
- typedef std::function<void(const vasum::api::Notification&)> NotificationCallback;
- void connect(const std::string& address, ipc::epoll::EventPoll& eventPoll);
- void disconnect();
- bool isConnected();
-
- void callGetZoneIds(vasum::api::ZoneIds& argOut);
- void callGetActiveZoneId(vasum::api::ZoneId& argOut);
- void callSetActiveZone(const vasum::api::ZoneId& argIn);
- void callGetZoneInfo(const vasum::api::ZoneId& argIn, vasum::api::ZoneInfoOut& argOut);
- void callSetNetdevAttrs(const vasum::api::SetNetDevAttrsIn& argIn);
- void callGetNetdevAttrs(const vasum::api::GetNetDevAttrsIn& argIn, vasum::api::GetNetDevAttrs& argOut);
- void callGetNetdevList(const vasum::api::ZoneId& argIn, vasum::api::NetDevList& argOut);
- void callCreateNetdevVeth(const vasum::api::CreateNetDevVethIn& argIn);
- void callCreateNetdevMacvlan(const vasum::api::CreateNetDevMacvlanIn& argIn);
- void callCreateNetdevPhys(const vasum::api::CreateNetDevPhysIn& argIn);
- void callDestroyNetdev(const vasum::api::DestroyNetDevIn& argIn);
- void callDeleteNetdevIpAddress(const vasum::api::DeleteNetdevIpAddressIn& argIn);
- void callDeclareFile(const vasum::api::DeclareFileIn& argIn, vasum::api::Declaration& argOut);
- void callDeclareMount(const vasum::api::DeclareMountIn& argIn, vasum::api::Declaration& argOut);
- void callDeclareLink(const vasum::api::DeclareLinkIn& argIn, vasum::api::Declaration& argOut);
- void callGetDeclarations(const vasum::api::ZoneId& argIn, vasum::api::Declarations& argOut);
- void callRemoveDeclaration(const vasum::api::RemoveDeclarationIn& argIn);
- void callCreateZone(const vasum::api::CreateZoneIn& argIn);
- void callDestroyZone(const vasum::api::ZoneId& argIn);
- void callShutdownZone(const vasum::api::ZoneId& argIn);
- void callStartZone(const vasum::api::ZoneId& argIn);
- void callLockZone(const vasum::api::ZoneId& argIn);
- void callUnlockZone(const vasum::api::ZoneId& argIn);
- void callGrantDevice(const vasum::api::GrantDeviceIn& argIn);
- void callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn);
- void callGetZoneConnections(vasum::api::Connections& argOut);
- void callNotifyActiveZone(const vasum::api::NotifActiveZoneIn& argIn);
- void callFileMoveRequest(const vasum::api::FileMoveRequestIn& argIn,
- vasum::api::FileMoveRequestStatus& argOut);
- void signalSwitchToDefault();
- SubscriptionId subscribeNotification(const NotificationCallback& callback);
- void unsubscribe(const SubscriptionId& id);
-
-private:
- std::unique_ptr<ipc::Client> mClient;
-};
-
-} // namespace client
-} // namespace vasum
-
-#endif /* VASUM_CLIENT_HOST_IPC_CONNECTION_HPP */
#include "utils.hpp"
#include "exception.hpp"
#include "utils/exception.hpp"
-#include "host-ipc-connection.hpp"
#include "logger/logger.hpp"
+#include <host-ipc-definitions.hpp>
+#include <ipc/client.hpp>
+#include <api/messages.hpp>
+
#include <algorithm>
#include <vector>
+#include <memory>
#include <cstring>
#include <fstream>
#include <arpa/inet.h>
namespace {
+const int TIMEOUT_INFINITE = -1;
+
VsmZoneState getZoneState(const char* state)
{
if (strcmp(state, "STOPPED") == 0) {
{
}
+bool Client::isConnected() const
+{
+ return mClient && mClient->isStarted();
+}
+
bool Client::isInternalDispatcherEnabled() const
{
return static_cast<bool>(mInternalDispatcher);
if (!mInternalDispatcher && !mEventPoll) {
vsm_set_dispatcher_type(VSMDISPATCHER_INTERNAL);
}
- mHostClient.connect(address, getEventPoll());
+ mClient.reset(new ipc::Client(getEventPoll(), address));
+ mClient->start();
});
}
VsmStatus Client::disconnect() noexcept
{
return coverException([&] {
- mHostClient.disconnect();
+ mClient.reset();
});
}
VsmStatus Client::vsm_set_dispatcher_type(VsmDispacherType dispacher) noexcept
{
return coverException([&] {
- if (mHostClient.isConnected()) {
+ if (isConnected()) {
throw OperationFailedException("Can't change dispacher");
}
switch (dispacher) {
return coverException([&] {
IS_SET(array);
- api::ZoneIds zoneIds;
- mHostClient.callGetZoneIds(zoneIds);
+ api::ZoneIds zoneIds = *mClient->callSync<api::Void, api::ZoneIds>(
+ vasum::api::ipc::METHOD_GET_ZONE_ID_LIST,
+ std::make_shared<api::Void>());
convert(zoneIds, *array);
});
}
return coverException([&] {
IS_SET(id);
- api::ZoneId zoneId;
- mHostClient.callGetActiveZoneId(zoneId);
+ api::ZoneId zoneId = *mClient->callSync<api::Void, api::ZoneId>(
+ api::ipc::METHOD_GET_ACTIVE_ZONE_ID,
+ std::make_shared<api::Void>());
*id = ::strdup(zoneId.value.c_str());
});
}
IS_SET(id);
IS_SET(rootpath);
- api::ZoneInfoOut info;
- mHostClient.callGetZoneInfo({ id }, info);
+ api::ZoneInfoOut info = *mClient->callSync<api::ZoneId, api::ZoneInfoOut>(
+ api::ipc::METHOD_GET_ZONE_INFO,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }));
*rootpath = ::strdup(info.rootPath.c_str());
});
}
IS_SET(id);
IS_SET(zone);
- api::ZoneInfoOut info;
- mHostClient.callGetZoneInfo({ id }, info);
+ api::ZoneInfoOut info = *mClient->callSync<api::ZoneId, api::ZoneInfoOut>(
+ api::ipc::METHOD_GET_ZONE_INFO,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }));
convert(info, *zone);
});
}
return coverException([&] {
IS_SET(id);
- mHostClient.callSetActiveZone({ id });
+ mClient->callSync<api::ZoneId, api::Void>(
+ api::ipc::METHOD_SET_ACTIVE_ZONE,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }));
});
}
IS_SET(id);
string template_name = tname ? tname : "default";
- mHostClient.callCreateZone({ id, template_name });
+ mClient->callSync<api::CreateZoneIn, api::Void>(
+ api::ipc::METHOD_CREATE_ZONE,
+ std::make_shared<api::CreateZoneIn>(api::CreateZoneIn{ id, template_name }),
+ TIMEOUT_INFINITE);
});
}
{
return coverException([&] {
IS_SET(id);
- mHostClient.callDestroyZone({ id });
+ mClient->callSync<api::ZoneId, api::Void>(
+ api::ipc::METHOD_DESTROY_ZONE,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }),
+ TIMEOUT_INFINITE);
});
}
{
return coverException([&] {
IS_SET(id);
- mHostClient.callShutdownZone({ id });
+ mClient->callSync<api::ZoneId, api::Void>(
+ api::ipc::METHOD_SHUTDOWN_ZONE,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }),
+ TIMEOUT_INFINITE);
});
}
{
return coverException([&] {
IS_SET(id);
- mHostClient.callStartZone({ id });
+ mClient->callSync<api::ZoneId, api::Void>(
+ api::ipc::METHOD_START_ZONE,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }),
+ TIMEOUT_INFINITE);
});
}
{
return coverException([&] {
IS_SET(id);
- mHostClient.callLockZone({ id });
+ mClient->callSync<api::ZoneId, api::Void>(
+ api::ipc::METHOD_LOCK_ZONE,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }),
+ TIMEOUT_INFINITE);
});
}
{
return coverException([&] {
IS_SET(id);
- mHostClient.callUnlockZone({ id });
+ mClient->callSync<api::ZoneId, api::Void>(
+ api::ipc::METHOD_UNLOCK_ZONE,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }));
});
}
VsmStatus Client::vsm_del_state_callback(VsmSubscriptionId subscriptionId) noexcept
{
return coverException([&] {
- mHostClient.unsubscribe(subscriptionId);
+ mClient->removeMethod(subscriptionId);
});
}
IS_SET(id);
IS_SET(device);
- mHostClient.callGrantDevice({ id, device, flags });
+ mClient->callSync<api::GrantDeviceIn, api::Void>(
+ api::ipc::METHOD_GRANT_DEVICE,
+ std::make_shared<api::GrantDeviceIn>(api::GrantDeviceIn{ id, device, flags }));
});
}
IS_SET(id);
IS_SET(device);
- mHostClient.callRevokeDevice({ id, device });
+ mClient->callSync<api::RevokeDeviceIn, api::Void>(
+ api::ipc::METHOD_REVOKE_DEVICE,
+ std::make_shared<api::RevokeDeviceIn>(api::RevokeDeviceIn{ id, device }));
});
}
IS_SET(id);
IS_SET(netdevIds);
- api::NetDevList netdevs;
- mHostClient.callGetNetdevList({ id }, netdevs);
+ api::NetDevList netdevs = *mClient->callSync<api::ZoneId, api::NetDevList>(
+ api::ipc::METHOD_GET_NETDEV_LIST,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }));
convert(netdevs, *netdevIds);
});
}
IS_SET(netdevId);
IS_SET(addr);
- api::GetNetDevAttrs attrs;
- mHostClient.callGetNetdevAttrs({ id, netdevId }, attrs);
+ api::GetNetDevAttrs attrs = *mClient->callSync<api::GetNetDevAttrsIn, api::GetNetDevAttrs>(
+ api::ipc::METHOD_GET_NETDEV_ATTRS,
+ std::make_shared<api::GetNetDevAttrsIn>(api::GetNetDevAttrsIn{ id, netdevId }));
auto it = find_if(attrs.values.begin(),
attrs.values.end(),
IS_SET(addr);
string value = "ip:" + toString(addr) + ",""prefixlen:" + to_string(prefix);
- mHostClient.callSetNetdevAttrs({ id, netdevId, { { "ipv4", value } } } );
+ mClient->callSync<api::SetNetDevAttrsIn, api::Void>(
+ api::ipc::METHOD_SET_NETDEV_ATTRS,
+ std::make_shared<api::SetNetDevAttrsIn>(
+ api::SetNetDevAttrsIn{ id, netdevId, { { "ipv4", value } } }));
});
}
IS_SET(addr);
string value = "ip:" + toString(addr) + ",""prefixlen:" + to_string(prefix);
- mHostClient.callSetNetdevAttrs({ id, netdevId, { { "ipv6", value } } } );
+ mClient->callSync<api::SetNetDevAttrsIn, api::Void>(
+ api::ipc::METHOD_SET_NETDEV_ATTRS,
+ std::make_shared<api::SetNetDevAttrsIn>(
+ api::SetNetDevAttrsIn{ id, netdevId, { { "ipv6", value } } }));
});
}
//CIDR notation
string ip = toString(addr) + "/" + to_string(prefix);
- mHostClient.callDeleteNetdevIpAddress({ id, netdevId, ip });
+ mClient->callSync<api::DeleteNetdevIpAddressIn, api::Void>(
+ api::ipc::METHOD_DELETE_NETDEV_IP_ADDRESS,
+ std::make_shared<api::DeleteNetdevIpAddressIn>(
+ api::DeleteNetdevIpAddressIn{ id, netdevId, ip }));
});
}
//CIDR notation
string ip = toString(addr) + "/" + to_string(prefix);
- mHostClient.callDeleteNetdevIpAddress({ id, netdevId, ip });
+ mClient->callSync<api::DeleteNetdevIpAddressIn, api::Void>(
+ api::ipc::METHOD_DELETE_NETDEV_IP_ADDRESS,
+ std::make_shared<api::DeleteNetdevIpAddressIn>(
+ api::DeleteNetdevIpAddressIn{ id, netdevId, ip }));
});
}
IS_SET(id);
IS_SET(netdevId);
- mHostClient.callSetNetdevAttrs({ id, netdevId, { { "flags", to_string(IFF_UP) },
- { "change", to_string(IFF_UP) } } } );
+ mClient->callSync<api::SetNetDevAttrsIn, api::Void>(
+ api::ipc::METHOD_SET_NETDEV_ATTRS,
+ std::make_shared<api::SetNetDevAttrsIn>(
+ api::SetNetDevAttrsIn{ id, netdevId, { { "flags", to_string(IFF_UP) },
+ { "change", to_string(IFF_UP) } } }));
});
}
IS_SET(id);
IS_SET(netdevId);
- mHostClient.callSetNetdevAttrs({ id, netdevId, { { "flags", to_string(~IFF_UP) },
- { "change", to_string(IFF_UP) } } } );
+ mClient->callSync<api::SetNetDevAttrsIn, api::Void>(
+ api::ipc::METHOD_SET_NETDEV_ATTRS,
+ std::make_shared<api::SetNetDevAttrsIn>(
+ api::SetNetDevAttrsIn{ id, netdevId, { { "flags", to_string(~IFF_UP) },
+ { "change", to_string(IFF_UP) } } }));
});
}
IS_SET(zoneDev);
IS_SET(hostDev);
- mHostClient.callCreateNetdevVeth({ id, zoneDev, hostDev });
+ mClient->callSync<api::CreateNetDevVethIn, api::Void>(
+ api::ipc::METHOD_CREATE_NETDEV_VETH,
+ std::make_shared<api::CreateNetDevVethIn>(
+ api::CreateNetDevVethIn{ id, zoneDev, hostDev }));
});
}
IS_SET(zoneDev);
IS_SET(hostDev);
- mHostClient.callCreateNetdevMacvlan({ id, zoneDev, hostDev, mode });
+ mClient->callSync<api::CreateNetDevMacvlanIn, api::Void>(
+ api::ipc::METHOD_CREATE_NETDEV_MACVLAN,
+ std::make_shared<api::CreateNetDevMacvlanIn>(
+ api::CreateNetDevMacvlanIn{ id, zoneDev, hostDev, mode }));
});
}
IS_SET(id);
IS_SET(devId);
- mHostClient.callCreateNetdevPhys({ id, devId });
+ mClient->callSync<api::CreateNetDevPhysIn, api::Void>(
+ api::ipc::METHOD_CREATE_NETDEV_PHYS,
+ std::make_shared<api::CreateNetDevPhysIn>(
+ api::CreateNetDevPhysIn{ id, devId }));
});
}
IS_SET(netdevId);
IS_SET(netdev);
- api::GetNetDevAttrs attrs;
- mHostClient.callGetNetdevAttrs({ id, netdevId }, attrs);
+ api::GetNetDevAttrs attrs = *mClient->callSync<api::GetNetDevAttrsIn, api::GetNetDevAttrs>(
+ api::ipc::METHOD_GET_NETDEV_ATTRS,
+ std::make_shared<api::GetNetDevAttrsIn>(api::GetNetDevAttrsIn{ id, netdevId }));
auto it = find_if(attrs.values.begin(),
attrs.values.end(),
[](const api::StringPair& entry) {
IS_SET(id);
IS_SET(devId);
- mHostClient.callDestroyNetdev({ id, devId });
+ mClient->callSync<api::DestroyNetDevIn, api::Void>(
+ api::ipc::METHOD_DESTROY_NETDEV,
+ std::make_shared<api::DestroyNetDevIn>(api::DestroyNetDevIn{ id, devId }));
});
}
IS_SET(id);
IS_SET(path);
- api::Declaration declaration;
- mHostClient.callDeclareFile({ id, type, path, flags, (int)mode }, declaration);
+ api::Declaration declaration = *mClient->callSync<api::DeclareFileIn, api::Declaration>(
+ api::ipc::METHOD_DECLARE_FILE,
+ std::make_shared<api::DeclareFileIn>(
+ api::DeclareFileIn{ id, type, path, flags, (int)mode }));
if (declarationId != NULL) {
*declarationId = ::strdup(declaration.value.c_str());
}
data = "";
}
- api::Declaration declaration;
- mHostClient.callDeclareMount({ source, id, target, type, flags, data }, declaration);
+ api::Declaration declaration = *mClient->callSync<api::DeclareMountIn, api::Declaration>(
+ api::ipc::METHOD_DECLARE_MOUNT,
+ std::make_shared<api::DeclareMountIn>(
+ api::DeclareMountIn{ source, id, target, type, flags, data }));
if (declarationId != NULL) {
*declarationId = ::strdup(declaration.value.c_str());
}
IS_SET(id);
IS_SET(target);
- api::Declaration declaration;
- mHostClient.callDeclareLink({ source, id, target }, declaration);
+ api::Declaration declaration = *mClient->callSync<api::DeclareLinkIn, api::Declaration>(
+ api::ipc::METHOD_DECLARE_LINK,
+ std::make_shared<api::DeclareLinkIn>(api::DeclareLinkIn{ source, id, target }));
if (declarationId != NULL) {
*declarationId = ::strdup(declaration.value.c_str());
}
IS_SET(id);
IS_SET(declarations);
- api::Declarations declarationsOut;
- mHostClient.callGetDeclarations({ id }, declarationsOut);
+ api::Declarations declarationsOut = *mClient->callSync<api::ZoneId, api::Declarations>(
+ api::ipc::METHOD_GET_DECLARATIONS,
+ std::make_shared<api::ZoneId>(api::ZoneId{ id }));
convert(declarationsOut, *declarations);
});
}
IS_SET(id);
IS_SET(declaration);
- mHostClient.callRemoveDeclaration({ id, declaration });
+ mClient->callSync<api::RemoveDeclarationIn, api::Void>(
+ api::ipc::METHOD_REMOVE_DECLARATION,
+ std::make_shared<api::RemoveDeclarationIn>(api::RemoveDeclarationIn{ id, declaration }));
});
}
VsmStatus Client::vsm_del_notification_callback(VsmSubscriptionId subscriptionId) noexcept
{
return coverException([&] {
- mHostClient.unsubscribe(subscriptionId);
+ mClient->removeMethod(subscriptionId);
});
}