Changeset f37e9bf
- Timestamp:
- Nov 18, 2011 10:06:55 AM (13 years ago)
- Branches:
- compt_changes, info-ops, master
- Children:
- 2ac64d1a
- Parents:
- cb0aafb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/topdl.py
rcb0aafb rf37e9bf 113 113 return "<time>%f</time><kind>%s</kind>" % (self.time, self.kind) 114 114 115 class ServiceParam(base): 116 def __init__(self, name, type): 117 self.name = self.init_string(name) 118 self.type = self.init_string(type) 119 120 def clone(self): 121 return ServiceParam(self.name. self.type) 122 123 def to_dict(self): 124 return { 'name': name, 'type': type } 125 126 def to_xml(self): 127 return "<name>%s</name><type>%s</type>" % (self.name, self.type) 128 129 class Service(base): 130 def __init__(self, name, importer=[], param=[], description=None, 131 status=None): 132 self.name = self.init_string(name) 133 self.importer = [self.init_string(i) \ 134 for i in self.make_list(importer)] 135 self.param = [ self.init_class(ServiceParam, p) \ 136 for p in self.make_list(param) ] 137 self.description = self.init_string(description) 138 self.status = self.init_string(status) 139 140 def clone(self): 141 return Service( 142 name=self.name, 143 importer=[ i for i in self.importer], 144 param=[p.clone() for p in self.param], 145 description=self.description, 146 status=self.status) 147 148 def to_dict(self): 149 rv = { } 150 if self.name is not None: 151 rv['name'] = self.name 152 if self.importer: 153 rv['importer'] = [ i for i in self.importer ] 154 if self.param: 155 rv['param'] = [ p.to_dict() for p in self.param ] 156 if self.description is not None: 157 rv['description'] = self.description 158 if self.status is not None: 159 rv['status'] = self.status 160 return rv 161 162 def to_xml(self): 163 rv = '' 164 if self.name is not None: 165 rv += '<name>%s</name>' % self.name 166 if self.importer: 167 rv += join(['<importer>%s</importer>' % i \ 168 for i in self.importer],'') 169 if self.param: 170 rv += join('<param>%s</param>' % p.to_xml() \ 171 for p in self.param], '') 172 if self.description is not None: 173 rv += '<description>%s</description>' % self.description 174 if self.status is not None: 175 rv += '<status>%s</status>' % self.status 176 return rv 177 115 178 class Substrate(base): 116 def __init__(self, name, capacity=None, latency=None, attribute=[]): 179 def __init__(self, name, capacity=None, latency=None, attribute=[], 180 localname=[], status=None, service=[], operation=[]): 117 181 self.name = self.init_string(name) 118 182 self.capacity = self.init_class(Capacity, capacity) … … 120 184 self.attribute = [ self.init_class(Attribute, a) \ 121 185 for a in self.make_list(attribute) ] 186 self.localname = [ self.init_string(ln)\ 187 for ln in self.make_list(localname) ] 188 self.status = self.init_string(status) 189 self.service = [ self.init_class(Service, s) \ 190 for s in self.make_list(service)] 191 self.operation = [self.init_string(op) \ 192 for op in self.make_list(operation)] 122 193 self.interfaces = [ ] 123 194 … … 132 203 capacity=c, 133 204 latency=l, 134 attribute = [a.clone() for a in self.attribute]) 205 attribute = [a.clone() for a in self.attribute], 206 localname = [ ln for ln in self.localname], 207 status = self.status, 208 service = [ s.clone() for s in self.service] 209 operation=[ op for op in operation]) 135 210 136 211 def to_dict(self): … … 142 217 if self.attribute: 143 218 rv['attribute'] = [ a.to_dict() for a in self.attribute ] 219 if self.localname: 220 rv['localname'] = [ ln for ln in self.localname ] 221 if self.status: 222 rv['status'] = self.status 223 if self.service: 224 rv['service'] = [s.to_dict() for s in self.service] 225 if self.operation: 226 rv['operation'] = [op for op in self.operation] 144 227 return rv 145 228 … … 154 237 rv += join(["<attribute>%s</attribute>" % a.to_xml() \ 155 238 for a in self.attribute], "") 239 if self.localname: 240 rv += join('<localname>%s</localname>' % ln \ 241 for ln in self.localname], '') 242 if self.status is not None: 243 rv += '<status>%s</status>' % self.status 244 if self.service: 245 rv += join(['<service>%s</service' % s.to_xml() \ 246 for s in self.service], '') 247 if self.operation: 248 rv += join(['<operation>%s</operation>' % op \ 249 for op in self.operation], '') 156 250 return rv 157 251 … … 360 454 class Computer(base): 361 455 def __init__(self, name, cpu=[], os=[], software=[], storage=[], 362 interface=[], attribute=[]): 456 interface=[], attribute=[], localname=[], status=None, service=[], 457 operation=[]): 363 458 def assign_element(i): 364 459 i.element = self … … 376 471 self.attribute = [ self.init_class(Attribute, a) \ 377 472 for a in self.make_list(attribute) ] 473 self.localname = [ self.init_string(ln)\ 474 for ln in self.make_list(localname) ] 475 self.status = self.init_string(status) 476 self.service = [ self.init_class(Service, s) \ 477 for s in self.make_list(service)] 478 self.operation = [self.init_string(op) \ 479 for op in self.make_list(operation)] 378 480 map(assign_element, self.interface) 379 481 … … 386 488 storage=[x.clone() for x in self.storage], 387 489 interface=[x.clone() for x in self.interface], 388 attribute=[x.clone() for x in self.attribute]) 490 attribute=[x.clone() for x in self.attribute], 491 localname =[ ln for for ln in self.localname], 492 status = self.status, 493 service = [s.clone() for s in self.service], 494 operation = [op for op in self.operation]) 389 495 390 496 def to_dict(self): … … 404 510 if self.attribute: 405 511 rv['attribute'] = [ i.to_dict() for i in self.attribute ] 512 if self.localname: 513 rv['localname'] = [ ln for ln in self.localname ] 514 if self.status: 515 rv['status'] = self.status 516 if self.service: 517 rv['service'] = [s.to_dict() for s in self.service] 518 if self.operation: 519 rv['operation'] = [op for op in self.operation] 406 520 return { 'computer': rv } 407 521 … … 424 538 rv += join(["<attribute>%s</attribute>" % a.to_xml() \ 425 539 for a in self.attribute], "") 540 if self.localname: 541 rv += join('<localname>%s</localname>' % ln \ 542 for ln in self.localname], '') 543 if self.status is not None: 544 rv += '<status>%s</status>' % self.status 545 if self.service: 546 rv += join(['<service>%s</service' % s.to_xml() \ 547 for s in self.service], '') 548 if self.operation: 549 rv += join(['<operation>%s</operation>' % op \ 550 for op in self.operation], '') 426 551 return "<computer>%s</computer>" % rv 427 552 … … 429 554 430 555 class Testbed(base): 431 def __init__(self, uri, type, interface=[], attribute=[]): 556 def __init__(self, uri, type, interface=[], attribute=[], localname=[], 557 status=None, service=[], operation=[]): 432 558 self.uri = self.init_string(uri) 433 559 self.type = self.init_string(type) … … 436 562 self.attribute = [ self.init_class(Attribute, c) \ 437 563 for c in self.make_list(attribute) ] 564 self.localname = [ self.init_string(ln)\ 565 for ln in self.make_list(localname) ] 566 self.status = self.init_string(status) 567 self.service = [ self.init_class(Service, s) \ 568 for s in self.make_list(service)] 569 self.operation = [self.init_string(op) \ 570 for op in self.make_list(operation)] 438 571 439 572 def clone(self): 440 573 return Testbed(self.uri, self.type, 441 574 interface=[i.clone() for i in self.interface], 442 attribute=[a.cone() for a in self.attribute]) 575 attribute=[a.cone() for a in self.attribute], 576 localname = [ ln for ln in self.localname ], 577 status=self.status, 578 service=[s.clone() for s in self.service ], 579 operation = [ op for op in self.operation ]) 443 580 444 581 def to_dict(self): … … 450 587 if self.attribute: 451 588 rv['attribute'] = [ a.to_dict() for a in self.attribute] 589 if self.localname: 590 rv['localname'] = [ ln for ln in self.localname ] 591 if self.status: 592 rv['status'] = self.status 593 if self.service: 594 rv['service'] = [s.to_dict() for s in self.service] 595 if self.operation: 596 rv['operation'] = [op for op in self.operation] 452 597 return { 'testbed': rv } 453 598 … … 461 606 rv += join(["<attribute>%s</attribute>" % a.to_xml() \ 462 607 for a in self.attribute], "") 608 if self.localname: 609 rv += join('<localname>%s</localname>' % ln \ 610 for ln in self.localname], '') 611 if self.status is not None: 612 rv += '<status>%s</status>' % self.status 613 if self.service: 614 rv += join(['<service>%s</service' % s.to_xml() \ 615 for s in self.service], '') 616 if self.operation: 617 rv += join(['<operation>%s</operation>' % op \ 618 for op in self.operation], '') 463 619 return "<testbed>%s</testbed>" % rv 464 620 -
wsdl/topdl.xsd
rcb0aafb rf37e9bf 99 99 <xsd:element name="description" type="xsd:string" 100 100 minOccurs="0" maxOccurs="1"/> 101 <xsd:element name="status" type="fns:statusType"/> 101 <xsd:element name="status" type="fns:statusType" 102 minOccurs="0" maxOccurs="1"/> 102 103 </xsd:sequence> 103 104 </xsd:complexType>
Note: See TracChangeset
for help on using the changeset viewer.