.. versionadded:: 2019.2.0

    Performs the action as called from ``port_add_policy`` or ``port_delete_policy``.

    Returns the result of the call to semanage.
550520
def _port_add_or_delete_policy(action, name, sel_type=None, protocol=None, port=None, sel_range=None):
    '''
    
    '''
    if action not in ['add', 'delete']:
        raise SaltInvocationError('Actions supported are "add" and "delete", not "{0}".'.format(action))
    if action == 'add' and not sel_type:
        raise SaltInvocationError('SELinux Type is required to add a policy')
    (protocol, port) = _parse_protocol_port(name, protocol, port)
    cmd = 'semanage port --{0} --proto {1}'.format(action, protocol)
    if sel_type:
        cmd += ' --type {0}'.format(sel_type)
    if sel_range:
        cmd += ' --range {0}'.format(sel_range)
    cmd += ' {0}'.format(port)
    return __salt__['cmd.run_all'](cmd)
1137830
def delete_policy_for_vhost(self, vhost, name):
        
        self._api_delete('/api/policies/{0}/{1}/'.format(
            urllib.parse.quote_plus(vhost),
            urllib.parse.quote_plus(name),
        ))
261069
def add_port_fwd(zone, src, dest, proto='tcp', dstaddr='', permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --add-forward-port=port={1}:proto={2}:toport={3}:toaddr={4}'.format(
        zone,
        src,
        proto,
        dest,
        dstaddr
    )

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd)
124613
def delete_port_if_removed(self, port):
        """"""
        instance_type = self.get_instance_type(port)
        if not instance_type:
            return
        port_type = instance_type + a_const.PORT_SUFFIX
        if not db_lib.port_provisioned(port['id']):
            p_res = MechResource(port['id'], port_type, a_const.DELETE)
            self.provision_queue.put(p_res)
888155
def add_port_profile_to_delete_table(self, profile_name, device_id):
        """"""
        if not self.has_port_profile_to_delete(profile_name, device_id):
            port_profile = ucsm_model.PortProfileDelete(
                profile_id=profile_name, device_id=device_id)
            with self.session.begin(subtransactions=True):
                self.session.add(port_profile)
            return port_profile
232003
def make_action(app_factory, hostname='localhost', port=5000,
                threaded=False, processes=1, stream=None,
                sort_by=('time', 'calls'), restrictions=()):
    
    def action(hostname=('h', hostname), port=('p', port),
               threaded=threaded, processes=processes):
        """Start a new development server."""
        from werkzeug.serving import run_simple
        app = ProfilerMiddleware(app_factory(), stream, sort_by, restrictions)
        run_simple(hostname, port, app, False, None, threaded, processes)
    return action
802056
def policy(self):
        
        if self.accepted_ports:
            return 'accept ' + ','.join(map(str, self.accepted_ports))
        elif self.rejected_ports:
            return 'reject ' + ','.join(map(str, self.rejected_ports))
        else:
            return ''
1179787
def execute_policy(self, scaling_group, policy):
        
        return self._manager.execute_policy(scaling_group=scaling_group,
                policy=policy)
115032
def enable(self, policy):
        
        if hasattr(policy, 'href'):
            if not isinstance(policy, InterfacePolicy):
                raise LoadPolicyFailed('Invalid policy type specified. The policy'
                    'type must be InterfacePolicy')
                
        self.update(l2_interface_policy_ref=element_resolver(policy))
538213
def record_udp_port(self, port):
        

        if port not in self._used_udp_ports:
            self._used_udp_ports.add(port)
530845
def default_policy(policy='deny', direction='incoming'):
    
    if policy not in ['allow', 'deny', 'reject']:
        raise UFWError(('Unknown policy %s, valid values: '
                        'allow, deny, reject') % policy)

    if direction not in ['incoming', 'outgoing', 'routed']:
        raise UFWError(('Unknown direction %s, valid values: '
                        'incoming, outgoing, routed') % direction)

    output = subprocess.check_output(['ufw', 'default', policy, direction],
                                     universal_newlines=True,
                                     env={'LANG': 'en_US',
                                          'PATH': os.environ['PATH']})
    hookenv.log(output, level='DEBUG')

    m = re.findall("^Default %s policy changed to '%s'\n" % (direction,
                                                             policy),
                   output, re.M)
    if len(m) == 0:
        hookenv.log("ufw couldn't change the default policy to %s for %s"
                    % (policy, direction), level='WARN')
        return False
    else:
        hookenv.log("ufw default policy for %s changed to %s"
                    % (direction, policy), level='INFO')
        return True
1294677
def delete_port(self, port):
        '''
        
        '''
        port_id = self._find_port_id(port)
        ret = self.network_conn.delete_port(port=port_id)
        return ret if ret else True
407915
def Delete(self):
		

		self.public_ip.ports = [o for o in self.public_ip.ports if o!=self]

		return(self.public_ip.Update())
256238
def remove_port(zone, port, permanent=True):
    '''
    
    '''
    cmd = '--zone={0} --remove-port={1}'.format(zone, port)

    if permanent:
        cmd += ' --permanent'

    return __firewall_cmd(cmd)
1281862
def register_actions(self, shortcut_manager):
        
        shortcut_manager.add_callback_for_action("delete", self.trans_list_ctrl.remove_action_callback)
        shortcut_manager.add_callback_for_action("add", self.trans_list_ctrl.add_action_callback)
866481
def slas_policy_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/slas/policies"
        return self.call(api_path, method="POST", data=data, **kwargs)
843962
def policy(self, args):
        

        word = args[0]
        if word == 'reject':
            self.accepted_ports = None
            self.rejected_ports = []
            target = self.rejected_ports

        elif word == 'accept':
            self.accepted_ports = []
            self.rejected_ports = None
            target = self.accepted_ports

        else:
            raise RuntimeError("Don't understand policy word \"%s\"" % word)

        for port in args[1].split(','):
            if '-' in port:
                (a, b) = port.split('-')
                target.append(PortRange(int(a), int(b)))
            else:
                target.append(int(port))