• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.create_vertex函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vitrage.graph.utils.create_vertex函数的典型用法代码示例。如果您正苦于以下问题:Python create_vertex函数的具体用法?Python create_vertex怎么用?Python create_vertex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_vertex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_aggregated_state_functionalities

    def test_aggregated_state_functionalities(self):
        # setup
        state_manager = StateManager(self.conf)
        new_vertex1 = create_vertex('12345',
                                    entity_state='ACTIVE',
                                    entity_category=EntityCategory.RESOURCE,
                                    entity_type=NOVA_INSTANCE_DATASOURCE)
        metadata2 = {VProps.VITRAGE_STATE: 'SUBOPTIMAL'}
        new_vertex2 = create_vertex('23456',
                                    entity_category=EntityCategory.RESOURCE,
                                    entity_type=NOVA_INSTANCE_DATASOURCE,
                                    metadata=metadata2)
        new_vertex3 = create_vertex('34567',
                                    entity_category=EntityCategory.RESOURCE,
                                    entity_type=NOVA_INSTANCE_DATASOURCE)
        graph_vertex3 = create_vertex('45678',
                                      entity_category=EntityCategory.RESOURCE,
                                      entity_type=NOVA_INSTANCE_DATASOURCE)

        # action
        state_manager.aggregated_state(new_vertex1,
                                       None)
        state_manager.aggregated_state(new_vertex2,
                                       None)
        state_manager.aggregated_state(new_vertex3,
                                       graph_vertex3)

        # test assertions
        self.assertEqual(NormalizedResourceState.RUNNING,
                         new_vertex1[VProps.AGGREGATED_STATE])
        self.assertEqual(NormalizedResourceState.SUBOPTIMAL,
                         new_vertex2[VProps.AGGREGATED_STATE])
        self.assertEqual(NormalizedResourceState.UNDEFINED,
                         new_vertex3[VProps.AGGREGATED_STATE])
开发者ID:Idandos,项目名称:vitrage,代码行数:34,代码来源:test_state_manager.py


示例2: test_aggregated_state

    def test_aggregated_state(self):
        # setup
        state_manager = DatasourceInfoMapper(self.conf)
        metadata1 = {VProps.VITRAGE_STATE: 'SUSPENDED'}
        new_vertex1 = create_vertex('12345',
                                    entity_state='ACTIVE',
                                    entity_category=EntityCategory.RESOURCE,
                                    entity_type=NOVA_INSTANCE_DATASOURCE,
                                    metadata=metadata1)
        metadata2 = {VProps.VITRAGE_STATE: 'ACTIVE'}
        new_vertex2 = create_vertex('23456',
                                    entity_state='SUSPENDED',
                                    entity_category=EntityCategory.RESOURCE,
                                    entity_type=NOVA_INSTANCE_DATASOURCE,
                                    metadata=metadata2)

        # action
        state_manager.aggregated_state(new_vertex1, None)
        state_manager.aggregated_state(new_vertex2, None)

        # test assertions
        self.assertEqual('SUSPENDED', new_vertex1[VProps.AGGREGATED_STATE])
        self.assertEqual(OperationalResourceState.SUBOPTIMAL,
                         new_vertex1[VProps.OPERATIONAL_STATE])
        self.assertEqual('SUSPENDED', new_vertex2[VProps.AGGREGATED_STATE])
        self.assertEqual(OperationalResourceState.SUBOPTIMAL,
                         new_vertex2[VProps.OPERATIONAL_STATE])
开发者ID:openstack,项目名称:vitrage,代码行数:27,代码来源:test_datasource_info_mapper.py


示例3: test_aggregated_state_not_normalized

    def test_aggregated_state_not_normalized(self):
        # setup
        state_manager = StateManager(self.conf)
        metadata1 = {VProps.VITRAGE_STATE: 'SUSPENDED'}
        new_vertex1 = create_vertex('12345',
                                    entity_state='ACTIVE',
                                    entity_category=EntityCategory.RESOURCE,
                                    entity_type=NOVA_INSTANCE_DATASOURCE,
                                    metadata=metadata1)
        metadata2 = {VProps.VITRAGE_STATE: 'ACTIVE'}
        new_vertex2 = create_vertex('23456',
                                    entity_state='SUSPENDED',
                                    entity_category=EntityCategory.RESOURCE,
                                    entity_type=NOVA_INSTANCE_DATASOURCE,
                                    metadata=metadata2)

        # action
        state_manager.aggregated_state(new_vertex1, None)
        state_manager.aggregated_state(new_vertex2, None)

        # test assertions
        self.assertEqual(NormalizedResourceState.SUSPENDED,
                         new_vertex1[VProps.AGGREGATED_STATE])
        self.assertEqual(NormalizedResourceState.SUSPENDED,
                         new_vertex2[VProps.AGGREGATED_STATE])
开发者ID:Idandos,项目名称:vitrage,代码行数:25,代码来源:test_state_manager.py


示例4: _create_vertex

    def _create_vertex(self, entity_event):
        self._unify_time_format(entity_event)

        update_timestamp = entity_event[ZProps.TIMESTAMP]

        sample_timestamp = entity_event[DSProps.SAMPLE_DATE]

        update_timestamp = self._format_update_timestamp(update_timestamp,
                                                         sample_timestamp)

        zabbix_hostname = entity_event[ZProps.ZABBIX_RESOURCE_NAME]
        vitrage_hostname = entity_event[ZProps.RESOURCE_NAME]
        entity_event[ZProps.DESCRIPTION] = entity_event[ZProps.DESCRIPTION]\
            .replace(zabbix_hostname, vitrage_hostname)

        value = entity_event[ZProps.VALUE]
        entity_state = AlarmProps.INACTIVE_STATE if \
            value == TriggerValue.OK else AlarmProps.ACTIVE_STATE

        metadata = {
            VProps.NAME: entity_event[ZProps.DESCRIPTION],
            VProps.SEVERITY: TriggerSeverity.str(
                entity_event[ZProps.PRIORITY]),
            VProps.RAWTEXT: entity_event[ZProps.RAWTEXT]
        }

        return graph_utils.create_vertex(
            self._create_entity_key(entity_event),
            entity_category=EntityCategory.ALARM,
            entity_type=entity_event[DSProps.ENTITY_TYPE],
            entity_state=entity_state,
            sample_timestamp=sample_timestamp,
            update_timestamp=update_timestamp,
            metadata=metadata)
开发者ID:openstack,项目名称:vitrage,代码行数:34,代码来源:transformer.py


示例5: _create_entity_vertex

    def _create_entity_vertex(self, entity_event):

        sync_mode = entity_event['sync_mode']

        host_name = extract_field_value(
            entity_event,
            self.HOST_NAME[sync_mode]
        )
        metadata = {VertexProperties.NAME: host_name}

        entity_key = self.extract_key(entity_event)

        timestamp = extract_field_value(
            entity_event,
            self.TIMESTAMP[sync_mode]
        )

        return graph_utils.create_vertex(
            entity_key,
            entity_id=host_name,
            entity_category=EntityTypes.RESOURCE,
            entity_type=self.HOST_TYPE,
            update_timestamp=timestamp,
            metadata=metadata
        )
开发者ID:MarinaKoushnir,项目名称:vitrage,代码行数:25,代码来源:host_transformer.py


示例6: _create_vertex

    def _create_vertex(self,
                       entity_event,
                       stack_name,
                       stack_id,
                       stack_state,
                       update_timestamp,
                       project_id):
        metadata = {
            VProps.NAME: stack_name,
            VProps.PROJECT_ID: project_id,
        }

        entity_key = self._create_entity_key(entity_event)

        sample_timestamp = entity_event[DSProps.SAMPLE_DATE]

        return graph_utils.create_vertex(
            entity_key,
            entity_id=stack_id,
            entity_category=EntityCategory.RESOURCE,
            entity_type=HEAT_STACK_DATASOURCE,
            entity_state=stack_state,
            sample_timestamp=sample_timestamp,
            update_timestamp=update_timestamp,
            metadata=metadata)
开发者ID:openstack,项目名称:vitrage,代码行数:25,代码来源:transformer.py


示例7: _create_vertex

    def _create_vertex(self, entity_event):

        update_timestamp = datetime_utils.change_time_str_format(
            entity_event[NagiosProperties.LAST_CHECK],
            '%Y-%m-%d %H:%M:%S',
            tbase.TIMESTAMP_FORMAT)

        sample_timestamp = entity_event[DSProps.SAMPLE_DATE]

        update_timestamp = self._format_update_timestamp(update_timestamp,
                                                         sample_timestamp)

        severity = entity_event[NagiosProperties.STATUS]
        entity_state = AlarmProps.ALARM_INACTIVE_STATE if \
            severity == NagiosStatus.OK else AlarmProps.ALARM_ACTIVE_STATE

        metadata = {
            VProps.NAME: entity_event[NagiosProperties.SERVICE],
            VProps.SEVERITY: severity,
            VProps.INFO: entity_event[NagiosProperties.STATUS_INFO]
        }

        return graph_utils.create_vertex(
            self._create_entity_key(entity_event),
            entity_category=EntityCategory.ALARM,
            entity_type=entity_event[DSProps.SYNC_TYPE],
            entity_state=entity_state,
            sample_timestamp=sample_timestamp,
            update_timestamp=update_timestamp,
            metadata=metadata)
开发者ID:Idandos,项目名称:vitrage,代码行数:30,代码来源:transformer.py


示例8: _create_entity_vertex

    def _create_entity_vertex(self, entity_event):

        sync_mode = entity_event['sync_mode']

        zone_name = extract_field_value(
            entity_event,
            self.ZONE_NAME[sync_mode]
        )

        metadata = {
            VertexProperties.NAME: zone_name
        }

        entity_key = self.extract_key(entity_event)
        is_available = extract_field_value(
            entity_event,
            self.ZONE_STATE[sync_mode]
        )
        state = self.STATE_AVAILABLE if is_available \
            else self.STATE_UNAVAILABLE

        timestamp = extract_field_value(
            entity_event,
            self.TIMESTAMP[sync_mode]
        )

        return graph_utils.create_vertex(
            entity_key,
            entity_id=zone_name,
            entity_category=EntityTypes.RESOURCE,
            entity_type=self.ZONE_TYPE,
            entity_state=state,
            update_timestamp=timestamp,
            metadata=metadata
        )
开发者ID:MarinaKoushnir,项目名称:vitrage,代码行数:35,代码来源:zone_transformer.py


示例9: _create_vertex

    def _create_vertex(self,
                       entity_event,
                       name,
                       entity_id,
                       state,
                       update_timestamp,
                       project_id):
        event_type = entity_event.get(DSProps.EVENT_TYPE, None)
        ip_addresses = []
        if not event_type:
            fixed_ips = extract_field_value(
                entity_event, *self.FIXED_IPS_PROPERTY[event_type])
            ip_addresses = [ip['ip_address'] for ip in fixed_ips]
        metadata = {
            VProps.NAME: name,
            VProps.PROJECT_ID: project_id,
            'ip_addresses': tuple(ip_addresses),
        }

        sample_timestamp = entity_event[DSProps.SAMPLE_DATE]

        return graph_utils.create_vertex(
            self._create_entity_key(entity_event),
            entity_id=entity_id,
            entity_category=EntityCategory.RESOURCE,
            entity_type=NEUTRON_PORT_DATASOURCE,
            entity_state=state,
            sample_timestamp=sample_timestamp,
            update_timestamp=update_timestamp,
            metadata=metadata)
开发者ID:openstack,项目名称:vitrage,代码行数:30,代码来源:transformer.py


示例10: _create_vertex

    def _create_vertex(self, entity_event, name, entity_id, state):

        project = extract_field_value(entity_event, 'tenant_id')

        metadata = {
            VProps.NAME: name,
            VProps.PROJECT_ID: project
        }

        sample_timestamp = entity_event[DSProps.SAMPLE_DATE]

        # TODO(Alexey): need to check here that only the UPDATE sync_mode will
        #               update the UPDATE_TIMESTAMP property
        update_timestamp = self._format_update_timestamp(
            extract_field_value(entity_event, DSProps.SAMPLE_DATE),
            sample_timestamp)

        return graph_utils.create_vertex(
            self._create_entity_key(entity_event),
            entity_id=entity_id,
            entity_category=EntityCategory.RESOURCE,
            entity_type=NOVA_INSTANCE_DATASOURCE,
            entity_state=state,
            sample_timestamp=sample_timestamp,
            update_timestamp=update_timestamp,
            metadata=metadata)
开发者ID:Idandos,项目名称:vitrage,代码行数:26,代码来源:transformer.py


示例11: create_placeholder_vertex

    def create_placeholder_vertex(self, zone_name, timestamp):
        key = base.build_key(self._key_values([zone_name]))

        return graph_utils.create_vertex(
            key,
            entity_id=zone_name,
            entity_category=EntityTypes.RESOURCE,
            entity_type=self.ZONE_TYPE,
            update_timestamp=timestamp,
            is_placeholder=True
        )
开发者ID:MarinaKoushnir,项目名称:vitrage,代码行数:11,代码来源:zone_transformer.py


示例12: _create_alarm

 def _create_alarm(vitrage_id, alarm_type):
     return graph_utils.create_vertex(
         vitrage_id,
         entity_id=vitrage_id,
         entity_category=EntityCategory.ALARM,
         entity_type=alarm_type,
         entity_state='active',
         is_deleted=False,
         sample_timestamp=utcnow(),
         is_placeholder=False,
     )
开发者ID:Idandos,项目名称:vitrage,代码行数:11,代码来源:base.py


示例13: _create_resource

 def _create_resource(vitrage_id, resource_type, project_id=None):
     return graph_utils.create_vertex(
         vitrage_id,
         entity_id=vitrage_id,
         entity_category=EntityCategory.RESOURCE,
         entity_type=resource_type,
         entity_state='active',
         is_deleted=False,
         sample_timestamp=None,
         is_placeholder=False,
         project_id=project_id
     )
开发者ID:openstack,项目名称:vitrage,代码行数:12,代码来源:base.py


示例14: create_placeholder_vertex

    def create_placeholder_vertex(self, instance_id, timestamp):

        key_fields = self._key_values([instance_id])

        return graph_utils.create_vertex(
            base.build_key(key_fields),
            entity_id=instance_id,
            entity_category=EntityTypes.RESOURCE,
            entity_type=self.INSTANCE_TYPE,
            update_timestamp=timestamp,
            is_placeholder=True
        )
开发者ID:MarinaKoushnir,项目名称:vitrage,代码行数:12,代码来源:instance_transformer.py


示例15: test_vertex_crud

    def test_vertex_crud(self):
        g = create_graph('test_vertex_crud')
        g.add_vertex(v_node)
        v = g.get_vertex(v_node.vertex_id)
        self.assertEqual(v_node[VProps.ID], v[VProps.ID],
                         'vertex properties are saved')
        self.assertEqual(v_node[VProps.CATEGORY], v[VProps.CATEGORY],
                         'vertex properties are saved')
        self.assertEqual(v_node.vertex_id, v.vertex_id,
                         'vertex vertex_id is saved')

        # Changing the referenced item
        updated_v = v
        updated_v['KUKU'] = 'KUKU'
        updated_v[VProps.CATEGORY] = 'CHANGED'
        # Get it again
        v = g.get_vertex(v_node.vertex_id)
        self.assertIsNone(v.get('KUKU', None),
                          'Change should not affect graph item')
        self.assertFalse(v.get(EProps.IS_DELETED, None),
                         'Change should not affect graph item')
        self.assertEqual(v_node[VProps.CATEGORY], v[VProps.CATEGORY],
                         'Change should not affect graph item')
        # Update the graph item and see changes take place
        g.update_vertex(updated_v)
        # Get it again
        v = g.get_vertex(v_node.vertex_id)
        self.assertEqual(updated_v['KUKU'], v['KUKU'],
                         'Graph item should change after update')
        self.assertEqual(updated_v[VProps.CATEGORY], v[VProps.CATEGORY],
                         'Graph item should change after update')

        # check metadata
        another_vertex = utils.create_vertex(
            vertex_id='123', entity_id='456', entity_category=INSTANCE,
            metadata={'some_meta': 'DATA'}
        )
        g.add_vertex(another_vertex)
        v = g.get_vertex(another_vertex.vertex_id)
        self.assertEqual(another_vertex[VProps.ID], v[VProps.ID],
                         'vertex properties are saved')
        self.assertEqual(another_vertex[VProps.CATEGORY], v[VProps.CATEGORY],
                         'vertex properties are saved')
        self.assertEqual('DATA', v['some_meta'],
                         'vertex properties are saved')
        self.assertEqual(another_vertex.vertex_id, v.vertex_id,
                         'vertex vertex_id is saved')

        # Remove the item
        g.remove_vertex(another_vertex)
        self.assertEqual(1, len(g), 'graph __len__ after remove vertex')
        v = g.get_vertex(another_vertex.vertex_id)
        self.assertIsNone(v, 'removed vertex not in graph')
开发者ID:MarinaKoushnir,项目名称:vitrage,代码行数:53,代码来源:test_graph.py


示例16: create_placeholder_vertex

    def create_placeholder_vertex(self, host_name, timestamp):

        key_fields = self._key_values([host_name])

        return graph_utils.create_vertex(
            base.build_key(key_fields),
            entity_id=host_name,
            entity_category=EntityTypes.RESOURCE,
            entity_type=self.HOST_TYPE,
            update_timestamp=timestamp,
            is_placeholder=True
        )
开发者ID:MarinaKoushnir,项目名称:vitrage,代码行数:12,代码来源:host_transformer.py


示例17: create_node_placeholder_vertex

def create_node_placeholder_vertex():
    key = build_key([cons.EntityTypes.RESOURCE, NODE_SUBTYPE])

    metadata = {
        cons.VertexProperties.NAME: NODE_SUBTYPE
    }

    return graph_utils.create_vertex(
        key,
        entity_category=cons.EntityTypes.RESOURCE,
        entity_type=NODE_SUBTYPE,
        metadata=metadata
    )
开发者ID:MarinaKoushnir,项目名称:vitrage,代码行数:13,代码来源:base.py


示例18: add_connected_vertex

def add_connected_vertex(graph, entity_type, entity_subtype, entity_id,
                         edge_type, other_vertex, reverse=False):
    vertex = graph_utils.create_vertex(
        vertex_id=entity_subtype + str(entity_id),
        entity_id=entity_id,
        entity_category=entity_type,
        entity_type=entity_subtype)
    edge = graph_utils.create_edge(
        source_id=other_vertex.vertex_id if reverse else vertex.vertex_id,
        target_id=vertex.vertex_id if reverse else other_vertex.vertex_id,
        relationship_type=edge_type)
    graph.add_vertex(vertex)
    graph.add_edge(edge)
    return vertex
开发者ID:MarinaKoushnir,项目名称:vitrage,代码行数:14,代码来源:base.py


示例19: create_cluster_placeholder_vertex

def create_cluster_placeholder_vertex():
    key = build_key([cons.EntityCategory.RESOURCE,
                     OPENSTACK_CLUSTER])

    metadata = {
        cons.VertexProperties.NAME: OPENSTACK_CLUSTER
    }

    return graph_utils.create_vertex(
        key,
        entity_id=OPENSTACK_CLUSTER,
        entity_category=cons.EntityCategory.RESOURCE,
        entity_type=OPENSTACK_CLUSTER,
        entity_state=AVAILABLE,
        metadata=metadata
    )
开发者ID:openstack,项目名称:vitrage,代码行数:16,代码来源:transformer_base.py


示例20: _create_vertex

    def _create_vertex(self, entity_event, host_name):

        metadata = {VProps.NAME: host_name}
        entity_key = self._create_entity_key(entity_event)

        sample_timestamp = entity_event[DSProps.SAMPLE_DATE]
        update_timestamp = self._format_update_timestamp(None,
                                                         sample_timestamp)

        return graph_utils.create_vertex(
            entity_key,
            entity_id=host_name,
            entity_category=EntityCategory.RESOURCE,
            entity_type=NOVA_HOST_DATASOURCE,
            sample_timestamp=sample_timestamp,
            update_timestamp=update_timestamp,
            metadata=metadata)
开发者ID:paperandsoap,项目名称:vitrage,代码行数:17,代码来源:transformer.py



注:本文中的vitrage.graph.utils.create_vertex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vivopump.write_csv_fp函数代码示例发布时间:2022-05-26
下一篇:
Python transformer_base.extract_field_value函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap