當前位置: 首頁>>代碼示例>>Python>>正文


Python CsRoute.defaultroute_exists方法代碼示例

本文整理匯總了Python中CsRoute.CsRoute.defaultroute_exists方法的典型用法代碼示例。如果您正苦於以下問題:Python CsRoute.defaultroute_exists方法的具體用法?Python CsRoute.defaultroute_exists怎麽用?Python CsRoute.defaultroute_exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CsRoute.CsRoute的用法示例。


在下文中一共展示了CsRoute.defaultroute_exists方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process

# 需要導入模塊: from CsRoute import CsRoute [as 別名]
# 或者: from CsRoute.CsRoute import defaultroute_exists [as 別名]
    def process(self):
        route = CsRoute()
        found_defaultroute = False

        for dev in self.dbag:
            if dev == "id":
                continue
            ip = CsIP(dev, self.config)

            for address in self.dbag[dev]:
                # check if link is up
                if not self.check_if_link_up(dev):
                    cmd = "ip link set %s up" % dev
                    CsHelper.execute(cmd)

                gateway = str(address["gateway"])
                network = str(address["network"])

                ip.setAddress(address)

                if ip.configured():
                    logging.info("Address %s on device %s already configured", ip.ip(), dev)

                    ip.post_configure()

                else:
                    logging.info("Address %s on device %s not configured", ip.ip(), dev)
                    if CsDevice(dev, self.config).waitfordevice():
                        ip.configure()

                route.add_route(dev, network)

                # The code looks redundant here, but we actually have to cater for routers and
                # VPC routers in a different manner. Please do not remove this block otherwise
                # The VPC default route will be broken.
                if address["nw_type"] == "public" and not found_defaultroute:
                    if not route.defaultroute_exists():
                        if route.add_defaultroute(gateway):
                            found_defaultroute = True

        # once we start processing public ip's we need to verify there
        # is a default route and add if needed
        if not route.defaultroute_exists():
            cmdline = self.config.cmdline()
            if cmdline.get_gateway():
                route.add_defaultroute(cmdline.get_gateway())
開發者ID:radu-stefanache,項目名稱:cloudstack,代碼行數:48,代碼來源:CsAddress.py

示例2: process

# 需要導入模塊: from CsRoute import CsRoute [as 別名]
# 或者: from CsRoute.CsRoute import defaultroute_exists [as 別名]
    def process(self):
        route = CsRoute()

        for dev in self.dbag:
            if dev == "id":
                continue
            ip = CsIP(dev, self.config)

            for address in self.dbag[dev]:
                if(address["nw_type"]!="public"):
                    continue

                #check if link is up
                if (not self.check_if_link_exists(dev)):
                    logging.info("link %s does not exist, so not processing"%dev)
                    continue
                if not self.check_if_link_up(dev):
                   cmd="ip link set %s up"%dev
                   CsHelper.execute(cmd)

                network = str(address["network"])

                ip.setAddress(address)

                if ip.configured():
                    logging.info(
                        "Address %s on device %s already configured", ip.ip(), dev)

                    ip.post_configure()

                else:
                    logging.info(
                        "Address %s on device %s not configured", ip.ip(), dev)
                    if CsDevice(dev, self.config).waitfordevice():
                        ip.configure()
                route.add_route(dev, network)

        # once we start processing public ip's we need to verify there
        # is a default route and add if needed
        if not route.defaultroute_exists():
            cmdline=self.config.get_cmdline_instance()
            if(cmdline.get_gateway()):
                route.add_defaultroute(cmdline.get_gateway())
開發者ID:NunoEdgarGub1,項目名稱:cloudstack,代碼行數:45,代碼來源:CsAddress.py

示例3: process

# 需要導入模塊: from CsRoute import CsRoute [as 別名]
# 或者: from CsRoute.CsRoute import defaultroute_exists [as 別名]
    def process(self):
        route = CsRoute()
        found_defaultroute = False

        for dev in self.dbag:
            if dev == "id":
                continue
            ip = CsIP(dev, self.config)

            for address in self.dbag[dev]:

                gateway = str(address["gateway"])
                network = str(address["network"])

                ip.setAddress(address)

                if ip.configured():
                    logging.info(
                        "Address %s on device %s already configured", ip.ip(), dev)

                    ip.post_configure()

                else:
                    logging.info(
                        "Address %s on device %s not configured", ip.ip(), dev)
                    if CsDevice(dev, self.config).waitfordevice():
                        ip.configure()

                if address["nw_type"] != "control":
                    route.add_route(dev, network)

                # once we start processing public ip's we need to verify there
                # is a default route and add if needed
                if address["nw_type"] == "public" and not found_defaultroute:
                    if not route.defaultroute_exists():
                        if route.add_defaultroute(gateway):
                            found_defaultroute = True
開發者ID:scottwx,項目名稱:cloudstack,代碼行數:39,代碼來源:CsAddress.py


注:本文中的CsRoute.CsRoute.defaultroute_exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。