def testAddVM(self):
        policys = self.connection.listAllSecurityGroup()
        self.vms = self.connection.listAllVM()

        default_policy = None
        test_policy = None
        for policy in policys:
            sec = self.connection.getSecurityGroup(policy.id)
            self.assertEqual(policy.id, sec.id)

            if policy.name == 'Default Policy':
                default_policy = sec
            elif policy.name == 'TESTING':
                test_policy = sec

        # move all vm into test policy
        for vm in self.vms:
            new_vm = VirtualMachine(self.connection)
            new_vm.imageGUID = vm.imageGUID
            test_policy.addVM(new_vm)

        response = None
        response = test_policy.update()
        self.assertEqual(response, 200)

        # move all vm back to default policy
        default = self.connection.getSecurityGroup(default_policy.id)
        for vm in self.vms:
            new_vm = VirtualMachine(self.connection)
            new_vm.imageGUID = vm.imageGUID
            default.vmList.append(new_vm)

        response = default.update()
        self.assertEqual(response, 200)
    def testAddVM(self):
        policys = self.connection.listAllSecurityGroup()
        self.vms = self.connection.listAllVM()

        default_policy = None
        test_policy = None
        for policy in policys:
            sec = self.connection.getSecurityGroup(policy.id)
            self.assertEqual(policy.id, sec.id)

            if policy.name == "Default Policy":
                default_policy = sec
            elif policy.name == "TESTING":
                test_policy = sec

        # move all vm into test policy
        for vm in self.vms:
            new_vm = VirtualMachine(self.connection)
            new_vm.imageGUID = vm.imageGUID
            test_policy.addVM(new_vm)

        response = None
        response = test_policy.update()
        self.assertEqual(response, 200)

        # move all vm back to default policy
        default = self.connection.getSecurityGroup(default_policy.id)
        for vm in self.vms:
            new_vm = VirtualMachine(self.connection)
            new_vm.imageGUID = vm.imageGUID
            default.vmList.append(new_vm)

        response = default.update()
        self.assertEqual(response, 200)
Ejemplo n.º 3
0
def addVM(policy, vmid):

    # add new vm into a Policy
    if isinstance(policy, SecurityGroup):
        new = VirtualMachine(policy.connection)
        new.imageGUID = vmid
        policy.addVM(new)
        policy.update()
        printPolicy(policy)
Ejemplo n.º 4
0
def addVM(policy, vmid):

    # add new vm into a Policy
    if isinstance(policy, SecurityGroup):
        new = VirtualMachine(policy.connection)
        new.imageGUID = vmid
        policy.addVM(new)
        policy.update()
        printPolicy(policy) 
Ejemplo n.º 5
0
    def testCase2903(self):
        newvm = self.connection.getVM(self.TestVM_ID)
        target = VirtualMachine(self.connection)
        target.imageGUID = newvm.imageGUID

        # should be removed
        target.SecurityGroupGUID = newvm.SecurityGroupGUID
        target.autoProvision = newvm.autoProvision

        target.imageName = testlib.RandomString(
            string.ascii_uppercase + string.digits, 36)
        updated = target.update()
        self.assertEqual(updated.imageName, target.imageName)
Ejemplo n.º 6
0
    def testCase2903(self):
        newvm = self.connection.getVM(self.TestVM_ID)
        target = VirtualMachine(self.connection)
        target.imageGUID = newvm.imageGUID

        # should be removed
        target.SecurityGroupGUID = newvm.SecurityGroupGUID
        target.autoProvision = newvm.autoProvision

        target.imageName = testlib.RandomString(
            string.ascii_uppercase + string.digits, 36)
        updated = target.update()
        self.assertEqual(updated.imageName, target.imageName)
Ejemplo n.º 7
0
    def testUpdateVM(self):
        self.vms = self.connection.listAllVM()

        for vm in self.vms:
            newvm = self.connection.getVM(vm.imageGUID)
            target = VirtualMachine(self.connection)
            target.imageGUID = newvm.imageGUID
            target.href = newvm.href
            target.imageDescription = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(360))
            target.SecurityGroupGUID = newvm.SecurityGroupGUID
            target.autoProvision = newvm.autoProvision
            updated = target.update()
            self.assertEqual(updated.imageGUID, target.imageGUID)
Ejemplo n.º 8
0
    def testCase2904(self):
        newvm = self.connection.getVM(self.TestVM_ID)
        target = VirtualMachine(self.connection)
        target.imageGUID = newvm.imageGUID

        # should be removed
        target.SecurityGroupGUID = newvm.SecurityGroupGUID
        target.autoProvision = newvm.autoProvision

        target.imageDescription = ''.join(
            random.choice(string.ascii_uppercase + string.digits)
            for x in range(361))
        updated = target.update()
        self.assertEqual(updated, None)
Ejemplo n.º 9
0
    def testCase2940(self):
        policy = SecurityGroup(self)
        policy.name = "testCase2940"
        # default values
        vm = VirtualMachine(self)
        vm.imageGUID = '245e35df-492a-40c8-8543-b07e1e252744'
        policy.addVM(vm)

        data = policy.tostring()
        policy = self.connection.get_object('%s/' % (self.connection.REST_SECURITY_GROUP),
                                            SecurityGroup, data=data, method='POST')

        # create policy
        self.assertEqual(policy, None)
Ejemplo n.º 10
0
    def testUpdateVM(self):
        self.vms = self.connection.listAllVM()

        for vm in self.vms:
            newvm = self.connection.getVM(vm.imageGUID)
            target = VirtualMachine(self.connection)
            target.imageGUID = newvm.imageGUID
            target.href = newvm.href
            target.imageDescription = ''.join(
                random.choice(string.ascii_uppercase + string.digits)
                for x in range(360))
            target.SecurityGroupGUID = newvm.SecurityGroupGUID
            target.autoProvision = newvm.autoProvision
            updated = target.update()
            self.assertEqual(updated.imageGUID, target.imageGUID)
Ejemplo n.º 11
0
    def testCase2940(self):
        policy = SecurityGroup(self)
        policy.name = "testCase2940"
        # default values
        vm = VirtualMachine(self)
        vm.imageGUID = '245e35df-492a-40c8-8543-b07e1e252744'
        policy.addVM(vm)

        data = policy.tostring()
        policy = self.connection.get_object(
            '%s/' % (self.connection.REST_SECURITY_GROUP),
            SecurityGroup,
            data=data,
            method='POST')

        # create policy
        self.assertEqual(policy, None)