コード例 #1
0
ファイル: dummyaggregate.py プロジェクト: aquila/sfa
    def node_to_rspec_node(self, node, options={}):
        rspec_node = NodeElement()
        site=self.driver.testbedInfo
        rspec_node['component_id'] = hostname_to_urn(self.driver.hrn, site['name'], node['hostname'])
        rspec_node['component_name'] = node['hostname']
        rspec_node['component_manager_id'] = Xrn(self.driver.hrn, 'authority+cm').get_urn()
        rspec_node['authority_id'] = hrn_to_urn(DummyXrn.site_hrn(self.driver.hrn, site['name']), 'authority+sa')
        #distinguish between Shared and Reservable nodes
        rspec_node['exclusive'] = 'false'

        rspec_node['hardware_types'] = [HardwareType({'name': 'dummy-pc'}),
                                        HardwareType({'name': 'pc'})]
        if site['longitude'] and site['latitude']:
            location = Location({'longitude': site['longitude'], 'latitude': site['latitude'], 'country': 'unknown'})
            rspec_node['location'] = location
        return rspec_node
コード例 #2
0
ファイル: dummyaggregate.py プロジェクト: tubav/sfa
    def get_nodes(self, slice_xrn, slice=None,slivers=[], options={}):
        # if we are dealing with a slice that has no node just return 
        # and empty list    
        if slice_xrn:
            if not slice or 'node_ids' not in slice.keys() or not slice['node_ids']:
                return []

        filter = {}
        if slice and 'node_ids' in slice and slice['node_ids']:
            filter['node_ids'] = slice['node_ids']

        nodes = self.driver.shell.GetNodes(filter)
        
        rspec_nodes = []
        for node in nodes:
            rspec_node = Node()
            # xxx how to retrieve site['login_base']
            site=self.driver.testbedInfo
            rspec_node['component_id'] = hostname_to_urn(self.driver.hrn, site['name'], node['hostname'])
            rspec_node['component_name'] = node['hostname']
            rspec_node['component_manager_id'] = Xrn(self.driver.hrn, 'authority+cm').get_urn()
            rspec_node['authority_id'] = hrn_to_urn(DummyXrn.site_hrn(self.driver.hrn, site['name']), 'authority+sa')
            rspec_node['exclusive'] = 'false'
            rspec_node['hardware_types'] = [HardwareType({'name': 'plab-pc'}),
                                            HardwareType({'name': 'pc'})]
             # add site/interface info to nodes.
            # assumes that sites, interfaces and tags have already been prepared.
            if site['longitude'] and site['latitude']:  
                location = Location({'longitude': site['longitude'], 'latitude': site['latitude'], 'country': 'unknown'})
                rspec_node['location'] = location

            if node['node_id'] in slivers:
                # add sliver info
                sliver = slivers[node['node_id']]
                rspec_node['client_id'] = node['hostname']
                rspec_node['slivers'] = [sliver]
                
                # slivers always provide the ssh service
                login = Login({'authentication': 'ssh-keys', 'hostname': node['hostname'], 'port':'22', 'username': slice['slice_name']})
                service = Services({'login': login})
                rspec_node['services'] = [service]
            rspec_nodes.append(rspec_node)
        return rspec_nodes