def tearDown(self): super(TestGeppettoLib, self).tearDown() options = { 'client-poll-interval': self.interval, 'client-master-reference': self.server, } puppet = PuppetNode() puppet.set_service_settings(options) with open(PuppetNode.ASIGN_FILE, 'w') as f: f.write(self.asign) with open(GeppettoService.GEPPETTO_BACKEND_FILE, 'w') as f: f.write(self.backend)
def get_geppetto_web_service_client(): try: master_fqdn = PuppetNode.get_puppet_option('server') except: master_fqdn = 'localhost' return service_proxy.create_proxy(master_fqdn, 8080, service_proxy.Proxy.Geppetto, 'v1')
class DataUtils: #TODO- split this util into meaningful sections? instance = None def __init__(self): self.count = 0 self.network_config = NetworkConfiguration() self.puppet_node = PuppetNode() self.geppetto_node = None @classmethod def Inst(cls): if cls.instance is None: cls.instance = DataUtils() return cls.instance def get_all_network_data_for_summary(self): network_config = NetworkConfiguration() try: network_config.load_interface("eth1") network_config.load_network() network_config.load_dns() network_config.load_ntp() # TODO build separate ui object that # has place holder text for missing info? self.puppet_node.load() if self.puppet_node.is_master(): network_config.master_hostname = "%s.%s" % \ (network_config.hostname, network_config.dns_suffix) else: network_config.master_hostname = \ self.\ refresh_config_and_generate_puppetmaster_hostname_on_client() network_config.admin_url = "http://%s:8080/" % \ network_config.master_hostname network_config.is_master = self.is_master() except Exception, e: log.error(e) return network_config
def test_puppet_client_config(self): puppet = PuppetNode() puppet.load() random.seed() interval = int(random.uniform(10, 1000)) fqdn = '%s.mycloud.org' % _generate_word() options = { 'client-poll-interval': interval, 'client-master-reference': fqdn, } puppet.set_service_settings(options) logger.debug('Am I a master? %s' % puppet.is_master()) expected = int(PuppetNode.get_puppet_option('runinterval')) self.assertEqual(interval, expected) expected = PuppetNode.get_puppet_option('server') self.assertEqual(fqdn, expected)
def setUp(self): super(TestGeppettoLib, self).setUp() NetworkConfiguration.IFCFG_FILE = 'tests/fakes/ifcfg-%s.test' NetworkConfiguration.NETWK_FILE = 'tests/fakes/net.test' NetworkConfiguration.RESLV_FILE = 'tests/fakes/res.test' NetworkConfiguration.RESLV_IFACE_FILE = 'tests/fakes/res.%s.test' NetworkConfiguration.NTPCF_FILE = 'tests/fakes/ntp.test' NetworkConfiguration.HOSTS_FILE = 'tests/fakes/hosts.test' NetworkConfiguration.DHCLIENT_FILE = 'tests/fakes/dhclient.test' PuppetNode.PCONF_FILE = 'tests/fakes/puppet.test' PuppetNode.STATE_FILE = 'tests/fakes/state.test' PuppetNode.ASIGN_FILE = 'tests/fakes/asign.test' config_generator.TEMPLATES_PATH = 'core/templates' self.server = PuppetNode.get_puppet_option('server') self.interval = int(PuppetNode.get_puppet_option('runinterval')) with open(PuppetNode.ASIGN_FILE, 'r') as f: self.asign = f.read() GeppettoService.GEPPETTO_BACKEND_FILE = 'tests/fakes/backend.test' GeppettoService.GEPPETTO_SETUP_SCRIPT = ':' # noop with open(GeppettoService.GEPPETTO_BACKEND_FILE, 'r') as f: self.backend = f.read()
def test_puppet_server_config(self): puppet = PuppetNode() puppet.load() dns_suffix = '*.%s.org' % _generate_word() options = { 'server-auto-sign-policy': True, 'server-autosign-pattern': dns_suffix, } puppet.set_service_settings(options) logger.debug('Am I a master? %s' % puppet.is_master()) with open(PuppetNode.ASIGN_FILE, 'r') as f: expected = f.read() self.assertEqual(dns_suffix, expected)
def __init__(self): self.count = 0 self.network_config = NetworkConfiguration() self.puppet_node = PuppetNode() self.geppetto_node = None
def get_master_proxy(): master_fqdn = PuppetNode.get_puppet_option('server') master_url = MASTER_URL_PATTERN % master_fqdn return xmlrpclib.ServerProxy(master_url)