|
@@ 576-621 (lines=46) @@
|
| 573 |
|
|
| 574 |
|
return cmd.to_string() |
| 575 |
|
|
| 576 |
|
def create_schedule_command(self, name, kwargs): |
| 577 |
|
"""Generates xml string for create schedule on gvmd.""" |
| 578 |
|
if not name: |
| 579 |
|
raise ValueError('create_schedule requires a name element') |
| 580 |
|
|
| 581 |
|
cmd = XmlCommand('create_schedule') |
| 582 |
|
cmd.add_element('name', name) |
| 583 |
|
|
| 584 |
|
comment = kwargs.get('comment', '') |
| 585 |
|
if comment: |
| 586 |
|
cmd.add_element('comment', comment) |
| 587 |
|
|
| 588 |
|
copy = kwargs.get('copy', '') |
| 589 |
|
if copy: |
| 590 |
|
cmd.add_element('copy', copy) |
| 591 |
|
|
| 592 |
|
first_time = kwargs.get('first_time', '') |
| 593 |
|
if first_time: |
| 594 |
|
first_time_minute = first_time['minute'] |
| 595 |
|
first_time_hour = first_time['hour'] |
| 596 |
|
first_time_day_of_month = first_time['day_of_month'] |
| 597 |
|
first_time_month = first_time['month'] |
| 598 |
|
first_time_year = first_time['year'] |
| 599 |
|
|
| 600 |
|
_xmlftime = cmd.add_element('first_time') |
| 601 |
|
_xmlftime.add_element('minute', first_time_minute) |
| 602 |
|
_xmlftime.add_element('hour', str(first_time_hour)) |
| 603 |
|
_xmlftime.add_element('day_of_month', str(first_time_day_of_month)) |
| 604 |
|
_xmlftime.add_element('month', str(first_time_month)) |
| 605 |
|
_xmlftime.add_element('year', str(first_time_year)) |
| 606 |
|
|
| 607 |
|
duration = kwargs.get('duration', '') |
| 608 |
|
if len(duration) > 1: |
| 609 |
|
_xmlduration = cmd.add_element('duration', str(duration[0])) |
| 610 |
|
_xmlduration.add_element('unit', str(duration[1])) |
| 611 |
|
|
| 612 |
|
period = kwargs.get('period', '') |
| 613 |
|
if len(period) > 1: |
| 614 |
|
_xmlperiod = cmd.add_element('period', str(period[0])) |
| 615 |
|
_xmlperiod.add_element('unit', str(period[1])) |
| 616 |
|
|
| 617 |
|
timezone = kwargs.get('timezone', '') |
| 618 |
|
if timezone: |
| 619 |
|
cmd.add_element('timezone', str(timezone)) |
| 620 |
|
|
| 621 |
|
return cmd.to_string() |
| 622 |
|
|
| 623 |
|
def create_tag_command(self, name, resource_id, resource_type, kwargs): |
| 624 |
|
"""Generates xml string for create tag on gvmd.""" |
|
@@ 1282-1326 (lines=45) @@
|
| 1279 |
|
|
| 1280 |
|
return cmd.to_string() |
| 1281 |
|
|
| 1282 |
|
def modify_schedule_command(self, schedule_id, kwargs): |
| 1283 |
|
"""Generates xml string for modify schedule on gvmd.""" |
| 1284 |
|
if not schedule_id: |
| 1285 |
|
raise ValueError('modify_schedule requires a schedule_id element') |
| 1286 |
|
|
| 1287 |
|
cmd = XmlCommand('modify_schedule') |
| 1288 |
|
cmd.set_attribute('schedule_id', schedule_id) |
| 1289 |
|
comment = kwargs.get('comment', '') |
| 1290 |
|
if comment: |
| 1291 |
|
cmd.add_element('comment', comment) |
| 1292 |
|
|
| 1293 |
|
name = kwargs.get('name', '') |
| 1294 |
|
if name: |
| 1295 |
|
cmd.add_element('name', name) |
| 1296 |
|
|
| 1297 |
|
first_time = kwargs.get('first_time', '') |
| 1298 |
|
if first_time: |
| 1299 |
|
first_time_minute = first_time['minute'] |
| 1300 |
|
first_time_hour = first_time['hour'] |
| 1301 |
|
first_time_day_of_month = first_time['day_of_month'] |
| 1302 |
|
first_time_month = first_time['month'] |
| 1303 |
|
first_time_year = first_time['year'] |
| 1304 |
|
|
| 1305 |
|
_xmlftime = cmd.add_element('first_time') |
| 1306 |
|
_xmlftime.add_element('minute', str(first_time_minute)) |
| 1307 |
|
_xmlftime.add_element('hour', str(first_time_hour)) |
| 1308 |
|
_xmlftime.add_element('day_of_month', str(first_time_day_of_month)) |
| 1309 |
|
_xmlftime.add_element('month', str(first_time_month)) |
| 1310 |
|
_xmlftime.add_element('year', str(first_time_year)) |
| 1311 |
|
|
| 1312 |
|
duration = kwargs.get('duration', '') |
| 1313 |
|
if len(duration) > 1: |
| 1314 |
|
_xmlduration = cmd.add_element('duration', str(duration[0])) |
| 1315 |
|
_xmlduration.add_element('unit', str(duration[1])) |
| 1316 |
|
|
| 1317 |
|
period = kwargs.get('period', '') |
| 1318 |
|
if len(period) > 1: |
| 1319 |
|
_xmlperiod = cmd.add_element('period', str(period[0])) |
| 1320 |
|
_xmlperiod.add_element('unit', str(period[1])) |
| 1321 |
|
|
| 1322 |
|
timezone = kwargs.get('timezone', '') |
| 1323 |
|
if timezone: |
| 1324 |
|
cmd.add_element('timezone', str(timezone)) |
| 1325 |
|
|
| 1326 |
|
return cmd.to_string() |
| 1327 |
|
|
| 1328 |
|
def modify_tag_command(self, tag_id, kwargs): |
| 1329 |
|
"""Generates xml string for modify tag on gvmd.""" |