def add(self): access_key = self.app.pargs.access_key secret_key = self.app.pargs.secret_key region_id = self.app.pargs.region_id endpoint = self.app.pargs.endpoint scheme = self.app.pargs.scheme timeout = self.app.pargs.timeout profile = self.app.pargs.profile if access_key is None: access_key = cmd_input("Please input your access-key:") if access_key == '': print('access-key is required.') exit(1) if secret_key is None: secret_key = getpass("Please input your secret-key:") if secret_key == '': print('secret-key is required.') exit(1) profile_manager = ProfileManager() result, msg = profile_manager.add_profile( profile, Config(access_key, secret_key, region_id, endpoint, scheme, timeout)) if result: profile_manager.set_current_profile(profile) print('Configure successfully!') else: print(msg)
def use(self): profile_manager = ProfileManager() result, msg = profile_manager.set_current_profile(self.app.pargs.profile) if result: print 'Configure successfully!' else: print msg
def delete(self): profile_manager = ProfileManager() result, msg = profile_manager.delete_profile(self.app.pargs.profile) if result: print('Configure successfully!') else: print(msg)
def get(self, app): client_map = { 'vm': VmClient, 'iam': IamClient, 'disk': DiskClient, 'mongodb': MongodbClient, 'mps': MpsClient, 'streambus': StreambusClient, 'ipanti': IpantiClient, 'rds': RdsClient, 'redis': RedisClient, 'monitor': MonitorClient, 'vpc': VpcClient, 'xdata': XdataClient, 'nc': NcClient, 'oss': OssClient, } profile_manager = ProfileManager() cli_config = profile_manager.load_current_profile() if cli_config is None: return None logger = get_logger(app.pargs.debug) config = Config(cli_config.endpoint, cli_config.scheme) credential = Credential(cli_config.access_key, cli_config.secret_key) if self.__service not in client_map: return None client = client_map[self.__service](credential, config, logger) return client
def get(self, app): client_map = { 'rds': RdsClient, 'kubernetes': KubernetesClient, 'streamcomputer': StreamcomputerClient, 'ipanti': IpantiClient, 'oss': OssClient, 'redis': RedisClient, 'deploy': DeployClient, 'sop': SopClient, 'function': FunctionClient, 'portal': PortalClient, 'clouddnsservice': ClouddnsserviceClient, 'cps': CpsClient, 'cdn': CdnClient, 'streambus': StreambusClient, 'httpdns': HttpdnsClient, 'mps': MpsClient, 'disk': DiskClient, 'nc': NcClient, 'vm': VmClient, 'pod': PodClient, 'ams': AmsClient, 'jdro': JdroClient, 'zfs': ZfsClient, 'datastar': DatastarClient, 'kms': KmsClient, 'elite': EliteClient, 'iam': IamClient, 'iothub': IothubClient, 'jcq': JcqClient, 'baseanti': BaseantiClient, 'ias': IasClient, 'mongodb': MongodbClient, 'live': LiveClient, 'jdfusion': JdfusionClient, 'vpc': VpcClient, 'monitor': MonitorClient, 'xdata': XdataClient, 'cr': CrClient, } profile_manager = ProfileManager() cli_config = profile_manager.load_current_profile() if cli_config is None: return None logger = get_logger(app.pargs.debug) config = Config(cli_config.endpoint, cli_config.scheme, int(cli_config.timeout)) credential = Credential(cli_config.access_key, cli_config.secret_key) if self.__service not in client_map: return None client = client_map[self.__service](credential, config, logger) return client
def attach(self): profile_region_id = ProfileManager().load_current_profile().region_id region_id = self.app.pargs.regionId if self.app.pargs.regionId else profile_region_id headers = collect_user_headers(self.app) attach(self.app, 'pod', headers, region_id, self.app.pargs.containerName, pod_id=self.app.pargs.podId)
def add(self): access_key = self.app.pargs.access_key secret_key = self.app.pargs.secret_key region_id = self.app.pargs.region_id endpoint = self.app.pargs.endpoint scheme = self.app.pargs.scheme profile = self.app.pargs.profile profile_manager = ProfileManager() result, msg = profile_manager.add_profile(profile, Config(access_key, secret_key, region_id, endpoint, scheme)) if result: print 'Configure successfully!' else: print msg
def attach(app, service, headers, region_id, container_id, pod_id=None): def handle_signal(signum, frame): h, w = web_socket.get_win_size() resize_tty(h, w, app, service, headers, region_id, container_id, pod_id=pod_id) web_socket.reg_winch_handler(handle_signal) profile_manager = ProfileManager() cli_config = profile_manager.load_current_profile() credential = Credential(cli_config.access_key, cli_config.secret_key) request = AttachRequest(service, WEBSOCKET_SCHEME, cli_config.endpoint, METHOD_GET, headers, region_id, container_id, pod_id=pod_id) request.invoke_shell(credential) h_o, w_o = web_socket.get_win_size() resize_tty(h_o, w_o, app, service, headers, region_id, container_id, pod_id=pod_id)
def exec_start(app, region_id, container_id, exec_id): def handle_signal(signum, frame): h, w = web_socket.get_win_size() resize_tty(h, w, app, region_id, container_id, exec_id) web_socket.reg_winch_handler(handle_signal) profile_manager = ProfileManager() cli_config = profile_manager.load_current_profile() credential = Credential(cli_config.access_key, cli_config.secret_key) request = ExecStartRequest(WEBSOCKET_SCHEME, cli_config.endpoint, METHOD_GET, region_id, container_id, exec_id) request.invoke_shell(credential) h_o, w_o = web_socket.get_win_size() resize_tty(h_o, w_o, app, region_id, container_id, exec_id)
def exec_start(self): profile_region_id = ProfileManager().load_current_profile().region_id region_id = self.app.pargs.regionId if self.app.pargs.regionId else profile_region_id headers = collect_user_headers(self.app) exec_start(self.app, 'nc', headers, region_id, self.app.pargs.containerId, self.app.pargs.execId)
def show_all(self): profile_manager = ProfileManager() profiles = profile_manager.get_all_profiles() self._print_profiles(profiles)
def show_current(self): profile_manager = ProfileManager() profiles = profile_manager.get_current_profile() self._print_profiles(profiles)
def get(self, app): client_map = { 'rds': RdsClient, 'kubernetes': KubernetesClient, 'vqd': VqdClient, 'streamcomputer': StreamcomputerClient, 'ipanti': IpantiClient, 'ssl': SslClient, 'domainservice': DomainserviceClient, 'jmr': JmrClient, 'oss': OssClient, 'redis': RedisClient, 'billing': BillingClient, 'deploy': DeployClient, 'sop': SopClient, 'function': FunctionClient, 'portal': PortalClient, 'jdccs': JdccsClient, 'logs': LogsClient, 'clouddnsservice': ClouddnsserviceClient, 'cps': CpsClient, 'cdn': CdnClient, 'streambus': StreambusClient, 'apigateway': ApigatewayClient, 'httpdns': HttpdnsClient, 'disk': DiskClient, 'sts': StsClient, 'nc': NcClient, 'vm': VmClient, 'nativecontainer': NativecontainerClient, 'iotcore': IotcoreClient, 'pod': PodClient, 'ams': AmsClient, 'jdro': JdroClient, 'zfs': ZfsClient, 'vod': VodClient, 'yundingdatapush': YundingdatapushClient, 'datastar': DatastarClient, 'kms': KmsClient, 'elite': EliteClient, 'ossopenapi': OssopenapiClient, 'iam': IamClient, 'iothub': IothubClient, 'sms': SmsClient, 'jcq': JcqClient, 'resourcetag': ResourcetagClient, 'baseanti': BaseantiClient, 'ias': IasClient, 'mongodb': MongodbClient, 'jdfusion': JdfusionClient, 'live': LiveClient, 'detection': DetectionClient, 'iotlink': IotlinkClient, 'renewal': RenewalClient, 'yunding': YundingClient, 'vpc': VpcClient, 'monitor': MonitorClient, 'xdata': XdataClient, 'containerregistry': ContainerregistryClient, 'partner': PartnerClient, 'lb': LbClient, 'industrydata': IndustrydataClient, } profile_manager = ProfileManager() cli_config = profile_manager.load_current_profile() if cli_config is None: return None logger = get_logger(app.pargs.debug) config = Config(cli_config.endpoint, cli_config.scheme, int(cli_config.timeout)) credential = Credential(cli_config.access_key, cli_config.secret_key) if self.__service not in client_map: return None client = client_map[self.__service](credential, config, logger) return client
def _append_region_id(param_dict): if REGION_ID in param_dict and param_dict[REGION_ID] is None: pm = ProfileManager() param_dict.update({REGION_ID: str(pm.load_current_profile().region_id)})