Exemple #1
0
    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 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