aboutsummaryrefslogtreecommitdiffstats
path: root/src/workflow
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2020-03-16 17:54:09 +0000
committerGerrit Code Review <gerrit@opnfv.org>2020-03-16 17:54:09 +0000
commit0db3a84d9d9ed213983a517efd35c339537ef472 (patch)
treea6d7ac7ba2f2d70e18cb984bda4020c736082c62 /src/workflow
parent176ec9aacbc87e6077e8807c60f95a1ccbbc26e3 (diff)
parent064f145f218385a6401fa6be2ccbbc462e915c26 (diff)
Merge "Test resource templates now use the same lab as the image generated alongside it."
Diffstat (limited to 'src/workflow')
-rw-r--r--src/workflow/booking_workflow.py7
-rw-r--r--src/workflow/forms.py37
-rw-r--r--src/workflow/models.py6
-rw-r--r--src/workflow/opnfv_workflow.py4
-rw-r--r--src/workflow/resource_bundle_workflow.py30
-rw-r--r--src/workflow/snapshot_workflow.py4
-rw-r--r--src/workflow/sw_bundle_workflow.py12
-rw-r--r--src/workflow/workflow_manager.py13
8 files changed, 53 insertions, 60 deletions
diff --git a/src/workflow/booking_workflow.py b/src/workflow/booking_workflow.py
index c96e1b9..00fa0f9 100644
--- a/src/workflow/booking_workflow.py
+++ b/src/workflow/booking_workflow.py
@@ -14,7 +14,7 @@ from datetime import timedelta
from booking.models import Booking
from workflow.models import WorkflowStep, AbstractSelectOrCreate
from workflow.forms import ResourceSelectorForm, SWConfigSelectorForm, BookingMetaForm, OPNFVSelectForm
-from resource_inventory.models import GenericResourceBundle, ConfigBundle, OPNFVConfig
+from resource_inventory.models import OPNFVConfig, ResourceTemplate
from django.db.models import Q
@@ -44,8 +44,7 @@ class Abstract_Resource_Select(AbstractSelectOrCreate):
def get_form_queryset(self):
user = self.repo_get(self.repo.SESSION_USER)
- qs = GenericResourceBundle.objects.filter(Q(hidden=False) & (Q(owner=user) | Q(public=True)))
- return qs
+ return ResourceTemplate.objects.filter(Q(hidden=False) & (Q(owner=user) | Q(public=True)))
def get_page_context(self):
return {
@@ -83,7 +82,7 @@ class SWConfig_Select(AbstractSelectOrCreate):
def get_form_queryset(self):
user = self.repo_get(self.repo.SESSION_USER)
grb = self.repo_get(self.repo.SELECTED_GRESOURCE_BUNDLE)
- qs = ConfigBundle.objects.filter(Q(hidden=False) & (Q(owner=user) | Q(public=True))).filter(bundle=grb)
+ qs = ResourceTemplate.objects.filter(Q(hidden=False) & (Q(owner=user) | Q(public=True))).filter(bundle=grb)
return qs
def put_confirm_info(self, bundle):
diff --git a/src/workflow/forms.py b/src/workflow/forms.py
index f7a20eb..37bc390 100644
--- a/src/workflow/forms.py
+++ b/src/workflow/forms.py
@@ -300,7 +300,7 @@ class FormUtils:
else:
multiple_hosts = false
labs = {}
- hosts = {}
+ resources = {}
items = {}
neighbors = {}
for lab in Lab.objects.all():
@@ -311,24 +311,21 @@ class FormUtils:
'description': lab.description,
'selected': false,
'selectable': true,
- 'follow': false,
+ 'follow': multiple_hosts,
'multiple': false,
'class': 'lab'
}
- if multiple_hosts:
- # "follow" this lab node to discover more hosts if allowed
- lab_node['follow'] = true
items[lab_node['id']] = lab_node
neighbors[lab_node['id']] = []
labs[lab_node['id']] = lab_node
- for host in lab.hostprofiles.all():
- host_node = {
+ for template in lab.resourcetemplates.all():
+ resource_node = {
'form': {"name": "host_name", "type": "text", "placeholder": "hostname"},
- 'id': "host_" + str(host.id),
- 'model_id': host.id,
- 'name': host.name,
- 'description': host.description,
+ 'id': "resource_" + str(template.id),
+ 'model_id': template.id,
+ 'name': template.name,
+ 'description': template.description,
'selected': false,
'selectable': true,
'follow': false,
@@ -336,15 +333,15 @@ class FormUtils:
'class': 'host'
}
if multiple_hosts:
- host_node['values'] = [] # place to store multiple values
- items[host_node['id']] = host_node
- neighbors[lab_node['id']].append(host_node['id'])
- if host_node['id'] not in neighbors:
- neighbors[host_node['id']] = []
- neighbors[host_node['id']].append(lab_node['id'])
- hosts[host_node['id']] = host_node
-
- display_objects = [("lab", labs.values()), ("host", hosts.values())]
+ resource_node['values'] = [] # place to store multiple values
+ items[resource_node['id']] = resource_node
+ neighbors[lab_node['id']].append(resource_node['id'])
+ if resource_node['id'] not in neighbors:
+ neighbors[resource_node['id']] = []
+ neighbors[resource_node['id']].append(lab_node['id'])
+ resources[resource_node['id']] = resource_node
+
+ display_objects = [("lab", labs.values()), ("resource", resources.values())]
context = {
'display_objects': display_objects,
diff --git a/src/workflow/models.py b/src/workflow/models.py
index 32ac39c..df00d21 100644
--- a/src/workflow/models.py
+++ b/src/workflow/models.py
@@ -18,7 +18,7 @@ import requests
from workflow.forms import ConfirmationForm
from api.models import JobFactory
from dashboard.exceptions import ResourceAvailabilityException, ModelValidationException
-from resource_inventory.models import Image, GenericInterface, OPNFVConfig, HostOPNFVConfig, NetworkRole
+from resource_inventory.models import Image, InterfaceConfiguration, OPNFVConfig, ResourceOPNFVConfig, NetworkRole
from resource_inventory.resource_manager import ResourceManager
from resource_inventory.pdf_templater import PDFTemplater
from notifier.manager import NotificationHandler
@@ -552,7 +552,7 @@ class Repository():
if 'connections' in models:
for resource_name, mapping in models['connections'].items():
for profile_name, connection_set in mapping.items():
- interface = GenericInterface.objects.get(
+ interface = InterfaceConfiguration.objects.get(
profile__name=profile_name,
host__resource__name=resource_name,
host__resource__bundle=models['bundle']
@@ -725,7 +725,7 @@ class Repository():
config = config_bundle.hostConfigurations.get(
host__resource__name=host_role['host_name']
)
- HostOPNFVConfig.objects.create(
+ ResourceOPNFVConfig.objects.create(
role=host_role['role'],
host_config=config,
opnfv_config=opnfv_config
diff --git a/src/workflow/opnfv_workflow.py b/src/workflow/opnfv_workflow.py
index 0cac48e..6ffc91d 100644
--- a/src/workflow/opnfv_workflow.py
+++ b/src/workflow/opnfv_workflow.py
@@ -11,7 +11,7 @@
from django.forms import formset_factory
from workflow.models import WorkflowStep, AbstractSelectOrCreate
-from resource_inventory.models import ConfigBundle, OPNFV_SETTINGS
+from resource_inventory.models import ResourceTemplate, OPNFV_SETTINGS
from workflow.forms import OPNFVSelectionForm, OPNFVNetworkRoleForm, OPNFVHostRoleForm, SWConfigSelectorForm, BasicMetaForm
@@ -27,7 +27,7 @@ class OPNFV_Resource_Select(AbstractSelectOrCreate):
def get_form_queryset(self):
user = self.repo_get(self.repo.SESSION_USER)
- qs = ConfigBundle.objects.filter(owner=user)
+ qs = ResourceTemplate.objects.filter(owner=user)
return qs
def put_confirm_info(self, bundle):
diff --git a/src/workflow/resource_bundle_workflow.py b/src/workflow/resource_bundle_workflow.py
index f57476b..89baae7 100644
--- a/src/workflow/resource_bundle_workflow.py
+++ b/src/workflow/resource_bundle_workflow.py
@@ -22,11 +22,10 @@ from workflow.forms import (
ResourceMetaForm,
)
from resource_inventory.models import (
- GenericResourceBundle,
- GenericInterface,
- GenericHost,
- GenericResource,
- HostProfile,
+ ResourceProfile,
+ ResourceTemplate,
+ ResourceConfiguration,
+ InterfaceConfiguration,
Network,
NetworkConnection
)
@@ -64,12 +63,12 @@ class Define_Hardware(WorkflowStep):
models['hosts'] = [] # This will always clear existing data when this step changes
models['interfaces'] = {}
if "bundle" not in models:
- models['bundle'] = GenericResourceBundle(owner=self.repo_get(self.repo.SESSION_USER))
+ models['bundle'] = ResourceTemplate(owner=self.repo_get(self.repo.SESSION_USER))
host_data = data['host']
names = {}
for host_profile_dict in host_data.values():
id = host_profile_dict['id']
- profile = HostProfile.objects.get(id=id)
+ profile = ResourceProfile.objects.get(id=id)
# instantiate genericHost and store in repo
for name in host_profile_dict['values'].values():
if not re.match(r"(?=^.{1,253}$)(^([A-Za-z0-9-_]{1,62}\.)*[A-Za-z0-9-_]{1,63})", name):
@@ -77,14 +76,13 @@ class Define_Hardware(WorkflowStep):
if name in names:
raise NonUniqueHostnameException("All hosts must have unique names")
names[name] = True
- genericResource = GenericResource(bundle=models['bundle'], name=name)
- genericHost = GenericHost(profile=profile, resource=genericResource)
- models['hosts'].append(genericHost)
+ resourceConfig = ResourceConfiguration(profile=profile, template=models['bundle'])
+ models['hosts'].append(resourceConfig)
for interface_profile in profile.interfaceprofile.all():
- genericInterface = GenericInterface(profile=interface_profile, host=genericHost)
- if genericHost.resource.name not in models['interfaces']:
- models['interfaces'][genericHost.resource.name] = []
- models['interfaces'][genericHost.resource.name].append(genericInterface)
+ genericInterface = InterfaceConfiguration(profile=interface_profile, resource_config=resourceConfig)
+ if resourceConfig.name not in models['interfaces']:
+ models['interfaces'][resourceConfig.name] = []
+ models['interfaces'][resourceConfig.name].append(genericInterface)
# add selected lab to models
for lab_dict in data['lab'].values():
@@ -226,7 +224,7 @@ class Define_Nets(WorkflowStep):
for host in existing_host_list:
existing_hosts[host.resource.name] = host
- bundle = models.get("bundle", GenericResourceBundle(owner=self.repo_get(self.repo.SESSION_USER)))
+ bundle = models.get("bundle", ResourceTemplate(owner=self.repo_get(self.repo.SESSION_USER)))
for net_id, net in networks.items():
network = Network()
@@ -381,7 +379,7 @@ class Resource_Meta_Info(WorkflowStep):
models = self.repo_get(self.repo.GRESOURCE_BUNDLE_MODELS, {})
name = form.cleaned_data['bundle_name']
desc = form.cleaned_data['bundle_description']
- bundle = models.get("bundle", GenericResourceBundle(owner=self.repo_get(self.repo.SESSION_USER)))
+ bundle = models.get("bundle", ResourceTemplate(owner=self.repo_get(self.repo.SESSION_USER)))
bundle.name = name
bundle.description = desc
models['bundle'] = bundle
diff --git a/src/workflow/snapshot_workflow.py b/src/workflow/snapshot_workflow.py
index c2f4cd6..c0e2052 100644
--- a/src/workflow/snapshot_workflow.py
+++ b/src/workflow/snapshot_workflow.py
@@ -12,7 +12,7 @@ from django.utils import timezone
import json
from booking.models import Booking
-from resource_inventory.models import Host, Image
+from resource_inventory.models import ResourceQuery, Image
from workflow.models import WorkflowStep
from workflow.forms import BasicMetaForm, SnapshotHostSelectForm
@@ -61,7 +61,7 @@ class Select_Host_Step(WorkflowStep):
name = host['name']
booking_id = host['booking']
booking = Booking.objects.get(pk=booking_id)
- host = Host.objects.get(bundle=booking.resource, template__resource__name=name)
+ host = ResourceQuery.get(bundle=booking.resource, template__resource__name=name)
models = self.repo_get(self.repo.SNAPSHOT_MODELS, {})
if "host" not in models:
models['host'] = host
diff --git a/src/workflow/sw_bundle_workflow.py b/src/workflow/sw_bundle_workflow.py
index ebd8c86..686f46f 100644
--- a/src/workflow/sw_bundle_workflow.py
+++ b/src/workflow/sw_bundle_workflow.py
@@ -13,7 +13,7 @@ from django.forms import formset_factory
from workflow.models import WorkflowStep
from workflow.forms import BasicMetaForm, HostSoftwareDefinitionForm
from workflow.booking_workflow import Abstract_Resource_Select
-from resource_inventory.models import Image, GenericHost, ConfigBundle, HostConfiguration
+from resource_inventory.models import Image, ResourceConfiguration, ResourceTemplate
class SWConf_Resource_Select(Abstract_Resource_Select):
@@ -38,7 +38,7 @@ class Define_Software(WorkflowStep):
user = self.repo_get(self.repo.SESSION_USER)
lab = self.repo_get(self.repo.SELECTED_GRESOURCE_BUNDLE).lab
for i, host_data in enumerate(hosts_data):
- host = GenericHost.objects.get(pk=host_data['host_id'])
+ host = ResourceConfiguration.objects.get(pk=host_data['host_id'])
wrong_owner = Image.objects.exclude(owner=user).exclude(public=True)
wrong_host = Image.objects.exclude(host_type=host.profile)
wrong_lab = Image.objects.exclude(from_lab=lab)
@@ -86,7 +86,7 @@ class Define_Software(WorkflowStep):
if not grb:
return []
if grb.id:
- return GenericHost.objects.filter(resource__bundle=grb)
+ return ResourceConfiguration.objects.filter(resource__bundle=grb)
generic_hosts = self.repo_get(self.repo.GRESOURCE_BUNDLE_MODELS, {}).get("hosts", [])
return generic_hosts
@@ -109,7 +109,7 @@ class Define_Software(WorkflowStep):
def post(self, post_data, user):
models = self.repo_get(self.repo.CONFIG_MODELS, {})
if "bundle" not in models:
- models['bundle'] = ConfigBundle(owner=self.repo_get(self.repo.SESSION_USER))
+ models['bundle'] = ResourceTemplate(owner=self.repo_get(self.repo.SESSION_USER))
confirm = self.repo_get(self.repo.CONFIRMATION, {})
@@ -127,7 +127,7 @@ class Define_Software(WorkflowStep):
if headnode:
has_headnode = True
bundle = models['bundle']
- hostConfig = HostConfiguration(
+ hostConfig = ResourceConfiguration(
host=host,
image=image,
bundle=bundle,
@@ -175,7 +175,7 @@ class Config_Software(WorkflowStep):
def post(self, post_data, user):
models = self.repo_get(self.repo.CONFIG_MODELS, {})
if "bundle" not in models:
- models['bundle'] = ConfigBundle(owner=self.repo_get(self.repo.SESSION_USER))
+ models['bundle'] = ResourceTemplate(owner=self.repo_get(self.repo.SESSION_USER))
confirm = self.repo_get(self.repo.CONFIRMATION, {})
if "configuration" not in confirm:
diff --git a/src/workflow/workflow_manager.py b/src/workflow/workflow_manager.py
index fda105e..e31e14c 100644
--- a/src/workflow/workflow_manager.py
+++ b/src/workflow/workflow_manager.py
@@ -16,9 +16,8 @@ from booking.models import Booking
from workflow.workflow_factory import WorkflowFactory
from workflow.models import Repository
from resource_inventory.models import (
- GenericResourceBundle,
- ConfigBundle,
- HostConfiguration,
+ ResourceTemplate,
+ ResourceConfiguration,
OPNFVConfig
)
from workflow.forms import ManagerForm
@@ -154,10 +153,10 @@ class SessionManager():
edit_object = Booking.objects.get(pk=target_id)
self.prefill_booking(edit_object)
elif workflow_type == 1:
- edit_object = GenericResourceBundle.objects.get(pk=target_id)
+ edit_object = ResourceTemplate.objects.get(pk=target_id)
self.prefill_resource(edit_object)
elif workflow_type == 2:
- edit_object = ConfigBundle.objects.get(pk=target_id)
+ edit_object = ResourceTemplate.objects.get(pk=target_id)
self.prefill_config(edit_object)
def prefill_booking(self, booking):
@@ -213,7 +212,7 @@ class SessionManager():
models = self.active_workflow().repository.el.get(self.active_workflow().repository.CONFIG_MODELS, {})
models['bundle'] = config
models['host_configs'] = []
- for host_conf in HostConfiguration.objects.filter(bundle=config):
+ for host_conf in ResourceConfiguration.objects.filter(bundle=config):
models['host_configs'].append(host_conf)
models['opnfv'] = OPNFVConfig.objects.filter(bundle=config).last()
return models
@@ -227,7 +226,7 @@ class SessionManager():
opnfv = OPNFVConfig.objects.filter(bundle=config).last()
confirm['configuration']['installer'] = opnfv.installer.name
confirm['configuration']['scenario'] = opnfv.scenario.name
- for host_conf in HostConfiguration.objects.filter(bundle=config):
+ for host_conf in ResourceConfiguration.objects.filter(bundle=config):
h = {"name": host_conf.host.resource.name, "image": host_conf.image.name, "role": host_conf.opnfvRole.name}
confirm['configuration']['hosts'].append(h)
return confirm