knows about the new plcapi interface about ipaddresses and routes
Thierry Parmentelat [Mon, 23 Apr 2012 16:50:23 +0000 (18:50 +0200)]
system/LocalSubstrate.inria.py
system/Substrate.py
system/TestApiserver.py
system/TestNode.py
system/TestPlc.py
system/config_default.py

index 1dcd262..74e8a0d 100755 (executable)
@@ -59,12 +59,15 @@ class OnelabSubstrate (Substrate):
       return 'pl.sophia.inria.fr'
 
    def network_settings (self):
-      return { 'interface_fields:gateway':'138.96.112.250',
-               'interface_fields:network':'138.96.112.0',
-               'interface_fields:broadcast':'138.96.119.255',
-               'interface_fields:netmask':'255.255.248.0',
-               'interface_fields:dns1': '138.96.112.1',
-               'interface_fields:dns2': '138.96.112.2',
+      return { 'interface_fields:gateway':      '138.96.112.250',
+               'route_fields:next_hop':         '138.96.112.250',
+               'interface_fields:network':      '138.96.112.0',
+               'interface_fields:broadcast':    '138.96.119.255',
+               'interface_fields:netmask':      '255.255.248.0',
+               'interface_fields:dns1':         '138.96.112.1',
+               'interface_fields:dns2':         '138.96.112.2',
+               'node_fields_nint:dns':          '138.96.112.1,138.96.112.2',
+               'ipaddress_fields:netmask':      '255.255.248.0',
                }
 
 # the hostname for the testmaster - in case we'd like to run this remotely
index 4204815..4e67a85 100644 (file)
@@ -1174,6 +1174,7 @@ class Substrate:
             nodemap={'host_box':qemu_boxname,
                      'node_fields:hostname':vnode_fqdn,
                      'interface_fields:ip':ip, 
+                     'ipaddress_fields:ip_addr':ip, 
                      'interface_fields:mac':mac,
                      }
             nodemap.update(self.network_settings())
index 29bdebc..c5389f2 100644 (file)
@@ -12,6 +12,8 @@ server_methods = [ ('GetNodes' ,  []),
                    ('DeleteNode' , True),
                    ('UpdateNode' , True),
                    ('AddInterface' , True),
+                   ('AddIpAddress' , True),
+                   ('AddRoute' , True),
                    ('GetInterfaces' , True),
                    ('GetTagTypes' , []),
                    ('AddTagType' , True),
index 4d684dc..54ea416 100644 (file)
@@ -67,17 +67,30 @@ class TestNode:
         utils.header("node %s created by user %s"%(self.name(),test_user.name()))
         rootauth=self.test_plc.auth_root()
         server = self.test_plc.apiserver
-        server.AddNode(userauth,
-                       self.test_site.site_spec['site_fields']['login_base'],
-                       self.node_spec['node_fields'])
+        node_id=server.AddNode(userauth,
+                               self.test_site.site_spec['site_fields']['login_base'],
+                               self.node_spec['node_fields'])
         server.SetNodePlainBootstrapfs(userauth,
                                        self.node_spec['node_fields']['hostname'],
                                        'YES')
         # create as reinstall to avoid user confirmation
         server.UpdateNode(userauth, self.name(), {'boot_state':'reinstall'})
-        # populate network interfaces - primary
-        server.AddInterface(userauth,self.name(),
-                                            self.node_spec['interface_fields'])
+
+        if not self.test_plc.has_addresses_api():
+#            print 'USING OLD INTERFACE'
+            # populate network interfaces - primary
+            server.AddInterface(userauth,self.name(),
+                                self.node_spec['interface_fields'])
+        else:
+#            print 'USING NEW INTERFACE with separate ip addresses'
+            # this is for setting the 'dns' stuff that now goes with the node
+            server.UpdateNode (userauth, self.name(), self.node_spec['node_fields_nint'])
+            interface_id = server.AddInterface (userauth, self.name(),self.node_spec['interface_fields_nint'])
+            server.AddIpAddress (userauth, interface_id, self.node_spec['ipaddress_fields'])
+            route_fields=self.node_spec['route_fields']
+            route_fields['interface_id']=interface_id
+            server.AddRoute (userauth, node_id, self.node_spec['route_fields'])
+            pass
         # populate network interfaces - others
         if self.node_spec.has_key('extra_interfaces'):
             for interface in self.node_spec['extra_interfaces']:
index 463e794..f1ecd27 100644 (file)
@@ -146,6 +146,9 @@ class TestPlc:
         self.url="https://%s:443/PLCAPI/"%plc_spec['vserverip']
        self.apiserver=TestApiserver(self.url,options.dry_run)
         
+    def has_addresses_api (self):
+        return hasattr(self.apiserver,'AddIpAddress')
+
     def name(self):
         name=self.plc_spec['name']
         return "%s.%s"%(name,self.vservername)
@@ -357,8 +360,8 @@ class TestPlc:
     #################### display config
     def show (self):
         "show test configuration after localization"
-        self.display_pass (1)
-        self.display_pass (2)
+        self.show_pass (1)
+        self.show_pass (2)
         return True
 
     def export (self):
@@ -382,7 +385,7 @@ class TestPlc:
 
     # entry point
     always_display_keys=['PLC_WWW_HOST','nodes','sites',]
-    def display_pass (self,passno):
+    def show_pass (self,passno):
         for (key,val) in self.plc_spec.iteritems():
             if not self.options.verbose and key not in TestPlc.always_display_keys: continue
             if passno == 2:
index 288b613..0a3c9be 100644 (file)
@@ -27,21 +27,40 @@ def sfa_root (index):
 
 def nodes(options,index):
     return [{'name':'node%d'%index,
-             'node_fields': {'hostname': 'deferred-nodename%d'%index,
-                             'model':'qemu/minhw', } ,
+             'node_fields':             {'hostname': 'deferred-nodename%d'%index,
+                                         'model':'qemu/minhw', } ,
              'host_box': 'deferred-node-hostbox-%d'%index,
              'owner' : 'pi',
              'nodegroups' : 'mynodegroup',
-             'interface_fields': { 'method':'static',
-                                   'type':'ipv4',
-                                   'ip':'xxx-deferred-xxx',
-                                   'gateway':'xxx-deferred-xxx',
-                                   'network':'xxx-deferred-xxx',
-                                   'broadcast':'xxx-deferred-xxx',
-                                   'netmask':'xxx-deferred-xxx',
-                                   'dns1': 'xxx-deferred-xxx',
-                                   'dns2': 'xxx-deferred-xxx',
-                                   },
+             'interface_fields':        { 'method':'static',
+                                          'type':'ipv4',
+                                          'ip':'xxx-deferred-xxx',
+                                          'gateway':'xxx-deferred-xxx',
+                                          'network':'xxx-deferred-xxx',
+                                          'broadcast':'xxx-deferred-xxx',
+                                          'netmask':'xxx-deferred-xxx',
+                                          'dns1': 'xxx-deferred-xxx',
+                                          'dns2': 'xxx-deferred-xxx',
+                                          },
+             # how to deal with the new plcapi way of modeling interfaces
+             # last_updated - ip_address_ids - is_primary - hostname 
+             # method 'static' or 'dhcp' - mac - interface_tag_ids
+             # if_name - ifname (accessor) - bwlimit
+             # xxx remains to deal with dns1 dns2 and gateway
+             # this gets appended to node_fields with the new interface
+             'node_fields_nint' :       { 'dns':'xxx-deferred-xxx',
+                                          },
+             'interface_fields_nint' :  { 'is_primary' : True,
+                                          'method' : 'static',
+                                          },
+             # last_updated - netmask - ip_addr - type (e.g., 'ipv4')
+             'ipaddress_fields' :       { 'type' : 'ipv4',
+                                          'ip_addr' : 'xxx-deferred-xxx',
+                                          'netmask' : 'xxx-deferred-xxx',
+                                          } ,
+             'route_fields' :           { 'subnet' : '0.0.0.0/0',
+                                          'next_hop' : 'xxx-deferred-xxx',
+                                          },
              }]
 
 def all_nodenames (options,index):