:return: save this OS instance on Ariane server (create or update)
162214
def save(self):
        
        LOGGER.debug("OSInstance.save")
        post_payload = {}
        consolidated_osi_id = []
        consolidated_ipa_id = []
        consolidated_nic_id = []
        consolidated_app_id = []
        consolidated_env_id = []
        consolidated_snet_id = []
        consolidated_team_id = []

        if self.id is not None:
            post_payload['osInstanceID'] = self.id

        if self.name is not None:
            post_payload['osInstanceName'] = self.name

        if self.description is not None:
            post_payload['osInstanceDescription'] = self.description

        if self.admin_gate_uri is not None:
            post_payload['osInstanceAdminGateURI'] = self.admin_gate_uri

        if self.embedding_osi_id is not None:
            post_payload['osInstanceEmbeddingOSInstanceID'] = self.embedding_osi_id

        if self.ost_id is not None:
            post_payload['osInstanceOSTypeID'] = self.ost_id

        if self.embedded_osi_ids is not None:
            consolidated_osi_id = copy.deepcopy(self.embedded_osi_ids)
        if self.embedded_osi_2_rm is not None:
            for osi_2_rm in self.embedded_osi_2_rm:
                if osi_2_rm.id is None:
                    osi_2_rm.sync()
                consolidated_osi_id.remove(osi_2_rm.id)
        if self.embedded_osi_2_add is not None:
            for osi_id_2_add in self.embedded_osi_2_add:
                if osi_id_2_add.id is None:
                    osi_id_2_add.save()
                consolidated_osi_id.append(osi_id_2_add.id)
        post_payload['osInstanceEmbeddedOSInstancesID'] = consolidated_osi_id

        if self.ip_address_ids is not None:
            consolidated_ipa_id = copy.deepcopy(self.ip_address_ids)
        if self.ip_address_2_rm is not None:
            for ipa_2_rm in self.ip_address_2_rm:
                if ipa_2_rm.id is None:
                    ipa_2_rm.sync()
                consolidated_ipa_id.remove(ipa_2_rm.id)
        if self.ip_address_2_add is not None:
            for ipa_2_add in self.ip_address_2_add:
                if ipa_2_add.id is None:
                    ipa_2_add.save()
                consolidated_ipa_id.append(ipa_2_add.id)
        post_payload['osInstanceIPAddressesID'] = consolidated_ipa_id

        if self.nic_ids is not None:
            consolidated_nic_id = copy.deepcopy(self.nic_ids)
        if self.nic_2_rm is not None:
            for nic_2_rm in self.nic_2_rm:
                if nic_2_rm.id is None:
                    nic_2_rm.sync()
                consolidated_nic_id.remove(nic_2_rm.id)
        if self.nic_2_add is not None:
            for nic_2_add in self.nic_2_add:
                if nic_2_add.id is None:
                    nic_2_add.save()
                consolidated_nic_id.append(nic_2_add.id)
        post_payload['osInstanceNICsID'] = consolidated_nic_id

        if self.subnet_ids is not None:
            consolidated_snet_id = copy.deepcopy(self.subnet_ids)
        if self.subnets_2_rm is not None:
            for snet_2_rm in self.subnets_2_rm:
                if snet_2_rm.id is None:
                    snet_2_rm.sync()
                consolidated_snet_id.remove(snet_2_rm.id)
        if self.subnets_2_add is not None:
            for snet_2_add in self.subnets_2_add:
                if snet_2_add.id is None:
                    snet_2_add.save()
                consolidated_snet_id.append(snet_2_add.id)
        post_payload['osInstanceSubnetsID'] = consolidated_snet_id

        if self.application_ids is not None:
            consolidated_app_id = copy.deepcopy(self.application_ids)
        if self.application_2_rm is not None:
            for app_2_rm in self.application_2_rm:
                if app_2_rm.id is None:
                    app_2_rm.sync()
                consolidated_app_id.remove(app_2_rm.id)
        if self.application_2_add is not None:
            for app_2_add in self.application_2_add:
                if app_2_add.id is None:
                    app_2_add.save()
                consolidated_app_id.append(app_2_add.id)
        post_payload['osInstanceApplicationsID'] = consolidated_app_id

        if self.environment_ids is not None:
            consolidated_env_id = copy.deepcopy(self.environment_ids)
        if self.environment_2_rm is not None:
            for env_2_rm in self.environment_2_rm:
                if env_2_rm.id is None:
                    env_2_rm.sync()
                consolidated_env_id.remove(env_2_rm.id)
        if self.environment_2_add is not None:
            for env_2_add in self.environment_2_add:
                if env_2_add.id is None:
                    env_2_add.save()
                consolidated_env_id.append(env_2_add.id)
        post_payload['osInstanceEnvironmentsID'] = consolidated_env_id

        if self.team_ids is not None:
            consolidated_team_id = copy.deepcopy(self.team_ids)
        if self.team_2_rm is not None:
            for team_2_rm in self.team_2_rm:
                if team_2_rm.id is None:
                    team_2_rm.sync()
                consolidated_team_id.remove(team_2_rm.id)
        if self.team_2_add is not None:
            for team_2_add in self.team_2_add:
                if team_2_add.id is None:
                    team_2_add.save()
                consolidated_team_id.append(team_2_add.id)
        post_payload['osInstanceTeamsID'] = consolidated_team_id

        args = {'http_operation': 'POST', 'operation_path': '', 'parameters': {'payload': json.dumps(post_payload)}}
        response = OSInstanceService.requester.call(args)
        if response.rc != 0:
            LOGGER.warning(
                'OSInstance.save - Problem while saving OS instance ' + self.name +
                '. Reason: ' + str(response.response_content) + '-' + str(response.error_message) +
                " (" + str(response.rc) + ")"
            )
        else:
            self.id = response.response_content['osInstanceID']
            if self.embedded_osi_2_add is not None:
                for osi_2_add in self.embedded_osi_2_add:
                    osi_2_add.sync()
            if self.embedded_osi_2_rm is not None:
                for osi_2_rm in self.embedded_osi_2_rm:
                    osi_2_rm.sync()
            if self.ip_address_2_add is not None:
                for ipa_2_add in self.ip_address_2_add:
                    ipa_2_add.sync()
            if self.ip_address_2_rm is not None:
                for ipa_2_rm in self.ip_address_2_rm:
                    ipa_2_rm.sync()
            if self.nic_2_add is not None:
                for nic_2_add in self.nic_2_add:
                    nic_2_add.sync()
            if self.nic_2_rm is not None:
                for nic_2_rm in self.nic_2_rm:
                    nic_2_rm.sync()
            if self.subnets_2_add is not None:
                for snet_2_add in self.subnets_2_add:
                    snet_2_add.sync()
            if self.subnets_2_rm is not None:
                for snet_2_rm in self.subnets_2_rm:
                    snet_2_rm.sync()
            if self.application_2_add is not None:
                for app_2_add in self.application_2_add:
                    app_2_add.sync()
            if self.application_2_rm is not None:
                for app_2_rm in self.application_2_rm:
                    app_2_rm.sync()
            if self.environment_2_add is not None:
                for env_2_add in self.environment_2_add:
                    env_2_add.sync()
            if self.environment_2_rm is not None:
                for env_2_rm in self.environment_2_rm:
                    env_2_rm.sync()
            if self.team_2_add is not None:
                for team_2_add in self.team_2_add:
                    team_2_add.sync()
            if self.team_2_rm is not None:
                for team_2_rm in self.team_2_rm:
                    team_2_rm.sync()

        self.embedded_osi_2_add.clear()
        self.embedded_osi_2_rm.clear()
        self.ip_address_2_add.clear()
        self.ip_address_2_rm.clear()
        self.nic_2_add.clear()
        self.nic_2_rm.clear()
        self.subnets_2_add.clear()
        self.subnets_2_rm.clear()
        self.application_2_add.clear()
        self.application_2_rm.clear()
        self.environment_2_add.clear()
        self.environment_2_rm.clear()
        self.team_2_add.clear()
        self.team_2_rm.clear()
        self.sync()
        return self
58966
def save(self, *args, **kwargs):
        
        self.host = self.host.strip()

        if not self.id:
            self.device = self.__create_device()

        if self.store is True:
            super(DeviceConnector, self).save(*args, **kwargs)
608134
def save_hierarchy(self, hierarchy_form, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinAdminSession.update_bin
        if hierarchy_form.is_for_update():
            return self.update_hierarchy(hierarchy_form, *args, **kwargs)
        else:
            return self.create_hierarchy(hierarchy_form, *args, **kwargs)
926474
def choice_download(self):
        
        Download(path="", url=self.dwn_srcs, repo="sbo").start()
        raise SystemExit()
1255729
def save(self):
        
        LOGGER.debug("Environment.save")
        post_payload = {}
        consolidated_osi_id = []

        if self.id is not None:
            post_payload['environmentID'] = self.id

        if self.name is not None:
            post_payload['environmentName'] = self.name

        if self.description is not None:
            post_payload['environmentDescription'] = self.description

        if self.color_code is not None:
            post_payload['environmentColorCode'] = self.color_code

        if self.osi_ids is not None:
            consolidated_osi_id = copy.deepcopy(self.osi_ids)
        if self.osi_2_rm is not None:
            for osi_2_rm in self.osi_2_rm:
                if osi_2_rm.id is None:
                    osi_2_rm.sync()
                consolidated_osi_id.remove(osi_2_rm.id)
        if self.osi_2_add is not None:
            for osi_id_2_add in self.osi_2_add:
                if osi_id_2_add.id is None:
                    osi_id_2_add.save()
                consolidated_osi_id.append(osi_id_2_add.id)
        post_payload['environmentOSInstancesID'] = consolidated_osi_id

        args = {'http_operation': 'POST', 'operation_path': '', 'parameters': {'payload': json.dumps(post_payload)}}
        response = EnvironmentService.requester.call(args)
        if response.rc != 0:
            LOGGER.warning(
                'Environment.save - Problem while saving environment ' + self.name +
                '. Reason: ' + str(response.response_content) + '-' + str(response.error_message) +
                " (" + str(response.rc) + ")"
            )
        else:
            self.id = response.response_content['environmentID']
            if self.osi_2_add is not None:
                for osi_2_add in self.osi_2_add:
                    osi_2_add.sync()
            if self.osi_2_rm is not None:
                for osi_2_rm in self.osi_2_rm:
                    osi_2_rm.sync()
        self.osi_2_add.clear()
        self.osi_2_rm.clear()
        self.sync()
        return self
80327
def save_or_update(self, cluster):
        
        if not os.path.exists(self.storage_path):
            os.makedirs(self.storage_path)

        path = self._get_cluster_storage_path(cluster.name)
        cluster.storage_file = path
        with open(path, 'wb') as storage:
            self.dump(cluster, storage)
960211
def save(self):
        
        resp = self.r_session.put(
            self.document_url,
            data=self.json(),
            headers={'Content-Type': 'application/json'}
        )
        resp.raise_for_status()
216000
def save(**kwargs):
    '''
    
    '''

    ret = {'comment': [],
           'result': True}

    beacons = list_(return_yaml=False, include_pillar=False, **kwargs)

    # move this file into an configurable opt
    sfn = os.path.join(os.path.dirname(__opts__['conf_file']),
                       os.path.dirname(__opts__['default_include']),
                       'beacons.conf')
    if beacons:
        tmp = {'beacons': beacons}
        yaml_out = salt.utils.yaml.safe_dump(tmp, default_flow_style=False)
    else:
        yaml_out = ''

    try:
        with salt.utils.files.fopen(sfn, 'w+') as fp_:
            fp_.write(yaml_out)
        ret['comment'] = 'Beacons saved to {0}.'.format(sfn)
    except (IOError, OSError):
        ret['comment'] = 'Unable to write to beacons file at {0}. Check ' \
                         'permissions.'.format(sfn)
        ret['result'] = False
    return ret
66021
def create(self, max_wait=180, **kwargs):
        
        # Will need to wait for the service to be provisioned before can add
        # service keys and get env details.
        self.service.create(async=True, create_keys=False)
        while self._create_in_progress() and max_wait > 0:
            time.sleep(1)
            max_wait -= 1

        # Now get the service env (via service keys)
        cfg = self.service._get_service_config()
        self.service.settings.save(cfg)

        host = predix.config.get_env_key(self.use_class, 'host')
        os.environ[host] = self.service.settings.data['host']

        password = predix.config.get_env_key(self.use_class, 'password')
        os.environ[password] = self.service.settings.data['password']

        port = predix.config.get_env_key(self.use_class, 'port')
        os.environ[port] = str(self.service.settings.data['port'])
216193
def save(self, path=None):
        
        if path==None: 
            
            if self._autosettings_path == None: return self
            
            # Get the gui settings directory
            gui_settings_dir = _os.path.join(_cwd, 'egg_settings')

            # make sure the directory exists
            if not _os.path.exists(gui_settings_dir): _os.mkdir(gui_settings_dir)            
            
            # Assemble the path
            path = _os.path.join(gui_settings_dir, self._autosettings_path)
      
        # make the databox object
        d = _d.databox()

        # get the keys and dictionary
        keys, dictionary = self.get_dictionary()

        # loop over the keys and add them to the databox header
        for k in keys: 
            d.insert_header(k, dictionary[k])
            
        # save it
        try:
            d.save_file(path, force_overwrite=True, header_only=True)
        except:
            print('Warning: could not save '+path.__repr__()+' once. Could be that this is being called too rapidly.')
        
        return self
630429
def save(self):
        
        try:
            with open(self._filename, 'wb') as session_file:
                session_file.write(self.dumps())
        except IOError as error:
            LOGGER.error('Session file error: %s', error)
            raise error
674507
def updated(self, instance):
        
        self.session_manager.save(instance, commit=True)
        return instance
138533
def save_objective(self, objective_form, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.ResourceAdminSession.update_resource
        if objective_form.is_for_update():
            return self.update_objective(objective_form, *args, **kwargs)
        else:
            return self.create_objective(objective_form, *args, **kwargs)
794251
def created(self, instance, commit=True):
        
        if commit:
            self.session_manager.save(instance, commit=True)
        return instance, HTTPStatus.CREATED
124021
def save(self, config=None):
        
        if config is not None:
            clist = [config]
        else:
            clist = [
                self._system_config,
                self._global_config,
                self._repo_config,
                self._local_config,
            ]

        for conf in clist:
            if conf.filename is None:
                continue

            try:
                logger.debug("Writing '{}'.".format(conf.filename))
                dname = os.path.dirname(os.path.abspath(conf.filename))
                try:
                    os.makedirs(dname)
                except OSError as exc:
                    if exc.errno != errno.EEXIST:
                        raise
                conf.write()
            except Exception as exc:
                msg = "failed to write config '{}'".format(conf.filename)
                raise ConfigError(msg, exc)
1114208
def save(self):
        
        if self.filename is None:
            raise StoreException("Filename must be set to write store to disk")

        # We need an atomic way of re-writing the settings, we also need to
        # prevent only overwriting part of the settings file (see bug #116).
        # Create a temp file and only then re-name it to the config
        filename = "{filename}.{date}.tmp".format(
            filename=self.filename,
            date=datetime.datetime.utcnow().strftime('%Y-%m-%dT%H_%M_%S.%f')
        )

        # The `open` built-in doesn't allow us to set the mode
        mode = stat.S_IRUSR | stat.S_IWUSR  # 0600
        fd = os.open(filename, os.O_WRONLY | os.O_CREAT, mode)
        fout = os.fdopen(fd, "w")
        fout.write(json.dumps(self.export()))
        fout.close()

        # Now we should remove the old config
        if os.path.isfile(self.filename):
            os.remove(self.filename)

        # Now rename the temp file to the real config file
        os.rename(filename, self.filename)
777592
def _save_or_update(self):
        
        with self._resource_lock:
            if not self._config or not self._config._storage_path:
                raise Exception("self._config._storage path is undefined")
            if not self._config._base_name:
                raise Exception("self._config._base_name is undefined")
            if not os.path.exists(self._config._storage_path):
                os.makedirs(self._config._storage_path)
            path = self._get_cloud_provider_storage_path()
            with open(path, 'wb') as storage:
                pickle.dump(self._config, storage, pickle.HIGHEST_PROTOCOL)
                pickle.dump(self._subscriptions, storage,
                            pickle.HIGHEST_PROTOCOL)