Firewall Rule update routine.

        Function to decode the updated rules and call routines that
        in turn calls the device routines to update rules.
437064
def _fw_rule_update(self, drvr_name, data):
        
        LOG.debug("FW Update %s", data)
        tenant_id = data.get('firewall_rule').get('tenant_id')
        fw_rule = data.get('firewall_rule')
        rule = self._fw_rule_decode_store(data)
        rule_id = fw_rule.get('id')
        if tenant_id not in self.fwid_attr or not (
           self.fwid_attr[tenant_id].is_rule_present(rule_id)):
            LOG.error("Incorrect update info for tenant %s", tenant_id)
            return
        self.fwid_attr[tenant_id].rule_update(rule_id, rule)
        self._check_update_fw(tenant_id, drvr_name)
252280
def _rt_state_update(route_table_id, dcidr, router_ip="(none)",
                     instance_id="(none)", eni_id="(none)",
                     old_router_ip="(none)", msg="(none)"):
    
    buf = "inst: %s, eni: %s, r_ip: %-15s, o_r_ip: %-15s, msg: %s" % \
          (instance_id, eni_id, router_ip, old_router_ip, msg)
    CURRENT_STATE.vpc_state.setdefault('route_tables', {}). \
                            setdefault(route_table_id, {})[dcidr] = buf
201697
def call_and_wrap(func, *args, **kw):
    '''
    '''
    try:
        return func(*args, **kw)
    except api.exceptions.APIException as ex:
        click_exception(ex)
    except urllib3exc.SSLError:
        # see monkey patch above re InsecurePlatformWarning
        if _insecure_warning:
            click.echo(click.style(str(_insecure_warning[0]), fg='red'))
        raise
1347643
def patched_function(self, *args, **kwargs):
        
        result = self.function(*args, **kwargs)
        self.validate(result)
        return result
335946
func (c *Client) UpdateFirewallRule(p *UpdateFirewallRuleParameter) (*FirewallRule, error) {
	obj, err := c.Request("updateFirewallRule", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*FirewallRule), err
}
1107847
def create_firewall_rule(self, server, firewall_rule_body):
        
        server_uuid, server_instance = uuid_and_instance(server)

        url = '/server/{0}/firewall_rule'.format(server_uuid)
        body = {'firewall_rule': firewall_rule_body}
        res = self.post_request(url, body)

        return FirewallRule(server=server_instance, **res['firewall_rule'])
1299894
def update_fw_local_router(self, net_id, subnet_id, router_id, os_result):
        
        fw_dict = self.get_fw_dict()
        fw_dict.update({'router_id': router_id, 'router_net_id': net_id,
                        'router_subnet_id': subnet_id})
        self.store_dummy_router_net(net_id, subnet_id, router_id)
        self.update_fw_local_result(os_result=os_result)
778233
def update(self, name=None, algorithm=None, protocol=None, halfClosed=None,
            port=None, timeout=None, httpsRedirect=None):
        
        return self.manager.update(self, name=name, algorithm=algorithm,
                protocol=protocol, halfClosed=halfClosed, port=port,
                timeout=timeout, httpsRedirect=httpsRedirect)
630863
def _get_firewall_rules(firewall_rules):
    '''
    
    '''
    ret = []
    for key, value in six.iteritems(firewall_rules):
        # Verify the required 'protocol' property is present in the cloud
        # profile config
        if 'protocol' not in firewall_rules[key].keys():
            raise SaltCloudConfigError(
                'The firewall rule \'{0}\' is missing \'protocol\''.format(key)
            )
        ret.append(FirewallRule(
            name=key,
            protocol=firewall_rules[key].get('protocol', None),
            source_mac=firewall_rules[key].get('source_mac', None),
            source_ip=firewall_rules[key].get('source_ip', None),
            target_ip=firewall_rules[key].get('target_ip', None),
            port_range_start=firewall_rules[key].get('port_range_start', None),
            port_range_end=firewall_rules[key].get('port_range_end', None),
            icmp_type=firewall_rules[key].get('icmp_type', None),
            icmp_code=firewall_rules[key].get('icmp_code', None)
        ))

    return ret
845178
public OperationFuture<FirewallPolicy> update(FirewallPolicy firewallPolicy, FirewallPolicyConfig config) {
        FirewallPolicyMetadata metadata = findByRef(firewallPolicy);

        firewallPolicyClient.update(
            metadata.getDataCenterId(),
            metadata.getId(),
            composeFirewallPolicyRequest(config)
        );

        return new OperationFuture<>(
            firewallPolicy,
            new NoWaitingJobFuture()
        );
    }
491127
def firmware_updates(self, firmware_updates):
        
        if firmware_updates is None:
            raise ValueError("Invalid value for `firmware_updates`, must not be `None`")
        if firmware_updates is not None and firmware_updates < 0:
            raise ValueError("Invalid value for `firmware_updates`, must be a value greater than or equal to `0`")

        self._firmware_updates = firmware_updates
1365542
def updatephysicalport(update_processor = partial(default_processor, excluding=('vhost', 'systemid',
                                                                                   'bridge', 'name'),
                                                                     disabled=('physicalnetwork',)),
                       reorder_dict = default_iterate_dict
                      ):
    
    def walker(walk, write, timestamp, parameters_dict):
        for key, parameters in reorder_dict(parameters_dict):
            try:
                value = walk(key)
            except KeyError:
                pass
            else:
                if update_processor(value, walk, write, parameters=parameters):
                    write(key, value)
    return walker
1369456
def update_vpnservice(self, vpnservice, desc):
        '''
        
        '''
        vpnservice_id = self._find_vpnservice_id(vpnservice)
        body = {'description': desc}
        return self.network_conn.update_vpnservice(vpnservice_id,
                                                   body={'vpnservice': body})
873921
def update_firewall(self, firewall, body=None):
        """"""
        return self.put(self.firewall_path % (firewall), body=body)
1202507
async function handleLog(log, rule, contractVersion, context) {
  log.decoded = web3.eth.abi.decodeLog(
    rule.eventAbi.inputs,
    log.data,
    log.topics.slice(1)
  )
  log.contractName = contractVersion.contractName
  log.eventName = rule.eventName
  log.contractVersionKey = contractVersion.versionKey
  log.networkId = context.networkId

  console.log(
    `Processing log \
    blockNumber=${log.blockNumber} \
    transactionIndex=${log.transactionIndex} \
    eventName=${log.eventName} \
    contractName=${log.contractName}`
  )

  // Note: we run the rule with a retry since we've seen in production cases where we fail loading
  // from smart contracts the data pointed to by the event. This may occur due to load balancing
  // across ethereum nodes and if some nodes are lagging. For example the ethereum node we
  // end up connecting to for reading the data may lag compared to the node received the event from.
  let ruleResults = undefined
  await withRetrys(async () => {
    ruleResults = await rule.ruleFn(log)
  })

  const output = {
    log: log,
    related: ruleResults
  }

  const json = JSON.stringify(output, null, 2)
  if (context.config.verbose) {
    console.log(json)
    console.log('\n----\n')
  }

  const userAddress = log.decoded.party
  const ipfsHash = log.decoded.ipfsHash

  //TODO: remove binary data from pictures in a proper way.
  const listing = output.related.listing
  delete listing.ipfs.data.pictures
  const listingId = listing.id

  // Data consistency: check  listingId from the JSON stored in IPFS
  // matches with listingID emitted in the event.
  // TODO: use method utils/id.js:parseListingId
  // DVF: this should really be handled in origin js - origin.js should throw
  // an error if this happens.
  const ipfsListingId = listingId.split('-')[2]
  if (ipfsListingId !== log.decoded.listingID) {
    throw `ListingId mismatch: ${ipfsListingId} !== ${log.decoded.listingID}`
  }

  // TODO: This kind of verification logic should live in origin.js
  if(output.related.listing.ipfs.data.price === undefined){
    return
  }

  if (context.config.elasticsearch) {
    console.log('INDEXING ', listingId)
    await withRetrys(async () => {
      await search.Listing.index(
        listingId,
        userAddress,
        ipfsHash,
        listing
      )
    })
    if (output.related.offer !== undefined) {
      const offer = output.related.offer
      await withRetrys(async () => {
        await search.Offer.index(offer, listing)
      })
    }
    if (output.related.seller !== undefined) {
      await withRetrys(async () => {
        await search.User.index(output.related.seller)
      })
    }
    if (output.related.buyer !== undefined) {
      await withRetrys(async () => {
        await search.User.index(output.related.buyer)
      })
    }
  }

  if (context.config.db) {
    await withRetrys(async () => {
      await db.Listing.insert(
        listingId,
        userAddress,
        ipfsHash,
        listing.ipfs.data
      )
    })
  }

  if (context.config.webhook) {
    console.log('\n-- WEBHOOK to ' + context.config.webhook + ' --\n')
    await withRetrys(async () => {
      await postToWebhook(context.config.webhook, json)
    })
  }
}
700516
def call_contract_function(
        web3,
        address,
        normalizers,
        function_identifier,
        transaction,
        block_id=None,
        contract_abi=None,
        fn_abi=None,
        *args,
        **kwargs):
    
    call_transaction = prepare_transaction(
        address,
        web3,
        fn_identifier=function_identifier,
        contract_abi=contract_abi,
        fn_abi=fn_abi,
        transaction=transaction,
        fn_args=args,
        fn_kwargs=kwargs,
    )

    if block_id is None:
        return_data = web3.eth.call(call_transaction)
    else:
        return_data = web3.eth.call(call_transaction, block_identifier=block_id)

    if fn_abi is None:
        fn_abi = find_matching_fn_abi(contract_abi, function_identifier, args, kwargs)

    output_types = get_abi_output_types(fn_abi)

    try:
        output_data = decode_abi(output_types, return_data)
    except DecodingError as e:
        # Provide a more helpful error message than the one provided by
        # eth-abi-utils
        is_missing_code_error = (
            return_data in ACCEPTABLE_EMPTY_STRINGS and
            web3.eth.getCode(address) in ACCEPTABLE_EMPTY_STRINGS
        )
        if is_missing_code_error:
            msg = (
                "Could not transact with/call contract function, is contract "
                "deployed correctly and chain synced?"
            )
        else:
            msg = (
                "Could not decode contract function call {} return data {} for "
                "output_types {}".format(
                    function_identifier,
                    return_data,
                    output_types
                )
            )
        raise BadFunctionCallOutput(msg) from e

    _normalizers = itertools.chain(
        BASE_RETURN_NORMALIZERS,
        normalizers,
    )
    normalized_data = map_abi_data(_normalizers, output_types, output_data)

    if len(normalized_data) == 1:
        return normalized_data[0]
    else:
        return normalized_data
551137
def update_rules(self):
        
        if self.config.offline or not self.config.auto_update:
            logger.debug("Bypassing rule update due to config "
                "running in offline mode or auto updating turned off.")
        else:
            return client.update_rules(self.config, self.connection)