Example #1
0
def _gen_query_action(resource):
    if resource == BACKUP_STORAGE:
        action = api_actions.QueryBackupStorageAction()
    elif resource == SFTP_BACKUP_STORAGE:
        action = api_actions.QuerySftpBackupStorageAction()
    elif resource == CEPH_BACKUP_STORAGE:
        action = api_actions.QueryCephBackupStorageAction()
    elif resource == ZONE:
        action = api_actions.QueryZoneAction()
    elif resource == PRIMARY_STORAGE:
        action = api_actions.QueryPrimaryStorageAction()
    elif resource == L2_NETWORK:
        action = api_actions.QueryL2NetworkAction()
    elif resource == L2_VLAN_NETWORK:
        action = api_actions.QueryL2VlanNetworkAction()
    elif resource == CLUSTER:
        action = api_actions.QueryClusterAction()
    elif resource == L3_NETWORK:
        action = api_actions.QueryL3NetworkAction()
    elif resource == INSTANCE_OFFERING:
        action = api_actions.QueryInstanceOfferingAction()
    elif resource == IMAGE:
        action = api_actions.QueryImageAction()
    elif resource == VOLUME:
        action = api_actions.QueryVolumeAction()
    elif resource == VM_INSTANCE:
        action = api_actions.QueryVmInstanceAction()
    elif resource == IP_RANGE:
        action = api_actions.QueryIpRangeAction()
    elif resource == HOST:
        action = api_actions.QueryHostAction()
    elif resource == NETWORK_SERVICE_PROVIDER:
        action = api_actions.QueryNetworkServiceProviderAction()
    elif resource == NETWORK_SERVICE_PROVIDER_L3_REF:
        action = api_actions.QueryNetworkServiceL3NetworkRefAction()
    elif resource == APPLIANCE_VM:
        action = api_actions.QueryApplianceVmAction()
    elif resource == VIRTUALROUTER_VM:
        action = api_actions.QueryVirtualRouterVmAction()
    elif resource == DISK_OFFERING:
        action = api_actions.QueryDiskOfferingAction()
    elif resource == ACCOUNT:
        action = api_actions.QueryAccountAction()
    elif resource == PRIMARY_STORAGE:
        action = api_actions.QueryPrimaryStorageAction()
    elif resource == CEPH_PRIMARY_STORAGE:
        action = api_actions.QueryCephPrimaryStorageAction()
    elif resource == SECURITY_GROUP:
        action = api_actions.QuerySecurityGroupAction()
    elif resource == SECURITY_GROUP_RULE:
        action = api_actions.QuerySecurityGroupRuleAction()
    elif resource == VM_SECURITY_GROUP:
        action = api_actions.QueryVmNicInSecurityGroupAction()
    elif resource == VM_NIC:
        action = api_actions.QueryVmNicAction()
    elif resource == PORT_FORWARDING:
        action = api_actions.QueryPortForwardingRuleAction()
    elif resource == MANAGEMENT_NODE:
        action = api_actions.QueryManagementNodeAction()
    elif resource == EIP:
        action = api_actions.QueryEipAction()
    elif resource == VIP:
        action = api_actions.QueryVipAction()
    elif resource == VR_OFFERING:
        action = api_actions.QueryVirtualRouterOfferingAction()
    elif resource == SYSTEM_TAG:
        action = api_actions.QuerySystemTagAction()
    elif resource == USER_TAG:
        action = api_actions.QueryUserTagAction()
    elif resource == VOLUME_SNAPSHOT_TREE:
        action = api_actions.QueryVolumeSnapshotTreeAction()
    elif resource == VOLUME_SNAPSHOT:
        action = api_actions.QueryVolumeSnapshotAction()
    elif resource == USER:
        action = api_actions.QueryUserAction()
    elif resource == LOAD_BALANCER:
        action = api_actions.QueryLoadBalancerAction()
    elif resource == LOAD_BALANCER_LISTENER:
        action = api_actions.QueryLoadBalancerListenerAction()
    elif resource == LOCAL_STORAGE_RESOURCE_REF:
        action = api_actions.QueryLocalStorageResourceRefAction()

    return action
Example #2
0
def query_vm(conditions=[], parameters=[]):
	action = api_actions.QueryVmInstanceAction()
	action.conditions = conditions
	action.parameters = parameters
	evt = zs.execute_action_with_session(action,zs.login_as_admin())
	return evt
Example #3
0
def _gen_query_action(resource, condition=None):
    if resource == BACKUP_STORAGE:
        action = api_actions.QueryBackupStorageAction()
    elif resource == SFTP_BACKUP_STORAGE:
        action = api_actions.QuerySftpBackupStorageAction()
    elif resource == CEPH_BACKUP_STORAGE:
        action = api_actions.QueryCephBackupStorageAction()
    elif resource == ZONE:
        action = api_actions.QueryZoneAction()
    elif resource == PRIMARY_STORAGE:
        action = api_actions.QueryPrimaryStorageAction()
    elif resource == L2_NETWORK:
        action = api_actions.QueryL2NetworkAction()
    elif resource == L2_VLAN_NETWORK:
        action = api_actions.QueryL2VlanNetworkAction()
    elif resource == L2_VXLAN_NETWORK:
        action = api_actions.QueryL2VxlanNetworkAction()
    elif resource == L2_VXLAN_NETWORK_POOL:
        action = api_actions.QueryL2VxlanNetworkPoolAction()
    elif resource == VNI_RANGE:
        action = api_actions.QueryVniRangeAction()
    elif resource == CLUSTER:
        action = api_actions.QueryClusterAction()
    elif resource == L3_NETWORK:
        action = api_actions.QueryL3NetworkAction()
    elif resource == INSTANCE_OFFERING:
        action = api_actions.QueryInstanceOfferingAction()
    elif resource == IMAGE:
        _lazyload_image(condition)
        action = api_actions.QueryImageAction()
    elif resource == VOLUME:
        action = api_actions.QueryVolumeAction()
    elif resource == SHARE_VOLUME:
        action = api_actions.QueryShareableVolumeVmInstanceRefAction()
    elif resource == VM_INSTANCE:
        action = api_actions.QueryVmInstanceAction()
    elif resource == IP_RANGE:
        action = api_actions.QueryIpRangeAction()
    elif resource == HOST:
        action = api_actions.QueryHostAction()
    elif resource == NETWORK_SERVICE_PROVIDER:
        action = api_actions.QueryNetworkServiceProviderAction()
    elif resource == NETWORK_SERVICE_PROVIDER_L3_REF:
        action = api_actions.QueryNetworkServiceL3NetworkRefAction()
    elif resource == APPLIANCE_VM:
        action = api_actions.QueryApplianceVmAction()
    elif resource == VIRTUALROUTER_VM:
        action = api_actions.QueryVirtualRouterVmAction()
    elif resource == DISK_OFFERING:
        action = api_actions.QueryDiskOfferingAction()
    elif resource == ACCOUNT:
        action = api_actions.QueryAccountAction()
    elif resource == CEPH_PRIMARY_STORAGE:
        action = api_actions.QueryCephPrimaryStorageAction()
    elif resource == CEPH_PRIMARY_STORAGE_POOL:
        action = api_actions.QueryCephPrimaryStoragePoolAction()
    elif resource == SECURITY_GROUP:
        action = api_actions.QuerySecurityGroupAction()
    elif resource == SECURITY_GROUP_RULE:
        action = api_actions.QuerySecurityGroupRuleAction()
    elif resource == VM_SECURITY_GROUP:
        action = api_actions.QueryVmNicInSecurityGroupAction()
    elif resource == VM_NIC:
        action = api_actions.QueryVmNicAction()
    elif resource == PORT_FORWARDING:
        action = api_actions.QueryPortForwardingRuleAction()
    elif resource == MANAGEMENT_NODE:
        action = api_actions.QueryManagementNodeAction()
    elif resource == EIP:
        action = api_actions.QueryEipAction()
    elif resource == VIP:
        action = api_actions.QueryVipAction()
    elif resource == VR_OFFERING:
        action = api_actions.QueryVirtualRouterOfferingAction()
    elif resource == SYSTEM_TAG:
        action = api_actions.QuerySystemTagAction()
    elif resource == USER_TAG:
        action = api_actions.QueryUserTagAction()
    elif resource == VOLUME_SNAPSHOT_TREE:
        action = api_actions.QueryVolumeSnapshotTreeAction()
    elif resource == VOLUME_SNAPSHOT:
        action = api_actions.QueryVolumeSnapshotAction()
    elif resource == USER:
        action = api_actions.QueryUserAction()
    elif resource == LOAD_BALANCER:
        action = api_actions.QueryLoadBalancerAction()
    elif resource == LOAD_BALANCER_LISTENER:
        action = api_actions.QueryLoadBalancerListenerAction()
    elif resource == LOCAL_STORAGE_RESOURCE_REF:
        action = api_actions.QueryLocalStorageResourceRefAction()
    elif resource == IMAGE_STORE_BACKUP_STORAGE:
        action = api_actions.QueryImageStoreBackupStorageAction()
    elif resource == SCHEDULER:
        action = api_actions.QuerySchedulerAction()
    elif resource == SCHEDULERJOB:
        action = api_actions.QuerySchedulerJobAction()
    elif resource == SCHEDULERTRIGGER:
        action = api_actions.QuerySchedulerTriggerAction()
    elif resource == VCENTER:
        action = api_actions.QueryVCenterAction()
    elif resource == VCENTER_CLUSTER:
        action = api_actions.QueryVCenterClusterAction()
    elif resource == VCENTER_BACKUP_STORAGE:
        action = api_actions.QueryVCenterBackupStorageAction()
    elif resource == VCENTER_PRIMARY_STORAGE:
        action = api_actions.QueryVCenterPrimaryStorageAction()
    elif resource == MONITOR_TRIGGER:
        action = api_actions.QueryMonitorTriggerAction()
    elif resource == MONITOR_TRIGGER_ACTION:
        action = api_actions.QueryMonitorTriggerActionAction()
    elif resource == PXE_SERVER:
        action = api_actions.QueryBaremetalPxeServerAction()
    elif resource == CHASSIS:
        action = api_actions.QueryBaremetalChassisAction()
    elif resource == HWINFO:
        action = api_actions.QueryBaremetalHardwareInfoAction()
    elif resource == BAREMETAL_INS:
        action = api_actions.QueryBaremetalInstanceAction()
    elif resource == LONGJOB:
        action = api_actions.QueryLongJobAction()
    elif resource == ALARM:
        action = api_actions.QueryAlarmAction()
    elif resource == EVENT_SUBSCRIPTION:
        action = api_actions.QueryEventSubscriptionAction()
    elif resource == SNS_APPLICATION_ENDPOINT:
        action = api_actions.QuerySNSApplicationEndpointAction()
    elif resource == SNS_APPLICATION_PLATFORM:
        action = api_actions.QuerySNSApplicationPlatformAction()
    elif resource == SNS_TOPIC:
        action = api_actions.QuerySNSTopicAction()
    elif resource == SNS_TOPIC_SUBSCRIBER:
        action = api_actions.QuerySNSTopicSubscriberAction()
    elif resource == SNS_DING_TALK_ENDPOINT:
        action = api_actions.QuerySNSDingTalkEndpointAction()
    elif resource == SNS_EMAIL_ENDPOINT:
        action = api_actions.QuerySNSEmailEndpointAction()
    elif resource == SNS_EMAIL_PLATFORM:
        action = api_actions.QuerySNSEmailPlatformAction()
    elif resource == SNS_HTTP_ENDPOINT:
        action = api_actions.QuerySNSHttpEndpointAction()
    elif resource == SNS_TEXT_TEMPLATE:
        action = api_actions.QuerySNSTextTemplateAction()
    elif resource == AFFINITY_GROUP:
        action = api_actions.QueryAffinityGroupAction()
    elif resource == IAM2_ORGANIZATION:
        action = api_actions.QueryIAM2OrganizationAction()
    elif resource == IAM2_PROJECT:
        action = api_actions.QueryIAM2ProjectAction()
    elif resource == IAM2_VIRTUAL_ID_GROUP:
        action = api_actions.QueryIAM2VirtualIDGroupAction()
    elif resource == IAM2_VIRTUAL_ID:
        action = api_actions.QueryIAM2VirtualIDAction()
    elif resource == IAM2_PROJECT_TEMPLATE:
        action = api_actions.QueryIAM2ProjectTemplateAction()
    elif resource == IAM2_VIRTUAL_ID_GROUP_ATTRIBUTE:
        action = api_actions.QueryIAM2VirtualIDGroupAttributeAction()
    elif resource == IAM2_VIRTUAL_ID_ATTRIBUTE:
        action = api_actions.QueryIAM2VirtualIDAttributeAction()
    elif resource == IAM2_PROJECT_ATTRIBUTE:
        action = api_actions.QueryIAM2ProjectAttributeAction()
    elif resource == IAM2_ORGANIZATION_ATTRIBUTE:
        action = api_actions.QueryIAM2OrganizationAttributeAction()
    elif resource == ROLE:
        action = api_actions.QueryRoleAction()
    elif resource == DATACENTER:
        action = api_actions.QueryDataCenterFromLocalAction()
    elif resource == ALIYUNNAS_ACCESSGROUP:
        action = api_actions.QueryAliyunNasAccessGroupAction()
    elif resource == NAS_FILESYSTEM:
        action = api_actions.QueryNasFileSystemAction()
    elif resource == NAS_MOUNTTARGET:
        action = api_actions.QueryNasMountTargetAction()
    elif resource == STACK_TEMPLATE:
        action = api_actions.QueryStackTemplateAction()
    elif resource == RESOURCE_STACK:
        action = api_actions.QueryResourceStackAction()
    elif resource == EVENT_FROM_STACK:
        action = api_actions.QueryEventFromResourceStackAction()
    elif resource == TICKET:
        action = api_actions.QueryTicketAction()
    elif resource == TICKET_HISTORY:
        action = api_actions.QueryTicketHistoryAction()
    elif resource == QUOTA:
        action = api_actions.QueryQuotaAction()
    elif resource == CERTIFICATE:
        action = api_actions.QueryCertificateAction()
    elif resource == VOLUME_BACKUP:
        action = api_actions.QueryVolumeBackupAction()
    elif resource == IPSEC_CONNECTION:
        action = api_actions.QueryIPSecConnectionAction()
    return action
Example #4
0
def query_vm_by_host(host_uuid, conditions = [], session_uuid = None):
    action = api_actions.QueryVmInstanceAction()
    action.conditions = gen_query_conditions('hostUuid', '=', host_uuid, conditions)
    evt = execute_action_with_session(action, session_uuid)
    return evt.inventories
Example #5
0
def _gen_query_action(resource, condition=None):
    if resource == BACKUP_STORAGE:
        action = api_actions.QueryBackupStorageAction()
    elif resource == SFTP_BACKUP_STORAGE:
        action = api_actions.QuerySftpBackupStorageAction()
    elif resource == CEPH_BACKUP_STORAGE:
        action = api_actions.QueryCephBackupStorageAction()
    elif resource == ZONE:
        action = api_actions.QueryZoneAction()
    elif resource == PRIMARY_STORAGE:
        action = api_actions.QueryPrimaryStorageAction()
    elif resource == L2_NETWORK:
        action = api_actions.QueryL2NetworkAction()
    elif resource == L2_VLAN_NETWORK:
        action = api_actions.QueryL2VlanNetworkAction()
    elif resource == L2_VXLAN_NETWORK:
        action = api_actions.QueryL2VxlanNetworkAction()
    elif resource == L2_VXLAN_NETWORK_POOL:
        action = api_actions.QueryL2VxlanNetworkPoolAction()
    elif resource == VNI_RANGE:
        action = api_actions.QueryVniRangeAction()
    elif resource == CLUSTER:
        action = api_actions.QueryClusterAction()
    elif resource == L3_NETWORK:
        action = api_actions.QueryL3NetworkAction()
    elif resource == INSTANCE_OFFERING:
        action = api_actions.QueryInstanceOfferingAction()
    elif resource == IMAGE:
        _lazyload_image(condition)
        action = api_actions.QueryImageAction()
    elif resource == VOLUME:
        action = api_actions.QueryVolumeAction()
    elif resource == SHARE_VOLUME:
        action = api_actions.QueryShareableVolumeVmInstanceRefAction()
    elif resource == VM_INSTANCE:
        action = api_actions.QueryVmInstanceAction()
    elif resource == IP_RANGE:
        action = api_actions.QueryIpRangeAction()
    elif resource == HOST:
        action = api_actions.QueryHostAction()
    elif resource == NETWORK_SERVICE_PROVIDER:
        action = api_actions.QueryNetworkServiceProviderAction()
    elif resource == NETWORK_SERVICE_PROVIDER_L3_REF:
        action = api_actions.QueryNetworkServiceL3NetworkRefAction()
    elif resource == APPLIANCE_VM:
        action = api_actions.QueryApplianceVmAction()
    elif resource == VIRTUALROUTER_VM:
        action = api_actions.QueryVirtualRouterVmAction()
    elif resource == DISK_OFFERING:
        action = api_actions.QueryDiskOfferingAction()
    elif resource == ACCOUNT:
        action = api_actions.QueryAccountAction()
    elif resource == CEPH_PRIMARY_STORAGE:
        action = api_actions.QueryCephPrimaryStorageAction()
    elif resource == CEPH_PRIMARY_STORAGE_POOL:
        action = api_actions.QueryCephPrimaryStoragePoolAction()
    elif resource == SECURITY_GROUP:
        action = api_actions.QuerySecurityGroupAction()
    elif resource == SECURITY_GROUP_RULE:
        action = api_actions.QuerySecurityGroupRuleAction()
    elif resource == VM_SECURITY_GROUP:
        action = api_actions.QueryVmNicInSecurityGroupAction()
    elif resource == VM_NIC:
        action = api_actions.QueryVmNicAction()
    elif resource == PORT_FORWARDING:
        action = api_actions.QueryPortForwardingRuleAction()
    elif resource == MANAGEMENT_NODE:
        action = api_actions.QueryManagementNodeAction()
    elif resource == EIP:
        action = api_actions.QueryEipAction()
    elif resource == VIP:
        action = api_actions.QueryVipAction()
    elif resource == VR_OFFERING:
        action = api_actions.QueryVirtualRouterOfferingAction()
    elif resource == SYSTEM_TAG:
        action = api_actions.QuerySystemTagAction()
    elif resource == USER_TAG:
        action = api_actions.QueryUserTagAction()
    elif resource == VOLUME_SNAPSHOT_TREE:
        action = api_actions.QueryVolumeSnapshotTreeAction()
    elif resource == VOLUME_SNAPSHOT:
        action = api_actions.QueryVolumeSnapshotAction()
    elif resource == USER:
        action = api_actions.QueryUserAction()
    elif resource == LOAD_BALANCER:
        action = api_actions.QueryLoadBalancerAction()
    elif resource == LOAD_BALANCER_LISTENER:
        action = api_actions.QueryLoadBalancerListenerAction()
    elif resource == LOCAL_STORAGE_RESOURCE_REF:
        action = api_actions.QueryLocalStorageResourceRefAction()
    elif resource == IMAGE_STORE_BACKUP_STORAGE:
        action = api_actions.QueryImageStoreBackupStorageAction()
    elif resource == SCHEDULER:
        action = api_actions.QuerySchedulerAction()
    elif resource == SCHEDULERJOB:
        action = api_actions.QuerySchedulerJobAction()
    elif resource == SCHEDULERTRIGGER:
        action = api_actions.QuerySchedulerTriggerAction()
    elif resource == VCENTER:
        action = api_actions.QueryVCenterAction()
    elif resource == VCENTER_CLUSTER:
        action = api_actions.QueryVCenterClusterAction()
    elif resource == VCENTER_BACKUP_STORAGE:
        action = api_actions.QueryVCenterBackupStorageAction()
    elif resource == VCENTER_PRIMARY_STORAGE:
        action = api_actions.QueryVCenterPrimaryStorageAction()
    elif resource == MONITOR_TRIGGER:
        action = api_actions.QueryMonitorTriggerAction()
    elif resource == MONITOR_TRIGGER_ACTION:
        action = api_actions.QueryMonitorTriggerActionAction()
    elif resource == PXE_SERVER:
        action = api_actions.QueryBaremetalPxeServerAction()
    elif resource == CHASSIS:
        action = api_actions.QueryBaremetalChassisAction()
    elif resource == HWINFO:
        action = api_actions.QueryBaremetalHardwareInfoAction()

    return action