def test_make_it(self): sot = status.FloatingIPEvent(**EXAMPLE_LOG) self.assertEqual( format.TimeTMsStr().deserialize(EXAMPLE_LOG['start_time']), sot.start_time), self.assertEqual( format.TimeTMsStr().deserialize(EXAMPLE_LOG['end_time']), sot.end_time), self.assertEqual(EXAMPLE_LOG['status'], sot.status) self.assertEqual(EXAMPLE_LOG['trigger_bps'], sot.trigger_bps) self.assertEqual(EXAMPLE_LOG['trigger_pps'], sot.trigger_pps) self.assertEqual(EXAMPLE_LOG['trigger_http_pps'], sot.trigger_http_pps)
def take_action(self, parsed_args): client = self.app.client_manager.cts query = {} if parsed_args.service_type: query['service_type'] = parsed_args.service_type if parsed_args.resource_type: query['res_type'] = parsed_args.resource_type if parsed_args.resource_id: query['res_id'] = parsed_args.resource_id if parsed_args.resource_name: query['res_name'] = parsed_args.resource_name if parsed_args.trace_name: query['trace_name'] = parsed_args.trace_name if parsed_args.trace_id: query['trace_id'] = parsed_args.trace_id if parsed_args.level: query['level'] = parsed_args.level if parsed_args.user: query['user'] = parsed_args.user if parsed_args.limit: query['limit'] = parsed_args.limit if parsed_args.next: query['next'] = parsed_args.next if parsed_args.start_time: query['from'] = format.TimeTMsStr().serialize( parsed_args.start_time) if parsed_args.end_time: query['to'] = format.TimeTMsStr().serialize(parsed_args.end_time) data = client.traces(tracker=parsed_args.tracker, **query) columns = () if not parsed_args.long: columns = self.columns else: columns = ('id', 'name', 'type', 'user', 'service_type', 'resource_type', 'resource_name', 'resource_id', 'source_ip', 'level', 'time', 'request', 'response') table = (columns, (utils.get_item_properties( s, columns, ) for s in data)) return table
def test_make_it(self): sot = trace.Trace(**EXAMPLE) self.assertEqual(EXAMPLE['trace_id'], sot.id) self.assertEqual(format.TimeTMsStr().deserialize(EXAMPLE['time']), sot.time), self.assertEqual(EXAMPLE['user'], sot.user) self.assertEqual(EXAMPLE['code'], sot.code) self.assertEqual(EXAMPLE['service_type'], sot.service_type) self.assertEqual(EXAMPLE['resource_type'], sot.resource_type) self.assertEqual(EXAMPLE['resource_name'], sot.resource_name) self.assertEqual(EXAMPLE['resource_id'], sot.resource_id) self.assertEqual(EXAMPLE['source_ip'], sot.source_ip) self.assertEqual(EXAMPLE['trace_name'], sot.name) self.assertEqual(EXAMPLE['trace_rating'], sot.level) self.assertEqual(EXAMPLE['trace_type'], sot.type) self.assertEqual( format.TimeTMsStr().deserialize(EXAMPLE['record_time']), sot.record_time)
def test_make_it(self): sot = status.FloatingIPDayStat(**EXAMPLE_DAY_STAT) self.assertEqual( format.TimeTMsStr().deserialize(EXAMPLE_DAY_STAT['period_start']), sot.period_start), self.assertEqual(EXAMPLE_DAY_STAT['bps_in'], sot.bps_in) self.assertEqual(EXAMPLE_DAY_STAT['bps_attack'], sot.bps_attack) self.assertEqual(EXAMPLE_DAY_STAT['total_bps'], sot.total_bps) self.assertEqual(EXAMPLE_DAY_STAT['pps_in'], sot.pps_in) self.assertEqual(EXAMPLE_DAY_STAT['pps_attack'], sot.pps_attack) self.assertEqual(EXAMPLE_DAY_STAT['total_pps'], sot.total_pps)
def take_action(self, parsed_args): client = self.app.client_manager.anti_ddos query = {} if parsed_args.start_time: query['period_start_date'] = format.TimeTMsStr().serialize( parsed_args.start_time) data = client.floating_ip_stat_week(**query) table = (self.columns, (utils.get_item_properties(s, self.columns) for s in data.weekdata)) return table
def test_make_data(self): sot = status.FloatingIPWeekStatData(**EXAMPLE_WEEK_DATA_STAT) self.assertEqual( format.TimeTMsStr().deserialize( EXAMPLE_WEEK_DATA_STAT['period_start_date']), sot.period_start_date), self.assertEqual(EXAMPLE_WEEK_DATA_STAT['ddos_intercept_times'], sot.ddos_intercept_times) self.assertEqual(EXAMPLE_WEEK_DATA_STAT['ddos_blackhole_times'], sot.ddos_blackhole_times) self.assertEqual(EXAMPLE_WEEK_DATA_STAT['max_attack_bps'], sot.max_attack_bps) self.assertEqual(EXAMPLE_WEEK_DATA_STAT['max_attack_conns'], sot.max_attack_conns)
def test_deserialize(self): obj = format.TimeTMsStr() self.assertEqual('2018-08-18T09:06:10.432+00:00', obj.deserialize(1534583170432))
def test_serialize(self): obj = format.TimeTMsStr() self.assertEqual(1534583170000, obj.serialize('2018-08-18T09:06:10+00:00'))