|
13 | 13 | import time |
14 | 14 | import warnings |
15 | 15 |
|
| 16 | +from SoftLayer.decoration import retry |
16 | 17 | from SoftLayer import exceptions |
17 | 18 | from SoftLayer.managers import ordering |
18 | 19 | from SoftLayer import utils |
19 | 20 |
|
| 21 | + |
20 | 22 | LOGGER = logging.getLogger(__name__) |
21 | 23 | # pylint: disable=no-self-use |
22 | 24 |
|
@@ -584,9 +586,17 @@ def create_instance(self, **kwargs): |
584 | 586 | tags = kwargs.pop('tags', None) |
585 | 587 | inst = self.guest.createObject(self._generate_create_dict(**kwargs)) |
586 | 588 | if tags is not None: |
587 | | - self.guest.setTags(tags, id=inst['id']) |
| 589 | + self.set_tags(tags, guest_id=inst['id']) |
588 | 590 | return inst |
589 | 591 |
|
| 592 | + @retry(exceptions.SoftLayerAPIError, logger=LOGGER) |
| 593 | + def set_tags(self, tags, guest_id): |
| 594 | + """Sets tags on a guest with a retry decorator |
| 595 | +
|
| 596 | + Just calls guest.setTags, but lets if it fails from an APIError will retry |
| 597 | + """ |
| 598 | + self.guest.setTags(tags, id=guest_id) |
| 599 | + |
590 | 600 | def create_instances(self, config_list): |
591 | 601 | """Creates multiple virtual server instances. |
592 | 602 |
|
@@ -636,7 +646,7 @@ def create_instances(self, config_list): |
636 | 646 |
|
637 | 647 | for instance, tag in zip(resp, tags): |
638 | 648 | if tag is not None: |
639 | | - self.guest.setTags(tag, id=instance['id']) |
| 649 | + self.set_tags(tag, guest_id=instance['id']) |
640 | 650 |
|
641 | 651 | return resp |
642 | 652 |
|
@@ -717,7 +727,7 @@ def edit(self, instance_id, userdata=None, hostname=None, domain=None, |
717 | 727 | self.guest.setUserMetadata([userdata], id=instance_id) |
718 | 728 |
|
719 | 729 | if tags is not None: |
720 | | - self.guest.setTags(tags, id=instance_id) |
| 730 | + self.set_tags(tags, guest_id=instance_id) |
721 | 731 |
|
722 | 732 | if hostname: |
723 | 733 | obj['hostname'] = hostname |
|
0 commit comments