def main(): parser = OptionParser(version='0.1') parser.add_option("--debug", dest="debug", default=False, help="Show debugging") parser.add_option("-f", "--fpack", dest="fpack", default=None, help="name for the feature pack") parser.add_option("-k", "--sku", dest="skuname", default=None, help="name of the sku for this feature pack") parser.add_option("-s", "--show feature pack and stm_sku", dest="list", action="store_true",default=False, help="show current feature packs") parser.add_option("-u", "--username", dest="username", default=None, help="username for api access") parser.add_option("-q", "--query", dest="query", default=None, help="list resource of a given feature") (options, args) = parser.parse_args() if options.debug: global debug debug = True username='******' if not options.username is None: username = options.username ssc_common.username=username if options.list: listurl('feature_pack') print '####### SKU LIST #########' listurl('sku') sys.exit(0) if not options.query is None: showResource(options.query) sys.exit(0) if (options.fpack is None) and (not options.list ): print >> sys.stderr, "provide name for feature pack" sys.exit(1) if (options.skuname is None) and (not options.list ): print >> sys.stderr, "provide the sku name, run -s to get sku list" sys.exit(1) skuname=options.skuname fpack=options.fpack featurejson={ "stm_sku": skuname, "excluded": "" } if not options.list: addFeature(featurejson,fpack)
def main(): parser = OptionParser(version='0.1') parser.add_option("--debug", dest="debug", default=False, help="Show debugging") parser.add_option("-l", "--license", dest="lname", default=None, help="license name") parser.add_option("-s", "--show licenses", dest="list", action="store_true",default=False, help="show current licenses") parser.add_option("-u", "--username", dest="username", default=None, help="username for api access") parser.add_option("-q", "--query", dest="query", default=None, help="list resource of a given license") (options, args) = parser.parse_args() if options.debug: global debug debug = True username='******' if not options.username is None: username = options.username ssc_common.username=username if options.list: listurl('license') sys.exit(0) if options.query: showResource(options.query) sys.exit(0) if (options.lname is None): print >> sys.stderr, "provide name for license resource" sys.exit(1) lname=options.lname licensejson={ "info": "This is the resource for fla "+lname+" license", } if not options.list: addLic(licensejson,lname)
def main(): parser = OptionParser(version='0.1') parser.add_option("--debug", dest="debug", default=False, help="Show debugging") parser.add_option("-n", "--notreally", dest="not_really", default=False, help="Don't create anything") parser.add_option("-i", "--instance", dest="instancename", default=None, help="hostname to add to sssc") parser.add_option("-l", "--lic", dest="license", default=None, help="fla license for the instance") parser.add_option("-b", "--bandwidth", dest="bandwidth", default=None, help="bandwidth allocation for the instance") parser.add_option("--show-bandwidth", dest='showbw', action="store_true", default=False, help="show all allocated bandwidth") parser.add_option("-u", "--username", dest="username", default=None, help="username for api access") parser.add_option("-f", "--fpack", dest="fpack", default=None, help="feature pack") parser.add_option("-r", "--remove", dest="remove", action="store_true",default=False, help="delete a given instance") parser.add_option("-c", "--change", dest="changestatus", default=None, help="change instance status to active, Active/Idle") parser.add_option("-s", "--show", dest="show", action="store_true",default=False, help="list all current instance resouce") parser.add_option("-q", "--query", dest="query", default=None, help="list resource of a given instance") parser.add_option("-p", "--pass", dest="adminpass", action="store_true",default=False, help="stm instance admin password for rest api") (options, args) = parser.parse_args() if options.debug: global debug debug = True username='******' if not options.username is None: username = options.username ssc_common.username=username if options.show: listurl('instance') sys.exit(0) if not options.query is None: showResource(options.query) sys.exit(0) if options.showbw: showBW() sys.exit(0) if (options.instancename is None) and (not options.show ): print >> sys.stderr, "Provide instancename" sys.exit(1) stmName=options.instancename if options.remove: changeInstanceStatus(stmName,"Deleted") sys.exit(0) if not options.changestatus is None: changeInstanceStatus(stmName,options.changestatus) sys.exit(0) # default values, can be changed later license ='STM_684893_License.fla' admin_password='******' fpack= 'STM-U-CSP-400-FP' # json object for creating a new instance, setting default values as defined above. instancejson={ "config_options": "", "stm_version" : "9.4", "rest_address": stmName+":9070", "snmp_address": stmName+":161", "admin_username": username, "cpu_usage": "0", "stm_feature_pack": fpack, "ui_address": stmName+":9090", "container_configuration": "", "admin_password": admin_password, "owner": "websys", "license_name" : license, "management_address": stmName, "host_name": stmName} # construct json object to to update an instacne, only update what we need to update, provided from cmdline, when empty nothing will change updateinstancejson={} if options.adminpass: admin_password=getPassword('stminstance','Enter instance admin password for rest api: ') updateinstancejson["admin_password"] = admin_password instancejson["admin_password"] = admin_password if not options.license is None: license =options.license updateinstancejson["license_name"] = license instancejson["license_name"] = license if not options.username is None: username =options.username updateinstancejson["admin_username"] = username instancejson["admin_username"] = username if not options.bandwidth is None: bandwidth =int(options.bandwidth) updateinstancejson["bandwidth"] = bandwidth instancejson["bandwidth"] = bandwidth if not options.fpack is None: fpack =options.fpack updateinstancejson["stm_feature_pack"] = fpack instancejson["stm_feature_pack"] = fpack if not options.show: addInstance(stmName,instancejson, updateinstancejson)