| 121 | |
| 122 | |
| 123 | static Future<v1::master::Response::GetFrameworks> getFrameworks( |
| 124 | const process::PID<Master>& pid) |
| 125 | { |
| 126 | v1::master::Call call; |
| 127 | call.set_type(v1::master::Call::GET_FRAMEWORKS); |
| 128 | |
| 129 | process::http::Headers headers = createBasicAuthHeaders(DEFAULT_CREDENTIAL); |
| 130 | headers["Accept"] = stringify(ContentType::PROTOBUF); |
| 131 | |
| 132 | return process::http::post( |
| 133 | pid, |
| 134 | "api/v1", |
| 135 | headers, |
| 136 | serialize(ContentType::PROTOBUF, call), |
| 137 | stringify(ContentType::PROTOBUF)) |
| 138 | .then([](const process::http::Response& httpResponse) |
| 139 | -> Future<v1::master::Response::GetFrameworks> { |
| 140 | if (httpResponse.status != process::http::OK().status) { |
| 141 | return Failure( |
| 142 | "GET_FRAMEWORKS failed with response status " + |
| 143 | httpResponse.status); |
| 144 | } |
| 145 | |
| 146 | Try<v1::master::Response> response = |
| 147 | deserialize<mesos::v1::master::Response>( |
| 148 | ContentType::PROTOBUF, httpResponse.body); |
| 149 | |
| 150 | if (response.isError()) { |
| 151 | return Failure(response.error()); |
| 152 | } |
| 153 | |
| 154 | if (!response->has_get_frameworks()) { |
| 155 | return Failure("Response to GET_FRAMEWORKS has no 'get_frameworks'"); |
| 156 | } |
| 157 | |
| 158 | return response->get_frameworks(); |
| 159 | }); |
| 160 | } |
| 161 | |
| 162 | |
| 163 | namespace scheduler { |