Ejemplo n.º 1
0
 def create_port_binding(self, port_id, blade_intf_dn, portprofile_name, \
                         vlan_name, vlan_id, qos):
     """create port binding"""
     port_bind_dict = {}
     try:
         res = ucs_db.add_portbinding(port_id, blade_intf_dn, \
                               portprofile_name, vlan_name, vlan_id, qos)
         LOG.debug("Created port binding: %s" % res.port_id)
         port_bind_dict["port-id"] = res.port_id
         port_bind_dict["blade-intf-dn"] = str(res.blade_intf_dn)
         port_bind_dict["portprofile-name"] = res.portprofile_name
         port_bind_dict["vlan-name"] = res.vlan_name
         port_bind_dict["vlan-id"] = str(res.vlan_id)
         port_bind_dict["qos"] = res.qos
         return port_bind_dict
     except Exception, exc:
         LOG.error("Failed to create port binding: %s" % str(exc))
Ejemplo n.º 2
0
    def reserve_blade_interface(self, ucsm_ip, chassis_id, blade_id,
                                blade_data_dict, tenant_id, port_id,
                                portprofile_name):
        """Reserve an interface on a blade"""
        ucsm_username = cred.Store.getUsername(ucsm_ip)
        ucsm_password = cred.Store.getPassword(ucsm_ip)
        """
        We are first getting the updated UCSM-specific blade
        interface state
        """
        blade_data = self._get_blade_state(chassis_id, blade_id, ucsm_ip,
                                           ucsm_username, ucsm_password)
        blade_intf_data = blade_data[const.BLADE_INTF_DATA]
        chassis_data = self._inventory_state[ucsm_ip][chassis_id]
        old_blade_intf_data = chassis_data[blade_id][const.BLADE_INTF_DATA]
        """
        We will now copy the older non-UCSM-specific blade
        interface state
        """
        for blade_intf in blade_intf_data.keys():
            old_intf_data = old_blade_intf_data[blade_intf]
            blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = (
                old_intf_data[const.BLADE_INTF_RESERVATION])
            blade_intf_data[blade_intf][const.TENANTID] = (
                old_intf_data[const.TENANTID])
            blade_intf_data[blade_intf][const.PORTID] = (
                old_intf_data[const.PORTID])
            blade_intf_data[blade_intf][const.PROFILE_ID] = (
                old_intf_data[const.PROFILE_ID])
            blade_intf_data[blade_intf][const.INSTANCE_ID] = (
                old_intf_data[const.INSTANCE_ID])
            blade_intf_data[blade_intf][const.VIF_ID] = (
                old_intf_data[const.VIF_ID])

        blade_data[const.BLADE_UNRESERVED_INTF_COUNT] = (
            chassis_data[blade_id][const.BLADE_UNRESERVED_INTF_COUNT])
        """
        Now we will reserve an interface if its available
        """
        for blade_intf in blade_intf_data.keys():
            intf_data = blade_intf_data[blade_intf]
            if (intf_data[const.BLADE_INTF_RESERVATION] ==
                    const.BLADE_INTF_UNRESERVED):
                intf_data[const.BLADE_INTF_RESERVATION] = (
                    const.BLADE_INTF_RESERVED)
                intf_data[const.TENANTID] = tenant_id
                intf_data[const.PORTID] = port_id
                intf_data[const.INSTANCE_ID] = None
                dev_eth_name = intf_data[const.BLADE_INTF_RHEL_DEVICE_NAME]
                """
                We are replacing the older blade interface state with new
                """
                chassis_data[blade_id][const.BLADE_INTF_DATA] = blade_intf_data
                chassis_data[blade_id][const.BLADE_UNRESERVED_INTF_COUNT] -= 1
                host_name = self._get_host_name(ucsm_ip, chassis_id, blade_id)
                reserved_nic_dict = {
                    const.RESERVED_NIC_HOSTNAME: host_name,
                    const.RESERVED_NIC_NAME: dev_eth_name,
                    const.BLADE_INTF_DN: blade_intf,
                }
                port_binding = udb.add_portbinding(port_id, blade_intf, None,
                                                   None, None, None)
                udb.update_portbinding(port_id,
                                       tenant_id=intf_data[const.TENANTID])
                LOG.debug("Reserved blade interface: %s\n" % reserved_nic_dict)
                return reserved_nic_dict

        LOG.warn("Dynamic nic %s could not be reserved for port-id: %s" %
                 (blade_data, port_id))
        return False
Ejemplo n.º 3
0
    def reserve_blade_interface(self, ucsm_ip, chassis_id, blade_id,
                                blade_data_dict, tenant_id, port_id,
                                portprofile_name):
        """Reserve an interface on a blade"""
        ucsm_username = cred.Store.getUsername(ucsm_ip)
        ucsm_password = cred.Store.getPassword(ucsm_ip)
        """
        We are first getting the updated UCSM-specific blade
        interface state
        """
        blade_data = self._get_blade_state(chassis_id, blade_id, ucsm_ip,
                                           ucsm_username, ucsm_password)
        blade_intf_data = blade_data[const.BLADE_INTF_DATA]
        #import sys
        #sys.exit(ucsm_ip)
        chassis_data = self._inventory_state[ucsm_ip][chassis_id]
        old_blade_intf_data = chassis_data[blade_id][const.BLADE_INTF_DATA]

        """
        We will now copy the older non-UCSM-specific blade
        interface state
        """
        for blade_intf in blade_intf_data.keys():
            old_intf_data = old_blade_intf_data[blade_intf]
            blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = \
                    old_intf_data[const.BLADE_INTF_RESERVATION]
            blade_intf_data[blade_intf][const.TENANTID] = \
                    old_intf_data[const.TENANTID]
            blade_intf_data[blade_intf][const.PORTID] = \
                    old_intf_data[const.PORTID]
            blade_intf_data[blade_intf][const.PROFILE_ID] = \
                    old_intf_data[const.PROFILE_ID]
            blade_intf_data[blade_intf][const.INSTANCE_ID] = \
                    old_intf_data[const.INSTANCE_ID]
            blade_intf_data[blade_intf][const.VIF_ID] = \
                    old_intf_data[const.VIF_ID]

        blade_data[const.BLADE_UNRESERVED_INTF_COUNT] = \
                chassis_data[blade_id][const.BLADE_UNRESERVED_INTF_COUNT]
        """
        Now we will reserve an interface if its available
        """
        for blade_intf in blade_intf_data.keys():
            intf_data = blade_intf_data[blade_intf]
            if intf_data[const.BLADE_INTF_RESERVATION] == \
               const.BLADE_INTF_UNRESERVED:
                intf_data[const.BLADE_INTF_RESERVATION] = \
                        const.BLADE_INTF_RESERVED
                intf_data[const.TENANTID] = tenant_id
                intf_data[const.PORTID] = port_id
                #intf_data[const.PROFILE_ID] = \
                #        portprofile_name
                intf_data[const.INSTANCE_ID] = None
                dev_eth_name = intf_data[const.BLADE_INTF_RHEL_DEVICE_NAME]
                """
                We are replacing the older blade interface state with new
                """
                chassis_data[blade_id][const.BLADE_INTF_DATA] = blade_intf_data
                chassis_data[blade_id][const.BLADE_UNRESERVED_INTF_COUNT] -= 1
                host_name = self._get_host_name(ucsm_ip, chassis_id,
                                                       blade_id)
                reserved_nic_dict = {const.RESERVED_NIC_HOSTNAME: host_name,
                                   const.RESERVED_NIC_NAME: dev_eth_name,
                                   const.BLADE_INTF_DN: blade_intf}
                port_binding = udb.add_portbinding(port_id, blade_intf, None,
                                                   None, None, None)
                udb.update_portbinding(port_id,
                                       tenant_id=intf_data[const.TENANTID])
                LOG.debug("Reserved blade interface: %s\n" % reserved_nic_dict)
                return reserved_nic_dict

        LOG.warn("Dynamic nic %s could not be reserved for port-id: %s" %
                 (blade_data, port_id))
        return False