示例#1
0
    def handle_deploy_ztp_config(self, pod_id):

        ## Find the Pod Object
        report = ResourceAllocationReport()
        with report._dao.getReadSession() as session:
            pod_object = report._dao.getObjectById(session, Pod, pod_id)
            podDirectoryName = "%s-%s" % (pod_id, pod_object.name)

        installedDhcpConf = "/etc/dhcp/dhcpd.conf"

        ## Generate the path to the dhcp conf
        generatedDhcpConf = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'out',
            podDirectoryName, "dhcpd.conf")

        if not os.path.isfile(generatedDhcpConf):
            print "DHCP configuration file has not been generated for Pod %s yet, will generate it first" % pod_id
            ztpServer = ZtpServer()
            ztpServer.createPodSpecificDhcpConfFile(session, pod_id)

        if util.isPlatformUbuntu():
            os.system('sudo cp ' + generatedDhcpConf + ' ' + installedDhcpConf)
            print "New configuration file copied to %s " % installedDhcpConf
            os.system("/etc/init.d/isc-dhcp-server restart")

        elif util.isPlatformCentos():
            os.system('sudo cp ' + generatedDhcpConf + ' ' + installedDhcpConf)
            print "New configuration file copied to %s " % installedDhcpConf
            os.system("/etc/rc.d/init.d/dhcpd restart")
示例#2
0
文件: rest.py 项目: ttjinma/OpenClos
 def createZtpConfiguration(self, dbSession, podId):
     try:
         ZtpServer().createPodSpecificDhcpConfFile(dbSession, podId)
     except PodNotFound as e:
         raise bottle.HTTPError(404, exception=e)
     except Exception as e:
         raise bottle.HTTPError(500, exception=e)
示例#3
0
    def handle_update_pods(self, pod_id):
        l3ClosMediation = L3ClosMediation()

        ## Get Object for this Pod based on ID
        ## Get Data from config file
        report = ResourceAllocationReport()
        with report._dao.getReadSession() as session:
            pod_object = report._dao.getObjectById(session, Pod, pod_id)
            pod_name = pod_object.name
        pods_from_conf = l3ClosMediation.loadClosDefinition()

        l3ClosMediation.updatePod(pod_id, pods_from_conf[pod_name])

        ## Regenerate devices configuration, cabling plan and ZTP configuration
        l3ClosMediation.createCablingPlan(pod_id)
        l3ClosMediation.createDeviceConfig(pod_id)

        ztpServer = ZtpServer()
        ztpServer.createPodSpecificDhcpConfFile(session, pod_id)
示例#4
0
 def handle_create_ztp_config(self, pod_name):
     report = ResourceAllocationReport()
     with report._dao.getReadSession() as session:
         ztpServer = ZtpServer()
         ztpServer.createPodSpecificDhcpConfFile(session, pod_name)