| @@ 223-258 (lines=36) @@ | ||
| 220 | """ |
|
| 221 | return self._authenticated |
|
| 222 | ||
| 223 | def authenticate(self, username: str, password: str) -> Any: |
|
| 224 | """Authenticate to gvmd. |
|
| 225 | ||
| 226 | The generated authenticate command will be send to server. |
|
| 227 | Afterwards the response is read, transformed and returned. |
|
| 228 | ||
| 229 | Arguments: |
|
| 230 | username: Username |
|
| 231 | password: Password |
|
| 232 | ||
| 233 | Returns: |
|
| 234 | Transformed response from server. |
|
| 235 | """ |
|
| 236 | cmd = XmlCommand("authenticate") |
|
| 237 | ||
| 238 | if not username: |
|
| 239 | raise RequiredArgument( |
|
| 240 | function=self.authenticate.__name__, argument='username' |
|
| 241 | ) |
|
| 242 | ||
| 243 | if not password: |
|
| 244 | raise RequiredArgument( |
|
| 245 | function=self.authenticate.__name__, argument='password' |
|
| 246 | ) |
|
| 247 | ||
| 248 | credentials = cmd.add_element("credentials") |
|
| 249 | credentials.add_element("username", username) |
|
| 250 | credentials.add_element("password", password) |
|
| 251 | ||
| 252 | self._send(cmd.to_string()) |
|
| 253 | response = self._read() |
|
| 254 | ||
| 255 | if _check_command_status(response): |
|
| 256 | self._authenticated = True |
|
| 257 | ||
| 258 | return self._transform(response) |
|
| 259 | ||
| 260 | def create_agent( |
|
| 261 | self, |
|
| @@ 242-277 (lines=36) @@ | ||
| 239 | """ |
|
| 240 | return self._authenticated |
|
| 241 | ||
| 242 | def authenticate(self, username: str, password: str) -> Any: |
|
| 243 | """Authenticate to gvmd. |
|
| 244 | ||
| 245 | The generated authenticate command will be send to server. |
|
| 246 | Afterwards the response is read, transformed and returned. |
|
| 247 | ||
| 248 | Arguments: |
|
| 249 | username: Username |
|
| 250 | password: Password |
|
| 251 | ||
| 252 | Returns: |
|
| 253 | Transformed response from server. |
|
| 254 | """ |
|
| 255 | cmd = XmlCommand("authenticate") |
|
| 256 | ||
| 257 | if not username: |
|
| 258 | raise RequiredArgument( |
|
| 259 | function=self.authenticate.__name__, argument='username' |
|
| 260 | ) |
|
| 261 | ||
| 262 | if not password: |
|
| 263 | raise RequiredArgument( |
|
| 264 | function=self.authenticate.__name__, argument='password' |
|
| 265 | ) |
|
| 266 | ||
| 267 | credentials = cmd.add_element("credentials") |
|
| 268 | credentials.add_element("username", username) |
|
| 269 | credentials.add_element("password", password) |
|
| 270 | ||
| 271 | self._send(cmd.to_string()) |
|
| 272 | response = self._read() |
|
| 273 | ||
| 274 | if _check_command_status(response): |
|
| 275 | self._authenticated = True |
|
| 276 | ||
| 277 | return self._transform(response) |
|
| 278 | ||
| 279 | def create_alert( |
|
| 280 | self, |
|