コード例 #1
0
def PrepareWorkloadVMotion(tc, candidateWorkloads):
    tc.vmotion_cntxt = parser.Dict2Object({})

    tc.vmotion_cntxt.OrigHome = {}
    tc.vmotion_cntxt.CurrentHome = {}
    tc.vmotion_cntxt.MoveRequest = {}
    tc.vmotion_cntxt.UUIDMap = api.GetNaplesNodeUuidMap()
    tc.vmotion_cntxt.TimeProfile = []

    for wl in candidateWorkloads:
        other_hosts = [
            _n.Name() for _n in api.GetNodes() if _n.Name() != wl.node_name
        ]
        if other_hosts:
            dest_host = other_hosts[0]
        else:
            api.Logger.warn("No alternative host found to move %s" %
                            wl.workload_name)
            continue
        tc.vmotion_cntxt.OrigHome[wl] = wl.node_name
        tc.vmotion_cntxt.CurrentHome[wl] = wl.node_name

        if dest_host not in tc.vmotion_cntxt.MoveRequest:
            tc.vmotion_cntxt.MoveRequest[dest_host] = []
        tc.vmotion_cntxt.MoveRequest[dest_host].append(wl)
        api.Logger.info("Preparing to move %s to %s" %
                        (wl.workload_name, dest_host))
    return
コード例 #2
0
    def __init__(self, spec):
        self.__spec = spec
        self.__testbundles = []
        self.__testbunfiles = []
        self.__verifs = []
        self.__debugs = []
        self.__setups = []
        self.__triggers = []
        self.__teardowns = []
        self.__common_args = parser.Dict2Object({})
        self.__setup_complete = False
        self.__release_versions = {}

        self.__aborted = False
        self.__attrs = {}
        self.__timer = timeprofiler.TimeProfiler()

        self.__stats_pass = 0
        self.__stats_fail = 0
        self.__stats_ignored = 0
        self.__stats_error = 0
        self.__stats_total = 0
        self.__stats_target = 0
        self.result = types.status.FAILURE
        self.__skip = self.__apply_skip_filters()
        self.__ignoreList = getattr(spec.meta, "ignore_list", [])
        self.__process_provision_spec()
        self.__defaultNicMode = getattr(spec.meta, "nicmode", "classic")
        self.__defaultNicPipeline = GlobalOptions.pipeline
        self.__portspeed = topo_pb2.DataSwitch.Speed_auto
        return
コード例 #3
0
def Setup(tc):
    api.Logger.verbose("BC MAC filter : Setup")
    tc.skip = False
    result = api.types.status.SUCCESS

    tc.skip, tc.workloads, tc.naples_node = filters_utils.getNaplesNodeandWorkloads(
    )
    if tc.skip:
        api.Logger.error(
            "BC MAC filter : Setup -> No Naples Topology - So skipping the TC")
        return api.types.status.IGNORED

    tc.device_data = defaultdict()
    tc.arping_count = __ARPING_COUNT
    for device_name in api.GetDeviceNames(tc.naples_node):
        data = parser.Dict2Object({})
        intfName2lifId_dict = hal_show_utils.GetIntfName2LifId_mapping(
            tc.naples_node, device_name)
        intf_pktfilter_list = getInterfaceList(tc.naples_node, device_name)
        statsCount, preStatsCount, postStatsCount = getStatObjects(
            tc, device_name)
        setattr(data, 'intfName2lifId_dict', intfName2lifId_dict)
        setattr(data, 'intf_pktfilter_list', intf_pktfilter_list)
        setattr(data, 'statsCount', statsCount)
        setattr(data, 'preStatsCount', preStatsCount)
        setattr(data, 'postStatsCount', postStatsCount)
        tc.device_data[device_name] = data

    api.Logger.info("BC MAC filter : Setup final result - ", result)
    debug_utils.collect_showtech(result)
    return result
コード例 #4
0
def Setup(tc):
    api.Logger.verbose("MC MAC filter : Setup")
    tc.skip = False
    result = api.types.status.SUCCESS

    if not api.RunningOnSameSwitch():
        tc.skip = True
        api.Logger.error("MC MAC filter : Setup -> Multi switch topology not supported yet - So skipping the TC")
        return api.types.status.IGNORED

    tc.skip, tc.workloads, tc.naples_node = filters_utils.getNaplesNodeandWorkloads()
    if tc.skip:
        api.Logger.error("MC MAC filter : Setup -> No Naples Topology - So skipping the TC")
        return api.types.status.IGNORED

    tc.device_data = defaultdict()
    for device_name in api.GetDeviceNames(tc.naples_node):
        data = parser.Dict2Object({})
        intfName2lifId_dict = hal_show_utils.GetIntfName2LifId_mapping(tc.naples_node)
        statsCount, preStatsCount, postStatsCount = getStatObjects(tc.naples_node, device_name)
        setattr(data, 'intfName2lifId_dict', intfName2lifId_dict)
        setattr(data, 'statsCount', statsCount)
        setattr(data, 'preStatsCount', preStatsCount)
        setattr(data, 'postStatsCount', postStatsCount)
        tc.device_data[device_name] = data

    api.Logger.info("MC MAC filter : Setup final result - ", result)
    debug_utils.collect_showtech(result)
    return result
コード例 #5
0
def __mapping_entry_handler(vnic, ep_ip_prefixes):
    """
    Generate/Destroy the lmap and rmap entries associated with vnic
    based on input EP IP entries.

    """
    api.Logger.info(
        f"Fixing local and remote mapping for {vnic}, ip prefixes {ep_ip_prefixes} "
    )
    ep_ips = set()
    for prefix in ep_ip_prefixes:
        ep_ips.add(__ip_from_prefix(prefix))
    api.Logger.info(f"IP address set: {ep_ips}")

    # Delete lmap entries
    for lmap in vnic.Children.copy():
        api.Logger.info(f"Handling lmap {lmap} {lmap.IP}")
        if lmap.IP in ep_ips:
            ep_ips.remove(lmap.IP)
        else:
            lmap.Delete()
            lmap.Destroy()
            # Delete rmap entries on other nodes
            for node in api.GetNaplesHostnames():
                if node != vnic.Node:
                    node_subnet = subnet_client.GetSubnetObject(
                        node, vnic.SUBNET.SubnetId)
                    rmap = node_subnet.GetRemoteMappingObjectByIp(lmap.IP)
                    assert (rmap)
                    rmap.Delete()
                    rmap.Destroy()

    # Add new lmap entries
    for ep_ip in ep_ips:
        lmap_spec = dict()
        lmap_spec['origin'] = 'discovered'
        lmap_spec['lipaddr'] = ep_ip
        vnic_spec = parser.Dict2Object({'lmap': [lmap_spec]})
        lmap_client.GenerateObjects(vnic.Node, vnic, vnic_spec)

        # Add rmap entries on other nodes
        for node in api.GetNaplesHostnames():
            if node != vnic.Node:
                mac = "macaddr/%s" % vnic.MACAddr.get()
                rmap_spec = dict()
                rmap_spec['rmacaddr'] = objects.TemplateFieldObject(mac)
                rmap_spec['ripaddr'] = ep_ip
                ipversion = utils.IP_VERSION_6 if lmap.AddrFamily == 'IPV6' else utils.IP_VERSION_4
                node_subnet = subnet_client.GetSubnetObject(
                    node, vnic.SUBNET.SubnetId)
                rmap_client.GenerateObj(node, node_subnet, rmap_spec,
                                        ipversion)
コード例 #6
0
    def __init__(self, wlSpec, default_vlan):
        self.__wlSpec = wlSpec
        self.__node = wlSpec.node
        self.__default_vlan = default_vlan

        self.__interfaces = {}
        self.__nic_devices = api.GetDeviceNames(self.__node)
        # Since its multi-Naples scenario, regenerate wl.interfaces
        for idx, dev_name in enumerate(self.__nic_devices):
            iflist = []
            hostIfList = api.GetWorkloadNodeHostInterfaces(
                self.GetNodeName(), dev_name)
            ifType = api.GetWorkloadNodeHostInterfaceType(
                self.GetNodeName(), dev_name)
            for ifnum, hostIntf in enumerate(hostIfList):
                obj = parser.Dict2Object({})
                setattr(obj, 'HostInterface', hostIntf)
                setattr(
                    obj, 'ParentHostInterface',
                    api.GetNodeParentHostInterface(self.GetNodeName(),
                                                   dev_name, hostIntf))
                setattr(obj, 'LogicalInterface',
                        'host_if{0}'.format(ifnum + 1))
                setattr(
                    obj, 'InterfaceIndex',
                    api.GetNodeParentHostInterfaceIndex(
                        self.GetNodeName(), dev_name, hostIntf))
                setattr(obj, 'InterfaceType', ifType)
                iflist.append(obj)
            if iflist:
                self.__interfaces[dev_name] = iflist

        if self.__wlSpec.count == 'auto':
            # Review following with bug PS-724 is fixed
            self.__num_subifs = int((api.Testbed_GetVlanCount() - 2) /
                                    len(self.__nic_devices))  # 1 for native
            api.Logger.info(
                "With %d nic-devices, evaluating %d sub-ifs with %d vlans" %
                (len(self.__nic_devices), self.__num_subifs,
                 api.Testbed_GetVlanCount()))
            # self.__num_subifs = 32
        else:
            self.__num_subifs = int(self.__wlSpec.count)

        self.portUdpAllocator = resmgr.TestbedPortAllocator(20000)
        self.portTcpAllocator = resmgr.TestbedPortAllocator(30000)

        return
コード例 #7
0
    def __build_image_object(self, processor):
        manifest_file = self.GetImageManifestFile()
        image_info = parser.JsonParse(manifest_file)
        images = parser.Dict2Object({})

        image_tag = GlobalOptions.pipeline
        if hasattr(self.__spec, 'image_manifest') and hasattr(self.__spec.image_manifest, 'build'): 
            setattr(images, 'build', self.__spec.image_manifest.build)
            image_tag += "-" + images.build

        all_fw_images = list(filter(lambda x: x.Processor == processor, image_info.Firmwares))
        if all_fw_images and len(all_fw_images) == 1:
            fw_images = list(filter(lambda x: x.tag == image_tag, all_fw_images[0].Images))
            if fw_images and len(fw_images) == 1:
                setattr(images, 'naples', fw_images[0].image)

        # Derive venice-image
        venice = False
        if hasattr(self.__spec, 'image_manifest') and hasattr(self.__spec.image_manifest, 'venice'): 
            venice = self.__spec.image_manifest.venice 
        if venice and image_info.Venice:
            setattr(images, 'venice', image_info.Venice[0].Image)

        # Derive driver-images
        driver = False
        if hasattr(self.__spec, 'image_manifest') and hasattr(self.__spec.image_manifest, 'driver'):
            driver = self.__spec.image_manifest.driver
        if driver:
            setattr(images, 'driver', image_info.Drivers)

        naples_sim = False
        if hasattr(self.__spec, 'image_manifest') and hasattr(self.__spec.image_manifest, 'naples_sim'):
            naples_sim = self.__spec.image_manifest.naples_sim
        if naples_sim:
            setattr(images, 'naples_sim', image_info.Simulation[0].Image)

        setattr(images, 'penctl', image_info.PenCtl[0].Image)
        return images
コード例 #8
0
def Setup(tc):
    api.Logger.verbose("UC MAC filter : Setup")
    tc.skip = False
    result = api.types.status.SUCCESS

    tc.skip, tc.workloads, naples_node = filters_utils.getNaplesNodeandWorkloads(
    )
    if tc.skip:
        api.Logger.error(
            "UC MAC filter : Setup -> No Naples Topology - So skipping the TC")
        return api.types.status.IGNORED

    tc.device_data = defaultdict()
    tc.naples_node = naples_node
    for device_name in api.GetDeviceNames(naples_node):
        #Get MAC address of all the naples' interfaces for rollback later
        naples_intf_mac_dict = filters_utils.getNaplesIntfMacAddrDict(
            naples_node, device_name)

        #Get workload interfaces for rollback later
        wloadIntf_list, wload_intf_vlan_map = getNaplesWorkloadInfo(
            naples_node, device_name)

        #Keep a dict of (wloadIntf, mac) pair for rollback later
        wload_intf_mac_dict = dict()

        #Get MAC address of all the workload interfaces
        for intf in wloadIntf_list:
            intf_mac_addr = host_utils.GetMACAddress(naples_node, intf)
            wload_intf_mac_dict.update({intf: intf_mac_addr})

        host_intf_mac_dict = dict()
        #Get MAC address of all the interfaces on the host of Naples (except the workload interfaces)
        host_intf_list = filters_utils.GetNaplesHostInterfacesList(
            naples_node, device_name)
        api.Logger.verbose("UC MAC filter : Setup host_intf_list : ",
                           host_intf_list)
        for intf in host_intf_list:
            if intf not in wload_intf_mac_dict:
                intf_mac_addr = host_utils.GetMACAddress(naples_node, intf)
                host_intf_mac_dict.update({intf: intf_mac_addr})

        #Store the following info for building endpoint view and also for rollback
        data = parser.Dict2Object({})
        setattr(data, 'naples_intf_mac_dict', naples_intf_mac_dict)
        setattr(data, 'host_intf_mac_dict', host_intf_mac_dict)
        setattr(data, 'wload_intf_mac_dict', wload_intf_mac_dict)
        setattr(data, 'wload_intf_vlan_map', wload_intf_vlan_map)

        api.Logger.debug("UC MAC filter : Setup naples_intf_mac_dict : ",
                         data.naples_intf_mac_dict)
        api.Logger.debug("UC MAC filter : Setup host_intf_mac_dict : ",
                         data.host_intf_mac_dict)
        api.Logger.debug("UC MAC filter : Setup wload_intf_mac_dict : ",
                         data.wload_intf_mac_dict)
        api.Logger.debug("UC MAC filter : Setup wload_intf_vlan_map : ",
                         data.wload_intf_vlan_map)
        tc.device_data[device_name] = data

    api.Logger.info("UC MAC filter : Setup final result - ", result)
    debug_utils.collect_showtech(result)
    return result
コード例 #9
0
def Setup(tc):
    api.Logger.info("Server Compatiblity Random-Wait Reboot")

    nodes = api.GetNodes()

    tc.naples_nodes = []
    tc.node_bmc_data = dict()
    tc.resp = api.types.status.SUCCESS
    #for every node in the setup
    for node in nodes:
        if api.IsNaplesNode(node.Name()):
            api.Logger.info(f"Found Naples Node: [{node.Name()}]")
            tc.naples_nodes.append(node)
            tc.node_bmc_data[node.Name()] = iota_util_parser.Dict2Object({})
        else:
            api.Logger.info(f"Skipping non-Naples Node: [{node.Name()}]")

    if len(tc.naples_nodes) == 0:
        api.Logger.error(f"Failed to find a Naples Node!")
        tc.resp = api.types.status.IGNORE
        return api.types.status.IGNORE

    # Check for
    for node in tc.naples_nodes:
        node_data = tc.node_bmc_data[node.Name()]
        # save
        api.Logger.info(f"Saving node: {node.Name()}")
        if api.SaveIotaAgentState([node.Name()]) == api.types.status.FAILURE:
            raise OfflineTestbedException

    # power-cycle nodes
    if tc.iterators.powercycle_method == "apc":
        api.ApcNodes([n.Name() for n in tc.naples_nodes])
    elif tc.iterators.powercycle_method == "ipmi":
        api.IpmiNodes([n.Name() for n in tc.naples_nodes])
    else:
        api.Logger.error(
            f"Powercycle-method: {tc.iterators.powercycle_method} unknown")
        return api.types.status.IGNORE

    time.sleep(180)

    for node in tc.naples_nodes:
        resp = api.RestoreIotaAgentState([node.Name()])
        if resp != api.types.status.SUCCESS:
            api.Logger.error(f"Failed to restore agent state after reboot")
            raise OfflineTestbedException
        api.Logger.info(f"Reboot SUCCESS")
        wl_api.ReAddWorkloads(node.Name())

        setattr(node_data, 'BmcLogs', dict())
        cimc_info = node.GetCimcInfo()
        node_data.BmcLogs['Init'] = iota_log_api.CollectBmcLogs(
            cimc_info.GetIp(), cimc_info.GetUsername(),
            cimc_info.GetPassword())

        # Check for any errors
        if bmc_utils.verify_bmc_logs(
                node.Name(), node_data.BmcLogs['Init'], tag='Init',
                save_logs=True) != api.types.status.SUCCESS:
            tc.resp = api.types.status.IGNORE
            break

        # TODO: Process BMC logs to get boot time-profile
        setattr(node_data, 'MeanBootTime', 120)  # FIXME

    return tc.resp