aboutsummaryrefslogtreecommitdiffstats
path: root/vicn/resource/linux
diff options
context:
space:
mode:
Diffstat (limited to 'vicn/resource/linux')
-rw-r--r--vicn/resource/linux/file.py9
-rw-r--r--vicn/resource/linux/keypair.py12
-rw-r--r--vicn/resource/linux/link.py3
-rw-r--r--vicn/resource/linux/net_device.py1
-rw-r--r--vicn/resource/linux/package_manager.py3
-rw-r--r--vicn/resource/linux/physical.py2
6 files changed, 19 insertions, 11 deletions
diff --git a/vicn/resource/linux/file.py b/vicn/resource/linux/file.py
index cddda8ed..44b4b5be 100644
--- a/vicn/resource/linux/file.py
+++ b/vicn/resource/linux/file.py
@@ -37,14 +37,16 @@ class File(Resource):
"""
Resource: File
"""
- filename = Attribute(String, description = 'Path to the file',
+ filename = Attribute(String, description = 'Path to the file',
+ key = True,
mandatory = True)
node = Attribute(Node, description = 'Node on which the file is created',
mandatory = True,
multiplicity = Multiplicity.ManyToOne,
reverse_name = 'files',
+ key = True,
reverse_description = 'Files created on the node')
- overwrite = Attribute(Bool,
+ overwrite = Attribute(Bool,
description = 'Determines whether an existing file is overwritten',
default = False)
@@ -53,13 +55,12 @@ class File(Resource):
#--------------------------------------------------------------------------
def __get__(self):
-
# UGLY
@inline_task
def not_found():
raise ResourceNotFound
- if self.overwrite:
+ if self.overwrite:
return not_found()
def is_path (rv):
diff --git a/vicn/resource/linux/keypair.py b/vicn/resource/linux/keypair.py
index a81a40d4..66c98e5b 100644
--- a/vicn/resource/linux/keypair.py
+++ b/vicn/resource/linux/keypair.py
@@ -37,7 +37,7 @@ class Keypair(Resource):
Implements a SSH keypair
"""
- node = Attribute(Node,
+ node = Attribute(Node,
description = 'Node on which the certificate is created',
mandatory = True,
multiplicity = Multiplicity.ManyToOne)
@@ -47,24 +47,24 @@ class Keypair(Resource):
#--------------------------------------------------------------------------
# Resource lifecycle
#--------------------------------------------------------------------------
-
+
@inline_task
def __initialize__(self):
self._pubkey_file = File(node = Reference(self, 'node'),
filename = self.key + '.pub',
managed = False)
- self._key_file = File(node = Reference(self, 'node'),
- filename = self.key,
+ self._key_file = File(node = Reference(self, 'node'),
+ filename = self.key,
managed = False)
def __get__(self):
return self._pubkey_file.__get__() | self._key_file.__get__()
def __create__(self):
- return BashTask(None, CMD_CREATE, {
+ return BashTask(self.node, CMD_CREATE, {
'dirname': os.path.dirname(self.key),
'self': self})
-
+
def __delete__(self):
return self._pubkey_file.__delete__() | self._key_file.__delete__()
diff --git a/vicn/resource/linux/link.py b/vicn/resource/linux/link.py
index ad77bfb9..da41fbe1 100644
--- a/vicn/resource/linux/link.py
+++ b/vicn/resource/linux/link.py
@@ -73,8 +73,10 @@ class Link(Channel):
delay = Attribute(String, description = 'Link propagation delay')
src_node = Attribute(Node, description = 'Source node',
+ key = True,
mandatory = True)
dst_node = Attribute(Node, description = 'Destination node',
+ key = True,
mandatory = True)
def __init__(self, *args, **kwargs):
@@ -89,6 +91,7 @@ class Link(Channel):
# but the resource manager has to take over for IP addresses etc.
# Being done in initialize, those attributes won't be considered as
# dependencies and will thus not block the resource state machine.
+
self._src = NonTapBaseNetDevice(node = self.src_node,
device_name = self.dst_node.name,
channel = self,
diff --git a/vicn/resource/linux/net_device.py b/vicn/resource/linux/net_device.py
index e40256ea..40d3edb7 100644
--- a/vicn/resource/linux/net_device.py
+++ b/vicn/resource/linux/net_device.py
@@ -280,6 +280,7 @@ class BaseNetDevice(Interface, Application):
description = 'Capacity for interface shaping (Mb/s)')
mac_address = Attribute(String, description = 'Mac address of the device')
ip4_address = Attribute(String, description = 'IP address of the device')
+ ip4_prefix = Attribute(Integer, description = 'Prefix for the IPv4link', default=31) #XXX 31?
ip6_address = Attribute(String, description = 'IPv6 address of the device')
ip6_prefix = Attribute(Integer, description = 'Prefix for the IPv6 link', default=64)
ip6_forwarding = Attribute(Bool, description = 'IPv6 forwarding', default = True)
diff --git a/vicn/resource/linux/package_manager.py b/vicn/resource/linux/package_manager.py
index eaf83e17..1b9d518c 100644
--- a/vicn/resource/linux/package_manager.py
+++ b/vicn/resource/linux/package_manager.py
@@ -78,6 +78,7 @@ class PackageManager(Resource):
reverse_name = 'package_manager',
reverse_auto = True,
mandatory = True,
+ key = True,
multiplicity = Multiplicity.OneToOne)
trusted = Attribute(Bool,
description="Force repository trust",
@@ -181,6 +182,7 @@ class Package(Resource):
package_name = Attribute(String, mandatory = True)
node = Attribute(Node,
mandatory = True,
+ key = True,
requirements=[
Requirement('package_manager')
])
@@ -216,6 +218,7 @@ class Packages(Resource):
names = Attribute(String, multiplicity = Multiplicity.OneToMany)
node = Attribute(Node,
mandatory = True,
+ key = True,
requirements=[
Requirement('package_manager')
])
diff --git a/vicn/resource/linux/physical.py b/vicn/resource/linux/physical.py
index d7c0b518..f71b5856 100644
--- a/vicn/resource/linux/physical.py
+++ b/vicn/resource/linux/physical.py
@@ -75,7 +75,7 @@ class Physical(Node):
"""
Require a SSH keypair to be present for authentication on nodes
"""
- return Keypair(node = None, key = FN_KEY)
+ return Keypair(node = self, key = FN_KEY)
def __initialize__(self):
if not is_local_host(self.hostname):