'Run the main method.'

def run(self):

    try:
        if (self.trust_password is not None):
            self.client.authenticate(self.trust_password)
        self.old_profile_json = self._get_profile_json()
        self.old_state = self._profile_json_to_module_state(self.old_profile_json)
        self._update_profile()
        state_changed = (len(self.actions) > 0)
        result_json = {'changed': state_changed, 'old_state': self.old_state, 'actions': self.actions}
        if self.client.debug:
            result_json['logs'] = self.client.logs
        self.module.exit_json(**result_json)
    except LXDClientException as e:
        state_changed = (len(self.actions) > 0)
        fail_params = {'msg': e.msg, 'changed': state_changed, 'actions': self.actions}
        if self.client.debug:
            fail_params['logs'] = e.kwargs['logs']
        self.module.fail_json(**fail_params)
