Temporary fix to site api
Change-Id: I11c7e6525d7d945e10db395a4f67bee8a2f98008
diff --git a/apiary.apib b/apiary.apib
index fbd11f9..5bd34fd 100644
--- a/apiary.apib
+++ b/apiary.apib
@@ -1182,17 +1182,57 @@
-## Sites [/api/core/sites/{id}/]
+## Sites [/api/core/sites/]
### List all sites [GET]
+ Response 200 (application/json)
+ [
+ {
+ "humanReadableName": "mysite",
+ "id": 1,
+ "created": "2016-08-18T21:21:03.429133Z",
+ "updated": "2016-08-18T21:21:06.676008Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": false,
+ "no_policy": false,
+ "name": "mysite",
+ "site_url": "http://opencloud.us/",
+ "enabled": true,
+ "hosts_nodes": true,
+ "hosts_users": true,
+ "longitude": null,
+ "latitude": null,
+ "login_base": "mysite",
+ "is_public": true,
+ "abbreviated_name": "",
+ "deployments": [
+ "1"
+ ]
+ }
+ ]
+
+## Sites [/api/core/sites/{id}/]
+
+### View a Site Detail [GET]
+
++ Parameters
+ + id: 1 (number) - ID of the Site in the form of an integer
+
++ Response 200 (application/json)
+
{
"humanReadableName": "mysite",
"id": 1,
- "created": "2016-04-29T16:19:03.587770Z",
- "updated": "2016-04-29T16:19:05.651933Z",
+ "created": "2016-08-18T21:21:03.429133Z",
+ "updated": "2016-08-18T21:21:06.676008Z",
"enacted": null,
"policed": null,
"backend_register": "{}",
@@ -1201,12 +1241,12 @@
"write_protect": false,
"lazy_blocked": false,
"no_sync": false,
- "name": "MySite",
- "site_url": "http://opencord.us/",
+ "no_policy": false,
+ "name": "mysite",
+ "site_url": "http://opencloud.us/",
"enabled": true,
"hosts_nodes": true,
"hosts_users": true,
- "location": null,
"longitude": null,
"latitude": null,
"login_base": "mysite",
@@ -1216,6 +1256,7 @@
"1"
]
}
+
## Slices [/api/core/slices/{id}/]
diff --git a/xos/core/admin.py b/xos/core/admin.py
index d968c32..f2a7156 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -1092,7 +1092,7 @@
class SiteAdmin(XOSBaseAdmin):
#fieldList = ['backend_status_text', 'name', 'site_url', 'enabled', 'is_public', 'login_base', 'accountLink','location']
fieldList = ['backend_status_text', 'name', 'site_url', 'enabled',
- 'login_base', 'location', 'is_public', 'hosts_nodes', 'hosts_users']
+ 'login_base', 'latitude', 'longitude', 'is_public', 'hosts_nodes', 'hosts_users']
fieldsets = [
(None, {'fields': fieldList, 'classes': [
'suit-tab suit-tab-general']}),
diff --git a/xos/core/models/site.py b/xos/core/models/site.py
index 31e69a6..a827672 100644
--- a/xos/core/models/site.py
+++ b/xos/core/models/site.py
@@ -101,7 +101,7 @@
enabled = models.BooleanField(default=True, help_text="Status for this Site")
hosts_nodes = models.BooleanField(default=True, help_text="Indicates whether or not the site host nodes")
hosts_users = models.BooleanField(default=True, help_text="Indicates whether or not the site manages user accounts")
- location = GeopositionField()
+ # location = GeopositionField()
longitude = models.FloatField(null=True, blank=True)
latitude = models.FloatField(null=True, blank=True)
login_base = StrippedCharField(max_length=50, unique=True, help_text="Prefix for Slices associated with this Site")
diff --git a/xos/tests/api/helpers/sites.py b/xos/tests/api/helpers/sites.py
new file mode 100644
index 0000000..7d20745
--- /dev/null
+++ b/xos/tests/api/helpers/sites.py
@@ -0,0 +1,23 @@
+import dredd_hooks as hooks
+import sys
+
+# HELPERS
+# NOTE move in separated module
+import os
+import sys
+sys.path.append("/opt/xos")
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xos.settings")
+import django
+from core.models import *
+import urllib2
+import json
+django.setup()
+
+
+def createSite():
+ site = Site(id=1)
+ site.name = 'mysite'
+ site.save()
+ print(site, site.id)
+
+createSite()
\ No newline at end of file
diff --git a/xos/tests/api/hooks.py b/xos/tests/api/hooks.py
index ff9b88c..53a18d4 100644
--- a/xos/tests/api/hooks.py
+++ b/xos/tests/api/hooks.py
@@ -62,6 +62,9 @@
for s in Image.objects.all():
s.delete(purge=True)
+ # for s in Site.objects.all():
+ # s.delete(purge=True)
+
# print 'DB Cleaned'
@@ -277,6 +280,14 @@
service.name = 'test-service'
service.save()
+
+def createSite():
+ site = Site(id=1)
+ site.name = 'mysite'
+ site.created = timezone.now()
+ site.save()
+
+
@hooks.before_all
def my_before_all_hook(transactions):
# print "-------------------------------- Before All Hook --------------------------------"
@@ -310,6 +321,11 @@
createService()
+@hooks.before("Core > Sites > View a Site Detail")
+def get_site(transaction):
+ createSite()
+
+
@hooks.before("Tenant > Truckroll Collection > Create a Truckroll")
def test1(transaction):
setUpTruckroll()
diff --git a/xos/tests/api/source/core/sites.md b/xos/tests/api/source/core/sites.md
index 7f963c3..afd4f12 100644
--- a/xos/tests/api/source/core/sites.md
+++ b/xos/tests/api/source/core/sites.md
@@ -1,14 +1,54 @@
-## Sites [/api/core/sites/{id}/]
+## Sites [/api/core/sites/]
### List all sites [GET]
+ Response 200 (application/json)
+ [
+ {
+ "humanReadableName": "mysite",
+ "id": 1,
+ "created": "2016-08-18T21:21:03.429133Z",
+ "updated": "2016-08-18T21:21:06.676008Z",
+ "enacted": null,
+ "policed": null,
+ "backend_register": "{}",
+ "backend_status": "0 - Provisioning in progress",
+ "deleted": false,
+ "write_protect": false,
+ "lazy_blocked": false,
+ "no_sync": false,
+ "no_policy": false,
+ "name": "mysite",
+ "site_url": "http://opencloud.us/",
+ "enabled": true,
+ "hosts_nodes": true,
+ "hosts_users": true,
+ "longitude": null,
+ "latitude": null,
+ "login_base": "mysite",
+ "is_public": true,
+ "abbreviated_name": "",
+ "deployments": [
+ "1"
+ ]
+ }
+ ]
+
+## Sites [/api/core/sites/{id}/]
+
+### View a Site Detail [GET]
+
++ Parameters
+ + id: 1 (number) - ID of the Site in the form of an integer
+
++ Response 200 (application/json)
+
{
"humanReadableName": "mysite",
"id": 1,
- "created": "2016-04-29T16:19:03.587770Z",
- "updated": "2016-04-29T16:19:05.651933Z",
+ "created": "2016-08-18T21:21:03.429133Z",
+ "updated": "2016-08-18T21:21:06.676008Z",
"enacted": null,
"policed": null,
"backend_register": "{}",
@@ -17,12 +57,12 @@
"write_protect": false,
"lazy_blocked": false,
"no_sync": false,
- "name": "MySite",
- "site_url": "http://opencord.us/",
+ "no_policy": false,
+ "name": "mysite",
+ "site_url": "http://opencloud.us/",
"enabled": true,
"hosts_nodes": true,
"hosts_users": true,
- "location": null,
"longitude": null,
"latitude": null,
"login_base": "mysite",
@@ -31,4 +71,4 @@
"deployments": [
"1"
]
- }
\ No newline at end of file
+ }
diff --git a/xos/tools/apigen/modelgen b/xos/tools/apigen/modelgen
old mode 100644
new mode 100755
diff --git a/xos/xos/xosapi.py b/xos/xos/xosapi.py
index 290fb65..3ffbdd4 100644
--- a/xos/xos/xosapi.py
+++ b/xos/xos/xosapi.py
@@ -942,7 +942,7 @@
return None
class Meta:
model = Site
- fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','name','site_url','enabled','hosts_nodes','hosts_users','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
+ fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','name','site_url','enabled','hosts_nodes','hosts_users','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
class SiteIdSerializer(XOSModelSerializer):
id = IdField()
@@ -962,7 +962,7 @@
return None
class Meta:
model = Site
- fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','name','site_url','enabled','hosts_nodes','hosts_users','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
+ fields = ('humanReadableName', 'validators', 'id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','name','site_url','enabled','hosts_nodes','hosts_users','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
@@ -3915,7 +3915,7 @@
serializer_class = SiteSerializer
id_serializer_class = SiteIdSerializer
filter_backends = (filters.DjangoFilterBackend,)
- filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','name','site_url','enabled','hosts_nodes','hosts_users','location','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
+ filter_fields = ('id','created','updated','enacted','policed','backend_register','backend_status','deleted','write_protect','lazy_blocked','no_sync','no_policy','name','site_url','enabled','hosts_nodes','hosts_users','longitude','latitude','login_base','is_public','abbreviated_name','deployments',)
def get_serializer_class(self):
no_hyperlinks=False