def get_system(module): """Return System Object or Fail""" box = module.params['system'] user = module.params['user'] password = module.params['password'] if user and password: system = InfiniBox(box, auth=(user, password)) elif environ.get('INFINIBOX_USER') and environ.get('INFINIBOX_PASSWORD'): system = InfiniBox(box, auth=(environ.get('INFINIBOX_USER'), environ.get('INFINIBOX_PASSWORD'))) elif path.isfile(path.expanduser('~') + '/.infinidat/infinisdk.ini'): system = InfiniBox(box) else: module.fail_json( msg= "You must set INFINIBOX_USER and INFINIBOX_PASSWORD environment variables or set username/password module arguments" ) try: system.login() except Exception: module.fail_json( msg="Infinibox authentication failed. Check your credentials") return system
def init(opts): ''' Open the connection to the ibox device, login, and bind to the Resource class ''' opts['multiprocessing'] = False log.debug('Opening connection to ibox') args = {"host": opts['proxy']['host'],"user": opts['proxy']['username'],"password":opts['proxy']['password']} # optional_args = ['user', # 'username', # 'password', # 'passwd' # ] # # if 'username' in opts['proxy'].keys(): # opts['proxy']['user'] = opts['proxy'].pop('username') # proxy_keys = opts['proxy'].keys() # for arg in optional_args: # if arg in proxy_keys: # args[arg] = opts['proxy'][arg] thisproxy['conn'] = InfiniBox(args["host"], auth=(args["user"], str(args["password"]))) thisproxy['conn'].login() thisproxy['initialized'] = True
def ibox_login(ibox): try: pass_file = "." + ibox + ".sec" system = InfiniBox(ibox, pass_decode(pass_file)) system.login() return system except Exception as E: print "failed due to {}".format(E)
def ibox_login(ibox): try: pass_file = "." + ibox + ".sec" print "Opening {}".format(pass_file) auth = pass_decode(pass_file) system = InfiniBox(ibox, auth) system.login() return system, auth except Exception as E: print "failed due to {}".format(E)
def run(*args, **kwargs): user, box, password = args simulation = False if kwargs["mode"] == 'delete': print("delete-snapshots") elif kwargs["mode"] == 'status': print("status") simulation = True #t = PrettyTable(['instance name', 'creation timestamp', 'retention days', 'snapshot name', 'lock state', 'expiration date', 'action']) #print ("instance name \t | creation timestamp \t | retention days \t | snapshot name \t | lock state \t | expiration date \t | action") else: usage() exit() config = read_config(config_file) auth = (args[0], args[2]) b = InfiniBox(args[1], auth=auth) b.login() iter_snap(config, b, kwargs["mode"], "filesystems") iter_snap(config, b, kwargs["mode"], "volumes")
# show command line options if options.verbose: # store password temporarily password = options.password # hide password from output options.password = "******" # show command line options print "command line options:\n%s\n" % (pformat(vars(options))) # restore password options.password = password global_vars.system = InfiniBox(options.fqdn, auth=(options.username, options.password)) global_vars.system.login() state = 0 total = 0 hosts = global_vars.system.hosts vols = global_vars.system.volumes pools = global_vars.system.pools luns = global_vars.system.luns clusters = global_vars.system.host_clusters total_space_allocated = 0 total_space_used = 0 i = 0 # For loop iterator # build proper message
def iboxauth(ibox, user, pw): ibox = InfiniBox(ibox, auth=(user, pw)) ibox.login() return ibox
import requests import os import json from infinisdk import InfiniBox from capacity import GiB import argparse box_a = 'ibox2373' box_b = 'ibox606' auth = ('infinidat', '123456') box_a_object = InfiniBox(box_a, auth) box_b_object = InfiniBox(box_b, auth) box_a_object.login() box_b_object.login() volume_name = 'ds3' host = 'iocloudcore-02' additional = 2 * GiB def get_args(): """ Supports the command-line arguments listed below. """ parser = argparse.ArgumentParser( description="Resizing replica for Active/Active") parser.add_argument('-v', '--volume', nargs=1, required=True, help='Name of the volume') parser.add_argument('-s', '--size',
help='Ibox Name') parser.add_argument('-u', '--user', nargs=1, required=True, help='Ibox user') parser.add_argument('-p', '--password', nargs=1, required=True, help='Ibox password') args = parser.parse_args() return args args = get_args() auth = (args.user[0], args.password[0]) system = InfiniBox(args.ibox[0], auth) try: system.login() volume = system.volumes.find(name=args.volume[0]) if (volume.to_list()): volume = volume.to_list()[0] print(volume.get_name()) for snap in volume.get_snapshots().to_list(): sp = "^" + args.rename[0] if re.search(sp, snap.get_name()): new_name = (re.sub(sp, volume.get_name(), snap.get_name())) snap.update_name(new_name) except Exception as E: print("Cannot run", E)
required=True, help='Sync interval in minutes') args = parser.parse_args() return args if __name__ == '__main__': args = get_args() if args.configfile: if os.path.isfile('{}'.format(args.configfile[0])): cfgargs = args_from_cfgfile(args.configfile[0]) ibox1 = cfgargs['src_ibox'] user1 = cfgargs['src_user'] enc_pw1 = cfgargs['dst_password'] ibox2 = cfgargs['dst_ibox'] user2 = cfgargs['dst_user'] enc_pw2 = cfgargs['src_password'] v1_name = args.v1_name[0] v2_name = args.v2_name[0] rpo = args.rpo[0] interval = args.interval[0] pw1 = base64.b64decode(enc_pw1).decode("utf-8", "ignore") pw2 = base64.b64decode(enc_pw2).decode("utf-8", "ignore") src = InfiniBox(ibox1, auth=(user1, pw1)) src.login() dst = InfiniBox(ibox2, auth=(user2, pw2)) dst.login() rep = get_objects(v1_name, ibox2, v2_name, rpo, interval) if (rep.is_active()): print("\033[1;32;40m Replicated Successfuly \033[0m")