Esempio n. 1
0
def perform_bulk_delete_vlans(agent,
                              org_name,
                              fname,
                              fn_deploy,
                              vlans_only=False):
    store_list = Json.reader(fname, "templates")

    if not goahead_confirm("stores"):
        return

    for store in store_list:
        store_name = store.get("name", None)
        l.runlogs_logger.info("deploying network: {}".format(store_name))
        if store_name is None:
            str = "fname: {} ::: store_name field was not found for store {}".format(
                fname, store)
            l.logger.error(str)
            l.runlogs_logger.error(str)
            gv.fake_assert()
        l.logger.info("deploying store : {}".format(store_name))
        auto_globals.select_store(store_name)
        if (auto_globals.load_store(agent, store_name)) is False:
            l.logger.error("failed deploying network: {}".format(store_name))
            l.runlogs_logger.error(
                "failed deploying network: {}".format(store_name))
            return

        fn_deploy(agent, vlans_only)
        l.logger.info("deployed store : {}".format(store_name))
        Json.writer(fname, store_list, "templates")
        Csv.transform_to_csv(fname, None, path="templates")
        l.runlogs_logger.info("deployed network: {}  netid: {}".format(
            store_name, settings["netid"]))
Esempio n. 2
0
def perform_bulk_get_firewall(agent, fn_get, org_name, store_list):
    fname = store_list
    store_list = Json.reader(fname, "templates")

    for store in store_list:
        store_name = store.get("name", None)
        if store_name is None:
            str = "fname: {} ::: name field was not found for store {}".format(
                fname, store)
            l.runlogs_logger.error(str)
            l.logger.error(str)
            gv.fake_assert()
        auto_globals.select_store(store_name)
        try:
            success = auto_globals.load_store(agent, store_name)
            assert (success)
            str = ('getting l3fwrules for {}'.format(store_name))
            l.logger.info(str)
            l.runlogs_logger.info(str)
            fn_get(agent)
            str = ('got l3fwrules for {}'.format(store_name))
            l.logger.info(str)
            l.runlogs_logger.info(str)
        except:
            str = "failed getting l3fwrules for store : {}".format(store_name)
            l.logger.error(str)
            l.runlogs_logger.error(str)
            gv.fake_assert()
Esempio n. 3
0
def bulk_deploy_networks_for_all_orgs(agent):
    org_group = settings["CLI"]["networks-org"]
    store_list = settings["CLI"]["networks-store-list"]
    serials_list = settings.get("CLI").get("networks-serials")
    l.runlogs_logger.info("deploy networks <starting>")

    org_list = json.reader(org_group, "templates")
    orglist = json.make_pretty(org_list)

    l.logger.info("org   list: {}".format(orglist))
    l.logger.info("store list: {}".format(store_list))
    l.logger.info("serials list: {}".format(serials_list))

    for org in org_list:
        org_name = org["org_name"]
        auto_globals.select_org(org_name)
        l.runlogs_logger.info("selected org: {}".format(org_name))
        l.runlogs_logger.info("using clone source: {}".format(settings["CLI"]["networks-clone-source"]))
        l.runlogs_logger.info("using serials : {}".format(settings.get("CLI").get("networks-serials")))

        # Now get the netid for the clone_source
        store_name = settings["CLI"]["networks-clone-source"]
        auto_globals.select_store(store_name)
        auto_globals.load_store(agent, store_name)
        config.set_clone_id(settings["netid"])

        bulk.perform_bulk_deploy_networks(agent, deploy, deploy_serials,  store_list)
    l.runlogs_logger.info("deploy networks <finished>")
Esempio n. 4
0
def perform_bulk_update_firewall(agent, fn_deploy, fw_rules, store_list):
    fname = store_list
    store_list = Json.reader(fname, "templates")
    """Ensure that the list now has always all the three fields
    in short that it is normalized so csv conversion is not upset"""
    Json.writer(fname, store_list, "templates")
    Csv.transform_to_csv(fname, None, path="templates")

    show_store_list(store_list)

    if not goahead_confirm("l3fwrules"):
        return

    for store in store_list:
        store_name = store.get("name", None)

        if store_name is None:
            str = "fname: {} ::: name field was not found for store {}".format(
                fname, store)
            l.runlogs_logger.error(str)
            l.logger.error(str)
            gv.fake_assert()
        auto_globals.select_store(store_name)
        try:
            assert (auto_globals.load_store(agent, store_name))
            str = ('deploying l3fwrules to {}'.format(store_name))
            l.runlogs_logger.info(str)
            fn_deploy(agent, fw_rules)
            str = ('deployed l3fwrules to {}'.format(store_name))
            l.logger.info(str)
            l.runlogs_logger.info(str)
        except:
            str = "failed deployment for store : {}".format(store_name)
            l.logger.error(str)
            l.runlogs_logger.error(str)
            gv.fake_assert()
Esempio n. 5
0
def perform_bulk_deploy_networks(agent, fn_deploy, fn_deploy_serials,
                                 store_list_file):

    store_list = Json.reader(store_list_file, "templates")
    show_store_list(store_list)
    serials_list_file = settings.get("CLI").get("networks-serials")
    if serials_list_file:
        serials_list = Json.reader(serials_list_file, "templates")
    else:
        serials_list = None
    if not goahead_confirm("stores"):
        return

    for store in store_list:
        store_name = store.get("name", None)
        if store_name is None:
            l.logger.error(
                "fname: {} ::: name field was not found for store {}".format(
                    store))
            l.runlogs_logger.error(
                "fname: {} ::: name field was not found for store {}".format(
                    store))
            gv.fake_assert()
        l.runlogs_logger.info("created network : {}".format(store_name))
        l.logger.info("created network : {}".format(store_name))

        auto_globals.select_store(store_name)
        assert (auto_globals.load_empty_store(agent, store_name))
        if gv.use_serials:
            if serials_list is None:
                l.logger.error("failed no serials file provided")
                l.runlogs_logger.error("failed no serials file provided")
                return

        if not fn_deploy(agent):
            l.logger.error("failed to create network : {}".format(store_name))
            l.runlogs_logger.error(
                "failed to create network : {}".format(store_name))
            return

        if gv.use_serials:
            serial_count = auto_globals.load_store_serials(
                store_name, serials_list)
            for count in range(1, serial_count + 1):
                settings["serial"] = settings["serial{}".format(count)]
                settings["device-name"] = settings["device-name{}".format(
                    count)]
                l.runlogs_logger.info("adding serial {} to {}".format(
                    settings["serial"], store_name))
                l.logger.info("adding serial {} to {}".format(
                    settings["serial"], store_name))
                if not fn_deploy_serials():
                    if gv.serial_not_available_revert_clone:
                        destroy(netid=settings["netid"])
                    l.logger.error(
                        "failed adding serial {} to  network : {}".format(
                            settings["serial"], store_name))
                    l.runlogs_logger.error(
                        "failed adding serial {} network : {}".format(
                            settings["serial"], store_name))
                    return
                l.runlogs_logger.info("added serial {} to {}".format(
                    settings["serial"], store_name))
                l.logger.info("added serial {} to {}".format(
                    settings["serial"], store_name))