# For those usages not covered by the Apache version 2.0 License please # contact with [email protected] # import logging import warnings import requests from requests.packages.urllib3.exceptions import InsecureRequestWarning from requests.packages.urllib3.exceptions import InsecurePlatformWarning from fiwareskuld.utils import queries from fiwareskuld.utils import log from conf.settings import TRIAL_ROLE_ID, BASIC_ROLE_ID, HORIZON_ENDPOINT __author__ = 'chema' logger = log.init_logs('phase0c') trial = TRIAL_ROLE_ID basic = BASIC_ROLE_ID q = queries.Queries() keystone = q.osclients.get_keystoneclientv3() warnings.simplefilter('ignore', category=InsecureRequestWarning) warnings.simplefilter('ignore', category=InsecurePlatformWarning) def change_user_keystone(user_id): """Change the user from trial to basic We use this on our testing environment :param user_id: :return: nothing """
"""add a hidden element; the 'in' operator finds it but it is an invisible element for the other methods of the set""" self.hidden_set.add(hidden) def __contains__(self, element): """extend the 'in' operator to support hidden elements""" return super(hidden_set, self).__contains__(element) or\ element in self.hidden_set def to_list(self): """override this methods to return the list used in iterators and other methods""" return self.baselist if __name__ == '__main__': logger = log.init_logs('classify_resources_by_owner') # Parse cmdline description = 'A tool to classify users and the resources on any region' parser = argparse.ArgumentParser(description=description) res_types = hidden_set(OpenStackMap.resources_region) res_types.add_hidden('none') res_types.add_hidden('all') h = 'resources to analyse. If may be all or any of this list: %(choices)s' parser.add_argument('resources', metavar='resource', type=str, nargs='*', choices=res_types, default='none', help=h) parser.add_argument('--regions', nargs='+', help='regions to analyse') parser.add_argument('--omit-user-summary', action='store_true',
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. # # For those usages not covered by the Apache version 2.0 License please # contact with [email protected] # import cPickle as pickle from fiwareskuld.queries import Queries from fiwareskuld.utils import log __author__ = 'chema' """This scripts generate a file with a set of images ids that are in use by at least another tenant different than the owner of the image Invoke this script before deleting the users if you don't want to remove the images of the tenant in use by other tenants. """ q = Queries() logger = log.init_logs('phase2b') image_set = q.get_imageset_othertenants() print(image_set) with open('imagesinuse.pickle', 'wb') as f: pickle.dump(image_set, f, protocol=-1)
try: count += 1 (username, trust_id) = trust_factory.create_trust_admin(user, trustee) users_trusted_ids.write(username + ',' + trust_id + '\n') msg = 'Generated trustid for user {0} ({1}/{2})' logger.info(msg.format(user, count, total)) except Exception, e: msg = 'Failed getting trust-id from trustor {0}. Reason: {1}' logger.error(msg.format(user, str(e))) users_trusted_ids.close() if __name__ == '__main__': logger = log.init_logs('phase1') if len(sys.argv) == 2: name = sys.argv[1] else: name = 'users_to_delete.txt' try: users_to_delete = open(name) except Exception: m = 'Failed reading the file ' + name logger.error(m) generate_trust_ids(users_to_delete) else: logger = logging.getLogger(__name__)
# For those usages not covered by the Apache version 2.0 License please # contact with [email protected] # from os import environ as env import os.path import cPickle as pickle import datetime from fiwareskuld.user_resources import UserResources from fiwareskuld.utils import log import conf.settings __author__ = 'chema' logger = log.init_logs('phase3') images_in_use = None free_trust_id = False users_list = list() report = dict() if os.path.exists('imagesinuse.pickle'): images_in_use = pickle.load(open('imagesinuse.pickle')) # clean credential if 'OS_USERNAME' in env: del env['OS_USERNAME'] if 'OS_TENANT_NAME' in env: del env['OS_TENANT_NAME'] if 'OS_TENANT_ID' in env:
an invisible element for the other methods of the set""" self.hidden_set.add(hidden) def __contains__(self, element): """extend the 'in' operator to support hidden elements""" return super(hidden_set, self).__contains__(element) or\ element in self.hidden_set def to_list(self): """override this methods to return the list used in iterators and other methods""" return self.baselist if __name__ == '__main__': logger = log.init_logs('classify_resources_by_owner') # Parse cmdline description = 'A tool to classify users and the resources on any region' parser = argparse.ArgumentParser(description=description) res_types = hidden_set(OpenStackMap.resources_region) res_types.add_hidden('none') res_types.add_hidden('all') h = 'resources to analyse. If may be all or any of this list: %(choices)s' parser.add_argument('resources', metavar='resource', type=str, nargs='*', choices=res_types, default='none',
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. # # For those usages not covered by the Apache version 2.0 License please # contact with [email protected] # from fiwareskuld.utils import log from fiwareskuld.change_password import PasswordChanger __author__ = 'chema' logger = log.init_logs('phase1') try: users_to_delete = open('users_to_delete.txt') users_credentials = open('users_credentials.txt', 'w') user_manager = PasswordChanger() user_ids = list() for user in users_to_delete.readlines(): user_ids.append(user.strip()) cred_list = user_manager.get_list_users_with_cred(user_ids) for cred in cred_list: users_credentials.write(','.join(cred) + '\n')
# # For those usages not covered by the Apache version 2.0 License please # contact with [email protected] # from os import environ as env import os import cPickle as pickle import datetime from fiwareskuld.user_resources import UserResources import conf.settings from fiwareskuld.utils import log __author__ = 'chema' logger = log.init_logs('phase2') free_trust_id = False stopped_vms = 0 unshared_images = 0 dict_vms = dict() failed_users = set() # Ensure we are not using other credentials if 'OS_USERNAME' in env: del env['OS_USERNAME'] if 'OS_TENANT_NAME' in env: del env['OS_TENANT_NAME'] if 'OS_TENANT_ID' in env: del env['OS_TENANT_ID'] if 'OS_TRUST_ID' in env: