def configure(self): """ Description: Creates a series of prompts asking for values, and specifies which are optional and which are not. Only use in places where user has the ability to get data to STDIN. """ classname = str(self.__class__).split("'")[1].split('.')[-1] #Display prompts the user for required properties for prop in self.required_properties: if prop in self._constraints[classname]: self.__dict__[prop] = ish_prompt( "Value for %s" % prop, required=True, constraints=self._constraints[classname][prop]) else: self.__dict__[classname][prop] = ish_prompt("Value for %s" % prop, required=True) #Display prompts the user for optional properties for prop in self.optional_properties: if prop in self._constraints[classname]: self.__dict__[prop] = ish_prompt( "Value for optional property %s" % prop, required=False, constraints=self._constraints[classname][prop]) else: self.__dict__[prop] = ish_prompt( "Value for optional property %s" % prop, required=False)
def configure(self): """ Description: Creates a series of prompts asking for values, and specifies which are optional and which are not. Only use in places where user has the ability to get data to STDIN. """ classname = str(self.__class__).split("'")[1].split('.')[-1] #Display prompts the user for required properties for prop in self.required_properties: if prop in self._constraints[classname]: self.__dict__[prop] = ish_prompt("Value for %s" % prop, required=True, constraints=self._constraints[classname][prop]) else: self.__dict__[classname][prop] = ish_prompt("Value for %s" % prop, required=True) #Display prompts the user for optional properties for prop in self.optional_properties: if prop in self._constraints[classname]: self.__dict__[prop] = ish_prompt("Value for optional property %s" % prop, required=False, constraints=self._constraints[classname][prop]) else: self.__dict__[prop] = ish_prompt("Value for optional property %s" % prop, required=False)
def use_unused_address(self, ipr=None): """ Description: Grab an unused address from an IPRange, specified by its name If no parameters are given, it puts up a prompt to ask for the IPRange to use If an IPRange object is given, it gets the address from that object If a string is given, it gets the IPRange with the name specified returns the address that was used, and assigns the free address to the "Address.address" attribute """ if not ipr: ipr = ish_prompt("Select an IP Range", constraints=[i.name for i in IPRange.all()]) if not isinstance(IPRange, ipr): iprange = IPRange.find(ipr) else: iprange = ipr self.address = iprange.get_unused_address() return self.address