本文整理汇总了Python中pycadf.identifier.generate_uuid函数的典型用法代码示例。如果您正苦于以下问题:Python generate_uuid函数的具体用法?Python generate_uuid怎么用?Python generate_uuid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_uuid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_event
def test_event(self):
ev = event.Event(eventType='activity',
id=identifier.generate_uuid(),
eventTime=timestamp.get_utc_now(),
initiator=resource.Resource(typeURI='storage'),
initiatorId=identifier.generate_uuid(),
action='read',
target=resource.Resource(typeURI='storage'),
targetId=identifier.generate_uuid(),
observer='target',
outcome='success',
reason=reason.Reason(reasonType='HTTP',
reasonCode='200'),
severity='high')
ev.add_measurement(measurement.Measurement(result='100'))
ev.add_tag(tag.generate_name_value_tag('name', 'val'))
ev.add_attachment(attachment.Attachment(typeURI='attachURI',
content='content',
name='attachment_name'))
ev.observer = resource.Resource(typeURI='service/security')
ev.add_reporterstep(reporterstep.Reporterstep(
role='observer',
reporter=resource.Resource(typeURI='service/security')))
ev.add_reporterstep(reporterstep.Reporterstep(
reporterId=identifier.generate_uuid()))
dict_ev = ev.as_dict()
for key in event.EVENT_KEYNAMES:
self.assertIn(key, dict_ev)
开发者ID:saschpe,项目名称:pycadf,代码行数:29,代码来源:test_cadf_spec.py
示例2: test_credential
def test_credential(self):
cred = credential.Credential(type='auth token',
token=identifier.generate_uuid())
self.assertEqual(cred.is_valid(), True)
dict_cred = cred.as_dict()
for key in credential.CRED_KEYNAMES:
self.assertIn(key, dict_cred)
开发者ID:COSHPC,项目名称:pycadf,代码行数:7,代码来源:test_cadf_spec.py
示例3: _create_event
def _create_event(self, req):
correlation_id = identifier.generate_uuid()
action = self.get_action(req)
initiator = ClientResource(
typeURI=taxonomy.ACCOUNT_USER,
id=req.environ.get('HTTP_X_USER_ID', taxonomy.UNKNOWN),
name=req.environ.get('HTTP_X_USER_NAME', taxonomy.UNKNOWN),
host=host.Host(address=req.client_addr, agent=req.user_agent),
credential=KeystoneCredential(
token=req.environ.get('HTTP_X_AUTH_TOKEN', ''),
identity_status=req.environ.get('HTTP_X_IDENTITY_STATUS',
taxonomy.UNKNOWN)),
project_id=req.environ.get('HTTP_X_PROJECT_ID', taxonomy.UNKNOWN))
target = self.get_target_resource(req)
event = factory.EventFactory().new_event(
eventType=cadftype.EVENTTYPE_ACTIVITY,
outcome=taxonomy.OUTCOME_PENDING,
action=action,
initiator=initiator,
target=target,
observer=resource.Resource(id='target'))
event.requestPath = req.path_qs
event.add_tag(tag.generate_name_value_tag('correlation_id',
correlation_id))
return event
开发者ID:swiftstack,项目名称:keystonemiddleware,代码行数:27,代码来源:_api.py
示例4: _create_event
def _create_event(self, req):
correlation_id = identifier.generate_uuid()
action = self._cadf_audit.get_action(req)
initiator = ClientResource(
typeURI=taxonomy.ACCOUNT_USER,
id=identifier.norm_ns(str(req.environ['HTTP_X_USER_ID'])),
name=req.environ['HTTP_X_USER_NAME'],
host=host.Host(address=req.client_addr, agent=req.user_agent),
credential=KeystoneCredential(
token=req.environ['HTTP_X_AUTH_TOKEN'],
identity_status=req.environ['HTTP_X_IDENTITY_STATUS']),
project_id=identifier.norm_ns(req.environ['HTTP_X_PROJECT_ID']))
target = self._cadf_audit.get_target_resource(req)
event = factory.EventFactory().new_event(
eventType=cadftype.EVENTTYPE_ACTIVITY,
outcome=taxonomy.OUTCOME_PENDING,
action=action,
initiator=initiator,
target=target,
observer=resource.Resource(id='target'))
event.requestPath = req.path_qs
event.add_tag(tag.generate_name_value_tag('correlation_id',
correlation_id))
# cache model in request to allow tracking of transistive steps.
req.environ['cadf_event'] = event
return event
开发者ID:KoreaCloudObjectStorage,项目名称:keystonemiddleware,代码行数:28,代码来源:audit.py
示例5: test_cadfabstracttype_attribute_error
def test_cadfabstracttype_attribute_error(self):
"""Test an invalid CADFAbstractType attribute is set returns False"""
h = host.Host(id=identifier.generate_uuid(),
address='192.168.0.1',
agent='client',
platform='AIX')
self.assertEqual(h._isset(uuid.uuid4().hex), False)
开发者ID:bdrich,项目名称:neutron-lbaas,代码行数:8,代码来源:test_cadf_spec.py
示例6: test_metric
def test_metric(self):
metric_val = metric.Metric(metricId=identifier.generate_uuid(),
unit='b',
name='bytes')
dict_metric_val = metric_val.as_dict()
for key in metric.METRIC_KEYNAMES:
self.assertIn(key, dict_metric_val)
开发者ID:saschpe,项目名称:pycadf,代码行数:8,代码来源:test_cadf_spec.py
示例7: test_host
def test_host(self):
h = host.Host(id=identifier.generate_uuid(),
address='192.168.0.1',
agent='client',
platform='AIX')
dict_host = h.as_dict()
for key in host.HOST_KEYNAMES:
self.assertIn(key, dict_host)
开发者ID:saschpe,项目名称:pycadf,代码行数:8,代码来源:test_cadf_spec.py
示例8: __init__
def __init__(
self,
id=None,
typeURI=cadftaxonomy.UNKNOWN,
name=None,
ref=None,
domain=None,
credential=None,
host=None,
geolocation=None,
geolocationId=None,
):
"""Resource data type
:param id: id of resource
:param typeURI: typeURI of resource, defaults to 'unknown' if not set
:param name: name of resource
:param domain: domain to qualify name of resource
:param credential: optional security Credential data type
:param host: optional Host data type information relating to resource
:param geolocation: optional CADF Geolocation of resource
:param geolocationId: optional id of CADF Geolocation for resource
"""
# Resource.id
setattr(self, RESOURCE_KEYNAME_ID, id or identifier.generate_uuid())
# Resource.typeURI
if getattr(self, RESOURCE_KEYNAME_ID) != "target" and getattr(self, RESOURCE_KEYNAME_ID) != "initiator":
setattr(self, RESOURCE_KEYNAME_TYPEURI, typeURI)
# Resource.name
if name is not None:
setattr(self, RESOURCE_KEYNAME_NAME, name)
# Resource.ref
if ref is not None:
setattr(self, RESOURCE_KEYNAME_REF, ref)
# Resource.domain
if domain is not None:
setattr(self, RESOURCE_KEYNAME_DOMAIN, domain)
# Resource.credential
if credential is not None:
setattr(self, RESOURCE_KEYNAME_CRED, credential)
# Resource.host
if host is not None:
setattr(self, RESOURCE_KEYNAME_HOST, host)
# Resource.geolocation
if geolocation is not None:
setattr(self, RESOURCE_KEYNAME_GEO, geolocation)
# Resource.geolocationId
if geolocationId:
setattr(self, RESOURCE_KEYNAME_GEOID, geolocationId)
开发者ID:shaunduncan,项目名称:pycadf,代码行数:58,代码来源:resource.py
示例9: test_identifier
def test_identifier(self, warning_mock):
# empty string
self.assertFalse(identifier.is_valid(''))
# generated uuid
self.assertTrue(identifier.is_valid(identifier.generate_uuid()))
self.assertFalse(warning_mock.called)
# any string
self.assertTrue(identifier.is_valid('blah'))
self.assertTrue(warning_mock.called)
开发者ID:bdrich,项目名称:neutron-lbaas,代码行数:9,代码来源:test_cadf_spec.py
示例10: test_reason
def test_reason(self):
reason_val = reason.Reason(reasonType='HTTP',
reasonCode='200',
policyType='poltype',
policyId=identifier.generate_uuid())
dict_reason_val = reason_val.as_dict()
for key in reason.REASON_KEYNAMES:
self.assertIn(key, dict_reason_val)
开发者ID:saschpe,项目名称:pycadf,代码行数:9,代码来源:test_cadf_spec.py
示例11: test_resource
def test_resource(self):
res = resource.Resource(typeURI='storage',
name='res_name',
domain='res_domain',
ref='res_ref',
credential=credential.Credential(
token=identifier.generate_uuid()),
host=host.Host(address='192.168.0.1'),
geolocation=geolocation.Geolocation(),
geolocationId=identifier.generate_uuid())
res.add_attachment(attachment.Attachment(typeURI='attachURI',
content='content',
name='attachment_name'))
res.add_address(endpoint.Endpoint(url='http://192.168.0.1'))
dict_res = res.as_dict()
for key in resource.RESOURCE_KEYNAMES:
self.assertIn(key, dict_res)
开发者ID:saschpe,项目名称:pycadf,代码行数:18,代码来源:test_cadf_spec.py
示例12: _certificate_resource
def _certificate_resource(fingerprint):
if fingerprint is None:
res_id = identifier.generate_uuid()
else:
res_id = "certificate:%s" % (fingerprint,)
return resource.Resource(
id=res_id,
typeURI=cadftaxonomy.SECURITY_KEY,
)
开发者ID:agh,项目名称:anchor,代码行数:9,代码来源:__init__.py
示例13: test_reporterstep
def test_reporterstep(self):
step = reporterstep.Reporterstep(
role='modifier',
reporter=resource.Resource(typeURI='storage'),
reporterId=identifier.generate_uuid(),
reporterTime=timestamp.get_utc_now())
dict_step = step.as_dict()
for key in reporterstep.REPORTERSTEP_KEYNAMES:
self.assertIn(key, dict_step)
开发者ID:saschpe,项目名称:pycadf,代码行数:10,代码来源:test_cadf_spec.py
示例14: append_audit_event
def append_audit_event(self, req):
"""Append a CADF event to req.environ['CADF_EVENT']
Also, stores model in request for future process and includes a
CADF correlation id.
"""
correlation_id = identifier.generate_uuid()
req.environ['CADF_EVENT_CORRELATION_ID'] = correlation_id
event = self.create_event(req, correlation_id)
setattr(req, 'cadf_model', event)
req.environ['CADF_EVENT'] = event.as_dict()
开发者ID:saschpe,项目名称:pycadf,代码行数:10,代码来源:api.py
示例15: test_measurement
def test_measurement(self):
measure_val = measurement.Measurement(
result='100',
metric=metric.Metric(),
metricId=identifier.generate_uuid(),
calculatedBy=resource.Resource(typeURI='storage'))
dict_measure_val = measure_val.as_dict()
for key in measurement.MEASUREMENT_KEYNAMES:
self.assertIn(key, dict_measure_val)
开发者ID:saschpe,项目名称:pycadf,代码行数:10,代码来源:test_cadf_spec.py
示例16: test_event_unique
def test_event_unique(self):
ev = event.Event(eventType='activity',
initiator=resource.Resource(typeURI='storage'),
initiatorId=identifier.generate_uuid(),
action='read',
target=resource.Resource(typeURI='storage'),
targetId=identifier.generate_uuid(),
observer='target',
outcome='success')
time.sleep(1)
ev2 = event.Event(eventType='activity',
initiator=resource.Resource(typeURI='storage'),
initiatorId=identifier.generate_uuid(),
action='read',
target=resource.Resource(typeURI='storage'),
targetId=identifier.generate_uuid(),
observer='target',
outcome='success')
self.assertNotEqual(ev.id, ev2.id)
self.assertNotEqual(ev.eventTime, ev2.eventTime)
开发者ID:saschpe,项目名称:pycadf,代码行数:20,代码来源:test_cadf_spec.py
示例17: __init__
def __init__(self, eventType=cadftype.EVENTTYPE_ACTIVITY,
id=None, eventTime=None,
action=cadftaxonomy.UNKNOWN, outcome=cadftaxonomy.UNKNOWN,
initiator=None, initiatorId=None, target=None, targetId=None,
severity=None, reason=None, observer=None, observerId=None):
# Establish typeURI for the CADF Event data type
# TODO(mrutkows): support extended typeURIs for Event subtypes
setattr(self, EVENT_KEYNAME_TYPEURI, TYPE_URI_EVENT)
# Event.eventType (Mandatory)
setattr(self, EVENT_KEYNAME_EVENTTYPE, eventType)
# Event.id (Mandatory)
setattr(self, EVENT_KEYNAME_ID, id or identifier.generate_uuid())
# Event.eventTime (Mandatory)
setattr(self, EVENT_KEYNAME_EVENTTIME,
eventTime or timestamp.get_utc_now())
# Event.action (Mandatory)
setattr(self, EVENT_KEYNAME_ACTION, action)
# Event.outcome (Mandatory)
setattr(self, EVENT_KEYNAME_OUTCOME, outcome)
# Event.observer (Mandatory if no observerId)
if observer is not None:
setattr(self, EVENT_KEYNAME_OBSERVER, observer)
# Event.observerId (Dependent)
if observerId is not None:
setattr(self, EVENT_KEYNAME_OBSERVERID, observerId)
# Event.initiator (Mandatory if no initiatorId)
if initiator is not None:
setattr(self, EVENT_KEYNAME_INITIATOR, initiator)
# Event.initiatorId (Dependent)
if initiatorId is not None:
setattr(self, EVENT_KEYNAME_INITIATORID, initiatorId)
# Event.target (Mandatory if no targetId)
if target is not None:
setattr(self, EVENT_KEYNAME_TARGET, target)
# Event.targetId (Dependent)
if targetId is not None:
setattr(self, EVENT_KEYNAME_TARGETID, targetId)
# Event.severity (Optional)
if severity is not None:
setattr(self, EVENT_KEYNAME_SEVERITY, severity)
# Event.reason (Optional)
if reason is not None:
setattr(self, EVENT_KEYNAME_REASON, reason)
开发者ID:citrix-openstack-build,项目名称:pycadf,代码行数:54,代码来源:event.py
示例18: __init__
def __init__(self, metricId=None, unit=None, name=None):
# Metric.id
setattr(self, METRIC_KEYNAME_METRICID,
metricId or identifier.generate_uuid())
# Metric.unit
if unit is not None:
setattr(self, METRIC_KEYNAME_UNIT, unit)
# Metric.name
if name is not None:
setattr(self, METRIC_KEYNAME_NAME, name)
开发者ID:saschpe,项目名称:pycadf,代码行数:12,代码来源:metric.py
示例19: test_geolocation
def test_geolocation(self):
geo = geolocation.Geolocation(id=identifier.generate_uuid(),
latitude='43.6481 N',
longitude='79.4042 W',
elevation='0',
accuracy='1',
city='toronto',
state='ontario',
regionICANN='ca')
dict_geo = geo.as_dict()
for key in geolocation.GEO_KEYNAMES:
self.assertIn(key, dict_geo)
开发者ID:saschpe,项目名称:pycadf,代码行数:13,代码来源:test_cadf_spec.py
示例20: __init__
def __init__(self, metricId=None, unit=None, name=None):
"""Create metric data type
:param metricId: id of metric. uuid generated if not provided
:param unit: unit of metric
:param name: name of metric
"""
# Metric.id
setattr(self, METRIC_KEYNAME_METRICID,
metricId or identifier.generate_uuid())
# Metric.unit
if unit is not None:
setattr(self, METRIC_KEYNAME_UNIT, unit)
# Metric.name
if name is not None:
setattr(self, METRIC_KEYNAME_NAME, name)
开发者ID:COSHPC,项目名称:pycadf,代码行数:18,代码来源:metric.py
注:本文中的pycadf.identifier.generate_uuid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论