Пример #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
    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")
Пример #3
0
 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)
Пример #4
0
    def handle_update_pods(self, pod_id):
        l3ClosMediation = L3ClosMediation()

        ## Get Object for this Pod based on ID
        ## Get Data from config file
        pod = l3ClosMediation.dao.getObjectById(Pod, pod_id)
        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(pod.id)
Пример #5
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)
Пример #6
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)
Пример #7
0
 def handle_create_ztp_config(self, pod_name):
     report = ResourceAllocationReport()
     with report._dao.getReadSession() as session:
         ztpServer = ZtpServer()
         ztpServer.createPodSpecificDhcpConfFile(session, pod_name)
Пример #8
0
 def createZtpConfiguration(self, dbSession, ipFabricId):
     try:
         ZtpServer.createPodSpecificDhcpConfFile(self, ipFabricId)
     except ValueError:
         raise bottle.HTTPError(404, "Fabric with id[%s] not found" % (ipFabricId))
Пример #9
0
 def handle_create_ztp_config(self, pod_name):
     report = ResourceAllocationReport()
     with report._dao.getReadSession() as session:
         ztpServer = ZtpServer()
         ztpServer.createPodSpecificDhcpConfFile(session, pod_name)
Пример #10
0
 def handle_create_ztp_config(self, pod_name):
     ztpServer = ZtpServer()
     ztpServer.createPodSpecificDhcpConfFile(pod_name)