aboutsummaryrefslogtreecommitdiffstats
path: root/src/resource_inventory/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/resource_inventory/models.py')
-rw-r--r--src/resource_inventory/models.py37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py
index 1e2e547..f462ac5 100644
--- a/src/resource_inventory/models.py
+++ b/src/resource_inventory/models.py
@@ -111,24 +111,20 @@ class Resource(models.Model):
def get_configuration(self, state):
"""
+ Get configuration of Resource.
+
Returns the desired configuration for this host as a
JSON object as defined in the rest api spec.
state is a ConfigState
- TODO: single method, or different methods for hw, network, snapshot, etc?
"""
raise NotImplementedError("Must implement in concrete Resource classes")
def reserve(self):
- """
- Reserves this resource for its currently
- assigned booking.
- """
+ """Reserve this resource for its currently assigned booking."""
raise NotImplementedError("Must implement in concrete Resource classes")
def release(self):
- """
- Makes this resource available again for new boookings
- """
+ """Make this resource available again for new boookings."""
raise NotImplementedError("Must implement in concrete Resource classes")
@@ -170,15 +166,14 @@ class PhysicalNetwork(Resource):
def get_configuration(self, state):
"""
- Returns the network configuration
+ Get the network configuration.
+
Collects info about each attached network interface and vlan, etc
"""
return {}
def reserve(self):
- """
- Reserves vlan(s) associated with this network
- """
+ """Reserve vlan(s) associated with this network."""
# vlan_manager = self.bundle.lab.vlan_manager
return False
@@ -329,9 +324,8 @@ class OPNFVRole(models.Model):
class Image(models.Model):
- """
- model for representing OS images / snapshots of hosts
- """
+ """Model for representing OS images / snapshots of hosts."""
+
id = models.AutoField(primary_key=True)
lab_id = models.IntegerField() # ID the lab who holds this image knows
from_lab = models.ForeignKey(Lab, on_delete=models.CASCADE)
@@ -354,10 +348,8 @@ def get_sentinal_opnfv_role():
class HostConfiguration(models.Model):
- """
- model to represent a complete configuration for a single
- physical host
- """
+ """Model to represent a complete configuration for a single physical host."""
+
id = models.AutoField(primary_key=True)
host = models.ForeignKey(GenericHost, related_name="configuration", on_delete=models.CASCADE)
image = models.ForeignKey(Image, on_delete=models.PROTECT)
@@ -433,17 +425,16 @@ class Interface(models.Model):
id = models.AutoField(primary_key=True)
mac_address = models.CharField(max_length=17)
bus_address = models.CharField(max_length=50)
- name = models.CharField(max_length=100, default="eth0")
config = models.ManyToManyField(Vlan)
host = models.ForeignKey(Host, on_delete=models.CASCADE, related_name='interfaces')
+ profile = models.ForeignKey(InterfaceProfile, on_delete=models.CASCADE)
def __str__(self):
return self.mac_address + " on host " + str(self.host)
class OPNFV_SETTINGS():
- """
- This is a static configuration class
- """
+ """This is a static configuration class."""
+
# all the required network types in PDF/IDF spec
NETWORK_ROLES = ["public", "private", "admin", "mgmt"]