Skip to content

Commit

Permalink
Update provisioning
Browse files Browse the repository at this point in the history
  • Loading branch information
Samcandy committed May 21, 2020
1 parent ff4e6be commit 1acb8b1
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 16 deletions.
64 changes: 63 additions & 1 deletion allocate/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def upload_vnf_package(self, vnf_pkg_path):
print(upload_vnfp.status_code)

def listen_on_vnf_package_subscriptions(self):
# TODO gitlab feature/deallocateNSSI API in 250 row
pass

def create_ns_descriptor(self):
Expand Down Expand Up @@ -254,5 +253,68 @@ def read_ns_instantiation(self, ns_instance_id):
}
return read_instance_nsi

def update_ns_instantiation(self, ns_instance_id, update_info):
print("Update Network service instance ID: {}".format(ns_instance_id))
print("Update Network service Info: {}".format(update_info))
url = self.NFVO_URL + "nslcm/v1/ns_instances/{}/update/".format(ns_instance_id)
data = dict()
if 'ADD' in update_info['type']:
data = {
"updateType": update_info['type'],
"addVnfInstance": [
{
"vnfInstanceId": update_info['vnf_instance_id'],
"vnfProfiledId": "string"
}
]
}
elif 'REMOVE' in update_info['type']:
data = {
"updateType": update_info['type'],
"removeVnfInstanceId": update_info['vnf_instance_id']
}
update_nsi = requests.post(url, data=json.dumps(data), headers=self.headers)
if update_nsi.status_code == 202:
print("Update operated status {}".format(update_nsi.status_code))
else:
response = {
"attributeListOut": {
'update_nsi': update_nsi.status_code
},
"status": "OperationFailed"
}
raise Exception(response)

def scale_ns_instantiation(self, ns_instance_id, scale_info):
print("Scale Network service instance ID: {}".format(ns_instance_id))
print("Scale Network service instance Info".format(scale_info))
url = self.NFVO_URL + "nslcm/v1/ns_instances/{}/scale/".format(ns_instance_id)
data = {
"scaleType": "SCALE_VNF",
"scaleVnfData": [
{
"vnfInstanceId": scale_info['vnf_instance_id'],
"scaleVnfType": scale_info['type'],
"scaleByStepData": {
"additionalParams": {
"replicas": scale_info['replicas']
}
}
}
]
}

scale_nsi = requests.post(url, data=json.dumps(data), headers=self.headers)
if scale_nsi.status_code == 202:
print("Scale operated status {}".format(scale_nsi.status_code))
else:
response = {
"attributeListOut": {
'scale_nsi': scale_nsi.status_code
},
"status": "OperationFailed"
}
raise Exception(response)

def listen_on_ns_instance_subscriptions(self):
pass
62 changes: 47 additions & 15 deletions deallocate/main.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,69 @@
from service_mapping_plugin_framework.deallocate_nssi_abc import DeallocateNSSIabc
import requests
import json


class NFVOPlugin(DeallocateNSSIabc):
def __init__(self, nm_host, nfvo_host):
super().__init__(nm_host, nfvo_host)
def __init__(self, nm_host, nfvo_host, subscription_host, parameter):
super().__init__(nm_host, nfvo_host, subscription_host, parameter)
self.headers = {'Content-type': 'application/json'}

def coordinate_tn_manager(self):
pass

def terminate_network_service_instance(self):
pass
print('Terminate Network service instance...')
url = self.NFVO_URL + "nslcm/v1/ns_instances/{}/terminate/".format(self.ns_instance)
response = requests.post(url, headers=self.headers)
print(response.status_code)

def delete_network_service_instance(self):
print('Delete Network service instance...')
url = self.NFVO_URL + "nslcm/v1/ns_instances/{}/".format(self.ns_instance)
response = requests.delete(url, headers=self.headers)
print(response.status_code)

def delete_network_service_instance_subscriptions(self):
pass

def update_network_service_descriptor(self):
pass
print('Update Network service descriptor...')
url = self.NFVO_URL + "nsd/v1/ns_descriptors/{}/".format(self.ns_descriptor)
data = {
"nsdOperationalState": "DISABLED",
"userDefinedData": [
{}
]
}
response = requests.patch(url, data=json.dumps(data), headers=self.headers)
print(response.status_code)

def delete_network_service_descriptor(self):
print('Delete Network service descriptor...')
url = self.NFVO_URL + "nsd/v1/ns_descriptors/{}/".format(self.ns_descriptor)
response = requests.delete(url, headers=self.headers)
print(response.status_code)

def delete_network_service_descriptor_subscriptions(self):
pass

def update_vnf_package(self):
pass
for vnf in self.vnf_package:
print('Update {} Vnf Package...'.format(vnf))
url = self.NFVO_URL + "vnfpkgm/v1/vnf_packages/{}/".format(vnf)
data = {
"operationalState": "DISABLED",
"userDefinedData": {}
}
response = requests.patch(url, data=json.dumps(data), headers=self.headers)
print(response.status_code)

def delete_vnf_package(self):
pass


def main():
nfvo_plugin = NFVOPlugin('', # nm host ip
'') # os-ma-nfvo host ip
nfvo_plugin.deallocate_nssi()
for vnf in self.vnf_package:
print('Delete {} Vnf Package...'.format(vnf))
url = self.NFVO_URL + "vnfpkgm/v1/vnf_packages/{}/".format(vnf)
response = requests.delete(url, headers=self.headers)
print(response.status_code)


if __name__ == '__main__':
main()
def delete_vnf_package_subscriptions(self):
pass

0 comments on commit 1acb8b1

Please sign in to comment.