xsnippet logotype

xsnippet

#363709, Untitled [ Python ]

by Guest
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
class RequiredPlatform(validation.Validator):
     def __init__(self, platform, platfrom_requirements):
           self.platfrom = platform
           self.requirements = platform_requirements

     def validate(self, env, task_config....):
          for p in env["platforms"]:
               if p.suites(self.platform, self.requirements, task_config):
                   return
          self.fail("Env doesn't contain platform which suits %s with %s." % (self.platfrom, self.requirements))


  class OpenStackPlatform(Platfrom):
       def suites(self, platform, requriements, task_config):
             if platfrom != "openstack":
                  return False
             if set(requirements) - {"admin", "users"}:
                  LOG.debug("Detected unsuported requirements")
                  return False                    
             if requirements.get("admin", False) and not self.admin:
                  LOG.info("Platfrom 'openstack' deosn't have admin creds")
                  return False