def port_update(device, dmd, evt):
    evt.summary = event_summary("Port", evt)

    objmap = neutron_objmap(evt, "Port")
    _apply_neutron_traits(evt, objmap, 'port')
    _apply_trait_rel(evt, objmap, 'trait_network_id', 'network')

    # If device_owner is part of compute, then add device_id as set_instance
    if 'compute' in evt.trait_device_owner and evt.trait_device_id:
        _apply_trait_rel(evt, objmap, 'trait_device_id', 'server')

    if hasattr(evt, 'evt.trait_device_id'):
        port_instance = get_port_instance(evt.trait_device_owner,
                                           evt.trait_device_id)
        setattr(objmap, 'set_instance', port_instance)

    # get subnets and fixed_ips
    if hasattr(evt, 'trait_fixed_ips'):
        port_fips = ast.literal_eval(evt.trait_fixed_ips)
        _subnets = get_subnets_from_fixedips(port_fips)
        port_subnets = [prepId('subnet-{}'.format(x)) for x in _subnets]
        port_fixedips = get_port_fixedips(port_fips)
        setattr(objmap, 'set_subnets', port_subnets)
        setattr(objmap, 'fixed_ip_list', port_fixedips)

    return [objmap]
Exemplo n.º 2
0
def port_update(evt):
    if not port_id(evt):
        LOG.info("Unable to identify port component from event: %s" % evt)
        return None

    traitmap = {
        'admin_state_up': ['admin_state_up'],
        'binding_vif_type': ['vif_type'],
        'device_owner': ['device_owner'],
        'id': ['portId'],
        'resource_id': ['portId'],
        'mac_address': ['mac_address'],
        'name': ['title'],
        'status': ['status'],
        # See: _apply_neutron_traits: set_tenant, set_network
    }

    objmap = neutron_objmap(evt, "Port")
    _apply_neutron_traits(evt, objmap, traitmap)
    _apply_trait_rel(evt, objmap, 'trait_network_id', 'network')

    if 'trait_device_id' in evt and 'trait_device_owner' in evt:
        port_instance = get_port_instance(evt['trait_device_owner'],
                                          evt['trait_device_id'])
        setattr(objmap, 'set_instance', port_instance)

    # get subnets and fixed_ips
    if 'trait_fixed_ips' in evt:
        port_fips = ast.literal_eval(evt['trait_fixed_ips'])
        _subnets = get_subnets_from_fixedips(port_fips)
        port_subnets = [prepId('subnet-{}'.format(x)) for x in _subnets]
        port_fixedips = get_port_fixedips(port_fips)
        setattr(objmap, 'set_subnets', port_subnets)
        setattr(objmap, 'fixed_ip_list', port_fixedips)

    return objmap
def port_update(evt):
    if not port_id(evt):
        LOG.info("Unable to identify port component from event: %s" % evt)
        return None

    traitmap = {
        'admin_state_up': ['admin_state_up'],
        'binding_vif_type': ['vif_type'],
        'device_owner': ['device_owner'],
        'id': ['portId'],
        'resource_id': ['portId'],
        'mac_address': ['mac_address'],
        'name': ['title'],
        'status': ['status'],
        # See: _apply_neutron_traits: set_tenant, set_network
    }

    objmap = neutron_objmap(evt, "Port")
    _apply_neutron_traits(evt, objmap, traitmap)
    _apply_trait_rel(evt, objmap, 'trait_network_id', 'network')

    if 'trait_device_id' in evt and 'trait_device_owner' in evt:
        port_instance = get_port_instance(evt['trait_device_owner'],
                                          evt['trait_device_id'])
        setattr(objmap, 'set_instance', port_instance)

    # get subnets and fixed_ips
    if 'trait_fixed_ips' in evt:
        port_fips = ast.literal_eval(evt['trait_fixed_ips'])
        _subnets = get_subnets_from_fixedips(port_fips)
        port_subnets = [prepId('subnet-{}'.format(x)) for x in _subnets]
        port_fixedips = get_port_fixedips(port_fips)
        setattr(objmap, 'set_subnets', port_subnets)
        setattr(objmap, 'fixed_ip_list', port_fixedips)

    return objmap
            if port["tenant_id"]:
                port_tenant = "tenant-{0}".format(port["tenant_id"])

            ports.append(
                ObjectMap(
                    modname="ZenPacks.zenoss.OpenStackInfrastructure.Port",
                    data=dict(
                        admin_state_up=port["admin_state_up"],
                        device_owner=port["device_owner"],
                        fixed_ip_list=get_port_fixedips(port["fixed_ips"]),
                        id="port-{0}".format(port["id"]),
                        mac_address=port["mac_address"].upper(),
                        portId=port["id"],
                        set_instance=get_port_instance(port["device_owner"], port["device_id"]),
                        set_network="network-{0}".format(port["network_id"]),
                        set_subnets=get_subnets_from_fixedips(port["fixed_ips"]),
                        set_tenant=port_tenant,
                        status=port["status"],
                        title=port["name"],
                        vif_type=port["binding:vif_type"],
                    ),
                )
            )

        # floatingip
        floatingips = []
        for floatingip in results["floatingips"]:
            floatingips.append(
                ObjectMap(
                    modname="ZenPacks.zenoss.OpenStackInfrastructure.FloatingIp",
                    data=dict(