Пример #1
0
    def set_vf_rate(self, vf_index, rate):
        """sets vf rate.

        @param vf_index: vf index
        @param rate: tx rate
        """

        try:
            self._execute(
                '', "link",
                ("set", self.dev_name, "vf", str(vf_index), "rate", rate),
                self.root_helper)
        except Exception as e:
            LOG.exception(_("Failed executing ip command"))
            raise exc.IpCommandError(dev_name=self.dev_name, reason=str(e))
Пример #2
0
    def set_vf_state(self, vf_index, state):
        """sets vf state.

        @param vf_index: vf index
        @param state: required state {True/False}
        """
        status_str = self.LinkState.ENABLE if state else \
            self.LinkState.DISABLE

        try:
            self._as_root([], "link", ("set", self.dev_name, "vf",
                                       str(vf_index), "state", status_str))
        except Exception as e:
            LOG.exception(_LE("Failed executing ip command"))
            raise exc.IpCommandError(dev_name=self.dev_name,
                                     reason=e)
Пример #3
0
    def get_assigned_macs(self, vf_list):
        """Get assigned mac addresses for vf list.

        @param vf_list: list of vf indexes
        @return: list of assigned mac addresses
        """
        try:
            out = self._as_root([], "link", ("show", self.dev_name))
        except Exception as e:
            LOG.exception(_LE("Failed executing ip command"))
            raise exc.IpCommandError(dev_name=self.dev_name,
                                     reason=e)
        vf_lines = self._get_vf_link_show(vf_list, out)
        vf_details_list = []
        if vf_lines:
            for vf_line in vf_lines:
                vf_details = self._parse_vf_link_show(vf_line)
                if vf_details:
                    vf_details_list.append(vf_details)
        return [details.get("MAC") for details in vf_details_list]
Пример #4
0
    def get_vf_state(self, vf_index):
        """Get vf state {True/False}

        @param vf_index: vf index
        @todo: Handle "auto" state
        """
        try:
            out = self._execute('', "link", ("show", self.dev_name),
                                self.root_helper)
        except Exception as e:
            LOG.exception(_("Failed executing ip command"))
            raise exc.IpCommandError(dev_name=self.dev_name, reason=str(e))
        vf_lines = self._get_vf_link_show([vf_index], out)
        if vf_lines:
            vf_details = self._parse_vf_link_show(vf_lines[0])
            if vf_details:
                state = vf_details.get("link-state", self.LinkState.DISABLE)
            if state != self.LinkState.DISABLE:
                return True
        return False
Пример #5
0
    def get_vf_rate(self, vf_index):
        """Get vf tx rate

        @param vf_index: vf index
        """
        try:
            out = self._execute('', "link", ("show", self.dev_name),
                                self.root_helper)
        except Exception as e:
            LOG.exception(_("Failed executing ip command"))
            raise exc.IpCommandError(dev_name=self.dev_name, reason=str(e))
        vf_lines = self._get_vf_link_show([vf_index], out)
        if vf_lines:
            vf_details = self._parse_vf_link_show(vf_lines[0])
            rate = None
            if vf_details:
                rate = vf_details.get("rate", None)
            if rate:
                return True
        return False