summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vio/vio/pub/msapi/extsys.py2
-rw-r--r--vio/vio/pub/vim/drivers/vimsdk/compute.py13
-rw-r--r--vio/vio/pub/vim/vimapi/network/OperateNetwork.py18
-rw-r--r--vio/vio/pub/vim/vimapi/network/OperatePort.py18
-rw-r--r--vio/vio/pub/vim/vimapi/network/OperateSubnet.py12
-rw-r--r--vio/vio/pub/vim/vimapi/nova/OperateServers.py30
-rw-r--r--vio/vio/swagger/image_utils.py2
-rw-r--r--vio/vio/swagger/urls.py86
-rw-r--r--vio/vio/swagger/views/proxyplugin/dns/views.py34
-rw-r--r--vio/vio/swagger/views/proxyplugin/heat/views.py25
-rw-r--r--vio/vio/swagger/views/proxyplugin/identity/views.py64
-rw-r--r--vio/vio/swagger/views/proxyplugin/image/views.py34
-rw-r--r--vio/vio/swagger/views/proxyplugin/neutron/views.py34
-rw-r--r--vio/vio/swagger/views/proxyplugin/nova/views.py21
-rw-r--r--vio/vio/swagger/views/proxyplugin/volumn/views.py25
-rw-r--r--vio/vio/swagger/views/server/views.py58
-rw-r--r--vio/vio/swagger/views/service/views.py4
-rw-r--r--vio/vio/swagger/views/tenant/views.py2
-rw-r--r--vio/vio/swagger/volume_utils.py2
19 files changed, 471 insertions, 13 deletions
diff --git a/vio/vio/pub/msapi/extsys.py b/vio/vio/pub/msapi/extsys.py
index 05213f4..9b45f2b 100644
--- a/vio/vio/pub/msapi/extsys.py
+++ b/vio/vio/pub/msapi/extsys.py
@@ -31,6 +31,8 @@ def get_vim_by_id(vim_id):
ret['type'] = ret['cloud-type']
ret['version'] = ret['cloud-region-version']
ret['vimId'] = vim_id
+ ret['cloud_owner'] = cloud_owner
+ ret['cloud_region_id'] = cloud_region
ret['name'] = vim_id
ret['userName'] = ret['esr-system-info-list'][
'esr-system-info'][0]['user-name']
diff --git a/vio/vio/pub/vim/drivers/vimsdk/compute.py b/vio/vio/pub/vim/drivers/vimsdk/compute.py
index 2326fff..e415573 100644
--- a/vio/vio/pub/vim/drivers/vimsdk/compute.py
+++ b/vio/vio/pub/vim/drivers/vimsdk/compute.py
@@ -77,6 +77,19 @@ class ComputeClient(base.DriverBase):
return list(ifaces)
@sdk.translate_exception
+ def start_server(self, server_id):
+ self.conn.compute.start_server(server=server_id)
+
+ @sdk.translate_exception
+ def stop_server(self, server_id):
+ self.conn.compute.stop_server(server=server_id)
+
+ @sdk.translate_exception
+ def reboot_server(self, server_id, reboot_type):
+ self.conn.compute.reboot_server(server=server_id,
+ reboot_type=reboot_type)
+
+ @sdk.translate_exception
def list_flavors(self, **query):
flavors = self.conn.compute.flavors(**query)
return flavors
diff --git a/vio/vio/pub/vim/vimapi/network/OperateNetwork.py b/vio/vio/pub/vim/vimapi/network/OperateNetwork.py
index f20e377..91d333f 100644
--- a/vio/vio/pub/vim/vimapi/network/OperateNetwork.py
+++ b/vio/vio/pub/vim/vimapi/network/OperateNetwork.py
@@ -90,7 +90,11 @@ class OperateNetwork(BaseNet):
network = self.auth(vim_info, tenantid)
body = translate(self.keys_mapping, body)
net = network.network_create(**body)
- vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId']}
+ vim_dict = {
+ "vimName": vim_info['name'],
+ "vimId": vim_info['vimId'],
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
resp = self._convert(net)
resp.update(vim_dict)
return resp
@@ -101,7 +105,11 @@ class OperateNetwork(BaseNet):
net = network.network_get(networkid)
if net is None:
return net
- vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId']}
+ vim_dict = {
+ "vimName": vim_info['name'],
+ "vimId": vim_info['vimId'],
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
resp = self._convert(net)
resp.update(vim_dict)
return resp
@@ -115,7 +123,11 @@ class OperateNetwork(BaseNet):
vim_info = self.get_vim_info(vimid)
network = self.auth(vim_info, tenantid)
resp = network.networks_get(**query)
- vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId']}
+ vim_dict = {
+ "vimName": vim_info['name'],
+ "vimId": vim_info['vimId'],
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
networks = {'networks': []}
if resp:
for net in resp:
diff --git a/vio/vio/pub/vim/vimapi/network/OperatePort.py b/vio/vio/pub/vim/vimapi/network/OperatePort.py
index b9abb60..fdf9576 100644
--- a/vio/vio/pub/vim/vimapi/network/OperatePort.py
+++ b/vio/vio/pub/vim/vimapi/network/OperatePort.py
@@ -68,7 +68,11 @@ class OperatePort(BaseNet):
else:
body['fixed_ips'] = [{'subnet_id': body.pop('subnetId')}]
port = network.port_create(**body)
- vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId']}
+ vim_dict = {
+ "vimName": vim_info['name'],
+ "vimId": vim_info['vimId'],
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
resp = self._convert(port)
resp.update(vim_dict)
return resp
@@ -79,7 +83,11 @@ class OperatePort(BaseNet):
port = network.port_find(portid, ignore_missing=ignore_missing)
if port is None:
return port
- vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId']}
+ vim_dict = {
+ "vimName": vim_info['name'],
+ "vimId": vim_info['vimId'],
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
resp = self._convert(port)
resp.update(vim_dict)
return resp
@@ -94,7 +102,11 @@ class OperatePort(BaseNet):
network = self.auth(vim_info, tenantid)
query.update({"project_id": tenantid})
resp = network.ports_get(**query)
- vim_dict = {"vimName": vim_info['name'], "vimId": vim_info['vimId']}
+ vim_dict = {
+ "vimName": vim_info['name'],
+ "vimId": vim_info['vimId'],
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
ports = {'ports': []}
if resp:
for port in resp:
diff --git a/vio/vio/pub/vim/vimapi/network/OperateSubnet.py b/vio/vio/pub/vim/vimapi/network/OperateSubnet.py
index 1076f40..bd67578 100644
--- a/vio/vio/pub/vim/vimapi/network/OperateSubnet.py
+++ b/vio/vio/pub/vim/vimapi/network/OperateSubnet.py
@@ -56,7 +56,9 @@ class OperateSubnet(BaseNet):
subnet = network.subnet_create(**body)
vim_dict = {
"vimName": vim_info['name'], "vimId": vim_info['vimId'],
- "tenantId": tenantid}
+ "tenantId": tenantid,
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
resp = self._convert(subnet)
resp.update(vim_dict)
return resp
@@ -69,7 +71,9 @@ class OperateSubnet(BaseNet):
return subnet
vim_dict = {
"vimName": vim_info['name'], "vimId": vim_info['vimId'],
- "tenantId": tenantid}
+ "tenantId": tenantid,
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
resp = self._convert(subnet)
resp.update(vim_dict)
return resp
@@ -86,7 +90,9 @@ class OperateSubnet(BaseNet):
resp = network.subnets_get(**query)
vim_dict = {
"vimName": vim_info['name'], "vimId": vim_info['vimId'],
- "tenantId": tenantid}
+ "tenantId": tenantid,
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
subnets = {'subnets': []}
if resp:
for subnet in resp:
diff --git a/vio/vio/pub/vim/vimapi/nova/OperateServers.py b/vio/vio/pub/vim/vimapi/nova/OperateServers.py
index 3075276..b14c7f4 100644
--- a/vio/vio/pub/vim/vimapi/nova/OperateServers.py
+++ b/vio/vio/pub/vim/vimapi/nova/OperateServers.py
@@ -162,3 +162,33 @@ class OperateServers(OperateNova):
'project_id': project_id}
project = self.compute(param).delete_server(server_id)
return project
+
+ def start_server(self, data, project_id, server_id):
+ param = {'username': data['username'],
+ 'user_domain_name': 'default',
+ 'project_domain_name': 'default',
+ 'password': data['password'],
+ 'auth_url': data['url'],
+ 'project_id': project_id}
+ project = self.compute(param).start_server(server_id)
+ return project
+
+ def stop_server(self, data, project_id, server_id):
+ param = {'username': data['username'],
+ 'user_domain_name': 'default',
+ 'project_domain_name': 'default',
+ 'password': data['password'],
+ 'auth_url': data['url'],
+ 'project_id': project_id}
+ project = self.compute(param).stop_server(server_id)
+ return project
+
+ def reboot_server(self, data, project_id, server_id, reboot_type):
+ param = {'username': data['username'],
+ 'user_domain_name': 'default',
+ 'project_domain_name': 'default',
+ 'password': data['password'],
+ 'auth_url': data['url'],
+ 'project_id': project_id}
+ project = self.compute(param).reboot_server(server_id, reboot_type)
+ return project
diff --git a/vio/vio/swagger/image_utils.py b/vio/vio/swagger/image_utils.py
index 9370508..02acc8e 100644
--- a/vio/vio/swagger/image_utils.py
+++ b/vio/vio/swagger/image_utils.py
@@ -36,6 +36,8 @@ def vim_formatter(vim_info, tenantid):
rsp = {}
rsp['vimId'] = vim_info.get('vimId')
+ rsp['cloud_owner'] = vim_info.get('cloud_owner')
+ rsp['cloud_region_id'] = vim_info.get('cloud_region_id')
rsp['vimName'] = vim_info.get('name')
rsp['tenantId'] = tenantid
return rsp
diff --git a/vio/vio/swagger/urls.py b/vio/vio/swagger/urls.py
index b7bdbcf..8456d71 100644
--- a/vio/vio/swagger/urls.py
+++ b/vio/vio/swagger/urls.py
@@ -25,6 +25,8 @@ from vio.swagger.views.image.views import GetImageFileView
from vio.swagger.views.volume.views import CreateListVolumeView
from vio.swagger.views.volume.views import GetDeleteVolumeView
from vio.swagger.views.server.views import ListServersView, GetServerView
+from vio.swagger.views.server.views import ServerActionView
+from vio.swagger.views.server.views import ServerActionViewV1
from vio.swagger.views.flavor.views import FlavorsView, FlavorView
from vio.swagger.views.network.views import CreateNetworkView
from vio.swagger.views.network.views import DeleteNetworkView
@@ -65,6 +67,21 @@ from vio.swagger.views.proxyplugin.heat.views import HeatServer
from vio.swagger.views.proxyplugin.dns.views import DesignateServer
from vio.swagger.views.proxyplugin.dns.views import DesignateVersionLink
+# proxy V1
+from vio.swagger.views.proxyplugin.identity.views import TokenViewV1
+from vio.swagger.views.proxyplugin.identity.views import TokenV2ViewV1
+from vio.swagger.views.proxyplugin.identity.views import IdentityServerV1
+from vio.swagger.views.proxyplugin.identity.views import IdentityVersionLinkV1
+from vio.swagger.views.proxyplugin.nova.views import ComputeServerV1
+from vio.swagger.views.proxyplugin.image.views import ImageServerV1
+from vio.swagger.views.proxyplugin.image.views import ImageVersionLinkV1
+from vio.swagger.views.proxyplugin.neutron.views import NetWorkServerV1
+from vio.swagger.views.proxyplugin.neutron.views import NetworkVersionLinkV1
+from vio.swagger.views.proxyplugin.volumn.views import VolumeServerV1
+from vio.swagger.views.proxyplugin.heat.views import HeatServerV1
+from vio.swagger.views.proxyplugin.dns.views import DesignateServerV1
+from vio.swagger.views.proxyplugin.dns.views import DesignateVersionLinkV1
+
# Registry
from vio.swagger.views.registry.views import Registry, RegistryV1
from vio.swagger.views.registry.views import UnRegistry, UnRegistryV1
@@ -134,6 +151,10 @@ urlpatterns = [
r'(?P<tenantid>[0-9a-zA-Z]+)/servers/(?P<serverid>[0-9a-zA-Z_-]+)$',
GetServerView.as_view()),
url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z_-]+)/'
+ r'(?P<tenantid>[0-9a-zA-Z]+)/servers/'
+ r'(?P<serverid>[0-9a-zA-Z_-]+)/action$',
+ ServerActionView.as_view()),
+ url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z_-]+)/'
r'(?P<tenantid>[0-9a-zA-Z]+)/flavors$',
FlavorsView.as_view()),
url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-zA-Z_-]+)/'
@@ -170,6 +191,7 @@ urlpatterns = [
r'(?P<portid>[0-9a-zA-Z\-\_]+)$',
DeletePortView.as_view()),
+
# V1 urls
url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
r'(?P<cloud_region>[0-9a-zA-Z_-]+)/tenants$',
@@ -208,6 +230,10 @@ urlpatterns = [
GetServerViewV1.as_view()),
url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
r'(?P<cloud_region>[0-9a-zA-Z_-]+)/(?P<tenantid>[0-9a-zA-Z]+)/'
+ r'servers/(?P<serverid>[0-9a-zA-Z_-]+)/action$',
+ ServerActionViewV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/(?P<tenantid>[0-9a-zA-Z]+)/'
r'flavors$',
FlavorsViewV1.as_view()),
url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
@@ -420,6 +446,66 @@ urlpatterns = [
r'designate/(?P<other>(.*))$',
DesignateServer.as_view()),
+ # proxy V1
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/identity/v3',
+ TokenViewV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/identity/v2.0$',
+ TokenV2ViewV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/identity/v2.0/tokens$',
+ TokenV2ViewV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/identity$',
+ IdentityVersionLinkV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/identity/(?P<other>(.*))$',
+ IdentityServerV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/glance$',
+ ImageVersionLinkV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/glance/(?P<other>(.*))$',
+ ImageServerV1.as_view()),
+ url(
+ r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/'
+ r'cinder/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$',
+ VolumeServerV1.as_view()),
+ url(
+ r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/'
+ r'cinderv2/(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$',
+ VolumeServerV1.as_view()),
+ url(
+ r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/cinderv3/'
+ r'(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$',
+ VolumeServerV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/neutron$',
+ NetworkVersionLinkV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/neutron/(?P<other>(.*))$',
+ NetWorkServerV1.as_view()),
+ url(
+ r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/heat/'
+ r'(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$',
+ HeatServerV1.as_view()),
+ url(
+ r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/nova/'
+ r'(?P<tenantid>[0-9a-z-A-Z\-\_]+)/(?P<other>(.*))$',
+ ComputeServerV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/designate$',
+ DesignateVersionLinkV1.as_view()),
+ url(r'^api/multicloud-vio/v1/(?P<cloud_owner>[0-9a-zA-Z_-]+)/'
+ r'(?P<cloud_region>[0-9a-zA-Z_-]+)/designate/(?P<other>(.*))$',
+ DesignateServerV1.as_view()),
+
# Extensions
url(r'^api/multicloud-vio/v0/(?P<vimid>[0-9a-z-A-Z\-\_]+)'
r'/extensions$',
diff --git a/vio/vio/swagger/views/proxyplugin/dns/views.py b/vio/vio/swagger/views/proxyplugin/dns/views.py
index 6b4819d..5878481 100644
--- a/vio/vio/swagger/views/proxyplugin/dns/views.py
+++ b/vio/vio/swagger/views/proxyplugin/dns/views.py
@@ -55,6 +55,15 @@ class DesignateVersionLink(BaseClient):
return Response(data=res, status=status.HTTP_200_OK)
+class DesignateVersionLinkV1(DesignateVersionLink):
+
+ serverType = 'designate'
+
+ def get(self, request, cloud_owner, cloud_region):
+ return super(DesignateVersionLinkV1, self).get(
+ request, cloud_owner + "_" + cloud_region)
+
+
class DesignateServer(BaseClient):
serverType = "designate"
@@ -85,3 +94,28 @@ class DesignateServer(BaseClient):
return self.send(request=request, method="DELETE",
vimid=vimid, other=other)
+
+
+class DesignateServerV1(DesignateServer):
+
+ serverType = 'designate'
+
+ def get(self, request, cloud_owner, cloud_region, other=None):
+ return super(DesignateServerV1, self).get(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def post(self, request, cloud_owner, cloud_region, other):
+ return super(DesignateServerV1, self).post(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def patch(self, request, cloud_owner, cloud_region, other):
+ return super(DesignateServerV1, self).patch(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def put(self, request, cloud_owner, cloud_region, other):
+ return super(DesignateServerV1, self).put(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def delete(self, request, cloud_owner, cloud_region, other):
+ return super(DesignateServerV1, self).delete(
+ request, cloud_owner + "_" + cloud_region, other)
diff --git a/vio/vio/swagger/views/proxyplugin/heat/views.py b/vio/vio/swagger/views/proxyplugin/heat/views.py
index 5e0de68..4c56f18 100644
--- a/vio/vio/swagger/views/proxyplugin/heat/views.py
+++ b/vio/vio/swagger/views/proxyplugin/heat/views.py
@@ -43,3 +43,28 @@ class HeatServer(BaseClient):
return self.send(request=request, method="PATCH",
vimid=vimid, tenantid=tenantid, other=other)
+
+
+class HeatServerV1(HeatServer):
+
+ serverType = 'heat'
+
+ def get(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(HeatServerV1, self).get(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def post(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(HeatServerV1, self).post(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def patch(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(HeatServerV1, self).patch(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def put(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(HeatServerV1, self).put(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def delete(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(HeatServerV1, self).delete(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
diff --git a/vio/vio/swagger/views/proxyplugin/identity/views.py b/vio/vio/swagger/views/proxyplugin/identity/views.py
index c6db117..6ff8b2a 100644
--- a/vio/vio/swagger/views/proxyplugin/identity/views.py
+++ b/vio/vio/swagger/views/proxyplugin/identity/views.py
@@ -64,6 +64,15 @@ class IdentityVersionLink(BaseClient):
return Response(data=res, status=status.HTTP_200_OK)
+class IdentityVersionLinkV1(IdentityVersionLink):
+
+ serverType = 'keystone'
+
+ def get(self, request, cloud_owner, cloud_region):
+ return super(IdentityVersionLinkV1, self).get(
+ request, cloud_owner + "_" + cloud_region)
+
+
class IdentityServer(BaseClient):
serverType = 'keystone'
@@ -96,6 +105,31 @@ class IdentityServer(BaseClient):
vimid=vimid, other=other)
+class IdentityServerV1(IdentityServer):
+
+ serverType = 'keystone'
+
+ def get(self, request, cloud_owner, cloud_region, other=None):
+ return super(IdentityServerV1, self).get(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def post(self, request, cloud_owner, cloud_region, other):
+ return super(IdentityServerV1, self).post(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def patch(self, request, cloud_owner, cloud_region, other):
+ return super(IdentityServerV1, self).patch(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def put(self, request, cloud_owner, cloud_region, other):
+ return super(IdentityServerV1, self).put(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def head(self, request, cloud_owner, cloud_region, other):
+ return super(IdentityServerV1, self).head(
+ request, cloud_owner + "_" + cloud_region, other)
+
+
class TokenView(BaseClient):
serverType = 'identity'
@@ -238,6 +272,23 @@ class TokenView(BaseClient):
return Res
+class TokenViewV1(TokenView):
+
+ serverType = 'identity'
+
+ def get(self, request, cloud_owner, cloud_region):
+ return super(TokenViewV1, self).get(
+ request, cloud_owner + "_" + cloud_region)
+
+ def post(self, request, cloud_owner, cloud_region):
+ return super(TokenViewV1, self).post(
+ request, cloud_owner + "_" + cloud_region)
+
+ def delete(self, request, cloud_owner, cloud_region):
+ return super(TokenViewV1, self).delete(
+ request, cloud_owner + "_" + cloud_region)
+
+
class TokenV2View(BaseClient):
serverType = "identity"
@@ -294,6 +345,19 @@ class TokenV2View(BaseClient):
create_req=create_req)
+class TokenV2ViewV1(TokenV2View):
+
+ serverType = 'identity'
+
+ def get(self, request, cloud_owner, cloud_region):
+ return super(TokenV2ViewV1, self).get(
+ request, cloud_owner + "_" + cloud_region)
+
+ def post(self, request, cloud_owner, cloud_region):
+ return super(TokenV2ViewV1, self).post(
+ request, cloud_owner + "_" + cloud_region)
+
+
def _keystoneV2Token(url, vimid=None, create_req=None):
try:
diff --git a/vio/vio/swagger/views/proxyplugin/image/views.py b/vio/vio/swagger/views/proxyplugin/image/views.py
index 0156131..e183152 100644
--- a/vio/vio/swagger/views/proxyplugin/image/views.py
+++ b/vio/vio/swagger/views/proxyplugin/image/views.py
@@ -53,6 +53,15 @@ class ImageVersionLink(BaseClient):
return Response(data=res, status=status.HTTP_300_MULTIPLE_CHOICES)
+class ImageVersionLinkV1(ImageVersionLink):
+
+ serverType = 'glance'
+
+ def get(self, request, cloud_owner, cloud_region):
+ return super(ImageVersionLinkV1, self).get(
+ request, cloud_owner + "_" + cloud_region)
+
+
class ImageServer(BaseClient):
serverType = "glance"
@@ -83,3 +92,28 @@ class ImageServer(BaseClient):
return self.send(request=request, method="DELETE",
vimid=vimid, other=other)
+
+
+class ImageServerV1(ImageServer):
+
+ serverType = 'glance'
+
+ def get(self, request, cloud_owner, cloud_region, other=None):
+ return super(ImageServerV1, self).get(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def post(self, request, cloud_owner, cloud_region, other):
+ return super(ImageServerV1, self).post(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def patch(self, request, cloud_owner, cloud_region, other):
+ return super(ImageServerV1, self).patch(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def put(self, request, cloud_owner, cloud_region, other):
+ return super(ImageServerV1, self).put(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def delete(self, request, cloud_owner, cloud_region, other):
+ return super(ImageServerV1, self).delete(
+ request, cloud_owner + "_" + cloud_region, other)
diff --git a/vio/vio/swagger/views/proxyplugin/neutron/views.py b/vio/vio/swagger/views/proxyplugin/neutron/views.py
index d6b23e6..47590ed 100644
--- a/vio/vio/swagger/views/proxyplugin/neutron/views.py
+++ b/vio/vio/swagger/views/proxyplugin/neutron/views.py
@@ -53,6 +53,15 @@ class NetworkVersionLink(BaseClient):
return Response(data=res, status=status.HTTP_200_OK)
+class NetworkVersionLinkV1(NetworkVersionLink):
+
+ serverType = 'neutron'
+
+ def get(self, request, cloud_owner, cloud_region):
+ return super(NetworkVersionLinkV1, self).get(
+ request, cloud_owner + "_" + cloud_region)
+
+
class NetWorkServer(BaseClient):
serverType = "neutron"
@@ -83,3 +92,28 @@ class NetWorkServer(BaseClient):
return self.send(request=request, method="DELETE",
vimid=vimid, other=other)
+
+
+class NetWorkServerV1(NetWorkServer):
+
+ serverType = 'neutron'
+
+ def get(self, request, cloud_owner, cloud_region, other=None):
+ return super(NetWorkServerV1, self).get(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def post(self, request, cloud_owner, cloud_region, other):
+ return super(NetWorkServerV1, self).post(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def patch(self, request, cloud_owner, cloud_region, other):
+ return super(NetWorkServerV1, self).patch(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def put(self, request, cloud_owner, cloud_region, other):
+ return super(NetWorkServerV1, self).put(
+ request, cloud_owner + "_" + cloud_region, other)
+
+ def delete(self, request, cloud_owner, cloud_region, other):
+ return super(NetWorkServerV1, self).delete(
+ request, cloud_owner + "_" + cloud_region, other)
diff --git a/vio/vio/swagger/views/proxyplugin/nova/views.py b/vio/vio/swagger/views/proxyplugin/nova/views.py
index c61ec37..3527b88 100644
--- a/vio/vio/swagger/views/proxyplugin/nova/views.py
+++ b/vio/vio/swagger/views/proxyplugin/nova/views.py
@@ -38,3 +38,24 @@ class ComputeServer(BaseClient):
return self.send(request=request, method="DELETE", vimid=vimid,
tenantid=tenantid, other=other)
+
+
+class ComputeServerV1(ComputeServer):
+
+ serverType = 'nova'
+
+ def get(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(ComputeServerV1, self).get(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def post(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(ComputeServerV1, self).post(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def put(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(ComputeServerV1, self).put(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def delete(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(ComputeServerV1, self).delete(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
diff --git a/vio/vio/swagger/views/proxyplugin/volumn/views.py b/vio/vio/swagger/views/proxyplugin/volumn/views.py
index 3b3013c..01902e1 100644
--- a/vio/vio/swagger/views/proxyplugin/volumn/views.py
+++ b/vio/vio/swagger/views/proxyplugin/volumn/views.py
@@ -45,6 +45,31 @@ class VolumeServer(BaseClient):
tenantid=tenantid, other=other)
+class VolumeServerV1(VolumeServer):
+
+ serverType = 'cinder'
+
+ def get(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(VolumeServerV1, self).get(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def post(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(VolumeServerV1, self).post(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def patch(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(VolumeServerV1, self).patch(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def put(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(VolumeServerV1, self).put(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+ def delete(self, request, cloud_owner, cloud_region, tenantid, other):
+ return super(VolumeServerV1, self).delete(
+ request, cloud_owner + "_" + cloud_region, tenantid, other)
+
+
class VolumeServer2(VolumeServer):
serverType = "cinderv2"
diff --git a/vio/vio/swagger/views/server/views.py b/vio/vio/swagger/views/server/views.py
index fca9cb9..eb8acf0 100644
--- a/vio/vio/swagger/views/server/views.py
+++ b/vio/vio/swagger/views/server/views.py
@@ -45,7 +45,9 @@ class ListServersView(APIView):
'url': vim_info['url']}
rsp = {'vimId': vim_info['vimId'],
'vimName': vim_info['name'],
- 'tenantId': tenantid}
+ 'tenantId': tenantid,
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
servers_op = OperateServers.OperateServers()
server_name = create_req.get('name', None)
server_id = create_req.get('id', None)
@@ -104,7 +106,9 @@ class ListServersView(APIView):
rsp = {'vimId': vim_info['vimId'],
'vimName': vim_info['name'],
- 'servers': servers_resp}
+ 'servers': servers_resp,
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
return Response(data=rsp, status=status.HTTP_200_OK)
@@ -147,7 +151,9 @@ class GetServerView(APIView):
rsp = {'vimId': vim_info['vimId'],
'vimName': vim_info['name'],
- 'tenantId': tenantid}
+ 'tenantId': tenantid,
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
rsp.update(server_dict)
return Response(data=rsp, status=status.HTTP_200_OK)
@@ -183,3 +189,49 @@ class GetServerViewV1(GetServerView):
def delete(self, request, cloud_owner, cloud_region, tenantid, serverid):
return super(GetServerViewV1, self).delete(
request, cloud_owner + "_" + cloud_region, tenantid, serverid)
+
+
+class ServerActionView(APIView):
+
+ def post(self, request, vimid, tenantid, serverid):
+ try:
+ action_req = json.loads(request.body)
+ except Exception as e:
+ return Response(data={'error': 'Fail to decode request body.'},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+
+ try:
+ vim_info = extsys.get_vim_by_id(vimid)
+ except VimDriverVioException as e:
+ return Response(data={'error': str(e)}, status=e.status_code)
+ data = {'vimid': vim_info['vimId'],
+ 'vimName': vim_info['name'],
+ 'username': vim_info['userName'],
+ 'password': vim_info['password'],
+ 'url': vim_info['url']}
+
+ server_op = OperateServers.OperateServers()
+ try:
+ if 'os-start' in action_req:
+ server_op.start_server(data, tenantid, serverid)
+ elif 'os-stop' in action_req:
+ server_op.stop_server(data, tenantid, serverid)
+ elif 'reboot' in action_req:
+ reboot_type = action_req.get('reboot').get('type')
+ server_op.reboot_server(data, tenantid, serverid, reboot_type)
+ else:
+ return Response(data={'error': 'invalid request body.'},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ except Exception as e:
+ if hasattr(e, "http_status"):
+ return Response(data={'error': str(e)}, status=e.http_status)
+ else:
+ return Response(data={'error': str(e)},
+ status=status.HTTP_500_INTERNAL_SERVER_ERROR)
+ return Response(status=status.HTTP_202_ACCEPTED)
+
+
+class ServerActionViewV1(ServerActionView):
+ def post(self, request, cloud_owner, cloud_region, tenantid, serverid):
+ return super(ServerActionViewV1, self).post(
+ request, cloud_owner + "_" + cloud_region, tenantid, serverid)
diff --git a/vio/vio/swagger/views/service/views.py b/vio/vio/swagger/views/service/views.py
index 239e795..fe081fb 100644
--- a/vio/vio/swagger/views/service/views.py
+++ b/vio/vio/swagger/views/service/views.py
@@ -50,7 +50,9 @@ class HostsView(APIView):
rsp = {'vimid': vim_info['vimId'],
'vimName': vim_info['name'],
'tenantId': tenantid,
- 'hosts': hosts}
+ 'hosts': hosts,
+ 'cloud_owner': vim_info.get('cloud_owner'),
+ 'cloud_region_id': vim_info.get("cloud_region_id")}
return Response(data=rsp, status=status.HTTP_200_OK)
diff --git a/vio/vio/swagger/views/tenant/views.py b/vio/vio/swagger/views/tenant/views.py
index 0ee58df..b48c5f5 100644
--- a/vio/vio/swagger/views/tenant/views.py
+++ b/vio/vio/swagger/views/tenant/views.py
@@ -53,6 +53,8 @@ class ListTenantsView(APIView):
rsp['vimId'] = vim_info['vimId']
rsp['vimName'] = vim_info['name']
rsp['tenants'] = []
+ rsp['cloud_owner'] = vim_info.get('cloud_owner')
+ rsp['cloud_region_id'] = vim_info.get('cloud_region_id')
for project in projects:
tenant = {}
diff --git a/vio/vio/swagger/volume_utils.py b/vio/vio/swagger/volume_utils.py
index 94d8de0..49ebb31 100644
--- a/vio/vio/swagger/volume_utils.py
+++ b/vio/vio/swagger/volume_utils.py
@@ -42,6 +42,8 @@ def vim_formatter(vim_info, tenantid):
rsp['vimId'] = vim_info.get('vimId')
rsp['vimName'] = vim_info.get('name')
rsp['tenantId'] = tenantid
+ rsp['cloud_owner'] = vim_info.get('cloud_owner')
+ rsp['cloud_region_id'] = vim_info.get('cloud_region_id')
return rsp