43 auto req = queue.front();
46 MIL_PRV <<
"Received provide: " << req->_spec.code() << std::endl;
49 switch ( req->_spec.code () ) {
50 case zyppng::ProvideMessage::Code::Attach: {
56 for (
const auto &i : req->_spec.headers() ) {
61 vals.
set( i.first, i.second );
64 const auto &res =
_driver->mountDevice( req->_spec.requestId(), attachUrl, attachId, label, vals );
66 const auto &err = res.error();
76 MIL <<
"Attach of " << attachUrl <<
" was successfull" << std::endl;
78 attachSuccess( req->_spec.requestId(), res.get().asString() );
81 case zyppng::ProvideMessage::Code::Detach: {
84 const auto &attachId =
url.getAuthority();
86 if (
_driver->detachMedia( attachId ) ) {
90 , zyppng::ProvideMessage::Code::NotFound
91 ,
"Attach ID not known."
101 case zyppng::ProvideMessage::Code::Prov: {
104 const auto &attachId =
url.getAuthority();
106 const auto &availMedia =
_driver->attachedMedia();
108 auto i = availMedia.find( attachId );
109 if ( i == availMedia.end() ) {
110 ERR <<
"Unknown Attach ID " << attachId << std::endl;
112 , zyppng::ProvideMessage::Code::NotFound
113 ,
"Attach ID not known."
119 const auto &locPath = i->second._dev->_mountPoint / i->second._attachRoot / path;
121 MIL <<
"Trying to find file: " << locPath << std::endl;
131 , zyppng::ProvideMessage::Code::NotAFile
132 ,
zypp::str::Str() <<
"Path " << path <<
" exists, but its not a file"
137 , zyppng::ProvideMessage::Code::NotFound
148 , zyppng::ProvideMessage::Code::BadRequest
149 ,
"Request type not implemented"
158 , zyppng::ProvideMessage::Code::BadRequest
163 }
catch (
const std::exception &e ) {
166 , zyppng::ProvideMessage::Code::BadRequest
174 , zyppng::ProvideMessage::Code::BadRequest
175 ,
"Unknown exception"