Ejemplo n.º 1
0
def SyncSlice(sslice, hostname_or_site, addwhitelist, addsliceips, addusers,
              createslice):
    """Creates and/or Updates a slice object in the PLC DB."""
    if createslice:
        print "Making slice! %s" % sslice['name']
        MakeSlice(sslice['name'])
    SyncSliceExpiration(sslice['name'])

    if addusers:
        SyncPersonsOnSlice(sslice['name'], sslice['users'])

    for attr in sslice['attrs']:
        SyncSliceAttribute(sslice['name'], attr)
    for h,node in sslice['network_list']:
        if (hostname_or_site is None or
            hostname_or_site == h or
            hostname_or_site in h):
            if addwhitelist:
                # Add this slice to the whitelist of all hosts.
                WhitelistSliceOnNode(sslice['name'], h)
                #RemoveSliceFromNode(sslice['name'], h)
            if addsliceips:
                attr = node.get_interface_attr(sslice)
                if attr:
                    SyncSliceAttribute(sslice['name'], attr)

            if sslice['use_initscript'] and hostname_or_site is not None:
                # Assign the mlab_generic_initscript to slices on this node.
                # TODO: Make this more flexible.
                attr = model.Attr(node.hostname(),
                                  initscript="mlab_generic_initscript")
                SyncSliceAttribute(sslice['name'], attr)
    return
Ejemplo n.º 2
0
 def setUp(self):
     self.users = [('User', 'Name', '*****@*****.**')]
     self.sites = [
         model.makesite('abc01',
                        '192.168.1.0',
                        '2400:1002:4008::',
                        'Some City',
                        'US',
                        36.850000,
                        74.783000,
                        self.users,
                        nodegroup='MeasurementLabCentos')
     ]
     self.attrs = [model.Attr('MeasurementLabCentos', disk_max='60000000')]
     # Setup synthetic user, site, and experiment configuration data.
     self.experiments = [
         model.Slice(name='abc_bar',
                     index=1,
                     attrs=self.attrs,
                     users=self.users,
                     use_initscript=True,
                     ipv6='all')
     ]
     # Assign experiments to nodes.
     for hostname, node in self.sites[0]['nodes'].iteritems():
         self.experiments[0].add_node_address(node)