X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Fvpp_config%2Fvpplib%2FVPPUtil.py;h=4551cf45a5e0104e8e252fe8df5409e9ba860a93;hb=c6b2a206b6a27bd136adb856cf51828bf91d892d;hp=f042e80bd8f3c2d4e4778041935d6f732a71c4f5;hpb=a74b7419bd6c7c5b23f59253b0b0b6c0d683794d;p=vpp.git diff --git a/extras/vpp_config/vpplib/VPPUtil.py b/extras/vpp_config/vpplib/VPPUtil.py index f042e80bd8f..4551cf45a5e 100644 --- a/extras/vpp_config/vpplib/VPPUtil.py +++ b/extras/vpp_config/vpplib/VPPUtil.py @@ -140,8 +140,11 @@ class VPPUtil(object): stderr)) reps = 'deb [trusted=yes] https://nexus.fd.io/content/' - reps += 'repositories/fd.io.stable.{}.ubuntu.{}.main/ ./\n' \ - .format(fdio_release, ubuntu_version) + # When using a stable branch + # reps += 'repositories/fd.io.stable.{}.ubuntu.{}.main/ ./\n' \ + # .format(fdio_release, ubuntu_version) + reps += 'repositories/fd.io.ubuntu.{}.main/ ./\n' \ + .format(ubuntu_version) cmd = 'echo "{0}" | sudo tee {1}'.format(reps, sfile) (ret, stdout, stderr) = self.exec_command(cmd) @@ -201,8 +204,11 @@ class VPPUtil(object): reps = '[fdio-stable-{}]\n'.format(fdio_release) reps += 'name=fd.io stable/{} branch latest merge\n'.format(fdio_release) - reps += 'baseurl=https://nexus.fd.io/content/repositories/fd.io.stable.{}.{}/\n'.\ - format(fdio_release, centos_version) + # When using stable + # reps += 'baseurl=https://nexus.fd.io/content/repositories/fd.io.stable.{}.{}/\n'.\ + # format(fdio_release, centos_version) + reps += 'baseurl=https://nexus.fd.io/content/repositories/fd.io.{}/\n'.\ + format(centos_version) reps += 'enabled=1\n' reps += 'gpgcheck=0' @@ -336,6 +342,10 @@ class VPPUtil(object): :param node: Node dictionary with cpuinfo. :type node: dict """ + + # First stop VPP + self.stop(node) + distro = self.get_linux_distro() if distro[0] == 'Ubuntu': self._uninstall_vpp_ubuntu(node) @@ -372,6 +382,23 @@ class VPPUtil(object): for _, value in def_setting_tb_displayed.items(): self.exec_command('vppctl sh {}'.format(value)) + @staticmethod + def get_vms(node): + """ + Get a list of VMs that are connected to VPP interfaces + + :param node: VPP node. + :type node: dict + :returns: Dictionary containing a list of VMs and the interfaces that are connected to VPP + :rtype: dictionary + """ + + vmdict = {} + + print "Need to implement get vms" + + return vmdict + @staticmethod def get_int_ip(node): """ @@ -393,6 +420,7 @@ class VPPUtil(object): if lines[0].split(' ')[0] == 'FileNotFoundError': return interfaces + name = '' for line in lines: if len(line) is 0: continue @@ -582,6 +610,23 @@ class VPPUtil(object): return 0 + @staticmethod + def restart(node): + """ + + Starts vpp for a given node + + :param node: VPP node. + :type node: dict + """ + + cmd = 'service vpp restart' + (ret, stdout, stderr) = VPPUtil.exec_command(cmd) + if ret != 0: + raise RuntimeError('{} failed on node {} {} {}'. + format(cmd, node['host'], + stdout, stderr)) + @staticmethod def start(node): """ @@ -699,3 +744,40 @@ class VPPUtil(object): version[dct[0]] = dct[1].lstrip(' ') return version + + @staticmethod + def show_bridge(node): + """ + Shows the current bridge configuration + + :param node: VPP node. + :type node: dict + """ + + cmd = 'vppctl show bridge' + (ret, stdout, stderr) = VPPUtil.exec_command(cmd) + if ret != 0: + raise RuntimeError('{} failed on node {} {} {}'. + format(cmd, node['host'], + stdout, stderr)) + lines = stdout.split('\r\n') + bridges = [] + for line in lines: + if line == 'no bridge-domains in use': + print line + return + if len(line) == 0: + continue + + lspl = line.lstrip(' ').split() + if lspl[0] != 'BD-ID': + bridges.append(lspl[0]) + + for bridge in bridges: + cmd = 'vppctl show bridge {} detail'.format(bridge) + (ret, stdout, stderr) = VPPUtil.exec_command(cmd) + if ret != 0: + raise RuntimeError('{} failed on node {} {} {}'. + format(cmd, node['host'], + stdout, stderr)) + print stdout