in tools/marvin/marvin/lib/base.py [0:0]
def create(cls, apiclient, services, templateid=None, accountid=None,
domainid=None, zoneid=None, networkids=None,
serviceofferingid=None, securitygroupids=None,
projectid=None, startvm=None, diskofferingid=None,
affinitygroupnames=None, affinitygroupids=None, group=None,
hostid=None, clusterid=None, keypair=None, ipaddress=None, mode='default',
method='GET', hypervisor=None, customcpunumber=None,
customcpuspeed=None, custommemory=None, rootdisksize=None,
rootdiskcontroller=None, vpcid=None, macaddress=None, datadisktemplate_diskoffering_list={},
properties=None, nicnetworklist=None, bootmode=None, boottype=None, dynamicscalingenabled=None,
userdataid=None, userdatadetails=None, extraconfig=None,
vnfconfiguremanagement=None, vnfcidrlist=None):
"""Create the VNF appliance"""
cmd = deployVnfAppliance.deployVnfApplianceCmd()
if serviceofferingid:
cmd.serviceofferingid = serviceofferingid
elif "serviceoffering" in services:
cmd.serviceofferingid = services["serviceoffering"]
if zoneid:
cmd.zoneid = zoneid
elif "zoneid" in services:
cmd.zoneid = services["zoneid"]
if hypervisor:
cmd.hypervisor = hypervisor
if "displayname" in services:
cmd.displayname = services["displayname"]
if "name" in services:
cmd.name = services["name"]
if accountid:
cmd.account = accountid
elif "account" in services:
cmd.account = services["account"]
if domainid:
cmd.domainid = domainid
elif "domainid" in services:
cmd.domainid = services["domainid"]
if networkids:
cmd.networkids = networkids
allow_egress = False
elif "networkids" in services:
cmd.networkids = services["networkids"]
allow_egress = False
else:
# When no networkids are passed, network
# is created using the "defaultOfferingWithSourceNAT"
# which has an egress policy of DENY. But guests in tests
# need access to test network connectivity
allow_egress = True
if templateid:
cmd.templateid = templateid
elif "template" in services:
cmd.templateid = services["template"]
if diskofferingid:
cmd.diskofferingid = diskofferingid
elif "diskoffering" in services:
cmd.diskofferingid = services["diskoffering"]
if keypair:
cmd.keypair = keypair
elif "keypair" in services:
cmd.keypair = services["keypair"]
if ipaddress:
cmd.ipaddress = ipaddress
elif "ipaddress" in services:
cmd.ipaddress = services["ipaddress"]
if securitygroupids:
cmd.securitygroupids = [str(sg_id) for sg_id in securitygroupids]
if "affinitygroupnames" in services:
cmd.affinitygroupnames = services["affinitygroupnames"]
elif affinitygroupnames:
cmd.affinitygroupnames = affinitygroupnames
if affinitygroupids:
cmd.affinitygroupids = affinitygroupids
if projectid:
cmd.projectid = projectid
if startvm is not None:
cmd.startvm = startvm
if hostid:
cmd.hostid = hostid
if clusterid:
cmd.clusterid = clusterid
if "userdata" in services:
cmd.userdata = base64.urlsafe_b64encode(services["userdata"].encode()).decode()
if userdataid is not None:
cmd.userdataid = userdataid
if userdatadetails is not None:
cmd.userdatadetails = userdatadetails
if "dhcpoptionsnetworklist" in services:
cmd.dhcpoptionsnetworklist = services["dhcpoptionsnetworklist"]
if dynamicscalingenabled is not None:
cmd.dynamicscalingenabled = dynamicscalingenabled
cmd.details = [{}]
if customcpunumber:
cmd.details[0]["cpuNumber"] = customcpunumber
if customcpuspeed:
cmd.details[0]["cpuSpeed"] = customcpuspeed
if custommemory:
cmd.details[0]["memory"] = custommemory
if not rootdisksize is None and rootdisksize >= 0:
cmd.details[0]["rootdisksize"] = rootdisksize
if rootdiskcontroller:
cmd.details[0]["rootDiskController"] = rootdiskcontroller
if "size" in services:
cmd.size = services["size"]
if group:
cmd.group = group
cmd.datadisktemplatetodiskofferinglist = []
for datadisktemplate, diskoffering in list(datadisktemplate_diskoffering_list.items()):
cmd.datadisktemplatetodiskofferinglist.append({
'datadisktemplateid': datadisktemplate,
'diskofferingid': diskoffering
})
# program default access to ssh
if mode.lower() == 'basic':
cls.ssh_access_group(apiclient, cmd)
if macaddress:
cmd.macaddress = macaddress
elif macaddress in services:
cmd.macaddress = services["macaddress"]
if properties:
cmd.properties = properties
if nicnetworklist:
cmd.nicnetworklist = nicnetworklist
if bootmode:
cmd.bootmode = bootmode
if boottype:
cmd.boottype = boottype
if extraconfig:
cmd.extraconfig = extraconfig
if vnfconfiguremanagement:
cmd.vnfconfiguremanagement = vnfconfiguremanagement
if vnfcidrlist:
cmd.vnfcidrlist = vnfcidrlist
vnf_app = apiclient.deployVnfAppliance(cmd, method=method)
return VnfAppliance(vnf_app.__dict__)