merge latest Amisha changes
diff --git a/planetstack/core/plus/views.py b/planetstack/core/plus/views.py
index 2b7bf38..2fcef20 100644
--- a/planetstack/core/plus/views.py
+++ b/planetstack/core/plus/views.py
@@ -161,24 +161,42 @@
serviceClass = request.POST.get("serviceClass", "0")
imageName = request.POST.get("imageName", "0")
actionToDo = request.POST.get("actionToDo", "0")
- #network = request.POST.get("network","0")
+ networkPorts = request.POST.get("network","0")
mountDataSets = request.POST.get("mountDataSets","0")
+ privateVolume = request.POST.get("privateVolume","0")
if (actionToDo == "add"):
serviceClass = ServiceClass.objects.get(name=serviceClass)
site = request.user.site
image = Image.objects.get(name=imageName)
newSlice = Slice(name=sliceName,serviceClass=serviceClass,site=site,imagePreference=image,mountDataSets=mountDataSets)
newSlice.save()
+ privateTemplate="Private"
+ publicTemplate="Public shared IPv4"
+ privateNetworkName = sliceName+"-"+privateTemplate
+ publicNetworkName = sliceName+"-"+publicTemplate
+ slice=Slice.objects.get(name=sliceName)
+ addNetwork(privateNetworkName,privateTemplate,slice)
+ addNetwork(publicNetworkName,publicTemplate,slice)
+ addOrModifyPorts(networkPorts,sliceName)
+ if privateVolume=="true":
+ privateVolForSlice(request.user,sliceName)
return HttpResponse("Slice created")
+def privateVolForSlice(user,sliceName):
+ if not hasPrivateVolume(sliceName):
+ volumeName=createPrivateVolume(user,sliceName)
+ readWrite="true"
+ mountVolume(sliceName,volumeName,readWrite)
+
class TenantUpdateSlice(View):
def post(self, request, *args, **kwargs):
sliceName = request.POST.get("sliceName", "0")
serviceClass = request.POST.get("serviceClass", "0")
imageName = request.POST.get("imageName", "0")
actionToDo = request.POST.get("actionToDo", "0")
- #network = request.POST.get("network","0")
+ networkPorts = request.POST.get("networkPorts","0")
dataSet = request.POST.get("dataSet","0")
+ privateVolume = request.POST.get("privateVolume","0")
slice = Slice.objects.all()
for entry in slice:
serviceClass = ServiceClass.objects.get(name=serviceClass)
@@ -186,12 +204,39 @@
if (actionToDo == "update"):
setattr(entry,'serviceClass',serviceClass)
setattr(entry,'imagePreference',imageName)
- #setattr(entry,'network',network)
setattr(entry,'mountDataSets',dataSet)
entry.save()
break
+ addOrModifyPorts(networkPorts,sliceName)
+ if privateVolume=="true":
+ privateVolForSlice(request.user,sliceName)
return HttpResponse("Slice updated")
+def addNetwork(name,template,sliceName):
+ networkTemplate=NetworkTemplate.objects.get(name=template)
+ newNetwork = Network(name = name,
+ template = networkTemplate,
+ owner = sliceName)
+ newNetwork.save()
+ addNetworkSlice(newNetwork,sliceName)
+
+def addNetworkSlice(networkSlice,sliceName):
+ newNetworkSlice=NetworkSlice(network =networkSlice,
+ slice=sliceName)
+ newNetworkSlice.save()
+
+def addOrModifyPorts(networkPorts,sliceName):
+ networkList = Network.objects.all()
+ networkInfo = []
+ if networkPorts:
+ for networkEntry in networkList:
+ networkSlices = networkEntry.slices.all()
+ for slice in networkSlices:
+ if slice.name==sliceName:
+ if networkEntry.template.name=="Public shared IPv4":
+ setattr(networkEntry,'ports',networkPorts)
+ networkEntry.save()
+
def getTenantSliceInfo(user, tableFormat = False):
tenantSliceDetails = {}
tenantSliceData = getTenantInfo(user)
@@ -203,7 +248,6 @@
tenantSliceDetails['userSliceInfo'] = tenantSliceData
tenantSliceDetails['sliceServiceClass']=userSliceTableFormatter(tenantServiceClassData)
tenantSliceDetails['image']=userSliceTableFormatter(getImageInfo(user))
- #tenantSliceDetails['network']=userSliceTableFormatter(getNetworkInfo(user))
tenantSliceDetails['deploymentSites']=userSliceTableFormatter(getDeploymentSites())
tenantSliceDetails['sites'] = userSliceTableFormatter(getTenantSitesInfo())
tenantSliceDetails['mountDataSets'] = userSliceTableFormatter(getMountDataSets())
@@ -218,13 +262,14 @@
slice = Slice.objects.get(name=Slice.objects.get(id=entry.id).name)
sliceServiceClass = entry.serviceClass.name
preferredImage = entry.imagePreference
- sliceDataSet = entry.mountDataSets
- #sliceNetwork = entry.network
+ #sliceDataSet = entry.mountDataSets
+ sliceNetwork = {}
numSliver = 0
sliceImage=""
sliceSite = {}
sliceNode = {}
sliceInstance= {}
+ #createPrivateVolume(user,sliceName)
for sliver in slice.slivers.all():
if sliver.node.site.name in BLESSED_SITES:
sliceSite[sliver.node.site.name] = sliceSite.get(sliver.node.site.name,0) + 1
@@ -232,7 +277,7 @@
sliceNode[str(sliver)] = sliver.node.name
numSliver = sum(sliceSite.values())
numSites = len(sliceSite)
- userSliceInfo.append({'sliceName': sliceName,'sliceServiceClass': sliceServiceClass,'preferredImage':preferredImage,'numOfSites':numSites, 'sliceSite':sliceSite,'sliceImage':sliceImage,'numOfSlivers':numSliver,'sliceDataSet':sliceDataSet,'instanceNodePair':sliceNode})
+ userSliceInfo.append({'sliceName': sliceName,'sliceServiceClass': sliceServiceClass,'preferredImage':preferredImage,'numOfSites':numSites, 'sliceSite':sliceSite,'sliceImage':sliceImage,'numOfSlivers':numSliver,'instanceNodePair':sliceNode})
return userSliceInfo
def getTenantSitesInfo():
@@ -279,6 +324,7 @@
getattr(Volume.default_gateway_caps,"host files")
v = Volume(name="private_" + sliceName, owner_id=user, description="private volume for %s" % sliceName, blocksize=61440, private=True, archive=False, default_gateway_caps = caps)
v.save()
+ return v
SYNDICATE_REPLICATE_PORTNUM = 1025
@@ -289,6 +335,8 @@
inuse[vs.peer_portnum]=True
inuse[vs.replicate_portnum]=True
for network in Network.objects.all():
+ if not network_ports:
+ continue
network_ports = [x.strip() for x in network.ports.split(",")]
for network_port in network_ports:
try:
@@ -326,15 +374,6 @@
return dataSetInfo
-def getNetworkInfo(user):
- #networkList = Network.objects.all()
- networkList = ['Private Only','Private and Publicly Routable']
- networkInfo = []
- for networkEntry in networkList:
- #networkInfo.append({'Network':networkEntry.name})
- networkInfo.append({'Network':networkEntry})
- return networkInfo
-
def getDeploymentSites():
deploymentList = Deployment.objects.all()
deploymentInfo = []
diff --git a/planetstack/templates/admin/dashboard/tenant.html b/planetstack/templates/admin/dashboard/tenant.html
index 88933a3..07d1e9c 100644
--- a/planetstack/templates/admin/dashboard/tenant.html
+++ b/planetstack/templates/admin/dashboard/tenant.html
@@ -34,7 +34,7 @@
<select id="new-image" class="tenant-create-slice"></select>
</div>
<div class="create-slice-row">
- <label for="new-network">Network</label>
+ <label for="new-network">Network Ports</label>
<input type="text" name="new-network" id="new-network">
</div>
<div class="create-slice-row">
@@ -261,6 +261,8 @@
serviceClass: $("#adv-service-level-dropdown").val(),
imageName: $("#adv-image-dropdown").val(),
dataSet: $("#adv-dataset-dropdown").val(),
+ networkPorts: $("#adv-network-value").val(),
+ privateVolume: $("#private-vol-checkbox").is(":checked"),
actionToDo: "update",
csrfmiddlewaretoken: "{{ csrf_token }}", // < here
state: "inactive"
@@ -462,7 +464,8 @@
sliceName: $("#new-slice-name").val(),
serviceClass: nameOfServiceClass,
imageName: $("#new-image").val(),
-// network: $("#new-network").val(),
+ network: $("#new-network").val(),
+ privateVolume: $("#private-vol").is(":checked"),
mountDataSets: $("#mount-data-sets").val(),
actionToDo: "add",
csrfmiddlewaretoken: "{{ csrf_token }}", // < here