Process subnet create event.
968302
def subnet_create_event(self, subnet_info):
        """"""

        subnet = subnet_info.get('subnet')
        if subnet:
            self.create_subnet(subnet)
        else:
            # Check whether request is for subnets.
            subnets = subnet_info.get('subnets')
            if subnets:
                for subnet in subnets:
                    self.create_subnet(subnet)
499143
def _process_added_port_event(self, port_name):
        """"""
        LOG.info("Hyper-V VM vNIC added: %s", port_name)
        self._added_ports.add(port_name)
645683
def start(cls, originator_id, quorum_size, network_uid):
        
        assert isinstance(quorum_size, int), "Not an integer: {}".format(quorum_size)
        return cls.__create__(
            event_class=cls.Started,
            originator_id=originator_id,
            quorum_size=quorum_size,
            network_uid=network_uid
        )
582752
def process_events(events, source_ip):
    """"""
    s3 = boto3.resource('s3')
    table = boto3.resource("dynamodb").Table(os.environ['database'])
    with table.batch_writer() as batch:
        for idx, event in enumerate(events):
            event = convert_keys_to_string(event)
            event['sourceIp'] = source_ip
            event['event'] = hashlib.sha256(str(event)).hexdigest()
            metadata = event['metadata']
            timestamp = str(event['metadata']['timeStamp'])
            event['metadata']['timeStamp'] = timestamp
            kwargs = {'match': event['indicatorMatch'],
                      'type': metadata['type'],
                      'method': metadata['method'].lower(),
                      'time': event['analysisTime'], 'ip': source_ip}
            file_struct = '{match}_{type}_{method}_{ip}_{time}.json'
            file_name = file_struct.format(**kwargs)
            key_path = '/tmp/%s' % file_name
            output = json.dumps(event, indent=4, sort_keys=True)
            open(key_path, "w").write(output)
            data = open(key_path, 'rb')
            s3.Bucket(os.environ['s3_bucket']).put_object(Key=file_name,
                                                          Body=data)
            logger.info("EVENT: %s" % str(event))
            batch.put_item(Item=event)
    return True
278518
def process_events(self):
        """"""
        for event, args in iter_except(self.event_queue.popleft, IndexError):
            for callback in self.event_callbacks[event]:
                callback(*args)
967124
def create_event(self, timestamp, event_type, hostname, fields, tags=None):
        
        # Agent6 expects a specific set of fields, so we need to place all
        # extra fields in the msg_title and let the Datadog backend separate them
        # Any remaining fields that aren't a part of the datadog-agent payload
        # specification will be dropped.
        event_payload = fields._asdict()

        msg_text = {
            'event_type': event_payload.pop('event_type', None),
            'event_soft_hard': event_payload.pop('event_soft_hard', None),
            'check_name': event_payload.pop('check_name', None),
            'event_state': event_payload.pop('event_state', None),
            'payload': event_payload.pop('payload', None),
            'ack_author': event_payload.pop('ack_author', None),
        }

        msg_text = json.dumps(msg_text)
        self.log.info("Nagios Event pack: {}".format(msg_text))

        event_payload.update(
            {
                'timestamp': timestamp,
                'event_type': event_type,
                'msg_text': msg_text,
                'source_type_name': SOURCE_TYPE_NAME,
                'tags': tags,
            }
        )

        # if host is localhost, turn that into the internal host name
        host = event_payload.get('host', None)
        if host == "localhost":
            event_payload["host"] = hostname
        return event_payload
888370
def _make_event(self, value):  # pylint: disable=arguments-differ
        """"""
        super(SystemLED, self)._make_event(
            self._led_type_code,
            self.code,
            value)
406566
def on_created(self, event):
        
        self._logger.debug('Detected create event on watched path: %s', event.src_path)

        self._process_event(event)
551785
private void handleCreate(final NetworkContext context) {
    log.debug(String.format("%s - Network configuration created in cluster: %s", NetworkManager.this, cluster.address()));
    log.debug(String.format("%s - Scheduling network deployment task", NetworkManager.this));
    tasks.runTask(new Handler<Task>() {
      @Override
      public void handle(final Task task) {
        currentContext = context;

        // Any time the network is being reconfigured, unready the network.
        // This will cause components to pause during the reconfiguration.
        unready(new Handler<AsyncResult<Void>>() {
          @Override
          public void handle(AsyncResult<Void> result) {
            if (result.failed()) {
              log.error(result.cause());
              task.complete();
            } else {
              deployNetwork(context, new Handler<AsyncResult<NetworkContext>>() {
                @Override
                public void handle(AsyncResult<NetworkContext> result) {
                  task.complete();
                  if (result.failed()) {
                    log.error(result.cause());
                  } else {
                    log.info(String.format("%s - Successfully deployed network", NetworkManager.this));
                  }
                }
              });
            }
          }
        });
      }
    });
  }
404937
def _configure_subnet(config):
    """"""

    # Rationale: avoid subnet lookup if the network is already
    # completely manually configured
    if ("networkInterfaces" in config["head_node"]
            and "networkInterfaces" in config["worker_nodes"]):
        return config

    subnets = _list_subnets(config)

    if not subnets:
        raise NotImplementedError("Should be able to create subnet.")

    # TODO: make sure that we have usable subnet. Maybe call
    # compute.subnetworks().listUsable? For some reason it didn't
    # work out-of-the-box
    default_subnet = subnets[0]

    if "networkInterfaces" not in config["head_node"]:
        config["head_node"]["networkInterfaces"] = [{
            "subnetwork": default_subnet["selfLink"],
            "accessConfigs": [{
                "name": "External NAT",
                "type": "ONE_TO_ONE_NAT",
            }],
        }]

    if "networkInterfaces" not in config["worker_nodes"]:
        config["worker_nodes"]["networkInterfaces"] = [{
            "subnetwork": default_subnet["selfLink"],
            "accessConfigs": [{
                "name": "External NAT",
                "type": "ONE_TO_ONE_NAT",
            }],
        }]

    return config
1138128
private void processPartitionWatchEvent() throws KeeperException, InterruptedException {
        try {
            m_zk.create(m_rootNode, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            m_zk.getData(m_rootNode, m_childWatch, null);
        } catch (KeeperException.NodeExistsException e) {
            m_zk.getData(m_rootNode, m_childWatch, null);
        }
    }
816743
def process_event(self, name, subject, data):
        
        method_mapping = Registry.get_event(name)
        if not method_mapping:
            log.info('@{}.process_event no subscriber for event `{}`'
                     .format(self.__class__.__name__, name))
            return
        for event, methods in method_mapping.items():
            event_instance = event(subject, data)
            log.info('@{}.process_event `{}` for subject `{}`'.format(
                self.__class__.__name__,
                event_instance.__class__.__name__,
                subject
            ))
            for method in methods:
                with self._context_manager:
                    log.info('>> Calling subscriber `{}`'
                             .format(method.__name__))
                    method(event_instance)
197990
def create(cls, receiver_id, user_id=None):
        """"""
        event = cls(id=uuid.uuid4(), receiver_id=receiver_id, user_id=user_id)
        event.payload = event.receiver.extract_payload()
        return event
203203
def handle_subports(self, subports, event_type):
        """"""

        LOG.debug("Subports event received: %(event_type)s. "
                  "Subports: %(subports)s",
                  {'event_type': event_type, 'subports': subports})

        # update the cache.
        if event_type == events.CREATED:
            for subport in subports:
                trunk = self._trunks.get(subport['trunk_id'])
                if trunk:
                    trunk.sub_ports.append(subport)
        elif event_type == events.DELETED:
            for subport in subports:
                trunk = self._trunks.get(subport['trunk_id'])
                if trunk and subport in trunk.sub_ports:
                    trunk.sub_ports.remove(subport)

        # update the bound trunks.
        affected_trunk_ids = set([s['trunk_id'] for s in subports])
        for trunk_id in affected_trunk_ids:
            trunk = self._trunks.get(trunk_id)
            if trunk:
                self._setup_trunk(trunk)
765442
void performPostCreationTasks()
    {
        StatusAction statusAction = new StatusAction();
        try
        {
            ResponseEvents events = CoherentManagerConnection.sendEventGeneratingAction(statusAction, 1000);
            for (ResponseEvent event : events.getEvents())
            {
                if (event instanceof StatusEvent)
                {
                    // do nothing. Creating the events will register the
                    // channels, which is after all what we are trying to do.
                }
            }

        }
        catch (IllegalArgumentException | IllegalStateException | IOException | TimeoutException e)
        {
            logger.error(e, e);
        }

    }
1075025
def network_create(provider, names, **kwargs):
    '''
    

    '''
    client = _get_client()
    return client.extra_action(provider=provider, names=names, action='network_create', **kwargs)
64025
def trigger_event(self, module_name, event):
        
        if module_name:
            self._py3_wrapper.events_thread.process_event(module_name, event)