merge latest Amisha changes
diff --git a/planetstack/core/models/slice.py b/planetstack/core/models/slice.py
index 86a1586..94bcd5b 100644
--- a/planetstack/core/models/slice.py
+++ b/planetstack/core/models/slice.py
@@ -20,10 +20,10 @@
description=models.TextField(blank=True,help_text="High level description of the slice and expected activities", max_length=1024)
slice_url = models.URLField(blank=True, max_length=512)
site = models.ForeignKey(Site, related_name='slices', help_text="The Site this Slice belongs to")
- imagePreference = models.CharField(default="abc",null=True, blank=True, max_length=256)
+ imagePreference = models.CharField(null=True, blank=True, max_length=256)
service = models.ForeignKey(Service, related_name='service', null=True, blank=True)
- network = models.CharField(null=True, blank=True, max_length=256)
- mountDataSets = models.CharField(null=True, blank=True, max_length=256)
+ network = models.CharField(default="Private Only",null=True, blank=True, max_length=256)
+ mountDataSets = models.CharField(default="GenBank",null=True, blank=True, max_length=256)
tags = generic.GenericRelation(Tag)
serviceClass = models.ForeignKey(ServiceClass, related_name = "slices", null=True, default=ServiceClass.get_default)
diff --git a/planetstack/core/plus/views.py b/planetstack/core/plus/views.py
index 4e58508..246a30d 100644
--- a/planetstack/core/plus/views.py
+++ b/planetstack/core/plus/views.py
@@ -68,10 +68,10 @@
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=imageName,mountDataSets=mountDataSets,network=network)
+ image = Image.objects.get(name=imageName)
+ newSlice = Slice(name=sliceName,serviceClass=serviceClass,site=site,imagePreference=image,mountDataSets=mountDataSets,network=network)
newSlice.save()
- return newSlice
+ return HttpResponse("Slice created")
class TenantUpdateSlice(View):
def post(self, request, *args, **kwargs):
@@ -80,18 +80,20 @@
imageName = request.POST.get("imageName", "0")
actionToDo = request.POST.get("actionToDo", "0")
network = request.POST.get("network","0")
- slice = Slice.objects.filter(name = sliceName)
- abc = ServiceClass.objects.get(name=serviceClass)
- if (actionToDo == "update"):
- # print getattr(slice,'serviceClass',abc)
- setattr(slice,'serviceClass',abc)
- #fields = {'serviceClass':ServiceClass.objects.get(name=serviceClass),
- # 'imagePreference':imageName,
- # 'network':network
- # }
- #update_slice(sliceName,**fields)
- return HttpResponse("Slice updated")
-
+ dataSet = request.POST.get("dataSet","0")
+ slice = Slice.objects.all()
+ for entry in slice:
+ serviceClass = ServiceClass.objects.get(name=serviceClass)
+ if(entry.name==sliceName):
+ if (actionToDo == "update"):
+ setattr(entry,'serviceClass',serviceClass)
+ setattr(entry,'imagePreference',imageName)
+ setattr(entry,'network',network)
+ setattr(entry,'mountDataSets',dataSet)
+ entry.save()
+ break
+ return HttpResponse("Slice updated")
+
def update_slice(sliceName,**fields):
slice = Slice.objects.filter(name = sliceName)
for (k,v) in fields.items():
@@ -164,12 +166,12 @@
return sliceInfo
def getImageInfo(user):
- #imageList = Image.objects.all()
- imageList = ['Fedora 16 LXC rev 1.3','Hadoop','MPI']
+ imageList = Image.objects.all()
+ #imageList = ['Fedora 16 LXC rev 1.3','Hadoop','MPI']
imageInfo = []
for imageEntry in imageList:
- #imageInfo.append({'Image':imageEntry.name})
- imageInfo.append({'Image':imageEntry})
+ imageInfo.append({'Image':imageEntry.name})
+ #imageInfo.append({'Image':imageEntry})
return imageInfo
def getMountDataSets():
@@ -323,12 +325,12 @@
return HttpResponse(json.dumps(getTenantSliceInfo(request.user, True)), mimetype='application/javascript')
def haversine(site_lat, site_lon, lat, lon):
- site_lat = float(site_lat)
- site_lon = float(site_lon)
- lat = float(lat)
- lon = float(lon)
d=0
if lat and lon and site_lat and site_lon:
+ site_lat = float(site_lat)
+ site_lon = float(site_lon)
+ lat = float(lat)
+ lon = float(lon)
R = 6378.1
a = math.sin( math.radians((lat - site_lat)/2.0) )**2 + math.cos( math.radians(lat) )*math.cos( math.radians(site_lat) )*(math.sin( math.radians((lon - site_lon)/2.0 ) )**2)
c = 2 * math.atan2( math.sqrt(a), math.sqrt(1 - a) )
@@ -439,6 +441,7 @@
print slice, slice.id
sliceToDel=Slice(name=sliceName, id=slice.id)
sliceToDel.delete()
+ return HttpResponse("Slice deleted")
class TenantAddOrRemoveSliverView(View):
""" Add or remove slivers from a Slice
diff --git a/planetstack/core/serializers.py b/planetstack/core/serializers.py
index 5bbe7aa..3fb726d 100644
--- a/planetstack/core/serializers.py
+++ b/planetstack/core/serializers.py
@@ -125,6 +125,8 @@
'router_id',
'subnet_id',
'imagePreference',
+ 'network',
+ 'mountDataSets',
'site',
'slivers',
'updated',
diff --git a/planetstack/core/static/planetstack.css b/planetstack/core/static/planetstack.css
index de9139b..e891a70 100644
--- a/planetstack/core/static/planetstack.css
+++ b/planetstack/core/static/planetstack.css
@@ -1061,9 +1061,10 @@
.tenantDialog.ui-widget input{
border-radius: 0px !important;
-margin: 0 0 0 5% !important;
-height: 15px !important;
-width: 164px !important;
+ height: 12px !important;
+ width: 180px !important;
+ margin-right: 10% !important;
+ float: right;
}
.tenantDialog .ui-dialog-buttonset .ui-button{
@@ -1079,7 +1080,9 @@
}
.create-slice-row{
- margin-bottom:3%;
+ margin-bottom: 4%;
+ clear: both;
+ height: 25px;
}
.create-slice-row label, .tenantDialog label{
@@ -1117,3 +1120,8 @@
color: #999;
padding-bottom: 1%;
}
+
+.create-slice-row label{
+ clear:both;
+ margin-right: 1%;
+}
diff --git a/planetstack/templates/admin/dashboard/tenant.html b/planetstack/templates/admin/dashboard/tenant.html
index 6fedd6c..2819fe2 100644
--- a/planetstack/templates/admin/dashboard/tenant.html
+++ b/planetstack/templates/admin/dashboard/tenant.html
@@ -23,7 +23,7 @@
<fieldset>
<div class="create-slice-row">
<label for="new-slice-name">Name</label>
- <input type="text" name="new-slice-name" id="new-slice-name" class="text tenant-create-slice">
+ <input type="text" name="new-slice-name" id="new-slice-name">
</div>
<div class="create-slice-row">
<label for="new-service-class">Service Class</label>
@@ -43,7 +43,7 @@
</div>
<div class="create-slice-row">
<label for="number-of-slivers">Number Of Slivers</label>
- <input type="text" name="number-of-slivers" id="number-of-slivers" class="text tenant-create-slice">
+ <input type="text" name="number-of-slivers" id="number-of-slivers">
</div>
<div id=tooltip>Slice Name cannot be empty</div>
</fieldset>
@@ -281,6 +281,7 @@
serviceClass: $("#adv-service-level-dropdown").val(),
imageName: $("#adv-image-dropdown").val(),
network: $("#adv-network-dropdown").val(),
+ dataSet: $("#adv-dataset-dropdown").val(),
actionToDo: "update",
csrfmiddlewaretoken: "{{ csrf_token }}", // < here
state: "inactive"
@@ -378,8 +379,8 @@
$('<div class="btn btn-high btn-info" id="download-details">Download Slice Details</div>').appendTo("#tabs-5");
$('<div class="btn btn-success" id="sliver-btn"><i class="icon-plus-sign icon-white"></i> Add/Remove Slivers</div>').appendTo("#tabs-5");
$('<div class="btn btn-high btn-info" id="save-btn">Save</div>').appendTo("#tabs-5").css("display", "none");
- $("#advanced-tenant").click(function () {
- var value = $("#advTenantSliceDropDown").val();
+ $("#advanced-tenant").unbind().click(function () {
+ var value = $("#tenantSliceDropDown").val();
advShowSliceData(data,value);
$("#tenantSliceDataWrapper").css("display","none");
$("#advancedTenantSliceDataWrapper").css("display","block");
@@ -388,9 +389,6 @@
$("#sliver-btn").toggle();
$("#save-btn").toggle();
- //$("#advTenantSliceDropDown").val(selectedValue);
- //advShowSliceData(data);
- //editSliverAdv();
});
$("#sliver-btn").click(function () {
$("#numOfSlivers").empty();
@@ -398,7 +396,7 @@
$("#dialog-form").dialog({
autoOpen: false,
height: 200,
- width: 350,
+ width: 400,
modal: true,
dialogClass: "tenantDialog",
buttons: {