コード例 #1
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        # Get the host group name
        if self.args.host_group_name is not None:
            self.host_group_name = self.args.host_group_name

        # Get the list of sources separated by commas
        if self.args.sources is not None:
            self.sources = self.args.sources

        payload = {}
        if self.host_group_name is not None:
            payload['name'] = self.host_group_name

        if self.sources is not None:
            source_list = str.split(self.sources, ',')
            if 'hostnames' not in payload:
                payload['hostnames'] = []

            for s in source_list:
                payload['hostnames'].append(s)
        self.data = json.dumps(payload, sort_keys=True)
        self.headers = {'Content-Type': 'application/json', "Accept": "application/json"}
コード例 #2
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.metricName is not None:
            self.metricName = self.args.metricName

        if self.args.measurement is not None:
            self.measurement = self.args.measurement

        if self.args.source is not None:
            self.source = self.args.source
        else:
            self.source = socket.gethostname()

        if self.args.timestamp is not None:
            self.timestamp = int(self.args.timestamp)

        m = {'metric': self.metricName,
             'measure': self.measurement}

        if self.source is not None:
            m['source'] = self.source
        if self.timestamp is not None:
            m['timestamp'] = int(self.timestamp)

        self._process_properties()

        if self._properties is not None:
            m['metadata'] = self._properties

        self.data = json.dumps(m, sort_keys=True)
        self.headers = {'Content-Type': 'application/json', "Accept": "application/json"}
コード例 #3
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.file is not None:
            self._file = self.args.path

        self.path = 'v1/relays/{0}/config'.format(self._meter)
コード例 #4
0
 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     if self.args.pluginName is not None:
         self.pluginName = self.args.pluginName
コード例 #5
0
 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     if self.args.hostGroupName is not None:
         self.url_parameters = {"name": self.args.hostGroupName}
コード例 #6
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        # Get the host group name
        if self.args.host_group_name is not None:
            self.host_group_name = self.args.host_group_name

        # Get the list of sources separated by commas
        if self.args.sources is not None:
            self.sources = self.args.sources

        payload = {}
        if self.host_group_name is not None:
            payload['name'] = self.host_group_name

        if self.sources is not None:
            source_list = str.split(self.sources, ',')
            if 'hostnames' not in payload:
                payload['hostnames'] = []

            for s in source_list:
                payload['hostnames'].append(s)
        self.data = json.dumps(payload, sort_keys=True)
        self.headers = {
            'Content-Type': 'application/json',
            "Accept": "application/json"
        }
コード例 #7
0
ファイル: plugin_base.py プロジェクト: boundary/pulse-api-cli
 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     if self.args.pluginName is not None:
         self.pluginName = self.args.pluginName
コード例 #8
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.file is not None:
            self._file = self.args.path

        self.path = 'v1/relays/{0}/config'.format(self._meter)
コード例 #9
0
    def get_arguments(self):

        ApiCli.get_arguments(self)

        if self.args.metric_manifest_path is not None:
            self.metric_manifest_path = self.args.metric_manifest_path

        if self.args.metric_manifest_path is not None:
            self.plugin_manifest_path = self.args.metric_manifest_path
コード例 #10
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.hostGroupId is not None:
            self.hostGroupId = self.args.hostGroupId

        self.path = "v1/hostgroup/{0}".format(str(self.hostGroupId))
コード例 #11
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.hostGroupId is not None:
            self.hostGroupId = self.args.hostGroupId

        self.path = "v1/hostgroup/{0}".format(str(self.hostGroupId))
コード例 #12
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        self._meter = self.args.meter if self.args.meter is not None else None
        self._since = self.args.since if self.args.since is not None else None
        self._raw = self.args.raw if self.args.raw is not None else None

        self.method = 'GET'
        self.path = 'v1/relays/{0}/output/{1}'.format(self._meter, self._since)
コード例 #13
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.pluginName is not None:
            self.pluginName = self.args.pluginName

        self.path = "v1/plugins/{0}/components".format(self.pluginName)
コード例 #14
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        self._meter = self.args.meter if self.args.meter is not None else None
        self._since = self.args.since if self.args.since is not None else None
        self._raw = self.args.raw if self.args.raw is not None else None

        self.method = 'GET'
        self.path = 'v1/relays/{0}/output/{1}'.format(self._meter, self._since)
コード例 #15
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.metric_name is not None:
            self._metric_name = self.args.metric_name

        self.path = "v1/metrics/{0}".format(self._metric_name)
コード例 #16
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.control is not None:
            self._control = self.args.control
        if self.args.metrics is not None:
            self._metrics = self.args.metrics
        if self.args.plugins is not None:
            self._plugins = self.args.plugins
コード例 #17
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.plugin_name is not None:
            self.plugin_name = self.args.plugin_name

        self.path = "v1/plugins/{0}".format(self.plugin_name)
コード例 #18
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.file_path is None:
            self.file_path = 'plugin.json'
        else:
            self.file_path = self.args.file_path

        self.path = "v1/metrics"

        self.load()
コード例 #19
0
    def get_arguments(self):
        ApiCli.get_arguments(self)

        if self.args.file_path is None:
            self.file_path = 'plugin.json'
        else:
            self.file_path = self.args.file_path

        self.path = "v1/metrics"

        self.load()
コード例 #20
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        if self.args.tenant_id is not None:
            self._tenant_id = self.args.tenant_id

        if self.args.fingerprint_fields is not None:
            self._fingerprint_fields = self.args.fingerprint_fields

        if self.args.title is not None:
            self._title = self.args.title

        if self.args.source is not None:
            self._source = self.args.source

        if self.args.severity is not None:
            self._severity = self.args.severity

        if self.args.message is not None:
            self._message = self.args.message

        event = {}

        if self._title is not None:
            event['title'] = self._title

        if self._severity is not None:
            event['severity'] = self._severity

        if self._message is not None:
            event['message'] = self._message

        if self._source is not None:
            if 'source' not in event:
                event['source'] = {}
            if len(self._source) >= 1:
                event['source']['ref'] = self._source[0]
            if len(self._source) >= 2:
                event['source']['type'] = self._source[1]

        self._process_properties(self.args.properties)
        if self._properties is not None:
            event['properties'] = self._properties

        if self._fingerprint_fields is not None:
            event['fingerprintFields'] = self._fingerprint_fields

        self.data = json.dumps(event, sort_keys=True)
        self.headers = {'Content-Type': 'application/json'}
コード例 #21
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        if self.args.tenant_id is not None:
            self._tenant_id = self.args.tenant_id

        if self.args.fingerprint_fields is not None:
            self._fingerprint_fields = self.args.fingerprint_fields

        if self.args.title is not None:
            self._title = self.args.title

        if self.args.source is not None:
            self._source = self.args.source

        if self.args.severity is not None:
            self._severity = self.args.severity

        if self.args.message is not None:
            self._message = self.args.message

        event = {}

        if self._title is not None:
            event['title'] = self._title

        if self._severity is not None:
            event['severity'] = self._severity

        if self._message is not None:
            event['message'] = self._message

        if self._source is not None:
            if 'source' not in event:
                event['source'] = {}
            if len(self._source) >= 1:
                event['source']['ref'] = self._source[0]
            if len(self._source) >= 2:
                event['source']['type'] = self._source[1]

        self._process_properties(self.args.properties)
        if self._properties is not None:
            event['properties'] = self._properties

        if self._fingerprint_fields is not None:
            event['fingerprintFields'] = self._fingerprint_fields

        self.data = json.dumps(event, sort_keys=True)
        self.headers = {'Content-Type': 'application/json'}
コード例 #22
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.metric_name is not None:
            self._metric_name = self.args.metric_name

        if self.args.sample is not None:
            self.sample = self.args.sample

        if self.args.source is not None:
            self.source = self.args.source
        else:
            self.source = None

        if self.args.aggregate is not None:
            self.aggregate = self.args.aggregate
        else:
            self.aggregate = "avg"

        if self.args.format is not None:
            self.format = self.args.format
        else:
            self.format = "json"

        if self.args.date_format is not None:
            self.date_format = self.args.date_format

        start_time = int(self.parse_time_date(self.args.start).strftime("%s"))

        # If the end time is not specified then
        # default to the current time
        if self.args.end is None:
            stop_time = int(self.now.strftime("%s"))
        else:
            stop_time = int(self.parse_time_date(self.args.end).strftime("%s"))

        # Convert to epoch time in milli-seconds
        start_time *= 1000
        stop_time *= 1000

        self.path = "v1/measurements/{0}".format(self._metric_name)
        url_parameters = {
            "start": str(start_time),
            "end": str(stop_time),
            "sample": str(self.sample),
            "agg": self.aggregate
        }
        if self.source is not None:
            url_parameters['source'] = self.source
        self.url_parameters = url_parameters
コード例 #23
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.metric_name is not None:
            self._metric_name = self.args.metric_name

        if self.args.sample is not None:
            self.sample = self.args.sample

        if self.args.source is not None:
            self.source = self.args.source
        else:
            self.source = None

        if self.args.aggregate is not None:
            self.aggregate = self.args.aggregate
        else:
            self.aggregate = "avg"

        if self.args.format is not None:
            self.format = self.args.format
        else:
            self.format = "json"

        if self.args.date_format is not None:
            self.date_format = self.args.date_format

        start_time = int(self.parse_time_date(self.args.start).strftime("%s"))

        # If the end time is not specified then
        # default to the current time
        if self.args.end is None:
            stop_time = int(self.now.strftime("%s"))
        else:
            stop_time = int(self.parse_time_date(self.args.end).strftime("%s"))

        # Convert to epoch time in milli-seconds
        start_time *= 1000
        stop_time *= 1000

        self.path = "v1/measurements/{0}".format(self._metric_name)
        url_parameters = {"start": str(start_time),
                          "end": str(stop_time),
                          "sample": str(self.sample),
                          "agg": self.aggregate}
        if self.source is not None:
            url_parameters['source'] = self.source
        self.url_parameters = url_parameters
コード例 #24
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.hostGroupId is not None:
            self.hostGroupId = self.args.hostGroupId
        if self.args.force is not None:
            self.force = self.args.force

        if self.force:
            self.url_parameters = {"forceRemove": True}

        self.path = "v1/hostgroup/{0}".format(str(self.hostGroupId))
コード例 #25
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)
        if self.args.hostGroupId is not None:
            self.hostGroupId = self.args.hostGroupId
        if self.args.force is not None:
            self.force = self.args.force

        if self.force:
            self.url_parameters = {"forceRemove": True}

        self.path = "v1/hostgroups/{0}".format(str(self.hostGroupId))
コード例 #26
0
    def get_arguments(self):
        """
        """
        ApiCli.get_arguments(self)

        if self.args.meter is not None:
            self.meter = self.args.meter

        if self.args.since is not None:
            self.since = self.args.since

        self.path = 'v1/relays/{0}/config'.format(self.meter)

        if self.since is not None:
            self.url_parameters = {"since": self.since}
コード例 #27
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        self._actions = self.args.actions if self.args.actions is not None else None
        self._alarm_name = self.args.alarm_name if self.args.alarm_name is not None else None

        self._metric = self.args.metric if self.args.metric is not None else None
        self._aggregate = self.args.aggregate if self.args.aggregate is not None else None
        self._operation = self.args.operation if self.args.operation is not None else None
        self._threshold = self.args.threshold if self.args.threshold is not None else None
        self._trigger_interval = self.args.trigger_interval if self.args.trigger_interval is not None else None
        self._host_group_id = self.args.host_group_id if self.args.host_group_id is not None else None
        self._note = self.args.note if self.args.note is not None else None
        self._per_host_notify = self.args.per_host_notify if self.args.per_host_notify is not None else None
        self._is_disabled = self.args.is_disabled if self.args.is_disabled is not None else None
        self._notify_clear = self.args.notify_clear if self.args.notify_clear is not None else None
        self._notify_set = self.args.notify_set if self.args.notify_set is not None else None
        self._timeout_interval = self.args.timeout_interval if self.args.timeout_interval is not None else None
コード例 #28
0
    def get_arguments(self):
        """
        Extracts the specific arguments of this CLI
        """
        ApiCli.get_arguments(self)

        self._actions = self.args.actions if self.args.actions is not None else None
        self._alarm_name = self.args.alarm_name if self.args.alarm_name is not None else None

        self._metric = self.args.metric if self.args.metric is not None else None
        self._aggregate = self.args.aggregate if self.args.aggregate is not None else None
        self._operation = self.args.operation if self.args.operation is not None else None
        self._threshold = self.args.threshold if self.args.threshold is not None else None
        self._trigger_interval = self.args.trigger_interval if self.args.trigger_interval is not None else None
        self._host_group_id = self.args.host_group_id if self.args.host_group_id is not None else None
        self._note = self.args.note if self.args.note is not None else None
        self._per_host_notify = self.args.per_host_notify if self.args.per_host_notify is not None else None
        self._is_disabled = self.args.is_disabled if self.args.is_disabled is not None else None
        self._notify_clear = self.args.notify_clear if self.args.notify_clear is not None else None
        self._notify_set = self.args.notify_set if self.args.notify_set is not None else None
        self._timeout_interval = self.args.timeout_interval if self.args.timeout_interval is not None else None
コード例 #29
0
 def get_arguments(self):
     """
     Extracts the specific arguments of this CLI
     """
     ApiCli.get_arguments(self)
     self._alarm_id = self.args.alarm_id if self.args.alarm_id is not None else None