def create_org(self, org_name, full_org_name, is_enabled=False, settings=None): """Create new organization. :param str org_name: name of the organization. :param str full_org_name: full name of the organization. :param bool is_enabled: enable organization if True :return: an object containing EntityType.ADMIN_ORG XML data which represents the newly created organization. :rtype: lxml.objectify.ObjectifiedElement """ if self.admin_resource is None: self.admin_resource = self.client.get_resource(self.admin_href) org_params = E.AdminOrg(E.FullName(full_org_name), E.IsEnabled(is_enabled), name=org_name) # Append setting if provided if settings is None: org_params.append(E.Settings()) else: org_params.append(settings.get_settings()) return self.client.post_linked_resource(self.admin_resource, RelationType.ADD, EntityType.ADMIN_ORG.value, org_params)
def create_org(self, org_name, full_org_name): """ Create new organization :param org_name: The name of the organization :param full_org_name: The fullname of the organization :return: (AdminOrgType) Created org object """ # NOQA if self.admin_resource is None: self.admin_resource = self.client.get_resource(self.admin_href) org_params = E.AdminOrg(E.FullName(full_org_name), E.Settings, name=org_name) return self.client.post_linked_resource(self.admin_resource, RelationType.ADD, EntityType.ADMIN_ORG.value, org_params)
def create_org(self, org_name, full_org_name, is_enabled=False): """Create new organization. :param org_name: (str): The name of the organization. :param full_org_name: (str): The fullname of the organization. :param is_enabled: (bool): Enable organization if True :return: (AdminOrgType) Created org object. """ if self.admin_resource is None: self.admin_resource = self.client.get_resource(self.admin_href) org_params = E.AdminOrg( E.FullName(full_org_name), E.IsEnabled(is_enabled), E.Settings, name=org_name) return self.client.post_linked_resource( self.admin_resource, RelationType.ADD, EntityType.ADMIN_ORG.value, org_params)
def create_user(self, user_name, password, role_href, full_name='', description='', email='', telephone='', im='', alert_email='', alert_email_prefix='', stored_vm_quota=0, deployed_vm_quota=0, is_group_role=False, is_default_cached=False, is_external=False, is_alert_enabled=False, is_enabled=False): """Create User in the current Org. :param user_name: The username of the user :param password: The password of the user :param role_href: The href of the user role :param full_name: The full name of the user :param description: The description for the User :param email: The email of the user :param telephone: The telephone of the user :param im: The im address of the user :param alert_email: The alert email address :param alert_email_prefix: The string to prepend to the alert message subject line :param stored_vm_quota: The quota of vApps that this user can store :param deployed_vm_quota: The quota of vApps that this user can deploy concurrently :param is_group_role: Indicates if the user has a group role :param is_default_cached: Indicates if user should be cached :param is_external: Indicates if user is imported from an external source :param is_alert_enabled: The alert email address :param is_enabled: Enable user :return: (UserType) Created user object """ resource_admin = self.client.get_resource(self.href_admin) user = E.User(E.Description(description), E.FullName(full_name), E.EmailAddress(email), E.Telephone(telephone), E.IsEnabled(is_enabled), E.IM(im), E.IsAlertEnabled(is_alert_enabled), E.AlertEmailPrefix(alert_email_prefix), E.AlertEmail(alert_email), E.IsExternal(is_external), E.IsDefaultCached(is_default_cached), E.IsGroupRole(is_group_role), E.StoredVmQuota(stored_vm_quota), E.DeployedVmQuota(deployed_vm_quota), E.Role(href=role_href), E.Password(password), name=user_name) return self.client.post_linked_resource(resource_admin, RelationType.ADD, EntityType.USER.value, user)