'Sync settings to cluster if required'

def sync(self):

    if (not self.exists()):
        msg = "'%s'    is    %s.    Cannot    sync."
        self.module.fail_json(msg=(msg % (self.name, self.status)))
    if (self.status in ['creating', 'rebooting', 'modifying']):
        if self.wait:
            self._wait_for_status('available')
        else:
            return
    if self._requires_destroy_and_create():
        if (not self.hard_modify):
            msg = "'%s'    requires    destructive    modification.    'hard_modify'    must    be    set    to    true    to    proceed."
            self.module.fail_json(msg=(msg % self.name))
        if (not self.wait):
            msg = "'%s'    requires    destructive    modification.    'wait'    must    be    set    to    true."
            self.module.fail_json(msg=(msg % self.name))
        self.delete()
        self.create()
        return
    if self._requires_modification():
        self.modify()
