Esempio n. 1
0
def site_create(**new_site_data):

    new_site = Site()

    new_site.name = new_site_data['name']
    new_site.description = new_site_data['description']
    new_site.url = new_site_data['url']
    new_site.path = new_site_data['path']
    new_site.local_path = new_site.path

    new_site.save()

    return new_site
Esempio n. 2
0
    def get_network_links(self):

        objs = []

        # Connectivity object - Point to Point
        cordpod1device = NetworkDevice()
        cordpod1device.id = self.networkdevice.id

        # Edge to Edge Point Connectivity Objects
        edgetoedgeconnectivity = NetworkEdgeToEdgePointConnection()
        edgetoedgeconnectivity.uni1_createbuffer = cordpod1device.id + "." + "of:000000001/1"
        edgetoedgeconnectivity.uni2_createbuffer = cordpod1device.id + "." + "of:000000001/2"
        edgetoedgeconnectivity.type = 'direct'
        edgetoedgeconnectivity.operstate = 'active'
        edgetoedgeconnectivity.adminstate = 'enabled'
        edgetoedgeconnectivity.sid = 'EdgeToEdgePointConnectivity_1'
        objs.append(edgetoedgeconnectivity)


        # Multipoint to Multipoint Connectivity Objects
        multipoint2multipointconnectivity=NetworkMultipointToMultipointConnection()
        multipoint2multipointconnectivity.operstate = 'active'
        multipoint2multipointconnectivity.adminstate = 'enabled'
        multipoint2multipointconnectivity.type = 'ethernet'
        multipoint2multipointconnectivity.sid = 'MultipointToMultipointConnectivity_1'

        #
        # Create JSON array for post-save behaviour
        #
        eps = []
        eps.append(cordpod1device.id + "." + "of:000000001/3")
        eps.append(cordpod1device.id + "." + "of:000000001/4")
        eps.append(cordpod1device.id + "." + "of:000000001/5")

        myjsonstr = {'eps': eps, 'foo':0, 'bar':0}
        multipoint2multipointconnectivity.eps_createbuffer = json.dumps(myjsonstr)
        objs.append(multipoint2multipointconnectivity)

        # Edge to Multipoint Connectivity Objects
        edge2multipointconnectivity = NetworkEdgeToMultipointConnection()
        edge2multipointconnectivity.operstate = 'active'
        edge2multipointconnectivity.adminstate = 'enabled'
        edge2multipointconnectivity.type = 'ethernet'
        edge2multipointconnectivity.sid = 'EdgeToMultipointConnectivity_1'
        edge2multipointconnectivity.root_createbuffer = cordpod1device.id + "." + "of:000000001/7"
        #
        # Create JSON array for post-save behaviour
        #
        eps = []
        eps.append(cordpod1device.id + "." + "of:000000001/6")
        eps.append(cordpod1device.id + "." + "of:000000001/8")

        myjsonstr = {'eps': eps, 'foo': 0, 'bar': 0}
        edge2multipointconnectivity.eps_createbuffer = json.dumps(myjsonstr)
        objs.append(edge2multipointconnectivity)

        # Create Objects for VnodGlobal Sort of Testing

        # Bandwidth Profile

        bwprofile = BandwidthProfile()
        bwprofile.bwpcfgcbs  = 0
        bwprofile.bwpcfgcir = 0
        bwprofile.bwpcfgebs = 0
        bwprofile.bwpcfgeir = 0
        bwprofile.name = 'TestBWP'
        objs.append(bwprofile)

        # Two Sites
        site1 = Site()
        site1.name = 'CORDPod1'
        site1.login_base = 'CordPod1'
        site1.site_url = 'http://1.2.3.4:8080/VnodLocalApi'
        objs.append(site1)

        site2 = Site()
        site2.name = 'CORDPod2'
        site2.login_base = 'CordPod2'
        site2.site_url = 'http://10.11.12.13:8080/VnodLocalApi'
        objs.append(site2)

        # Two Ports - one per Site

        remoteport1 = RemotePort()
        remoteport1.name = "CORDPOD1:Port1"
        remoteport1.sitename = 'CordPod1'
        remoteport1.edgeportname = cordpod1device.id + "." + "of:000000001/1"
        objs.append(remoteport1)

        remoteport2 = RemotePort()
        remoteport2.name = "CORDPOD2:Port1"
        remoteport2.sitename = 'CordPod2'
        remoteport2.edgeportname = cordpod1device.id + "." + "of:000000001/2"
        objs.append(remoteport2)

        # One Spoke/Site
        spoke1 = ServiceSpoke()
        spoke1.name = 'TestSpoke1'
        spoke1.remoteportname = "CORDPOD1:Port1"
        spoke1.remotevnodid = 'CORDPod1:VnodLocal:1'
        spoke1.operstate = 'inactive'
        spoke1.adminstate = 'enabled'
        spoke1.sitename = 'CordPod1'
        objs.append(spoke1)

        spoke2 = ServiceSpoke()
        spoke2.name = 'TestSpoke2'
        spoke2.remoteportname = "CORDPOD2:Port1"
        spoke2.remotevnodid = 'CORDPod2:VnodLocal:1'
        spoke2.operstate = 'active'
        spoke2.adminstate = 'enabled'
        spoke2.sitename = 'CordPod2'
        objs.append(spoke2)

        # One VnodGlobal Service
        vnodglobal = VnodGlobalService()
        vnodglobal.name = 'VnodGlobalPtToPtTest1'
        vnodglobal.type = 'eline'
        vnodglobal.vlanid = '100'
        vnodglobal.operstate = 'active'
        vnodglobal.adminstate = 'enabled'
        vnodglobal.servicehandle = 'testhandle1'
        vnodglobal.pointtopointsid = 'onos_eline_id'
        vnodglobal.bwpname = 'TestBWP'

        # Create JSON array for post-save behaviour
        #
        spokes = ['TestSpoke1', 'TestSpoke2']
        myjsonstr = {'spokes': spokes}
        vnodglobal.spokes_createbuffer = json.dumps(myjsonstr)
        objs.append(vnodglobal)

        return objs