Esempio n. 1
0
 def ping(self, ip, other_opt='', size='56', count='5', expectation=True):
     src_ip = self.bms_ip6 if get_af_type(ip) == 'v6' else self.bms_ip
     ping = 'ping6' if get_af_type(ip) == 'v6' else 'ping'
     cmd = '%s -s %s -c %s %s %s' % (ping, str(size), str(count), other_opt,
                                     ip)
     output = self.run_namespace(cmd)
     if expectation:
         expected_result = ' 0% packet loss'
     else:
         expected_result = '100% packet loss'
     try:
         if expected_result not in output:
             self.logger.warn(
                 "Ping to IP %s from host %s(%s) should have %s" %
                 (ip, src_ip, self.name,
                  "passed" if expectation else "failed"))
             return False
         else:
             self.logger.info(
                 'Ping to IP %s from host %s(%s) %s as expected' %
                 (ip, src_ip, self.name,
                  "passed" if expectation else "failed"))
         return True
     except Exception as e:
         self.logger.warn("Got exception in ping from host ns ip %s: %s" %
                          (src_ip, e))
         return False
Esempio n. 2
0
 def get_bms_ips(self, af=None):
     if not af:
         af = self.inputs.get_af()
     af = ['v4', 'v6'] if 'dual' in af else af
     return [
         ip for ip in [self.bms_ip, self.bms_ip6]
         if (get_af_type(ip) and get_af_type(ip) in af)
     ]
 def get_cidrs(self, af=None):
     subnets = []
     for ipam in self.vnc_obj.get_network_ipam_refs():
         for subnet in ipam['attr'].ipam_subnets:
             subnets.append(
                 str(subnet.subnet.ip_prefix) + '/' +
                 str(subnet.subnet.ip_prefix_len))
     if not af or af == 'dual':
         return subnets
     return [x for x in subnets if af == get_af_type(x)]
Esempio n. 4
0
 def setUp(self):
     super(BMSFixture, self).setUp()
     if self.is_ironic_node:
        return
     try:
         if not self.port_fixture:
             self.create_vmi()
         if not self.external_dhcp_server and \
            not self.bms_ip and not self.bms_ip6:
             for address in self.port_fixture.get_ip_addresses():
                 if get_af_type(address) == 'v4':
                     self.bms_ip = address
                 elif get_af_type(address) == 'v6':
                     self.bms_ip6 = address
         if not self.bms_mac:
             self.bms_mac = self.port_fixture.mac_address
         if not self.bms_gw_ip and not self.bms_gw_ip6:
             for subnet in self.vn_fixture.vn_subnet_objs:
                 if get_af_type(subnet['gateway_ip']) == 'v4':
                     self.bms_gw_ip = subnet['gateway_ip']
                 elif get_af_type(subnet['gateway_ip']) == 'v6':
                     self.bms_gw_ip6 = subnet['gateway_ip']
         if not self.bms_ip_netmask and not self.bms_ip6_netmask:
             for subnet in self.vn_fixture.vn_subnet_objs:
                 if get_af_type(subnet['cidr']) == 'v4':
                     self.bms_ip_netmask = subnet['cidr'].split('/')[1]
                 if get_af_type(subnet['cidr']) == 'v6':
                     self.bms_ip6_netmask = subnet['cidr'].split('/')[1]
         host_macs = [intf['host_mac'] for intf in self.interfaces]
         if self.bms_mac in host_macs or not self.mgmt_ip:
             self.logger.debug('Not setting up Namespaces')
             return
         self.logger.info('Setting up namespace %s on BMS host %s' % (
                 self.namespace, self.mgmt_ip))
         self.setup_bms()
     except:
         try:
             self.cleanUp()
             self._clear_cleanups()
         finally:
             raise