Exemplo n.º 1
0
def main():
    args = parser.parse_args()
    app = create_app()
    with app.app_context():
        # Organization and user
        try:
            organization = Organization(
                id=organization_id,
                name=args.organization,
                namespace=args.namespace,
                created_at=datetime.utcnow()
            )
            organization.save()
            print('Organization {} successfully created!'.format(organization.name))
        except Exception:
            raise Exception('Adding {} organization failed'.format(args.organization))
        try:
            user = User.create(
                None,
                id=user_id,
                username=args.username,
                password=args.password,
                email='*****@*****.**',
                organization=organization,
                created_at=datetime.utcnow(),
                role='superadmin',
                active=True
            )
            user.save()
            print('User {} successfully created!'.format(user.username))
        except Exception:
            raise Exception('Adding {} user failed'.format(args.username))
Exemplo n.º 2
0
    def __init__(self, name=None):
        """Prepare organization object."""
        if not name:
            name = ''.join(
                random.choice(string.ascii_letters) for _ in range(8))
        organization = Organization(None, name=name, namespace=name)
        organization.save(validate=False)

        self.obj = organization
Exemplo n.º 3
0
def organization():
    """Prepare organization object."""
    organization = Organization(
        name='DemoOrg',
        namespace='demoorg',
    )
    organization.save()

    return organization
Exemplo n.º 4
0
 def __init__(self):
     """Prepare organization object."""
     organization = Organization(
         None,
         name='DemoOrg',
         namespace='demoorg',
     )
     organization.save()
     self.obj = organization
Exemplo n.º 5
0
    def get_data(self):
        # users
        cls = User
        namespace = None

        sum = defaultdict(lambda: defaultdict(lambda: 0))

        for obj_id, obj in cls.list(namespace, True).items():
            user_dict = obj.get_dict(True)

            user_namespace = user_dict['organization']['namespace']
            user_role = user_dict['role']
            user_active = user_dict['active']

            sum['namespace'][user_namespace] += 1
            sum['roles'][user_role] += 1
            sum['active'][user_active] += 1

        self.data['users'] = sum

        # organizations
        objs = Organization.list(None, False)
        self.data['organizations'] = len(objs)
Exemplo n.º 6
0
uuid_jenkins = 'c88b05d6-a107-4636-a3cc-eb5c90562f8f'
uuid_local = '2d51891a-adac-4bbc-a725-eed20cc67849'

uuid_provisioner_jenkins = 'e8de24b0-43d1-4a3c-af55-7b1d3f700554'
uuid_provisioner_local = '203c50d6-3d09-4789-8b8b-1ecb00814436'
uuid_provisioner_kubespray = '689de9a2-50e0-4fcd-b6a6-96930b5fadc9'

kubeconfig_url = 'https://ci.mcp.mirantis.net/job/deploy-aws-k8s_ha_calico_sm/33/artifact/kubeconfig'

app = create_app()
with app.app_context():
    # Organization and user
    try:
        organization = Organization(
            id=uuid_organization,
            name='DemoOrg',
            namespace='demoorg'
        )
        organization.save()
    except:
        raise Exception('Adding DemoOrg organization failed')

    try:
        user = User(
            username='******',
            password='******',
            organization=organization,
        )
        user.save()
    except:
        raise Exception('Adding admin user failed')
Exemplo n.º 7
0
 def get_namespaces(self, *args, **kwargs):
     try:
         organizations = Organization.list(None).values()
     except Exception:
         organizations = []
     return [o.namespace for o in organizations]
Exemplo n.º 8
0
uuid_provisioner_jenkins = 'e8de24b0-43d1-4a3c-af55-7b1d3f700554'
uuid_provisioner_local = '203c50d6-3d09-4789-8b8b-1ecb00814436'
uuid_provisioner_kubespray = '689de9a2-50e0-4fcd-b6a6-96930b5fadc9'
uuid_provisioner_gke = '516e3a8c-6c4d-49f1-8178-c6f802836618'
uuid_provisioner_aks = 'b72df8cc-d06e-11e7-97cc-68f72873a109'

kubeconfig_url = 'https://ci.mcp.mirantis.net/job/deploy-aws-k8s_ha_calico_sm/17/artifact/kubeconfig'
kubeconfig_file = 'kubeconfig_remote'

app = create_app()
with app.app_context():
    # Organization and user
    try:
        organization = Organization(id=uuid_organization,
                                    name='DemoOrg',
                                    namespace='demoorg',
                                    created_at=datetime.utcnow())
        organization.save()
    except:
        raise Exception('Adding DemoOrg organization failed')

    try:
        user = User(None,
                    username='******',
                    password='******',
                    organization=organization,
                    created_at=datetime.utcnow(),
                    active=True)
        user.save()
    except:
        raise Exception('Adding admin user failed')