示例#1
0
def update_portbinding(port_id, blade_intf_dn=None, portprofile_name=None,
                       vlan_name=None, vlan_id=None, qos=None,
                       tenant_id=None, instance_id=None,
                       vif_id=None):
    """Updates port binding"""
    LOG.debug("db update_portbinding() called")
    session = db.get_session()
    try:
        port_binding = session.query(ucs_models.PortBinding).\
          filter_by(port_id=port_id).\
          one()
        if blade_intf_dn:
            port_binding.blade_intf_dn = blade_intf_dn
        if portprofile_name:
            port_binding.portprofile_name = portprofile_name
        if vlan_name:
            port_binding.vlan_name = vlan_name
        if vlan_name:
            port_binding.vlan_id = vlan_id
        if qos:
            port_binding.qos = qos
        if tenant_id:
            port_binding.tenant_id = tenant_id
        if instance_id:
            port_binding.instance_id = instance_id
        if vif_id:
            port_binding.vif_id = vif_id
        session.merge(port_binding)
        session.flush()
        return port_binding
    except exc.NoResultFound:
        raise c_exc.PortVnicNotFound(port_id=port_id)
示例#2
0
def update_portbinding(port_id, blade_intf_dn=None, portprofile_name=None,
                       vlan_name=None, vlan_id=None, qos=None,
                       tenant_id=None, instance_id=None,
                       vif_id=None):
    """Updates port binding"""
    LOG.debug("db update_portbinding() called")
    session = db.get_session()
    try:
        port_binding = session.query(ucs_models.PortBinding).\
          filter_by(port_id=port_id).\
          one()
        if blade_intf_dn:
            port_binding.blade_intf_dn = blade_intf_dn
        if portprofile_name:
            port_binding.portprofile_name = portprofile_name
        if vlan_name:
            port_binding.vlan_name = vlan_name
        if vlan_name:
            port_binding.vlan_id = vlan_id
        if qos:
            port_binding.qos = qos
        if tenant_id:
            port_binding.tenant_id = tenant_id
        if instance_id:
            port_binding.instance_id = instance_id
        if vif_id:
            port_binding.vif_id = vif_id
        session.merge(port_binding)
        session.flush()
        return port_binding
    except exc.NoResultFound:
        raise c_exc.PortVnicNotFound(port_id=port_id)
示例#3
0
def add_services_binding(service_id, mngnet_id, nbnet_id, sbnet_id):
    """Adds a services binding"""
    LOG.debug(_("add_services_binding() called"))
    session = db.get_session()
    binding = services_models.ServicesBinding(service_id, mngnet_id, nbnet_id, sbnet_id)
    session.add(binding)
    session.flush()
    return binding
示例#4
0
def add_nexusport_binding(port_id, vlan_id):
    """Adds a nexusport binding"""
    LOG.debug("add_nexusport_binding() called")
    session = db.get_session()
    binding = nexus_models.NexusPortBinding(port_id, vlan_id)
    session.add(binding)
    session.flush()
    return binding
示例#5
0
def get_all_credentials(tenant_id):
    """Lists all the creds for a tenant"""
    session = db.get_session()
    try:
        creds = session.query(l2network_models.Credential).filter_by(tenant_id=tenant_id).all()
        return creds
    except exc.NoResultFound:
        return []
def add_catalystport_binding(port_id, vlan_id):
    """Adds a catalystport binding"""
    LOG.debug("add_catalystport_binding() called")
    session = db.get_session()
    binding = catalyst_models.CatalystPortBinding(port_id, vlan_id)
    session.add(binding)
    session.flush()
    return binding
示例#7
0
def get_all_nexusport_bindings():
    """Lists all the nexusport bindings"""
    LOG.debug("get_all_nexusport_bindings() called")
    session = db.get_session()
    try:
        bindings = session.query(nexus_models.NexusPortBinding).all()
        return bindings
    except exc.NoResultFound:
        return []
示例#8
0
def get_service_bindings(service_id):
    """Lists services bindings for a service_id"""
    LOG.debug(_("get_service_bindings() called"))
    session = db.get_session()
    try:
        bindings = session.query(services_models.ServicesBinding).filter_by(service_id=service_id).one()
        return bindings
    except exc.NoResultFound:
        return []
示例#9
0
def get_all_credentials(tenant_id):
    """Lists all the creds for a tenant"""
    session = db.get_session()
    try:
        creds = (session.query(l2network_models.Credential).
                 filter_by(tenant_id=tenant_id).all())
        return creds
    except exc.NoResultFound:
        return []
示例#10
0
def get_all_portbindings():
    """Lists all the port bindings"""
    LOG.debug("db get_all_portbindings() called")
    session = db.get_session()
    try:
        port_bindings = session.query(ucs_models.PortBinding).all()
        return port_bindings
    except exc.NoResultFound:
        return []
示例#11
0
def get_qos(tenant_id, qos_id):
    """Lists the qos given a tenant_id and qos_id"""
    LOG.debug("get_qos() called")
    session = db.get_session()
    try:
        qos = session.query(l2network_models.QoS).filter_by(tenant_id=tenant_id).filter_by(qos_id=qos_id).one()
        return qos
    except exc.NoResultFound:
        raise c_exc.QosNotFound(qos_id=qos_id, tenant_id=tenant_id)
示例#12
0
def get_all_portprofiles():
    """Lists all the port profiles"""
    LOG.debug(_("get_all_portprofiles() called"))
    session = db.get_session()
    try:
        pps = session.query(l2network_models.PortProfile).all()
        return pps
    except exc.NoResultFound:
        return []
示例#13
0
def get_all_services_bindings():
    """Lists all the services bindings"""
    LOG.debug("get_all_services_bindings() called")
    session = db.get_session()
    try:
        bindings = session.query(services_models.ServicesBinding).all()
        return bindings
    except exc.NoResultFound:
        return []
示例#14
0
def get_all_vlan_bindings():
    """Lists all the vlan to network associations"""
    LOG.debug("get_all_vlan_bindings() called")
    session = db.get_session()
    try:
        bindings = session.query(l2network_models.VlanBinding).all()
        return bindings
    except exc.NoResultFound:
        return []
示例#15
0
def add_services_binding(service_id, mngnet_id, nbnet_id, sbnet_id):
    """Adds a services binding"""
    LOG.debug("add_services_binding() called")
    session = db.get_session()
    binding = services_models.ServicesBinding(service_id, mngnet_id, nbnet_id,
                                              sbnet_id)
    session.add(binding)
    session.flush()
    return binding
示例#16
0
def get_all_nexusport_bindings():
    """Lists all the nexusport bindings"""
    LOG.debug("get_all_nexusport_bindings() called")
    session = db.get_session()
    try:
        bindings = session.query(nexus_models.NexusPortBinding).all()
        return bindings
    except exc.NoResultFound:
        return []
示例#17
0
def is_vlanid_used(vlan_id):
    """Checks if a vlanid is in use"""
    LOG.debug("is_vlanid_used() called")
    session = db.get_session()
    try:
        vlanid = session.query(l2network_models.VlanID).filter_by(vlan_id=vlan_id).one()
        return vlanid["vlan_used"]
    except exc.NoResultFound:
        raise c_exc.VlanIDNotFound(vlan_id=vlan_id)
示例#18
0
def get_vlan_binding(netid):
    """Lists the vlan given a network_id"""
    LOG.debug("get_vlan_binding() called")
    session = db.get_session()
    try:
        binding = session.query(l2network_models.VlanBinding).filter_by(network_id=netid).one()
        return binding
    except exc.NoResultFound:
        raise q_exc.NetworkNotFound(net_id=netid)
示例#19
0
def get_pp_binding(tenantid, ppid):
    """Lists a port profile binding"""
    LOG.debug("get_pp_binding() called")
    session = db.get_session()
    try:
        binding = session.query(l2network_models.PortProfileBinding).filter_by(portprofile_id=ppid).one()
        return binding
    except exc.NoResultFound:
        return []
示例#20
0
def get_all_qoss(tenant_id):
    """Lists all the qos to tenant associations"""
    LOG.debug("get_all_qoss() called")
    session = db.get_session()
    try:
        qoss = session.query(l2network_models.QoS).filter_by(tenant_id=tenant_id).all()
        return qoss
    except exc.NoResultFound:
        return []
示例#21
0
def get_all_pp_bindings():
    """Lists all the port profiles"""
    LOG.debug("get_all_pp_bindings() called")
    session = db.get_session()
    try:
        bindings = session.query(l2network_models.PortProfileBinding).all()
        return bindings
    except exc.NoResultFound:
        return []
示例#22
0
def get_portprofile(tenantid, ppid):
    """Lists a port profile"""
    LOG.debug("get_portprofile() called")
    session = db.get_session()
    try:
        pp = session.query(l2network_models.PortProfile).filter_by(uuid=ppid).one()
        return pp
    except exc.NoResultFound:
        raise c_exc.PortProfileNotFound(tenant_id=tenantid, portprofile_id=ppid)
示例#23
0
def get_all_vlanids():
    """Gets all the vlanids"""
    LOG.debug("get_all_vlanids() called")
    session = db.get_session()
    try:
        vlanids = session.query(l2network_models.VlanID).all()
        return vlanids
    except exc.NoResultFound:
        return []
示例#24
0
def get_all_services_bindings():
    """Lists all the services bindings"""
    LOG.debug("get_all_services_bindings() called")
    session = db.get_session()
    try:
        bindings = session.query(services_models.ServicesBinding).all()
        return bindings
    except exc.NoResultFound:
        return []
示例#25
0
def get_credential(tenant_id, credential_id):
    """Lists the creds for given a cred_id and tenant_id"""
    session = db.get_session()
    try:
        cred = (session.query(l2network_models.Credential).filter_by(
            tenant_id=tenant_id).filter_by(credential_id=credential_id).one())
        return cred
    except exc.NoResultFound:
        raise c_exc.CredentialNotFound(credential_id=credential_id,
                                       tenant_id=tenant_id)
示例#26
0
def get_all_portprofiles():
    """Lists all the port profiles"""
    LOG.debug("get_all_portprofiles() called")
    session = db.get_session()
    try:
        pps = session.query(l2network_models.PortProfile).\
          all()
        return pps
    except exc.NoResultFound:
        return []
示例#27
0
def get_all_portbindings():
    """Lists all the port bindings"""
    LOG.debug("db get_all_portbindings() called")
    session = db.get_session()
    try:
        port_bindings = session.query(ucs_models.PortBinding).\
          all()
        return port_bindings
    except exc.NoResultFound:
        return []
示例#28
0
def get_portbinding_dn(blade_intf_dn):
    """Lists a port binding"""
    LOG.debug("get_portbinding_dn() called")
    session = db.get_session()
    try:
        port_binding = (session.query(ucs_models.PortBinding).
                        filter_by(blade_intf_dn=blade_intf_dn).one())
        return port_binding
    except exc.NoResultFound:
        return []
示例#29
0
def get_portbinding(port_id):
    """Lists a port binding"""
    LOG.debug("get_portbinding() called")
    session = db.get_session()
    try:
        port_binding = (session.query(ucs_models.PortBinding).
                        filter_by(port_id=port_id).one())
        return port_binding
    except exc.NoResultFound:
        raise c_exc.PortVnicNotFound(port_id=port_id)
示例#30
0
def get_nexusport_binding(vlan_id):
    """Lists a nexusport binding"""
    LOG.debug("get_nexusport_binding() called")
    session = db.get_session()
    try:
        binding = (session.query(nexus_models.NexusPortBinding).
                   filter_by(vlan_id=vlan_id).all())
        return binding
    except exc.NoResultFound:
        raise c_exc.NexusPortBindingNotFound(vlan_id=vlan_id)
示例#31
0
def remove_qos(tenant_id, qos_id):
    """Removes a qos to tenant association"""
    session = db.get_session()
    try:
        qos = session.query(l2network_models.QoS).filter_by(tenant_id=tenant_id).filter_by(qos_id=qos_id).one()
        session.delete(qos)
        session.flush()
        return qos
    except exc.NoResultFound:
        pass
示例#32
0
def get_qos(tenant_id, qos_id):
    """Lists the qos given a tenant_id and qos_id"""
    LOG.debug("get_qos() called")
    session = db.get_session()
    try:
        qos = (session.query(l2network_models.QoS).filter_by(
            tenant_id=tenant_id).filter_by(qos_id=qos_id).one())
        return qos
    except exc.NoResultFound:
        raise c_exc.QosNotFound(qos_id=qos_id, tenant_id=tenant_id)
示例#33
0
def get_catalystport_binding(vland_id):
    """Lists catalyst port binding for particular vlan"""
    LOG.debug("get_catlystport_binding() called")
    session = db.get_session()
    try:
        binding = (session.query(catalyst_models.CatalystPortBinding). \
                                filter_by(vland_id).all())
        return binding
    except exc.NoresultFound:
        raise c_exc.CatalystPortBindingNotFound(vlan_id=vlan_id)
示例#34
0
def get_vlan_binding(netid):
    """Lists the vlan given a network_id"""
    LOG.debug("get_vlan_binding() called")
    session = db.get_session()
    try:
        binding = (session.query(l2network_models.VlanBinding).
                   filter_by(network_id=netid).one())
        return binding
    except exc.NoResultFound:
        raise q_exc.NetworkNotFound(net_id=netid)
示例#35
0
def get_all_qoss(tenant_id):
    """Lists all the qos to tenant associations"""
    LOG.debug("get_all_qoss() called")
    session = db.get_session()
    try:
        qoss = (session.query(l2network_models.QoS).
                filter_by(tenant_id=tenant_id).all())
        return qoss
    except exc.NoResultFound:
        return []
示例#36
0
def get_pp_binding(tenantid, ppid):
    """Lists a port profile binding"""
    LOG.debug("get_pp_binding() called")
    session = db.get_session()
    try:
        binding = (session.query(l2network_models.PortProfileBinding).
                   filter_by(portprofile_id=ppid).one())
        return binding
    except exc.NoResultFound:
        return []
示例#37
0
def is_vlanid_used(vlan_id):
    """Checks if a vlanid is in use"""
    LOG.debug("is_vlanid_used() called")
    session = db.get_session()
    try:
        vlanid = (session.query(l2network_models.VlanID).
                  filter_by(vlan_id=vlan_id).one())
        return vlanid["vlan_used"]
    except exc.NoResultFound:
        raise c_exc.VlanIDNotFound(vlan_id=vlan_id)
示例#38
0
def get_all_catalystport_bindings():
    """Lists all the catalystport bindings"""
    LOG.debug("get_all_catalystport_bindings() called")
    session = db.get_session()
    try:
        bindings = session.query
        (catalyst_models.CatalystPortBinding).all()
        return bindings
    except exc.NoResultFound:
        return []
示例#39
0
def get_all_vlanids_used():
    """Gets all the vlanids used"""
    LOG.debug("get_all_vlanids() called")
    session = db.get_session()
    try:
        vlanids = (session.query(l2network_models.VlanID).
                   filter_by(vlan_used=True).all())
        return vlanids
    except exc.NoResultFound:
        return []
示例#40
0
def get_nexusport_binding(vlan_id):
    """Lists a nexusport binding"""
    LOG.debug("get_nexusport_binding() called")
    session = db.get_session()
    try:
        binding = (session.query(
            nexus_models.NexusPortBinding).filter_by(vlan_id=vlan_id).all())
        return binding
    except exc.NoResultFound:
        raise c_exc.NexusPortBindingNotFound(vlan_id=vlan_id)
示例#41
0
def get_service_bindings(service_id):
    """Lists services bindings for a service_id"""
    LOG.debug("get_service_bindings() called")
    session = db.get_session()
    try:
        bindings = (session.query(services_models.ServicesBinding).filter_by(
            service_id=service_id).one())
        return bindings
    except exc.NoResultFound:
        return []
示例#42
0
def remove_vlan_binding(netid):
    """Removes a vlan to network association"""
    LOG.debug("remove_vlan_binding() called")
    session = db.get_session()
    try:
        binding = session.query(l2network_models.VlanBinding).filter_by(network_id=netid).one()
        session.delete(binding)
        session.flush()
        return binding
    except exc.NoResultFound:
        pass
示例#43
0
def remove_portprofile(tenantid, ppid):
    """Removes a port profile"""
    LOG.debug("remove_portprofile() called")
    session = db.get_session()
    try:
        pp = session.query(l2network_models.PortProfile).filter_by(uuid=ppid).one()
        session.delete(pp)
        session.flush()
        return pp
    except exc.NoResultFound:
        pass
示例#44
0
def get_portprofile(tenantid, ppid):
    """Lists a port profile"""
    LOG.debug("get_portprofile() called")
    session = db.get_session()
    try:
        pp = (session.query(l2network_models.PortProfile).
              filter_by(uuid=ppid).one())
        return pp
    except exc.NoResultFound:
        raise c_exc.PortProfileNotFound(tenant_id=tenantid,
                                        portprofile_id=ppid)
示例#45
0
def delete_vlanid(vlan_id):
    """Deletes a vlanid entry from db"""
    LOG.debug("delete_vlanid() called")
    session = db.get_session()
    try:
        vlanid = session.query(l2network_models.VlanID).filter_by(vlan_id=vlan_id).one()
        session.delete(vlanid)
        session.flush()
        return vlanid
    except exc.NoResultFound:
        pass
示例#46
0
def get_portbinding(port_id):
    """Lists a port binding"""
    LOG.debug("get_portbinding() called")
    session = db.get_session()
    try:
        port_binding = session.query(ucs_models.PortBinding).\
          filter_by(port_id=port_id).\
          one()
        return port_binding
    except exc.NoResultFound:
        raise c_exc.PortVnicNotFound(port_id=port_id)
示例#47
0
def get_credential_name(tenant_id, credential_name):
    """Lists the creds for given a cred_name and tenant_id"""
    session = db.get_session()
    try:
        cred = (session.query(l2network_models.Credential).
                filter_by(tenant_id=tenant_id).
                filter_by(credential_name=credential_name).one())
        return cred
    except exc.NoResultFound:
        raise c_exc.CredentialNameNotFound(credential_name=credential_name,
                                           tenant_id=tenant_id)
示例#48
0
def remove_qos(tenant_id, qos_id):
    """Removes a qos to tenant association"""
    session = db.get_session()
    try:
        qos = (session.query(l2network_models.QoS).filter_by(
            tenant_id=tenant_id).filter_by(qos_id=qos_id).one())
        session.delete(qos)
        session.flush()
        return qos
    except exc.NoResultFound:
        pass
示例#49
0
def remove_credential(tenant_id, credential_id):
    """Removes a credential from a  tenant"""
    session = db.get_session()
    try:
        cred = (session.query(l2network_models.Credential).filter_by(
            tenant_id=tenant_id).filter_by(credential_id=credential_id).one())
        session.delete(cred)
        session.flush()
        return cred
    except exc.NoResultFound:
        pass
示例#50
0
def get_portbinding_dn(blade_intf_dn):
    """Lists a port binding"""
    LOG.debug("get_portbinding_dn() called")
    session = db.get_session()
    try:
        port_binding = session.query(ucs_models.PortBinding).\
          filter_by(blade_intf_dn=blade_intf_dn).\
          one()
        return port_binding
    except exc.NoResultFound:
        return []
示例#51
0
def get_credential_name(tenant_id, credential_name):
    """Lists the creds for given a cred_name and tenant_id"""
    session = db.get_session()
    try:
        cred = session.query(l2network_models.Credential).\
          filter_by(tenant_id=tenant_id).\
          filter_by(credential_name=credential_name).\
          one()
        return cred
    except exc.NoResultFound:
        raise c_exc.CredentialNameNotFound(credential_name=credential_name,
                                           tenant_id=tenant_id)
示例#52
0
def remove_vlan_binding(netid):
    """Removes a vlan to network association"""
    LOG.debug("remove_vlan_binding() called")
    session = db.get_session()
    try:
        binding = (session.query(l2network_models.VlanBinding).
                   filter_by(network_id=netid).one())
        session.delete(binding)
        session.flush()
        return binding
    except exc.NoResultFound:
        pass
示例#53
0
def delete_vlanid(vlan_id):
    """Deletes a vlanid entry from db"""
    LOG.debug("delete_vlanid() called")
    session = db.get_session()
    try:
        vlanid = (session.query(l2network_models.VlanID).
                  filter_by(vlan_id=vlan_id).one())
        session.delete(vlanid)
        session.flush()
        return vlanid
    except exc.NoResultFound:
        pass
示例#54
0
def remove_portprofile(tenantid, ppid):
    """Removes a port profile"""
    LOG.debug("remove_portprofile() called")
    session = db.get_session()
    try:
        pp = (session.query(l2network_models.PortProfile).
              filter_by(uuid=ppid).one())
        session.delete(pp)
        session.flush()
        return pp
    except exc.NoResultFound:
        pass
示例#55
0
def remove_pp_binding(tenantid, portid, ppid):
    """Removes a port profile binding"""
    LOG.debug("remove_pp_binding() called")
    session = db.get_session()
    try:
        binding = (session.query(l2network_models.PortProfileBinding).
                   filter_by(portprofile_id=ppid).filter_by(port_id=portid).
                   one())
        session.delete(binding)
        session.flush()
        return binding
    except exc.NoResultFound:
        pass