def _logoutFromTarget(self): logging.info("Logging out from target") strLogoutCommand = "cf" + " logout" status, output = self.executeShellCommand(strLogoutCommand) self.assertEqual(0, status) logging.info("Logged out from target") return status, output
def _connectTarget(self, target_url): logging.info("Connecting ...") targetCommand = "hdpctl" + " target -u" + target_url status, output = self.executeShellCommand(targetCommand) self.assertEqual(status, 0) logging.info("Connected to target") return status, output
def _list_space(self): """ :returns: list of spaces """ logging.info("List spaces") spaceListCommand = "cf" + " spaces " status, output = self.executeShellCommand(spaceListCommand) return output
def _list_quota(self): """ :returns: list of quota plans """ logging.info("List quota plans") quotaListCommand = "cf" + " quotas " status, output = self.executeShellCommand(quotaListCommand) return output
def _list_instances(self): """ :returns: list of instances """ logging.info("List instances") InstanceListCommand = "catalog" + " instances " status, output = self.executeShellCommand(InstanceListCommand) self.assertEqual(status, 0)
def _list_org(self): """ :returns: list of orgs """ logging.info("List organisations") orgListCommand = "cf" + " orgs" status, output = self.executeShellCommand(orgListCommand) return output
def _list_catalog(self, catalog_name): """ :returns: list of catalogs """ logging.info("List catalogs") catalogListCommand = "catalog" + " list" status, output = self.executeShellCommand(catalogListCommand) self.assertEqual(status, 0) self.assertIn(catalog_name, output)
def _connectApi(self, cluster_url): logging.info("Connecting ...") print "Connecting to api" strConnectApiCommand = "cf" + " api --skip-ssl-validation " \ + cluster_url status, output = self.executeShellCommand(strConnectApiCommand) self.assertEqual(0, status) logging.info("Connected to target") return status, output
def _details_service(self, service_name): """ :returns: service details """ logging.info("detail service") ServiceDetailsCommand = "catalog" + " service " + service_name status, output = self.executeShellCommand(ServiceDetailsCommand) self.assertEqual(status, 0) self.assertIn(service_name, output)
def _list_services(self, service_name): """ :returns: list of services """ logging.info("List services") ServiceListCommand = "catalog" + " services " status, output = self.executeShellCommand(ServiceListCommand) self.assertEqual(status, 0) self.assertIn(service_name, output)
def _details_catalog(self, catalog_name): """ :returns: catalog details """ logging.info("detail catalog") catalogDetailsCommand = "catalog" + " details " + catalog_name status, output = self.executeShellCommand(catalogDetailsCommand) self.assertEqual(status, 0) self.assertIn(catalog_name, output)
def _view_instance(self, instance_id): """ :returns: instance details """ logging.info("viewing instance") instViewCommand = "hdpctl" + " view-instance " + instance_id status, output = self.executeShellCommand(instViewCommand) self.assertEqual(status, 0) self.assertIn(instance_id, output) logging.info("instance Viewed successfully")
def _create_mysql_instance(self, service_Id, instancefile): """ :returns: Mysql Service instance """ logging.info("Create mysql instance") InstanceCreateCommand = "catalog" + " create-instance " + \ service_Id + "-i" + instancefile status, output = self.executeShellCommand(InstanceCreateCommand) self.assertEqual(status, 0) instance_Id = output return instance_Id
def _delete_quota(self, quota_name): """ :param quota_name: quota plan name """ logging.info("Delete quota") quotaDeleteCommand = "cf" + " delete-quota " + quota_name + " -f" status, output = self.executeShellCommand(quotaDeleteCommand) output = self._wait_for_quota_delete(quota_name, timeout=300, check_interval=4) self.assertNotIn(quota_name, output) self.assertEqual(0, status)
def _create_org(self): """ :returns: created org """ logging.info("Create new organisation") org_name = 'og_test_org' + str(random.randint(1024, 4096)) orgCreateCommand = "cf" + " create-org " + org_name status, output = self.executeShellCommand(orgCreateCommand) self.assertEqual(0, status) logging.info("Org created successfully") self.assertIn(org_name, output) return org_name
def _delete_instance(self, instance_id): """ :returns: deleted instance """ logging.info("Deleting instance") instDeleteCommand = "hdpctl" + " delete-instance " + instance_id status, output = self.executeShellCommand(instDeleteCommand) logging.info("instance deleted successfully") status = self._wait_for_instance_delete(instance_id, timeout=50, check_interval=4) self.assertEqual(status, 0)
def _delete_org(self, org_name): """ :param org_name: org name """ logging.info("Delete organisation") orgDeleteCommand = "cf" + " delete-org " + org_name + " -f" status, output = self.executeShellCommand(orgDeleteCommand) self.assertEqual(0, status) logging.info("Org deleted successfully") output = self._wait_for_org_delete(org_name, timeout=300, check_interval=4) self.assertNotIn(org_name, output)
def _delete_space(self, space_name): """ :param space_name: space name """ logging.info("Delete space") spaceDeleteCommand = "cf" + " delete-space " + space_name + " -f" status, output = self.executeShellCommand(spaceDeleteCommand) self.assertEqual(0, status) logging.info("Space deleted successfully") output = self._wait_for_space_delete(space_name, timeout=300, check_interval=4) self.assertNotIn(space_name, output)
def _create_instance(self): """ :returns: created instance """ logging.info("Creating new instance") instance_id = "ucpcluster" + str(random.randint(1024, 4096)) jsonFileName = self._create_instance_json(instance_id) instCreateCommand = "hdpctl" + " create-instance -d " + jsonFileName status, output = self.executeShellCommand(instCreateCommand) self.assertEqual(status, 0) self.assertIn(instance_id, output) logging.info("instance created successfully") os.remove(jsonFileName) return instance_id
def _loginToTarget(self, strUsr, strPasswd, strOrg=None, strSpc=None): logging.info("Logging in ...") if strOrg is None: strLoginCommand = "cf" + " login -u " + strUsr + " -p " \ + strPasswd else: strLoginCommand = cfCLICommand + " login -u " \ + strUsr + " -p " + strPasswd + " -o " \ + strOrg + " -s " + strSpc strLogin = "******" + " | " + strLoginCommand status, output = self.executeShellCommand(strLogin) time.sleep(60) self.assertEqual(0, status) logging.info("Logged into target") return status, output
def _create_space(self, org_name): """ :param: org_name: org name :returns: created space """ targetOrgCommand = "cf" + " target -o " + org_name self.executeShellCommand(targetOrgCommand) logging.info("Create new space") space_name = 'sp_test_space' + str(random.randint(1024, 4096)) spaceCreateCommand = "cf" + " create-space " + space_name + \ " -o " + org_name status, output = self.executeShellCommand(spaceCreateCommand) self.assertEqual(0, status) logging.info("Space created successfully") self.assertIn(space_name, output) return space_name
def _create_quota(self): """ :returns: created quota plan """ logging.info("Create new quota plan") quota_name = 'q_test_quota_plan' + str(random.randint(1024, 4096)) max_mem = "1G" total_mem = "1G" total_routes = "500" total_service_inst = "110" quotaCreateCommand = "cf" + " create-quota " + quota_name + \ " -i " + max_mem + " -m " + total_mem + " -r " + total_routes + \ " -s " + total_service_inst + " --allow-paid-service-plans" status, output = self.executeShellCommand(quotaCreateCommand) self.assertEqual(0, status) logging.info("Quota Plan created successfully") self.assertIn(quota_name, output) return quota_name
def _delete_mysql_instance(self, instance_Id): logging.info("Delete mysql instance") InstanceDeleteCommand = "catalog" + "delete-instance " + \ "-f " + instance_Id status, output = self.executeShellCommand(InstanceDeleteCommand) self.assertEqual(status, 0)