Apply global network configuration.

    CLI Example:

    .. code-block:: bash

        salt '*' ip.apply_network_settings
178034
def apply_network_settings(**settings):
    '''
    
    '''
    if 'require_reboot' not in settings:
        settings['require_reboot'] = False

    if 'apply_hostname' not in settings:
        settings['apply_hostname'] = False

    hostname_res = True
    if settings['apply_hostname'] in _CONFIG_TRUE:
        if 'hostname' in settings:
            hostname_res = __salt__['network.mod_hostname'](settings['hostname'])
        else:
            log.warning(
                'The network state sls is trying to apply hostname '
                'changes but no hostname is defined.'
            )
            hostname_res = False

    res = True
    if settings['require_reboot'] in _CONFIG_TRUE:
        log.warning(
            'The network state sls is requiring a reboot of the system to '
            'properly apply network configuration.'
        )
        res = True
    else:
        stop = __salt__['service.stop']('networking')
        time.sleep(2)
        res = stop and __salt__['service.start']('networking')

    return hostname_res and res
1079976
def set_mode(iface, mode):
    '''
    
    '''
    if not _valid_iface(iface):
        raise SaltInvocationError(
            'The interface specified is not valid'
        )

    valid_modes = ('Managed', 'Ad-Hoc', 'Master', 'Repeater', 'Secondary', 'Monitor', 'Auto')
    if mode not in valid_modes:
        raise SaltInvocationError(
            'One of the following modes must be specified: {0}'.format(', '.join(valid_modes))
        )
    __salt__['ip.down'](iface)
    out = __salt__['cmd.run']('iwconfig {0} mode {1}'.format(iface, mode))
    __salt__['ip.up'](iface)

    return mode
1281350
def set_ddns_config(self, isenable, hostname, ddnsserver,
                                        user, password, callback=None):
        '''
        
        '''
        params = {'isEnable': isenable,
                  'hostName': hostname,
                  'ddnsServer': ddnsserver,
                  'user': user,
                  'password': password,
                 }
        return self.execute_command('setDDNSConfig', params, callback=callback)
986473
def set_public_lan(lan_id):
    '''
    
    '''
    conn = get_conn()
    datacenter_id = get_datacenter_id()

    try:
        lan = conn.get_lan(datacenter_id=datacenter_id, lan_id=lan_id)
        if not lan['properties']['public']:
            conn.update_lan(datacenter_id=datacenter_id,
                            lan_id=lan_id,
                            public=True)
        return lan['id']
    except Exception:
        lan = conn.create_lan(datacenter_id,
                              LAN(public=True,
                                  name='Public LAN'))
        return lan['id']
40291
def set_address(network, address):
    
    if network.find('.//ip') is not None:
        raise RuntimeError("Address already specified in XML configuration.")

    netmask = str(address.netmask)
    ipv4 = str(address[1])
    dhcp_start = str(address[2])
    dhcp_end = str(address[-2])
    ip = etree.SubElement(network, 'ip', address=ipv4, netmask=netmask)
    dhcp = etree.SubElement(ip, 'dhcp')

    etree.SubElement(dhcp, 'range', start=dhcp_start, end=dhcp_end)
721292
def _apply_user_port_channel_config(self, nexus_host, vpc_nbr):
        

        cli_cmds = self._get_user_port_channel_config(nexus_host, vpc_nbr)
        if cli_cmds:
            self._send_cli_conf_string(nexus_host, cli_cmds)
        else:
            vpc_str = str(vpc_nbr)
            path_snip = snipp.PATH_ALL
            body_snip = snipp.BODY_ADD_PORT_CH_P2 % (vpc_str, vpc_str)
            self.send_edit_string(nexus_host, path_snip, body_snip)
310838
def enable_static_ip_config(self, ip_address, network_mask):
        
        if not isinstance(ip_address, basestring):
            raise TypeError("ip_address can only be an instance of type basestring")
        if not isinstance(network_mask, basestring):
            raise TypeError("network_mask can only be an instance of type basestring")
        self._call("enableStaticIPConfig",
                     in_p=[ip_address, network_mask])
187551
def configure(cls, global_, key, val):
        
        # first retrieve current configuration
        scope = 'global' if global_ else 'local'
        if scope not in cls._conffiles:
            cls._conffiles[scope] = {}
        config = cls._conffiles.get(scope, {})
        # apply modification to fields
        cls._set(scope, key, val)
        conf_file = cls.home_config if global_ else cls.local_config
        # save configuration to file
        cls.save(os.path.expanduser(conf_file), config)
324653
def _adjust_router_list_for_global_router(self, routers):
        
        #ToDo(Hareesh): Simplify if possible
        for r in routers:
            if r[ROUTER_ROLE_ATTR] == c_constants.ROUTER_ROLE_GLOBAL:
                LOG.debug("Global router:%s found. Moved to the end of list "
                          "for processing", r['id'])
                routers.remove(r)
                routers.append(r)
968891
def set_settings(instance=None):
    """"""

    global settings

    settings = None

    if instance:
        settings = import_settings(instance)

    elif "INSTANCE_FOR_DYNACONF" in os.environ:
        settings = import_settings(os.environ["INSTANCE_FOR_DYNACONF"])

    elif "FLASK_APP" in os.environ:  # pragma: no cover
        with suppress(ImportError, click.UsageError):
            from flask.cli import ScriptInfo

            flask_app = ScriptInfo().load_app()
            settings = flask_app.config
            click.echo(
                click.style(
                    "Flask app detected", fg="white", bg="bright_black"
                )
            )

    elif "DJANGO_SETTINGS_MODULE" in os.environ:  # pragma: no cover
        sys.path.insert(0, os.path.abspath(os.getcwd()))
        try:
            # Django extension v2
            from django.conf import settings

            settings.DYNACONF.configure()
        except (ImportError, AttributeError):
            # Backwards compatible with old django extension (pre 2.0.0)
            import dynaconf.contrib.django_dynaconf  # noqa
            from django.conf import settings as django_settings

            django_settings.configure()
            settings = django_settings

        if settings is not None:
            click.echo(
                click.style(
                    "Django app detected", fg="white", bg="bright_black"
                )
            )

    if settings is None:
        settings = LazySettings()
853104
def write_nginx_config(self):
        
        log = logging.getLogger('ipsv.models.sites.site')
        if not os.path.exists(self.root):
            log.debug('Creating HTTP root directory: %s', self.root)
            os.makedirs(self.root, 0o755)

        # Generate our server block configuration
        server_block = ServerBlock(self)

        server_config_path = os.path.join(_cfg.get('Paths', 'NginxSitesAvailable'), self.domain.name)
        if not os.path.exists(server_config_path):
            log.debug('Creating new configuration path: %s', server_config_path)
            os.makedirs(server_config_path, 0o755)

        server_config_path = os.path.join(server_config_path, '{fn}.conf'.format(fn=self.slug))
        if os.path.exists(server_config_path):
            log.info('Server block configuration file already exists, overwriting: %s', server_config_path)
            os.remove(server_config_path)

        log.info('Writing Nginx server block configuration file')
        with open(server_config_path, 'w') as f:
            f.write(server_block.template)
222947
def apply(context_scope, locals, &block)
      locals = locals.dup unless locals.nil?

      set_instance_variables!(context_scope, locals)

      reset_settings!
      reset_options!

      eval_source(locals, &block)

      instance_exec(root_object, &block) if block_given?

      self
    end
1004165
def apply_defaults_from_client(args)
      return unless JSS::Client.installed?
      # these settings can come from the jamf binary config, if this machine is a JSS client.
      args[:server] ||= JSS::Client.jss_server
      args[:port] ||= JSS::Client.jss_port.to_i
      args[:use_ssl] ||= JSS::Client.jss_protocol.to_s.end_with? 's'
      args
    end
37611
def apply_settings(settings):
    
    for key, value in settings.items():
        ConfigManager.SETTINGS[key] = value
533954
def load_connection_settings(self):
        """"""
        existing_kernel = CONF.get("existing-kernel", "settings", {})

        connection_file_path = existing_kernel.get("json_file_path", "")
        is_remote = existing_kernel.get("is_remote", False)
        username = existing_kernel.get("username", "")
        hostname = existing_kernel.get("hostname", "")
        port = str(existing_kernel.get("port", 22))
        is_ssh_kf = existing_kernel.get("is_ssh_keyfile", False)
        ssh_kf = existing_kernel.get("ssh_key_file_path", "")

        if connection_file_path != "":
            self.cf.setText(connection_file_path)
        if username != "":
            self.un.setText(username)
        if hostname != "":
            self.hn.setText(hostname)
        if ssh_kf != "":
            self.kf.setText(ssh_kf)
        self.rm_group.setChecked(is_remote)
        self.pn.setText(port)
        self.kf_radio.setChecked(is_ssh_kf)
        self.pw_radio.setChecked(not is_ssh_kf)

        try:
            import keyring
            ssh_passphrase = keyring.get_password("spyder_remote_kernel",
                                                  "ssh_key_passphrase")
            ssh_password = keyring.get_password("spyder_remote_kernel",
                                                "ssh_password")
            if ssh_passphrase:
                self.kfp.setText(ssh_passphrase)
            if ssh_password:
                self.pw.setText(ssh_password)
        except Exception:
            pass
1104083
def network(ip, netmask, gateway):
    '''
    
    '''
    ret = {'name': ip,
           'result': True,
           'changes': {},
           'comment': ''}

    current_network = __salt__['drac.network_info']()
    new_network = {}

    if ip != current_network['IPv4 settings']['IP Address']:
        ret['changes'].update({'IP Address':
                              {'Old': current_network['IPv4 settings']['IP Address'],
                               'New': ip}})

    if netmask != current_network['IPv4 settings']['Subnet Mask']:
        ret['changes'].update({'Netmask':
                              {'Old': current_network['IPv4 settings']['Subnet Mask'],
                               'New': netmask}})

    if gateway != current_network['IPv4 settings']['Gateway']:
        ret['changes'].update({'Gateway':
                              {'Old': current_network['IPv4 settings']['Gateway'],
                               'New': gateway}})

    if __opts__['test']:
        ret['result'] = None
        return ret

    if __salt__['drac.set_network'](ip, netmask, gateway):
        if not ret['changes']:
            ret['comment'] = 'Network is in the desired state'

        return ret

    ret['result'] = False
    ret['comment'] = 'unable to configure network'

    return ret
274069
def set_network_connection(self, network):
        
        mode = network.mask if isinstance(network, self.ConnectionType) else network
        return self.ConnectionType(self._driver.execute(
            Command.SET_NETWORK_CONNECTION, {
                'name': 'network_connection',
                'parameters': {'type': mode}})['value'])