def intercloudGW_stop(intercloudGW):
    response = respAction("200", "ok")
    """Implement here your function"""
    print(
        '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
    print(
        '                Receiving action STOP intercloudGW                  ')
    #------------------------------------------------linkgw------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle linkgw category """
    attributePUB = {'what': 'linkgw'}
    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    attribute = {
        'intercloudGW': intercloudGW.node,
        'state': '1',
    }
    conetsOCCI = OCCIclient(publication['host'], publication['port'],
                            'CO-NETS-PAAS', 'linkgw', attribute)
    listInstance = conetsOCCI.Get()

    for item in listInstance:
        linkgws = conetsOCCI.GetElement_pathuuid(item)
        conetsOCCI.host = linkgws['host']
        conetsOCCI.port = linkgws['port']
        conetsOCCI.category = linkgws['category']
        linkgws = conetsOCCI.GetElement(linkgws['uuid'])
        print('Sending STOP to linkgw')
        conetsOCCI.action(linkgws['occi.core.id'], 'stop')

    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    tempintercloudGW = {
        'name': intercloudGW.name,
        'node': intercloudGW.node,
        'account': intercloudGW.account,
        'price': intercloudGW.price,
        'state': intercloudGW.state,
    }
    attribute = {
        'state': '0',
    }
    conetsOCCI.category = 'intercloudGW'
    conetsOCCI.attributes = tempintercloudGW

    uuidintercloudGW = conetsOCCI.Get()
    conetsOCCI.attributes = attribute
    conetsOCCI.Put(conetsOCCI.GetElement_pathuuid(uuidintercloudGW[0])['uuid'])
    print('Changing the state of the intercloudGW to 0')

    return response
def intercloudGW_stop(intercloudGW):
	response=respAction("200","ok")
	"""Implement here your function"""
	print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
	print('                Receiving action STOP intercloudGW                  ')
	#------------------------------------------------linkgw------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#	
	""" Determine server which handle linkgw category """
	attributePUB= {
		'what': 'linkgw'
	}
	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])
	

	attribute = {
		'intercloudGW': intercloudGW.node,
		'state': '1',
	}
	conetsOCCI = OCCIclient(publication['host'], publication['port'], 'CO-NETS-PAAS', 'linkgw', attribute)
	listInstance = conetsOCCI.Get()

	for item in listInstance:
        	linkgws = conetsOCCI.GetElement_pathuuid(item)
        	conetsOCCI.host = linkgws['host']
        	conetsOCCI.port = linkgws['port']
        	conetsOCCI.category = linkgws['category']
        	linkgws = conetsOCCI.GetElement(linkgws['uuid'])
		print('Sending STOP to linkgw')
		conetsOCCI.action(linkgws['occi.core.id'], 'stop')

	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	tempintercloudGW={
		'name':intercloudGW.name,
		'node':intercloudGW.node,
		'account':intercloudGW.account,
		'price':intercloudGW.price,
		'state': intercloudGW.state,
	}
	attribute = {
		'state': '0',
	}
	conetsOCCI.category = 'intercloudGW'
        conetsOCCI.attributes = tempintercloudGW
        
	uuidintercloudGW=conetsOCCI.Get()
	conetsOCCI.attributes=attribute
	conetsOCCI.Put(conetsOCCI.GetElement_pathuuid(uuidintercloudGW[0])['uuid'])
	print('Changing the state of the intercloudGW to 0')

	return response
def intercloudGW_start(intercloudGW):
	response=respAction("200","ok")
	"""Implement here your function"""
	print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
	print('                Receiving action START intercloudGW                 ')


	#---------------------------------------------------intercloudGW---------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle intercloudGW category """
	attributePUB= {
		'what': 'intercloudGW'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])

	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#

	tempintercloudGW={
		'name':intercloudGW.name,
		'node':intercloudGW.node,
		'account':intercloudGW.account,
		'price': intercloudGW.price,
		'state':intercloudGW.state,
	}

	gwOCCI = OCCIclient(publication['host'], publication['port'], 'CO-NETS-PAAS', 'intercloudGW', tempintercloudGW)

	uuidintercloudGW=gwOCCI.Get()[0].replace(' ','')
	
	#-------------------------------------------------contract---------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle contract category """
	attributePUB= {
		'what': 'contract'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


	attribute = {
		'provider': uuidintercloudGW,
		'profile': 'intercloudGW',
		'node':intercloudGW.node,
	} 
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'contract', attribute)
	listinstruction=client.GetLinks(client.GetElement_pathuuid(client.Get()[0])['uuid'])
	#print listinstruction


	#------------------------------------------------Instruction-------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#    
	""" Determine server which handle instruction category """
	attributePUB= {
		'what': 'instruction'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])

	attribute = {}
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'instruction', attribute)

	listNodeToConnect = []
	for item in listinstruction:
		nodetoConnect = client.GetElement_pathuuid(item)
		client.host = nodetoConnect['host']
		client.port = nodetoConnect['port']
		client.category = nodetoConnect['category']
		listNodeToConnect.append(client.GetElement(nodetoConnect['uuid'])['occi.instruction.source'])


	listlinkgw = []
	for i in range(len(listNodeToConnect)):
		for j in range(i+1,len(listNodeToConnect)):
			listlinkgw.append( {
				'name': intercloudGW.name,
				'intercloudGW': intercloudGW.node,
				'account': intercloudGW.account,
				'gwsrc': '',
				'gwdst': '',
				'tunnelproto': 'gre',
				'addressgresrc': '10.3.3.1',
				'addressgredst': '10.3.3.2',
				'prefix': '30',
				'authenticationkey': 'test_key_1',
				'endpointsrc': listNodeToConnect[i],
				'endpointdst': listNodeToConnect[j],
				'state': '0',
			})



	#------------------------------------------------linkgw------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#	
	""" Determine server which handle linkgw category """
	attributePUB= {
		'what': 'linkgw'
	}
	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])
	

	listuuidlinkgw = []
	for i in listlinkgw:
		conetsOCCI = OCCIclient(publication['host'], publication['port'], 'CO-NETS-PAAS', 'linkgw', i)
		uuidlinkgw = conetsOCCI.GetElement_pathuuid(conetsOCCI.Post())['uuid']
		listuuidlinkgw.append(uuidlinkgw)
		print('Sending Post to linkgw')

	for item in listuuidlinkgw:
		print('Sending START to linkgw')
		conetsOCCI.action(item, 'start')

	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	tempintercloudGW={
		'name':intercloudGW.name,
		'node':intercloudGW.node,
		'account':intercloudGW.account,
		'price':intercloudGW.price,
		'state': intercloudGW.state,
	}
	attribute = {
		'state': '1',
	}
	conetsOCCI.category = 'intercloudGW'
        conetsOCCI.attributes = tempintercloudGW
        
	uuidintercloudGW=conetsOCCI.Get()
	conetsOCCI.attributes=attribute
	conetsOCCI.Put(conetsOCCI.GetElement_pathuuid(uuidintercloudGW[0])['uuid'])
	print('Changing the state of the intercloudGW to 1')

	return response
예제 #4
0
def linkgw_start(linkgw):
    response = respAction("200", "ok")
    """Implement here your function"""
    print(
        '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
    print(
        '                 Receiving action START linkgw                      ')

    #---------------------------------------------------gw-------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle gw category """
    attributePUB = {'what': 'gw'}

    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    attribute = {}
    conetsOCCI = OCCIclient(publication['host'], publication['port'],
                            'CO-NETS-PAAS', 'gw', attribute)

    #--------------------------------------------uuid gw src-----------------------------------------------------------#
    gwsrc = conetsOCCI.GetElement_pathuuid(linkgw.gwsrc)
    addressgwsrc = conetsOCCI.GetElement(gwsrc['uuid'])
    publicaddrgwsrc = addressgwsrc['occi.gw.publicaddr']
    privateaddrgwsrc = addressgwsrc['occi.gw.privateaddr']
    ethernamegwsrc = addressgwsrc['occi.gw.ethername']

    #--------------------------------------------uuid gw dst-----------------------------------------------------------#
    gwdst = conetsOCCI.GetElement_pathuuid(linkgw.gwdst)
    addressgwdst = conetsOCCI.GetElement(gwdst['uuid'])
    publicaddrgwdst = addressgwdst['occi.gw.publicaddr']
    privateaddrgwdst = addressgwdst['occi.gw.privateaddr']
    ethernamegwdst = addressgwdst['occi.gw.ethername']
    #-----------------------------start gateway source and gateway destination-----------------------------------------#

    print('Sending START to gateway source')
    conetsOCCI.action(gwsrc['uuid'], 'start')
    print('Sending START to gateway destination')
    conetsOCCI.action(gwdst['uuid'], 'start')

    #-------------------------------------------------contract---------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle contract category """
    attributePUB = {'what': 'contract'}

    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    attribute = {}
    client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER',
                        'contract', attribute)

    endpointsrc = client.GetElement(
        client.GetElement_pathuuid(linkgw.endpointsrc)['uuid'])
    endpointdst = client.GetElement(
        client.GetElement_pathuuid(linkgw.endpointdst)['uuid'])

    #-------------------------------------------------provider gwsrc---------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle procci provider category """
    attributePUB = {'what': endpointsrc['occi.contract.profile']}

    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    attribute = {}
    client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER',
                        endpointsrc['occi.contract.profile'], attribute)

    #print endpointsrc['occi.contract.provider']
    privateaddrvmsrc = client.GetElement(
        client.GetElement_pathuuid(
            endpointsrc['occi.contract.provider'])['uuid'])
    privateaddrvmsrc = privateaddrvmsrc['occi.' +
                                        endpointsrc['occi.contract.profile'] +
                                        '.privateaddr']

    #-------------------------------------------------provider gwdst---------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle procci provider category """
    attributePUB = {'what': endpointdst['occi.contract.profile']}

    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    attribute = {}
    client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER',
                        endpointdst['occi.contract.profile'], attribute)

    #print endpointdst['occi.contract.provider']
    privateaddrvmdst = client.GetElement(
        client.GetElement_pathuuid(
            endpointdst['occi.contract.provider'])['uuid'])
    privateaddrvmdst = privateaddrvmdst['occi.' +
                                        endpointdst['occi.contract.profile'] +
                                        '.privateaddr']

    gwsrc = gwProcci()
    gwdst = gwProcci()

    templist = privateaddrvmsrc.split('.')
    templist[3] = '0/24'
    privateaddrvmsrc = '.'.join(templist)
    #print privateaddrvmsrc

    templist = privateaddrvmdst.split('.')
    templist[3] = '0/24'
    privateaddrvmdst = '.'.join(templist)
    #print privateaddrvmdst
    ''' Configuration des gateways'''
    gwsrc.configure_protocol_IPSEC(gwsrc, publicaddrgwsrc, ethernamegwsrc,
                                   'IKEgwsrc', 'ESPgwsrc')
    gwdst.configure_protocol_IPSEC(gwdst, publicaddrgwdst, ethernamegwdst,
                                   'IKEgwdst', 'ESPgwdst')
    ''' Connecte les deux gateways'''
    gwsrc.connect_gw(gwsrc, linkgw.addressgresrc, linkgw.prefix,
                     linkgw.tunnelproto, publicaddrgwsrc, publicaddrgwdst,
                     linkgw.authenticationkey, linkgw.addressgredst,
                     privateaddrvmdst)
    gwsrc.connect_gw(gwsrc, linkgw.addressgredst, linkgw.prefix,
                     linkgw.tunnelproto, publicaddrgwdst, publicaddrgwsrc,
                     linkgw.authenticationkey, linkgw.addressgresrc,
                     privateaddrvmsrc)

    return response
예제 #5
0
def linkgw_stop(linkgw):
    response = respAction("200", "ok")
    """Implement here your function"""
    print(
        '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
    print(
        '                   Receiving action STOP linkgw                     ')

    #---------------------------------------------------gw-------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle gw category """
    attributePUB = {'what': 'gw'}

    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    attribute = {}
    gwOCCI = OCCIclient(publication['host'], publication['port'], 'CO-PARSER',
                        'gw', attribute)

    #--------------------------------------------uuid gw src-----------------------------------------------------------#
    gwsrc = gwOCCI.GetElement_pathuuid(linkgw.gwsrc)
    #--------------------------------------------uuid gw dst-----------------------------------------------------------#
    gwdst = gwOCCI.GetElement_pathuuid(linkgw.gwdst)
    #------------------------------stop gateway source and gateway destination-----------------------------------------#
    print('Sending STOP to gateway source')
    gwOCCI.action(gwsrc['uuid'], 'stop')
    print('Sending STOP to gateway destination')
    gwOCCI.action(gwdst['uuid'], 'stop')

    templinkgw = {
        'name': linkgw.name,
        'intercloudGW': linkgw.intercloudGW,
        'account': linkgw.account,
        'gwsrc': linkgw.gwsrc,
        'gwdst': linkgw.gwdst,
        'tunnelproto': linkgw.tunnelproto,
        'addressgresrc': linkgw.addressgresrc,
        'addressgredst': linkgw.addressgredst,
        'prefix': linkgw.prefix,
        'authenticationkey': linkgw.authenticationkey,
        'endpointsrc': linkgw.endpointsrc,
        'endpointdst': linkgw.endpointdst,
        'state': linkgw.state,
    }

    gwOCCI.category = 'linkgw'
    gwOCCI.attributes = templinkgw

    uuidlinkgw = gwOCCI.Get()
    uuidlinkgw = gwOCCI.GetElement_pathuuid(uuidlinkgw[0])['uuid']

    attribute = {
        'state': '0',
    }

    gwOCCI.attributes = attribute
    gwOCCI.Put(uuidlinkgw)
    print('Changing the state of the link gateway to 0')

    return response
def intercloudGW_start(intercloudGW):
    response = respAction("200", "ok")
    """Implement here your function"""
    print(
        '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
    print(
        '                Receiving action START intercloudGW                 ')

    #---------------------------------------------------intercloudGW---------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle intercloudGW category """
    attributePUB = {'what': 'intercloudGW'}

    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#

    tempintercloudGW = {
        'name': intercloudGW.name,
        'node': intercloudGW.node,
        'account': intercloudGW.account,
        'price': intercloudGW.price,
        'state': intercloudGW.state,
    }

    gwOCCI = OCCIclient(publication['host'], publication['port'],
                        'CO-NETS-PAAS', 'intercloudGW', tempintercloudGW)

    uuidintercloudGW = gwOCCI.Get()[0].replace(' ', '')

    #-------------------------------------------------contract---------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle contract category """
    attributePUB = {'what': 'contract'}

    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    attribute = {
        'provider': uuidintercloudGW,
        'profile': 'intercloudGW',
        'node': intercloudGW.node,
    }
    client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER',
                        'contract', attribute)
    listinstruction = client.GetLinks(
        client.GetElement_pathuuid(client.Get()[0])['uuid'])
    #print listinstruction

    #------------------------------------------------Instruction-------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle instruction category """
    attributePUB = {'what': 'instruction'}

    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    attribute = {}
    client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER',
                        'instruction', attribute)

    listNodeToConnect = []
    for item in listinstruction:
        nodetoConnect = client.GetElement_pathuuid(item)
        client.host = nodetoConnect['host']
        client.port = nodetoConnect['port']
        client.category = nodetoConnect['category']
        listNodeToConnect.append(
            client.GetElement(
                nodetoConnect['uuid'])['occi.instruction.source'])

    listlinkgw = []
    for i in range(len(listNodeToConnect)):
        for j in range(i + 1, len(listNodeToConnect)):
            listlinkgw.append({
                'name': intercloudGW.name,
                'intercloudGW': intercloudGW.node,
                'account': intercloudGW.account,
                'gwsrc': '',
                'gwdst': '',
                'tunnelproto': 'gre',
                'addressgresrc': '10.3.3.1',
                'addressgredst': '10.3.3.2',
                'prefix': '30',
                'authenticationkey': 'test_key_1',
                'endpointsrc': listNodeToConnect[i],
                'endpointdst': listNodeToConnect[j],
                'state': '0',
            })

    #------------------------------------------------linkgw------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    """ Determine server which handle linkgw category """
    attributePUB = {'what': 'linkgw'}
    client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication',
                        attributePUB)
    publication = client.GetElement_pathuuid(client.Get()[0])
    client.host = publication['host']
    client.port = publication['port']
    publication = client.GetElement_pathuuid(
        client.GetElement(publication['uuid'])['occi.publication.why'])

    listuuidlinkgw = []
    for i in listlinkgw:
        conetsOCCI = OCCIclient(publication['host'], publication['port'],
                                'CO-NETS-PAAS', 'linkgw', i)
        uuidlinkgw = conetsOCCI.GetElement_pathuuid(conetsOCCI.Post())['uuid']
        listuuidlinkgw.append(uuidlinkgw)
        print('Sending Post to linkgw')

    for item in listuuidlinkgw:
        print('Sending START to linkgw')
        conetsOCCI.action(item, 'start')

    #------------------------------------------------------------------------------------------------------------------#
    #------------------------------------------------------------------------------------------------------------------#
    tempintercloudGW = {
        'name': intercloudGW.name,
        'node': intercloudGW.node,
        'account': intercloudGW.account,
        'price': intercloudGW.price,
        'state': intercloudGW.state,
    }
    attribute = {
        'state': '1',
    }
    conetsOCCI.category = 'intercloudGW'
    conetsOCCI.attributes = tempintercloudGW

    uuidintercloudGW = conetsOCCI.Get()
    conetsOCCI.attributes = attribute
    conetsOCCI.Put(conetsOCCI.GetElement_pathuuid(uuidintercloudGW[0])['uuid'])
    print('Changing the state of the intercloudGW to 1')

    return response
예제 #7
0
def gw_start(gw):
	response=respAction("200","ok")
	"""Implement here your function"""
	print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
	print('                     Receiving action START gw                      ')

	#-------------------------------------------------contract---------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle contract category """
	attributePUB= {
		'what': 'contract'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


	attribute = {}
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'contract', attribute)

	#----------------------------------------------start Node----------------------------------------------------------#
	gwcontract = client.GetElement_pathuuid(gw.contract)
	print('Sending START to the contract of the gateway source')
	client.action(gwcontract['uuid'], 'start')
	gwcontract = client.GetElement(gwcontract['uuid'])

	#-------------------------------------------------provider gw------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle procci provider category """
	attributePUB= {
		'what': gwcontract['occi.contract.profile']
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


	attribute = {}
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', gwcontract['occi.contract.profile'], attribute)

	addressgw = client.GetElement(client.GetElement_pathuuid(gwcontract['occi.contract.provider'])['uuid'])
	gwprivateaddr = addressgw['occi.'+ gwcontract['occi.contract.profile'] +'.privateaddr']
	gwpublicaddr = addressgw['occi.'+ gwcontract['occi.contract.profile'] +'.publicaddr']

	print('The private address of the gateway is: '+gwprivateaddr)
	print('The public address of the gateway is: '+gwpublicaddr)

	#---------------------------------------------------gw-------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle gw category """
	attributePUB= {
		'what': 'gw'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])

	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	tempgw={
		'name':gw.name,
		'publicaddr':gw.publicaddr,
		'privateaddr':gw.privateaddr,
		'ethername':gw.ethername,
		'intercloudGW': gw.intercloudGW,
		'contract':gw.contract,
		'provider_type':gw.provider_type,
		'provider_platform':gw.provider_platform,
		'connection':gw.connection,
		'account':gw.account,
		'state':gw.state,
	}
	attribute = {
		'publicaddr': gwpublicaddr,
		'privateaddr': gwprivateaddr,
		'state': '1',
	}
	gwOCCI = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'gw', tempgw)

	uuidgw=gwOCCI.Get()
	gwOCCI.attributes=attribute
	gwOCCI.Put(gwOCCI.GetElement_pathuuid(uuidgw[0])['uuid'])
	print('updating the gateway category with the public and private address')


	return response
예제 #8
0
def gw_stop(gw):
	response=respAction("200","ok")
	"""Implement here your function"""
	print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
	print('                     Receiving action STOP gw                       ')

	#---------------------------------------------------gw-------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle gw category """
	attributePUB= {
		'what': 'gw'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#

	tempgw={
		'name':gw.name,
		'publicaddr':gw.publicaddr,
		'privateaddr':gw.privateaddr,
		'ethername':gw.ethername,
		'intercloudGW': gw.intercloudGW,
		'contract':gw.contract,
		'provider_type':gw.provider_type,
		'provider_platform':gw.provider_platform,
		'connection':gw.connection,
		'account':gw.account,
		'state':gw.state,
	}

	gwOCCI = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'gw', tempgw)
	uuidgw=gwOCCI.Get()
	uuidgw=gwOCCI.GetElement_pathuuid(uuidgw[0])['uuid']
	nbconnection = gwOCCI.GetElement(uuidgw)['occi.gw.connection']

	if int(nbconnection) > 0:
		attributes = {
			'connection': str(int(nbconnection)-1)
		}
		gwOCCI.attributes = attributes
		gwOCCI.Put(uuidgw)
		print('decrement the number of connection to :'+attributes['connection'])


	if int(nbconnection) == 1:
		#-------------------------------------------------contract---------------------------------------------------------#
		#------------------------------------------------------------------------------------------------------------------#
		#------------------------------------------------------------------------------------------------------------------#
		""" Determine server which handle contract category """
		attributePUB= {
			'what': 'contract'
		}
		client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
		publication = client.GetElement_pathuuid(client.Get()[0])
		client.host = publication['host']
		client.port = publication['port']
		publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


		attribute = {}
		client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'contract', attribute)

		#----------------------------------------------stop Node----------------------------------------------------------#
		gwcontract = client.GetElement_pathuuid(gw.contract)
		print('the number of connection = 0 ==> stopping the gateway  ')

		client.action(gwcontract['uuid'], 'stop')
		gwcontract = client.GetElement(gwcontract['uuid'])


		attribute = {
			'publicaddr': '',
			'privateaddr': '',
			'state': '0',
		}

		gwOCCI.attributes=attribute
		gwOCCI.Put(uuidgw)
		print('Changing the state of the gateway to 0')

	return response
예제 #9
0
def linkgw_start(linkgw):
	response=respAction("200","ok")
	"""Implement here your function"""
	print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
	print('                 Receiving action START linkgw                      ')


	#---------------------------------------------------gw-------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle gw category """
	attributePUB= {
		'what': 'gw'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])

	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	attribute = {}
	conetsOCCI = OCCIclient(publication['host'], publication['port'], 'CO-NETS-PAAS', 'gw', attribute)


	#--------------------------------------------uuid gw src-----------------------------------------------------------#
	gwsrc = conetsOCCI.GetElement_pathuuid(linkgw.gwsrc)
	addressgwsrc = conetsOCCI.GetElement(gwsrc['uuid'])
	publicaddrgwsrc = addressgwsrc['occi.gw.publicaddr']
	privateaddrgwsrc = addressgwsrc['occi.gw.privateaddr']
	ethernamegwsrc = addressgwsrc['occi.gw.ethername']

	#--------------------------------------------uuid gw dst-----------------------------------------------------------#
	gwdst = conetsOCCI.GetElement_pathuuid(linkgw.gwdst)
	addressgwdst = conetsOCCI.GetElement(gwdst['uuid'])
	publicaddrgwdst = addressgwdst['occi.gw.publicaddr']
	privateaddrgwdst = addressgwdst['occi.gw.privateaddr']
	ethernamegwdst = addressgwdst['occi.gw.ethername']
	#-----------------------------start gateway source and gateway destination-----------------------------------------#

	print('Sending START to gateway source')
	conetsOCCI.action(gwsrc['uuid'], 'start')
	print('Sending START to gateway destination')
	conetsOCCI.action(gwdst['uuid'], 'start')



	#-------------------------------------------------contract---------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle contract category """
	attributePUB= {
		'what': 'contract'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


	attribute = {}
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'contract', attribute)

	endpointsrc = client.GetElement(client.GetElement_pathuuid(linkgw.endpointsrc)['uuid'])
	endpointdst = client.GetElement(client.GetElement_pathuuid(linkgw.endpointdst)['uuid'])


	#-------------------------------------------------provider gwsrc---------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle procci provider category """
	attributePUB= {
		'what': endpointsrc['occi.contract.profile']
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


	attribute = {}
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', endpointsrc['occi.contract.profile'], attribute)

	#print endpointsrc['occi.contract.provider']
	privateaddrvmsrc = client.GetElement(client.GetElement_pathuuid(endpointsrc['occi.contract.provider'])['uuid'])
	privateaddrvmsrc = privateaddrvmsrc['occi.'+ endpointsrc['occi.contract.profile'] +'.privateaddr']

	#-------------------------------------------------provider gwdst---------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle procci provider category """
	attributePUB= {
		'what': endpointdst['occi.contract.profile']
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


	attribute = {}
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', endpointdst['occi.contract.profile'], attribute)

	#print endpointdst['occi.contract.provider']
	privateaddrvmdst = client.GetElement(client.GetElement_pathuuid(endpointdst['occi.contract.provider'])['uuid'])
	privateaddrvmdst = privateaddrvmdst['occi.'+ endpointdst['occi.contract.profile'] +'.privateaddr']




	gwsrc = gwProcci()
	gwdst = gwProcci()

	templist = privateaddrvmsrc.split('.')
	templist[3] = '0/24'
	privateaddrvmsrc = '.'.join(templist)
	#print privateaddrvmsrc

	templist = privateaddrvmdst.split('.')
	templist[3] = '0/24'
	privateaddrvmdst = '.'.join(templist)
	#print privateaddrvmdst

	''' Configuration des gateways'''
	gwsrc.configure_protocol_IPSEC(gwsrc, publicaddrgwsrc, ethernamegwsrc, 'IKEgwsrc', 'ESPgwsrc')
	gwdst.configure_protocol_IPSEC(gwdst, publicaddrgwdst, ethernamegwdst, 'IKEgwdst', 'ESPgwdst')

	''' Connecte les deux gateways'''
	gwsrc.connect_gw(gwsrc, linkgw.addressgresrc, linkgw.prefix, linkgw.tunnelproto, publicaddrgwsrc, publicaddrgwdst, linkgw.authenticationkey, linkgw.addressgredst, privateaddrvmdst)
	gwsrc.connect_gw(gwsrc, linkgw.addressgredst, linkgw.prefix, linkgw.tunnelproto, publicaddrgwdst, publicaddrgwsrc, linkgw.authenticationkey, linkgw.addressgresrc, privateaddrvmsrc)


	return response
예제 #10
0
def linkgw_stop(linkgw):
	response=respAction("200","ok")
	"""Implement here your function"""
	print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
	print('                   Receiving action STOP linkgw                     ')

	#---------------------------------------------------gw-------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle gw category """
	attributePUB= {
		'what': 'gw'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])

	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	attribute = {}
	gwOCCI = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'gw', attribute)

	#--------------------------------------------uuid gw src-----------------------------------------------------------#
	gwsrc = gwOCCI.GetElement_pathuuid(linkgw.gwsrc)
	#--------------------------------------------uuid gw dst-----------------------------------------------------------#
	gwdst = gwOCCI.GetElement_pathuuid(linkgw.gwdst)
	#------------------------------stop gateway source and gateway destination-----------------------------------------#
	print('Sending STOP to gateway source')
	gwOCCI.action(gwsrc['uuid'], 'stop')
	print('Sending STOP to gateway destination')
	gwOCCI.action(gwdst['uuid'], 'stop')
	

	templinkgw={
		'name':linkgw.name,
		'intercloudGW':linkgw.intercloudGW,
		'account':linkgw.account,
		'gwsrc':linkgw.gwsrc,
		'gwdst': linkgw.gwdst,
		'tunnelproto':linkgw.tunnelproto,
		'addressgresrc':linkgw.addressgresrc,
		'addressgredst':linkgw.addressgredst,
		'prefix':linkgw.prefix,
		'authenticationkey':linkgw.authenticationkey,
		'endpointsrc':linkgw.endpointsrc,
		'endpointdst':linkgw.endpointdst,
		'state':linkgw.state,
	}

	gwOCCI.category = 'linkgw'
	gwOCCI.attributes=templinkgw

	uuidlinkgw=gwOCCI.Get()
	uuidlinkgw=gwOCCI.GetElement_pathuuid(uuidlinkgw[0])['uuid']

	attribute = {
		'state': '0',
	}

	gwOCCI.attributes=attribute
	gwOCCI.Put(uuidlinkgw)
	print('Changing the state of the link gateway to 0')



	return response
예제 #11
0
def gw_start(gw):
	response=respAction("200","ok")
	"""Implement here your function"""
	print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
	print('                     Receiving action START gw                      ')

	#-------------------------------------------------contract---------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle contract category """
	attributePUB= {
		'what': 'contract'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


	attribute = {}
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'contract', attribute)

	#----------------------------------------------start Node----------------------------------------------------------#
	gwcontract = client.GetElement_pathuuid(gw.contract)
	print('Sending START to the contract of the gateway source')
	client.action(gwcontract['uuid'], 'start')
	gwcontract = client.GetElement(gwcontract['uuid'])

	#-------------------------------------------------provider gw------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle procci provider category """
	attributePUB= {
		'what': gwcontract['occi.contract.profile']
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


	attribute = {}
	client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', gwcontract['occi.contract.profile'], attribute)

	addressgw = client.GetElement(client.GetElement_pathuuid(gwcontract['occi.contract.provider'])['uuid'])
	gwprivateaddr = addressgw['occi.'+ gwcontract['occi.contract.profile'] +'.privateaddr']
	gwpublicaddr = addressgw['occi.'+ gwcontract['occi.contract.profile'] +'.publicaddr']

	print('The private address of the gateway is: '+gwprivateaddr)
	print('The public address of the gateway is: '+gwpublicaddr)

	#---------------------------------------------------gw-------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle gw category """
	attributePUB= {
		'what': 'gw'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])

	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	tempgw={
		'name':gw.name,
		'publicaddr':gw.publicaddr,
		'privateaddr':gw.privateaddr,
		'ethername':gw.ethername,
		'intercloudGW': gw.intercloudGW,
		'contract':gw.contract,
		'provider_type':gw.provider_type,
		'provider_platform':gw.provider_platform,
		'connection':gw.connection,
		'account':gw.account,
		'state':gw.state,
	}
	attribute = {
		'publicaddr': gwpublicaddr,
		'privateaddr': gwprivateaddr,
		'state': '1',
	}
	gwOCCI = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'gw', tempgw)

	uuidgw=gwOCCI.Get()
	gwOCCI.attributes=attribute
	gwOCCI.Put(gwOCCI.GetElement_pathuuid(uuidgw[0])['uuid'])
	print('updating the gateway category with the public and private address')


	return response
예제 #12
0
def gw_stop(gw):
	response=respAction("200","ok")
	"""Implement here your function"""
	print('$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$')
	print('                     Receiving action STOP gw                       ')

	#---------------------------------------------------gw-------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#
	""" Determine server which handle gw category """
	attributePUB= {
		'what': 'gw'
	}

	client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
	publication = client.GetElement_pathuuid(client.Get()[0])
	client.host = publication['host']
	client.port = publication['port']
	publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])
	#------------------------------------------------------------------------------------------------------------------#
	#------------------------------------------------------------------------------------------------------------------#

	tempgw={
		'name':gw.name,
		'publicaddr':gw.publicaddr,
		'privateaddr':gw.privateaddr,
		'ethername':gw.ethername,
		'intercloudGW': gw.intercloudGW,
		'contract':gw.contract,
		'provider_type':gw.provider_type,
		'provider_platform':gw.provider_platform,
		'connection':gw.connection,
		'account':gw.account,
		'state':gw.state,
	}

	gwOCCI = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'gw', tempgw)
	uuidgw=gwOCCI.Get()
	uuidgw=gwOCCI.GetElement_pathuuid(uuidgw[0])['uuid']
	nbconnection = gwOCCI.GetElement(uuidgw)['occi.gw.connection']

	if int(nbconnection) > 0:
		attributes = {
			'connection': str(int(nbconnection)-1)
		}
		gwOCCI.attributes = attributes
		gwOCCI.Put(uuidgw)
		print('decrement the number of connection to :'+attributes['connection'])


	if int(nbconnection) == 1:
		#-------------------------------------------------contract---------------------------------------------------------#
		#------------------------------------------------------------------------------------------------------------------#
		#------------------------------------------------------------------------------------------------------------------#
		""" Determine server which handle contract category """
		attributePUB= {
			'what': 'contract'
		}
		client = OCCIclient('127.0.0.1', '8086', 'CO-PUB', 'publication', attributePUB)
		publication = client.GetElement_pathuuid(client.Get()[0])
		client.host = publication['host']
		client.port = publication['port']
		publication = client.GetElement_pathuuid(client.GetElement(publication['uuid'])['occi.publication.why'])


		attribute = {}
		client = OCCIclient(publication['host'], publication['port'], 'CO-PARSER', 'contract', attribute)

		#----------------------------------------------stop Node----------------------------------------------------------#
		gwcontract = client.GetElement_pathuuid(gw.contract)
		print('the number of connection = 0 ==> stopping the gateway  ')

		client.action(gwcontract['uuid'], 'stop')
		gwcontract = client.GetElement(gwcontract['uuid'])


		attribute = {
			'publicaddr': '',
			'privateaddr': '',
			'state': '0',
		}

		gwOCCI.attributes=attribute
		gwOCCI.Put(uuidgw)
		print('Changing the state of the gateway to 0')

	return response