Module Expr Str Import alias Import alias ImportFrom alias alias ImportFrom alias Import alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias alias ImportFrom alias ImportFrom alias Assign NameStore Str Expr Call NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Str ClassDef bases body FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Dict NameLoad NameLoad body If CompareEq Call NameLoad NameLoad NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad Call NameLoad keyword NameLoad attr orelse Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr Call NameLoad keyword Call NameLoad Str NameLoad Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Pass decorator_list Expr Str FunctionDef arguments args NameParam NameParam defaults body If Call AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Str Return Call AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If CompareIsNot NameLoad NameLoad body TryExcept body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad handlers ExceptHandler type AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str NameLoad Assign NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr orelse Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str If Call AttributeLoad NameLoad attr body If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Return Call AttributeLoad AttributeLoad NameLoad attr attr Str orelse Return Call AttributeLoad AttributeLoad NameLoad attr attr Str orelse If Call AttributeLoad NameLoad attr body If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Return Call AttributeLoad AttributeLoad NameLoad attr attr Str orelse Return Call AttributeLoad AttributeLoad NameLoad attr attr Str orelse If Call AttributeLoad NameLoad attr body Expr Str If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Return Call AttributeLoad AttributeLoad NameLoad attr attr Str orelse Return Call AttributeLoad AttributeLoad NameLoad attr attr Str decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Dict Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Index Str Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str Call NameLoad AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str Call NameLoad AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr Str If BoolOpOr CompareIs SubscriptLoad NameLoad Index Str NameLoad CompareEq SubscriptLoad NameLoad Index Str Str body Assign SubscriptStore NameLoad Index Str Call NameLoad SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr Str If BoolOpOr CompareIs SubscriptLoad NameLoad Index Str NameLoad CompareEq SubscriptLoad NameLoad Index Str Str body Assign SubscriptStore NameLoad Index Str Call NameLoad SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr Str If BoolOpOr CompareIs SubscriptLoad NameLoad Index Str NameLoad CompareEq SubscriptLoad NameLoad Index Str Str body Assign SubscriptStore NameLoad Index Str Call NameLoad SubscriptLoad NameLoad Index Num Assign SubscriptStore NameLoad Index Str Call NameLoad AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str SubscriptLoad SubscriptLoad AttributeLoad NameLoad attr Index Str Index Str If CompareIsNot Call AttributeLoad NameLoad attr Str NameLoad body Assign SubscriptStore NameLoad Index Str BinOpAdd Str Call AttributeLoad NameLoad attr Str Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Dict body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults Dict body Expr Str Assign NameStore Str If CompareIs Call AttributeLoad NameLoad attr Str NameLoad body Assign SubscriptStore NameLoad Index Str ListLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad For NameStore AttributeLoad NameLoad attr body If CompareEq AttributeLoad NameLoad attr Str body Continue If CompareEq AttributeLoad NameLoad attr Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareIsNot NameLoad NameLoad body Assign NameStore BinOpAdd NameLoad NameLoad orelse Assign NameStore NameLoad orelse If CompareEq AttributeLoad NameLoad attr Str body If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Continue Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareIsNot NameLoad NameLoad body Assign NameStore BinOpAdd NameLoad NameLoad orelse Assign NameStore NameLoad orelse Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Continue Assign NameStore Call NameLoad AttributeLoad Call NameLoad AttributeLoad NameLoad attr attr If AttributeLoad NameLoad attr body Expr Call AttributeLoad SubscriptLoad NameLoad Index Str attr Dict Str Str Str Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Str NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad orelse If AttributeLoad NameLoad attr body Expr Call AttributeLoad SubscriptLoad NameLoad Index Str attr Dict Str Str Str Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Str NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad orelse Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad If Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign SubscriptStore NameLoad Index Str ListLoad For NameStore AttributeLoad NameLoad attr body Assign NameStore Dict Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr If CompareIsNot AttributeLoad NameLoad attr NameLoad body Assign SubscriptStore NameLoad Index Str BinOpAdd NameLoad AttributeLoad NameLoad attr orelse Assign SubscriptStore NameLoad Index Str NameLoad Assign SubscriptStore NameLoad Index Str BinOpAdd BinOpAdd BinOpAdd Str AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Expr Str Assign SubscriptStore NameLoad Index Str Call NameLoad BinOpAdd Str AttributeLoad NameLoad attr Expr Call AttributeLoad SubscriptLoad NameLoad Index Str attr NameLoad Return NameLoad decorator_list decorator_list If CompareEq NameLoad Str body Assign NameStore Call NameLoad With Call AttributeLoad AttributeLoad NameLoad attr attr NameStore body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad SubscriptLoad NameLoad Index Num attr Expr Call AttributeLoad NameLoad attr NameLoad AttributeLoad SubscriptLoad NameLoad Index Num attr
N/A N/A 
Created on Sep 10, 2014

@author: moloyc
 N/A os N/A logging jinja2 Environment PackageLoader netaddr IPNetwork N/A util model Pod dao Dao writer DhcpConfWriter propLoader OpenClosProperty loadLoggingConfig sqlalchemy.orm exc exception PodNotFound N/A moduleName ztp N/A N/A loadLoggingConfig appName moduleName N/A logger N/A N/A logging getLogger moduleName N/A ztpTemplateLocation N/A N/A N/A os path join conf ztp ZtpServer N/A N/A __init__ N/A N/A self conf templateEnv daoClass N/A N/A None Dao N/A N/A N/A N/A any conf False N/A N/A N/A self __conf N/A N/A N/A OpenClosProperty appName moduleName getProperties N/A N/A N/A self __conf conf N/A N/A self _dao N/A N/A daoClass getInstance N/A N/A templateEnv None N/A N/A N/A self templateEnv N/A Environment loader N/A PackageLoader jnpr.openclos ztpTemplateLocation N/A N/A N/A self templateEnv lstrip_blocks True N/A N/A N/A self templateEnv trim_blocks True N/A dcpServerReloadConfig N/A N/A self N/A N/A N/A N/A N/A  TODO: for 2.0, Not needed as of now
    def createSingleDhcpConfFile(self):
        pods = self._dao.getAll(Pod)

        if len(pods) > 0:
            confWriter = DhcpConfWriter(self.__conf, pods[0], self._dao)
            confWriter.writeSingle(self.generateSingleDhcpConf())
     generateSingleDhcpConf N/A N/A self session N/A N/A N/A N/A N/A util isPlatformUbuntu N/A N/A ztp N/A N/A self populateDhcpGlobalSettings N/A dhcpTemplate N/A N/A N/A self templateEnv get_template ubuntu.1stage.dhcp.conf N/A N/A N/A dhcpTemplate render ztp N/A N/A self populateDhcpDeviceSpecificSettingForAllPods session ztp N/A createPodSpecificDhcpConfFile N/A N/A self session podId N/A N/A N/A N/A podId None N/A N/A N/A N/A pod N/A N/A N/A self _dao getObjectById session Pod podId N/A N/A N/A N/A exc NoResultFound N/A N/A N/A PodNotFound N/A Pod[id='%s']: not found podId N/A confWriter N/A DhcpConfWriter N/A self __conf pod N/A self _dao N/A N/A N/A confWriter write N/A N/A self generatePodSpecificDhcpConf session N/A pod id N/A N/A N/A PodNotFound Pod id can't be None N/A getTemplate N/A N/A self N/A N/A N/A  
        Finds template based on o/s on which OpenClos is running
        and 1stage/2stage ZTP process
        returns: jinja2 template 
         N/A N/A N/A util isPlatformUbuntu N/A N/A N/A N/A util isZtpStaged N/A self __conf N/A N/A N/A N/A N/A self templateEnv get_template ubuntu.2stage.dhcp.conf N/A N/A N/A N/A N/A self templateEnv get_template ubuntu.1stage.dhcp.conf N/A N/A N/A N/A util isPlatformCentos N/A N/A N/A N/A util isZtpStaged N/A self __conf N/A N/A N/A N/A N/A self templateEnv get_template centos.2stage.dhcp.conf N/A N/A N/A N/A N/A self templateEnv get_template centos.1stage.dhcp.conf N/A N/A N/A N/A util isPlatformWindows N/A N/A  
            this code is for testing only, generated dhcpd.conf would not work on windows  
             N/A N/A N/A util isZtpStaged N/A self __conf N/A N/A N/A N/A N/A self templateEnv get_template ubuntu.2stage.dhcp.conf N/A N/A N/A N/A N/A self templateEnv get_template ubuntu.1stage.dhcp.conf N/A generatePodSpecificDhcpConf N/A N/A self session podId N/A N/A N/A ztp N/A N/A self populateDhcpGlobalSettings N/A dhcpTemplate N/A N/A self getTemplate N/A ztp N/A N/A self populateDhcpDeviceSpecificSetting session podId ztp N/A conf N/A N/A dhcpTemplate render ztp ztp N/A conf N/A populateDhcpGlobalSettings N/A N/A self N/A N/A N/A ztp N/A N/A ztpGlobalSettings N/A N/A N/A util loadClosDefinition N/A ztp N/A subnet N/A ztpGlobalSettings N/A dhcpSubnet N/A dhcpBlock N/A IPNetwork subnet N/A ipList N/A list N/A N/A dhcpBlock iter_hosts N/A N/A ztp N/A network N/A str N/A dhcpBlock network N/A N/A ztp N/A netmask N/A str N/A dhcpBlock netmask N/A N/A ztp N/A defaultRoute N/A N/A ztpGlobalSettings get dhcpOptionRoute N/A N/A N/A N/A ztp N/A defaultRoute None N/A N/A ztp N/A defaultRoute N/A N/A N/A ztp N/A defaultRoute N/A str N/A ipList N/A 0 N/A N/A ztp N/A rangeStart N/A N/A ztpGlobalSettings get dhcpOptionRangeStart N/A N/A N/A N/A ztp N/A rangeStart None N/A N/A ztp N/A rangeStart N/A N/A N/A ztp N/A rangeStart N/A str N/A ipList N/A 1 N/A N/A ztp N/A rangeEnd N/A N/A ztpGlobalSettings get dhcpOptionRangeEnd N/A N/A N/A N/A ztp N/A rangeEnd None N/A N/A ztp N/A rangeEnd N/A N/A N/A ztp N/A rangeEnd N/A str N/A ipList N/A -1 N/A N/A ztp N/A broadcast N/A str N/A dhcpBlock broadcast N/A N/A ztp N/A httpServerIp N/A N/A N/A self __conf N/A httpServer N/A ipAddr N/A N/A N/A N/A ztpGlobalSettings get junosImage None N/A N/A N/A ztp N/A imageUrl N/A openclos/images/ N/A N/A ztpGlobalSettings get junosImage N/A ztp N/A populateDhcpDeviceSpecificSettingForAllPods N/A N/A self session ztp N/A N/A N/A N/A pods N/A N/A N/A self _dao getAll session Pod N/A pod pods N/A N/A ztp N/A N/A self populateDhcpDeviceSpecificSetting session N/A pod id ztp N/A ztp N/A populateDhcpDeviceSpecificSetting N/A N/A self session podId ztp N/A N/A N/A N/A 
        don't start any url as /openclos/... first / causes ZTP problem
         N/A imageUrlPrefix openclos/images/ N/A N/A N/A N/A ztp get devices None N/A N/A N/A ztp N/A devices N/A N/A pod N/A N/A N/A self _dao getObjectById session Pod podId N/A device N/A pod devices N/A N/A N/A N/A device family unknown N/A N/A N/A N/A N/A device role spine N/A N/A imageName N/A N/A util getImageNameForDevice pod device N/A N/A imageName None N/A N/A imageUrl N/A imageUrlPrefix imageName N/A N/A imageUrl None N/A N/A N/A N/A device role leaf N/A N/A N/A N/A util isZtpStaged N/A self __conf N/A N/A N/A imageName N/A N/A util getImageNameForDevice pod device N/A N/A imageName None N/A N/A imageUrl N/A imageUrlPrefix imageName N/A N/A imageUrl None N/A N/A N/A N/A logger error N/A PodId: %s, Pod: %s, Device: %s with unknown role: %s N/A N/A pod id N/A pod name N/A device name N/A device role N/A N/A deviceMgmtIp N/A str N/A N/A IPNetwork N/A device managementIp ip N/A N/A device macAddress N/A N/A N/A N/A N/A ztp N/A devices append N/A name mac configUrl imageUrl mgmtIp N/A device name N/A device macAddress N/A N/A N/A N/A openclos/pods/ N/A pod id /devices/ N/A device id /config imageUrl deviceMgmtIp N/A N/A N/A logger info N/A Device: %s, %s used MAC to map in dhcpd.conf N/A N/A device name deviceMgmtIp N/A N/A N/A device serialNumber N/A N/A N/A N/A N/A ztp N/A devices append N/A name serial configUrl imageUrl mgmtIp N/A device name N/A device serialNumber N/A N/A N/A N/A openclos/pods/ N/A pod id /devices/ N/A device id /config imageUrl deviceMgmtIp N/A N/A N/A logger info N/A Device: %s, %s used Serial to map in dhcpd.conf N/A N/A device name deviceMgmtIp N/A N/A N/A N/A logger error N/A Device: %s, %s does not have MAC or SerialNumber, not added in dhcpd.conf N/A N/A device name deviceMgmtIp N/A N/A N/A util isZtpStaged N/A self __conf N/A N/A N/A ztp N/A leafs N/A N/A leafSetting N/A pod leafSettings N/A N/A setting N/A N/A N/A setting N/A leafDeviceFamily N/A leafSetting deviceFamily N/A N/A N/A leafSetting junosImage None N/A N/A N/A setting N/A leafImageUrl N/A imageUrlPrefix N/A leafSetting junosImage N/A N/A N/A setting N/A leafImageUrl None N/A N/A setting N/A leafGenericConfigUrl N/A N/A N/A openclos/pods/ N/A pod id /leaf-generic-configurations/ N/A leafSetting deviceFamily N/A 
                setting['substringLength'] is the last argument of substring on dhcpd.conf, 
                should not be hardcoded, as it would change based on device family
                match if substring (option vendor-class-identifier, 0,21) = "Juniper-qfx5100-48s-6q"
    
                 N/A N/A setting N/A substringLength N/A len N/A Juniper- N/A leafSetting deviceFamily N/A N/A N/A N/A ztp N/A leafs append setting N/A ztp N/A N/A N/A N/A __name__ __main__ N/A N/A ztpServer N/A ZtpServer N/A N/A N/A N/A ztpServer _dao getReadSession session N/A N/A pods N/A N/A N/A ztpServer _dao getAll session Pod N/A N/A N/A ztpServer createPodSpecificDhcpConfFile session N/A N/A pods N/A 0 id N/A N/A N/A ztpServer createPodSpecificDhcpConfFile session N/A N/A pods N/A 1 id