def create(**kwargs): ctx.logger.info("network_create") for rel in ctx.instance.relationships: ctx.logger.info(rel.node.properties) solo_config = ctx.node.properties["solo_config"] vNetName = str(ctx.node.properties["vNetworkName"]) urlPath = "/vnet" data = {"vNets" : [{"vNetworkName": vNetName}]} ctx.logger.info(data) dummy = REST.post(urlPath, data, solo_config)
def create(**kwargs): ctx.logger.info("switch_create") datapathId = str(ctx.node.properties["datapathId"]) controllerIp = str(ctx.node.properties["controllerIp"]) controllerPort = str(ctx.node.properties["controllerPort"]) openflowVersion = str(ctx.node.properties["openflowVersion"]) physicalDevice = str(ctx.node.properties["physicalDevice"]) ctx.logger.info("properties: " + str(ctx.node.properties)) ctx.logger.info("ctx: " + str(dir(ctx))) ctx.logger.info("ctx.node: " + str(dir(ctx.node))) ctx.logger.info("ctx.instance: " + str(dir(ctx.instance))) ctx.logger.info("ctx.instance.runtime_properties: " + str(ctx.instance.runtime_properties)) for rel in ctx.instance.relationships: solo_config = rel.target.node.properties["solo_config"] ctx.logger.info("rel: " + str(dir(rel))) ctx.logger.info("rel.target: " + str(dir(rel.target))) ctx.logger.info("rel.type: " + str(rel.type)) ctx.logger.info("rel.target.node.properties: " + str(rel.target.node.properties)) ctx.logger.info("rel.target.node.type: " + str(rel.target.node.type)) solo_config = None vNetworkName = None for rel in ctx.instance.relationships: if rel.target.node.type == "cloudify.solo.nodes.VirtualNetwork": solo_config = rel.target.node.properties["solo_config"] vNetworkName = str(rel.target.node.properties["vNetworkName"]) if solo_config == None: solo_config = ctx.node.properties["solo_config"] if vNetworkName == None: vNetworkName = str(ctx.node.properties["vNetworkName"]) ctx.instance.runtime_properties['vNetworkName'] = vNetworkName ctx.instance.runtime_properties['solo_config'] = solo_config ctx.instance.runtime_properties['datapathId'] = datapathId data = { "vSwitches": [{ "vNetworkName": vNetworkName, "datapathId": datapathId, "controllerIp": controllerIp, "controllerPort": controllerPort, "openflowVersion": openflowVersion, "physicalDevice": physicalDevice }] } urlPath = "/vswitch" ctx.logger.info(data) dummy = REST.post(urlPath, data, solo_config)
def delete(**kwargs): ctx.logger.info("switch_delete") datapathId = str(ctx.node.properties["datapathId"]) #maybe I could get this information in runtime_properties solo_config = None vNetworkName = None for rel in ctx.instance.relationships: if rel.target.node.type == "cloudify.solo.nodes.VirtualNetwork": solo_config = rel.target.node.properties["solo_config"] vNetworkName = str(rel.target.node.properties["vNetworkName"]) if solo_config == None: solo_config = ctx.node.properties["solo_config"] if vNetworkName == None: vNetworkName = str(ctx.node.properties["vNetworkName"]) urlPath = "/vswitch/network/{}/device/{}".format(vNetworkName, datapathId) dummy = REST.delete(urlPath, solo_config)
def create(**kwargs): ctx.logger.info("link_create") linkType = str(ctx.node.properties["linkType"]) vlanId = str(ctx.node.properties["vlanId"]) nsiBandwidth = str(ctx.node.properties["nsiBandwidth"]) srcVirtualPortNumber = str(ctx.node.properties["srcVirtualPortNumber"]) dstVirtualPortNumber = str(ctx.node.properties["dstVirtualPortNumber"]) srcPhysicalPort = str(ctx.node.properties["srcPhysicalPort"]) dstPhysicalPort = str(ctx.node.properties["dstPhysicalPort"]) solo_config = None vNetworkName = None datapathId = {} point = None for rel in ctx.instance.relationships: if rel.target.node.type == "cloudify.solo.nodes.VirtualSwitch": if rel.type == "cloudify.solo.connected_from": point = "src" if rel.type == "cloudify.solo.connected_to": point = "dst" solo_config = rel.target.instance.runtime_properties["solo_config"] vNetworkName = str( rel.target.instance.runtime_properties["vNetworkName"]) datapathId[point] = str( rel.target.instance.runtime_properties["datapathId"]) #TODO if it is defined in bluepint and not in relationship data = { "vLinks": [{ "vNetworkName": vNetworkName, "srcVirtualPortNumber": srcVirtualPortNumber, "dstVirtualPortNumber": dstVirtualPortNumber, "srcDatapathId": datapathId["src"], "dstDatapathId": datapathId["dst"], "srcPhysicalPort": srcPhysicalPort, "dstPhysicalPort": dstPhysicalPort, "linkType": linkType, "vlanId": vlanId, "nsiBandwidth": nsiBandwidth }] } urlPath = "/vlink" ctx.logger.info(data) response = REST.post(urlPath, data, solo_config)
def create(**kwargs): ctx.logger.info("port_create") virtualPortNumber = str(ctx.node.properties["virtualPortNumber"]) physicalPortName = str(ctx.node.properties["physicalPortName"]) bindingType = str(ctx.node.properties["bindingType"]) vlanId = str(ctx.node.properties["vlanId"]) solo_config = None vNetworkName = None datapathId = None for rel in ctx.instance.relationships: if rel.target.node.type == "cloudify.solo.nodes.VirtualSwitch": solo_config = rel.target.instance.runtime_properties["solo_config"] vNetworkName = str( rel.target.instance.runtime_properties["vNetworkName"]) datapathId = str( rel.target.instance.runtime_properties["datapathId"]) if solo_config == None: solo_config = ctx.node.properties["solo_config"] if vNetworkName == None: vNetworkName = str(ctx.node.properties["vNetworkName"]) if datapathId == None: datapathId = str(ctx.node.properties["datapathId"]) data = { "vPorts": [{ "vNetworkName": vNetworkName, "datapathId": datapathId, "virtualPortNumber": virtualPortNumber, "physicalPortName": physicalPortName, "bindingType": bindingType, "vlanId": vlanId }] } urlPath = "/vport" ctx.logger.info(data) dummy = REST.post(urlPath, data, solo_config)
def delete(**kwargs): ctx.logger.info("port_delete") virtualPortNumber = str(ctx.node.properties["virtualPortNumber"]) solo_config = None vNetworkName = None datapathId = None for rel in ctx.instance.relationships: if rel.target.node.type == "cloudify.solo.nodes.VirtualSwitch": solo_config = rel.target.instance.runtime_properties["solo_config"] vNetworkName = str( rel.target.instance.runtime_properties["vNetworkName"]) datapathId = str( rel.target.instance.runtime_properties["datapathId"]) if solo_config == None: solo_config = ctx.node.properties["solo_config"] if vNetworkName == None: vNetworkName = str(ctx.node.properties["vNetworkName"]) if datapathId == None: datapathId = str(ctx.node.properties["datapathId"]) urlPath = "/vport/network/{}/device/{}/port/{}".format( vNetworkName, datapathId, virtualPortNumber) dummy = REST.delete(urlPath, solo_config)
def delete(**kwargs): ctx.logger.info("network_delete") solo_config = ctx.node.properties["solo_config"] vNetName = str(ctx.node.properties["vNetworkName"]) urlPath = "/vnet/network/{}".format(vNetName) dummy = REST.delete(urlPath, solo_config)