def _config_adjust_paste(self, contents, fn): params = keystone.get_shared_params(self.cfg, self.pw_gen, 'nova') with io.BytesIO(contents) as stream: config = cfg.IgnoreMissingConfigParser() config.readfp(stream) config.set('filter:authtoken', 'auth_host', params['KEYSTONE_AUTH_HOST']) config.set('filter:authtoken', 'auth_port', params['KEYSTONE_AUTH_PORT']) config.set('filter:authtoken', 'auth_protocol', params['KEYSTONE_AUTH_PROTOCOL']) config.set('filter:authtoken', 'auth_uri', params['SERVICE_ENDPOINT']) config.set('filter:authtoken', 'admin_tenant_name', params['SERVICE_TENANT_NAME']) config.set('filter:authtoken', 'admin_user', params['SERVICE_USERNAME']) config.set('filter:authtoken', 'admin_password', params['SERVICE_PASSWORD']) config.set('filter:authtoken', 'service_host', params['KEYSTONE_SERVICE_HOST']) config.set('filter:authtoken', 'service_port', params['KEYSTONE_SERVICE_PORT']) config.set('filter:authtoken', 'service_protocol', params['KEYSTONE_SERVICE_PROTOCOL']) contents = config.stringify(fn) return contents
def _get_os_envs(self): key_params = keystone.get_shared_params(self.cfg, self.pw_gen) to_set = dict() to_set['OS_PASSWORD'] = key_params['ADMIN_PASSWORD'] to_set['OS_TENANT_NAME'] = key_params['DEMO_TENANT_NAME'] to_set['OS_USERNAME'] = key_params['DEMO_USER_NAME'] # This seems named weirdly the OS_AUTH_URL is the keystone SERVICE_ENDPOINT endpoint # Todo: describe more why this is the case... to_set['OS_AUTH_URL'] = key_params['SERVICE_ENDPOINT'] return to_set
def _get_param_map(self, config_fn): # This dict will be used to fill in the configuration # params with actual values mp = dict() mp['DEST'] = self.app_dir mp['SYSLOG'] = self.cfg.getboolean("default", "syslog") mp['SQL_CONN'] = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME) mp['SERVICE_HOST'] = self.cfg.get('host', 'ip') mp['HOST_IP'] = self.cfg.get('host', 'ip') mp.update(keystone.get_shared_params(self.cfg, self.pw_gen, 'glance')) return mp
def _get_param_map(self, config_fn): #this dict will be used to fill in the configuration #params with actual values mp = dict() mp['DEST'] = self.appdir mp['SYSLOG'] = self.cfg.getboolean("default", "syslog") mp['SQL_CONN'] = self.cfg.get_dbdsn(DB_NAME) mp['SERVICE_HOST'] = self.cfg.get('host', 'ip') mp['HOST_IP'] = self.cfg.get('host', 'ip') mp.update(keystone.get_shared_params(self.cfg, 'glance')) return mp
def _get_param_map(self, config_fn): # This dict will be used to fill in the configuration # params with actual values mp = comp.PythonInstallComponent._get_param_map(self, config_fn) mp['IMG_DIR'] = self._get_image_dir() mp['SYSLOG'] = self.cfg.getboolean("default", "syslog") mp['SQL_CONN'] = db.fetch_dbdsn(self.cfg, self.pw_gen, DB_NAME, utf8=True) mp['SERVICE_HOST'] = self.cfg.get('host', 'ip') mp['HOST_IP'] = self.cfg.get('host', 'ip') mp.update(keystone.get_shared_params(self.cfg, self.pw_gen, 'glance')) return mp
def _get_token(self): LOG.info("Fetching your keystone admin token so that we can perform image uploads/detail calls.") key_params = keystone.get_shared_params(self.cfg, self.pw_gen) keystone_service_url = key_params["SERVICE_ENDPOINT"] keystone_token_url = "%s/tokens" % (keystone_service_url) # form the post json data data = json.dumps( { "auth": { "passwordCredentials": { "username": key_params["ADMIN_USER_NAME"], "password": key_params["ADMIN_PASSWORD"], }, "tenantName": key_params["ADMIN_TENANT_NAME"], } } ) # Prepare the request request = urllib2.Request(keystone_token_url) # Post body request.add_data(data) # Content type request.add_header("Content-Type", "application/json") # Make the request LOG.info("Getting your token from url [%s], please wait..." % (keystone_token_url)) LOG.debug("With post json data %s" % (data)) response = urllib2.urlopen(request) token = json.loads(response.read()) # TODO is there a better way to validate??? if ( not token or not type(token) is dict or not token.get("access") or not type(token.get("access")) is dict or not token.get("access").get("token") or not type(token.get("access").get("token")) is dict or not token.get("access").get("token").get("id") ): msg = "Response from url [%s] did not match expected json format." % (keystone_token_url) raise IOError(msg) # Basic checks passed, extract it! tok = token["access"]["token"]["id"] LOG.debug("Got token %s" % (tok)) return tok
def _generate_os_env(self): lines = list() lines.append('# Openstack stuff') lines.extend(self._make_export_cfg('OS_PASSWORD', ('passwords', 'horizon_keystone_admin'))) key_users = keystone.get_shared_users(self.cfg) key_ends = keystone.get_shared_params(self.cfg) lines.extend(self._make_export('OS_TENANT_NAME', key_users['DEMO_TENANT_NAME'])) lines.extend(self._make_export('OS_USERNAME', key_users['DEMO_USER_NAME'])) lines.extend(self._make_export('OS_AUTH_URL', key_ends['SERVICE_ENDPOINT'])) lines.append("") return lines
def _get_param_map(self, config_fn): mp = dict() if config_fn == NET_INIT_CONF: mp['NOVA_DIR'] = self.app_dir mp['CFG_FILE'] = sh.joinpths(self.cfg_dir, API_CONF) mp['FLOATING_RANGE'] = self.cfg.getdefaulted('nova', 'floating_range', '172.24.4.224/28') mp['TEST_FLOATING_RANGE'] = self.cfg.getdefaulted('nova', 'test_floating_range', '192.168.253.0/29') mp['TEST_FLOATING_POOL'] = self.cfg.getdefaulted('nova', 'test_floating_pool', 'test') mp['FIXED_NETWORK_SIZE'] = self.cfg.getdefaulted('nova', 'fixed_network_size', '256') mp['FIXED_RANGE'] = self.cfg.getdefaulted('nova', 'fixed_range', '10.0.0.0/24') else: mp.update(keystone.get_shared_params(self.cfg, self.pw_gen, 'nova')) return mp
def _get_token(self): LOG.info( "Fetching your keystone admin token so that we can perform image uploads/detail calls." ) key_params = keystone.get_shared_params(self.cfg, self.pw_gen) keystone_service_url = key_params['SERVICE_ENDPOINT'] keystone_token_url = "%s/tokens" % (keystone_service_url) # form the post json data data = json.dumps({ "auth": { "passwordCredentials": { "username": key_params['ADMIN_USER_NAME'], "password": key_params['ADMIN_PASSWORD'], }, "tenantName": key_params['ADMIN_TENANT_NAME'], } }) # Prepare the request request = urllib2.Request(keystone_token_url) # Post body request.add_data(data) # Content type request.add_header('Content-Type', 'application/json') # Make the request LOG.info("Getting your token from url [%s], please wait..." % (keystone_token_url)) LOG.debug("With post json data %s" % (data)) response = urllib2.urlopen(request) token = json.loads(response.read()) # TODO is there a better way to validate??? if (not token or not type(token) is dict or not token.get('access') or not type(token.get('access')) is dict or not token.get('access').get('token') or not type(token.get('access').get('token')) is dict or not token.get('access').get('token').get('id')): msg = "Response from url [%s] did not match expected json format." % ( keystone_token_url) raise IOError(msg) # Basic checks passed, extract it! tok = token['access']['token']['id'] LOG.debug("Got token %s" % (tok)) return tok
def _get_token(self): LOG.info("Fetching your keystone admin token so that we can perform image uploads.") pwd = self.cfg.get("passwords", "horizon_keystone_admin") key_users = keystone.get_shared_users(self.cfg) key_params = keystone.get_shared_params(self.cfg) keystone_service_url = key_params['SERVICE_ENDPOINT'] keystone_token_url = "%s/tokens" % (keystone_service_url) #form the post json data data = json.dumps( { "auth": { "passwordCredentials": { "username": key_users['ADMIN_USER_NAME'], "password": pwd, }, "tenantName": key_users['ADMIN_TENANT_NAME'], } }) # prepare the request request = urllib2.Request(keystone_token_url) # post body request.add_data(data) # content type request.add_header('Content-Type', 'application/json') # make the request LOG.info("Getting your token from url [%s], please wait..." % (keystone_token_url)) LOG.debug("With post json data %s" % (data)) response = urllib2.urlopen(request) token = json.loads(response.read()) if (not token or not type(token) is dict or not token.get('access') or not type(token.get('access')) is dict or not token.get('access').get('token') or not type(token.get('access').get('token')) is dict or not token.get('access').get('token').get('id')): msg = "Response from url [%s] did not match expected json format." % (keystone_token_url) raise IOError(msg) #basic checks passed, extract it! tok = token['access']['token']['id'] LOG.debug("Got token %s" % (tok)) return tok
def _get_param_map(self, config_fn): mp = dict() if config_fn == NET_INIT_CONF: mp['NOVA_DIR'] = self.appdir mp['CFG_FILE'] = sh.joinpths(self.cfgdir, API_CONF) mp['FLOATING_RANGE'] = self.cfg.get('nova', 'floating_range') mp['TEST_FLOATING_RANGE'] = self.cfg.get('nova', 'test_floating_range') mp['TEST_FLOATING_POOL'] = self.cfg.get('nova', 'test_floating_pool') mp['FIXED_NETWORK_SIZE'] = self.cfg.get('nova', 'fixed_network_size') mp['FIXED_RANGE'] = self.cfg.get('nova', 'fixed_range') else: mp = keystone.get_shared_params(self.cfg) mp['SERVICE_PASSWORD'] = "******" mp['SERVICE_USER'] = "******" return mp
def _get_token(self): LOG.info("Fetching your keystone admin token so that we can perform image uploads/detail calls.") key_params = keystone.get_shared_params(self.cfg, self.pw_gen) keystone_service_url = key_params['SERVICE_ENDPOINT'] keystone_token_url = "%s/tokens" % (keystone_service_url) # form the post json data data = json.dumps( { "auth": { "passwordCredentials": { "username": key_params['ADMIN_USER_NAME'], "password": key_params['ADMIN_PASSWORD'], }, "tenantName": key_params['ADMIN_TENANT_NAME'], } }) # Prepare the request headers = { 'Content-Type': 'application/json' } request = urllib2.Request(keystone_token_url, data=data, headers=headers) # Make the request LOG.info("Getting your token from url %r, please wait..." % (keystone_token_url)) LOG.debug("With post data %s" % (data)) LOG.debug("With headers %s" % (headers)) response = urllib2.urlopen(request) token = json.loads(response.read()) # TODO is there a better way to validate??? if (not token or not type(token) is dict or not token.get('access') or not type(token.get('access')) is dict or not token.get('access').get('token') or not type(token.get('access').get('token')) is dict or not token.get('access').get('token').get('id')): msg = "Response from url %r did not match expected json format." % (keystone_token_url) raise IOError(msg) # Basic checks passed, extract it! tok = token['access']['token']['id'] LOG.debug("Got token %r" % (tok)) return tok
def _generate_nova_env(self): lines = list() lines.append('# Nova stuff') lines.extend(self._make_export_cfg('NOVA_PASSWORD', ('passwords', 'horizon_keystone_admin'))) key_users = keystone.get_shared_users(self.cfg) key_ends = keystone.get_shared_params(self.cfg) lines.extend(self._make_export('NOVA_URL', key_ends['SERVICE_ENDPOINT'])) lines.extend(self._make_export('NOVA_PROJECT_ID', key_users['DEMO_TENANT_NAME'])) lines.extend(self._make_export('NOVA_USERNAME', key_users['DEMO_USER_NAME'])) lines.extend(self._make_export_cfg('NOVA_VERSION', ('nova', 'nova_version'))) lines.extend(self._make_export_cfg('NOVA_CERT', ('extern', 'nova_cert_fn'))) lines.append("") return lines
def _get_param_map(self, config_fn): mp = dict() if config_fn == NET_INIT_CONF: mp['NOVA_DIR'] = self.app_dir mp['CFG_FILE'] = sh.joinpths(self.cfg_dir, API_CONF) mp['FLOATING_RANGE'] = self.cfg.getdefaulted( 'nova', 'floating_range', '172.24.4.224/28') mp['TEST_FLOATING_RANGE'] = self.cfg.getdefaulted( 'nova', 'test_floating_range', '192.168.253.0/29') mp['TEST_FLOATING_POOL'] = self.cfg.getdefaulted( 'nova', 'test_floating_pool', 'test') mp['FIXED_NETWORK_SIZE'] = self.cfg.getdefaulted( 'nova', 'fixed_network_size', '256') mp['FIXED_RANGE'] = self.cfg.getdefaulted('nova', 'fixed_range', '10.0.0.0/24') else: mp.update(keystone.get_shared_params(self.cfg, self.pw_gen, 'nova')) return mp
def _get_param_map(self, config_fn): return keystone.get_shared_params(self.cfg)