def __init__(self): self.protos = [] self.ctree = None self.sspec = None self.pref = ProtoPreference() self.classifier = set([]) self.prefProtocol = None
class ProtocolFactory(object): def __init__(self): self.protos = [] self.ctree = None self.sspec = None self.pref = ProtoPreference() self.classifier = set([]) def clone(self): pFactory = ProtocolFactory() for i in self.protos: pFactory.protos.append(i.clone()) pFactory.pref = self.pref.clone() pFactory.ctree = self.ctree pFactory.sspec = self.sspec pFactory.classifier = self.classifier return pFactory def __iter__(self): return ProtocolFactoryIterator(self) def add(self, protocol): self.protos.append(protocol) self.pref.add(protocol.enumid) def copy(self, source): self.pref.copy(source) for i in range(len(source.protocols)-1, -1, -1): self._set_preferred_proto(source.protocols[i]) def _set_preferred_proto(self, protoenum): moveit = [] for i in range(0, len(self.pref.protocols)): if (self.pref.protocols[i] == protoenum): moveit.append(i) tt1 = [] tt2 = [] tt3 = [] for i in range(len(moveit), 0, -1): tt1.insert(0, self.protos[moveit[i-1]]) tt2.insert(0, self.pref.protocols[moveit[i-1]]) tt3.insert(0, self.pref.include_flag[moveit[i-1]]) del self.protos[moveit[i-1]] del self.pref.protocols[moveit[i-1]] del self.pref.include_flag[moveit[i-1]] self.protos[0:0] = tt1 self.pref.protocols[0:0] = tt2 self.pref.include_flag[0:0] = tt3 def get(self, i): if i < len(self.protos): return self.protos[i] return None def count(self): return len(self.protos) def addCTree(self, ctree): self.ctree = ctree def addSubsystemSpec(self, sspec): self.sspec = sspec def addClassifier(self, classifier): self.classifier = set(classifier) def printx(self): for i in self.protos: logger.debug(i) self.pref.printx()
ipaddr = get_args(argsinfo, 'ipaddr') driver = get_optional(argsinfo, 'driver') uname = get_optional(argsinfo, 'user.name') upass = get_optional(argsinfo, 'user.password', '') pref = get_optional(argsinfo, 'protocol', 'WSMAN') nshare = get_optional(argsinfo, 'share') nsharename = get_optional(argsinfo, 'share.user.name') nsharepass = get_optional(argsinfo, 'share.user.password', '') image = get_optional(argsinfo, 'image', '') creds = ProtocolCredentialsFactory() if uname : creds.add(UserCredentials(uname, upass)) protopref = None if pref == "WSMAN": protopref = ProtoPreference(ProtocolEnum.WSMAN) @property def not_implemented(): print("===== not implemented ====") if platform.system() == "Windows": myshare = FileOnShare(remote =nshare, mount_point='Z:\\', isFolder=True, creds = UserCredentials(nsharename, nsharepass)) updshare = myshare else: myshare = FileOnShare(remote =nshare, mount_point='/tst', isFolder=True, creds = UserCredentials(nsharename, nsharepass))