|
@@ 530-575 (lines=46) @@
|
| 527 |
|
|
| 528 |
|
return cmd.to_string() |
| 529 |
|
|
| 530 |
|
def create_schedule_command(self, name, kwargs): |
| 531 |
|
"""Generates xml string for create schedule on gvmd.""" |
| 532 |
|
if not name: |
| 533 |
|
raise ValueError('create_schedule requires a name element') |
| 534 |
|
|
| 535 |
|
cmd = XmlCommand('create_schedule') |
| 536 |
|
cmd.add_element('name', name) |
| 537 |
|
|
| 538 |
|
comment = kwargs.get('comment', '') |
| 539 |
|
if comment: |
| 540 |
|
cmd.add_element('comment', comment) |
| 541 |
|
|
| 542 |
|
copy = kwargs.get('copy', '') |
| 543 |
|
if copy: |
| 544 |
|
cmd.add_element('copy', copy) |
| 545 |
|
|
| 546 |
|
first_time = kwargs.get('first_time', '') |
| 547 |
|
if first_time: |
| 548 |
|
first_time_minute = first_time['minute'] |
| 549 |
|
first_time_hour = first_time['hour'] |
| 550 |
|
first_time_day_of_month = first_time['day_of_month'] |
| 551 |
|
first_time_month = first_time['month'] |
| 552 |
|
first_time_year = first_time['year'] |
| 553 |
|
|
| 554 |
|
_xmlftime = cmd.add_element('first_time') |
| 555 |
|
_xmlftime.add_element('minute', first_time_minute) |
| 556 |
|
_xmlftime.add_element('hour', str(first_time_hour)) |
| 557 |
|
_xmlftime.add_element('day_of_month', str(first_time_day_of_month)) |
| 558 |
|
_xmlftime.add_element('month', str(first_time_month)) |
| 559 |
|
_xmlftime.add_element('year', str(first_time_year)) |
| 560 |
|
|
| 561 |
|
duration = kwargs.get('duration', '') |
| 562 |
|
if len(duration) > 1: |
| 563 |
|
_xmlduration = cmd.add_element('duration', str(duration[0])) |
| 564 |
|
_xmlduration.add_element('unit', str(duration[1])) |
| 565 |
|
|
| 566 |
|
period = kwargs.get('period', '') |
| 567 |
|
if len(period) > 1: |
| 568 |
|
_xmlperiod = cmd.add_element('period', str(period[0])) |
| 569 |
|
_xmlperiod.add_element('unit', str(period[1])) |
| 570 |
|
|
| 571 |
|
timezone = kwargs.get('timezone', '') |
| 572 |
|
if timezone: |
| 573 |
|
cmd.add_element('timezone', str(timezone)) |
| 574 |
|
|
| 575 |
|
return cmd.to_string() |
| 576 |
|
|
| 577 |
|
def create_tag_command(self, name, resource_id, resource_type, kwargs): |
| 578 |
|
"""Generates xml string for create tag on gvmd.""" |
|
@@ 1147-1191 (lines=45) @@
|
| 1144 |
|
|
| 1145 |
|
return cmd.to_string() |
| 1146 |
|
|
| 1147 |
|
def modify_schedule_command(self, schedule_id, kwargs): |
| 1148 |
|
"""Generates xml string for modify schedule on gvmd.""" |
| 1149 |
|
if not schedule_id: |
| 1150 |
|
raise ValueError('modify_schedule requires a schedule_id element') |
| 1151 |
|
|
| 1152 |
|
cmd = XmlCommand('modify_schedule') |
| 1153 |
|
cmd.set_attribute('schedule_id', schedule_id) |
| 1154 |
|
comment = kwargs.get('comment', '') |
| 1155 |
|
if comment: |
| 1156 |
|
cmd.add_element('comment', comment) |
| 1157 |
|
|
| 1158 |
|
name = kwargs.get('name', '') |
| 1159 |
|
if name: |
| 1160 |
|
cmd.add_element('name', name) |
| 1161 |
|
|
| 1162 |
|
first_time = kwargs.get('first_time', '') |
| 1163 |
|
if first_time: |
| 1164 |
|
first_time_minute = first_time['minute'] |
| 1165 |
|
first_time_hour = first_time['hour'] |
| 1166 |
|
first_time_day_of_month = first_time['day_of_month'] |
| 1167 |
|
first_time_month = first_time['month'] |
| 1168 |
|
first_time_year = first_time['year'] |
| 1169 |
|
|
| 1170 |
|
_xmlftime = cmd.add_element('first_time') |
| 1171 |
|
_xmlftime.add_element('minute', str(first_time_minute)) |
| 1172 |
|
_xmlftime.add_element('hour', str(first_time_hour)) |
| 1173 |
|
_xmlftime.add_element('day_of_month', str(first_time_day_of_month)) |
| 1174 |
|
_xmlftime.add_element('month', str(first_time_month)) |
| 1175 |
|
_xmlftime.add_element('year', str(first_time_year)) |
| 1176 |
|
|
| 1177 |
|
duration = kwargs.get('duration', '') |
| 1178 |
|
if len(duration) > 1: |
| 1179 |
|
_xmlduration = cmd.add_element('duration', str(duration[0])) |
| 1180 |
|
_xmlduration.add_element('unit', str(duration[1])) |
| 1181 |
|
|
| 1182 |
|
period = kwargs.get('period', '') |
| 1183 |
|
if len(period) > 1: |
| 1184 |
|
_xmlperiod = cmd.add_element('period', str(period[0])) |
| 1185 |
|
_xmlperiod.add_element('unit', str(period[1])) |
| 1186 |
|
|
| 1187 |
|
timezone = kwargs.get('timezone', '') |
| 1188 |
|
if timezone: |
| 1189 |
|
cmd.add_element('timezone', str(timezone)) |
| 1190 |
|
|
| 1191 |
|
return cmd.to_string() |
| 1192 |
|
|
| 1193 |
|
def modify_setting_command(self, setting_id, name, value): |
| 1194 |
|
"""Generates xml string for modify setting format on gvmd.""" |