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 req ->_spec.forEachVal([&](
const std::string &name,
const auto &val ) {
61 vals.
add( name, val );
65 const auto &res =
_driver->mountDevice( req->_spec.requestId(), attachUrl, attachId, label, vals );
67 const auto &err = res.error();
77 MIL <<
"Attach of " << attachUrl <<
" was successfull" << std::endl;
79 attachSuccess( req->_spec.requestId(), res.get().asString() );
82 case zyppng::ProvideMessage::Code::Detach: {
85 const auto &attachId = url.getAuthority();
87 if (
_driver->detachMedia( attachId ) ) {
91 , zyppng::ProvideMessage::Code::NotFound
92 ,
"Attach ID not known."
102 case zyppng::ProvideMessage::Code::Prov: {
105 const auto &attachId = url.getAuthority();
107 const auto &availMedia =
_driver->attachedMedia();
109 auto i = availMedia.find( attachId );
110 if ( i == availMedia.end() ) {
111 ERR <<
"Unknown Attach ID " << attachId << std::endl;
113 , zyppng::ProvideMessage::Code::NotFound
114 ,
"Attach ID not known."
120 const auto &locPath = i->second._dev->_mountPoint / i->second._attachRoot / path;
122 MIL <<
"Trying to find file: " << locPath << std::endl;
132 , zyppng::ProvideMessage::Code::NotAFile
133 ,
zypp::str::Str() <<
"Path " << path <<
" exists, but its not a file"
138 , zyppng::ProvideMessage::Code::NotFound
149 , zyppng::ProvideMessage::Code::BadRequest
150 ,
"Request type not implemented"
159 , zyppng::ProvideMessage::Code::BadRequest
164 }
catch (
const std::exception &e ) {
167 , zyppng::ProvideMessage::Code::BadRequest
175 , zyppng::ProvideMessage::Code::BadRequest
176 ,
"Unknown exception"