当前位置: 首页>>代码示例>>Python>>正文


Python VirtualMachine.delete方法代码示例

本文整理汇总了Python中marvin.lib.base.VirtualMachine.delete方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualMachine.delete方法的具体用法?Python VirtualMachine.delete怎么用?Python VirtualMachine.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marvin.lib.base.VirtualMachine的用法示例。


在下文中一共展示了VirtualMachine.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_network_vcs

# 需要导入模块: from marvin.lib.base import VirtualMachine [as 别名]
# 或者: from marvin.lib.base.VirtualMachine import delete [as 别名]
    def test_network_vcs(self):
        """Test Brocade Network and VM Creation
        """


        # Validate the following
        # 1. Deploy the first VM using a network from the above created
        #    Network offering.
        # 2. Deploy another VM.
        # 3. Delete The VMs and the Network

        # Creating network using the network offering created
        self.debug("Creating network with network offering: %s" %
                                                    self.network_offering.id)
        self.network = Network.create(
                                    self.apiclient,
                                    self.services["network"],
                                    accountid=self.account.name,
                                    domainid=self.account.domainid,
                                    networkofferingid=self.network_offering.id,
                                    zoneid=self.zone.id
                                    )
        self.debug("Created network with ID: %s" % self.network.id)

        self.debug("Deploying VM in account: %s" % self.account.name)

        # Spawn an instance in that network
        virtual_machine_1 = VirtualMachine.create(
                                  self.apiclient,
                                  self.services["virtual_machine"],
                                  accountid=self.account.name,
                                  domainid=self.account.domainid,
                                  serviceofferingid=self.service_offering.id,
                                  networkids=[str(self.network.id)]
                                  )
        self.debug("Deployed VM in network: %s" % self.network.id)
        list_vm_response = VirtualMachine.list(
                                        self.apiclient,
                                        id=virtual_machine_1.id
                                        )

        self.debug(
                "Verify listVirtualMachines response for virtual machine: %s" \
                % virtual_machine_1.id
            )

        self.assertEqual(
                            isinstance(list_vm_response, list),
                            True,
                            "Check list response returns a valid list"
                        )
        vm_response = list_vm_response[0]

        self.assertEqual(
                            vm_response.state,
                            "Running",
                            "VM state should be running after deployment"
                        )

        self.debug("Deploying another VM in account: %s" %
                                            self.account.name)

        # Spawn an instance in that network
        virtual_machine_2 = VirtualMachine.create(
                                  self.apiclient,
                                  self.services["virtual_machine"],
                                  accountid=self.account.name,
                                  domainid=self.account.domainid,
                                  serviceofferingid=self.service_offering.id,
                                  networkids=[str(self.network.id)]
                                  )
        self.debug("Deployed VM in network: %s" % self.network.id)
        list_vm_response = VirtualMachine.list(
                                        self.apiclient,
                                        id=virtual_machine_2.id
                                        )

        self.debug(
                "Verify listVirtualMachines response for virtual machine: %s" \
                % virtual_machine_2.id
            )

        self.assertEqual(
                            isinstance(list_vm_response, list),
                            True,
                            "Check list response returns a valid list"
                        )
        vm_response = list_vm_response[0]

        self.assertEqual(
                            vm_response.state,
                            "Running",
                            "VM state should be running after deployment"
                        )

        # Deleting a single VM
        VirtualMachine.delete(virtual_machine_1, self.apiclient, expunge=True)


        # Deleting a single VM
#.........这里部分代码省略.........
开发者ID:Accelerite,项目名称:cloudstack,代码行数:103,代码来源:test_brocade_vcs.py

示例2: test_network_vsp

# 需要导入模块: from marvin.lib.base import VirtualMachine [as 别名]
# 或者: from marvin.lib.base.VirtualMachine import delete [as 别名]
    def test_network_vsp(self):
        """Test nuage Network and VM Creation
        """

        self.debug("Creating network with network offering: %s" %
                   self.network_offering.id)
        self.network = Network.create(
            self.apiclient,
            self.services["network"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            networkofferingid=self.network_offering.id,
            zoneid=self.zone.id,
            gateway = "10.1.1.1",
            netmask = '255.255.255.0'
        )
        self.debug("Created network with ID: %s" % self.network.id)

        self.debug("Deploying VM in account: %s" % self.account.name)

        virtual_machine_1 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            networkids=[str(self.network.id)]
        )
        self.debug("Deployed VM in network: %s" % self.network.id)
        list_vm_response = VirtualMachine.list(
            self.apiclient,
            id=virtual_machine_1.id
        )

        self.debug(
            "Verify listVirtualMachines response for virtual machine: %s"
            % virtual_machine_1.id
        )

        self.assertEqual(
            isinstance(list_vm_response, list),
            True,
            "Check list response returns a valid list"
        )
        vm_response = list_vm_response[0]

        self.assertEqual(
            vm_response.state,
            "Running",
            "VM state should be running after deployment"
        )

        self.debug("Deploying another VM in account: %s" %
                   self.account.name)

        virtual_machine_2 = VirtualMachine.create(
            self.apiclient,
            self.services["virtual_machine"],
            accountid=self.account.name,
            domainid=self.account.domainid,
            serviceofferingid=self.service_offering.id,
            networkids=[str(self.network.id)]
        )
        self.debug("Deployed VM in network: %s" % self.network.id)
        list_vm_response = VirtualMachine.list(
            self.apiclient,
            id=virtual_machine_2.id
        )

        self.debug(
            "Verify listVirtualMachines response for virtual machine: %s"
            % virtual_machine_2.id
        )

        self.assertEqual(
            isinstance(list_vm_response, list),
            True,
            "Check list response returns a valid list"
        )
        vm_response = list_vm_response[0]

        self.assertEqual(
            vm_response.state,
            "Running",
            "VM state should be running after deployment"
        )

        VirtualMachine.delete(virtual_machine_1, self.apiclient, expunge=True)

        # # Deleting a single VM
        VirtualMachine.delete(virtual_machine_2, self.apiclient, expunge=True)

        # Delete Network
        Network.delete(self.network, self.apiclient)

        return
开发者ID:DiegoSanjuan,项目名称:cloudstack,代码行数:98,代码来源:test_nuage_vsp.py

示例3: test_vpc_network_bcf

# 需要导入模块: from marvin.lib.base import VirtualMachine [as 别名]
# 或者: from marvin.lib.base.VirtualMachine import delete [as 别名]

#.........这里部分代码省略.........

        #Create Firewall rules on source NAT
        fw_rule_icmp = FireWallRule.create(
                            self.apiclient,
                            ipaddressid=src_nat.id,
                            protocol='ICMP',
                            cidrlist=["0.0.0.0/0",]
                            )
        self.debug("Created firewall rule: %s" % fw_rule_icmp.id)

        self.debug("STEP 4: Trying to ping source NAT %s" % src_nat.ipaddress)
        # User should be able to ping router via source nat ip
        try:
            self.debug("Trying to ping source NAT %s" % src_nat.ipaddress)
            result = subprocess.call(
                ['ping', '-c 1', src_nat.ipaddress])

            self.debug("Ping result: %s" % result)
            # if ping successful, then result should be 0
            self.assertEqual(
                             result,
                             0,
                             "Check if ping is successful or not"
                            )
        except Exception as e:
            self.fail("Ping failed for source NAT %s (%s)"
                      % (src_nat.ipaddress, e))

        self.debug("STEP 5: Add static NAT to vm_1 with FW rule to allow SSH")
        floating_ip_1 = PublicIPAddress.create(
                                               self.apiclient,
                                               accountid=self.account.name,
                                               zoneid=self.zone.id,
                                               domainid=self.account.domainid,
                                               networkid=net1.id,
                                               vpcid=vpc.id
                                              )
        self.debug("Associated %s with network %s" % (
                                                      floating_ip_1.ipaddress,
                                                      net1.id
                                                     )
                  )
        NATRule.create(
                                  self.apiclient,
                                  vm_1,
                                  self.services["natrule"],
                                  ipaddressid=floating_ip_1.ipaddress.id,
                                  openfirewall=False,
                                  networkid=net1.id,
                                  vpcid=vpc.id
                                  )

        # Should be able to SSH vm_1 via static nat, then ping vm_2 & Internet
        try:
            self.debug("STEP 6: SSH into vm_1: %s" % floating_ip_1)

            ssh = vm_1.get_ssh_client(
                                  ipaddress=floating_ip_1.ipaddress.ipaddress
                                  )
#            self.debug("Ping vm_2 at %s" % vm_2.ipaddress)
            # Ping to outsite world
#            res_1 = ssh.execute("ping -c 1 %s" % vm_2.ipaddress)

#            self.debug("Ping to google.com from VM")
            # Ping to outsite world
#            res_2 = ssh.execute("ping -c 1 www.google.com")

            # res = 64 bytes from maa03s17-in-f20.1e100.net (74.125.236.212):
            # icmp_req=1 ttl=57 time=25.9 ms
            # --- www.l.google.com ping statistics ---
            # 1 packets transmitted, 1 received, 0% packet loss, time 0ms
            # rtt min/avg/max/mdev = 25.970/25.970/25.970/0.000 ms
        except Exception as e:
            self.fail("SSH Access failed: %s" % e)

#        self.debug("ping result1: %s" % res_1);
#        self.debug("ping result2: %s" % res_2);

#        result1 = str(res_1)
#        self.assertEqual(
#                         result1.count("1 received"),
#                         1,
#                         "Ping vm_2 from vm_1 should be successful"
#                         )

#        result2 = str(res_2)
#        self.assertEqual(
#                         result2.count("1 received"),
#                         1,
#                         "Ping Internet from vm_1 should be successful"
#                         )

        # Deleting two test VMs
        VirtualMachine.delete(vm_1, self.apiclient, expunge=True)
        VirtualMachine.delete(vm_2, self.apiclient, expunge=True)

        # Delete Network
        Network.delete(self.network, self.apiclient)

        return
开发者ID:Accelerite,项目名称:cloudstack,代码行数:104,代码来源:test_bigswitch_bcf.py


注:本文中的marvin.lib.base.VirtualMachine.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。