Ejemplo n.º 1
0
    if 'TRUSTEE_USER' in env:
        trustee = env['TRUSTEE_USER']
    else:
        trustee = conf.settings.TRUSTEE

    lines = users_trusted_ids.readlines()
    user_count = 0
    user_total = len(lines)
    for line in lines:
        (user, trust_id, user_id) = line.strip().split(',')
        user_count += 1
        logger.info('Stopping active VMs of user {3} {0} ({1}/{2})'.format(
            user, user_count, user_total, user_id))

        try:
            user_resources = UserResources(
                trustee, password, trust_id=trust_id)
            vms = user_resources.get_resources_dict()['vms']
            dict_vms[user] = vms
            stopped = user_resources.stop_tenant_vms()
            stopped_vms += stopped
            logger.info('Stopped {0} (total {1})'.format(stopped, stopped_vms))
            logger.info('Unshare public images of user ' + user)
            user_resources.unshare_images()
            if 'DONT_FREE_TRUST_ID' not in env:
                user_resources.free_trust_id()
        except Exception, e:
            logger.error('Failed operations with user ' + user + ' cause: ' +
                         str(e))
            failed_users.add(user)

    print('Stopped servers: ' + str(stopped_vms))
Ejemplo n.º 2
0
    use_trust_ids = False
    lines = open('users_credentials.txt').readlines()
else:
    raise Exception("user_trusted_ids.txt or users_credentials.txt must exists")


count = 0
total = len(lines)
for line in lines:
    try:
        count += 1
        if use_trust_ids:
            (user, trust_id, user_id) = line.strip().split(',')
            logger.info('Obtaining resources of user {0} ({1}/{2})'.format(
                user, count, total))
            user_resources = UserResources(trustee, password,
                                           trust_id=trust_id)
        else:
            (user, password, tenant_id) = line.strip().split(',')
            logger.info('Obtaining resources of user ' + user)
            user_resources = UserResources(user, password, tenant_id)

        if images_in_use:
            user_resources.imagesinuse = images_in_use

        user_id = user_resources.user_id
        logger.info('user ' + user + ' has id ' + user_id)
        resources_before = user_resources.get_resources_dict()

        # check if user does not have any resources and
        all_free = True
        for key in resources_before:
Ejemplo n.º 3
0
# 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 os import environ as env

from fiwareskuld.user_resources import UserResources

__author__ = 'chema'

user = env['OS_USERNAME']
password = env['OS_PASSWORD']
user_resources = None
if 'OS_TRUST_ID' in env:
    trust_id = env['OS_TRUST_ID']
    user_resources = UserResources(user, password, trust_id=trust_id)
elif 'OS_TENANT_ID' in env:
    tenant_id = env['OS_TENANT_ID']
    user_resources = UserResources(user, password, tenant_id=tenant_id)
elif 'OS_TENANT_NAME' in env:
    tenant_name = env['OS_TENANT_NAME']
    user_resources = UserResources(user, password, tenant_name=tenant_name)

user_resources.print_tenant_resources()