本文整理汇总了Python中marvin.lib.base.Project.create方法的典型用法代码示例。如果您正苦于以下问题:Python Project.create方法的具体用法?Python Project.create怎么用?Python Project.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.Project
的用法示例。
在下文中一共展示了Project.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_domain_account_user
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def create_domain_account_user(parentDomain=None):
domain = Domain.create(cls.api_client,
cls.services["domain"],
parentdomainid=parentDomain.id if parentDomain else None)
cls._cleanup.append(domain)
# Create an Account associated with domain
account = Account.create(cls.api_client,
cls.services["account"],
domainid=domain.id)
cls._cleanup.append(account)
# Create an User, Project, Volume associated with account
user = User.create(cls.api_client,
cls.services["user"],
account=account.name,
domainid=account.domainid)
cls._cleanup.append(user)
project = Project.create(cls.api_client,
cls.services["project"],
account=account.name,
domainid=account.domainid)
cls._cleanup.append(project)
volume = Volume.create(cls.api_client,
cls.services["volume"],
zoneid=cls.zone.id,
account=account.name,
domainid=account.domainid,
diskofferingid=cls.disk_offering.id)
cls._cleanup.append(volume)
return {'domain':domain, 'account':account, 'user':user, 'project':project, 'volume':volume}
示例2: setUpClass
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def setUpClass(cls):
cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
cls.services["server"]["zoneid"] = cls.zone.id
# Create Domains, Account etc
cls.domain = Domain.create(cls.api_client, cls.services["domain"])
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
cls.userapiclient = cls.testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain)
# Create project as a domain admin
cls.project = Project.create(
cls.api_client, cls.services["project"], account=cls.account.name, domainid=cls.account.domainid
)
cls.services["account"] = cls.account.name
# Create Service offering and disk offerings etc
cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"])
cls._cleanup = [cls.project, cls.service_offering, cls.disk_offering, cls.account, cls.domain]
return
示例3: setupAccounts
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def setupAccounts(self, account_limit=2, domain_limit=2, project_limit=2):
self.debug("Creating a domain under: %s" % self.domain.name)
self.child_domain = Domain.create(self.apiclient,
services=self.testdata["domain"],
parentdomainid=self.domain.id)
self.debug("domain crated with domain id %s" % self.child_domain.id)
self.child_do_admin = Account.create(self.apiclient,
self.testdata["account"],
admin=True,
domainid=self.child_domain.id)
self.debug("domain admin created for domain id %s" %
self.child_do_admin.domainid)
# Create project as a domain admin
self.project = Project.create(self.apiclient,
self.testdata["project"],
account=self.child_do_admin.name,
domainid=self.child_do_admin.domainid)
# Cleanup created project at end of test
self.cleanup.append(self.project)
# Cleanup accounts created
self.cleanup.append(self.child_do_admin)
self.cleanup.append(self.child_domain)
self.debug("Updating the CPU resource count for domain: %s" %
self.child_domain.name)
# Update resource limits for account 1
responses = Resources.updateLimit(self.apiclient,
resourcetype=8,
max=account_limit,
account=self.child_do_admin.name,
domainid=self.child_do_admin.domainid)
self.debug("CPU Resource count for child domain admin account is now: %s" %
responses.max)
self.debug("Updating the CPU limit for project")
responses = Resources.updateLimit(self.apiclient,
resourcetype=8,
max=project_limit,
projectid=self.project.id)
self.debug("CPU Resource count for project is now")
self.debug(responses.max)
self.debug("Updating the CPU limit for domain only")
responses = Resources.updateLimit(self.apiclient,
resourcetype=8,
max=domain_limit,
domainid=self.child_domain.id)
self.debug("CPU Resource count for domain %s with id %s is now %s" %
(responses.domain, responses.domainid, responses.max))
return
示例4: setupProjectAccounts
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def setupProjectAccounts(self):
self.debug("Creating a domain under: %s" % self.domain.name)
self.domain = Domain.create(self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id)
self.admin = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.domain.id
)
# Create project as a domain admin
self.project = Project.create(self.apiclient,
self.services["project"],
account=self.admin.name,
domainid=self.admin.domainid)
# Cleanup created project at end of test
self.cleanup.append(self.project)
self.cleanup.append(self.admin)
self.cleanup.append(self.domain)
self.debug("Created project with domain admin with name: %s" %
self.project.name)
projects = Project.list(self.apiclient, id=self.project.id,
listall=True)
self.assertEqual(isinstance(projects, list), True,
"Check for a valid list projects response")
project = projects[0]
self.assertEqual(project.name, self.project.name,
"Check project name from list response")
return
示例5: setupAccounts
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def setupAccounts(self):
try:
self.child_domain = Domain.create(self.apiclient,services=self.services["domain"],
parentdomainid=self.domain.id)
self.child_do_admin = Account.create(self.apiclient, self.services["account"], admin=True,
domainid=self.child_domain.id)
self.userapiclient = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
# Create project as a domain admin
self.project = Project.create(self.apiclient, self.services["project"],
account=self.child_do_admin.name,
domainid=self.child_do_admin.domainid)
# Cleanup created project at end of test
self.cleanup.append(self.project)
# Cleanup accounts created
self.cleanup.append(self.child_do_admin)
self.cleanup.append(self.child_domain)
except Exception as e:
return [FAIL, e]
return [PASS, None]
示例6: setUpClass
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def setUpClass(cls):
cls.testClient = super(TestPublicIpAddress, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
cls.services["server"]["zoneid"] = cls.zone.id
# Create Domains, Account etc
cls.domain = Domain.create(cls.api_client, cls.services["domain"])
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
# Create project as a domain admin
cls.project = Project.create(
cls.api_client, cls.services["project"], account=cls.account.name, domainid=cls.account.domainid
)
cls.services["account"] = cls.account.name
# Create Service offering and disk offerings etc
cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
cls.virtual_machine = VirtualMachine.create(
cls.api_client,
cls.services["server"],
templateid=cls.template.id,
serviceofferingid=cls.service_offering.id,
projectid=cls.project.id,
)
cls._cleanup = [cls.project, cls.service_offering, cls.account, cls.domain]
return
示例7: test_01_service_offerings
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def test_01_service_offerings(self):
""" Test service offerings in a project
"""
# Validate the following
# 1. Create a project.
# 2. List service offerings for the project. All SO available in the
# domain can be used for project resource creation.
# Create project as a domain admin
project = Project.create(
self.apiclient, self.services["project"], account=self.account.name, domainid=self.account.domainid
)
# Cleanup created project at end of test
self.cleanup.append(project)
self.debug("Created project with domain admin with ID: %s" % project.id)
self.debug(
"Deploying VM instance for project: %s & service offering: %s" % (project.id, self.service_offering.id)
)
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
serviceofferingid=self.service_offering.id,
projectid=project.id,
)
# Verify VM state
self.assertEqual(virtual_machine.state, "Running", "Check VM state is Running or not")
return
示例8: test_06_volumes_per_project
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def test_06_volumes_per_project(self):
"""Test Volumes limit per project
"""
# Validate the following
# 1. set max no of volume per project to 1.
# 2. Create 1 VM in this project
# 4. Try to Create another VM in the project. It should give the user
# an appropriate error that Volume limit is exhausted and an alert
# should be generated.
if self.hypervisor.lower() == 'lxc':
if not find_storage_pool_type(self.apiclient, storagetype='rbd'):
self.skipTest("RBD storage type is required for data volumes for LXC")
self.project_1 = Project.create(
self.api_client,
self.services["project"],
account=self.account.name,
domainid=self.account.domainid
)
self.cleanup.append(self.project_1)
self.debug(
"Updating volume resource limits for project: %s" %
self.project_1.id)
# Set usage_vm=1 for Account 1
update_resource_limit(
self.apiclient,
2, # Volume
max=1,
projectid=self.project_1.id
)
self.debug("Deploying VM for project: %s" % self.project_1.id)
virtual_machine_1 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
serviceofferingid=self.service_offering.id,
projectid=self.project_1.id
)
# Verify VM state
self.assertEqual(
virtual_machine_1.state,
'Running',
"Check VM state is Running or not"
)
# Exception should be raised for second volume
with self.assertRaises(Exception):
Volume.create(
self.apiclient,
self.services["volume"],
zoneid=self.zone.id,
diskofferingid=self.disk_offering.id,
projectid=self.project_1.id
)
return
示例9: test_maxAccountNetworks
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def test_maxAccountNetworks(self):
"""Test Limit number of guest account specific networks
"""
# Steps for validation
# 1. Fetch max.account.networks from configurations
# 2. Create an account. Create account more that max.accout.network
# 3. Create network should fail
self.debug("Creating project with '%s' as admin" % self.account.name)
# Create project as a domain admin
project = Project.create(
self.apiclient, self.services["project"], account=self.account.name, domainid=self.account.domainid
)
# Cleanup created project at end of test
self.cleanup.append(project)
self.debug("Created project with domain admin with ID: %s" % project.id)
config = Configurations.list(self.apiclient, name="max.project.networks", listall=True)
self.assertEqual(isinstance(config, list), True, "List configurations hsould have max.project.networks")
config_value = int(config[0].value)
self.debug("max.project.networks: %s" % config_value)
for ctr in range(config_value):
# Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.network_offering.id)
network = Network.create(
self.apiclient,
self.services["network"],
projectid=project.id,
networkofferingid=self.network_offering.id,
zoneid=self.zone.id,
)
self.debug("Created network with ID: %s" % network.id)
self.debug("Creating network in account already having networks : %s" % config_value)
with self.assertRaises(Exception):
Network.create(
self.apiclient,
self.services["network"],
projectid=project.id,
networkofferingid=self.network_offering.id,
zoneid=self.zone.id,
)
self.debug("Create network failed (as expected)")
return
示例10: setupProjectAccounts
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def setupProjectAccounts(self):
try:
self.domain = Domain.create(self.apiclient,
services=self.services["domain"],
parentdomainid=self.domain.id)
self.admin = Account.create(
self.apiclient, self.services["account"],
admin=True, domainid=self.domain.id)
# Create project as a domain admin
self.project = Project.create(
self.apiclient,self.services["project"],
account=self.admin.name,domainid=self.admin.domainid)
# Cleanup created project at end of test
self.cleanup.append(self.project)
self.cleanup.append(self.admin)
self.cleanup.append(self.domain)
except Exception as e:
return [FAIL, e]
return [PASS, None]
示例11: test_02_project_disk_offerings
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def test_02_project_disk_offerings(self):
""" Test project disk offerings
"""
# Validate the following
# 1. Create a project.
# 2. List service offerings for the project. All disk offerings
# available in the domain can be used for project resource creation
# Create project as a domain admin
project = Project.create(
self.apiclient, self.services["project"], account=self.account.name, domainid=self.account.domainid
)
# Cleanup created project at end of test
self.cleanup.append(project)
self.debug("Created project with domain admin with ID: %s" % project.id)
list_projects_reponse = Project.list(self.apiclient, id=project.id, listall=True)
self.assertEqual(isinstance(list_projects_reponse, list), True, "Check for a valid list projects response")
list_project = list_projects_reponse[0]
self.assertNotEqual(len(list_projects_reponse), 0, "Check list project response returns a valid project")
self.assertEqual(project.name, list_project.name, "Check project name from list response")
self.debug("Create a data volume for project: %s" % project.id)
# Create a volume for project
volume = Volume.create(
self.apiclient,
self.services["volume"],
zoneid=self.zone.id,
diskofferingid=self.disk_offering.id,
projectid=project.id,
)
self.cleanup.append(volume)
# Verify Volume state
self.assertEqual(volume.state in ["Allocated", "Ready"], True, "Check Volume state is Ready or not")
return
示例12: test_02_project_limits_normal_user
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def test_02_project_limits_normal_user(self):
""" Test project limits for normal user
"""
# Validate the following
# 1. Create a Project
# 2. Reduce the projects limits as a domain admin. Verify resource
# count is updated
# 3. Reduce the projects limits as a project user owner who is not a
# domain admin. Resource count should fail
# Create project as a domain admin
project = Project.create(
self.apiclient,
self.services["project"],
account=self.admin.name,
domainid=self.admin.domainid
)
# Cleanup created project at end of test
self.cleanup.append(project)
self.debug("Created project with domain admin with ID: %s" %
project.id)
list_projects_reponse = Project.list(
self.apiclient,
id=project.id,
listall=True
)
self.assertEqual(
isinstance(list_projects_reponse, list),
True,
"Check for a valid list projects response"
)
list_project = list_projects_reponse[0]
self.assertNotEqual(
len(list_projects_reponse),
0,
"Check list project response returns a valid project"
)
self.assertEqual(
project.name,
list_project.name,
"Check project name from list response"
)
# Get the resource limits for ROOT domain
resource_limits = list_resource_limits(self.apiclient)
self.assertEqual(
isinstance(resource_limits, list),
True,
"List resource API should return a valid list"
)
self.assertNotEqual(
len(resource_limits),
0,
"List resource API response should not be empty"
)
# Reduce resource limits for project
# Resource: 0 - Instance. Number of instances a user can create.
# Resource: 1 - IP. Number of public IP addresses a user can own.
# Resource: 2 - Volume. Number of disk volumes a user can create.
# Resource: 3 - Snapshot. Number of snapshots a user can create.
# Resource: 4 - Template. Number of templates that a user can
# register/create
for resource in resource_limits:
update_resource_limit(
self.apiclient,
resource.resourcetype,
max=1,
projectid=project.id
)
self.debug(
"Updating resource (ID: %s) limit for project: %s" % (
resource,
project.id
))
resource_limits = list_resource_limits(
self.apiclient,
projectid=project.id
)
self.assertEqual(
isinstance(resource_limits, list),
True,
"List resource API should return a valid list"
)
self.assertNotEqual(
len(resource_limits),
0,
"List resource API response should not be empty"
)
for resource in resource_limits:
self.assertEqual(
resource.max,
1,
"Resource limit should be updated to 1"
)
#.........这里部分代码省略.........
示例13: test_01_project_limits
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def test_01_project_limits(self):
""" Test project limits for domain admin
"""
# Validate the following
# 1. Create a Project. Verify once projects are created, they inherit
# a default set of resource limits as configured by the Cloud Stack
# ROOT admin.
# 2. Reduce Project resources limits. Verify limits can be reduced by
# the Project Owner of each project and project limit applies to
# number of virtual instances, disk volumes, snapshots, IP address.
# Also, verify resource limits for the project are independent of
# account resource limits
# 3. Increase Projects Resources limits above domains limit. Verify
# project can't have more resources than domain level limit allows.
# 4. Create Resource more than its set limit for the parent domain.
# Verify resource allocation should fail giving proper message
# Create project as a domain admin
project = Project.create(
self.apiclient,
self.services["project"],
account=self.admin.name,
domainid=self.admin.domainid
)
# Cleanup created project at end of test
self.cleanup.append(project)
self.debug("Created project with domain admin with ID: %s" %
project.id)
list_projects_reponse = Project.list(
self.apiclient,
id=project.id,
listall=True
)
self.assertEqual(
isinstance(list_projects_reponse, list),
True,
"Check for a valid list projects response"
)
list_project = list_projects_reponse[0]
self.assertNotEqual(
len(list_projects_reponse),
0,
"Check list project response returns a valid project"
)
self.assertEqual(
project.name,
list_project.name,
"Check project name from list response"
)
# Get the resource limits for ROOT domain
resource_limits = list_resource_limits(self.apiclient)
self.assertEqual(
isinstance(resource_limits, list),
True,
"List resource API should return a valid list"
)
self.assertNotEqual(
len(resource_limits),
0,
"List resource API response should not be empty"
)
# Reduce resource limits for project
# Resource: 0 - Instance. Number of instances a user can create.
# Resource: 1 - IP. Number of public IP addresses a user can own.
# Resource: 2 - Volume. Number of disk volumes a user can create.
# Resource: 3 - Snapshot. Number of snapshots a user can create.
# Resource: 4 - Template. Number of templates that a user can
# register/create
for resource in resource_limits:
update_resource_limit(
self.apiclient,
resource.resourcetype,
max=1,
projectid=project.id
)
self.debug(
"Updating resource (ID: %s) limit for project: %s" % (
resource,
project.id
))
resource_limits = list_resource_limits(
self.apiclient,
projectid=project.id
)
self.assertEqual(
isinstance(resource_limits, list),
True,
"List resource API should return a valid list"
)
self.assertNotEqual(
len(resource_limits),
0,
"List resource API response should not be empty"
)
#.........这里部分代码省略.........
示例14: setUpClass
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def setUpClass(cls):
cls.testClient = super(TestCreateAffinityGroup, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
#Get Zone, Domain and templates
cls.rootdomain = get_domain(cls.api_client)
cls.domain = Domain.create(cls.api_client, cls.services["domain"])
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["template"] = cls.template.id
cls.services["zoneid"] = cls.zone.id
cls.domain_admin_account = Account.create(
cls.api_client,
cls.services["domain_admin_account"],
domainid=cls.domain.id,
admin=True
)
cls.domain_api_client = cls.testClient.getUserApiClient(cls.domain_admin_account.name, cls.domain.name, 2)
cls.account = Account.create(
cls.api_client,
cls.services["account"],
domainid=cls.domain.id
)
cls.account_api_client = cls.testClient.getUserApiClient(cls.account.name, cls.domain.name, 0)
cls.account_not_in_project = Account.create(
cls.api_client,
cls.services["account_not_in_project"],
domainid=cls.domain.id
)
cls.account_not_in_project_api_client = cls.testClient.getUserApiClient(cls.account_not_in_project.name, cls.domain.name, 0)
cls.project = Project.create(
cls.api_client,
cls.services["project"],
account=cls.domain_admin_account.name,
domainid=cls.domain_admin_account.domainid
)
cls.project2 = Project.create(
cls.api_client,
cls.services["project2"],
account=cls.domain_admin_account.name,
domainid=cls.domain_admin_account.domainid
)
cls.debug("Created project with ID: %s" % cls.project.id)
cls.debug("Created project2 with ID: %s" % cls.project2.id)
# Add user to the project
cls.project.addAccount(
cls.api_client,
cls.account.name
)
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"],
domainid=cls.account.domainid
)
cls._cleanup = []
return
示例15: test_03_network_create
# 需要导入模块: from marvin.lib.base import Project [as 别名]
# 或者: from marvin.lib.base.Project import create [as 别名]
def test_03_network_create(self):
""" Test create network in project
"""
# Validate the following
# 1. Create a project.
# 2. Add virtual/direct network resource to the project. User shared
# network resource for the project
# 3. Verify any number of Project level Virtual/Direct networks can be
# created and used for vm deployment within the project.
# 4. Verify shared networks (zone and domain wide) from outside the
# project can also be used in a project.
# Create project as a domain admin
project = Project.create(
self.apiclient, self.services["project"], account=self.account.name, domainid=self.account.domainid
)
# Cleanup created project at end of test
self.cleanup.append(project)
self.debug("Created project with domain admin with ID: %s" % project.id)
network_offerings = list_network_offerings(
self.apiclient, projectid=project.id, supportedServices="SourceNat", type="isolated", state="Enabled"
)
self.assertEqual(isinstance(network_offerings, list), True, "Check for the valid network offerings")
network_offering = network_offerings[0]
self.debug("creating a network with network offering ID: %s" % network_offering.id)
self.services["network"]["zoneid"] = self.zone.id
network = Network.create(
self.apiclient, self.services["network"], networkofferingid=network_offering.id, projectid=project.id
)
self.debug("Created network with ID: %s" % network.id)
networks = Network.list(self.apiclient, projectid=project.id, listall=True)
self.assertEqual(isinstance(networks, list), True, "Check for the valid network list response")
self.debug("Deploying VM with network: %s" % network.id)
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
networkids=[str(network.id)],
serviceofferingid=self.service_offering.id,
projectid=project.id,
)
self.debug("Deployed VM with ID: %s" % virtual_machine.id)
# Verify VM state
self.assertEqual(virtual_machine.state, "Running", "Check VM state is Running or not")
network_offerings = list_network_offerings(
self.apiclient,
state="Enabled",
guestiptype="Shared",
name="DefaultSharedNetworkOffering",
displaytext="Offering for Shared networks",
)
self.assertEqual(isinstance(network_offerings, list), True, "Check for the valid network offerings")
network_offering = network_offerings[0]
self.debug("creating a shared network in domain: %s" % self.domain.id)
# Getting physical network and free vlan in it
physical_network, vlan = get_free_vlan(self.apiclient, self.zone.id)
self.services["domain_network"]["vlan"] = vlan
self.services["domain_network"]["physicalnetworkid"] = physical_network.id
# Generating random subnet number for shared network creation
shared_network_subnet_number = random.randrange(1, 254)
self.services["domain_network"]["gateway"] = "172.16." + str(shared_network_subnet_number) + ".1"
self.services["domain_network"]["startip"] = "172.16." + str(shared_network_subnet_number) + ".2"
self.services["domain_network"]["endip"] = "172.16." + str(shared_network_subnet_number) + ".20"
domain_network = Network.create(
self.apiclient,
self.services["domain_network"],
domainid=self.domain.id,
networkofferingid=network_offering.id,
zoneid=self.zone.id,
)
self.cleanup.append(domain_network)
self.debug("Created network with ID: %s" % domain_network.id)
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
networkids=[str(domain_network.id)],
serviceofferingid=self.service_offering.id,
projectid=project.id,
)
self.debug("Deployed VM with ID: %s" % virtual_machine.id)
# Verify VM state
self.assertEqual(virtual_machine.state, "Running", "Check VM state is Running or not")
# Delete VM before network gets deleted in cleanup
virtual_machine.delete(self.apiclient, expunge=True)
return