示例#1
0
文件: sfav1.py 项目: HalasNet/felix
    def merge(self, in_rspec):
        """
        Merge contents for specified rspec with current rspec
        """

        if not in_rspec:
            return

        from foam.sfa.rspecs.rspec import RSpec
        if isinstance(in_rspec, RSpec):
            rspec = in_rspec
        else:
            rspec = RSpec(in_rspec)
        if rspec.version.type.lower() == 'protogeni':
            from foam.sfa.rspecs.rspec_converter import RSpecConverter
            in_rspec = RSpecConverter.to_sfa_rspec(rspec.toxml())
            rspec = RSpec(in_rspec)

        # just copy over all networks
        current_networks = self.get_networks()
        networks = rspec.version.get_networks()
        for network in networks:
            current_network = network.get('name')
            if current_network and current_network not in current_networks:
                self.xml.append(network.element)
                current_networks.append(current_network)
示例#2
0
    def get_rspec(self,
                  version=None,
                  slice_leaf=None,
                  projectName=None,
                  options={}):

        version_manager = VersionManager()
        version = version_manager.get_version(version)
        if slice_leaf:
            #Manifest RSpec will be used when somebody creates an sliver, returning the resources of this AM and the vm(s) requested by the user.
            rspec_version = version_manager._get_version(
                version.type, version.version, 'manifest')
            options['slice'] = slice_leaf
            of_xml = getManifest(options['slivers'], slice_leaf)
            rspec = RSpec(version=rspec_version, user_options=options)
            rspec.version.add_slivers(of_xml)
        else:
            rspec_version = version_manager._get_version(
                version.type, version.version, 'ad')
            if 'slice_urn' in options.keys():
                #TODO add filter
                pass
            of_xml = getAdvertisement()
            rspec = RSpec(version=rspec_version, user_options=options)
            rspec.version.add_nodes(of_xml)
        return rspec.toxml()
示例#3
0
    def merge(self, in_rspec):
        """
        Merge contents for specified rspec with current rspec
        """

        if not in_rspec:
            return

        from foam.sfa.rspecs.rspec import RSpec
        if isinstance(in_rspec, RSpec):
            rspec = in_rspec
        else:
            rspec = RSpec(in_rspec)
        if rspec.version.type.lower() == 'protogeni':
            from foam.sfa.rspecs.rspec_converter import RSpecConverter
            in_rspec = RSpecConverter.to_sfa_rspec(rspec.toxml())
            rspec = RSpec(in_rspec)

        # just copy over all networks
        current_networks = self.get_networks()
        networks = rspec.version.get_networks()
        for network in networks:
            current_network = network.get('name')
            if current_network and current_network not in current_networks:
                self.xml.append(network.element)
                current_networks.append(current_network)
示例#4
0
    def to_sfa_rspec(rspec, content_type=None):
        if not isinstance(rspec, RSpec):
            pg_rspec = RSpec(rspec)
        else:
            pg_rspec = rspec

        version_manager = VersionManager()
        sfa_version = version_manager._get_version('sfa', '1')
        sfa_rspec = RSpec(version=sfa_version)

        #nodes = pg_rspec.version.get_nodes()
        #sfa_rspec.version.add_nodes(nodes())
        #sfa_rspec.version.add_links(pg_rspec.version.get_links())
        #return sfa_rspec.toxml()

        # get network
        networks = pg_rspec.version.get_networks()
        network_hrn = networks[0]["name"]
        network_element = sfa_rspec.xml.add_element('network',
                                                    name=network_hrn,
                                                    id=network_hrn)

        # get nodes
        pg_nodes_elements = pg_rspec.version.get_nodes()
        nodes_with_slivers = pg_rspec.version.get_nodes_with_slivers()
        i = 1
        for pg_node in pg_nodes_elements:
            attribs = dict(pg_node.items())
            attribs['id'] = 'n' + str(i)

            node_element = network_element.add_element('node')
            for attrib in attribs:
                if type(attribs[attrib]) == str:
                    node_element.set(attrib, attribs[attrib])
            urn = pg_node["component_id"]
            if urn:
                if type(urn) == list:
                    # legacy code, not sure if urn is ever a list...
                    urn = urn[0]
                hostname = Xrn.urn_split(urn)[-1]
                hostname_element = node_element.add_element('hostname')
                hostname_element.set_text(hostname)
                if hostname in nodes_with_slivers:
                    node_element.add_element('sliver')

            for hardware_type in pg_node["hardware_types"]:
                if "name" in hardware_type:
                    node_element.add_element("hardware_type",
                                             name=hardware_type["name"])

            # just copy over remaining child elements
            #for child in pg_node_element.getchildren():
            #    node_element.append(transform(child).getroot())
            i = i + 1

        return sfa_rspec.toxml()
示例#5
0
    def to_sfa_rspec(rspec, content_type = None):
        if not isinstance(rspec, RSpec):
            pg_rspec = RSpec(rspec)
        else:
            pg_rspec = rspec
        
        version_manager = VersionManager()
        sfa_version = version_manager._get_version('sfa', '1')    
        sfa_rspec = RSpec(version=sfa_version)

        #nodes = pg_rspec.version.get_nodes()
        #sfa_rspec.version.add_nodes(nodes())
        #sfa_rspec.version.add_links(pg_rspec.version.get_links())
        #return sfa_rspec.toxml() 

        # get network
        networks = pg_rspec.version.get_networks()
        network_hrn = networks[0]["name"]
        network_element = sfa_rspec.xml.add_element('network', name=network_hrn, id=network_hrn)
        
        # get nodes
        pg_nodes_elements = pg_rspec.version.get_nodes()
        nodes_with_slivers = pg_rspec.version.get_nodes_with_slivers()
        i = 1
        for pg_node in pg_nodes_elements:
            attribs = dict(pg_node.items())
            attribs['id'] = 'n'+str(i)
            
            node_element = network_element.add_element('node')
            for attrib in attribs:
                if type(attribs[attrib]) == str:
                    node_element.set(attrib, attribs[attrib])
            urn = pg_node["component_id"]
            if urn:
                if type(urn)==list:
                    # legacy code, not sure if urn is ever a list...
                    urn = urn[0]
                hostname = Xrn.urn_split(urn)[-1]
                hostname_element = node_element.add_element('hostname')
                hostname_element.set_text(hostname)
                if hostname in nodes_with_slivers:
                    node_element.add_element('sliver')

            for hardware_type in pg_node["hardware_types"]:
                if "name" in hardware_type:
                    node_element.add_element("hardware_type", name=hardware_type["name"])
                     
            # just copy over remaining child elements  
            #for child in pg_node_element.getchildren():
            #    node_element.append(transform(child).getroot())
            i = i+1
 
        return sfa_rspec.toxml()
 def to_sfa_rspec(in_rspec, content_type=None):
     rspec = RSpec(in_rspec)
     version_manager = VersionManager()
     sfa_version = version_manager._get_version('sfa', '1')
     pg_version = version_manager._get_version('protogeni', '2')
     if rspec.version.type.lower() == sfa_version.type.lower():
         return in_rspec
     elif rspec.version.type.lower() == pg_version.type.lower():
         return PGRSpecConverter.to_sfa_rspec(in_rspec, content_type)
     else:
         return in_rspec
示例#7
0
	def get_rspec(self, version=None, slice_leaf=None, projectName=None, options={}):

        	version_manager = VersionManager()
        	version = version_manager.get_version(version)
		if slice_leaf:
		    #Manifest RSpec will be used when somebody creates an sliver, returning the resources of this AM and the vm(s) requested by the user.
		    rspec_version = version_manager._get_version(version.type, version.version, 'manifest')
		    options['slice'] = slice_leaf
                    of_xml = getManifest(options['slivers'],slice_leaf)
                    rspec = RSpec(version=rspec_version, user_options=options)
                    rspec.version.add_slivers(of_xml)
		else:
        	    rspec_version = version_manager._get_version(version.type, version.version, 'ad')
                    if 'slice_urn' in options.keys() :
                        #TODO add filter
                        pass
		    of_xml = getAdvertisement()
		    rspec = RSpec(version=rspec_version, user_options=options)
                    rspec.version.add_nodes(of_xml)
        	return rspec.toxml()
示例#8
0
    def merge(self, in_rspec):
        """
        Merge contents for specified rspec with current rspec
        """
        from foam.sfa.rspecs.rspec import RSpec
        # just copy over all the child elements under the root element
        if isinstance(in_rspec, basestring):
            in_rspec = RSpec(in_rspec)

        nodes = in_rspec.version.get_nodes()
        # protogeni rspecs need to advertise the availabel sliver types
        for node in nodes:
            if not node.has_key('sliver') or not node['sliver']:
                node['sliver'] = {'name': 'plab-vserver'}

        self.add_nodes(nodes)
        self.add_links(in_rspec.version.get_links())
示例#9
0
文件: ocfvtv1.py 项目: HalasNet/felix
    )  #'http://www.protogeni.net/resources/rspec/2/ad.xsd'
    template = '<rspec type="advertisement" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/ad.xsd /opt/ofelia/vt_manager/src/python/foam/sfa/tests/vm_schema.xsd"/>'


class OcfVtRequest(OcfVt):
    enabled = True
    content_type = "request"
    schema = (
        "/opt/ofelia/vt_manager/src/python/foam/sfa/tests/vm_schema.xsd"
    )  #'http://www.protogeni.net/resources/rspec/2/ad.xsd'
    template = '<rspec type="advertisement" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/ad.xsd /opt/ofelia/vt_manager/src/python/foam/sfa/tests/vm_schema.xsd"/>'

    # schema = 'http://www.protogeni.net/resources/rspec/2/request.xsd'
    # template = '<rspec type="request" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/request.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


class OcfVtManifest(OcfVt):
    enabled = True
    content_type = "manifest"
    schema = "http://www.protogeni.net/resources/rspec/2/manifest.xsd"
    template = '<rspec type="manifest" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/manifest.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


if __name__ == "__main__":
    from foam.sfa.rspecs.rspec import RSpec
    from foam.sfa.rspecs.rspec_elements import *

    r = RSpec("/tmp/ocf.rspec")
    r.load_rspec_elements(OcfVt.elements)
    print r.get(RSpecElements.NODE)
示例#10
0
文件: pgv2.py 项目: HalasNet/felix
class PGv2Ad(PGv2):
    enabled = True
    content_type = "ad"
    schema = "http://www.protogeni.net/resources/rspec/2/ad.xsd"
    template = '<rspec type="advertisement" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/ad.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


class PGv2Request(PGv2):
    enabled = True
    content_type = "request"
    schema = "http://www.protogeni.net/resources/rspec/2/request.xsd"
    template = '<rspec type="request" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/request.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


class PGv2Manifest(PGv2):
    enabled = True
    content_type = "manifest"
    schema = "http://www.protogeni.net/resources/rspec/2/manifest.xsd"
    template = '<rspec type="manifest" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/manifest.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


if __name__ == "__main__":
    from foam.sfa.rspecs.rspec import RSpec
    from foam.sfa.rspecs.rspec_elements import *

    r = RSpec("/tmp/pg.rspec")
    r.load_rspec_elements(PGv2.elements)
    r.namespaces = PGv2.namespaces
    print r.get(RSpecElements.NODE)
示例#11
0
        networks = rspec.version.get_networks()
        for network in networks:
            current_network = network.get('name')
            if current_network and current_network not in current_networks:
                self.xml.append(network.element)
                current_networks.append(current_network)

    # Leases

    def get_leases(self, filter=None):
        return NITOSv1Lease.get_leases(self.xml, filter)

    def add_leases(self, leases, channels, network=None, no_dupes=False):
        NITOSv1Lease.add_leases(self.xml, leases, channels)

    # Spectrum

    def get_channels(self, filter=None):
        return NITOSv1Channel.get_channels(self.xml, filter)

    def add_channels(self, channels, network=None, no_dupes=False):
        NITOSv1Channel.add_channels(self.xml, channels)


if __name__ == '__main__':
    from foam.sfa.rspecs.rspec import RSpec
    from foam.sfa.rspecs.rspec_elements import *
    r = RSpec('/tmp/resources.rspec')
    r.load_rspec_elements(SFAv1.elements)
    print r.get(RSpecElements.NODE)
    def to_pg_rspec(rspec, content_type = None):
        if not isinstance(rspec, RSpec):
            sfa_rspec = RSpec(rspec)
        else:
            sfa_rspec = rspec
  
        if not content_type or content_type not in \
          ['ad', 'request', 'manifest']:
            content_type = sfa_rspec.version.content_type
     
 
        version_manager = VersionManager()
        pg_version = version_manager._get_version('protogeni', '2', 'request')
        pg_rspec = RSpec(version=pg_version)
 
        # get networks
        networks = sfa_rspec.version.get_networks()
        
        for network in networks:
            # get nodes
            sfa_node_elements = sfa_rspec.version.get_node_elements(network=network)
            for sfa_node_element in sfa_node_elements:
                # create node element
                node_attrs = {}
                node_attrs['exclusive'] = 'false'
                if 'component_manager_id' in sfa_node_element.attrib:
                    node_attrs['component_manager_id'] = sfa_node_element.attrib['component_manager_id']
                else:
                    node_attrs['component_manager_id'] = hrn_to_urn(network, 'authority+cm')

                if 'component_id' in sfa_node_element.attrib:
                    node_attrs['compoenent_id'] = sfa_node_element.attrib['component_id']

                if sfa_node_element.find('hostname') != None:
                    hostname = sfa_node_element.find('hostname').text
                    node_attrs['component_name'] = hostname
                    node_attrs['client_id'] = hostname
                node_element = pg_rspec.xml.add_element('node', node_attrs)    
            
                if content_type == 'request':
                    sliver_element = sfa_node_element.find('sliver')
                    sliver_type_elements = sfa_node_element.xpath('./sliver_type', namespaces=sfa_rspec.namespaces)
                    available_sliver_types = [element.attrib['name'] for element in sliver_type_elements]
                    valid_sliver_types = ['emulab-openvz', 'raw-pc']
                   
                    # determine sliver type 
                    requested_sliver_type = 'emulab-openvz'
                    for available_sliver_type in available_sliver_types:
                        if available_sliver_type in valid_sliver_types:
                            requested_sliver_type = available_sliver_type
                                
                    if sliver_element != None:
                        pg_rspec.xml.add_element('sliver_type', {'name': requested_sliver_type}, parent=node_element) 
                else:
                    # create node_type element
                    for hw_type in ['plab-pc', 'pc']:
                        hdware_type_element = pg_rspec.xml.add_element('hardware_type', {'name': hw_type}, parent=node_element)
                    # create available element
                    pg_rspec.xml.add_element('available', {'now': 'true'}, parent=node_element)
                    # create locaiton element
                    # We don't actually associate nodes with a country. 
                    # Set country to "unknown" until we figure out how to make
                    # sure this value is always accurate.
                    location = sfa_node_element.find('location')
                    if location != None:
                        location_attrs = {}      
                        location_attrs['country'] =  location.get('country', 'unknown')
                        location_attrs['latitude'] = location.get('latitude', 'None')
                        location_attrs['longitude'] = location.get('longitude', 'None')
                        pg_rspec.xml.add_element('location', location_attrs, parent=node_element)

        return pg_rspec.toxml()
示例#13
0
	    if sliver_elems:
                node['slivers'] = OcfOfSlivers.get_slivers(sliver_elems)
	
            available_elems = node_elem.xpath('./available | ./default:available')
            if len(available_elems) > 0 and 'name' in available_elems[0].attrib:
                if available_elems[0].attrib.get('now', '').lower() == 'true': 
                    node['boot_state'] = 'boot'
                else: 
                    node['boot_state'] = 'disabled' 

        return nodes

    @staticmethod
    def remove_slivers(xml, hostnames):
        for hostname in hostnames:
            nodes = OcfOfNode.get_nodes(xml, {'component_id': '*%s*' % hostname})
            for node in nodes:
                slivers = OcfOfSliverType.get_slivers(node.element)
                for sliver in slivers:
                    node.element.remove(sliver.element) 
if __name__ == '__main__':
    from foam.sfa.rspecs.rspec import RSpec
    #import pdb
    r = RSpec('/tmp/emulab.rspec')
    r2 = RSpec(version = 'OcfOf')
    nodes = OcfOfNode.get_nodes(r.xml)
    OcfOfNode.add_nodes(r2.xml.root, nodes)
    #pdb.set_trace()
        
                                    
示例#14
0
                sliver = {}
            elif 'component_id' in sliver and sliver['component_id']:
                filter['component_id'] = '*%s*' % sliver['component_id']
            if not filter:
                continue
            nodes = PGv2Node.get_nodes(xml, filter)
            if not nodes:
                continue
            node = nodes[0]
            PGv2SliverType.add_slivers(node, sliver)

    @staticmethod
    def remove_slivers(xml, hostnames):
        for hostname in hostnames:
            nodes = PGv2Node.get_nodes(xml,
                                       {'component_id': '*%s*' % hostname})
            for node in nodes:
                slivers = PGv2SliverType.get_slivers(node.element)
                for sliver in slivers:
                    node.element.remove(sliver.element)


if __name__ == '__main__':
    from foam.sfa.rspecs.rspec import RSpec
    import pdb
    r = RSpec('/tmp/emulab.rspec')
    r2 = RSpec(version='ProtoGENI')
    nodes = PGv2Node.get_nodes(r.xml)
    PGv2Node.add_nodes(r2.xml.root, nodes)
    #pdb.set_trace()
示例#15
0
文件: sfav1.py 项目: HalasNet/felix
        else:
            rspec = RSpec(in_rspec)
        if rspec.version.type.lower() == 'protogeni':
            from foam.sfa.rspecs.rspec_converter import RSpecConverter
            in_rspec = RSpecConverter.to_sfa_rspec(rspec.toxml())
            rspec = RSpec(in_rspec)

        # just copy over all networks
        current_networks = self.get_networks()
        networks = rspec.version.get_networks()
        for network in networks:
            current_network = network.get('name')
            if current_network and current_network not in current_networks:
                self.xml.append(network.element)
                current_networks.append(current_network)

    # Leases

    def get_leases(self, filter=None):
        return SFAv1Lease.get_leases(self.xml, filter)

    def add_leases(self, leases, network = None, no_dupes=False):
        SFAv1Lease.add_leases(self.xml, leases)

if __name__ == '__main__':
    from foam.sfa.rspecs.rspec import RSpec
    from foam.sfa.rspecs.rspec_elements import *
    r = RSpec('/tmp/resources.rspec')
    r.load_rspec_elements(SFAv1.elements)
    print r.get(RSpecElements.NODE)
示例#16
0

class PGv2Ad(PGv2):
    enabled = True
    content_type = 'ad'
    schema = 'http://www.protogeni.net/resources/rspec/2/ad.xsd'
    template = '<rspec type="advertisement" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/ad.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


class PGv2Request(PGv2):
    enabled = True
    content_type = 'request'
    schema = 'http://www.protogeni.net/resources/rspec/2/request.xsd'
    template = '<rspec type="request" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/request.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


class PGv2Manifest(PGv2):
    enabled = True
    content_type = 'manifest'
    schema = 'http://www.protogeni.net/resources/rspec/2/manifest.xsd'
    template = '<rspec type="manifest" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/manifest.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


if __name__ == '__main__':
    from foam.sfa.rspecs.rspec import RSpec
    from foam.sfa.rspecs.rspec_elements import *
    r = RSpec('/tmp/pg.rspec')
    r.load_rspec_elements(PGv2.elements)
    r.namespaces = PGv2.namespaces
    print r.get(RSpecElements.NODE)
示例#17
0
class OcfVtAd(OcfVt):
    enabled = True
    content_type = 'ad'
    schema = '/opt/ofelia/vt_manager/src/python/foam/sfa/tests/vm_schema.xsd'  #'http://www.protogeni.net/resources/rspec/2/ad.xsd'
    template = '<rspec type="advertisement" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/ad.xsd /opt/ofelia/vt_manager/src/python/foam/sfa/tests/vm_schema.xsd"/>'


class OcfVtRequest(OcfVt):
    enabled = True
    content_type = 'request'
    schema = '/opt/ofelia/vt_manager/src/python/foam/sfa/tests/vm_schema.xsd'  #'http://www.protogeni.net/resources/rspec/2/ad.xsd'
    template = '<rspec type="advertisement" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/ad.xsd /opt/ofelia/vt_manager/src/python/foam/sfa/tests/vm_schema.xsd"/>'

    #schema = 'http://www.protogeni.net/resources/rspec/2/request.xsd'
    #template = '<rspec type="request" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/request.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


class OcfVtManifest(OcfVt):
    enabled = True
    content_type = 'manifest'
    schema = 'http://www.protogeni.net/resources/rspec/2/manifest.xsd'
    template = '<rspec type="manifest" xmlns="http://www.protogeni.net/resources/rspec/2" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.protogeni.net/resources/rspec/2 http://www.protogeni.net/resources/rspec/2/manifest.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd"/>'


if __name__ == '__main__':
    from foam.sfa.rspecs.rspec import RSpec
    from foam.sfa.rspecs.rspec_elements import *
    r = RSpec('/tmp/ocf.rspec')
    r.load_rspec_elements(OcfVt.elements)
    print r.get(RSpecElements.NODE)